whycxzp
2022-08-22 fb06e27167f575a241e3c0b21e5f768f6c88bbe1
src/main/java/com/whyc/service/WorksheetMainService.java
@@ -51,10 +51,10 @@
    private MaterialProductApprovingService cpApprovingService;
    @Autowired
    private MaterialApprovingService cApprovingService;
    private MaterialApprovingService mApprovingService;
    @Autowired
    private MaterialService cService;
    private MaterialService mService;
    @Autowired
    private ProductBomService pbService;
@@ -204,7 +204,7 @@
        }else{
            return false;
        }
        //散装件-产品审批提交
        //物料-产品审批提交
        if(addedList!=null && addedList.size()!=0){
            addedList.forEach(item->{
                item.setMainId(main.getId());
@@ -230,33 +230,33 @@
        return true;
    }
    public Response MaterialSubmit(WorksheetMain main, DocUser user) {
    public Response materialSubmit(WorksheetMain main, DocUser user) {
        Response<Object> response = new Response<>();
        List<MaterialApproving> cApprovingList = main.getCApprovingList();
        List<MaterialApproving> mApprovingList = main.getMApprovingList();
        //判断是新增还是删除
        boolean isAdded = cApprovingList.get(0).getSubName()!=null;
        boolean isAdded = mApprovingList.get(0).getSubName()!=null;
        if(isAdded) { //新增
            //查询是否有 已生效或者已提交审批的 相同的散装件
            //查询是否有 已生效或者已提交审批的 相同的物料
            List<Material> existMaterialList = new LinkedList<>();
            List<MaterialApproving> existCAList = new LinkedList<>();
            List<Material> MaterialList = cService.getList();
            List<MaterialApproving> cAList = cApprovingService.getListByStatus(1);
            for (int i = 0; i < cApprovingList.size(); i++) {
                MaterialApproving MaterialApproving = cApprovingList.get(i);
                for (int j = 0; j < MaterialList.size(); j++) {
                    if (MaterialApproving.getSubCode().equals(MaterialList.get(j).getSubCode())
                            && MaterialApproving.getSubName().equals(MaterialList.get(j).getSubName())
                            && MaterialApproving.getSubModel().equals(MaterialList.get(j).getSubModel())
            List<Material> materialList = mService.getList();
            List<MaterialApproving> cAList = mApprovingService.getListByStatus(1);
            for (int i = 0; i < mApprovingList.size(); i++) {
                MaterialApproving materialApproving = mApprovingList.get(i);
                for (int j = 0; j < materialList.size(); j++) {
                    if (materialApproving.getSubCode().equals(materialList.get(j).getSubCode())
                            && materialApproving.getSubName().equals(materialList.get(j).getSubName())
                            && materialApproving.getSubModel().equals(materialList.get(j).getSubModel())
                    ) {
                        existMaterialList.add(MaterialList.get(j));
                        existMaterialList.add(materialList.get(j));
                    }
                }
                for (int j = 0; j < cAList.size(); j++) {
                    if (MaterialApproving.getSubCode().equals(cAList.get(j).getSubCode())
                            && MaterialApproving.getSubName().equals(cAList.get(j).getSubName())
                            && MaterialApproving.getSubModel().equals(cAList.get(j).getSubModel())
                    if (materialApproving.getSubCode().equals(cAList.get(j).getSubCode())
                            && materialApproving.getSubName().equals(cAList.get(j).getSubName())
                            && materialApproving.getSubModel().equals(cAList.get(j).getSubModel())
                    ) {
                        existCAList.add(cAList.get(j));
                    }
@@ -267,41 +267,39 @@
            int existMaterialSize = existMaterialList.size();
            if (existCASize != 0) {
                if (existMaterialSize != 0) {
                    response.setII(21, existCAList, existMaterialList, "重复提交:现有散装件及正在进行审批的散装件中,存在当前提交上传的散装件");
                    response.setII(21, existCAList, existMaterialList, "重复提交:现有物料及正在进行审批的物料中,存在当前提交上传的物料");
                } else {
                    response.set(22, existCAList, "重复提交:正在进行审批的散装件中,存在当前提交上传的散装件");
                    response.set(22, existCAList, "重复提交:正在进行审批的物料中,存在当前提交上传的物料");
                }
                return response;
            } else {
                if (existMaterialSize != 0) {
                    return response.setII(23, null, existMaterialList, "重复提交:现有散装件中,存在当前提交上传的散装件");
                    return response.setII(23, null, existMaterialList, "重复提交:现有物料中,存在当前提交上传的物料");
                }
            }
        }else{ //删除
            //判断是否在散装件审批删除中,是否存在产品关联及关联审批
            //判断是否在物料审批删除中,是否存在产品关联及关联审批
            MaterialApproving deleteApproving = new MaterialApproving();
            List<MaterialProductHistory> existMaterialProducts = new LinkedList<>();
            List<MaterialProductApproving> existMaterialProductApprovingList = new LinkedList<>();
            deleteApproving = cApprovingService.getListByMaterialId(cApprovingList.get(0).getMaterialId());
            deleteApproving = mApprovingService.getListByMaterialId(mApprovingList.get(0).getMaterialId());
            //查看产品关联
            List<MaterialProductHistory> cphLatestExistList =  cphService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId());
            List<MaterialProductHistory> cphLatestExistList =  cphService.getLatestExistListByMaterialId(mApprovingList.get(0).getMaterialId());
            //查看产品关联审批
            //lxw注释
            //List<MaterialProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByMaterialId(cApprovingList.get(0).getMaterialId());
            List<MaterialProductApproving> cpaLatestExistList =new ArrayList<>();
            List<MaterialProductApproving> cpaLatestExistList = cpApprovingService.getLatestExistListByMaterialId(mApprovingList.get(0).getMaterialId());
            if(deleteApproving!=null){
                return response.set(31,deleteApproving,"拒绝本次删除申请,当前散装件正在进行删除审批");
                return response.set(31,deleteApproving,"拒绝本次删除申请,当前物料正在进行删除审批");
            }
            if(cphLatestExistList!=null && cphLatestExistList.size()!=0){
                if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){
                    return response.setII(32,cpaLatestExistList,cphLatestExistList,"拒绝本次删除申请,当前散装已经关联产品及在产品关联审批");
                }else{
                    return response.setII(33,null,cphLatestExistList,"拒绝本次删除申请,当前散装件在产品关联审批");
                    return response.setII(33,null,cphLatestExistList,"拒绝本次删除申请,当前物料在产品关联审批");
                }
            }else{
                if(cpaLatestExistList!=null && cpaLatestExistList.size()!=0){
                    return response.set(34,cpaLatestExistList,"拒绝本次删除申请,当前散装件已经关联产品");
                    return response.set(34,cpaLatestExistList,"拒绝本次删除申请,当前物料已经关联产品");
                }
            }
@@ -351,14 +349,14 @@
        }else{
            return response.set(3);
        }
        //散装件-审批提交
        cApprovingList.forEach(cApproving->{
        //物料-审批提交
        mApprovingList.forEach(cApproving->{
            cApproving.setCreateDate(new Date());
            cApproving.setMainId(main.getId());
            cApproving.setStatus(1);
        });
        cApprovingService.insert(cApprovingList);
        mApprovingService.insert(mApprovingList);
        return response.set(1);
    }
@@ -613,7 +611,7 @@
            //lxw注释
            //return mainMapper.getLinkListWithMaterials(id);
            return null;
        }else{ //散装件-产品
        }else{ //物料-产品
            //return mainMapper.getLinkListWithMaterialProducts(id);
            return null;
        }