PatentApiController.java 36 KB

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