From 9e2ee26a25c6ac42963e374afb01b788831bb52f Mon Sep 17 00:00:00 2001 From: lxw <810412026@qq.com> Date: 星期三, 03 八月 2022 10:16:23 +0800 Subject: [PATCH] 产品管理去除bom最大版本查询和最新版本打包下载 --- src/main/java/com/whyc/service/WorksheetLinkService.java | 112 +++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 78 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/whyc/service/WorksheetLinkService.java b/src/main/java/com/whyc/service/WorksheetLinkService.java index 293fa2c..9f25750 100644 --- a/src/main/java/com/whyc/service/WorksheetLinkService.java +++ b/src/main/java/com/whyc/service/WorksheetLinkService.java @@ -5,11 +5,15 @@ import com.whyc.mapper.ProductBomApprovingMapper; import com.whyc.mapper.WorksheetLinkMapper; import com.whyc.pojo.*; +import com.whyc.util.CommonUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.FileCopyUtils; import javax.annotation.Resource; +import java.io.File; +import java.io.IOException; import java.util.Date; import java.util.LinkedList; import java.util.List; @@ -39,21 +43,20 @@ //鏇存柊鑺傜偣淇℃伅 linkMapper.updateById(link); if(link.getLinkStatus() == 2){ //椹冲洖 - //椹冲洖鍒板憳宸ヨ繘琛屽鐞� - //鏌ヨ宸ュ崟鐨勫憳宸� - Long createUserId = mainService.getInfoById(link.getMainId()).getCreateUserId(); - WorksheetLink link2 = new WorksheetLink(); - link2.setMainId(link.getMainId()); - link2.setParentId(link.getId()); - link2.setDealUserId(createUserId); - link2.setDealType(0); - link2.setDealDesc("宸ュ崟琚粡鐞嗛┏鍥�,椹冲洖淇℃伅:"+link.getDealReason()); - link2.setLinkStatus(0); - link2.setEnableArchive(0); - link2.setRejectVersion(link.getRejectVersion()); - linkMapper.insert(link2); - //鏇存柊涓昏〃鐘舵�� - mainService.updateStatusById(link.getMainId(),0); + //椤圭洰缁忕悊椹冲洖,椹冲洖鍗崇粓姝� + mainService.updateEndStatusById(link.getMainId(),"缁忕悊椹冲洖,椹冲洖鍘熷洜:"+link.getDealReason(),0); + //椤圭洰缁忕悊椹冲洖鍓�,杩樻浘缁忚繃鎬荤粡鐞�,鍒欓渶瑕佸鍔犳�荤粡鐞嗛┏鍥炲師鍥� + if(link.getParentId()!=0) { + QueryWrapper<WorksheetLink> query = Wrappers.query(); + query.eq("id", link.getParentId()); + WorksheetLink parentLink = linkMapper.selectOne(query); + //杩欎釜鏄棤鏁堢殑,鐢ㄦ埛璺熻鑹插姣�,涓嶇,涓嬮潰浠g爜姘镐笉鐢熸晥 + if (parentLink.getDealUserId() == 1003) { + mainService.updateEndStatusById(link.getMainId(), + "缁忕悊椹冲洖,椹冲洖鍘熷洜:" + link.getDealReason() + ";鎬荤粡鐞嗛┏鍥�,椹冲洖鍘熷洜:" + parentLink.getDealReason(), + 0); + } + } }else{ //杩涘叆涓嬩竴鑺傜偣,鎬荤粡鐞嗗鎵� WorksheetLink link2 = new WorksheetLink(); @@ -77,21 +80,25 @@ //鏇存柊鑺傜偣淇℃伅 linkMapper.updateById(link); if(link.getLinkStatus() == 2){ //椹冲洖 - //椹冲洖鍒板憳宸ヨ繘琛屽鐞� - //鏌ヨ瀵瑰簲鐨勯」鐩粡鐞� - Long createUserId = linkMapper.selectById(link.getParentId()).getDealUserId(); - WorksheetLink link2 = new WorksheetLink(); - link2.setMainId(link.getMainId()); - link2.setParentId(link.getId()); - link2.setDealUserId(createUserId); - link2.setDealType(0); - link2.setDealDesc("宸ュ崟琚�荤粡鐞嗛┏鍥�,椹冲洖淇℃伅:"+link.getDealReason()); - link2.setLinkStatus(0); - link2.setEnableArchive(0); - link2.setRejectVersion(link.getRejectVersion()); - linkMapper.insert(link2); - //鏇存柊涓昏〃鐘舵�� - mainService.updateStatusById(link.getMainId(),1); + if(link.getParentId()!=0) { + //鏌ヨ瀵瑰簲鐨勯」鐩粡鐞� + Long createUserId = linkMapper.selectById(link.getParentId()).getDealUserId(); + WorksheetLink link2 = new WorksheetLink(); + link2.setMainId(link.getMainId()); + link2.setParentId(link.getId()); + link2.setDealUserId(createUserId); + link2.setDealType(0); + link2.setDealDesc("宸ュ崟琚�荤粡鐞嗛┏鍥�,椹冲洖淇℃伅:" + link.getDealReason()); + link2.setLinkStatus(0); + link2.setEnableArchive(0); + link2.setRejectVersion(link.getRejectVersion()); + linkMapper.insert(link2); + //鏇存柊涓昏〃鐘舵�� + mainService.updateStatusById(link.getMainId(), 1); + }else{ + //璇存槑鏄」鐩粡鐞嗘彁浜ょ殑,椹冲洖鍗崇粓姝� + mainService.updateEndStatusById(link.getMainId(),"鎬荤粡鐞嗛┏鍥�,椹冲洖鍘熷洜:"+link.getDealReason(),0); + } }else{ //瀹℃壒閫氳繃,鏇存柊涓昏〃鐘舵�� mainService.updateEndStatusById(link.getMainId(),"瀹岀粨",5); @@ -147,7 +154,7 @@ his.setThickness(approvingBom.getThickness()); his.setType(approvingBom.getType()); his.setUnit(approvingBom.getUnit()); - his.setUpUser(approvingBom.getUpUser()); + his.setUpUserId(approvingBom.getUpUserId()); newHistoryList.add(his); }); @@ -161,8 +168,9 @@ .filter(currentHistory -> !approvingUpdateSubNameList.contains(currentHistory.getSubName())) .collect(Collectors.toList()); newVersionCurrentHistoryList.forEach(history->{history.setEVersion(nextVersion);}); - historyService.updateVersionBatch(newVersionCurrentHistoryList); - + if(newVersionCurrentHistoryList.size()!=0) { + historyService.updateVersionBatch(newVersionCurrentHistoryList); + } /*鏇存柊鍒皃roduct_bom*/ //鏌ヨ鏂扮殑鐗堟湰 List<ProductBomHistory> newBomList = historyService.getListByParentModel(approvingList.get(0).getParentModel(), nextVersion); @@ -172,7 +180,43 @@ FileUtil.copyDir()*/ - //灏嗕骇鍝乥om琛ㄧ殑url淇,鏇存柊鍒版寮忚〃 TODO + /*灏嗕骇鍝乥om琛ㄧ殑url淇,鏇存柊鍒版寮忚〃*/ + //瀹℃壒瀹屽悗,灏嗘湰娆$殑bom甯rl鐨勫叏閮ㄥ鍒跺埌姝e紡鏂囦欢澶逛腑 + List<ProductBomApproving> fileBomApprovingList = approvingList.stream() + .filter(productBomApproving -> + productBomApproving.getPictureUrl() != null || productBomApproving.getDwgUrl() != null + ).collect(Collectors.toList()); + String projectDir = CommonUtil.getProjectDir(); + fileBomApprovingList.forEach(fileBom->{ + try { + String pictureUrl = fileBom.getPictureUrl(); + String dwgUrl = fileBom.getDwgUrl(); + if(pictureUrl !=null){ + String newPictureUrl ="doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()+File.separator+ pictureUrl.substring(pictureUrl.lastIndexOf(File.separator)+1); + File newPictureDir = new File(projectDir + File.separator + "doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()); + if(!newPictureDir.exists()){ + newPictureDir.mkdirs(); + } + FileCopyUtils.copy(new File(projectDir+File.separator+ pictureUrl), + new File(projectDir+File.separator+newPictureUrl)); + fileBom.setPictureUrl(newPictureUrl); + } + if(dwgUrl !=null){ + String newDwgUrl ="doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()+File.separator+ dwgUrl.substring(dwgUrl.lastIndexOf(File.separator)+1); + File newDwgDir = new File(projectDir + File.separator + "doc_file"+File.separator+"product"+File.separator+fileBom.getParentModel()); + if(!newDwgDir.exists()){ + newDwgDir.mkdirs(); + } + FileCopyUtils.copy(new File(projectDir+File.separator+ dwgUrl), + new File(projectDir + File.separator + newDwgUrl)); + fileBom.setDwgUrl(newDwgUrl); + } + } catch (IOException e) { + e.printStackTrace(); + } + }); + //鏇存柊姝e紡bom鐨勫搴攗rl + bomService.updateUrl(fileBomApprovingList); } } -- Gitblit v1.9.1