From 8fe657f1d00f27307b51bc609554fe4a996a15ae Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期四, 28 七月 2022 10:53:02 +0800 Subject: [PATCH] 更新工作流 --- src/main/java/com/whyc/service/WorksheetLinkService.java | 121 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 120 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/whyc/service/WorksheetLinkService.java b/src/main/java/com/whyc/service/WorksheetLinkService.java index 2d58845..2e5c4de 100644 --- a/src/main/java/com/whyc/service/WorksheetLinkService.java +++ b/src/main/java/com/whyc/service/WorksheetLinkService.java @@ -1,13 +1,19 @@ package com.whyc.service; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.whyc.mapper.ProductBomApprovingMapper; import com.whyc.mapper.WorksheetLinkMapper; -import com.whyc.pojo.WorksheetLink; +import com.whyc.pojo.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; +import java.util.LinkedList; import java.util.List; +import java.util.stream.Collectors; @Service public class WorksheetLinkService { @@ -18,6 +24,14 @@ @Resource private WorksheetLinkMapper linkMapper; + @Autowired + private ProductBomApprovingMapper approvingMapper; + + @Autowired + private ProductBomService bomService; + + @Autowired + private ProductBomHistoryService historyService; @Transactional public void audit(WorksheetLink link) { @@ -36,6 +50,7 @@ link2.setDealDesc("宸ュ崟琚粡鐞嗛┏鍥�,椹冲洖淇℃伅:"+link.getDealReason()); link2.setLinkStatus(0); link2.setEnableArchive(0); + link2.setRejectVersion(link.getRejectVersion()); linkMapper.insert(link2); //鏇存柊涓昏〃鐘舵�� mainService.updateStatusById(link.getMainId(),0); @@ -49,6 +64,7 @@ link2.setDealDesc("宸ュ崟琚粡鐞嗗鏍搁�氳繃,淇℃伅:"+link.getDealReason()); link2.setLinkStatus(0); link2.setEnableArchive(1); + link2.setRejectVersion(link.getRejectVersion()); linkMapper.insert(link2); //鏇存柊涓昏〃鐘舵�� mainService.updateStatusById(link.getMainId(),2); @@ -72,12 +88,91 @@ link2.setDealDesc("宸ュ崟琚粡鐞嗛┏鍥�,椹冲洖淇℃伅:"+link.getDealReason()); link2.setLinkStatus(0); link2.setEnableArchive(0); + link2.setRejectVersion(link.getRejectVersion()); linkMapper.insert(link2); //鏇存柊涓昏〃鐘舵�� mainService.updateStatusById(link.getMainId(),0); }else{ //瀹℃壒閫氳繃,鏇存柊涓昏〃鐘舵�� mainService.updateEndStatusById(link.getMainId(),"瀹岀粨",5); + //灏嗕骇鍝佹枃浠跺鍒惰嚦姝e紡璺緞 + QueryWrapper<ProductBomApproving> query = Wrappers.query(); + query.eq("main_id",link.getMainId()); + List<ProductBomApproving> approvingList = approvingMapper.selectList(query); + + //澧炲姞->澧炲姞閮ㄤ欢(澧炲姞璁板綍,鍚屾椂鎵�鏈塭Version+1) + //淇敼->淇敼閮ㄤ欢鍥剧焊,淇敼閮ㄤ欢闈炲浘绾�(澧炲姞璁板綍,鍚屾椂淇敼闈炲師閮ㄤ欢鐨勬墍鏈塭Version+1) + //鍒犻櫎? TODO 闇�瑕佺害瀹氶�昏緫 + + //鏌ヨ閮ㄤ欢鏈�鏂扮殑鐗堟湰鍙� + Integer currentVersion = bomService.getProduct(approvingList.get(0).getParentModel()).getVersion(); + if(currentVersion==null){ + currentVersion = 0; + } + Integer nextVersion = currentVersion+1; + //鏇存柊鍒皃roduct_bom_history,澧炲姞杩涘幓鐨勯渶瑕乻Version鍜宔Version涓�鑷� + //澧炲姞鎵�鏈夐儴浠�,鎺掓煡鍑虹浉鍏崇殑鍘熼儴浠�,闈炰篃鏄洿鏂� + List<ProductBomHistory> currentHistoryList = historyService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion); + List<String> currentSubNameList = currentHistoryList.stream().map(ProductBomHistory::getSubName).collect(Collectors.toList()); + + List<ProductBomHistory> newHistoryList = new LinkedList<>(); + approvingList.forEach(approvingBom->{ + if(currentSubNameList.contains(approvingBom.getSubName())){ + approvingBom.setVersion(1); + }else{ + approvingBom.setVersion(0); + } + //杞寲涓簆roductBomHistory + ProductBomHistory his = new ProductBomHistory(); + his.setCategory(approvingBom.getCategory()); + his.setCreateDate(approvingBom.getCreateDate()); + his.setDwgUrl(approvingBom.getDwgUrl()); + his.setEVersion(nextVersion); + his.setFileUrl(approvingBom.getFileUrl()); + his.setMaterial(approvingBom.getMaterial()); + his.setNotes(approvingBom.getNotes()); + his.setParentCode(approvingBom.getParentCode()); + his.setParentModel(approvingBom.getParentModel()); + his.setParentName(approvingBom.getParentName()); + his.setParentVersion(approvingBom.getParentVersion()); + his.setPictureUrl(approvingBom.getPictureUrl()); + his.setProducer(approvingBom.getProducer()); + his.setQuantity(approvingBom.getQuantity()); + his.setSubCode(approvingBom.getSubCode()); + his.setSubModel(approvingBom.getSubModel()); + his.setSubName(approvingBom.getSubName()); + his.setSurfaceDetail(approvingBom.getSurfaceDetail()); + his.setSVersion(nextVersion); + his.setThickness(approvingBom.getThickness()); + his.setType(approvingBom.getType()); + his.setUnit(approvingBom.getUnit()); + his.setUpdateDate(approvingBom.getUpdateDate()); + his.setUpUser(approvingBom.getUpUser()); + + newHistoryList.add(his); + }); + //鏈瀹℃牳涓瓙浠惰淇敼鐨勫瓙浠堕泦鍚� + List<String> approvingUpdateSubNameList = approvingList.stream().filter(approvingBom -> approvingBom.getVersion() == 1).map(ProductBomApproving::getSubName).collect(Collectors.toList()); + + historyService.addBatch(newHistoryList); + /*鏇存柊浜у搧鐨勫綋鍓嶇増鏈�,鏇存柊鍒版渶鏂扮殑鐗堟湰*/ + //褰撳墠鐗堟湰鐨勬墍鏈塨om鐨別Version鏇存柊,鎺掗櫎琚慨鏀圭殑瀛愪欢 + List<ProductBomHistory> newVersionCurrentHistoryList = currentHistoryList.stream() + .filter(currentHistory -> !approvingUpdateSubNameList.contains(currentHistory.getSubName())) + .collect(Collectors.toList()); + newVersionCurrentHistoryList.forEach(history->{history.setEVersion(nextVersion);}); + historyService.updateVersionBatch(newVersionCurrentHistoryList); + + /*鏇存柊鍒皃roduct_bom*/ + //鏌ヨ鏂扮殑鐗堟湰 + List<ProductBomHistory> newBomList = historyService.getListByParentModel(approvingList.get(0).getParentModel(), nextVersion); + bomService.updateNewBom(newBomList); + + /*String projectDir = CommonUtil.getProjectDir(); + FileUtil.copyDir()*/ + + + //灏嗕骇鍝乥om琛ㄧ殑url淇,鏇存柊鍒版寮忚〃 TODO } } @@ -89,4 +184,28 @@ public List<WorksheetLink> getInfoList(Long id) { return linkMapper.getInfoList(id); } + + /** + * + * @param userId 鎬荤粡鐞嗗搴旂殑userId + * @param statusExp 0:鏈鎵�,1:宸插鎵�(鍖呭惈鐘舵�佸��1,2) + * @return + */ + public List<WorksheetMain> getInfoList2(Long userId, int statusExp) { + return linkMapper.getInfoList2(userId,statusExp); + } + + /** + * + * @param userId 鎬荤粡鐞嗗搴旂殑userId + * @param statusExp 0:鏈鎵�,1:宸插鎵�(鍖呭惈鐘舵�佸��1,2) + * @return + */ + public List<WorksheetMain> getInfoList3(Long userId, int statusExp) { + return linkMapper.getInfoList3(userId,statusExp); + } + + public DocUser getApprovingUser(Integer mainId) { + return linkMapper.getApprovingUser(mainId); + } } -- Gitblit v1.9.1