PatentApiController.java 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. package com.goafanti.patent.controller;
  2. import java.text.ParseException;
  3. import java.util.ArrayList;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.LinkedHashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.TreeMap;
  10. import javax.annotation.Resource;
  11. import javax.servlet.http.HttpServletRequest;
  12. import javax.servlet.http.HttpServletResponse;
  13. import javax.validation.Valid;
  14. import org.apache.poi.hssf.usermodel.HSSFCell;
  15. import org.apache.poi.hssf.usermodel.HSSFRow;
  16. import org.apache.poi.hssf.usermodel.HSSFSheet;
  17. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  18. import org.apache.poi.ss.util.CellRangeAddress;
  19. import org.springframework.beans.BeanUtils;
  20. import org.springframework.beans.factory.annotation.Value;
  21. import org.springframework.stereotype.Controller;
  22. import org.springframework.validation.BindingResult;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestMethod;
  25. import org.springframework.web.bind.annotation.RequestParam;
  26. import com.goafanti.admin.service.AftFileService;
  27. import com.goafanti.cognizance.service.OrgIntellectualPropertyService;
  28. import com.goafanti.common.bo.Result;
  29. import com.goafanti.common.constant.ErrorConstants;
  30. import com.goafanti.common.controller.CertifyApiController;
  31. import com.goafanti.common.enums.AttachmentType;
  32. import com.goafanti.common.enums.PatentInfoFields;
  33. import com.goafanti.common.enums.PatentInfoStatus;
  34. import com.goafanti.common.model.Admin;
  35. import com.goafanti.common.model.AftFile;
  36. import com.goafanti.common.model.OrganizationIdentity;
  37. import com.goafanti.common.model.PatentCost;
  38. import com.goafanti.common.model.PatentInfo;
  39. import com.goafanti.common.model.PatentLog;
  40. import com.goafanti.common.model.PatentRegistration;
  41. import com.goafanti.common.model.User;
  42. import com.goafanti.common.utils.DateUtils;
  43. import com.goafanti.common.utils.FileUtils;
  44. import com.goafanti.common.utils.StringUtils;
  45. import com.goafanti.core.mybatis.page.Pagination;
  46. import com.goafanti.core.shiro.token.TokenManager;
  47. import com.goafanti.patent.bo.InputPatentInfo;
  48. import com.goafanti.patent.bo.PatentApplicationFeeBo;
  49. import com.goafanti.patent.bo.PatentCompositeBo;
  50. import com.goafanti.patent.bo.PatentManageListBo;
  51. import com.goafanti.patent.bo.PatentNoticeOfCorrectionBo;
  52. import com.goafanti.patent.bo.PatentPendingBo;
  53. import com.goafanti.patent.bo.PatentRecieveSendBo;
  54. import com.goafanti.patent.bo.PatentRegistrationBo;
  55. import com.goafanti.patent.service.AdminService;
  56. import com.goafanti.patent.service.PatentCostService;
  57. import com.goafanti.patent.service.PatentInfoService;
  58. import com.goafanti.patent.service.PatentLogService;
  59. import com.goafanti.patent.service.PatentRegistrationService;
  60. import com.goafanti.user.service.OrganizationIdentityService;
  61. import com.goafanti.user.service.UserService;
  62. @Controller
  63. @RequestMapping(value = "/techservice/patent")
  64. public class PatentApiController extends CertifyApiController {
  65. @Resource
  66. private PatentInfoService patentInfoService;
  67. @Resource
  68. private PatentLogService patentLogService;
  69. @Resource
  70. private OrganizationIdentityService organizationIdentityServivce;
  71. @Resource
  72. private PatentCostService patentCostService;
  73. @Resource
  74. private PatentRegistrationService patentRegistrationService;
  75. @Resource
  76. private AdminService adminService;
  77. @Resource
  78. private OrgIntellectualPropertyService orgIntellectualPropertyService;
  79. @Resource
  80. private UserService userService;
  81. @Resource
  82. private AftFileService aftFileService;
  83. @Value(value = "${upload.private.path}")
  84. private String uploadPrivatePath = null;
  85. /**
  86. * 专利相关材料上传
  87. * @param req
  88. * @param uid
  89. * @param sign
  90. * @return
  91. */
  92. @RequestMapping(value = "/upload", method = RequestMethod.POST)
  93. public Result upload(HttpServletRequest req, String sign){
  94. Result res = new Result();
  95. if (!checkUserLogin(res)) {
  96. return res;
  97. }
  98. User curUser = TokenManager.getUserToken();
  99. if (!checkCertify(res, curUser)) {
  100. return res;
  101. }
  102. AttachmentType attachmentType = AttachmentType.getField(sign);
  103. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT || attachmentType == AttachmentType.PATENT_WRITING
  104. || attachmentType == AttachmentType.AUTHORIZATION_NOTICE || attachmentType == AttachmentType.PATENT_CERTIFICATE) {
  105. res.setData(handleFiles(res, "/patent/", true, req, sign, TokenManager.getUserId()));
  106. } else {
  107. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  108. }
  109. return res;
  110. }
  111. /**
  112. * 下载专利相关材料
  113. *
  114. * @param id
  115. * @param sign
  116. * @param response
  117. * @return
  118. */
  119. @RequestMapping(value = "/download", method = RequestMethod.GET)
  120. public Result download(String id, String sign, HttpServletResponse response) {
  121. Result res = new Result();
  122. if (!checkAdminLogin(res)) {
  123. return res;
  124. }
  125. if (StringUtils.isEmpty(id)) {
  126. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id"));
  127. return res;
  128. }
  129. PatentInfo pi = patentInfoService.selectByPrimaryKey(id);
  130. if (pi == null) {
  131. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id"));
  132. return res;
  133. }
  134. AttachmentType attachmentType = AttachmentType.getField(sign);
  135. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT || attachmentType == AttachmentType.PATENT_WRITING
  136. || attachmentType == AttachmentType.AUTHORIZATION_NOTICE
  137. || attachmentType == AttachmentType.PATENT_CERTIFICATE) {
  138. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  139. downloadFile(response, pi.getPatentProryStatementDownloadFileName(), pi.getPatentProryStatementUrl());
  140. } else if (attachmentType == AttachmentType.PATENT_WRITING) {
  141. downloadFile(response, pi.getPatentWritingDownloadFileName(), pi.getPatentWritingUrl());
  142. } else if (attachmentType == AttachmentType.AUTHORIZATION_NOTICE) {
  143. downloadFile(response, pi.getAuthorizationNoticeDownloadFileName(), pi.getAuthorizationNoticeUrl());
  144. } else if (attachmentType == AttachmentType.PATENT_CERTIFICATE){
  145. downloadFile(response, pi.getPatentCertificateDownloadFileName(), pi.getPatentCertificateUrl());
  146. }
  147. } else{
  148. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
  149. }
  150. return res;
  151. }
  152. /**
  153. * 下载模版文件(专利代理委托书)
  154. *
  155. * @param response
  156. * @return
  157. */
  158. @RequestMapping(value = "/downloadTemplateFile", method = RequestMethod.GET)
  159. public Result downloadTemplateFile(HttpServletResponse response, String sign) {
  160. Result res = new Result();
  161. if (!checkAdminLogin(res)) {
  162. return res;
  163. }
  164. AttachmentType attachmentType = AttachmentType.getField(sign);
  165. if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) {
  166. String fileName = "";
  167. AftFile af = aftFileService.selectAftFileBySign(sign);
  168. if (null == af) {
  169. res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "找不到", "文件"));
  170. } else {
  171. String path = af.getFilePath();
  172. String suffix = path.substring(path.lastIndexOf("."));
  173. fileName = "专利代理委托书模版" + suffix;
  174. downloadFile(response, fileName, path);
  175. }
  176. } else {
  177. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利代理委托书标示"));
  178. }
  179. return res;
  180. }
  181. /**
  182. * 用户端专利申请
  183. */
  184. @RequestMapping(value = "/clientApplyPatent", method = RequestMethod.POST)
  185. public Result clientApplyPatent(@Valid InputPatentInfo patentInfo, BindingResult bindingResult) {
  186. Result res = new Result();
  187. if (bindingResult.hasErrors()) {
  188. res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
  189. PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField())));
  190. return res;
  191. }
  192. if (!checkUserLogin(res)) {
  193. return res;
  194. }
  195. User curUser = TokenManager.getUserToken();
  196. if (!checkCertify(res, curUser)) {
  197. return res;
  198. }
  199. String aid = curUser.getAid();
  200. PatentInfo pi = new PatentInfo();
  201. BeanUtils.copyProperties(patentInfo, pi);
  202. pi.setUid(TokenManager.getUserId());
  203. res.setData(patentInfoService.savePatentInfo(pi, aid));
  204. return res;
  205. }
  206. /**
  207. * 用户端专利详情
  208. *
  209. */
  210. @RequestMapping(value = "/clientPatentInfo", method = RequestMethod.GET)
  211. public Result clientPatentInfo(String pid) {
  212. Result res = new Result();
  213. if (!checkUserLogin(res)) {
  214. return res;
  215. }
  216. if (StringUtils.isBlank(pid)) {
  217. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID"));
  218. } else {
  219. PatentInfo pi = patentInfoService.selectByPrimaryKey(pid);
  220. if (null != pi.getUid() && pi.getUid().equals(TokenManager.getUserId())) {
  221. res.setData(pi);
  222. } else {
  223. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利ID"));
  224. }
  225. }
  226. res.setData(patentInfoService.selectByPrimaryKey(pid));
  227. return res;
  228. }
  229. /**
  230. * 用户端申请专利列表
  231. */
  232. @RequestMapping(value = "/clientApplyList", method = RequestMethod.GET)
  233. public Result clientApplyList(String patentNumber, String patentName, Integer patentCatagory, Integer patentState,
  234. String pageNo, String pageSize) {
  235. Result res = new Result();
  236. if (!checkUserLogin(res)) {
  237. return res;
  238. }
  239. Integer pNo = 1;
  240. Integer pSize = 10;
  241. if (StringUtils.isNumeric(pageSize)) {
  242. pSize = Integer.parseInt(pageSize);
  243. }
  244. if (StringUtils.isNumeric(pageNo)) {
  245. pNo = Integer.parseInt(pageNo);
  246. }
  247. res.setData(getClientApplyList(res, patentNumber, patentName, patentCatagory, patentState, pNo, pSize));
  248. return res;
  249. }
  250. /**
  251. * 用户端logs
  252. */
  253. @RequestMapping(value = "/patentProcess", method = RequestMethod.GET)
  254. public Result patentProcess(String pid) {
  255. Result res = new Result();
  256. if (!checkUserLogin(res)) {
  257. return res;
  258. }
  259. if (StringUtils.isBlank(pid)) {
  260. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID"));
  261. return res;
  262. }
  263. PatentInfo pi = patentInfoService.selectByPrimaryKey(pid);
  264. if (null != pi.getUid() && pi.getUid().equals(TokenManager.getUserId())) {
  265. List<PatentLog> list = patentLogService.selectProcessByPid(pid);
  266. for (PatentLog log : list){
  267. if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.SIGN){
  268. log.setState(PatentInfoStatus.CREATE.getCode());
  269. }
  270. if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.CIRCULATION){
  271. log.setState(PatentInfoStatus.DELIVERD.getCode());
  272. }
  273. if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.SETTLEMENT){
  274. log.setState(PatentInfoStatus.LICENSE.getCode());
  275. }
  276. }
  277. res.setData(list);
  278. } else {
  279. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利d"));
  280. }
  281. return res;
  282. }
  283. /**
  284. * 用户确认申报材料
  285. *
  286. * @return
  287. */
  288. @RequestMapping(value = "/clientConfirm", method = RequestMethod.POST)
  289. public Result clientConfirmApplicationMaterials(String pid) {
  290. Result res = new Result();
  291. if (!checkUserLogin(res)) {
  292. return res;
  293. }
  294. if (StringUtils.isBlank(pid)){
  295. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利d"));
  296. return res;
  297. }
  298. PatentInfo p = new PatentInfo();
  299. p.setId(pid);
  300. p.setConfirmState(1);
  301. res.setData(patentInfoService.updateByPrimaryKeySelective(p));
  302. return res;
  303. }
  304. /**
  305. * 删除专利记录
  306. *
  307. * @param ids
  308. * @return
  309. */
  310. @RequestMapping(value = "/deletePatent", method = RequestMethod.POST)
  311. public Result deletePatent(@RequestParam(name = "ids[]", required = true) String[] ids) {
  312. Result res = new Result();
  313. List<String> id = new ArrayList<String>();
  314. for (String s : ids) {
  315. id.add(s);
  316. }
  317. res.setData(patentInfoService.batchDeleteByPrimaryKey(id));
  318. return res;
  319. }
  320. /**
  321. * 管理端申请专利列表
  322. *
  323. * @throws ParseException
  324. */
  325. @RequestMapping(value = "/managePatentList", method = RequestMethod.POST)
  326. public Result managePatentList(Integer serialNumber, String patentNumber, String office, String locationProvince,
  327. String unitName, Integer patentCatagory, String patentName, Integer patentState,
  328. @RequestParam(name = "createTime[]", required = false) String[] createTime,
  329. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  330. String author, String pageNo, String pageSize) throws ParseException {
  331. Result res = new Result();
  332. Integer pNo = 1;
  333. Integer pSize = 10;
  334. if (StringUtils.isNumeric(pageSize)) {
  335. pSize = Integer.parseInt(pageSize);
  336. }
  337. if (StringUtils.isNumeric(pageNo)) {
  338. pNo = Integer.parseInt(pageNo);
  339. }
  340. res.setData(getManagePatentList(serialNumber, patentNumber, office, locationProvince, unitName, patentCatagory,
  341. patentName, patentState, createTime, patentApplicationDate, author, pNo, pSize));
  342. return res;
  343. }
  344. /**
  345. * 获取公司
  346. */
  347. @RequestMapping(value = "/getUnitNames", method = RequestMethod.GET)
  348. public Result getUnitNames() {
  349. Result res = new Result();
  350. List<OrganizationIdentity> list = organizationIdentityServivce.selectAllOrgIndentity();
  351. Map<String, String> map = new TreeMap<String, String>();
  352. for (OrganizationIdentity o : list) {
  353. map.put(o.getUid(), o.getUnitName());
  354. }
  355. res.setData(map);
  356. return res;
  357. }
  358. /**
  359. * 获取管理员
  360. */
  361. @RequestMapping(value = "/getAdmin", method = RequestMethod.GET)
  362. public Result getAdmin() {
  363. Result res = new Result();
  364. List<Admin> admin = adminService.selectAllAdmin();
  365. Map<String, String> map = new LinkedHashMap<String, String>();
  366. for (Admin a : admin) {
  367. map.put(a.getId(), a.getName());
  368. }
  369. res.setData(map);
  370. return res;
  371. }
  372. /**
  373. * 管理端新增专利申请
  374. */
  375. @RequestMapping(value = "/manageApplyPatent", method = RequestMethod.POST)
  376. public Result manageApplyPatent(PatentInfo patentInfo, String uid) {
  377. Result res = new Result();
  378. res = checkCertify(res, uid);
  379. if (res.getError().isEmpty()) {
  380. String aid = userService.selectByPrimaryKey(uid).getAid();
  381. res.setData(patentInfoService.savePatentInfo(patentInfo, aid));
  382. }
  383. return res;
  384. }
  385. /**
  386. * 管理端专利详情修改保存
  387. *
  388. * @throws ParseException
  389. */
  390. @RequestMapping(value = "/managePatentInfo", method = RequestMethod.POST)
  391. public Result managePatentInfo(String patentNumber, String patentName, String patentCatagory, String patentField,
  392. String patentDes, String patentWritingUrl, String authorizationNoticeUrl, String patentCertificateUrl,
  393. String xid, PatentLog patentLog, String recordTimeFormattedDate, Integer pState) throws ParseException {
  394. Result res = new Result();
  395. PatentInfo patentInfo = new PatentInfo();
  396. patentInfo.setId(xid);
  397. patentInfo.setPatentState(pState);
  398. patentInfo.setPatentName(patentName);
  399. patentInfo.setPatentNumber(patentNumber);
  400. patentInfo.setPatentCatagory(StringUtils.isNumeric(patentCatagory) ? Integer.parseInt(patentCatagory) : null);
  401. patentInfo.setPatentField(StringUtils.isNumeric(patentField) ? Integer.parseInt(patentField) : null);
  402. patentInfo.setPatentDes(patentDes);
  403. patentInfo.setPatentWritingUrl(patentWritingUrl);
  404. patentInfo.setAuthorizationNoticeUrl(authorizationNoticeUrl);
  405. patentInfo.setPatentCertificateUrl(patentCertificateUrl);
  406. Date recordTime = null;
  407. if (!StringUtils.isBlank(recordTimeFormattedDate)) {
  408. recordTime = DateUtils.parseDate(recordTimeFormattedDate, "yyyy-MM-dd");
  409. }
  410. patentInfoService.updatePatentInfo(patentInfo, patentLog, recordTime);
  411. return res;
  412. }
  413. /**
  414. * 待缴费专利管理
  415. */
  416. @RequestMapping(value = "/managePendingPaymentList", method = RequestMethod.POST)
  417. public Result managePendingPaymentList(String locationProvince, String pageNo, String pageSize) {
  418. Result res = new Result();
  419. Integer pNo = 1;
  420. Integer pSize = 10;
  421. if (StringUtils.isNumeric(pageSize)) {
  422. pSize = Integer.parseInt(pageSize);
  423. }
  424. if (StringUtils.isNumeric(pageNo)) {
  425. pNo = Integer.parseInt(pageNo);
  426. }
  427. res.setData(getManagePendingPaymentList(locationProvince, pNo, pSize));
  428. return res;
  429. }
  430. /**
  431. * 年费确认缴费
  432. */
  433. @RequestMapping(value = "/confirmPayment", method = RequestMethod.POST)
  434. public Result confirmPayment(String cid) {
  435. Result res = new Result();
  436. if (StringUtils.isBlank(cid)) {
  437. res.getError().add(buildError("", "确认缴费失败!"));
  438. return res;
  439. }
  440. PatentCost patentCost = new PatentCost();
  441. patentCost.setId(cid);
  442. patentCost.setAnnualFeeState(1);
  443. patentCostService.updateByPrimaryKeySelective(patentCost);
  444. return res;
  445. }
  446. /**
  447. * 补正审查通知列表
  448. */
  449. @RequestMapping(value = "/noticeOfCorrectionList", method = RequestMethod.POST)
  450. public Result noticeOfCorrectionList(Date authorizedDate, Integer serialNumber, String patentNumber, String office,
  451. String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  452. String author, String pageNo, String pageSize) {
  453. Result res = new Result();
  454. Integer pNo = 1;
  455. Integer pSize = 10;
  456. if (StringUtils.isNumeric(pageSize)) {
  457. pSize = Integer.parseInt(pageSize);
  458. }
  459. if (StringUtils.isNumeric(pageNo)) {
  460. pNo = Integer.parseInt(pageNo);
  461. }
  462. res.setData(getNoticeOfCorrectionList(authorizedDate, serialNumber, patentNumber, office, locationProvince,
  463. unitName, patentCatagory, patentName, patentState, author, pNo, pSize));
  464. return res;
  465. }
  466. /**
  467. * 补正审查通知答复确认
  468. */
  469. @RequestMapping(value = "/replyConfirm", method = RequestMethod.POST)
  470. public Result replyConfirm(String pid, Integer patentState) {
  471. Result res = new Result();
  472. patentInfoService.updateNoticeOfCorrection(pid, patentState);
  473. return res;
  474. }
  475. /**
  476. * 收发详情入口/收发纸件登记
  477. */
  478. @RequestMapping(value = "/getRecieveSendList", method = RequestMethod.POST)
  479. public Result RecieveSendList(String pageNo, String pageSize) {
  480. Result res = new Result();
  481. Integer pNo = 1;
  482. Integer pSize = 10;
  483. if (StringUtils.isNumeric(pageSize)) {
  484. pSize = Integer.parseInt(pageSize);
  485. }
  486. if (StringUtils.isNumeric(pageNo)) {
  487. pNo = Integer.parseInt(pageNo);
  488. }
  489. res.setData(getRecieveSendList(pNo, pSize));
  490. return res;
  491. }
  492. /**
  493. * 收发登记详情编辑保存
  494. *
  495. * @throws ParseException
  496. */
  497. @RequestMapping(value = "/saveRecieveSend", method = RequestMethod.POST)
  498. public Result recieveSendDetail(String rid, String pid, PatentRegistrationBo patentRegistrationBo)
  499. throws ParseException {
  500. Result res = new Result();
  501. patentRegistrationService.updateByPrimaryKey(regBo2Reg(rid, pid, patentRegistrationBo));
  502. return res;
  503. }
  504. /**
  505. * 专利申请费用管理
  506. */
  507. @RequestMapping(value = "/getApplicationFeeList", method = RequestMethod.POST)
  508. public Result getApplicationFeeList(
  509. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  510. String locationProvince, String pageNo, String pageSize) throws ParseException {
  511. Result res = new Result();
  512. Integer pNo = 1;
  513. Integer pSize = 10;
  514. if (StringUtils.isNumeric(pageSize)) {
  515. pSize = Integer.parseInt(pageSize);
  516. }
  517. if (StringUtils.isNumeric(pageNo)) {
  518. pNo = Integer.parseInt(pageNo);
  519. }
  520. res.setData(getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize));
  521. return res;
  522. }
  523. /**
  524. * 登记申请费用
  525. */
  526. @RequestMapping(value = "/registerApplicationFee", method = RequestMethod.POST)
  527. public Result registerApplicationFee(PatentCost patentCost, String cid) {
  528. Result res = new Result();
  529. PatentCost p = new PatentCost();
  530. p.setId(cid);
  531. p.setApplicationFee(patentCost.getApplicationFee());
  532. p.setReimbursement(patentCost.getReimbursement());
  533. p.setFunds(patentCost.getFunds());
  534. p.setTrialFee(patentCost.getTrialFee());
  535. p.setPrintingFee(patentCost.getPrintingFee());
  536. p.setPaymentState(patentCost.getPaymentState());
  537. res.setData(patentCostService.updateByPrimaryKeySelective(p));
  538. return res;
  539. }
  540. /**
  541. * 专利综合管理报表导出
  542. *
  543. * @throws ParseException
  544. */
  545. @RequestMapping(value = "/exportComposite", method = RequestMethod.GET)
  546. public Result exportComposite(@RequestParam(name = "serialNumber", required = false) String serialNumber,
  547. String patentNumber, String office, String locationProvince, String unitName,
  548. @RequestParam(name = "patentCatagory", required = false) String patentCatagory, String patentName,
  549. @RequestParam(name = "patentState", required = false) String patentState,
  550. @RequestParam(name = "createTime[]", required = false) String[] createTime,
  551. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  552. String author, HttpServletResponse response) throws ParseException {
  553. Result res = new Result();
  554. Integer sn = (!StringUtils.isNumeric(serialNumber) ? null : Integer.parseInt(serialNumber));
  555. Integer pc = (!StringUtils.isNumeric(patentCatagory) ? null : Integer.parseInt(patentCatagory));
  556. Integer ps = (!StringUtils.isNumeric(patentState) ? null : Integer.parseInt(patentState));
  557. String lp = ("undefined".equals(locationProvince)) ? null : locationProvince;
  558. @SuppressWarnings("unchecked")
  559. List<PatentCompositeBo> composites = (List<PatentCompositeBo>) getManagePatentList(sn, patentNumber, office, lp,
  560. unitName, pc, patentName, ps, createTime, patentApplicationDate, author, 1, 1000).getList();
  561. if (res.getError().isEmpty()) {
  562. exportComosites(response, composites);
  563. } else {
  564. FileUtils.out(response, res.toString());
  565. }
  566. return res;
  567. }
  568. /**
  569. * 待缴年登印费专利管理报表导出
  570. */
  571. @RequestMapping(value = "/exportPending", method = RequestMethod.GET)
  572. public Result exportPending(String locationProvince, HttpServletResponse response) {
  573. Result res = new Result();
  574. @SuppressWarnings("unchecked")
  575. List<PatentPendingBo> pendings = (List<PatentPendingBo>) getManagePendingPaymentList(locationProvince, 1, 1000)
  576. .getList();
  577. if (res.getError().isEmpty()) {
  578. exportPendings(response, pendings);
  579. } else {
  580. FileUtils.out(response, res.toString());
  581. }
  582. return res;
  583. }
  584. /**
  585. * 专利申请费用管理报表导出
  586. *
  587. * @throws ParseException
  588. */
  589. @RequestMapping(value = "/exportApplicationFee", method = RequestMethod.GET)
  590. public Result exportApplicationFee(
  591. @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate,
  592. String locationProvince, HttpServletResponse response) throws ParseException {
  593. Result res = new Result();
  594. @SuppressWarnings("unchecked")
  595. List<PatentApplicationFeeBo> fees = (List<PatentApplicationFeeBo>) getApplicationFeeList(patentApplicationDate,
  596. locationProvince, 1, 1000).getList();
  597. if (res.getError().isEmpty()) {
  598. exportFees(response, fees);
  599. } else {
  600. FileUtils.out(response, res.toString());
  601. }
  602. return res;
  603. }
  604. // 专利申请费用管理报表
  605. private void exportFees(HttpServletResponse response, List<PatentApplicationFeeBo> fees) {
  606. String sheetName = "专利申请费用管理报表";
  607. HSSFWorkbook workbook = createWorkbook(sheetName, new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利名称", "缴费状态",
  608. "申请费", "实审费", "文印费", "是否请款", "是否报销", "申请日", "缴费截止时间" });
  609. HSSFSheet sheet = workbook.getSheet(sheetName);
  610. for (int i = 0; i < fees.size(); i++) {
  611. PatentApplicationFeeBo obj = fees.get(i);
  612. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  613. if (null == obj.getSerialNumber()) {
  614. row.createCell(0).setCellValue("");
  615. } else {
  616. row.createCell(0).setCellValue(obj.getSerialNumber());
  617. }
  618. row.createCell(1).setCellValue(obj.getPatentNumber());
  619. row.createCell(2).setCellValue(obj.getLocationProvince());
  620. row.createCell(3).setCellValue(obj.getUnitName());
  621. row.createCell(4).setCellValue(obj.getPatentName());
  622. if (null != obj.getPaymentState()) {
  623. switch (obj.getPaymentState()) {
  624. case 0:
  625. row.createCell(5).setCellValue("未缴费");
  626. break;
  627. case 1:
  628. row.createCell(5).setCellValue("已缴费");
  629. }
  630. } else {
  631. row.createCell(5).setCellValue("未缴费");
  632. }
  633. row.createCell(6).setCellValue(null == obj.getApplicationFee() ? 0 : obj.getApplicationFee());
  634. row.createCell(7).setCellValue(null == obj.getTrialFee() ? 0 : obj.getTrialFee());
  635. row.createCell(8).setCellValue(null == obj.getPrintingFee() ? 0 : obj.getPrintingFee());
  636. if (null != obj.getFunds()) {
  637. switch (obj.getFunds()) {
  638. case 0:
  639. row.createCell(9).setCellValue("否");
  640. break;
  641. case 1:
  642. row.createCell(9).setCellValue("是");
  643. }
  644. } else {
  645. row.createCell(9).setCellValue("否");
  646. }
  647. if (null != obj.getReimbursement()) {
  648. switch (obj.getReimbursement()) {
  649. case 0:
  650. row.createCell(10).setCellValue("否");
  651. break;
  652. case 1:
  653. row.createCell(10).setCellValue("是");
  654. }
  655. } else {
  656. row.createCell(10).setCellValue("否");
  657. }
  658. row.createCell(11).setCellValue(obj.getPatentApplicationDateFormattedDate());
  659. row.createCell(12).setCellValue(null == obj.getPatentApplicationDateFormattedDate() ? ""
  660. : calDeadline(obj.getPatentApplicationDateFormattedDate()));
  661. }
  662. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  663. }
  664. // 待缴年登印费专利管理报表
  665. private void exportPendings(HttpServletResponse response, List<PatentPendingBo> pendings) {
  666. String sheetName = "待缴年登印费专利管理报表";
  667. HSSFWorkbook workbook = createWorkbook(sheetName,
  668. new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利类型", "专利名称", "专利状态", "缴费状态", "缴费截止日期" });
  669. HSSFSheet sheet = workbook.getSheet(sheetName);
  670. for (int i = 0; i < pendings.size(); i++) {
  671. PatentPendingBo obj = pendings.get(i);
  672. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  673. if (null == obj.getSerialNumber()) {
  674. row.createCell(0).setCellValue("");
  675. } else {
  676. row.createCell(0).setCellValue(obj.getSerialNumber());
  677. }
  678. row.createCell(1).setCellValue(obj.getPatentNumber());
  679. row.createCell(2).setCellValue(obj.getLocationProvince());
  680. row.createCell(3).setCellValue(obj.getUnitName());
  681. if (null != obj.getPatentCatagory()) {
  682. switch (obj.getPatentCatagory()) {
  683. case 0:
  684. row.createCell(4).setCellValue("发明型专利");
  685. break;
  686. case 1:
  687. row.createCell(4).setCellValue("科技型专利");
  688. break;
  689. case 2:
  690. row.createCell(4).setCellValue("外观型专利");
  691. break;
  692. }
  693. } else {
  694. row.createCell(4).setCellValue("");
  695. }
  696. row.createCell(5).setCellValue(obj.getPatentName());
  697. row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
  698. if (null != obj.getAnnualFeeState()) {
  699. switch (obj.getAnnualFeeState()) {
  700. case 0:
  701. row.createCell(7).setCellValue("未缴费");
  702. break;
  703. case 1:
  704. row.createCell(7).setCellValue("已缴费");
  705. break;
  706. }
  707. } else {
  708. row.createCell(7).setCellValue("未缴费");
  709. }
  710. row.createCell(8).setCellValue(null == obj.getAuthorizedDateFormattedDate() ? ""
  711. : calDeadline(obj.getAuthorizedDateFormattedDate()));
  712. }
  713. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  714. }
  715. private void exportComosites(HttpServletResponse response, List<PatentCompositeBo> composites) {
  716. String sheetName = "专利综合管理报表";
  717. HSSFWorkbook workbook = createWorkbook(sheetName,
  718. new String[] { "编号", "申请号/专利号", "事务所", "省份", "公司名称", "专利名称", "专利状态", "派单日", "申请日", "授权日", "资料撰写人" });
  719. HSSFSheet sheet = workbook.getSheet(sheetName);
  720. // 将查询出的数据设置到sheet对应的单元格中
  721. for (int i = 0; i < composites.size(); i++) {
  722. PatentCompositeBo obj = composites.get(i);// 遍历每个对象
  723. HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数
  724. if (null == obj.getSerialNumber()) {
  725. row.createCell(0).setCellValue("");
  726. } else {
  727. row.createCell(0).setCellValue(obj.getSerialNumber());
  728. }
  729. row.createCell(1).setCellValue(obj.getPatentNumber());
  730. row.createCell(2).setCellValue(obj.getOffice());
  731. row.createCell(3).setCellValue(obj.getLocationProvince());
  732. row.createCell(4).setCellValue(obj.getUnitName());
  733. row.createCell(5).setCellValue(obj.getPatentName());
  734. row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
  735. row.createCell(7).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState()));
  736. row.createCell(8).setCellValue(obj.getCreateTimeFormattedDate());
  737. row.createCell(9).setCellValue(obj.getPatentApplicationFormattedDate());
  738. row.createCell(10).setCellValue(obj.getPatentApplicationFormattedDate());
  739. row.createCell(11).setCellValue(obj.getAuthor());
  740. }
  741. FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook);
  742. }
  743. private HSSFWorkbook createWorkbook(String sheetName, String[] colNames) {
  744. HSSFWorkbook workbook = new HSSFWorkbook();
  745. HSSFSheet sheet = workbook.createSheet(sheetName);
  746. // 产生表格标题行
  747. HSSFRow rowm = sheet.createRow(0);
  748. HSSFCell cellTitle = rowm.createCell(0);
  749. cellTitle.setCellValue(sheetName);
  750. sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (colNames.length - 1)));
  751. HSSFRow rowRowName = sheet.createRow(1); // 在索引2的位置创建行(最顶端的行开始的第二行)
  752. // 将列头设置到sheet的单元格中
  753. for (int n = 0; n < colNames.length; n++) {
  754. rowRowName.createCell(n).setCellValue(colNames[n]);
  755. }
  756. return workbook;
  757. }
  758. /**
  759. * 专利相关材料上传
  760. *
  761. * @param req
  762. * @param sign
  763. * 材料类型标记,其中'patent_prory_statement'为专利代理委托书标记
  764. * @return
  765. *//*
  766. @RequestMapping(value = "/patentFile", method = RequestMethod.POST)
  767. public Result patentFile(HttpServletRequest req, String sign, String oid) {
  768. Result res = new Result();
  769. res.setData(handleFile(res, "/cognizannce/", true, req, sign, oid));
  770. return res;
  771. }*/
  772. /*private String handleFile(Result res, String path, boolean isPrivate, HttpServletRequest req, String sign,
  773. String oid) {
  774. List<MultipartFile> files = getFiles(req);
  775. MultipartFile mf = files.get(0);
  776. String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign, path,
  777. StringUtils.isBlank(oid) ? TokenManager.getUserId() : oid);
  778. if (!files.isEmpty()) {
  779. try {
  780. mf.transferTo(toPrivateFile(fileName));
  781. LoggerUtils.debug(getClass(), fileName + " 文件上传成功");
  782. } catch (IllegalStateException | IOException e) {
  783. LoggerUtils.error(getClass(), "文件上传失败", e);
  784. res.getError().add(buildError("", "文件上传失败!"));
  785. return "";
  786. }
  787. } else {
  788. res.getError().add(buildError("", "文件上传失败!"));
  789. return "";
  790. }
  791. return fileName;
  792. }*/
  793. // 专利纸件收发登记
  794. private Pagination<PatentRecieveSendBo> getRecieveSendList(Integer pNo, Integer pSize) {
  795. return patentRegistrationService.getRecieveSendList(pNo, pSize);
  796. }
  797. // 专利申请费用管理
  798. private Pagination<PatentApplicationFeeBo> getApplicationFeeList(String[] patentApplicationDate,
  799. String locationProvince, Integer pNo, Integer pSize) throws ParseException {
  800. return patentCostService.getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize);
  801. }
  802. // 补正审查通知列表
  803. private Pagination<PatentNoticeOfCorrectionBo> getNoticeOfCorrectionList(Date authorizedDate, Integer serialNumber,
  804. String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory,
  805. String patentName, Integer patentState, String author, Integer pNo, Integer pSize) {
  806. return patentInfoService.getNoticeOfCorrectionList(authorizedDate, serialNumber, patentNumber, office,
  807. locationProvince, unitName, patentCatagory, patentName, patentState, author, pNo, pSize);
  808. }
  809. // 待缴费专利管理
  810. private Pagination<PatentPendingBo> getManagePendingPaymentList(String locationProvince, Integer pNo,
  811. Integer pSize) {
  812. return patentInfoService.getManagePendingPaymentList(locationProvince, pNo, pSize);
  813. }
  814. // 管理端申请专利列表(专利综合管理)
  815. private Pagination<PatentManageListBo> getManagePatentList(Integer serialNumber, String patentNumber, String office,
  816. String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState,
  817. String[] createTime, String[] patentApplicationDate, String author, Integer pNo, Integer pSize)
  818. throws ParseException {
  819. return patentInfoService.getManagePatentList(serialNumber, patentNumber, office, locationProvince, unitName,
  820. patentCatagory, patentName, patentState, createTime, patentApplicationDate, author, pNo, pSize);
  821. }
  822. // 用户端申请专利列表
  823. private Pagination<PatentInfo> getClientApplyList(Result res, String patentNumber, String patentName,
  824. Integer patentCatagory, Integer patentState, Integer pNo, Integer pSize) {
  825. return patentInfoService.getClientApplyList(TokenManager.getUserId(), patentNumber, patentName, patentCatagory,
  826. patentState, pNo, pSize);
  827. }
  828. private PatentRegistration regBo2Reg(String rid, String pid, PatentRegistrationBo patentRegistrationBo)
  829. throws ParseException {
  830. PatentRegistration patentRegistration = new PatentRegistration();
  831. patentRegistration.setId(rid);
  832. patentRegistration.setAcceptanceExpressCompany(patentRegistrationBo.getAcceptanceExpressCompany());
  833. if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceIssueTime())) {
  834. patentRegistration.setAcceptanceIssueTime(
  835. DateUtils.parseDate(patentRegistrationBo.getAcceptanceIssueTime(), "yyyy-MM-dd"));
  836. } else {
  837. patentRegistration.setAcceptanceIssueTime(null);
  838. }
  839. if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceReceiveTime())) {
  840. patentRegistration.setAcceptanceReceiveTime(
  841. DateUtils.parseDate(patentRegistrationBo.getAcceptanceReceiveTime(), "yyyy-MM-dd"));
  842. } else {
  843. patentRegistration.setAcceptanceReceiveTime(null);
  844. }
  845. patentRegistration.setAcceptanceTrackingNumber(patentRegistrationBo.getAcceptanceTrackingNumber());
  846. patentRegistration.setAuthorizationExpressCompany(patentRegistrationBo.getAuthorizationExpressCompany());
  847. if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationIssueTime())) {
  848. patentRegistration.setAuthorizationIssueTime(
  849. DateUtils.parseDate(patentRegistrationBo.getAuthorizationIssueTime(), "yyyy-MM-dd"));
  850. } else {
  851. patentRegistration.setAuthorizationIssueTime(null);
  852. }
  853. if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationReceiveTime())) {
  854. patentRegistration.setAuthorizationReceiveTime(
  855. DateUtils.parseDate(patentRegistrationBo.getAuthorizationReceiveTime(), "yyyy-MM-dd"));
  856. } else {
  857. patentRegistration.setAuthorizationReceiveTime(null);
  858. }
  859. patentRegistration.setAuthorizationTrackingNumber(patentRegistrationBo.getAuthorizationTrackingNumber());
  860. patentRegistration.setCertificateExpressCompany(patentRegistrationBo.getCertificateExpressCompany());
  861. if (!StringUtils.isBlank(patentRegistrationBo.getCertificateIssueTime())) {
  862. patentRegistration.setCertificateIssueTime(
  863. DateUtils.parseDate(patentRegistrationBo.getCertificateIssueTime(), "yyyy-MM-dd"));
  864. } else {
  865. patentRegistration.setCertificateIssueTime(null);
  866. }
  867. if (!StringUtils.isBlank(patentRegistrationBo.getCertificateRecieveTime())) {
  868. patentRegistration.setCertificateRecieveTime(
  869. DateUtils.parseDate(patentRegistrationBo.getCertificateRecieveTime(), "yyyy-MM-dd"));
  870. } else {
  871. patentRegistration.setCertificateRecieveTime(null);
  872. }
  873. patentRegistration.setCertificateTrackingNumber(patentRegistrationBo.getCertificateTrackingNumber());
  874. patentRegistration.setPid(pid);
  875. return patentRegistration;
  876. }
  877. // 缴费截止日期
  878. private String calDeadline(String s) {
  879. String[] arr = s.split("-");
  880. String y = arr[0];
  881. String m = arr[1];
  882. String d = arr[2];
  883. if ("11".equals(arr[0])) {
  884. m = "01";
  885. y = String.valueOf(Integer.parseInt(y) + 1);
  886. } else if ("12".equals(arr[0])) {
  887. m = "02";
  888. y = String.valueOf(Integer.parseInt(y) + 1);
  889. } else {
  890. m = String.valueOf(Integer.parseInt(m) + 2);
  891. }
  892. return y + m + d;
  893. }
  894. // 专利状态
  895. private String switchPatState(Integer s) {
  896. String state = "";
  897. switch (s) {
  898. case 11:
  899. state = "撤销";
  900. break;
  901. case 1:
  902. state = "申请";
  903. break;
  904. case 2:
  905. state = "撰写";
  906. break;
  907. case 3:
  908. state = "受理";
  909. break;
  910. case 4:
  911. state = "审查意见通知";
  912. break;
  913. case 5:
  914. state = "审查意见已答复";
  915. break;
  916. case 6:
  917. state = "补正通知";
  918. break;
  919. case 7:
  920. state = "补正已答复";
  921. break;
  922. case 8:
  923. state = "授权";
  924. break;
  925. case 9:
  926. state = "驳回";
  927. break;
  928. case 10:
  929. state = "发证";
  930. break;
  931. }
  932. return state;
  933. }
  934. // 判断用户是否通过认证
  935. private Result checkCertify(Result res, String uid) {
  936. OrganizationIdentity o = organizationIdentityServivce.selectOrgIdentityByUserId(uid);
  937. if (null == o || 5 != o.getAuditStatus()) {
  938. res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
  939. }
  940. return res;
  941. }
  942. }