whyclxw
2024-07-25 6ff23a47d7d88e420d476a8e739b83f4c2dc8da4
src/main/java/com/whyc/service/DefectiveProductsHistoryService.java
@@ -10,6 +10,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.xml.crypto.Data;
import java.io.File;
import java.io.IOException;
import java.util.Date;
@@ -25,24 +26,30 @@
    public void addHis(DefectiveProducts defective) {
        DefectiveProductsHistory his=new DefectiveProductsHistory();
        his.setDeftId(defective.getId());
        his.setRecordTime(defective.getStartTime());
        his.setBadProduct(defective.getBadProduct());
        his.setRecordTime(defective.getRecordTime());
        his.setConfirmStatus(defective.getConfirmStatus());
        his.setNote(defective.getNote());
        his.setReceiverIds(defective.getReceiverIds());
        his.setReceiverNames(defective.getReceiverNames());
        his.setDelProduct(0);
        his.setDelId(defective.getSenderId());
        his.setDelName(defective.getSenderName());
        mapper.insert(his);
    }
    //记录处理记录
    public void updateDefective( DefectiveProducts defective,DefectiveProductsHistory defectiveHis, List<MultipartFile> multipartFileList) {
        defectiveHis.setRecordTime(new Date());
        Date date=new Date();
        defectiveHis.setRecordTime(date);
        String recordTime=ActionUtil.sdfwithFTP.format(date);
        String delName = ActionUtil.getUser().getName();
        Integer delId =ActionUtil.getUser().getId().intValue();
        defectiveHis.setDelId(delId);
        String time = ActionUtil.sdfwithday.format(defective.getStartTime());
        defectiveHis.setDelName(delName);
        String record = ActionUtil.sdfwithFTP.format(defective.getRecordTime());
        String rootFile = CommonUtil.getRootFile();
        if(multipartFileList!=null && multipartFileList.size()!=0){
            String defectiveDirSuffix = "defective" + File.separator + defective.getSenderName() + File.separator + time + File.separator+delName+File.separator;
            String defectiveDirSuffix = "defective" + File.separator + defective.getSenderName() + File.separator+ record + File.separator
                    +delName+File.separator+recordTime+File.separator;
            String feedbackDir = rootFile + defectiveDirSuffix;
            File fileDir = new File(feedbackDir);
            if (!fileDir.exists()) {
@@ -62,7 +69,7 @@
                    e.printStackTrace();
                }
            }
            defective.setFileUrl("doc_file" + File.separator + defectiveDirSuffix);
            defectiveHis.setDelUrl(defectiveDirSuffix);
        }
        mapper.insert(defectiveHis);
    }