AdminPatentApiController.java 48 KB

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