| | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | //更新散件表当前版本,更新eVersion |
| | | List<ComponentProductHistory> cphList = cphService.getListByParentModel(approvingList.get(0).getParentModel(),currentVersion); |
| | | cphService.updateVersionBatch(cphList); |
| | | if(cphList.size()!=0){cphService.updateVersionBatch(cphList);} |
| | | |
| | | /*更新到product_bom*/ |
| | | //查询新的版本 |
| | |
| | | //处理思路:先解除关联,再替换,再关联 |
| | | if(removedList.size()!=0){ |
| | | removedList.forEach(remove -> { |
| | | nowHistoryList.forEach(nowHistory -> { |
| | | /*nowHistoryList.forEach(nowHistory -> { |
| | | if (remove.getComponentId().intValue() == nowHistory.getComponentId()) { |
| | | nowHistoryList.remove(nowHistory); |
| | | } |
| | | }); |
| | | });*/ |
| | | Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | if(remove.getComponentId().intValue() == iterator.next().getComponentId()){ |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | |
| | | if(replacedList.size()!=0){ |
| | | replacedList.forEach(replace -> { |
| | | //当前生效的散装件-产品列表 |
| | | nowHistoryList.forEach(nowHistory -> { |
| | | /*nowHistoryList.forEach(nowHistory -> { |
| | | if (replace.getComponentId().intValue() == nowHistory.getComponentId()) { |
| | | nowHistoryList.remove(nowHistory); |
| | | } |
| | | }); |
| | | //下个版本新增的散装件-产品列表 |
| | | });*/ |
| | | Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | if(replace.getComponentId().intValue() == iterator.next().getComponentId()){ |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | | //下个版本新增替换的散装件-产品列表 |
| | | ComponentProductHistory newHistory = new ComponentProductHistory(); |
| | | newHistory.setComponentId(replace.getComponentId()); |
| | | newHistory.setParentModel(replace.getParentModel()); |
| | |
| | | newHistory.setEVersion(nextVersion); |
| | | newHistoryList.add(newHistory); |
| | | //当前生效的bom列表 |
| | | nowBomHistoryList.forEach(nowBomHistory->{ |
| | | /*nowBomHistoryList.forEach(nowBomHistory->{ |
| | | if(replace.getSubName().equals(nowBomHistory.getSubName())){ |
| | | nowBomHistoryList.remove(nowBomHistory); |
| | | } |
| | | }); |
| | | });*/ |
| | | Iterator<ProductBomHistory> iterator1 = nowBomHistoryList.iterator(); |
| | | while (iterator1.hasNext()){ |
| | | if(replace.getSubName().equals(iterator1.next().getSubName())){ |
| | | iterator1.remove(); |
| | | break; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //处理关联 |
| | | addedList.forEach(add -> { |
| | | nowHistoryList.forEach(nowHistory -> { |
| | | /*nowHistoryList.forEach(nowHistory -> { |
| | | if (add.getComponentId().intValue() == nowHistory.getComponentId()) { |
| | | nowHistoryList.remove(nowHistory); |
| | | } |
| | | }); |
| | | });*/ |
| | | Iterator<ComponentProductHistory> iterator = nowHistoryList.iterator(); |
| | | while (iterator.hasNext()){ |
| | | if(add.getComponentId().intValue() == iterator.next().getComponentId()){ |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | ComponentProductHistory newHistory = new ComponentProductHistory(); |
| | | newHistory.setComponentId(add.getComponentId()); |
| | | newHistory.setParentModel(add.getParentModel()); |
| | | newHistory.setSubName(add.getSubName()); |
| | | newHistory.setCreateTime(new Date()); |
| | | newHistory.setLinkType(1); |
| | | newHistory.setSVersion(nextVersion); |
| | | newHistory.setEVersion(nextVersion); |
| | | newHistoryList.add(newHistory); |
| | | |
| | | }); |
| | | |
| | | //处理完成,进行表单数据更新,分为nowHistoryList,newHistoryList,nowBomHistoryList |
| | |
| | | newHistoryList.forEach(newHis->{newHis.setEVersion(nextVersion);newHis.setSVersion(nextVersion);}); |
| | | nowBomHistoryList.forEach(nowBomHis->nowBomHis.setEVersion(nextVersion)); |
| | | |
| | | cphService.updateVersionBatch(nowHistoryList); |
| | | cphService.insertBatch(newHistoryList); |
| | | historyService.updateVersionBatch(nowBomHistoryList); |
| | | if(nowHistoryList.size()!=0){cphService.updateVersionBatch(nowHistoryList);} |
| | | if(newHistoryList.size()!=0){cphService.insertBatch(newHistoryList);} |
| | | if(nowBomHistoryList.size()!=0){historyService.updateVersionBatch(nowBomHistoryList);} |
| | | //更新ProductBom |
| | | List<ProductBomHistory> newBomList = historyService.getListByParentModel(cpAList.get(0).getParentModel(), nextVersion); |
| | | bomService.updateNewBom(newBomList); |