AdminPatentApiController.java 52 KB

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