ebom pbom 报表单层子级
This commit is contained in:
parent
02ed618269
commit
5ba378b684
|
|
@ -205,6 +205,11 @@ public class BomReportApi extends BaseApi {
|
|||
return ResultVO.error(STATE.ParamErr, "bomRowId不能空");
|
||||
}
|
||||
|
||||
if (Objects.isNull(query.getVersionStrategy())) {
|
||||
return ResultVO.error(STATE.ParamErr, "版本策略不能空");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ResultVO.success(forwardReportService.chilidBom(query));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,15 @@ public class ChildBomReportQuery {
|
|||
@NotNull(message = "BOM类型不能为空")
|
||||
private Integer bomType;
|
||||
|
||||
@ApiModelProperty("版本策略 0-最新版 1-全部版本 2-指定版本")
|
||||
private Integer versionStrategy;
|
||||
|
||||
|
||||
@ApiModelProperty("子级Bom")
|
||||
@NotNull(message = "bomRowId不能为空")
|
||||
private Long bomRowId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package com.nflg.product.bomnew.service;
|
|||
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.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.ReportConstant;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentFormalEntity;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.*;
|
||||
import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
|
|
@ -28,6 +28,8 @@ import org.ttzero.excel.entity.ListSheet;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
|
@ -168,8 +170,23 @@ public class ForwardReportService {
|
|||
|
||||
|
||||
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)){
|
||||
return new ArrayList<>();
|
||||
|
|
@ -177,32 +194,58 @@ public class ForwardReportService {
|
|||
|
||||
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, BomNewEbomParentFormalEntity> parentEntityMap=null;
|
||||
if(CollUtil.isNotEmpty(bomRowIds)) {
|
||||
List<BomNewEbomParentFormalEntity> bomlist = SpringUtil.getBean(BomNewEbomParentFormalService.class).lambdaQuery().in(BomNewEbomParentFormalEntity::getRowId, bomRowIds).list();
|
||||
Map<Long, BomNewEbomParentVO > parentEntityMap=null;
|
||||
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
|
||||
List<String> materialNos = parentChildList.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo()) )
|
||||
.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) {
|
||||
|
||||
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getBomRowId())) {
|
||||
BomNewEbomParentFormalEntity ebomParentEntity = parentEntityMap.get(vo.getBomRowId());
|
||||
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getParentRowId())) {
|
||||
BomNewEbomParentVO ebomParentEntity = parentEntityMap.get(vo.getParentRowId());
|
||||
vo.setDeviseName(ebomParentEntity.getDeviseName());
|
||||
vo.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
|
||||
vo.setCurrentVersion(ebomParentEntity.getCurrentVersion());
|
||||
vo.setExpireEndTime(ebomParentEntity.getConvertToEbomTime());
|
||||
vo.setBomRowId(ebomParentEntity.getRowId());
|
||||
}else{
|
||||
vo.setDeviseName(parentEntity.getDeviseName());
|
||||
vo.setDeviseUserCode(parentEntity.getDeviseUserCode());
|
||||
if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
|
||||
vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
|
||||
}
|
||||
else {
|
||||
vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||
}
|
||||
// if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
|
||||
// vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
|
||||
// }
|
||||
// else {
|
||||
// vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,33 +257,71 @@ public class ForwardReportService {
|
|||
|
||||
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)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
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;
|
||||
if(CollUtil.isNotEmpty(bomRowIds)) {
|
||||
List<BomNewPbomParentFormalEntity > bomlist = SpringUtil.getBean(BomNewPbomParentFormalService.class ).lambdaQuery().in(BomNewPbomParentFormalEntity::getRowId, bomRowIds).list();
|
||||
Map<Long, BomNewPbomParentVO > parentEntityMap=null;
|
||||
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
|
||||
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) {
|
||||
|
||||
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getBomRowId())) {
|
||||
BomNewPbomParentFormalEntity pbomParentEntity = parentEntityMap.get(vo.getBomRowId());
|
||||
if (Objects.nonNull(parentEntityMap) && parentEntityMap.containsKey(vo.getParentRowId())) {
|
||||
BomNewPbomParentVO pbomParentEntity = parentEntityMap.get(vo.getBomRowId());
|
||||
|
||||
vo.setDeviseName(pbomParentEntity.getDeviseName());
|
||||
vo.setCurrentVersion(pbomParentEntity.getCurrentVersion());
|
||||
|
|
@ -249,12 +330,13 @@ public class ForwardReportService {
|
|||
vo.setExpireEndTime(parentEntity.getReleaseTime());
|
||||
vo.setDeviseName(parentEntity.getDeviseName());
|
||||
vo.setDeviseUserCode(parentEntity.getDeviseUserCode());
|
||||
if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
|
||||
vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
|
||||
}
|
||||
else {
|
||||
vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||
}
|
||||
|
||||
// if (MaterialshouldBomExistUtil.checkShouldBomExist(vo)) {
|
||||
// vo.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
|
||||
// }
|
||||
// else {
|
||||
// vo.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,13 +89,17 @@ public class EBomFormalTreeTask extends RecursiveTask<List<BomNewEbomParentVO>>
|
|||
detailVO.setCreatedBy(ebomParentEntity.getCreatedBy());
|
||||
}else {
|
||||
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getRowId, detailVO.getParentRowId()).one();
|
||||
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
|
||||
detailVO.setDeviseName(parent.getDeviseName());
|
||||
detailVO.setDeptName(parent.getDeptName());
|
||||
detailVO.setDeptRowId(parent.getDeptRowId());
|
||||
detailVO.setStatus(parent.getStatus());
|
||||
detailVO.setEditStatus(parent.getEditStatus());
|
||||
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
|
||||
|
||||
if(Objects.nonNull(parent)) {
|
||||
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
|
||||
detailVO.setDeviseName(parent.getDeviseName());
|
||||
detailVO.setDeptName(parent.getDeptName());
|
||||
detailVO.setDeptRowId(parent.getDeptRowId());
|
||||
detailVO.setStatus(parent.getStatus());
|
||||
detailVO.setEditStatus(parent.getEditStatus());
|
||||
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,13 +116,17 @@ public class PBomFormalTreeTask extends RecursiveTask<List<BomNewPbomParentVO>>
|
|||
detailVO.setVirtualPackageIs(ebomParentEntity.getVirtualPackageIs());
|
||||
} else {
|
||||
BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, detailVO.getParentRowId()).one();
|
||||
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
|
||||
detailVO.setDeviseName(parent.getDeviseName());
|
||||
detailVO.setDeptName(parent.getDeptName());
|
||||
detailVO.setDeptRowId(parent.getDeptRowId());
|
||||
detailVO.setStatus(parent.getStatus());
|
||||
detailVO.setEditStatus(parent.getEditStatus());
|
||||
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
|
||||
if(Objects.nonNull(parent)) {
|
||||
detailVO.setDeviseUserCode(parent.getDeviseUserCode());
|
||||
detailVO.setDeviseName(parent.getDeviseName());
|
||||
detailVO.setDeptName(parent.getDeptName());
|
||||
detailVO.setDeptRowId(parent.getDeptRowId());
|
||||
detailVO.setStatus(parent.getStatus());
|
||||
detailVO.setEditStatus(parent.getEditStatus());
|
||||
detailVO.setVirtualPackageIs(parent.getVirtualPackageIs());
|
||||
}
|
||||
|
||||
|
||||
// if (MaterialshouldBomExistUtil.checkShouldBomExist(detailVO)) {
|
||||
// detailVO.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
|
||||
// } else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue