bom-查看变更记录
This commit is contained in:
parent
7687006045
commit
f9829796c0
|
|
@ -127,8 +127,8 @@ public class BomReportApi extends BaseApi {
|
|||
|
||||
@PostMapping("getUpdateLog")
|
||||
@ApiOperation("bom-变更记录(和上一版本对比)")
|
||||
public ResultVO<List<UpdateLogVO>> getUpdateLog(@ApiParam("bom版本RowId") @RequestParam("bomRowId") Long bomRowId) {
|
||||
return ResultVO.success(forwardReportService.getUpdateLog(bomRowId));
|
||||
public ResultVO<List<UpdateLogVO>> getUpdateLog(@ApiParam("bom版本RowId") @RequestParam("bomRowId") Long bomRowId , @ApiParam("BOM 类型 0-原始BOM 1-EBom 2-PBom") @RequestParam("bomType") Integer bomType) {
|
||||
return ResultVO.success(forwardReportService.getUpdateLog(bomRowId,bomType));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,8 @@ public class BomConstant {
|
|||
|
||||
public static final Integer YES=1;
|
||||
public static final Integer NO=0;
|
||||
|
||||
public static final String ADD="新增";
|
||||
public static final String UP="修改";
|
||||
public static final String DEL="删除";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ public class UpdateLogVO {
|
|||
@ApiModelProperty(value = "序号")
|
||||
private String orderNumber;
|
||||
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private String currentVersion;
|
||||
|
||||
|
||||
@ApiModelProperty("项目类别")
|
||||
private String projectType;
|
||||
|
||||
|
|
@ -38,5 +42,8 @@ public class UpdateLogVO {
|
|||
@ApiModelProperty("操作类型")
|
||||
private String opType;
|
||||
|
||||
@ApiModelProperty("旧版或新版 0-旧版 1-新版")
|
||||
private Integer oldOrNewVersion=0;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
|
|
@ -19,9 +22,12 @@ import com.nflg.product.bomnew.util.EecExcelUtil;
|
|||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import org.apache.ibatis.builder.ParameterExpression;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.ttzero.excel.entity.ListSheet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
|
|
@ -32,6 +38,19 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class ForwardReportService {
|
||||
|
||||
@Resource
|
||||
private BomNewEbomParentFormalService ebomParentFormalService;
|
||||
|
||||
@Resource
|
||||
private BomNewEbomChildFormalService ebomChildFormalService;
|
||||
|
||||
|
||||
@Resource
|
||||
private BomNewPbomParentFormalService pbomParentFormalService;
|
||||
|
||||
@Resource
|
||||
private BomNewPbomChildFormalService pbomChildFormalService;
|
||||
|
||||
|
||||
public ReportBomVersionVO factoryVersion(ReverseReportQuery query) {
|
||||
//原始BOM
|
||||
|
|
@ -402,8 +421,101 @@ public class ForwardReportService {
|
|||
}
|
||||
|
||||
|
||||
public List<UpdateLogVO> getUpdateLog(Long bomRowId){
|
||||
/**
|
||||
* 获取BOM变更记录
|
||||
* @param bomRowId bom版本rowId
|
||||
* @param bomType BOM 类型 0-原始BOM 1-EBom 2-PBom
|
||||
* @return
|
||||
*/
|
||||
public List<UpdateLogVO> getUpdateLog(Long bomRowId ,Integer bomType){
|
||||
//结果
|
||||
List<UpdateLogVO> result=new ArrayList<>();
|
||||
//eBom
|
||||
if(bomType==1){
|
||||
BomNewEbomParentFormalEntity ebomVersion = ebomParentFormalService.getById(bomRowId);
|
||||
if(Objects.nonNull(ebomVersion)){
|
||||
//上一个BOM版本
|
||||
BomNewEbomParentFormalEntity preBomVersion = ebomParentFormalService.lambdaQuery().eq(BomNewEbomParentFormalEntity::getMaterialNo, ebomVersion.getMaterialNo())
|
||||
.lt(BomNewEbomParentFormalEntity::getCurrentVersion, ebomVersion.getCurrentVersion()).orderByDesc(BomNewEbomParentFormalEntity::getCurrentVersion).last(" limit 1").one();
|
||||
if(Objects.nonNull(preBomVersion)) {
|
||||
List<BomNewEbomChildFormalEntity> newBomDetail = ebomChildFormalService.lambdaQuery().eq(BomNewEbomChildFormalEntity::getParentRowId, bomRowId).list();
|
||||
|
||||
List<BomNewEbomChildFormalEntity> oldBomDetail = ebomChildFormalService.lambdaQuery().eq(BomNewEbomChildFormalEntity::getParentRowId, preBomVersion.getRowId()).list();
|
||||
List<UpdateLogVO> newBomChild = Convert.toList(UpdateLogVO.class, newBomDetail);
|
||||
List<UpdateLogVO> oldBomChild = Convert.toList(UpdateLogVO.class, oldBomDetail);
|
||||
newBomChild.forEach(item->{item.setCurrentVersion(ebomVersion.getCurrentVersion()); item.setOldOrNewVersion(1);});
|
||||
oldBomChild.forEach(item->item.setCurrentVersion(preBomVersion.getCurrentVersion()));
|
||||
result=compare(oldBomChild,newBomChild);
|
||||
}
|
||||
}
|
||||
}//pBom
|
||||
else if(bomType==2){
|
||||
BomNewPbomParentFormalEntity pbomVersion = pbomParentFormalService.getById(bomRowId);
|
||||
if(Objects.nonNull(pbomVersion)){
|
||||
//上一个BOM版本
|
||||
BomNewPbomParentFormalEntity preBomVersion = pbomParentFormalService.lambdaQuery().eq(BomNewPbomParentFormalEntity::getMaterialNo, pbomVersion.getMaterialNo())
|
||||
.lt(BomNewPbomParentFormalEntity::getCurrentVersion, pbomVersion.getCurrentVersion()).orderByDesc(BomNewPbomParentFormalEntity::getCurrentVersion).last(" limit 1").one();
|
||||
if(Objects.nonNull(preBomVersion)) {
|
||||
List<BomNewPbomChildFormalEntity> newBomDetail = pbomChildFormalService.lambdaQuery().eq(BomNewPbomChildFormalEntity::getParentRowId, bomRowId).list();
|
||||
|
||||
List<BomNewPbomChildFormalEntity> oldBomDetail = pbomChildFormalService.lambdaQuery().eq(BomNewPbomChildFormalEntity::getParentRowId, preBomVersion.getRowId()).list();
|
||||
List<UpdateLogVO> newBomChild = Convert.toList(UpdateLogVO.class, newBomDetail);
|
||||
List<UpdateLogVO> oldBomChild = Convert.toList(UpdateLogVO.class, oldBomDetail);
|
||||
newBomChild.forEach(item->{item.setCurrentVersion(pbomVersion.getCurrentVersion()); item.setOldOrNewVersion(1);});
|
||||
oldBomChild.forEach(item->item.setCurrentVersion(preBomVersion.getCurrentVersion()));
|
||||
result=compare(oldBomChild,newBomChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new NflgBusinessException(STATE.ParamErr ,"bomType参数错误:暂不支持该类型BOM");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bom-对比(变更记录)
|
||||
* @param oldBom
|
||||
* @param newBom
|
||||
* @return
|
||||
*/
|
||||
private List<UpdateLogVO> compare(List<UpdateLogVO> oldBom, List<UpdateLogVO> newBom){
|
||||
List<UpdateLogVO> result =new ArrayList<>();
|
||||
|
||||
Set<String> oldSet = oldBom.stream().map(u -> u.getOrderNumber()).collect(Collectors.toSet());
|
||||
Set<String> newSet =newBom.stream().map(u->u.getOrderNumber()).collect(Collectors.toSet());
|
||||
//删除的
|
||||
Set<String> del = Sets.difference(oldSet, newSet);
|
||||
for (String item: del) {
|
||||
UpdateLogVO oldEnd=oldBom.stream().filter(u->u.getOrderNumber().equals(item)).findFirst().get();
|
||||
result.add(oldEnd);
|
||||
UpdateLogVO newEnt =new UpdateLogVO();
|
||||
BeanUtil.copyProperties(oldEnd,newEnt);
|
||||
newEnt.setOpType(BomConstant.DEL);
|
||||
|
||||
}
|
||||
|
||||
//新增
|
||||
Set<String> add= Sets.difference(newSet,oldSet);
|
||||
for (String item: add) {
|
||||
UpdateLogVO updateLogVO=newBom.stream().filter(u->u.getOrderNumber().equals(item)).findFirst().get();
|
||||
updateLogVO.setOpType(BomConstant.ADD);
|
||||
result.add(updateLogVO);
|
||||
}
|
||||
|
||||
//都有比较编辑字段
|
||||
Set<String> intersection = Sets.intersection(oldSet,newSet);
|
||||
for (String item: intersection) {
|
||||
UpdateLogVO oldEnt = oldBom.stream().filter(u -> u.getOrderNumber().equals(item)).findFirst().get();
|
||||
UpdateLogVO newEnt = newBom.stream().filter(u -> u.getOrderNumber().equals(item)).findFirst().get();
|
||||
if(!oldEnt.getMaterialNo().equals(newEnt.getMaterialNo()) || ! oldEnt.getNum().equals(newEnt.getNum()) || oldEnt.getProjectType().equals(newEnt.getProjectType())){
|
||||
result.add(oldEnt);
|
||||
newEnt.setOpType(BomConstant.UP);
|
||||
result.add(newEnt);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue