From cf9a5039e6db9d1d5963e3fe1a37d00169ec2ef7 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期三, 25 六月 2025 11:18:22 +0800 Subject: [PATCH] 验收报告修改 --- src/main/java/com/whyc/service/WorksheetMainService.java | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 200 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/whyc/service/WorksheetMainService.java b/src/main/java/com/whyc/service/WorksheetMainService.java index 51b4873..246689d 100644 --- a/src/main/java/com/whyc/service/WorksheetMainService.java +++ b/src/main/java/com/whyc/service/WorksheetMainService.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.config.EnumWorksheetType; +import com.whyc.dto.MailDTO; import com.whyc.dto.Response; import com.whyc.dto.WorksheetMainDTO; import com.whyc.dto.WorksheetMainDTO2; @@ -13,8 +14,11 @@ import com.whyc.mapper.WorksheetMainMapper; import com.whyc.pojo.*; import com.whyc.util.CommonUtil; +import com.whyc.util.Word2PdfAsposeUtil; +import com.whyc.util.WordUtil; import com.whyc.util.Zip4jUtil; import org.aspectj.util.FileUtil; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -22,6 +26,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.mail.MessagingException; +import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; @@ -77,6 +83,12 @@ @Autowired private ProductHistoryService productHistoryService; + + @Autowired + private MailService mailService; + + @Autowired + private ProcedureDocApprovingService procedureDocApprovingService; @Transactional public boolean submit(WorksheetMain main, DocUser user) throws IOException { @@ -481,8 +493,12 @@ String filePath = rootFile + productSoftwarePath; String originalFilename = file.getOriginalFilename(); File zipFile = new File(filePath+File.separator+ originalFilename); - if(!zipFile.exists()){ + /*if(!zipFile.exists()){ zipFile.mkdirs(); + }*/ + File parentFile = new File(filePath); + if (!parentFile.exists()) { + parentFile.mkdirs(); } file.transferTo(zipFile); approving.setSoftwareUrl("doc_file"+productSoftwarePath+File.separator+ originalFilename); @@ -725,4 +741,187 @@ } + public Response addProductProcedureAndSOP(ProcedureDocApproving approving, DocUser user) throws IOException, MessagingException { + WorksheetMain main = new WorksheetMain(); + //瀛樺偍涓婁紶淇℃伅鍒颁富琛�,鑺傜偣琛� + //鏂囦欢淇濆瓨鍦�/doc_file/procedure_approving/xxx_鏃堕棿鎴�.doc + MultipartFile multipartFile = approving.getMultipartFile(); + String originalFilename = multipartFile.getOriginalFilename(); + String rootFile = CommonUtil.getRootFile(); + Date date = new Date(); + String filename = originalFilename.replace(".doc","_"+date.getTime()+".doc"); + String suffixFilePath = "procedure_approving" + File.separator + filename; + String outFilePath = rootFile + suffixFilePath; + File outFile = new File(outFilePath); + multipartFile.transferTo(outFile); + + main.setTitle(approving.getName()); + main.setDescription(approving.getDescription()); + main.setCreateUserId(user.getId()); + main.setBeginTime(date); + main.setStatus(1); + if(approving.getType()==1){ + main.setType(EnumWorksheetType.ProductProcedure.getType()); + }else{ + main.setType(EnumWorksheetType.SOP.getType()); + } + mainMapper.insert(main); + + List<WorksheetLink> links = new LinkedList<>(); + WorksheetLink baseLink = new WorksheetLink(); + WorksheetLink linkFzr = new WorksheetLink(); + WorksheetLink linkBz = new WorksheetLink(); + WorksheetLink linkZz = new WorksheetLink(); + WorksheetLink linkPb = new WorksheetLink(); + + baseLink.setMainId(main.getId()); + baseLink.setLinkStatus(0); + baseLink.setCreateTime(date); + + BeanUtils.copyProperties(baseLink,linkFzr); + BeanUtils.copyProperties(baseLink,linkBz); + BeanUtils.copyProperties(baseLink,linkZz); + BeanUtils.copyProperties(baseLink,linkPb); + + linkFzr.setDealUserId(approving.getFzr()); + linkBz.setDealUserId(approving.getBz()); + linkZz.setDealUserId(approving.getZz()); + linkPb.setDealUserId(approving.getPb()); + links.add(linkFzr); + links.add(linkBz); + links.add(linkZz); + links.add(linkPb); + linkMapper.insertBatchSomeColumn(links); + + //娴佺▼鏂囨。瀹℃壒瀛愯〃瀛樺叆 + approving.setFile("doc_file"+ File.separator + suffixFilePath); + approving.setMainId(main.getId()); + procedureDocApprovingService.insert(approving); + //鍙戦�侀偖浠剁粰鍥涗釜纭浜� + QueryWrapper<DocUser> query = Wrappers.query(); + query.select("mail").in("id",approving.getFzr(),approving.getBz(),approving.getZz(),approving.getPb()); + List<DocUser> docUsers = userMapper.selectList(query); + List<String> userMailList = docUsers.stream().map(DocUser::getMail).collect(Collectors.toList()); + + MailDTO mailDTO = new MailDTO(); + mailDTO.setMailList(userMailList); + if(approving.getType()==1){ + mailDTO.setTitle("銆愭祦绋嬪崱纭銆�"+main.getTitle()); + mailDTO.setContent(user.getName()+"鍦ㄦ枃妗g鐞嗗钩鍙颁笂浼犱簡浜у搧娴佺▼鍗�,璇峰強鏃剁‘璁�"); + }else{ + mailDTO.setTitle("銆怱OP纭銆�"+main.getTitle()); + mailDTO.setContent(user.getName()+"鍦ㄦ枃妗g鐞嗗钩鍙颁笂浼犱簡SOP,璇峰強鏃剁‘璁�"); + } + mailService.sendMail(mailDTO); + + return new Response().setII(1,"涓婁紶瀹屾垚"); + } + + /** + * 缁熻鏁伴噺: + * 鎴戠殑鎻愪氦 + * 寰呭鐞� + * 宸插鐞� + * @param user + * @return + */ + public Map<String, Integer> getProcedureDocApprovingStatusStatistic(DocUser user) { + Map<String,Integer> map = new HashMap<>(); + + //鎴戠殑鎻愪氦 + QueryWrapper<WorksheetMain> query = Wrappers.query(); + query.eq("create_user_id",user.getId()).in("type",EnumWorksheetType.ProductProcedure.getType(),EnumWorksheetType.SOP.getType()); + List<WorksheetMain> worksheetMains = mainMapper.selectList(query); + map.put("mySubmit",worksheetMains.size()); + //寰呭鐞唡宸插鐞� + int handlingCount = 0; + int handledCount = 0; + List<WorksheetLink> links = linkMapper.getProcedureDocApprovingByUserId(user.getId()); + for (WorksheetLink link : links) { + //dealType鐨勫�间负涓昏〃鐨勭姸鎬� + if(link.getDealType() == 1 && link.getLinkStatus() == 0){ //鏈鐞嗕笖瀹℃壒鏈粨鏉� + handlingCount++; + }else if(link.getLinkStatus() == 1 || link.getLinkStatus() ==2){ //宸茬‘璁ゆ垨宸叉嫆缁� + handledCount++; + } + } + map.put("handling",handlingCount); + map.put("handled",handledCount); + return map; + } + + public Response procedurePreview(HttpServletResponse response, int mainId) throws IOException { + //鏌ヨ褰撳墠鍗曟嵁瀹℃壒浜虹殑纭鐘舵�� + ProcedureDocApproving approving = procedureDocApprovingService.getByMainId(mainId); + List<WorksheetLink> linkList = linkMapper.getList(mainId); + String fzr = linkList.get(0).getLinkStatus() == 1 ? linkList.get(0).getDealUsername():""; + String bz = linkList.get(1).getLinkStatus() == 1 ? linkList.get(1).getDealUsername():""; + String zz = linkList.get(2).getLinkStatus() == 1 ? linkList.get(2).getDealUsername():""; + String pb = linkList.get(3).getLinkStatus() == 1 ? linkList.get(3).getDealUsername():""; + List<String> list = new LinkedList(); + list.add(fzr); + list.add(bz); + list.add(zz); + list.add(pb); + //鑾峰彇word妯℃澘鍏蜂綋鏂囦欢 + + long currentTimeMillis = System.currentTimeMillis(); + String projectDir = CommonUtil.getProjectDir(); + String fileRelativePath = approving.getFile(); + String inFilePath = projectDir + File.separator + fileRelativePath; + String outFilePath = inFilePath.replace(".doc","_"+currentTimeMillis+".doc"); + WordUtil.fillValue(inFilePath,outFilePath,list); + //pdf甯︽按鍗扮殑鍦板潃 /doc_file/procedure_approving/xxx.doc + String suffixOutPdfFilePath = "doc_file" + File.separator + "procedure_approving" + File.separator + outFilePath.substring(outFilePath.lastIndexOf(File.separator)+1,outFilePath.lastIndexOf(".")) + ".pdf"; + String outPdfFilePath = projectDir + File.separator + suffixOutPdfFilePath; + Word2PdfAsposeUtil.doc2pdfWithWaterMark(outFilePath,outPdfFilePath,true); + return new Response().setII(1,suffixOutPdfFilePath); + /*try { + // 杞爜闃叉涔辩爜 + //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1")); + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( fileRelativePath.substring(fileRelativePath.lastIndexOf(File.separator+1)), "utf-8")); + OutputStream out = response.getOutputStream(); + FileInputStream in = new FileInputStream(outFilePath); + int len=0; + byte[] buffer =new byte[1024]; + //7. 灏嗙紦鍐插尯涓殑鏁版嵁杈撳嚭 + while ((len=in.read(buffer))>0){ + out.write(buffer,0,len); + } + in.close(); + out.close(); + } catch (FileNotFoundException | UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + }*/ + } + + /** + * 鏌ヨ鎵�鏈夌殑宸ュ崟,鎵�鏈変汉鍙 + * @param param + * @return + */ + public Response getAllPage(WorksheetMain param) { + Integer pageNum = param.getPageNum(); + Integer pageSize = param.getPageSize(); + PageHelper.startPage(pageNum,pageSize); + + int createUserId = param.getCreateUserId().intValue(); + Date beginTime = param.getBeginTime(); + Date endTime = param.getEndTime(); + Integer type = param.getType(); + QueryWrapper<WorksheetMain> query = Wrappers.query(); + if(createUserId>0){ + query.eq("create_user_id",createUserId); + } + query.ge("begin_time",beginTime); + query.le("begin_time",endTime); + if(type!=null && type>=0){ + query.eq("type",type); + } + List<WorksheetMain> worksheetMains = mainMapper.selectList(query); + PageInfo pageInfo = new PageInfo(worksheetMains); + return new Response().set(1,pageInfo); + } } -- Gitblit v1.9.1