whycxzp
2022-07-27 d4d0c3614930df9a7877ba353cca97db6c99cdc4
更新工作流
1个文件已添加
5个文件已修改
89 ■■■■ 已修改文件
src/main/java/com/whyc/mapper/ProductBomHistoryMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/ProductBomHistory.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomHistoryService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductBomService.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/WorksheetLinkService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductBomHistoryMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ProductBomHistoryMapper.java
@@ -3,5 +3,9 @@
import com.whyc.pojo.ProductBomHistory;
import java.util.List;
public interface ProductBomHistoryMapper extends CustomMapper<ProductBomHistory> {
    void updateVersionBatch(List<ProductBomHistory> newVersionCurrentHistoryList);
}
src/main/java/com/whyc/pojo/ProductBomHistory.java
@@ -229,19 +229,19 @@
        this.updateDate = updateDate;
    }
    public Integer getsVersion() {
    public Integer getSVersion() {
        return sVersion;
    }
    public void setsVersion(Integer sVersion) {
    public void setSVersion(Integer sVersion) {
        this.sVersion = sVersion;
    }
    public Integer geteVersion() {
    public Integer getEVersion() {
        return eVersion;
    }
    public void seteVersion(Integer eVersion) {
    public void setEVersion(Integer eVersion) {
        this.eVersion = eVersion;
    }
src/main/java/com/whyc/service/ProductBomHistoryService.java
@@ -34,4 +34,8 @@
    public void addBatch(List<ProductBomHistory> newHistoryList) {
        mapper.insertBatchSomeColumn(newHistoryList);
    }
    public void updateVersionBatch(List<ProductBomHistory> newVersionCurrentHistoryList) {
        mapper.updateVersionBatch(newVersionCurrentHistoryList);
    }
}
src/main/java/com/whyc/service/ProductBomService.java
@@ -1,6 +1,7 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -9,14 +10,17 @@
import com.whyc.dto.ZipUtils;
import com.whyc.mapper.ProductBomMapper;
import com.whyc.pojo.ProductBom;
import com.whyc.pojo.ProductBomHistory;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@Service
@@ -70,10 +74,49 @@
        return new Response().setII(1,productBom!=null?true:false,productBom,"返回数据");
    }
    //获取产品的信息(不包含子料)
    /**获取产品的信息(不包含子料)*/
    public ProductBom getProduct(String parentModel){
        QueryWrapper<ProductBom> query = Wrappers.query();
        query.eq("parent_model",parentModel).last(" limit 1");
        return mapper.selectOne(query);
    }
    /** 删除旧的bom,增加新的bom*/
    @Transactional
    public void updateNewBom(List<ProductBomHistory> newBomHistoryList) {
        UpdateWrapper<ProductBom> update = Wrappers.update();
        update.eq("parent_model",newBomHistoryList.get(0).getParentModel());
        mapper.delete(update);
        List<ProductBom> newBomList = new LinkedList<>();
        newBomHistoryList.forEach(newBomHis->{
            ProductBom newBom = new ProductBom();
            newBom.setCategory(newBomHis.getCategory());
            newBom.setCreateDate(newBomHis.getCreateDate());
            newBom.setDwgUrl(newBomHis.getDwgUrl());
            newBom.setFileUrl(newBomHis.getFileUrl());
            newBom.setMaterial(newBomHis.getMaterial());
            newBom.setNotes(newBomHis.getNotes());
            newBom.setParentCode(newBomHis.getParentCode());
            newBom.setParentModel(newBomHis.getParentModel());
            newBom.setParentName(newBomHis.getParentName());
            newBom.setParentVersion(newBomHis.getParentVersion());
            newBom.setPictureUrl(newBomHis.getPictureUrl());
            newBom.setProducer(newBomHis.getProducer());
            newBom.setQuantity(newBomHis.getQuantity());
            newBom.setSubCode(newBomHis.getSubCode());
            newBom.setSubModel(newBomHis.getSubModel());
            newBom.setSubName(newBomHis.getSubName());
            newBom.setSurfaceDetail(newBomHis.getSurfaceDetail());
            newBom.setThickness(newBomHis.getThickness());
            newBom.setType(newBomHis.getType());
            newBom.setUnit(newBomHis.getUnit());
            newBom.setUpdateDate(newBomHis.getUpdateDate());
            newBom.setUpUser(newBomHis.getUpUser());
            newBom.setVersion(newBomHis.getEVersion());
            newBomList.add(newBom);
        });
        mapper.insertBatchSomeColumn(newBomList);
    }
}
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -107,7 +107,7 @@
                currentVersion = 0;
            }
            Integer nextVersion = currentVersion+1;
            //更新到product_bom_history,需要sVersion和eVersion
            //更新到product_bom_history,增加进去的需要sVersion和eVersion一致
            //增加所有部件,排查出相关的原部件,非也是更新
            List<ProductBomHistory> currentHistoryList = historyService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion);
            List<String> currentSubNameList = currentHistoryList.stream().map(ProductBomHistory::getSubName).collect(Collectors.toList());
@@ -124,7 +124,7 @@
                his.setCategory(approvingBom.getCategory());
                his.setCreateDate(approvingBom.getCreateDate());
                his.setDwgUrl(approvingBom.getDwgUrl());
                his.seteVersion(nextVersion);
                his.setEVersion(nextVersion);
                his.setFileUrl(approvingBom.getFileUrl());
                his.setMaterial(approvingBom.getMaterial());
                his.setNotes(approvingBom.getNotes());
@@ -139,7 +139,7 @@
                his.setSubModel(approvingBom.getSubModel());
                his.setSubName(approvingBom.getSubName());
                his.setSurfaceDetail(approvingBom.getSurfaceDetail());
                his.setsVersion(nextVersion);
                his.setSVersion(nextVersion);
                his.setThickness(approvingBom.getThickness());
                his.setType(approvingBom.getType());
                his.setUnit(approvingBom.getUnit());
@@ -151,12 +151,19 @@
            //本次审核中子件被修改的子件集合
            List<String> approvingUpdateSubNameList = approvingList.stream().filter(approvingBom -> approvingBom.getVersion() == 1).map(ProductBomApproving::getSubName).collect(Collectors.toList());
            //更新到product_bom
            historyService.addBatch(newHistoryList);
            /*更新产品的当前版本,更新到最新的版本*/
            //当前版本的所有bom,排除
            //currentHistoryList.stream().filter(currentHistory->currentHistory.getSubName());
            //当前版本的所有bom的eVersion更新,排除被修改的子件
            List<ProductBomHistory> newVersionCurrentHistoryList = currentHistoryList.stream()
                    .filter(currentHistory -> !approvingUpdateSubNameList.contains(currentHistory.getSubName()))
                    .collect(Collectors.toList());
            newVersionCurrentHistoryList.forEach(history->{history.setEVersion(nextVersion);});
            historyService.updateVersionBatch(newVersionCurrentHistoryList);
            /*更新到product_bom*/
            //查询新的版本
            List<ProductBomHistory> newBomList = historyService.getListByParentModel(approvingList.get(0).getParentModel(), nextVersion);
            bomService.updateNewBom(newBomList);
            /*String projectDir = CommonUtil.getProjectDir();
            FileUtil.copyDir()*/
src/main/resources/mapper/ProductBomHistoryMapper.xml
New file
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.ProductBomHistoryMapper" >
    <update id="updateVersionBatch">
        update db_doc.tb_product_bom_history set e_version = #{eVersion} where id = #{id}
    </update>
</mapper>