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/DefectiveProductsService.java | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 156 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/whyc/service/DefectiveProductsService.java b/src/main/java/com/whyc/service/DefectiveProductsService.java index 17e1014..469e625 100644 --- a/src/main/java/com/whyc/service/DefectiveProductsService.java +++ b/src/main/java/com/whyc/service/DefectiveProductsService.java @@ -1,17 +1,23 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.whyc.dto.DefectiveDto; import com.whyc.dto.MailDTO; import com.whyc.dto.Response; import com.whyc.mapper.DefectiveProductsMapper; import com.whyc.mapper.DocUserMapper; import com.whyc.pojo.DefectiveProducts; +import com.whyc.pojo.DefectiveProductsHistory; import com.whyc.pojo.DocUser; -import com.whyc.pojo.ProductHistory; import com.whyc.util.ActionUtil; import com.whyc.util.CommonUtil; +import com.whyc.util.FileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; @@ -38,16 +44,28 @@ private DefectiveProductsHistoryService defectiveHisService; + //褰曞叆涓嶈壇鍝佷俊鎭� + @Transactional public Response addDefective(DefectiveProducts defective, List<MultipartFile> multipartFileList) throws IOException { - Date date = new Date(); + //鍒濇褰曞叆鐘舵�佷负0 + defective.setConfirmStatus(0); //鍘嬬缉鍖呯殑璺緞鍙婃牸寮忎负: doc_file/defective/username_time.zip - String username = ActionUtil.getUser().getName(); - long time = date.getTime(); - //String feedbackZipPath = "defective" + File.separator + username + "_" + time+".zip"; + String senderName = ActionUtil.getUser().getName(); + Integer senderId =ActionUtil.getUser().getId().intValue(); + defective.setSenderId(senderId); + defective.setSenderName(senderName); + Date date=new Date(); + defective.setRecordTime(date); + defective.setRestProduct(defective.getBadProduct()); + if(defective.getStartTime()==null){ + //淇濆瓨 + defective.setStartTime(date); + } + String recordtime = ActionUtil.sdfwithFTP.format(defective.getRecordTime()); String rootFile = CommonUtil.getRootFile(); if(multipartFileList!=null && multipartFileList.size()!=0){ - String defectiveDirSuffix = "defective" + File.separator + username + File.separator + time + File.separator; + String defectiveDirSuffix = "defective" + File.separator + senderName + File.separator+ recordtime + File.separator; String feedbackDir = rootFile + defectiveDirSuffix; File fileDir = new File(feedbackDir); if (!fileDir.exists()) { @@ -65,26 +83,24 @@ multipartFile.transferTo(file); } //ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath))); - defective.setFileUrl("doc_file" + File.separator + defectiveDirSuffix); + defective.setFileUrl(defectiveDirSuffix); } - //淇濆瓨 - defective.setStartTime(date); + + mapper.insert(defective); //鍙戦�侀偖浠� String receiverIds = defective.getReceiverIds(); String[] receiverIdsSplit = receiverIds.split(","); List<String> receiverMailList = new LinkedList<>(); - Integer senderId = defective.getSenderId(); - String senderName = null; List<DocUser> docUsers = userMapper.selectList(null); - for (DocUser docUser:docUsers){ + /* for (DocUser docUser:docUsers){ if(docUser.getId().intValue() == senderId){ senderName = docUser.getName(); break; } - } + }*/ for (String receiverId:receiverIdsSplit){ for (DocUser docUser:docUsers){ @@ -99,7 +115,8 @@ } String subject = "銆愪笉鑹搧璁板綍銆�-"+senderName; - String content = defective.getContent(); + String content = senderName+"涓婁紶浜嗕笉鑹搧璁板綍,淇℃伅濡備笅:\n鍘傚晢:"+defective.getProvideName()+"\n浜у搧:"+defective.getProductName()+"\n鍨嬪彿:"+defective.getType() + +"\n涓嶈壇鍝佹暟閲�:"+defective.getBadProduct()+"\n鍏蜂綋涓嶈壇淇℃伅:"+defective.getContent(); MailDTO mailDTO = new MailDTO(); mailDTO.setTitle(subject); @@ -111,4 +128,129 @@ defectiveHisService.addHis(defective); return new Response().set(1,true,"涓嶈壇鍝佹搷浣滃畬鎴�"); } + + //涓嶈壇鍝侀椤垫帹閫� + public Response getDefectiveLimit(DefectiveDto defectiveDto) { + PageHelper.startPage(defectiveDto.getPageCurr(),defectiveDto.getPageSize()); + List<DefectiveProducts> list=mapper.getDefectiveLimit(defectiveDto); + String rootFile = CommonUtil.getRootFile();//涓昏矾寰� + for (DefectiveProducts defective:list) { + String filePath=defective.getFileUrl(); + String startTimeEx=ActionUtil.sdfwithday.format(defective.getStartTime()); + defective.setStartTimeEx(startTimeEx); + if(filePath!=null&&!filePath.isEmpty()){ + defective.setFileUrl("doc_file"+File.separator+filePath); + defective.setNameList(FileUtil.getFileNameWithOutDirectory(rootFile+filePath)); + + } + List<DefectiveProductsHistory> hisList=defective.getHisList(); + if(hisList!=null&&hisList.size()>0){ + for (DefectiveProductsHistory his:defective.getHisList()) { + String hisDelPath=his.getDelUrl(); + if(hisDelPath!=null&&!hisDelPath.isEmpty()){ + his.setDelUrl("doc_file"+File.separator+hisDelPath); + his.setHisNameList(FileUtil.getFileNameWithOutDirectory(rootFile+hisDelPath)); + } + } + + } + } + PageInfo pageInfo=new PageInfo(list); + return new Response().setII(1,list!=null,pageInfo,"涓嶈壇鍝侀椤垫帹閫�"); + } + + //澶勭悊涓嶈壇鍝� + @Transactional + public Response updateDefective(DefectiveProductsHistory defectiveHis, List<MultipartFile> multipartFileList) { + //鑾峰彇涓婁竴娆¤褰曚俊鎭� + QueryWrapper qwrapper=new QueryWrapper(); + qwrapper.eq("id",defectiveHis.getDeftId()); + qwrapper.last("limit 1"); + DefectiveProducts defective=mapper.selectOne(qwrapper); + //鑾峰彇 + Integer senderId = defective.getSenderId(); + String senderName = null; + + List<DocUser> docUsers = userMapper.selectList(null); + for (DocUser docUser:docUsers){ + if(docUser.getId().intValue() == senderId){ + senderName = docUser.getName(); + break; + } + } + defective.setSenderName(senderName); + //淇敼褰撳墠琛ㄨ褰� + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.set("receiver_ids",defectiveHis.getReceiverIds()); + wrapper.set("receiver_names",defectiveHis.getReceiverNames()); + int resProduct=defective.getRestProduct()-defectiveHis.getDelProduct(); + defectiveHis.setRestProduct(resProduct); + wrapper.set("rest_product",resProduct); + if(resProduct==0){ + defectiveHis.setConfirmStatus(2);//涓嶈壇鍝佹暟閲忎负0缁撴潫 + }else { + defectiveHis.setConfirmStatus(1); + } + wrapper.set("confirm_status",defectiveHis.getConfirmStatus()); + wrapper.set("note",defectiveHis.getNote()); + wrapper.eq("id",defectiveHis.getDeftId()); + mapper.update(null,wrapper); + //璁板綍澶勭悊璁板綍 + + defectiveHisService.updateDefective(defective,defectiveHis,multipartFileList); + + //鍙戦�侀偖浠� + String receiverIds = defectiveHis.getReceiverIds(); + String[] receiverIdsSplit = receiverIds.split(","); + List<String> receiverMailList = new LinkedList<>(); + + for (String receiverId:receiverIdsSplit){ + for (DocUser docUser:docUsers){ + if(docUser.getId().intValue() == Integer.parseInt(receiverId)){ + String mail = docUser.getMail(); + if(mail!=null && !mail.isEmpty()) { + receiverMailList.add(mail); + } + break; + } + } + } + + String subject = "銆愪笉鑹搧澶勭悊璁板綍銆�-"+senderName; + String content = defectiveHis.getDelName()+"淇浜嗕笉鑹搧,璁板綍淇℃伅濡備笅:\n鍘傚晢:"+defective.getProvideName()+"\n浜у搧:"+defective.getProductName()+"\n鍨嬪彿:"+defective.getType()+ + "\n涓嶈壇鍝佹暟閲�:"+defective.getBadProduct()+"\n淇涓嶈壇鍝佷釜鏁�:"+defectiveHis.getDelProduct()+"\n鍓╀綑涓嶈壇鍝佷釜鏁�:"+defectiveHis.getRestProduct()+"\n" + +"淇鏂瑰紡:"+defectiveHis.getNote(); + + MailDTO mailDTO = new MailDTO(); + mailDTO.setTitle(subject); + mailDTO.setContent(content); + mailDTO.setMailList(receiverMailList); + mailService.sendMail(mailDTO); + + return new Response().set(1,true); + } + + //褰掓。涓嶈壇鍝� + @Transactional + public Response stopDefective(int deftId) { + //淇敼褰撳墠琛ㄨ褰� + UpdateWrapper wrapper=new UpdateWrapper(); + wrapper.set("confirm_status",3);//褰掓。 + wrapper.set("receiver_ids",""); + wrapper.set("receiver_names",""); + wrapper.set("rest_product",0); + wrapper.set("note",""); + wrapper.eq("id",deftId); + mapper.update(null,wrapper); + //璁板綍澶勭悊璁板綍 + DefectiveProductsHistory defectiveHis=new DefectiveProductsHistory(); + defectiveHis.setDeftId(deftId); + defectiveHis.setDelId(ActionUtil.getUser().getId().intValue()); + defectiveHis.setConfirmStatus(3); + defectiveHis.setDelProduct(0); + defectiveHis.setDelName(ActionUtil.getUser().getName()); + defectiveHis.setRestProduct(0); + defectiveHisService.stopDefective(defectiveHis); + return new Response().set(1,true); + } } \ No newline at end of file -- Gitblit v1.9.1