src/main/java/com/whyc/controller/MaterialHistoryController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/MaterialHistoryService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/ProductService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/MaterialHistoryController.java
@@ -27,4 +27,16 @@ public Response getPicHisById(@RequestParam int materialId,@RequestParam int pageCurr,@RequestParam int pageSize){ return service.getPicHisById(materialId,pageCurr,pageSize); } /** * 一次调用,用于保留首次物料的图纸或图片 * @return */ @GetMapping("moveFromMaterialTable") public Response moveFromMaterialTable(@RequestParam int checkNum){ if(checkNum == 87654321){ return service.moveFromMaterialTable(checkNum); } return new Response().set(1,false,"参数校验错误"); } } src/main/java/com/whyc/service/MaterialHistoryService.java
@@ -5,17 +5,27 @@ import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; import com.whyc.mapper.MaterialHistoryMapper; import com.whyc.pojo.Material; import com.whyc.pojo.MaterialHistory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @Service public class MaterialHistoryService { @Resource private MaterialHistoryMapper mapper; @Autowired @Lazy private MaterialService materialService; public void insert(MaterialHistory mh) { mapper.insert(mh); @@ -48,4 +58,24 @@ PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list.size()>0,pageInfo,"根据物料id查询pic历史"); } public Response moveFromMaterialTable(int checkNum) { List<Material> list = materialService.getList(); list = list.stream().filter(temp-> temp.getPictureUrl()!=null || temp.getDwgUrl()!=null).collect(Collectors.toList()); List<MaterialHistory> materialHistories = new LinkedList<>(); Date now = new Date(); for (Material material : list) { MaterialHistory history = new MaterialHistory(); history.setProductId(0); history.setMaterialId(material.getId()); history.setPictureUrl(material.getPictureUrl()); history.setDwgUrl(material.getDwgUrl()); history.setUpUserId(material.getUpUserId()==null?null:material.getUpUserId().intValue()); history.setCreateTime(now); materialHistories.add(history); } mapper.insertBatchSomeColumn(materialHistories); return new Response().set(1,true,"首次的物料图纸转移保存完成"); } } src/main/java/com/whyc/service/ProductService.java
@@ -450,6 +450,7 @@ String zipFilePath = product.getFileUrl(); Date date = new Date(); String dateStr = DateUtil.YYYY_MM_DD_HH_MM_SS_UNION.format(date); Long userId = ActionUtil.getUser().getId(); boolean isCopyCustom = false; Product relatedProduct = null; //校验凡是有定制表单号的产品,不能使用已上传过的标准产品编码 @@ -900,6 +901,7 @@ material.setSubName(bom.getSubName()); material.setType(bom.getType()); material.setUnit(bom.getUnit()); material.setUpUserId(userId); materialList.add(material); } else { //物料已经存在的 @@ -929,6 +931,7 @@ material.setSubModel(product.getParentModel()); material.setCreateDate(date); material.setStatus(1); material.setUpUserId(userId); materialList.add(material); } @@ -1026,7 +1029,7 @@ materialHistory.setPictureUrl(material.getPictureUrl()); materialHistory.setProductId(productHistory.getId()); materialHistory.setDwgUrl(material.getDwgUrl()); materialHistory.setUpUserId(ActionUtil.getUser().getId().intValue()); materialHistory.setUpUserId(userId.intValue()); materialHistory.setCreateTime(date); for (Material materialInDB : materialExistList) { if ((material.getSubCode() + "/" + material.getSubModel()).equals(materialInDB.getSubCode() + "/" + materialInDB.getSubModel())) {