whycxzp
2022-08-12 8e252dca390a775f23b6ad621f81e39cac1b11e3
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -43,12 +43,22 @@
    @Autowired
    private ComponentProductApprovingService cpAService;
    @Autowired
    private ComponentApprovingService cAService;
    @Autowired
    private ComponentService cService;
    @Transactional
    public void audit(WorksheetLink link) {
        link.setDealTime(new Date());
        //更新节点信息
        linkMapper.updateById(link);
        if(link.getLinkStatus() == 2){ //驳回
            //查看是否为散装件审批,是则需要更新散装件审批表中的状态为完结
            if(mainService.getInfoById(link.getMainId()).getType().equals(EnumWorksheetType.Component.getType())){
                cAService.endType(link.getMainId());
            }
            //项目经理驳回,驳回即终止
            mainService.updateEndStatusById(link.getMainId(),"经理驳回,驳回原因:"+link.getDealReason(),0);
            //项目经理驳回前,还曾经过总经理,则需要增加总经理驳回原因
@@ -233,8 +243,25 @@
                //更新正式bom的对应url
                bomService.updateUrl(fileBomApprovingList);
            }
            else if(type.intValue() == EnumWorksheetType.Component.getType()){ //散装件 TODO
            else if(type.intValue() == EnumWorksheetType.Component.getType()){ //散装件
                //将散装件从审批表中转移到正式表
                List<Component> componentList = new LinkedList<>();
                List<ComponentApproving> approvingList = cAService.getListByMainId(link.getMainId());
                approvingList.forEach(approve->{
                    Component component = new Component();
                    component.setCategory(approve.getCategory());
                    component.setSubCode(approve.getSubCode());
                    component.setSubName(approve.getSubName());
                    component.setSubModel(approve.getSubModel());
                    component.setUnit(approve.getUnit());
                    component.setQuantity(approve.getQuantity());
                    component.setProducer(approve.getProducer());
                    component.setNotes(approve.getNotes());
                    componentList.add(component);
                });
                cService.insertBatch(componentList);
                //更新散装件审批子表中type为完结
                cAService.endType(link.getMainId());
            }
            else if(type.intValue() == EnumWorksheetType.ComponentProduct.getType()){ //更新散装件-产品关系
                //查找到对应的散装件-产品关系数据
@@ -289,7 +316,10 @@
                        });*/
                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                        while (iterator.hasNext()){
                            if(remove.getComponentId().intValue() == iterator.next().getComponentId()){
                            ComponentProductHistory next = iterator.next();
                            if(remove.getComponentId().intValue() == next.getComponentId()
                                &&remove.getSubName().equals(next.getSubName())
                            ){
                                iterator.remove();
                                break;
                            }
@@ -306,11 +336,16 @@
                                nowHistoryList.remove(nowHistory);
                            }
                        });*/
                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                        while (iterator.hasNext()){
                            if(replace.getComponentId().intValue() == iterator.next().getComponentId()){
                                iterator.remove();
                                break;
                        if(nowHistoryList.size()!=0) {
                            Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                            while (iterator.hasNext()) {
                                ComponentProductHistory next = iterator.next();
                                if (replace.getComponentId().intValue() == next.getComponentId()
                                        && replace.getSubName().equals(next.getSubName())
                                ) {
                                    iterator.remove();
                                    break;
                                }
                            }
                        }
                        //下个版本新增替换的散装件-产品列表
@@ -346,11 +381,16 @@
                            nowHistoryList.remove(nowHistory);
                        }
                    });*/
                    Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                    while (iterator.hasNext()){
                        if(add.getComponentId().intValue() == iterator.next().getComponentId()){
                            iterator.remove();
                            break;
                    if(nowHistoryList.size()!=0) {
                        Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator();
                        while (iterator.hasNext()) {
                            ComponentProductHistory next = iterator.next();
                            if (add.getComponentId().intValue() == next.getComponentId()
                                    && add.getSubName().equals(next.getSubName())
                            ) {
                                iterator.remove();
                                break;
                            }
                        }
                    }
@@ -368,8 +408,8 @@
                //处理完成,进行表单数据更新,分为nowHistoryList,newHistoryList,nowBomHistoryList
                //nowHistoryList.forEach(nowHis->nowHis.setEVersion(nextVersion));
                newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});
                nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));
                if(newHistoryList.size()!=0){newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);});}
                if(nowBomHistoryList.size()!=0){nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion));}
                if(nowHistoryList.size()!=0){cphService.updateVersionBatch(nowHistoryList);}
                if(newHistoryList.size()!=0){cphService.insertBatch(newHistoryList);}