whycxzp
2022-08-13 a1371a2912a6ef9b65354bb0d274be5fc3a21359
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -244,24 +244,31 @@
                bomService.updateUrl(fileBomApprovingList);
            }
            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());
                    component.setCreateDate(new Date());
                    component.setStatus(1);
                    componentList.add(component);
                });
                cService.insertBatch(componentList);
                List<Component> componentList = new LinkedList<>();
                //区分是新增还是删除
                Integer componentId = approvingList.get(0).getComponentId();
                if(componentId==null) { //新增
                    //将散装件从审批表中转移到正式表
                    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());
                        component.setCreateDate(new Date());
                        component.setStatus(1);
                        componentList.add(component);
                    });
                    cService.insertBatch(componentList);
                }else{ //删除
                    List<Integer> componentIdList = approvingList.stream().map(ComponentApproving::getComponentId).collect(Collectors.toList());
                    cService.deleteBatch(componentIdList);
                }
                //更新散装件审批子表中type为完结
                cAService.endStatus(link.getMainId());
            }