whyclxw
2024-07-25 1e2246a0842419b0f60e0a063318d3c49dd1e13e
src/main/java/com/whyc/service/DefectiveProductsService.java
@@ -24,6 +24,7 @@
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -58,6 +59,7 @@
        defective.setSenderName(senderName);
        Date date=new Date();
        defective.setRecordTime(date);
        defective.setRestProduct(defective.getBadProduct());
        if(defective.getStartTime()==null){
            //保存
            defective.setStartTime(date);
@@ -83,7 +85,7 @@
                multipartFile.transferTo(file);
            }
            //ZipUtils.toZip(fileList,new FileOutputStream(new File(rootFile+feedbackZipPath)));
            defective.setFileUrl( File.separator + defectiveDirSuffix);
            defective.setFileUrl(defectiveDirSuffix);
        }
@@ -115,7 +117,8 @@
        }
        String subject = "【不良品记录】-"+senderName;
        String content = defective.getContent();
        String content = defective.getSenderName()+"上传了厂商:"+defective.getProvideName()+",产品:"+defective.getProductName()+",型号:"+defective.getType()+"的不良品记录;\n"+
                "不良品数量为:"+defective.getBadProduct()+",具体不良信息为:"+defective.getContent();
        MailDTO mailDTO = new MailDTO();
        mailDTO.setTitle(subject);
@@ -135,16 +138,19 @@
        String rootFile = CommonUtil.getRootFile();//主路径
        for (DefectiveProducts defective:list) {
            String filePath=defective.getFileUrl();
            defective.setFileUrl("doc_file"+File.separator+filePath);
            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();
                    his.setDelUrl("doc_file"+File.separator+hisDelPath);
                    if(hisDelPath!=null&&!hisDelPath.isEmpty()){
                        his.setDelUrl("doc_file"+File.separator+hisDelPath);
                        his.setHisNameList(FileUtil.getFileNameWithOutDirectory(rootFile+hisDelPath));
                    }
                }
@@ -179,8 +185,10 @@
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("receiver_ids",defectiveHis.getReceiverIds());
        wrapper.set("receiver_names",defectiveHis.getReceiverNames());
        wrapper.set("bad_product",defectiveHis.getBadProduct());
        if(defectiveHis.getBadProduct()==0){
        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);
@@ -189,8 +197,8 @@
        wrapper.set("note",defectiveHis.getNote());
        wrapper.eq("id",defectiveHis.getDeftId());
        mapper.update(null,wrapper);
        //记录处理记录
        defectiveHisService.updateDefective(defective,defectiveHis,multipartFileList);
        //发送邮件
@@ -211,7 +219,9 @@
        }
        String subject = "【不良品处理记录】-"+senderName;
        String content = defective.getContent();
        String content = defectiveHis.getDelName()+"修复了厂商:"+defective.getProvideName()+",产品:"+defective.getProductName()+",型号:"+defective.getType()+"的不良品记录;\n"+
                "不良品数量为:"+defective.getBadProduct()+"修复不良品个数:"+defectiveHis.getDelProduct()+",剩余不良品个数:"+defectiveHis.getRestProduct()+"\n"
                +"修复方式:"+defectiveHis.getNote();
        MailDTO mailDTO = new MailDTO();
        mailDTO.setTitle(subject);
@@ -230,7 +240,7 @@
        wrapper.set("confirm_status",3);//归档
        wrapper.set("receiver_ids","");
        wrapper.set("receiver_names","");
        wrapper.set("bad_product",0);
        wrapper.set("rest_product",0);
        wrapper.set("note","");
        wrapper.eq("id",deftId);
        mapper.update(null,wrapper);
@@ -239,8 +249,9 @@
        defectiveHis.setDeftId(deftId);
        defectiveHis.setDelId(ActionUtil.getUser().getId().intValue());
        defectiveHis.setConfirmStatus(3);
        defectiveHis.setBadProduct(0);
        defectiveHis.setDelId(ActionUtil.getUser().getId().intValue());
        defectiveHis.setDelProduct(0);
        defectiveHis.setDelName(ActionUtil.getUser().getName());
        defectiveHis.setRestProduct(0);
        defectiveHisService.stopDefective(defectiveHis);
        return new Response().set(1,true);
    }