whycxzp
2022-09-06 19f70fea0253924fc71d5097198d0807d955fb1a
src/main/java/com/whyc/service/ProductService.java
@@ -22,10 +22,7 @@
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -110,7 +107,7 @@
        mapper.insert(product);
    }
    public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException {
    public Response zipParse(MultipartFile file, Product baseProduct) throws IOException, InvalidFormatException {
        Product product = new Product();
        List<ProductBom> bomList = new LinkedList<>();
        Response response = new Response();
@@ -264,7 +261,9 @@
                product.setBomList(bomList);
            }
        }
        return response.setII(1, true, product, filePath);
        //产品bom对比
        Map<String,List> compareMap = pbhService.parseCompare(baseProduct,product);
        return response.setIII(1, true, product,compareMap, filePath);
    }
@@ -274,7 +273,7 @@
            if(fileUrl.substring(fileUrl.lastIndexOf(".")+1).equals("dwg")) {
                FileUrlDTO dto = new FileUrlDTO();
                dto.setFileName(fileUrl.substring(fileUrl.lastIndexOf(File.separator) + 1));
                dto.setHttpFileUrl(fileUrl.substring(fileUrl.lastIndexOf("doc_file" + File.separator + "product_approving")));
                dto.setHttpFileUrl(fileUrl.substring(fileUrl.lastIndexOf("doc_file" + File.separator + "product_submit")));
                list.add(dto);
            }
        });
@@ -287,6 +286,7 @@
        String parentModel = product.getParentModel();
        List<ProductBom> bomList = product.getBomList();
        String fileUrl = product.getFileUrl();
        Date date = new Date();
        //查询产品最新的版本号
        ProductHistory latestProduct = phService.getLatestVersion(parentCode, customCode);
        ProductHistory enabledProduct = phService.getEnabledByParentCodeAndCustomCode(parentCode, customCode);
@@ -455,7 +455,7 @@
        //更新product_history/product_bom_history/product/product_bom,
        // product的主键沿用对应product_history的
        //根据编码和型号确定物料id并对应quantity,存入数据库
        //根据编码和型号确定物料id并对应quantity,存入数据库.
        //List<Material> bomMaterialList = mService.getListByCodeAndModelList2(bomList);
        List<ProductBom> bomMaterialList = pbService.getListByCodeAndModelList2(bomList);
        // -> product_history
@@ -465,15 +465,16 @@
        productHistory.setParentModel(product.getParentModel());
        productHistory.setNotes(product.getNotes());
        productHistory.setCustomCode(product.getCustomCode());
        productHistory.setCreateTime(product.getCreateTime());
        productHistory.setVersion(product.getVersion());
        productHistory.setCreateTime(date);
        productHistory.setVersionTime(product.getVersionTime());
        productHistory.setVersion(nextVersion);
        //版本新增,初始bom子件版本为1
        productHistory.setSubVersionMax(1);
        productHistory.setEnabled(1);
        phService.insertAndUpdateEnabled(productHistory);
        // -> product
        product.setId(productHistory.getId());
        product.setCreateTime(new Date());
        product.setCreateTime(date);
        product.setVersion(nextVersion);
        deleteAndInsert(product);
        // -> product_bom
@@ -484,7 +485,7 @@
            bom.setMaterialId(bomMaterial.getId());
            bom.setQuantity(bomMaterial.getQuantity());
            bom.setSubVersion(1);
            bom.setCreateDate(new Date());
            bom.setCreateDate(date);
            productBomList.add(bom);
        });
@@ -498,7 +499,7 @@
            bomHistory.setQuantity(bomMaterial.getQuantity());
            bomHistory.setSubSVersion(1);
            bomHistory.setSubEVersion(1);
            bomHistory.setCreateDate(new Date());
            bomHistory.setCreateDate(date);
            bomHistoryList.add(bomHistory);
        });