src/main/java/com/whyc/controller/ProductBomHistoryController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/ProductBom.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/ProductBomHistory.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/ProductBomHistoryService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/ProductBomHistoryController.java
@@ -10,9 +10,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @Api(tags = "文档历史信息管理") @RestController @RequestMapping("productBomHistory") @@ -38,4 +35,11 @@ public void downloaByVersion(HttpServletRequest req, HttpServletResponse resp, @RequestParam String parentModel, @RequestParam int version){ service.downloaByVersion(req,resp,parentModel,version); }*/ @GetMapping("compare") @ApiOperation(value = "版本对比",notes = "preProductId:旧版本的产品id,productId:新版本的产品id") public Response compare(@RequestParam int preProductId,@RequestParam int productId){ return service.compare(preProductId,productId); } } src/main/java/com/whyc/pojo/ProductBom.java
@@ -20,6 +20,10 @@ private Integer id; @ApiModelProperty("产品id") private Integer productId; @ApiModelProperty("物料id") private Integer materialId; @ApiModelProperty("bom最新版本号,同时也是生效版本号(不存在小版本手动启用)") private Integer subVersion; @ApiModelProperty("结构件类型") private String type; @ApiModelProperty("类别") @@ -275,4 +279,16 @@ public void setDwgExist(Integer dwgExist) { this.dwgExist = dwgExist; } public void setMaterialId(Integer materialId) { this.materialId = materialId; } public Integer getSubVersion() { return subVersion; } public void setSubVersion(Integer subVersion) { this.subVersion = subVersion; } } src/main/java/com/whyc/pojo/ProductBomHistory.java
@@ -18,6 +18,12 @@ private Integer id; @ApiModelProperty("产品id") private Integer productId; @ApiModelProperty("物料id") private Integer materialId; @ApiModelProperty("bom起始版本") private Integer subSVersion; @ApiModelProperty("bom终止版本") private Integer subEVersion; @ApiModelProperty("结构件类型") private String type; @ApiModelProperty("类别") @@ -255,4 +261,27 @@ this.customCode = customCode; } public Integer getMaterialId() { return materialId; } public void setMaterialId(Integer materialId) { this.materialId = materialId; } public Integer getSubSVersion() { return subSVersion; } public void setSubSVersion(Integer subSVersion) { this.subSVersion = subSVersion; } public Integer getSubEVersion() { return subEVersion; } public void setSubEVersion(Integer subEVersion) { this.subEVersion = subEVersion; } } src/main/java/com/whyc/service/ProductBomHistoryService.java
@@ -24,7 +24,9 @@ import java.io.*; import java.util.ArrayList; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @Service public class ProductBomHistoryService { @@ -327,4 +329,52 @@ public void insertBatch(List<ProductBomHistory> bomHistoryList) { mapper.insertBatchSomeColumn(bomHistoryList); } /** * 对比: * 现有数据库结构下,无法对比相同物料号的差异 TODO 数据库结构更新,待代码修改 * @param preProductId 旧的版本,作为基准 * @param productId 新的产品版本 * @return */ public Response compare(int preProductId, int productId) { List<ProductBomHistory> baseBomHistoryList = getListByProductId(preProductId); List<ProductBomHistory> bomHistoryList = getListByProductId(productId); //现有数据库结构,无法对比相同物料号的差异 //List<ProductBomHistory> diffList = getListByProductId(productId); List<ProductBomHistory> addList = new LinkedList<>(); List<ProductBomHistory> deleteList = new LinkedList<>(); //通过物料编码定位,对比字段:物料型号/数量/材质/料厚/表面处理/生产商/备注 /*baseBomHistoryList.forEach(baseBom->{ bomHistoryList.forEach(bom->{ if(bom.getSubCode().equals(baseBom.getSubCode())){ ProductBomHistory history = new ProductBomHistory(); if(!bom.getSubModel().equals(baseBom.getSubModel())){ String diffSubModel = "原物料型号:"+baseBom.getSubModel()+"/新物料型号:"+bom.getSubModel(); history.setSubModel(diffSubModel); } } }); });*/ List<String> baseCodeList = baseBomHistoryList.stream().map(ProductBomHistory::getSubCode).collect(Collectors.toList()); List<String> codeList = bomHistoryList.stream().map(ProductBomHistory::getSubCode).collect(Collectors.toList()); bomHistoryList.forEach(bom->{ if(!baseCodeList.contains(bom.getSubCode())){ addList.add(bom); } }); baseBomHistoryList.forEach(baseBom->{ if(!codeList.contains(baseBom.getSubCode())){ deleteList.add(baseBom); } }); return new Response().setII(1,addList,deleteList,"对比完成"); } private List<ProductBomHistory> getListByProductId(int productId) { QueryWrapper<ProductBomHistory> query = Wrappers.query(); query.eq("product_id",productId); return mapper.selectList(query); } }