PatentApiController.java 34 KB

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