ebom pbom 报表单层子级

This commit is contained in:
jing's 2024-07-05 21:03:28 +08:00
parent 02ed618269
commit 5ba378b684
5 changed files with 153 additions and 50 deletions

View File

@ -205,6 +205,11 @@ public class BomReportApi extends BaseApi {
return ResultVO.error(STATE.ParamErr, "bomRowId不能空"); return ResultVO.error(STATE.ParamErr, "bomRowId不能空");
} }
if (Objects.isNull(query.getVersionStrategy())) {
return ResultVO.error(STATE.ParamErr, "版本策略不能空");
}
return ResultVO.success(forwardReportService.chilidBom(query)); return ResultVO.success(forwardReportService.chilidBom(query));
} }

View File

@ -16,7 +16,15 @@ public class ChildBomReportQuery {
@NotNull(message = "BOM类型不能为空") @NotNull(message = "BOM类型不能为空")
private Integer bomType; private Integer bomType;
@ApiModelProperty("版本策略 0-最新版 1-全部版本 2-指定版本")
private Integer versionStrategy;
@ApiModelProperty("子级Bom") @ApiModelProperty("子级Bom")
@NotNull(message = "bomRowId不能为空")
private Long bomRowId; private Long bomRowId;
} }

View File

@ -3,14 +3,14 @@ package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference; import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
import com.nflg.product.bomnew.constant.OriginalConstant; import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.constant.ReportConstant; import com.nflg.product.bomnew.constant.ReportConstant;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity; import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity; import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentFormalEntity;
import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery; import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery; import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
import com.nflg.product.bomnew.pojo.vo.*; import com.nflg.product.bomnew.pojo.vo.*;
@ -28,6 +28,8 @@ import org.ttzero.excel.entity.ListSheet;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.*; import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -168,8 +170,23 @@ public class ForwardReportService {
List<ForwardReportVO> chilidEBomList(ChildBomReportQuery query) { List<ForwardReportVO> chilidEBomList(ChildBomReportQuery query) {
BomNewEbomParentFormalEntity parentEntity=SpringUtil.getBean(BomNewEbomParentFormalService .class).getById(query.getBomRowId());
List<BomNewEbomParentFormalVO> parentChildList = SpringUtil.getBean(BomNewEbomParentFormalService.class). getParentChild(query.getBomRowId());
BomNewEbomParentVO parentEntity=null;
List<BomNewEbomParentVO> parentChildList=null;
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
parentEntity= Convert.convert(BomNewEbomParentVO.class,SpringUtil.getBean(BomNewEbomParentService .class).getById(query.getBomRowId()));
parentChildList
= Convert.toList(BomNewEbomParentVO.class,SpringUtil.getBean(BomNewEbomParentService.class). getParentChild(query.getBomRowId()));
}else{
parentEntity= Convert.convert(BomNewEbomParentVO.class,SpringUtil.getBean(BomNewEbomParentFormalService .class).getById(query.getBomRowId()));
parentChildList
= Convert.toList(BomNewEbomParentVO.class,SpringUtil.getBean(BomNewEbomParentFormalService.class). getParentChild(query.getBomRowId()));
}
if(CollUtil.isEmpty(parentChildList)){ if(CollUtil.isEmpty(parentChildList)){
return new ArrayList<>(); return new ArrayList<>();
@ -177,32 +194,58 @@ public class ForwardReportService {
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(parentChildList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(parentChildList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<Long> bomRowIds=parentChildList.stream().filter(u -> Objects.nonNull(u.getBomRowId()) && u.getBomRowId()>0 ).map(BomNewEbomParentFormalVO::getBomRowId).collect(Collectors.toList()); Map<Long, BomNewEbomParentVO > parentEntityMap=null;
Map<Long, BomNewEbomParentFormalEntity> parentEntityMap=null; if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
if(CollUtil.isNotEmpty(bomRowIds)) { List<String> materialNos = parentChildList.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) )
List<BomNewEbomParentFormalEntity> bomlist = SpringUtil.getBean(BomNewEbomParentFormalService.class).lambdaQuery().in(BomNewEbomParentFormalEntity::getRowId, bomRowIds).list(); .map(BomNewEbomParentVO::getMaterialNo).collect(Collectors.toList());
parentEntityMap = ListCommonUtil.listToMap(bomlist, BomNewEbomParentFormalEntity::getRowId); List<BomNewEbomParentEntity> childBomlist = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery()
.in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
List<BomNewEbomParentVO> covertList=Convert.toList(BomNewEbomParentVO.class,childBomlist);
parentEntityMap = covertList.parallelStream()
.collect(Collectors.toMap(
BomNewEbomParentVO::getRowId,
Function.identity(),
BinaryOperator.maxBy(Comparator.comparing(BomNewEbomParentVO::getCurrentVersion))
));
}else {
List<Long> bomRowIds=parentChildList.stream().filter(u -> Objects.nonNull(u.getBomRowId()) && u.getBomRowId()>0 )
.map(BomNewEbomParentVO::getBomRowId).collect(Collectors.toList());
if(CollUtil.isNotEmpty(bomRowIds)) {
List<BomNewEbomParentFormalEntity> bomlist = SpringUtil.getBean(BomNewEbomParentFormalService.class).lambdaQuery()
.in(BomNewEbomParentFormalEntity::getRowId, bomRowIds).list();
parentEntityMap = ListCommonUtil.listToMap(Convert.toList(BomNewEbomParentVO.class,bomlist), BomNewEbomParentVO::getRowId);
}
} }
for (BomNewEbomParentFormalVO vo :
for (BomNewEbomParentVO vo :
parentChildList) { parentChildList) {
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getBomRowId())) { if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getParentRowId())) {
BomNewEbomParentFormalEntity ebomParentEntity = parentEntityMap.get(vo.getBomRowId()); BomNewEbomParentVO ebomParentEntity = parentEntityMap.get(vo.getParentRowId());
vo.setDeviseName(ebomParentEntity.getDeviseName()); vo.setDeviseName(ebomParentEntity.getDeviseName());
vo.setDeviseUserCode(ebomParentEntity.getDeviseUserCode()); vo.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
vo.setCurrentVersion(ebomParentEntity.getCurrentVersion()); vo.setCurrentVersion(ebomParentEntity.getCurrentVersion());
vo.setExpireEndTime(ebomParentEntity.getConvertToEbomTime()); vo.setExpireEndTime(ebomParentEntity.getConvertToEbomTime());
vo.setBomRowId(ebomParentEntity.getRowId());
}else{ }else{
vo.setDeviseName(parentEntity.getDeviseName()); vo.setDeviseName(parentEntity.getDeviseName());
vo.setDeviseUserCode(parentEntity.getDeviseUserCode()); vo.setDeviseUserCode(parentEntity.getDeviseUserCode());
if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) { // if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); // vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} // }
else { // else {
vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); // vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
} // }
} }
} }
@ -214,33 +257,71 @@ public class ForwardReportService {
List<ForwardReportVO> chilidPBomList(ChildBomReportQuery query) { List<ForwardReportVO> chilidPBomList(ChildBomReportQuery query) {
BomNewPbomParentVO parentEntity=null;
BomNewPbomParentFormalEntity parentEntity= SpringUtil.getBean(BomNewPbomParentFormalService .class).getById(query.getBomRowId()); List<BomNewPbomParentVO> parentChildList=null;
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
parentEntity= Convert.convert(BomNewPbomParentVO.class,SpringUtil.getBean(BomNewPbomParentService .class).getById(query.getBomRowId()));
parentChildList
= Convert.toList(BomNewPbomParentVO.class,SpringUtil.getBean(BomNewPbomParentMapper.class). getParentChild(query.getBomRowId()));
}else{
parentEntity= Convert.convert(BomNewPbomParentVO.class,SpringUtil.getBean(BomNewPbomParentFormalService .class).getById(query.getBomRowId()));
parentChildList
= Convert.toList(BomNewPbomParentVO.class,SpringUtil.getBean(BomNewPbomParentFormalService.class). getParentChild(query.getBomRowId()));
}
List<BomNewPbomParentFormalVO> parentChildList = SpringUtil.getBean(BomNewPbomParentFormalService .class).getParentChild(query.getBomRowId());
if(CollUtil.isEmpty(parentChildList)){ if(CollUtil.isEmpty(parentChildList)){
return new ArrayList<>(); return new ArrayList<>();
} }
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(parentChildList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(parentChildList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<Long> bomRowIds=parentChildList.stream().filter(u -> Objects.nonNull(u.getBomRowId()) && u.getBomRowId()>0 ).map(BomNewPbomParentFormalVO::getBomRowId).collect(Collectors.toList());
Map<Long, BomNewPbomParentFormalEntity> parentEntityMap=null; Map<Long, BomNewPbomParentVO > parentEntityMap=null;
if(CollUtil.isNotEmpty(bomRowIds)) { if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
List<BomNewPbomParentFormalEntity > bomlist = SpringUtil.getBean(BomNewPbomParentFormalService.class ).lambdaQuery().in(BomNewPbomParentFormalEntity::getRowId, bomRowIds).list(); List<String> materialNos = parentChildList.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) )
.map(BomNewPbomParentVO::getMaterialNo).collect(Collectors.toList());
parentEntityMap = ListCommonUtil.listToMap(bomlist, BomNewPbomParentFormalEntity::getRowId); List<BomNewPbomParentEntity> childBomlist = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
.in(BomNewPbomParentEntity::getMaterialNo, materialNos)
.eq(BomNewPbomParentEntity::getFacCode, parentEntity.getFacCode()).list();
List<BomNewPbomParentVO> covertList=Convert.toList(BomNewPbomParentVO.class,childBomlist);
parentEntityMap = covertList.stream()
.collect(Collectors.groupingBy(
BomNewPbomParentVO::getRowId,
Collectors.collectingAndThen(
Collectors.maxBy(Comparator.comparing(BomNewPbomParentVO::getCurrentVersion)),
Optional::get
)
));
}else {
List<Long> bomRowIds=parentChildList.stream().filter(u -> Objects.nonNull(u.getBomRowId()) && u.getBomRowId()>0 )
.map(BomNewPbomParentVO::getBomRowId).collect(Collectors.toList());
if(CollUtil.isNotEmpty(bomRowIds)) {
List<BomNewPbomParentFormalEntity> bomlist = SpringUtil.getBean(BomNewPbomParentFormalService.class).lambdaQuery()
.in(BomNewPbomParentFormalEntity::getRowId, bomRowIds).list();
parentEntityMap = ListCommonUtil.listToMap(Convert.toList(BomNewPbomParentVO.class,bomlist), BomNewPbomParentVO::getRowId);
}
} }
for (BomNewPbomParentFormalVO vo:
for (BomNewPbomParentVO vo:
parentChildList) { parentChildList) {
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getBomRowId())) { if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getParentRowId())) {
BomNewPbomParentFormalEntity pbomParentEntity = parentEntityMap.get(vo.getBomRowId()); BomNewPbomParentVO pbomParentEntity = parentEntityMap.get(vo.getBomRowId());
vo.setDeviseName(pbomParentEntity.getDeviseName()); vo.setDeviseName(pbomParentEntity.getDeviseName());
vo.setCurrentVersion(pbomParentEntity.getCurrentVersion()); vo.setCurrentVersion(pbomParentEntity.getCurrentVersion());
@ -249,12 +330,13 @@ public class ForwardReportService {
vo.setExpireEndTime(parentEntity.getReleaseTime()); vo.setExpireEndTime(parentEntity.getReleaseTime());
vo.setDeviseName(parentEntity.getDeviseName()); vo.setDeviseName(parentEntity.getDeviseName());
vo.setDeviseUserCode(parentEntity.getDeviseUserCode()); vo.setDeviseUserCode(parentEntity.getDeviseUserCode());
if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); // if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
} // vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
else { // }
vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); // else {
} // vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
// }
} }
} }

