package com.goafanti.patent.controller; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.util.CellRangeAddress; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import com.goafanti.admin.service.AftFileService; import com.goafanti.cognizance.service.OrgIntellectualPropertyService; import com.goafanti.common.bo.Result; import com.goafanti.common.constant.ErrorConstants; import com.goafanti.common.controller.CertifyApiController; import com.goafanti.common.enums.AttachmentType; import com.goafanti.common.enums.PatentInfoFields; import com.goafanti.common.enums.PatentInfoStatus; import com.goafanti.common.model.Admin; import com.goafanti.common.model.AftFile; import com.goafanti.common.model.OrganizationIdentity; import com.goafanti.common.model.PatentCost; import com.goafanti.common.model.PatentInfo; import com.goafanti.common.model.PatentLog; import com.goafanti.common.model.PatentRegistration; import com.goafanti.common.model.User; import com.goafanti.common.utils.DateUtils; import com.goafanti.common.utils.FileUtils; import com.goafanti.common.utils.StringUtils; import com.goafanti.core.mybatis.page.Pagination; import com.goafanti.core.shiro.token.TokenManager; import com.goafanti.patent.bo.InputPatentInfo; import com.goafanti.patent.bo.PatentApplicationFeeBo; import com.goafanti.patent.bo.PatentCompositeBo; import com.goafanti.patent.bo.PatentManageListBo; import com.goafanti.patent.bo.PatentNoticeOfCorrectionBo; import com.goafanti.patent.bo.PatentPendingBo; import com.goafanti.patent.bo.PatentRecieveSendBo; import com.goafanti.patent.bo.PatentRegistrationBo; import com.goafanti.patent.service.AdminService; import com.goafanti.patent.service.PatentCostService; import com.goafanti.patent.service.PatentInfoService; import com.goafanti.patent.service.PatentLogService; import com.goafanti.patent.service.PatentRegistrationService; import com.goafanti.user.service.OrganizationIdentityService; import com.goafanti.user.service.UserService; @Controller @RequestMapping(value = "/techservice/patent") public class PatentApiController extends CertifyApiController { @Resource private PatentInfoService patentInfoService; @Resource private PatentLogService patentLogService; @Resource private OrganizationIdentityService organizationIdentityServivce; @Resource private PatentCostService patentCostService; @Resource private PatentRegistrationService patentRegistrationService; @Resource private AdminService adminService; @Resource private OrgIntellectualPropertyService orgIntellectualPropertyService; @Resource private UserService userService; @Resource private AftFileService aftFileService; @Value(value = "${upload.private.path}") private String uploadPrivatePath = null; /** * 专利相关材料上传 * @param req * @param uid * @param sign * @return */ @RequestMapping(value = "/upload", method = RequestMethod.POST) public Result upload(HttpServletRequest req, String sign){ Result res = new Result(); if (!checkUserLogin(res)) { return res; } User curUser = TokenManager.getUserToken(); if (!checkCertify(res, curUser)) { return res; } AttachmentType attachmentType = AttachmentType.getField(sign); if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT || attachmentType == AttachmentType.PATENT_WRITING || attachmentType == AttachmentType.AUTHORIZATION_NOTICE || attachmentType == AttachmentType.PATENT_CERTIFICATE) { res.setData(handleFiles(res, "/patent/", true, req, sign, TokenManager.getUserId())); } else { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示")); } return res; } /** * 下载专利相关材料 * * @param id * @param sign * @param response * @return */ @RequestMapping(value = "/download", method = RequestMethod.GET) public Result download(String id, String sign, HttpServletResponse response) { Result res = new Result(); if (!checkAdminLogin(res)) { return res; } if (StringUtils.isEmpty(id)) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id")); return res; } PatentInfo pi = patentInfoService.selectByPrimaryKey(id); if (pi == null) { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利id")); return res; } AttachmentType attachmentType = AttachmentType.getField(sign); if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT || attachmentType == AttachmentType.PATENT_WRITING || attachmentType == AttachmentType.AUTHORIZATION_NOTICE || attachmentType == AttachmentType.PATENT_CERTIFICATE) { if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) { downloadFile(response, pi.getPatentProryStatementDownloadFileName(), pi.getPatentProryStatementUrl()); } else if (attachmentType == AttachmentType.PATENT_WRITING) { downloadFile(response, pi.getPatentWritingDownloadFileName(), pi.getPatentWritingUrl()); } else if (attachmentType == AttachmentType.AUTHORIZATION_NOTICE) { downloadFile(response, pi.getAuthorizationNoticeDownloadFileName(), pi.getAuthorizationNoticeUrl()); } else if (attachmentType == AttachmentType.PATENT_CERTIFICATE){ downloadFile(response, pi.getPatentCertificateDownloadFileName(), pi.getPatentCertificateUrl()); } } else{ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示")); } return res; } /** * 下载模版文件(专利代理委托书) * * @param response * @return */ @RequestMapping(value = "/downloadTemplateFile", method = RequestMethod.GET) public Result downloadTemplateFile(HttpServletResponse response, String sign) { Result res = new Result(); if (!checkAdminLogin(res)) { return res; } AttachmentType attachmentType = AttachmentType.getField(sign); if (attachmentType == AttachmentType.PATENT_PRORY_STATEMENT) { String fileName = ""; AftFile af = aftFileService.selectAftFileBySign(sign); if (null == af) { res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "找不到", "文件")); } else { String path = af.getFilePath(); String suffix = path.substring(path.lastIndexOf(".")); fileName = "专利代理委托书模版" + suffix; downloadFile(response, fileName, path); } } else { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利代理委托书标示")); } return res; } /** * 用户端专利申请 */ @RequestMapping(value = "/clientApplyPatent", method = RequestMethod.POST) public Result clientApplyPatent(@Valid InputPatentInfo patentInfo, BindingResult bindingResult) { Result res = new Result(); if (bindingResult.hasErrors()) { res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(), PatentInfoFields.getFieldDesc(bindingResult.getFieldError().getField()))); return res; } if (!checkUserLogin(res)) { return res; } User curUser = TokenManager.getUserToken(); if (!checkCertify(res, curUser)) { return res; } String aid = curUser.getAid(); PatentInfo pi = new PatentInfo(); BeanUtils.copyProperties(patentInfo, pi); pi.setUid(TokenManager.getUserId()); res.setData(patentInfoService.savePatentInfo(pi, aid)); return res; } /** * 用户端专利详情 * */ @RequestMapping(value = "/clientPatentInfo", method = RequestMethod.GET) public Result clientPatentInfo(String pid) { Result res = new Result(); if (!checkUserLogin(res)) { return res; } if (StringUtils.isBlank(pid)) { res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID")); } else { PatentInfo pi = patentInfoService.selectByPrimaryKey(pid); if (null != pi.getUid() && pi.getUid().equals(TokenManager.getUserId())) { res.setData(pi); } else { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利ID")); } } res.setData(patentInfoService.selectByPrimaryKey(pid)); return res; } /** * 用户端申请专利列表 */ @RequestMapping(value = "/clientApplyList", method = RequestMethod.GET) public Result clientApplyList(String patentNumber, String patentName, Integer patentCatagory, Integer patentState, String pageNo, String pageSize) { Result res = new Result(); if (!checkUserLogin(res)) { return res; } Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getClientApplyList(res, patentNumber, patentName, patentCatagory, patentState, pNo, pSize)); return res; } /** * 用户端logs */ @RequestMapping(value = "/patentProcess", method = RequestMethod.GET) public Result patentProcess(String pid) { Result res = new Result(); if (!checkUserLogin(res)) { return res; } if (StringUtils.isBlank(pid)) { res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "专利ID")); return res; } PatentInfo pi = patentInfoService.selectByPrimaryKey(pid); if (null != pi.getUid() && pi.getUid().equals(TokenManager.getUserId())) { List list = patentLogService.selectProcessByPid(pid); for (PatentLog log : list){ if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.SIGN){ log.setState(PatentInfoStatus.CREATE.getCode()); } if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.CIRCULATION){ log.setState(PatentInfoStatus.DELIVERD.getCode()); } if (PatentInfoStatus.getStatus(log.getState()) == PatentInfoStatus.SETTLEMENT){ log.setState(PatentInfoStatus.LICENSE.getCode()); } } res.setData(list); } else { res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利d")); } return res; } /** * 用户确认申报材料 * * @return */ @RequestMapping(value = "/clientConfirm", method = RequestMethod.POST) public Result clientConfirmApplicationMaterials(String pid) { Result res = new Result(); if (!checkUserLogin(res)) { return res; } if (StringUtils.isBlank(pid)){ res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "专利d")); return res; } PatentInfo p = new PatentInfo(); p.setId(pid); p.setConfirmState(1); res.setData(patentInfoService.updateByPrimaryKeySelective(p)); return res; } /** * 删除专利记录 * * @param ids * @return */ @RequestMapping(value = "/deletePatent", method = RequestMethod.POST) public Result deletePatent(@RequestParam(name = "ids[]", required = true) String[] ids) { Result res = new Result(); List id = new ArrayList(); for (String s : ids) { id.add(s); } res.setData(patentInfoService.batchDeleteByPrimaryKey(id)); return res; } /** * 管理端申请专利列表 * * @throws ParseException */ @RequestMapping(value = "/managePatentList", method = RequestMethod.POST) public Result managePatentList(Integer serialNumber, String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState, @RequestParam(name = "createTime[]", required = false) String[] createTime, @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate, String author, String pageNo, String pageSize) throws ParseException { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getManagePatentList(serialNumber, patentNumber, office, locationProvince, unitName, patentCatagory, patentName, patentState, createTime, patentApplicationDate, author, pNo, pSize)); return res; } /** * 获取公司 */ @RequestMapping(value = "/getUnitNames", method = RequestMethod.GET) public Result getUnitNames() { Result res = new Result(); List list = organizationIdentityServivce.selectAllOrgIndentity(); Map map = new TreeMap(); for (OrganizationIdentity o : list) { map.put(o.getUid(), o.getUnitName()); } res.setData(map); return res; } /** * 获取管理员 */ @RequestMapping(value = "/getAdmin", method = RequestMethod.GET) public Result getAdmin() { Result res = new Result(); List admin = adminService.selectAllAdmin(); Map map = new LinkedHashMap(); for (Admin a : admin) { map.put(a.getId(), a.getName()); } res.setData(map); return res; } /** * 管理端新增专利申请 */ @RequestMapping(value = "/manageApplyPatent", method = RequestMethod.POST) public Result manageApplyPatent(PatentInfo patentInfo, String uid) { Result res = new Result(); res = checkCertify(res, uid); if (res.getError().isEmpty()) { String aid = userService.selectByPrimaryKey(uid).getAid(); res.setData(patentInfoService.savePatentInfo(patentInfo, aid)); } return res; } /** * 管理端专利详情修改保存 * * @throws ParseException */ @RequestMapping(value = "/managePatentInfo", method = RequestMethod.POST) public Result managePatentInfo(String patentNumber, String patentName, String patentCatagory, String patentField, String patentDes, String patentWritingUrl, String authorizationNoticeUrl, String patentCertificateUrl, String xid, PatentLog patentLog, String recordTimeFormattedDate, Integer pState) throws ParseException { Result res = new Result(); PatentInfo patentInfo = new PatentInfo(); patentInfo.setId(xid); patentInfo.setPatentState(pState); patentInfo.setPatentName(patentName); patentInfo.setPatentNumber(patentNumber); patentInfo.setPatentCatagory(StringUtils.isNumeric(patentCatagory) ? Integer.parseInt(patentCatagory) : null); patentInfo.setPatentField(StringUtils.isNumeric(patentField) ? Integer.parseInt(patentField) : null); patentInfo.setPatentDes(patentDes); patentInfo.setPatentWritingUrl(patentWritingUrl); patentInfo.setAuthorizationNoticeUrl(authorizationNoticeUrl); patentInfo.setPatentCertificateUrl(patentCertificateUrl); Date recordTime = null; if (!StringUtils.isBlank(recordTimeFormattedDate)) { recordTime = DateUtils.parseDate(recordTimeFormattedDate, "yyyy-MM-dd"); } patentInfoService.updatePatentInfo(patentInfo, patentLog, recordTime); return res; } /** * 待缴费专利管理 */ @RequestMapping(value = "/managePendingPaymentList", method = RequestMethod.POST) public Result managePendingPaymentList(String locationProvince, String pageNo, String pageSize) { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getManagePendingPaymentList(locationProvince, pNo, pSize)); return res; } /** * 年费确认缴费 */ @RequestMapping(value = "/confirmPayment", method = RequestMethod.POST) public Result confirmPayment(String cid) { Result res = new Result(); if (StringUtils.isBlank(cid)) { res.getError().add(buildError("", "确认缴费失败!")); return res; } PatentCost patentCost = new PatentCost(); patentCost.setId(cid); patentCost.setAnnualFeeState(1); patentCostService.updateByPrimaryKeySelective(patentCost); return res; } /** * 补正审查通知列表 */ @RequestMapping(value = "/noticeOfCorrectionList", method = RequestMethod.POST) public Result noticeOfCorrectionList(Date authorizedDate, Integer serialNumber, String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState, String author, String pageNo, String pageSize) { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getNoticeOfCorrectionList(authorizedDate, serialNumber, patentNumber, office, locationProvince, unitName, patentCatagory, patentName, patentState, author, pNo, pSize)); return res; } /** * 补正审查通知答复确认 */ @RequestMapping(value = "/replyConfirm", method = RequestMethod.POST) public Result replyConfirm(String pid, Integer patentState) { Result res = new Result(); patentInfoService.updateNoticeOfCorrection(pid, patentState); return res; } /** * 收发详情入口/收发纸件登记 */ @RequestMapping(value = "/getRecieveSendList", method = RequestMethod.POST) public Result RecieveSendList(String pageNo, String pageSize) { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getRecieveSendList(pNo, pSize)); return res; } /** * 收发登记详情编辑保存 * * @throws ParseException */ @RequestMapping(value = "/saveRecieveSend", method = RequestMethod.POST) public Result recieveSendDetail(String rid, String pid, PatentRegistrationBo patentRegistrationBo) throws ParseException { Result res = new Result(); patentRegistrationService.updateByPrimaryKey(regBo2Reg(rid, pid, patentRegistrationBo)); return res; } /** * 专利申请费用管理 */ @RequestMapping(value = "/getApplicationFeeList", method = RequestMethod.POST) public Result getApplicationFeeList( @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate, String locationProvince, String pageNo, String pageSize) throws ParseException { Result res = new Result(); Integer pNo = 1; Integer pSize = 10; if (StringUtils.isNumeric(pageSize)) { pSize = Integer.parseInt(pageSize); } if (StringUtils.isNumeric(pageNo)) { pNo = Integer.parseInt(pageNo); } res.setData(getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize)); return res; } /** * 登记申请费用 */ @RequestMapping(value = "/registerApplicationFee", method = RequestMethod.POST) public Result registerApplicationFee(PatentCost patentCost, String cid) { Result res = new Result(); PatentCost p = new PatentCost(); p.setId(cid); p.setApplicationFee(patentCost.getApplicationFee()); p.setReimbursement(patentCost.getReimbursement()); p.setFunds(patentCost.getFunds()); p.setTrialFee(patentCost.getTrialFee()); p.setPrintingFee(patentCost.getPrintingFee()); p.setPaymentState(patentCost.getPaymentState()); res.setData(patentCostService.updateByPrimaryKeySelective(p)); return res; } /** * 专利综合管理报表导出 * * @throws ParseException */ @RequestMapping(value = "/exportComposite", method = RequestMethod.GET) public Result exportComposite(@RequestParam(name = "serialNumber", required = false) String serialNumber, String patentNumber, String office, String locationProvince, String unitName, @RequestParam(name = "patentCatagory", required = false) String patentCatagory, String patentName, @RequestParam(name = "patentState", required = false) String patentState, @RequestParam(name = "createTime[]", required = false) String[] createTime, @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate, String author, HttpServletResponse response) throws ParseException { Result res = new Result(); Integer sn = (!StringUtils.isNumeric(serialNumber) ? null : Integer.parseInt(serialNumber)); Integer pc = (!StringUtils.isNumeric(patentCatagory) ? null : Integer.parseInt(patentCatagory)); Integer ps = (!StringUtils.isNumeric(patentState) ? null : Integer.parseInt(patentState)); String lp = ("undefined".equals(locationProvince)) ? null : locationProvince; @SuppressWarnings("unchecked") List composites = (List) getManagePatentList(sn, patentNumber, office, lp, unitName, pc, patentName, ps, createTime, patentApplicationDate, author, 1, 1000).getList(); if (res.getError().isEmpty()) { exportComosites(response, composites); } else { FileUtils.out(response, res.toString()); } return res; } /** * 待缴年登印费专利管理报表导出 */ @RequestMapping(value = "/exportPending", method = RequestMethod.GET) public Result exportPending(String locationProvince, HttpServletResponse response) { Result res = new Result(); @SuppressWarnings("unchecked") List pendings = (List) getManagePendingPaymentList(locationProvince, 1, 1000) .getList(); if (res.getError().isEmpty()) { exportPendings(response, pendings); } else { FileUtils.out(response, res.toString()); } return res; } /** * 专利申请费用管理报表导出 * * @throws ParseException */ @RequestMapping(value = "/exportApplicationFee", method = RequestMethod.GET) public Result exportApplicationFee( @RequestParam(name = "patentApplicationDate[]", required = false) String[] patentApplicationDate, String locationProvince, HttpServletResponse response) throws ParseException { Result res = new Result(); @SuppressWarnings("unchecked") List fees = (List) getApplicationFeeList(patentApplicationDate, locationProvince, 1, 1000).getList(); if (res.getError().isEmpty()) { exportFees(response, fees); } else { FileUtils.out(response, res.toString()); } return res; } // 专利申请费用管理报表 private void exportFees(HttpServletResponse response, List fees) { String sheetName = "专利申请费用管理报表"; HSSFWorkbook workbook = createWorkbook(sheetName, new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利名称", "缴费状态", "申请费", "实审费", "文印费", "是否请款", "是否报销", "申请日", "缴费截止时间" }); HSSFSheet sheet = workbook.getSheet(sheetName); for (int i = 0; i < fees.size(); i++) { PatentApplicationFeeBo obj = fees.get(i); HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数 if (null == obj.getSerialNumber()) { row.createCell(0).setCellValue(""); } else { row.createCell(0).setCellValue(obj.getSerialNumber()); } row.createCell(1).setCellValue(obj.getPatentNumber()); row.createCell(2).setCellValue(obj.getLocationProvince()); row.createCell(3).setCellValue(obj.getUnitName()); row.createCell(4).setCellValue(obj.getPatentName()); if (null != obj.getPaymentState()) { switch (obj.getPaymentState()) { case 0: row.createCell(5).setCellValue("未缴费"); break; case 1: row.createCell(5).setCellValue("已缴费"); } } else { row.createCell(5).setCellValue("未缴费"); } row.createCell(6).setCellValue(null == obj.getApplicationFee() ? 0 : obj.getApplicationFee()); row.createCell(7).setCellValue(null == obj.getTrialFee() ? 0 : obj.getTrialFee()); row.createCell(8).setCellValue(null == obj.getPrintingFee() ? 0 : obj.getPrintingFee()); if (null != obj.getFunds()) { switch (obj.getFunds()) { case 0: row.createCell(9).setCellValue("否"); break; case 1: row.createCell(9).setCellValue("是"); } } else { row.createCell(9).setCellValue("否"); } if (null != obj.getReimbursement()) { switch (obj.getReimbursement()) { case 0: row.createCell(10).setCellValue("否"); break; case 1: row.createCell(10).setCellValue("是"); } } else { row.createCell(10).setCellValue("否"); } row.createCell(11).setCellValue(obj.getPatentApplicationDateFormattedDate()); row.createCell(12).setCellValue(null == obj.getPatentApplicationDateFormattedDate() ? "" : calDeadline(obj.getPatentApplicationDateFormattedDate())); } FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook); } // 待缴年登印费专利管理报表 private void exportPendings(HttpServletResponse response, List pendings) { String sheetName = "待缴年登印费专利管理报表"; HSSFWorkbook workbook = createWorkbook(sheetName, new String[] { "编号", "申请号/专利号", "省份", "公司名称", "专利类型", "专利名称", "专利状态", "缴费状态", "缴费截止日期" }); HSSFSheet sheet = workbook.getSheet(sheetName); for (int i = 0; i < pendings.size(); i++) { PatentPendingBo obj = pendings.get(i); HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数 if (null == obj.getSerialNumber()) { row.createCell(0).setCellValue(""); } else { row.createCell(0).setCellValue(obj.getSerialNumber()); } row.createCell(1).setCellValue(obj.getPatentNumber()); row.createCell(2).setCellValue(obj.getLocationProvince()); row.createCell(3).setCellValue(obj.getUnitName()); if (null != obj.getPatentCatagory()) { switch (obj.getPatentCatagory()) { case 0: row.createCell(4).setCellValue("发明型专利"); break; case 1: row.createCell(4).setCellValue("科技型专利"); break; case 2: row.createCell(4).setCellValue("外观型专利"); break; } } else { row.createCell(4).setCellValue(""); } row.createCell(5).setCellValue(obj.getPatentName()); row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState())); if (null != obj.getAnnualFeeState()) { switch (obj.getAnnualFeeState()) { case 0: row.createCell(7).setCellValue("未缴费"); break; case 1: row.createCell(7).setCellValue("已缴费"); break; } } else { row.createCell(7).setCellValue("未缴费"); } row.createCell(8).setCellValue(null == obj.getAuthorizedDateFormattedDate() ? "" : calDeadline(obj.getAuthorizedDateFormattedDate())); } FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook); } private void exportComosites(HttpServletResponse response, List composites) { String sheetName = "专利综合管理报表"; HSSFWorkbook workbook = createWorkbook(sheetName, new String[] { "编号", "申请号/专利号", "事务所", "省份", "公司名称", "专利名称", "专利状态", "派单日", "申请日", "授权日", "资料撰写人" }); HSSFSheet sheet = workbook.getSheet(sheetName); // 将查询出的数据设置到sheet对应的单元格中 for (int i = 0; i < composites.size(); i++) { PatentCompositeBo obj = composites.get(i);// 遍历每个对象 HSSFRow row = sheet.createRow(i + 2);// 创建所需的行数 if (null == obj.getSerialNumber()) { row.createCell(0).setCellValue(""); } else { row.createCell(0).setCellValue(obj.getSerialNumber()); } row.createCell(1).setCellValue(obj.getPatentNumber()); row.createCell(2).setCellValue(obj.getOffice()); row.createCell(3).setCellValue(obj.getLocationProvince()); row.createCell(4).setCellValue(obj.getUnitName()); row.createCell(5).setCellValue(obj.getPatentName()); row.createCell(6).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState())); row.createCell(7).setCellValue(null == obj.getPatentState() ? "" : switchPatState(obj.getPatentState())); row.createCell(8).setCellValue(obj.getCreateTimeFormattedDate()); row.createCell(9).setCellValue(obj.getPatentApplicationFormattedDate()); row.createCell(10).setCellValue(obj.getPatentApplicationFormattedDate()); row.createCell(11).setCellValue(obj.getAuthor()); } FileUtils.downloadExcel(response, sheetName + Calendar.getInstance().getTimeInMillis() + ".xls", workbook); } private HSSFWorkbook createWorkbook(String sheetName, String[] colNames) { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(sheetName); // 产生表格标题行 HSSFRow rowm = sheet.createRow(0); HSSFCell cellTitle = rowm.createCell(0); cellTitle.setCellValue(sheetName); sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (colNames.length - 1))); HSSFRow rowRowName = sheet.createRow(1); // 在索引2的位置创建行(最顶端的行开始的第二行) // 将列头设置到sheet的单元格中 for (int n = 0; n < colNames.length; n++) { rowRowName.createCell(n).setCellValue(colNames[n]); } return workbook; } /** * 专利相关材料上传 * * @param req * @param sign * 材料类型标记,其中'patent_prory_statement'为专利代理委托书标记 * @return *//* @RequestMapping(value = "/patentFile", method = RequestMethod.POST) public Result patentFile(HttpServletRequest req, String sign, String oid) { Result res = new Result(); res.setData(handleFile(res, "/cognizannce/", true, req, sign, oid)); return res; }*/ /*private String handleFile(Result res, String path, boolean isPrivate, HttpServletRequest req, String sign, String oid) { List files = getFiles(req); MultipartFile mf = files.get(0); String fileName = FileUtils.mosaicFileName(mf, isPrivate, sign, path, StringUtils.isBlank(oid) ? TokenManager.getUserId() : oid); if (!files.isEmpty()) { try { mf.transferTo(toPrivateFile(fileName)); LoggerUtils.debug(getClass(), fileName + " 文件上传成功"); } catch (IllegalStateException | IOException e) { LoggerUtils.error(getClass(), "文件上传失败", e); res.getError().add(buildError("", "文件上传失败!")); return ""; } } else { res.getError().add(buildError("", "文件上传失败!")); return ""; } return fileName; }*/ // 专利纸件收发登记 private Pagination getRecieveSendList(Integer pNo, Integer pSize) { return patentRegistrationService.getRecieveSendList(pNo, pSize); } // 专利申请费用管理 private Pagination getApplicationFeeList(String[] patentApplicationDate, String locationProvince, Integer pNo, Integer pSize) throws ParseException { return patentCostService.getApplicationFeeList(patentApplicationDate, locationProvince, pNo, pSize); } // 补正审查通知列表 private Pagination getNoticeOfCorrectionList(Date authorizedDate, Integer serialNumber, String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState, String author, Integer pNo, Integer pSize) { return patentInfoService.getNoticeOfCorrectionList(authorizedDate, serialNumber, patentNumber, office, locationProvince, unitName, patentCatagory, patentName, patentState, author, pNo, pSize); } // 待缴费专利管理 private Pagination getManagePendingPaymentList(String locationProvince, Integer pNo, Integer pSize) { return patentInfoService.getManagePendingPaymentList(locationProvince, pNo, pSize); } // 管理端申请专利列表(专利综合管理) private Pagination getManagePatentList(Integer serialNumber, String patentNumber, String office, String locationProvince, String unitName, Integer patentCatagory, String patentName, Integer patentState, String[] createTime, String[] patentApplicationDate, String author, Integer pNo, Integer pSize) throws ParseException { return patentInfoService.getManagePatentList(serialNumber, patentNumber, office, locationProvince, unitName, patentCatagory, patentName, patentState, createTime, patentApplicationDate, author, pNo, pSize); } // 用户端申请专利列表 private Pagination getClientApplyList(Result res, String patentNumber, String patentName, Integer patentCatagory, Integer patentState, Integer pNo, Integer pSize) { return patentInfoService.getClientApplyList(TokenManager.getUserId(), patentNumber, patentName, patentCatagory, patentState, pNo, pSize); } private PatentRegistration regBo2Reg(String rid, String pid, PatentRegistrationBo patentRegistrationBo) throws ParseException { PatentRegistration patentRegistration = new PatentRegistration(); patentRegistration.setId(rid); patentRegistration.setAcceptanceExpressCompany(patentRegistrationBo.getAcceptanceExpressCompany()); if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceIssueTime())) { patentRegistration.setAcceptanceIssueTime( DateUtils.parseDate(patentRegistrationBo.getAcceptanceIssueTime(), "yyyy-MM-dd")); } else { patentRegistration.setAcceptanceIssueTime(null); } if (!StringUtils.isBlank(patentRegistrationBo.getAcceptanceReceiveTime())) { patentRegistration.setAcceptanceReceiveTime( DateUtils.parseDate(patentRegistrationBo.getAcceptanceReceiveTime(), "yyyy-MM-dd")); } else { patentRegistration.setAcceptanceReceiveTime(null); } patentRegistration.setAcceptanceTrackingNumber(patentRegistrationBo.getAcceptanceTrackingNumber()); patentRegistration.setAuthorizationExpressCompany(patentRegistrationBo.getAuthorizationExpressCompany()); if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationIssueTime())) { patentRegistration.setAuthorizationIssueTime( DateUtils.parseDate(patentRegistrationBo.getAuthorizationIssueTime(), "yyyy-MM-dd")); } else { patentRegistration.setAuthorizationIssueTime(null); } if (!StringUtils.isBlank(patentRegistrationBo.getAuthorizationReceiveTime())) { patentRegistration.setAuthorizationReceiveTime( DateUtils.parseDate(patentRegistrationBo.getAuthorizationReceiveTime(), "yyyy-MM-dd")); } else { patentRegistration.setAuthorizationReceiveTime(null); } patentRegistration.setAuthorizationTrackingNumber(patentRegistrationBo.getAuthorizationTrackingNumber()); patentRegistration.setCertificateExpressCompany(patentRegistrationBo.getCertificateExpressCompany()); if (!StringUtils.isBlank(patentRegistrationBo.getCertificateIssueTime())) { patentRegistration.setCertificateIssueTime( DateUtils.parseDate(patentRegistrationBo.getCertificateIssueTime(), "yyyy-MM-dd")); } else { patentRegistration.setCertificateIssueTime(null); } if (!StringUtils.isBlank(patentRegistrationBo.getCertificateRecieveTime())) { patentRegistration.setCertificateRecieveTime( DateUtils.parseDate(patentRegistrationBo.getCertificateRecieveTime(), "yyyy-MM-dd")); } else { patentRegistration.setCertificateRecieveTime(null); } patentRegistration.setCertificateTrackingNumber(patentRegistrationBo.getCertificateTrackingNumber()); patentRegistration.setPid(pid); return patentRegistration; } // 缴费截止日期 private String calDeadline(String s) { String[] arr = s.split("-"); String y = arr[0]; String m = arr[1]; String d = arr[2]; if ("11".equals(arr[0])) { m = "01"; y = String.valueOf(Integer.parseInt(y) + 1); } else if ("12".equals(arr[0])) { m = "02"; y = String.valueOf(Integer.parseInt(y) + 1); } else { m = String.valueOf(Integer.parseInt(m) + 2); } return y + m + d; } // 专利状态 private String switchPatState(Integer s) { String state = ""; switch (s) { case 11: state = "撤销"; break; case 1: state = "申请"; break; case 2: state = "撰写"; break; case 3: state = "受理"; break; case 4: state = "审查意见通知"; break; case 5: state = "审查意见已答复"; break; case 6: state = "补正通知"; break; case 7: state = "补正已答复"; break; case 8: state = "授权"; break; case 9: state = "驳回"; break; case 10: state = "发证"; break; } return state; } // 判断用户是否通过认证 private Result checkCertify(Result res, String uid) { OrganizationIdentity o = organizationIdentityServivce.selectOrgIdentityByUserId(uid); if (null == o || 5 != o.getAuditStatus()) { res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!")); } return res; } }