PatentApiController.java 38 KB

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