| | |
| | | } |
| | | |
| | | public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException { |
| | | List<ProductBom> list = new LinkedList<>(); |
| | | |
| | | Product product = new Product(); |
| | | List<ProductBom> bomList = new LinkedList<>(); |
| | | Response response = new Response(); |
| | |
| | | material.setNotes(bom.getNotes()); |
| | | material.setPictureUrl(bom.getPictureUrl()); |
| | | material.setProducer(bom.getProducer()); |
| | | //TODO quantity |
| | | //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()); |