From 4d2a6bd70db3fdf4646b23244563252e41a514db Mon Sep 17 00:00:00 2001 From: liuxm <liuxm@fescotech.com> Date: 星期四, 16 五月 2024 09:42:58 +0800 Subject: [PATCH] 产品,生产线,添加查询所有方法 --- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 87 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 77 insertions(+), 10 deletions(-) diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java index 7ca53a1..2c1dcaf 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java @@ -2,8 +2,10 @@ import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoOth.OthFileMapper; +import com.dy.pmsGlobal.daoPlt.PltProParamsMapper; import com.dy.pmsGlobal.daoPlt.PltProductFileMapper; import com.dy.pmsGlobal.daoPlt.PltProductMapper; +import com.dy.pmsGlobal.daoPlt.PltProductQualityInspectionItemsMapper; import com.dy.pmsGlobal.dyFile.FileOperate; import com.dy.pmsGlobal.dyFile.FileRestVo; import com.dy.pmsGlobal.pojoOth.OthFile; @@ -18,6 +20,7 @@ import java.util.List; import java.util.Map; +import java.util.stream.Stream; @Slf4j @Service @@ -27,6 +30,8 @@ private FileOperate fileOperate; private OthFileMapper othFileMapper; + private PltProductQualityInspectionItemsMapper itemDao; + private PltProParamsMapper paramDao; @Value("${dy.webFile.fmUrl}") private String fmUrl ; @@ -48,15 +53,57 @@ public void setPfDao(PltProductFileMapper pfDao) { this.pfDao = pfDao; } + @Autowired + public void setItemDao(PltProductQualityInspectionItemsMapper itemDao) { + this.itemDao = itemDao; + } + @Autowired + public void setParamDao(PltProParamsMapper paramDao) { + this.paramDao = paramDao; + } + @Transactional - public long save(PltProduct p) { - return dao.insert(p); + public int save(PltProduct p) { + int count = dao.insert(p); + if(count>0){ + saveProRel(p); + } + return count; } @Transactional public int update(PltProduct p) { - return dao.updateByPrimaryKeySelective(p); + int count = dao.updateByPrimaryKeySelective(p); + //鍒犻櫎鏃ф暟鎹�,閲嶆柊鎻掑叆 + pfDao.deleteByProId(p.id); + saveProRel(p); + return count; } + + + private void saveProRel(PltProduct p) { + p.params.forEach(param->{ + param.proId=p.id; + if(param.id !=null){ + paramDao.updateByPrimaryKeySelective(param); + }else{ + paramDao.insert(param); + } + }); + saveRel(p, p.processDocuments, "01"); + saveRel(p, p.userManual, "02"); + saveRel(p, p.materials, "03"); + } + + private void saveRel(PltProduct p, List<PltProductFile> docs, String fileType) { + docs.forEach(doc -> { + doc.proId = p.id; + doc.fileType = fileType; + pfDao.insert(doc); + }); + } + + /** * 閫昏緫鍒犻櫎瀹炰綋 @@ -74,16 +121,32 @@ return pro; } - private PltProduct addWebUrl(PltProduct pro){ - if(pro !=null &&pro.image!=null){ - OthFile file = othFileMapper.selectByPrimaryKey(pro.image); - FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash ); + private PltProduct addWebUrl(PltProduct pro) { + if (pro != null) { + if (pro.image != null) { + String filePathWithWebUrl = getFilePathWithWebUrl(pro.image); + pro.imageWebPath = filePathWithWebUrl; + pro.imageWebPathZip = fileOperate.getImgFileZipPath(filePathWithWebUrl); + } - pro.imageWebPath=fileRestVo.fileWebUrl +file.filePath; - pro.imageWebPathZip= fileOperate.getImgFileZipPath(fileRestVo.fileWebUrl +file.filePath); + Stream.concat( + pro.userManual.stream(), + Stream.concat(pro.processDocuments.stream(), pro.materials.stream()) + ) + .forEach(doc -> { + String webUrl = getFilePathWithWebUrl(doc.fileId); + doc.webUrl = webUrl; + }); } return pro; } + + private String getFilePathWithWebUrl(Long fileId) { + OthFile file = othFileMapper.selectByPrimaryKey(fileId); + FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash); + return fileRestVo.fileWebUrl + file.filePath; + } + /** * 鑾峰彇浜у搧鍒楄〃 @@ -106,10 +169,11 @@ * @param fileId 鏂囨。id * @return 鏇存柊鏁伴噺 */ - public int addDoc(long proId,long fileId){ + public int addDoc(long proId,long fileId,String fileType){ PltProductFile pf=new PltProductFile(); pf.fileId = fileId; pf.proId = proId; + pf.fileType = fileType; return pfDao.insertSelective(pf); } @@ -123,4 +187,7 @@ } + public List<PltProduct> selectAll() { + return dao.selectAll(); + } } -- Gitblit v1.8.0