whycxzp
2022-08-10 d8ca9ccd14fe70e83bd586468cbc3db569f91de2
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.config.EnumWorksheetType;
import com.whyc.mapper.ProductBomApprovingMapper;
import com.whyc.mapper.WorksheetLinkMapper;
import com.whyc.pojo.*;
@@ -83,7 +84,9 @@
    }
    @Transactional
    public void approve(WorksheetLink link, Integer componentProductFlag) {
    public void approve(WorksheetLink link) {
        //根据节点,查询主表类型
        Integer type = mainService.getInfoById(link.getMainId()).getType();
        link.setDealTime(new Date());
        //更新节点信息
        linkMapper.updateById(link);
@@ -110,7 +113,7 @@
        }else {
            //审批通过,更新主表状态
            mainService.updateEndStatusById(link.getMainId(), "完结", 5);
            if (componentProductFlag == null) { //产品审批
            if (type.intValue() == EnumWorksheetType.ProductBom.getType()) { //产品审批
                //将产品文件复制至正式路径
                QueryWrapper<ProductBomApproving> query = Wrappers.query();
                query.eq("main_id", link.getMainId());
@@ -232,7 +235,11 @@
                });
                //更新正式bom的对应url
                bomService.updateUrl(fileBomApprovingList);
            }else{ //更新散装件-产品关系
            }
            else if(type.intValue() == EnumWorksheetType.Component.getType()){ //散装件 TODO
            }
            else if(type.intValue() == EnumWorksheetType.ComponentProduct.getType()){ //更新散装件-产品关系
                //查找到对应的散装件-产品关系数据
                List<ComponentProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
                //查询部件最新的版本号
@@ -324,7 +331,16 @@
                });
                //处理完成,进行表单数据更新,分为nowHistoryList,newHistoryList,nowBomHistoryList
                //nowHistoryList.forEach(nowHis->nowHis.setEVersion(nextVersion));
                newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});
                nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));
                cphService.updateVersionBatch(nowHistoryList);
                cphService.insertBatch(newHistoryList);
                historyService.updateVersionBatch(nowBomHistoryList);
                //更新ProductBom
                List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion);
                bomService.updateNewBom(newBomList);
            }
        }
    }