| | |
| | | |
| | | 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 |
| | |
| | | wrapper.orderByAsc("id"); |
| | | List list=mapper.selectList(wrapper); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0?true:false,pageInfo,"返回产品信息"); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"返回产品信息"); |
| | | } |
| | | |
| | | public Product getVersion(String parentCode, String customCode) { |
| | |
| | | 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); |
| | | } |
| | | }); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | //更新product/product_bom/product_history/product_bom_history |
| | | // -> product |
| | | product.setCreateTime(new Date()); |
| | | product.setVersion(nextVersion); |
| | | deleteAndInsert(product); |
| | | // -> product_history |
| | | ProductHistory productHistory = new ProductHistory(); |
| | | productHistory.setParentCode(product.getParentCode()); |
| | | productHistory.setParentName(product.getParentName()); |
| | | productHistory.setParentModel(product.getParentModel()); |
| | | productHistory.setNotes(product.getNotes()); |
| | | productHistory.setCustomCode(product.getCustomCode()); |
| | | productHistory.setCreateTime(product.getCreateTime()); |
| | | productHistory.setVersion(product.getVersion()); |
| | | productHistory.setEnabled(1); |
| | | phService.insertAndUpdateEnabled(productHistory); |
| | | // -> product_bom |
| | | bomList.forEach(bom->{ |
| | | bom.setCreateDate(new Date()); |
| | | }); |
| | | pbService.insertBatch(bomList); |
| | | // -> product_bom_history |
| | | List<ProductBomHistory> bomHistoryList = new LinkedList<>(); |
| | | bomList.forEach(bom->{ |
| | | ProductBomHistory bomHistory = new ProductBomHistory(); |
| | | bomHistory.setProductId(productHistory.getId()); |
| | | bomHistory.setSubCode(bom.getSubCode()); |
| | | bomHistory.setCreateDate(new Date()); |
| | | |
| | | bomHistoryList.add(bomHistory); |
| | | }); |
| | | pbhService.insertBatch(bomHistoryList); |
| | | |
| | | //物料表中不存在的(依据:物料编码+物料型号),则添加到物料表中去(包含product这个物料) |
| | | List<Material> materialExistList = mService.getListByCodeAndModelList2(bomList); |
| | |
| | | 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()); |
| | |
| | | materialList.add(material); |
| | | } |
| | | mService.insertBatch(materialList); |
| | | |
| | | //更新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.setParentName(product.getParentName()); |
| | | productHistory.setParentModel(product.getParentModel()); |
| | | productHistory.setNotes(product.getNotes()); |
| | | 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()); |
| | | |
| | | productBomList.add(bom); |
| | | }); |
| | | pbService.insertBatch(productBomList); |
| | | // -> product_bom_history |
| | | List<ProductBomHistory> bomHistoryList = new LinkedList<>(); |
| | | bomMaterialList.forEach(bomMaterial->{ |
| | | 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()); |
| | | |
| | | bomHistoryList.add(bomHistory); |
| | | }); |
| | | pbhService.insertBatch(bomHistoryList); |
| | | |
| | | return new Response().setII(1,"新增完成"); |
| | | } |
| | | |
| | |
| | | query.eq("parent_code",parentCode).eq("custom_code",customCode).last(" limit 1"); |
| | | return mapper.selectOne(query); |
| | | } |
| | | //查询出所有的产品无参不分页(产品上传的是用) |
| | | public Response getUpBomUseProduct() { |
| | | List list=mapper.selectList(null); |
| | | return new Response().setII(1,list.size()>0,list,""); |
| | | } |
| | | } |