View File

@ -89,13 +89,17 @@ public class EBomFormalTreeTask extends RecursiveTask<List<BomNewEbomParentVO>>
detailVO.setCreatedBy(ebomParentEntity.getCreatedBy()); detailVO.setCreatedBy(ebomParentEntity.getCreatedBy());
}else { }else {
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getRowId, detailVO.getParentRowId()).one(); BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getRowId, detailVO.getParentRowId()).one();
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
detailVO.setDeviseName(parent.getDeviseName()); if(Objects.nonNull(parent)) {
detailVO.setDeptName(parent.getDeptName()); detailVO.setDeviseUserCode(parent.getDeviseUserCode());
detailVO.setDeptRowId(parent.getDeptRowId()); detailVO.setDeviseName(parent.getDeviseName());
detailVO.setStatus(parent.getStatus()); detailVO.setDeptName(parent.getDeptName());
detailVO.setEditStatus(parent.getEditStatus()); detailVO.setDeptRowId(parent.getDeptRowId());
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs()); detailVO.setStatus(parent.getStatus());
detailVO.setEditStatus(parent.getEditStatus());
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
}
} }
} }

View File

@ -116,13 +116,17 @@ public class PBomFormalTreeTask extends RecursiveTask<List<BomNewPbomParentVO>>
detailVO.setVirtualPackageIs(ebomParentEntity.getVirtualPackageIs()); detailVO.setVirtualPackageIs(ebomParentEntity.getVirtualPackageIs());
} else { } else {
BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, detailVO.getParentRowId()).one(); BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, detailVO.getParentRowId()).one();
detailVO.setDeviseUserCode(parent.getDeviseUserCode()); if(Objects.nonNull(parent)) {
detailVO.setDeviseName(parent.getDeviseName()); detailVO.setDeviseUserCode(parent.getDeviseUserCode());
detailVO.setDeptName(parent.getDeptName()); detailVO.setDeviseName(parent.getDeviseName());
detailVO.setDeptRowId(parent.getDeptRowId()); detailVO.setDeptName(parent.getDeptName());
detailVO.setStatus(parent.getStatus()); detailVO.setDeptRowId(parent.getDeptRowId());
detailVO.setEditStatus(parent.getEditStatus()); detailVO.setStatus(parent.getStatus());
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs()); detailVO.setEditStatus(parent.getEditStatus());
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
}
// if (MaterialshouldBomExistUtil.checkShouldBomExist(detailVO)) { // if (MaterialshouldBomExistUtil.checkShouldBomExist(detailVO)) {
// detailVO.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); // detailVO.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
// } else { // } else {