whycxzp
2022-08-22 fb06e27167f575a241e3c0b21e5f768f6c88bbe1
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -43,10 +43,10 @@
    private MaterialProductApprovingService cpAService;
    @Autowired
    private MaterialApprovingService cAService;
    private MaterialApprovingService mAService;
    @Autowired
    private MaterialService cService;
    private MaterialService mService;
    @Autowired
    private ProductSoftwareApprovingService productSoftwareApprovingService;
@@ -60,9 +60,9 @@
        //更新节点信息
        linkMapper.updateById(link);
        if(link.getLinkStatus() == 2){ //驳回
            //查看是否为散装件审批,是则需要更新散装件审批表中的状态为完结
            //查看是否为物料审批,是则需要更新物料审批表中的状态为完结
            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Material.getType())){
                cAService.endStatus(link.getMainId());
                mAService.endStatus(link.getMainId());
            }
            //项目经理驳回,驳回即终止
            mainService.updateEndStatusById(link.getMainId(),"经理驳回,驳回原因:"+link.getDealReason(),0);
@@ -250,37 +250,37 @@
                //更新正式bom的对应url
                bomService.updateUrl(fileBomApprovingList);
            }
            else if(type.intValue() == EnumWorksheetType.Material.getType()){ //散装件
                List<MaterialApproving> approvingList = cAService.getListByMainId(link.getMainId());
            else if(type.intValue() == EnumWorksheetType.Material.getType()){ //物料
                List<MaterialApproving> approvingList = mAService.getListByMainId(link.getMainId());
                List<Material> MaterialList = new LinkedList<>();
                //区分是新增还是删除
                Integer MaterialId = approvingList.get(0).getMaterialId();
                if(MaterialId==null) { //新增
                    //将散装件从审批表中转移到正式表
                    //将物料从审批表中转移到正式表
                    approvingList.forEach(approve -> {
                        Material Material = new Material();
                        Material.setCategory(approve.getCategory());
                        Material.setSubCode(approve.getSubCode());
                        Material.setSubName(approve.getSubName());
                        Material.setSubModel(approve.getSubModel());
                        Material.setUnit(approve.getUnit());
                        Material.setQuantity(approve.getQuantity());
                        Material.setProducer(approve.getProducer());
                        Material.setNotes(approve.getNotes());
                        Material.setCreateDate(new Date());
                        Material.setStatus(1);
                        MaterialList.add(Material);
                        Material material = new Material();
                        material.setCategory(approve.getCategory());
                        material.setSubCode(approve.getSubCode());
                        material.setSubName(approve.getSubName());
                        material.setSubModel(approve.getSubModel());
                        material.setUnit(approve.getUnit());
                        material.setQuantity(approve.getQuantity());
                        material.setProducer(approve.getProducer());
                        material.setNotes(approve.getNotes());
                        material.setCreateDate(new Date());
                        material.setStatus(1);
                        MaterialList.add(material);
                    });
                    cService.insertBatch(MaterialList);
                    mService.insertBatch(MaterialList);
                }else{ //删除
                    List<Integer> MaterialIdList = approvingList.stream().map(MaterialApproving::getMaterialId).collect(Collectors.toList());
                    cService.deleteBatch(MaterialIdList);
                    mService.deleteBatch(MaterialIdList);
                }
                //更新散装件审批子表中type为完结
                cAService.endStatus(link.getMainId());
                //更新物料审批子表中type为完结
                mAService.endStatus(link.getMainId());
            }
            else if(type.intValue() == EnumWorksheetType.MaterialProduct.getType()){ //更新散装件-产品关系
                //查找到对应的散装件-产品关系数据
            else if(type.intValue() == EnumWorksheetType.MaterialProduct.getType()){ //更新物料-产品关系
                //查找到对应的物料-产品关系数据
                List<MaterialProductApproving> cpAList = cpAService.getListByMainId(link.getMainId());
                //查询部件最新的版本号
                //lxw修改
@@ -307,7 +307,7 @@
                    }
                });
                List<MaterialProductHistory> newHistoryList = new LinkedList<>();
                //查询最新版本生效的相关散装件
                //查询最新版本生效的相关物料
                //lxw注释
                //List<MaterialProductHistory> nowHistoryList = cphService.getListByParentModel(cpAList.get(0).getParentModel(), currentVersion);
                List<MaterialProductHistory> nowHistoryList =new ArrayList<>();
@@ -316,16 +316,16 @@
                List<ProductBomHistory> nowBomHistoryList = new ArrayList<>();
                /*
                对于关联的,判断当前版本中是否存在替换关系,存在,则直接下个版本插入关联;
                同时,其他当前版本的相关散装件-产品记录更新版本,排除存在的替换关系
                同时,其他当前版本的相关物料-产品记录更新版本,排除存在的替换关系
                */
                /*
                对于替换的,判断当前版本中是否存在关联关系,存在,直接下个版本替换,记录插入;
                同时,当前版本的相关散装件-产品记录更新版本,排除存在的关联关系;
                同时,当前版本的相关物料-产品记录更新版本,排除存在的关联关系;
                同时,bom表更新到下个版本时,排除被替换件
                */
                //对于解除关联的,当前版本的相关散装件-产品记录更新版本,排除解除关联的记录
                //对于解除关联的,当前版本的相关物料-产品记录更新版本,排除解除关联的记录
                //处理思路:先解除关联,再替换,再关联
                if(removedList.size()!=0){
                    removedList.forEach(remove -> {
@@ -351,7 +351,7 @@
                //处理替换
                if(replacedList.size()!=0){
                    replacedList.forEach(replace -> {
                        //当前生效的散装件-产品列表
                        //当前生效的物料-产品列表
                        /*nowHistoryList.forEach(nowHistory -> {
                            if (replace.getMaterialId().intValue() == nowHistory.getMaterialId()) {
                                nowHistoryList.remove(nowHistory);
@@ -370,7 +370,7 @@
                                }*/
                            }
                        }
                        //下个版本新增替换的散装件-产品列表
                        //下个版本新增替换的物料-产品列表
                        MaterialProductHistory newHistory = new MaterialProductHistory();
                        newHistory.setMaterialId(replace.getMaterialId());
                        //lxw注释