whycxzp
2022-08-26 eb63ad5d6a206557590de9dcf619464518f2360d
src/main/java/com/whyc/service/WorksheetLinkService.java
@@ -144,12 +144,28 @@
                String parentModel = productApproving.getParentModel();
                String parentCode = productApproving.getParentCode();
                String customCode = productApproving.getCustomCode();
                Product product = productService.getVersion(parentCode, customCode);
                ProductHistory latestProduct = phService.getLatestVersion(parentCode, customCode);
                ProductHistory enabledProduct = phService.getEnabledByParentCodeAndCustomCode(parentCode, customCode);
                int currentVersion = 0;
                if (product != null) {
                    currentVersion = product.getVersion();
                if (latestProduct != null) {
                    currentVersion = latestProduct.getVersion();
                }
                Integer nextVersion = currentVersion + 1;
                //产品物料关系迁移
                //查询生效版本的关联关系
                List<MaterialProductHistory> mpList = mphService.getListByParentCodeAndCustomCodeAndVersion(parentCode, customCode, enabledProduct.getVersion());
                if(latestProduct.getVersion().intValue() == enabledProduct.getVersion()){
                    //最新版本生效,关联关系版本连着的
                    mphService.updateVersionBatch(mpList);
                }else{
                    //旧版本生效,关联关系版本不连着
                    mpList.forEach(mp->{
                        mp.setSVersion(nextVersion);
                        mp.setEVersion(nextVersion);
                    });
                    mphService.insertBatch(mpList);
                }
                //将产品文件复制至正式路径
                //文件转移,未跟子件挂钩的所有图纸图片转移到产品版本下:doc_file/product/{产品型号}/standard或者{customCode}}/{version}/
                //跟子件挂钩的转移到子件图纸下:doc_file/material/
@@ -211,10 +227,10 @@
                //doc_file/product/{产品型号}/standard或者{customCode}}/{version}/
                //跟子件挂钩的转移到子件图纸下:doc_file/material/
                String customCodeString = null;
                if(customCode==null) {
                    customCodeString = "standard";
                }else{
                if(customCode!=null && !customCode.equals("")) {
                    customCodeString = customCode;
                }else{
                    customCodeString = "standard";
                }
                String productDir = projectDir + File.separator + "doc_file" + File.separator + "product" + File.separator + parentModel
                        + File.separator + customCodeString + File.separator +nextVersion;
@@ -351,8 +367,9 @@
                        materialList.add(temp);
                    }
                });
                mService.insertBatch(materialList);
                if(materialList.size()!=0) {
                    mService.insertBatch(materialList);
                }
                //将dwg图纸,全部更新到对应的记录url中
                mService.updateDwgUrl(materialDwgUrlNameList);
                /*List<ProductBomApproving> fileBomApprovingList = approvingList.stream()