PatentApiController.java 37 KB

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