lxw
2022-09-01 b848451e8889fea12ce40b7818c1b8d84b50ea02
src/main/java/com/whyc/service/WorksheetMainService.java
@@ -14,6 +14,7 @@
import com.whyc.pojo.*;
import com.whyc.util.CommonUtil;
import com.whyc.util.Zip4jUtil;
import org.aspectj.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -71,8 +72,14 @@
    @Autowired
    private ProductSoftwareService productSoftwareService;
    @Autowired
    private ProductService productService;
    @Autowired
    private ProductHistoryService productHistoryService;
    @Transactional
    public boolean submit(WorksheetMain main, DocUser user) {
    public boolean submit(WorksheetMain main, DocUser user) throws IOException {
        main.setType(1);
        ProductApproving productApproving = main.getProductApproving();
        List<ProductBomApproving> bomList = productApproving.getBomApprovingList();
@@ -122,8 +129,18 @@
        }
        //产品bom/图纸图片提交
        if(productApproving.getCustomCode()!=null && bomList.get(0).getId()!=null) { //与前端约定 定制表单号关联产品,则关联的产品id写入id
            Product product = productService.getById(bomList.get(0).getId());
            List<ProductBom> productBomList = pbService.getBomByProductId(bomList.get(0).getId());
            //product下的图纸复制到新的审批路径
            String rootFile = CommonUtil.getRootFile();
            String dateFormat = new SimpleDateFormat("YYYY-MM").format(new Date());
            long timeStamp = System.currentTimeMillis();
            String filePath = rootFile + "product_approving" + File.separator + user.getName() + File.separator + dateFormat+ File.separator + timeStamp;
            String inFilePath = rootFile + "product" + File.separator + product.getParentModel() + File.separator + "standard"+ File.separator + product.getVersion();
            File parentFile = new File(filePath);
            //FileCopyUtils.copy(new File(inFilePath),parentFile);
            FileUtil.copyDir(new File(inFilePath),parentFile);
            productApproving.setFileUrl(filePath);
            bomList.clear();
            productBomList.forEach(bom->{
                ProductBomApproving approving = new ProductBomApproving();
@@ -142,6 +159,10 @@
                bomList.add(approving);
            });
        }
        //冻结(不启用)已存在的产品编码+定制保单号
        productService.deleteByParentCodeAndCustomCode(productApproving.getParentCode(),productApproving.getCustomCode());
        productHistoryService.updateEnabledStatus(productApproving.getParentCode(),productApproving.getCustomCode(),0);
        productApproving.setMainId(main.getId());
        productApproving.setCreateTime(new Date());
        paService.insert(productApproving);
@@ -175,7 +196,7 @@
        List<MaterialProductApproving> approvingList = new LinkedList<>();
        WorksheetMain main = mainDTO.getMain();
        List<MaterialProductApproving> addedList = mainDTO.getAddedList();
        List<MaterialProductApproving> replacedList = mainDTO.getReplacedList();
        //List<MaterialProductApproving> replacedList = mainDTO.getReplacedList();
        List<MaterialProductApproving> removedList = mainDTO.getRemovedList();
        main.setType(EnumWorksheetType.MaterialProduct.getType());
@@ -231,13 +252,13 @@
            });
            approvingList.addAll(addedList);
        }
        if(replacedList!=null && replacedList.size()!=0){
        /*if(replacedList!=null && replacedList.size()!=0){
            replacedList.forEach(item->{
                item.setMainId(main.getId());
                item.setLinkType(2);
            });
            approvingList.addAll(replacedList);
        }
        }*/
        if(removedList!=null && removedList.size()!=0){
            removedList.forEach(item->{
                item.setMainId(main.getId());
@@ -625,14 +646,14 @@
         //判断是哪种类型的审批,返回不同的类型 具体数据
        Integer type = getInfoById(id).getType();
        if(type.intValue() == EnumWorksheetType.ProductBom.getType()) {
            return mainMapper.getLinkList(id);
            WorksheetMain main = mainMapper.getLinkList(id);
            List<ProductBomApproving> pbaList = approvingService.getList(main.getProductApproving().getId());
            main.getProductApproving().setBomApprovingList(pbaList);
            return main;
        }else if(type.intValue() == EnumWorksheetType.Material.getType()){
            //lxw注释
            //return mainMapper.getLinkListWithMaterials(id);
            return null;
            return mainMapper.getLinkListWithMaterials(id);
        }else{ //物料-产品
            //return mainMapper.getLinkListWithMaterialProducts(id);
            return null;
            return mainMapper.getLinkListWithMaterialProducts(id);
        }
    }