AdminPatentApiController.java 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. package com.goafanti.admin.controller;
  2. import java.io.IOException;
  3. import java.text.ParseException;
  4. import java.util.Arrays;
  5. import java.util.Calendar;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.TreeMap;
  11. import java.util.UUID;
  12. import javax.annotation.Resource;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import javax.validation.Valid;
  16. import org.apache.commons.lang3.time.DateUtils;
  17. import org.apache.poi.hssf.usermodel.HSSFCell;
  18. import org.apache.poi.hssf.usermodel.HSSFRow;
  19. import org.apache.poi.hssf.usermodel.HSSFSheet;
  20. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  21. import org.apache.poi.ss.util.CellRangeAddress;
  22. import org.springframework.beans.BeanUtils;
  23. import org.springframework.beans.factory.annotation.Value;
  24. import org.springframework.validation.BindingResult;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.RequestMethod;
  27. import org.springframework.web.bind.annotation.RequestParam;
  28. import org.springframework.web.bind.annotation.RestController;
  29. import org.springframework.web.multipart.MultipartFile;
  30. import com.alibaba.fastjson.JSON;
  31. import com.goafanti.admin.service.AdminService;
  32. import com.goafanti.admin.service.AftFileService;
  33. import com.goafanti.cognizance.service.OrgIntellectualPropertyService;
  34. import com.goafanti.cognizance.service.OrgRatepayService;
  35. import com.goafanti.common.bo.Result;
  36. import com.goafanti.common.constant.AFTConstants;
  37. import com.goafanti.common.constant.ErrorConstants;
  38. import com.goafanti.common.controller.CertifyApiController;
  39. import com.goafanti.common.enums.AttachmentType;
  40. import com.goafanti.common.enums.DeleteStatus;
  41. import com.goafanti.common.enums.PatentAnnualFeeStatus;
  42. import com.goafanti.common.enums.PatentApplicationFeeStatus;
  43. import com.goafanti.common.enums.PatentCategoryStatus;
  44. import com.goafanti.common.enums.PatentCostFields;
  45. import com.goafanti.common.enums.PatentFundsStatus;
  46. import com.goafanti.common.enums.PatentInfoFields;
  47. import com.goafanti.common.enums.PatentInfoStatus;
  48. import com.goafanti.common.enums.PatentRegistrationFields;
  49. import com.goafanti.common.enums.PatentReimbursementStatus;
  50. import com.goafanti.common.model.Admin;
  51. import com.goafanti.common.model.AftFile;
  52. import com.goafanti.common.model.DistrictGlossory;
  53. import com.goafanti.common.model.OrgRatepay;
  54. import com.goafanti.common.model.OrganizationIdentity;
  55. import com.goafanti.common.model.PatentCost;
  56. import com.goafanti.common.model.PatentInfo;
  57. import com.goafanti.common.model.PatentLog;
  58. import com.goafanti.common.model.PatentRegistration;
  59. import com.goafanti.common.model.User;
  60. import com.goafanti.common.utils.FileUtils;
  61. import com.goafanti.common.utils.LoggerUtils;
  62. import com.goafanti.common.utils.StringUtils;
  63. import com.goafanti.core.mybatis.page.Pagination;
  64. import com.goafanti.core.shiro.token.TokenManager;
  65. import com.goafanti.dataGlossory.service.DistrictGlossoryService;
  66. import com.goafanti.patent.bo.InputPatentCost;
  67. import com.goafanti.patent.bo.InputPatentInfo;
  68. import com.goafanti.patent.bo.InputPatentRegistration;
  69. import com.goafanti.patent.bo.PatentApplicationFeeBo;
  70. import com.goafanti.patent.bo.PatentManageListBo;
  71. import com.goafanti.patent.bo.PatentPendingBo;
  72. import com.goafanti.patent.service.PatentCostService;
  73. import com.goafanti.patent.service.PatentInfoService;
  74. import com.goafanti.patent.service.PatentLogService;
  75. import com.goafanti.patent.service.PatentRegistrationService;
  76. import com.goafanti.user.service.OrganizationIdentityService;
  77. import com.goafanti.user.service.UserService;
  78. @RestController
  79. @RequestMapping(value = "/api/admin/patent")
  80. public class AdminPatentApiController extends CertifyApiController {
  81. @Resource
  82. private PatentInfoService patentInfoService;
  83. @Resource
  84. private PatentLogService patentLogService;
  85. @Resource
  86. private OrganizationIdentityService organizationIdentityServivce;
  87. @Resource
  88. private PatentCostService patentCostService;
  89. @Resource
  90. private PatentRegistrationService patentRegistrationService;
  91. @Resource
  92. private AdminService adminService;
  93. @Resource
  94. private OrgIntellectualPropertyService orgIntellectualPropertyService;
  95. @Resource
  96. private UserService userService;
  97. @Resource
  98. private AftFileService aftFileService;
  99. @Resource
  100. private OrgRatepayService orgRatepayService;
  101. @Resource
  102. private OrganizationIdentityService organizationIdentityService;
  103. @Resource
  104. private DistrictGlossoryService districtGlossoryService;
  105. @Value(value = "${aesSecretKey}")
  106. private String secretKey = null;
  107. /**
  108. * 专利批量流转
  109. *
  110. * @return
  111. */
  112. @RequestMapping(value = "/circulation", method = RequestMethod.POST)
  113. public Result circulation(@RequestParam(name = "ids[]", required = false) String[] ids, @Valid InputPatentInfo pi,
  114. BindingResult bindingResult, String recordTimeFormattedDate) {
  115. Result res = new Result();
  116. if (bindingResult.hasErrors()) {
  117. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  118. PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
  119. return res;
  120. }
  121. if (ids == null || ids.length < 1) {
  122. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  123. return res;
  124. }
  125. if (null == pi.getState()) {
  126. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到流转状态", "流转状态"));
  127. return res;
  128. }
  129. if (StringUtils.isBlank(pi.getPrincipal())) {
  130. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到负责人", "负责人"));
  131. return res;
  132. }
  133. if (StringUtils.isBlank(recordTimeFormattedDate)) {
  134. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到记录流转时间", "记录流转时间"));
  135. return res;
  136. }
  137. if (PatentInfoStatus.DELIVERD.getCode() != pi.getState()
  138. && PatentInfoStatus.CIRCULATION.getCode() != pi.getState()
  139. && PatentInfoStatus.SETTLEMENT.getCode() != pi.getState()) {
  140. res.getError().add(buildError(ErrorConstants.STATUS_ERROR, "仅派单、流转、结款可操作!"));
  141. return res;
  142. }
  143. PatentLog pl = new PatentLog();
  144. BeanUtils.copyProperties(pi, pl);
  145. res.setData(patentInfoService.batchCirculation(ids, recordTimeFormattedDate, pl));
  146. return res;
  147. }
  148. /**
  149. * 专利列表
  150. *
  151. * @throws ParseException
  152. */
  153. @RequestMapping(value = "/patentList", method = RequestMethod.GET)
  154. public Result patentList(String contractId, Integer serialNumber, String patentNumber, String office,
  155. Integer locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  156. String uid, @RequestParam(name = "createTime[]", required = false) String[] createTime,
  157. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  158. String author, String pageNo, String pageSize) {
  159. Result res = new Result();
  160. Integer pNo = 1;
  161. Integer pSize = 10;
  162. if (StringUtils.isNumeric(pageSize)) {
  163. pSize = Integer.parseInt(pageSize);
  164. }
  165. if (StringUtils.isNumeric(pageNo)) {
  166. pNo = Integer.parseInt(pageNo);
  167. }
  168. res.setData(patentInfoService.getManagePatentList(contractId, serialNumber, patentNumber, office,
  169. locationProvince, unitName, patentCatagory, patentName, patentState, createTime, patentApplicationDate,
  170. author, uid, pNo, pSize));
  171. return res;
  172. }
  173. /**
  174. * 新增专利申请
  175. */
  176. @RequestMapping(value = "/apply", method = RequestMethod.POST)
  177. public Result manageApplyPatent(@Valid InputPatentInfo patentInfo, BindingResult bindingResult) {
  178. Result res = new Result();
  179. if (bindingResult.hasErrors()) {
  180. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  181. PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
  182. return res;
  183. }
  184. if (StringUtils.isBlank(patentInfo.getUid())) {
  185. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  186. return res;
  187. }
  188. if (StringUtils.isBlank(patentInfo.getSalesman())) {
  189. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到营销员", "营销员"));
  190. return res;
  191. }
  192. String salesman = patentInfo.getSalesman();
  193. User curUser = userService.selectByPrimaryKey(patentInfo.getUid());
  194. if (!checkCertify(res, curUser)) {
  195. return res;
  196. }
  197. PatentInfo pi = new PatentInfo();
  198. BeanUtils.copyProperties(patentInfo, pi);
  199. res.setData(patentInfoService.savePatentInfo(pi, salesman));
  200. return res;
  201. }
  202. /**
  203. * 专利详情
  204. *
  205. * @param pid
  206. * @return
  207. */
  208. @RequestMapping(value = "/detail", method = RequestMethod.GET)
  209. public Result patentDetail(String pid) {
  210. Result res = new Result();
  211. if (StringUtils.isBlank(pid)) {
  212. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID"));
  213. } else {
  214. res.setData(patentInfoService.selectPatentInfoDetail(pid));
  215. }
  216. return res;
  217. }
  218. /**
  219. * 管理端logs
  220. */
  221. @RequestMapping(value = "/logs", method = RequestMethod.GET)
  222. public Result patentProcess(String pid) {
  223. Result res = new Result();
  224. if (StringUtils.isBlank(pid)) {
  225. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID"));
  226. } else {
  227. res.setData(patentLogService.selectProcessByPid(pid));
  228. }
  229. return res;
  230. }
  231. /**
  232. * 专利详情修改保存
  233. *
  234. * @throws ParseException
  235. */
  236. @RequestMapping(value = "/update", method = RequestMethod.POST)
  237. public Result managePatentInfo(@Valid InputPatentInfo patentInfo, BindingResult bindingResult,
  238. String recordTimeFormattedDate) {
  239. Result res = new Result();
  240. if (bindingResult.hasErrors()) {
  241. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  242. PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
  243. return res;
  244. }
  245. if (StringUtils.isBlank(patentInfo.getId())) {
  246. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  247. return res;
  248. }
  249. PatentInfo p = patentInfoService.selectByPrimaryKey(patentInfo.getId());
  250. if (null == p) {
  251. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  252. return res;
  253. }
  254. if (PatentInfoStatus.CALLBACK.getCode() == p.getPatentState()) {
  255. res.getError().add(buildError(ErrorConstants.RECORD_CALLBACK, "当前申请已退单,无法修改!"));
  256. return res;
  257. }
  258. if (PatentInfoStatus.SETTLEMENT.getCode() == p.getPatentState()) {
  259. res.getError().add(buildError(ErrorConstants.RECORD_SETTLEMENT, "当前申请已结款,无法修改!"));
  260. return res;
  261. }
  262. Date recordTime = null;
  263. if (!StringUtils.isBlank(recordTimeFormattedDate)) {
  264. try {
  265. recordTime = DateUtils.parseDate(recordTimeFormattedDate, AFTConstants.YYYYMMDDHHMMSS);
  266. } catch (ParseException e) {
  267. }
  268. }
  269. PatentInfo pi = new PatentInfo();
  270. PatentLog pl = new PatentLog();
  271. pi.setId(patentInfo.getId());
  272. BeanUtils.copyProperties(patentInfo, pi);
  273. BeanUtils.copyProperties(patentInfo, pl);
  274. patentInfoService.updatePatentInfo(pi, pl, recordTime);
  275. return res;
  276. }
  277. /**
  278. * 专利状态流转下拉
  279. *
  280. * @return
  281. */
  282. @RequestMapping(value = "/patentStatus", method = RequestMethod.GET)
  283. public Result patentStatus() {
  284. Result res = new Result();
  285. res.setData(disposePatentStatus());
  286. return res;
  287. }
  288. /**
  289. * 上年度纳税申报报表是否存在
  290. *
  291. * @param uid
  292. * @param sign
  293. * @return
  294. */
  295. @RequestMapping(value = "/lastYearTax", method = RequestMethod.GET)
  296. public Result lastYearTax(String uid, String sign) {
  297. Result res = new Result();
  298. if (StringUtils.isBlank(uid)) {
  299. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
  300. return res;
  301. }
  302. AttachmentType attachmentType = AttachmentType.getField(sign);
  303. if (attachmentType != AttachmentType.LAST_YEAR_RATEPAY) {
  304. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  305. return res;
  306. }
  307. Calendar cal = Calendar.getInstance();
  308. OrgRatepay ratepay = orgRatepayService.selectRatepayByUidAndYear(uid, cal.get(Calendar.YEAR) - 1);
  309. if (null == ratepay || StringUtils.isBlank(ratepay.getTaxReturnUrl())) {
  310. return res;
  311. }
  312. Map<String, String> map = new TreeMap<String, String>();
  313. map.put("id", ratepay.getId());
  314. map.put("year", ratepay.getYear().toString());
  315. res.setData(map);
  316. return res;
  317. }
  318. /**
  319. * 专利相关材料上传(专利稿件,授权通知书,专利证书)
  320. *
  321. * @param req
  322. * @param uid
  323. * @param sign
  324. * @return
  325. */
  326. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  327. public Result upload(HttpServletRequest req, String sign, String uid, String id) {
  328. Result res = new Result();
  329. User curUser = userService.selectByPrimaryKey(uid);
  330. if (!checkCertify(res, curUser)) {
  331. return res;
  332. }
  333. if (StringUtils.isBlank(id)) {
  334. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  335. return res;
  336. }
  337. PatentInfo p = patentInfoService.selectByPrimaryKey(id);
  338. if (null == p) {
  339. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  340. return res;
  341. }
  342. if (PatentInfoStatus.CALLBACK.getCode() == p.getPatentState()) {
  343. res.getError().add(buildError(ErrorConstants.RECORD_CALLBACK, "当前申请已退单,无法修改!"));
  344. return res;
  345. }
  346. if (PatentInfoStatus.SETTLEMENT.getCode() == p.getPatentState()) {
  347. res.getError().add(buildError(ErrorConstants.RECORD_SETTLEMENT, "当前申请已结款,无法修改!"));
  348. return res;
  349. }
  350. AttachmentType attachmentType = AttachmentType.getField(sign);
  351. if (attachmentType == AttachmentType.PATENT_WRITING || attachmentType == AttachmentType.AUTHORIZATION_NOTICE
  352. || attachmentType == AttachmentType.PATENT_CERTIFICATE) {
  353. res.setData(handleFiles(res, "/patent/", true, req, sign, uid));
  354. } else {
  355. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  356. }
  357. return res;
  358. }
  359. /**
  360. * 新增专利申请上传专利代理委托书
  361. *
  362. * @param req
  363. * @param sign
  364. * @param uid
  365. * @return
  366. */
  367. @RequestMapping(value = "/uploadProry", method = RequestMethod.POST)
  368. public Result uploadProry(HttpServletRequest req, String sign, String uid) {
  369. Result res = new Result();
  370. User curUser = userService.selectByPrimaryKey(uid);
  371. if (!checkCertify(res, curUser)) {
  372. return res;
  373. }
  374. AttachmentType attachmentType = AttachmentType.getField(sign);
  375. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  376. res.setData(handleFiles(res, "/patent/", true, req, sign, uid));
  377. } else {
  378. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  379. }
  380. return res;
  381. }
  382. /**
  383. * 下载专利相关材料
  384. *
  385. * @param id
  386. * @param sign
  387. * @param response
  388. * @return
  389. */
  390. @RequestMapping(value = "/download", method = RequestMethod.GET)
  391. public Result download(String id, String sign, HttpServletResponse response) {
  392. Result res = new Result();
  393. if (StringUtils.isEmpty(id)) {
  394. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id"));
  395. return res;
  396. }
  397. PatentInfo pi = patentInfoService.selectByPrimaryKey(id);
  398. if (pi == null) {
  399. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id"));
  400. return res;
  401. }
  402. AttachmentType attachmentType = AttachmentType.getField(sign);
  403. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT || attachmentType == AttachmentType.PATENT_WRITING
  404. || attachmentType == AttachmentType.AUTHORIZATION_NOTICE
  405. || attachmentType == AttachmentType.PATENT_CERTIFICATE) {
  406. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  407. OrganizationIdentity oi = organizationIdentityService.selectOrgIdentityByUserId(pi.getUid());
  408. downloadFile(response, oi.getPatentProryStatementDownloadFileName(), oi.getPatentProryStatementUrl());
  409. } else if (attachmentType == AttachmentType.PATENT_WRITING) {
  410. downloadFile(response, pi.getPatentWritingDownloadFileName(), pi.getPatentWritingUrl());
  411. } else if (attachmentType == AttachmentType.AUTHORIZATION_NOTICE) {
  412. downloadFile(response, pi.getAuthorizationNoticeDownloadFileName(), pi.getAuthorizationNoticeUrl());
  413. } else if (attachmentType == AttachmentType.PATENT_CERTIFICATE) {
  414. downloadFile(response, pi.getPatentCertificateDownloadFileName(), pi.getPatentCertificateUrl());
  415. }
  416. } else {
  417. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  418. }
  419. return res;
  420. }
  421. /**
  422. * 下载模版文件(专利代理委托书)
  423. *
  424. * @param response
  425. * @return
  426. */
  427. @RequestMapping(value = "/downloadTemplateFile", method = RequestMethod.GET)
  428. public Result downloadTemplateFile(HttpServletResponse response, String sign) {
  429. Result res = new Result();
  430. AttachmentType attachmentType = AttachmentType.getField(sign);
  431. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  432. String fileName = "";
  433. AftFile af = aftFileService.selectAftFileBySign(sign);
  434. if (null == af) {
  435. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
  436. } else {
  437. String path = af.getFilePath();
  438. String suffix = path.substring(path.lastIndexOf("."));
  439. fileName = AttachmentType.PATENT_TEMPLATE.getDesc() + suffix;
  440. downloadFile(response, fileName, path);
  441. }
  442. } else {
  443. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  444. }
  445. return res;
  446. }
  447. /**
  448. * 下载上年度纳税申报表
  449. *
  450. * @param response
  451. * @param uid
  452. * @param year
  453. * @param sign
  454. * @return
  455. */
  456. @RequestMapping(value = "/downloadRatepay", method = RequestMethod.GET)
  457. public Result downloadRatepay(HttpServletResponse response, String id, String sign) {
  458. Result res = new Result();
  459. if (StringUtils.isBlank(id)) {
  460. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "纳税表ID"));
  461. return res;
  462. }
  463. OrgRatepay ratepay = orgRatepayService.selectByPrimaryKey(id);
  464. if (null == ratepay) {
  465. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到上年度纳税申报表", "上年度纳税申报表"));
  466. return res;
  467. }
  468. AttachmentType attachmentType = AttachmentType.getField(sign);
  469. if (attachmentType == AttachmentType.LAST_YEAR_RATEPAY) {
  470. downloadFile(response, ratepay.getTaxReturnDownloadFileName(), ratepay.getTaxReturnUrl());
  471. } else {
  472. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  473. }
  474. return res;
  475. }
  476. /**
  477. * 上传专利代理委托书模版
  478. *
  479. * @param req
  480. * @return
  481. */
  482. @RequestMapping(value = "/uploadTemplate", method = RequestMethod.POST)
  483. public Result uploadPatentTemplate(HttpServletRequest req, String sign) {
  484. Result res = new Result();
  485. String fileName = "";
  486. List<MultipartFile> files = getFiles(req);
  487. MultipartFile mf = files.get(0);
  488. String suffix = mf.getOriginalFilename().substring(mf.getOriginalFilename().lastIndexOf("."));
  489. if (suffix.equals(".doc") || suffix.equals(".docx")) {
  490. AttachmentType attachmentType = AttachmentType.getField(sign);
  491. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  492. fileName = sign + suffix;
  493. } else {
  494. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  495. return res;
  496. }
  497. String name = handleFile(res, req, fileName, files, mf);
  498. res.setData(name);
  499. if (!StringUtils.isBlank(name) && null == aftFileService.selectAftFileBySign(sign)) {
  500. AftFile f = new AftFile();
  501. f.setId(UUID.randomUUID().toString());
  502. f.setFileName(AttachmentType.PATENT_TEMPLATE.getDesc());
  503. f.setSign(sign);
  504. f.setUid(TokenManager.getAdminId());
  505. f.setComment(AttachmentType.PATENT_TEMPLATE.getDesc());
  506. f.setFilePath("/admin/" + fileName);
  507. f.setDeleletedSign(DeleteStatus.UNDELETE.getCode());
  508. aftFileService.insert(f);
  509. }
  510. } else {
  511. res.getError().add(buildError(ErrorConstants.FILE_PATTERN_ERROR, "文件格式错误,请重新上传!"));
  512. }
  513. return res;
  514. }
  515. /**
  516. * 删除专利
  517. *
  518. * @param ids
  519. * @return
  520. */
  521. @RequestMapping(value = "/delete", method = RequestMethod.POST)
  522. public Result deletePatent(@RequestParam(name = "ids[]", required = false) String[] ids) {
  523. Result res = new Result();
  524. if (ids == null || ids.length < 1) {
  525. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", ""));
  526. } else {
  527. res.setData(patentInfoService.batchDeleteByPrimaryKey(Arrays.asList(ids)));
  528. }
  529. return res;
  530. }
  531. /**
  532. * 待缴费专利管理列表
  533. */
  534. @RequestMapping(value = "/pendingPaymentList", method = RequestMethod.GET)
  535. public Result managePendingPaymentList(Integer locationProvince, String pageNo, String pageSize) {
  536. Result res = new Result();
  537. Integer pNo = 1;
  538. Integer pSize = 10;
  539. if (StringUtils.isNumeric(pageSize)) {
  540. pSize = Integer.parseInt(pageSize);
  541. }
  542. if (StringUtils.isNumeric(pageNo)) {
  543. pNo = Integer.parseInt(pageNo);
  544. }
  545. res.setData(patentInfoService.getManagePendingPaymentList(locationProvince, pNo, pSize));
  546. return res;
  547. }
  548. /**
  549. * 年费确认缴费
  550. */
  551. @RequestMapping(value = "/confirmPayment", method = RequestMethod.POST)
  552. public Result confirmPayment(String cid, String uid) {
  553. Result res = new Result();
  554. if (StringUtils.isBlank(cid) || StringUtils.isBlank(uid)) {
  555. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  556. return res;
  557. }
  558. PatentCost cost = patentCostService.selectByPrimaryKey(cid);
  559. if (null == cost) {
  560. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  561. return res;
  562. }
  563. if (null == cost.getPid()) {
  564. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  565. return res;
  566. }
  567. PatentInfo info = patentInfoService.selectByPrimaryKey(cost.getPid());
  568. if (!uid.equals(info.getUid())) {
  569. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  570. return res;
  571. }
  572. if (PatentInfoStatus.CALLBACK.getCode() == info.getPatentState()) {
  573. res.getError().add(buildError(ErrorConstants.RECORD_CALLBACK, "当前申请已退单,无法修改!"));
  574. return res;
  575. }
  576. if (PatentInfoStatus.SETTLEMENT.getCode() == info.getPatentState()) {
  577. res.getError().add(buildError(ErrorConstants.RECORD_SETTLEMENT, "当前申请已结款,无法修改!"));
  578. return res;
  579. }
  580. PatentCost patentCost = new PatentCost();
  581. patentCost.setId(cid);
  582. patentCost.setAnnualFeeState(1);
  583. patentCostService.updateByPrimaryKeySelective(patentCost);
  584. return res;
  585. }
  586. /**
  587. * 补正审查通知列表
  588. */
  589. @RequestMapping(value = "/noticeOfCorrectionList", method = RequestMethod.POST)
  590. public Result noticeOfCorrectionList(Date authorizedDate, Integer serialNumber, String patentNumber, String office,
  591. Integer locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  592. String author, String pageNo, String pageSize) {
  593. Result res = new Result();
  594. Integer pNo = 1;
  595. Integer pSize = 10;
  596. if (StringUtils.isNumeric(pageSize)) {
  597. pSize = Integer.parseInt(pageSize);
  598. }
  599. if (StringUtils.isNumeric(pageNo)) {
  600. pNo = Integer.parseInt(pageNo);
  601. }
  602. res.setData(patentInfoService.getNoticeOfCorrectionList(authorizedDate, serialNumber, patentNumber, office,
  603. locationProvince, unitName, patentCatagory, patentName, patentState, author, pNo, pSize));
  604. return res;
  605. }
  606. /**
  607. * 补正审查通知答复确认
  608. */
  609. @RequestMapping(value = "/replyConfirm", method = RequestMethod.POST)
  610. public Result replyConfirm(String pid, String uid, Integer patentState) {
  611. Result res = new Result();
  612. if (StringUtils.isBlank(pid) || StringUtils.isBlank(uid)) {
  613. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  614. return res;
  615. }
  616. if (null == patentState || (patentState != PatentInfoStatus.REVIEWNOTICE.getCode()
  617. && patentState != PatentInfoStatus.CORRECTIONNOTICE.getCode())) {
  618. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利状态"));
  619. return res;
  620. }
  621. PatentInfo info = patentInfoService.selectByPrimaryKey(pid);
  622. if (!uid.equals(info.getUid())) {
  623. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  624. return res;
  625. }
  626. patentInfoService.updateNoticeOfCorrection(pid, patentState);
  627. return res;
  628. }
  629. /**
  630. * 收发详情入口/收发纸件登记
  631. */
  632. @RequestMapping(value = "/getRecieveSendList", method = RequestMethod.GET)
  633. public Result RecieveSendList(String pageNo, String pageSize) {
  634. Result res = new Result();
  635. Integer pNo = 1;
  636. Integer pSize = 10;
  637. if (StringUtils.isNumeric(pageSize)) {
  638. pSize = Integer.parseInt(pageSize);
  639. }
  640. if (StringUtils.isNumeric(pageNo)) {
  641. pNo = Integer.parseInt(pageNo);
  642. }
  643. res.setData(patentRegistrationService.getRecieveSendList(pNo, pSize));
  644. return res;
  645. }
  646. /**
  647. * 收发登记详情编辑保存
  648. *
  649. * @throws ParseException
  650. */
  651. @RequestMapping(value = "/saveRecieveSend", method = RequestMethod.POST)
  652. public Result recieveSendDetail(@Valid InputPatentRegistration patentRegistrationBo, BindingResult bindingResult,
  653. String rid, String pid) {
  654. Result res = new Result();
  655. if (bindingResult.hasErrors()) {
  656. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  657. PatentRegistrationFields.getFieldDesc(bindingResult.getFieldError().getField())));
  658. return res;
  659. }
  660. if (StringUtils.isBlank(pid) || StringUtils.isBlank(rid)) {
  661. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "专利记录ID", "专利记录ID"));
  662. return res;
  663. }
  664. PatentInfo p = patentInfoService.selectByPrimaryKey(pid);
  665. if (null == p) {
  666. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  667. return res;
  668. }
  669. if (PatentInfoStatus.CALLBACK.getCode() == p.getPatentState()) {
  670. res.getError().add(buildError(ErrorConstants.RECORD_CALLBACK, "当前申请已退单,无法修改!"));
  671. return res;
  672. }
  673. if (PatentInfoStatus.SETTLEMENT.getCode() == p.getPatentState()) {
  674. res.getError().add(buildError(ErrorConstants.RECORD_SETTLEMENT, "当前申请已结款,无法修改!"));
  675. return res;
  676. }
  677. patentRegistrationService.updateByPrimaryKey(regBo2Reg(rid, pid, patentRegistrationBo));
  678. return res;
  679. }
  680. /**
  681. * 专利申请费用管理
  682. */
  683. @RequestMapping(value = "/getApplicationFeeList", method = RequestMethod.GET)
  684. public Result getApplicationFeeList(
  685. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  686. Integer locationProvince, String pageNo, String pageSize) throws ParseException {
  687. Result res = new Result();
  688. Integer pNo = 1;
  689. Integer pSize = 10;
  690. if (StringUtils.isNumeric(pageSize)) {
  691. pSize = Integer.parseInt(pageSize);
  692. }
  693. if (StringUtils.isNumeric(pageNo)) {
  694. pNo = Integer.parseInt(pageNo);
  695. }
  696. res.setData(patentCostService.getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize));
  697. return res;
  698. }
  699. /**
  700. * 登记申请费用
  701. */
  702. @RequestMapping(value = "/registerApplicationFee", method = RequestMethod.POST)
  703. public Result registerApplicationFee(@Valid InputPatentCost patentCost, BindingResult bindingResult, String cid) {
  704. Result res = new Result();
  705. if (bindingResult.hasErrors()) {
  706. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  707. PatentCostFields.getFieldDesc(bindingResult.getFieldError().getField())));
  708. return res;
  709. }
  710. if (null == cid) {
  711. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "专利记录ID", "专利记录ID"));
  712. return res;
  713. }
  714. PatentCost cost = patentCostService.selectByPrimaryKey(cid);
  715. if (null == cost) {
  716. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  717. return res;
  718. }
  719. if (null == cost.getPid()) {
  720. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到专利申请", "专利记录ID"));
  721. return res;
  722. }
  723. PatentInfo info = patentInfoService.selectByPrimaryKey(cost.getPid());
  724. if (PatentInfoStatus.CALLBACK.getCode() == info.getPatentState()) {
  725. res.getError().add(buildError(ErrorConstants.RECORD_CALLBACK, "当前申请已退单,无法修改!"));
  726. return res;
  727. }
  728. if (PatentInfoStatus.SETTLEMENT.getCode() == info.getPatentState()) {
  729. res.getError().add(buildError(ErrorConstants.RECORD_SETTLEMENT, "当前申请已结款,无法修改!"));
  730. return res;
  731. }
  732. PatentCost pc = new PatentCost();
  733. BeanUtils.copyProperties(patentCost, pc);
  734. pc.setId(cid);
  735. res.setData(patentCostService.updateByPrimaryKeySelective(pc));
  736. return res;
  737. }
  738. /**
  739. * 专利综合管理报表导出
  740. *
  741. * @throws ParseException
  742. */
  743. @SuppressWarnings("unchecked")
  744. @RequestMapping(value = "/exportComposite", method = RequestMethod.GET)
  745. public Result exportComposite(@RequestParam(name = "contractId", required = false) String contractId,
  746. @RequestParam(name = "serialNumber", required = false) String serialNumber, String patentNumber,
  747. String office, @RequestParam(name = "locationProvince", required = false) Integer locationProvince,
  748. String unitName, String uid, @RequestParam(name = "patentCatagory", required = false) String patentCatagory,
  749. String patentName, @RequestParam(name = "patentState", required = false) String patentState,
  750. @RequestParam(name = "createTime[]", required = false) String[] createTime,
  751. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  752. String author, HttpServletResponse response) throws ParseException {
  753. Result res = new Result();
  754. Integer sn = (!StringUtils.isNumeric(serialNumber) ? null : Integer.parseInt(serialNumber));
  755. Integer pc = (!StringUtils.isNumeric(patentCatagory) ? null : Integer.parseInt(patentCatagory));
  756. Integer ps = (!StringUtils.isNumeric(patentState) ? null : Integer.parseInt(patentState));
  757. Integer lp = (null == locationProvince) ? null : locationProvince;
  758. List<PatentManageListBo> composites = (List<PatentManageListBo>) getManagePatentList(contractId, sn,
  759. patentNumber, office, lp, unitName, pc, patentName, ps, createTime, patentApplicationDate, author, uid,
  760. 1, 1000).getList();
  761. if (res.getError().isEmpty()) {
  762. exportComosites(response, composites);
  763. } else {
  764. FileUtils.out(response, JSON.toJSONString(res));
  765. }
  766. return res;
  767. }
  768. /**
  769. * 待缴年登印费专利管理报表导出
  770. */
  771. @RequestMapping(value = "/exportPending", method = RequestMethod.GET)
  772. public Result exportPending(@RequestParam(name = "locationProvince", required = false) Integer locationProvince,
  773. HttpServletResponse response) {
  774. Result res = new Result();
  775. @SuppressWarnings("unchecked")
  776. List<PatentPendingBo> pendings = (List<PatentPendingBo>) getManagePendingPaymentList(locationProvince, 1, 1000)
  777. .getList();
  778. if (res.getError().isEmpty()) {
  779. exportPendings(response, pendings);
  780. } else {
  781. FileUtils.out(response, JSON.toJSONString(res));
  782. }
  783. return res;
  784. }
  785. /**
  786. * 专利申请费用管理报表导出
  787. */
  788. @SuppressWarnings("unchecked")
  789. @RequestMapping(value = "/exportApplicationFee", method = RequestMethod.GET)
  790. public Result exportApplicationFee(
  791. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  792. Integer locationProvince, HttpServletResponse response) throws ParseException {
  793. Result res = new Result();
  794. List<PatentApplicationFeeBo> fees = (List<PatentApplicationFeeBo>) getApplicationFeeList(patentApplicationDate,
  795. locationProvince, 1, 1000).getList();
  796. if (res.getError().isEmpty()) {
  797. exportFees(response, fees);
  798. } else {
  799. FileUtils.out(response, JSON.toJSONString(res));
  800. }
  801. return res;
  802. }
  803. /**
  804. * 获取资料撰写人下拉
  805. *
  806. * @return
  807. */
  808. @RequestMapping(value = "/getAuthor", method = RequestMethod.GET)
  809. public Result getAuthor() {
  810. Result res = new Result();
  811. List<Admin> list = adminService.selectPatentAuthor();
  812. Map<String, String> map = new TreeMap<String, String>();
  813. for (Admin o : list) {
  814. map.put(o.getId(), o.getName());
  815. }
  816. res.setData(map);
  817. return res;
  818. }
  819. /**
  820. * 专利负责人下拉
  821. *
  822. * @return
  823. */
  824. @RequestMapping(value = "/getPrincipal", method = RequestMethod.GET)
  825. public Result getPrincipal() {
  826. Result res = new Result();
  827. List<Admin> list = adminService.selectPatentPrincipal();
  828. Map<String, String> map = new TreeMap<String, String>();
  829. for (Admin o : list) {
  830. map.put(o.getId(), o.getName() + " " + (null == o.getPosition() ? "" : o.getPosition()));
  831. }
  832. res.setData(map);
  833. return res;
  834. }
  835. // 专利申请费用管理报表
  836. private void exportFees(HttpServletResponse response, List<PatentApplicationFeeBo> fees) {
  837. String sheetName = "专利申请费用管理报表";
  838. HSSFWorkbook workbook = createWorkbook(sheetName,
  839. new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利名称", "缴费状态", "申请费", "是否请款", "是否报销", "申请日", "缴费截止时间" });
  840. HSSFSheet sheet = workbook.getSheet(sheetName);
  841. Map<Integer, DistrictGlossory> districtMap = getProvinces();
  842. for (int i = 0; i < fees.size(); i++) {
  843. PatentApplicationFeeBo obj = fees.get(i);
  844. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  845. row.createCell(0).setCellValue(null == obj.getSerialNumber() ? "" : obj.getSerialNumber().toString());
  846. row.createCell(1).setCellValue(obj.getPatentNumber());
  847. Integer locationProvince = obj.getLocationProvince();
  848. row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
  849. row.createCell(3).setCellValue(obj.getUnitName());
  850. row.createCell(4).setCellValue(obj.getPatentName());
  851. Integer paymentState = obj.getPaymentState();
  852. if (null != paymentState && PatentApplicationFeeStatus.PAID.getCode().equals(paymentState)) {
  853. row.createCell(5).setCellValue(PatentApplicationFeeStatus.PAID.getDesc());
  854. } else {
  855. row.createCell(5).setCellValue(PatentApplicationFeeStatus.UNPAID.getDesc());
  856. }
  857. row.createCell(6).setCellValue(null == obj.getApplicationFee() ? 0 : obj.getApplicationFee());
  858. Integer funds = obj.getFunds();
  859. if (null != funds && PatentFundsStatus.YES.getCode().equals(funds)) {
  860. row.createCell(7).setCellValue(PatentFundsStatus.YES.getDesc());
  861. } else {
  862. row.createCell(7).setCellValue(PatentFundsStatus.NO.getDesc());
  863. }
  864. Integer reimbursement = obj.getReimbursement();
  865. if (null != reimbursement && PatentReimbursementStatus.YES.getCode().equals(reimbursement)) {
  866. row.createCell(8).setCellValue(PatentReimbursementStatus.YES.getDesc());
  867. } else {
  868. row.createCell(8).setCellValue(PatentReimbursementStatus.NO.getDesc());
  869. }
  870. row.createCell(9).setCellValue(obj.getPatentApplicationDateFormattedDate());
  871. row.createCell(10).setCellValue(null == obj.getPatentApplicationDateFormattedDate() ? ""
  872. : calDeadline(obj.getPatentApplicationDateFormattedDate()));
  873. }
  874. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  875. }
  876. // 待缴年登印费专利管理报表
  877. private void exportPendings(HttpServletResponse response, List<PatentPendingBo> pendings) {
  878. String sheetName = "待缴年登印费专利管理报表";
  879. HSSFWorkbook workbook = createWorkbook(sheetName,
  880. new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利类型", "专利名称", "专利状态", "缴费状态", "缴费截止日期" });
  881. HSSFSheet sheet = workbook.getSheet(sheetName);
  882. Map<Integer, DistrictGlossory> districtMap = getProvinces();
  883. for (int i = 0; i < pendings.size(); i++) {
  884. PatentPendingBo obj = pendings.get(i);
  885. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  886. row.createCell(0).setCellValue(null == obj.getSerialNumber() ? "" : obj.getSerialNumber().toString());
  887. row.createCell(1).setCellValue(obj.getPatentNumber());
  888. Integer locationProvince = obj.getLocationProvince();
  889. row.createCell(2).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
  890. row.createCell(3).setCellValue(obj.getUnitName());
  891. Integer patentCatagory = obj.getPatentCatagory();
  892. if (null != patentCatagory) {
  893. if (PatentCategoryStatus.OTHER.getCode().equals(patentCatagory)) {
  894. row.createCell(4).setCellValue(PatentCategoryStatus.OTHER.getDesc());
  895. } else if (PatentCategoryStatus.UTILITY.getCode().equals(patentCatagory)) {
  896. row.createCell(4).setCellValue(PatentCategoryStatus.UTILITY.getDesc());
  897. } else if (PatentCategoryStatus.DESIGN.getCode().equals(patentCatagory)) {
  898. row.createCell(4).setCellValue(PatentCategoryStatus.DESIGN.getDesc());
  899. } else if (PatentCategoryStatus.INVENTION.getCode().equals(patentCatagory)) {
  900. row.createCell(4).setCellValue(PatentCategoryStatus.INVENTION.getDesc());
  901. }
  902. } else {
  903. row.createCell(4).setCellValue("");
  904. }
  905. row.createCell(5).setCellValue(obj.getPatentName());
  906. row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
  907. Integer annualFeeState = obj.getAnnualFeeState();
  908. if (null != annualFeeState && PatentAnnualFeeStatus.PAID.getCode().equals(annualFeeState)) {
  909. row.createCell(7).setCellValue(PatentAnnualFeeStatus.PAID.getDesc());
  910. } else {
  911. row.createCell(7).setCellValue(PatentAnnualFeeStatus.UNPAID.getDesc());
  912. }
  913. row.createCell(8).setCellValue(null == obj.getAuthorizedDateFormattedDate() ? ""
  914. : calDeadline(obj.getAuthorizedDateFormattedDate()));
  915. }
  916. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  917. }
  918. private void exportComosites(HttpServletResponse response, List<PatentManageListBo> composites) {
  919. String sheetName = "专利综合管理报表";
  920. HSSFWorkbook workbook = createWorkbook(sheetName, new String[] { "编号", "申请号/专利号", "合同编号", "事务所", "省份", "公司名称",
  921. "专利名称", "专利状态", "派单日", "申请日", "授权日", "资料撰写人" });
  922. HSSFSheet sheet = workbook.getSheet(sheetName);
  923. // 将查询出的数据设置到sheet对应的单元格中
  924. Map<Integer, DistrictGlossory> districtMap = getProvinces();
  925. for (int i = 0; i < composites.size(); i++) {
  926. PatentManageListBo obj = composites.get(i);// 遍历每个对象
  927. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  928. row.createCell(0).setCellValue(null == obj.getSerialNumber() ? "" : obj.getSerialNumber().toString());
  929. row.createCell(1).setCellValue(obj.getPatentNumber());
  930. row.createCell(2).setCellValue(obj.getContractNumber());
  931. row.createCell(3).setCellValue(obj.getOffice());
  932. Integer locationProvince = obj.getLocationProvince();
  933. row.createCell(4).setCellValue(null == locationProvince ? "" : getProvince(districtMap, locationProvince));
  934. row.createCell(5).setCellValue(obj.getUnitName());
  935. row.createCell(6).setCellValue(obj.getPatentName());
  936. row.createCell(7).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
  937. row.createCell(8).setCellValue(obj.getCreateTimeFormattedDate());
  938. row.createCell(9).setCellValue(obj.getPatentApplicationFormattedDate());
  939. row.createCell(10).setCellValue(obj.getPatentApplicationFormattedDate());
  940. row.createCell(11).setCellValue(obj.getAuthor());
  941. }
  942. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  943. }
  944. private HSSFWorkbook createWorkbook(String sheetName, String[] colNames) {
  945. HSSFWorkbook workbook = new HSSFWorkbook();
  946. HSSFSheet sheet = workbook.createSheet(sheetName);
  947. // 产生表格标题行
  948. HSSFRow rowm = sheet.createRow(0);
  949. HSSFCell cellTitle = rowm.createCell(0);
  950. cellTitle.setCellValue(sheetName);
  951. sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (colNames.length - 1)));
  952. HSSFRow rowRowName = sheet.createRow(1); // 在索引2的位置创建行(最顶端的行开始的第二行)
  953. // 将列头设置到sheet的单元格中
  954. for (int n = 0; n < colNames.length; n++) {
  955. rowRowName.createCell(n).setCellValue(colNames[n]);
  956. }
  957. return workbook;
  958. }
  959. private PatentRegistration regBo2Reg(String rid, String pid, InputPatentRegistration patentRegistrationBo) {
  960. PatentRegistration patentRegistration = new PatentRegistration();
  961. patentRegistration.setId(rid);
  962. patentRegistration.setAcceptanceExpressCompany(patentRegistrationBo.getAcceptanceExpressCompany());
  963. try {
  964. if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceIssueTime())) {
  965. patentRegistration.setAcceptanceIssueTime(
  966. DateUtils.parseDate(patentRegistrationBo.getAcceptanceIssueTime(), AFTConstants.YYYYMMDD));
  967. }
  968. if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceReceiveTime())) {
  969. patentRegistration.setAcceptanceReceiveTime(
  970. DateUtils.parseDate(patentRegistrationBo.getAcceptanceReceiveTime(), AFTConstants.YYYYMMDD));
  971. }
  972. patentRegistration.setAcceptanceTrackingNumber(patentRegistrationBo.getAcceptanceTrackingNumber());
  973. patentRegistration.setAuthorizationExpressCompany(patentRegistrationBo.getAuthorizationExpressCompany());
  974. if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationIssueTime())) {
  975. patentRegistration.setAuthorizationIssueTime(
  976. DateUtils.parseDate(patentRegistrationBo.getAuthorizationIssueTime(), AFTConstants.YYYYMMDD));
  977. }
  978. if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationReceiveTime())) {
  979. patentRegistration.setAuthorizationReceiveTime(
  980. DateUtils.parseDate(patentRegistrationBo.getAuthorizationReceiveTime(), AFTConstants.YYYYMMDD));
  981. }
  982. patentRegistration.setAuthorizationTrackingNumber(patentRegistrationBo.getAuthorizationTrackingNumber());
  983. patentRegistration.setCertificateExpressCompany(patentRegistrationBo.getCertificateExpressCompany());
  984. if (!StringUtils.isBlank(patentRegistrationBo.getCertificateIssueTime())) {
  985. patentRegistration.setCertificateIssueTime(
  986. DateUtils.parseDate(patentRegistrationBo.getCertificateIssueTime(), AFTConstants.YYYYMMDD));
  987. }
  988. if (!StringUtils.isBlank(patentRegistrationBo.getCertificateRecieveTime())) {
  989. patentRegistration.setCertificateRecieveTime(
  990. DateUtils.parseDate(patentRegistrationBo.getCertificateRecieveTime(), AFTConstants.YYYYMMDD));
  991. }
  992. } catch (ParseException e) {
  993. }
  994. patentRegistration.setCertificateTrackingNumber(patentRegistrationBo.getCertificateTrackingNumber());
  995. patentRegistration.setPid(pid);
  996. return patentRegistration;
  997. }
  998. // 专利申请费用管理
  999. private Pagination<PatentApplicationFeeBo> getApplicationFeeList(String[] patentApplicationDate,
  1000. Integer locationProvince, Integer pNo, Integer pSize) throws ParseException {
  1001. return patentCostService.getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize);
  1002. }
  1003. // 待缴费专利管理
  1004. private Pagination<PatentPendingBo> getManagePendingPaymentList(Integer locationProvince, Integer pNo,
  1005. Integer pSize) {
  1006. return patentInfoService.getManagePendingPaymentList(locationProvince, pNo, pSize);
  1007. }
  1008. // 管理端申请专利列表(专利综合管理)
  1009. private Pagination<PatentManageListBo> getManagePatentList(String contractId, Integer serialNumber,
  1010. String patentNumber, String office, Integer locationProvince, String unitName, Integer patentCatagory,
  1011. String patentName, Integer patentState, String[] createTime, String[] patentApplicationDate, String author,
  1012. String uid, Integer pNo, Integer pSize) throws ParseException {
  1013. return patentInfoService.getManagePatentList(contractId, serialNumber, patentNumber, office, locationProvince,
  1014. unitName, patentCatagory, patentName, patentState, createTime, patentApplicationDate, author, uid, pNo,
  1015. pSize);
  1016. }
  1017. // 缴费截止日期
  1018. private String calDeadline(String s) {
  1019. String[] arr = s.split("-");
  1020. String y = arr[0];
  1021. String m = arr[1];
  1022. String d = arr[2];
  1023. if ("11".equals(arr[0])) {
  1024. m = "01";
  1025. y = String.valueOf(Integer.parseInt(y) + 1);
  1026. } else if ("12".equals(arr[0])) {
  1027. m = "02";
  1028. y = String.valueOf(Integer.parseInt(y) + 1);
  1029. } else {
  1030. m = String.valueOf(Integer.parseInt(m) + 2);
  1031. }
  1032. return y + m + d;
  1033. }
  1034. // 专利状态
  1035. private String switchPatState(Integer s) {
  1036. String state = "";
  1037. if (PatentInfoStatus.CREATE.getCode().equals(s)) {
  1038. state = PatentInfoStatus.CREATE.getDesc();
  1039. } else if (PatentInfoStatus.SIGN.getCode().equals(s)) {
  1040. state = PatentInfoStatus.SIGN.getDesc();
  1041. } else if (PatentInfoStatus.DELIVERD.getCode().equals(s)) {
  1042. state = PatentInfoStatus.DELIVERD.getDesc();
  1043. } else if (PatentInfoStatus.CIRCULATION.getCode().equals(s)) {
  1044. state = PatentInfoStatus.CIRCULATION.getDesc();
  1045. } else if (PatentInfoStatus.COMPOSE.getCode().equals(s)) {
  1046. state = PatentInfoStatus.COMPOSE.getDesc();
  1047. } else if (PatentInfoStatus.ACCEPT.getCode().equals(s)) {
  1048. state = PatentInfoStatus.ACCEPT.getDesc();
  1049. } else if (PatentInfoStatus.REVIEWNOTICE.getCode().equals(s)) {
  1050. state = PatentInfoStatus.REVIEWNOTICE.getDesc();
  1051. } else if (PatentInfoStatus.REVIEWREPLY.getCode().equals(s)) {
  1052. state = PatentInfoStatus.REVIEWREPLY.getDesc();
  1053. } else if (PatentInfoStatus.CORRECTIONNOTICE.getCode().equals(s)) {
  1054. state = PatentInfoStatus.CORRECTIONNOTICE.getDesc();
  1055. } else if (PatentInfoStatus.CORRECTIONREPLY.getCode().equals(s)) {
  1056. state = PatentInfoStatus.CORRECTIONREPLY.getDesc();
  1057. } else if (PatentInfoStatus.AUTHORIZE.getCode().equals(s)) {
  1058. state = PatentInfoStatus.AUTHORIZE.getDesc();
  1059. } else if (PatentInfoStatus.REJECT.getCode().equals(s)) {
  1060. state = PatentInfoStatus.REJECT.getDesc();
  1061. } else if (PatentInfoStatus.LICENSE.getCode().equals(s)) {
  1062. state = PatentInfoStatus.LICENSE.getDesc();
  1063. } else if (PatentInfoStatus.SETTLEMENT.getCode().equals(s)) {
  1064. state = PatentInfoStatus.SETTLEMENT.getDesc();
  1065. } else if (PatentInfoStatus.CREATE.getCode().equals(s)) {
  1066. state = PatentInfoStatus.CREATE.getDesc();
  1067. } else if (PatentInfoStatus.CALLBACK.getCode().equals(s)) {
  1068. state = PatentInfoStatus.CALLBACK.getDesc();
  1069. }
  1070. return state;
  1071. }
  1072. private String handleFile(Result res, HttpServletRequest req, String fileName, List<MultipartFile> files,
  1073. MultipartFile mf) {
  1074. if (!files.isEmpty()) {
  1075. try {
  1076. mf.transferTo(toAdminPrivateFile(fileName));
  1077. LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
  1078. } catch (IllegalStateException | IOException e) {
  1079. LoggerUtils.error(getClass(), "文件上传失败", e);
  1080. res.getError().add(buildError("", "文件上传失败!"));
  1081. return "";
  1082. }
  1083. } else {
  1084. res.getError().add(buildError("", "文件上传失败!"));
  1085. return "";
  1086. }
  1087. return fileName;
  1088. }
  1089. private Map<String, String> disposePatentStatus() {
  1090. Map<String, String> status = new TreeMap<String, String>();
  1091. if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
  1092. for (PatentInfoStatus p : PatentInfoStatus.values()) {
  1093. status.put(p.getCode().toString(), p.getDesc());
  1094. status.remove(PatentInfoStatus.OTHER.getCode().toString());
  1095. }
  1096. } else {
  1097. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.CREATE.getCode())) {
  1098. status.put(PatentInfoStatus.CREATE.getCode().toString(), PatentInfoStatus.CREATE.getDesc());
  1099. }
  1100. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.SIGN.getCode())) {
  1101. status.put(PatentInfoStatus.SIGN.getCode().toString(), PatentInfoStatus.SIGN.getDesc());
  1102. }
  1103. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.DELIVERD.getCode())) {
  1104. status.put(PatentInfoStatus.DELIVERD.getCode().toString(), PatentInfoStatus.DELIVERD.getDesc());
  1105. }
  1106. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.CIRCULATION.getCode())) {
  1107. status.put(PatentInfoStatus.CIRCULATION.getCode().toString(), PatentInfoStatus.CIRCULATION.getDesc());
  1108. }
  1109. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.COMPOSE.getCode())) {
  1110. status.put(PatentInfoStatus.COMPOSE.getCode().toString(), PatentInfoStatus.COMPOSE.getDesc());
  1111. }
  1112. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.ACCEPT.getCode())) {
  1113. status.put(PatentInfoStatus.ACCEPT.getCode().toString(), PatentInfoStatus.ACCEPT.getDesc());
  1114. }
  1115. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.REVIEWNOTICE.getCode())) {
  1116. status.put(PatentInfoStatus.REVIEWNOTICE.getCode().toString(), PatentInfoStatus.REVIEWNOTICE.getDesc());
  1117. }
  1118. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.REVIEWREPLY.getCode())) {
  1119. status.put(PatentInfoStatus.REVIEWREPLY.getCode().toString(), PatentInfoStatus.REVIEWREPLY.getDesc());
  1120. }
  1121. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.CORRECTIONNOTICE.getCode())) {
  1122. status.put(PatentInfoStatus.CORRECTIONNOTICE.getCode().toString(),
  1123. PatentInfoStatus.CORRECTIONNOTICE.getDesc());
  1124. }
  1125. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.CORRECTIONREPLY.getCode())) {
  1126. status.put(PatentInfoStatus.CORRECTIONREPLY.getCode().toString(),
  1127. PatentInfoStatus.CORRECTIONREPLY.getDesc());
  1128. }
  1129. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.AUTHORIZE.getCode())) {
  1130. status.put(PatentInfoStatus.AUTHORIZE.getCode().toString(), PatentInfoStatus.AUTHORIZE.getDesc());
  1131. }
  1132. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.REJECT.getCode())) {
  1133. status.put(PatentInfoStatus.REJECT.getCode().toString(), PatentInfoStatus.REJECT.getDesc());
  1134. }
  1135. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.LICENSE.getCode())) {
  1136. status.put(PatentInfoStatus.LICENSE.getCode().toString(), PatentInfoStatus.LICENSE.getDesc());
  1137. }
  1138. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.SETTLEMENT.getCode())) {
  1139. status.put(PatentInfoStatus.SETTLEMENT.getCode().toString(), PatentInfoStatus.SETTLEMENT.getDesc());
  1140. }
  1141. if (TokenManager.hasPermission("PatentInfoStatus" + PatentInfoStatus.CALLBACK.getCode())) {
  1142. status.put(PatentInfoStatus.CALLBACK.getCode().toString(), PatentInfoStatus.CALLBACK.getDesc());
  1143. }
  1144. }
  1145. return status;
  1146. }
  1147. private String getProvince(Map<Integer, DistrictGlossory> districtMap, Integer province) {
  1148. DistrictGlossory dg = districtMap.get(province);
  1149. return dg == null ? "未知地区" : dg.getName();
  1150. }
  1151. private Map<Integer, DistrictGlossory> getProvinces() {
  1152. List<DistrictGlossory> districts = districtGlossoryService.list(0);
  1153. Map<Integer, DistrictGlossory> districtMap = new HashMap<>();
  1154. for (DistrictGlossory dg : districts) {
  1155. districtMap.put(dg.getId(), dg);
  1156. }
  1157. return districtMap;
  1158. }
  1159. }