| | |
| | | |
| | | 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 |
| | |
| | | mapper.insert(product); |
| | | } |
| | | |
| | | public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException { |
| | | List<ProductBom> list = new LinkedList<>(); |
| | | |
| | | public Response zipParse(MultipartFile file, Product baseProduct) throws IOException, InvalidFormatException { |
| | | Product product = new Product(); |
| | | List<ProductBom> bomList = new LinkedList<>(); |
| | | Response response = new Response(); |
| | |
| | | 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); |
| | | |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | }); |
| | |
| | | material.setNotes(bom.getNotes()); |
| | | material.setPictureUrl(bom.getPictureUrl()); |
| | | material.setProducer(bom.getProducer()); |
| | | material.setQuantity(bom.getQuantity()); |
| | | // TODO 是否要更新同物料编码的老物料状态为0? |
| | | material.setStatus(1); |
| | | material.setSubCode(bom.getSubCode()); |
| | |
| | | } |
| | | mService.insertBatch(materialList); |
| | | |
| | | //更新product/product_bom/product_history/product_bom_history |
| | | //根据编码和型号确定物料id,存入数据库 |
| | | List<Material> bomMaterialList = mService.getListByCodeAndModelList2(bomList); |
| | | // -> product |
| | | product.setCreateTime(new Date()); |
| | | product.setVersion(nextVersion); |
| | | deleteAndInsert(product); |
| | | //更新product_history/product_bom_history/product/product_bom, |
| | | // product的主键沿用对应product_history的 |
| | | //根据编码和型号确定物料id并对应quantity,存入数据库 |
| | | //List<Material> bomMaterialList = mService.getListByCodeAndModelList2(bomList); |
| | | List<ProductBom> bomMaterialList = pbService.getListByCodeAndModelList2(bomList); |
| | | // -> product_history |
| | | ProductHistory productHistory = new ProductHistory(); |
| | | productHistory.setParentCode(product.getParentCode()); |
| | |
| | | productHistory.setCustomCode(product.getCustomCode()); |
| | | productHistory.setCreateTime(product.getCreateTime()); |
| | | productHistory.setVersion(product.getVersion()); |
| | | //版本新增,初始bom子件版本为1 |
| | | productHistory.setSubVersionMax(1); |
| | | productHistory.setEnabled(1); |
| | | phService.insertAndUpdateEnabled(productHistory); |
| | | // -> product |
| | | product.setId(productHistory.getId()); |
| | | product.setCreateTime(new Date()); |
| | | product.setVersion(nextVersion); |
| | | deleteAndInsert(product); |
| | | // -> product_bom |
| | | List<ProductBom> productBomList = new LinkedList<>(); |
| | | bomMaterialList.forEach(bomMaterial->{ |
| | | ProductBom bom = new ProductBom(); |
| | | bom.setProductId(product.getId()); |
| | | bom.setMaterialId(bomMaterial.getId()); |
| | | bom.setQuantity(bomMaterial.getQuantity()); |
| | | bom.setSubVersion(1); |
| | | bom.setCreateDate(new Date()); |
| | | |
| | |
| | | ProductBomHistory bomHistory = new ProductBomHistory(); |
| | | bomHistory.setProductId(productHistory.getId()); |
| | | bomHistory.setMaterialId(bomMaterial.getId()); |
| | | bomHistory.setQuantity(bomMaterial.getQuantity()); |
| | | bomHistory.setSubSVersion(1); |
| | | bomHistory.setSubEVersion(1); |
| | | bomHistory.setCreateDate(new Date()); |