AdminPatentApiController.java 47 KB

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