Mbom报表调整

This commit is contained in:
jing's 2024-03-12 17:46:52 +08:00
parent 70d65268d7
commit db934e1f4a
6 changed files with 88 additions and 130 deletions

View File

@ -3,6 +3,7 @@ package com.nflg.product.bomnew.api.user;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.base.core.exception.NflgBusinessException;
@ -46,7 +47,6 @@ public class BomReportApi extends BaseApi {
CompareReportService compareReportService; CompareReportService compareReportService;
@PostMapping("reverseReport") @PostMapping("reverseReport")
@ApiOperation("bom-反查") @ApiOperation("bom-反查")
public ResultVO<Page<ReverseReportVO>> reverseReport(@RequestBody ReverseReportQuery query) { public ResultVO<Page<ReverseReportVO>> reverseReport(@RequestBody ReverseReportQuery query) {
@ -62,7 +62,7 @@ public class BomReportApi extends BaseApi {
if (Objects.isNull(query.getBomType())) { if (Objects.isNull(query.getBomType())) {
return ResultVO.error(STATE.ParamErr, "请选择BOM类型"); return ResultVO.error(STATE.ParamErr, "请选择BOM类型");
} else { } else {
if ( !(query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0 if (!(query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0
|| query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0 || query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0
|| query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0 || query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0
|| query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0)) { || query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0)) {
@ -70,7 +70,6 @@ public class BomReportApi extends BaseApi {
} }
} }
if (Objects.isNull(query.getQueryType())) { if (Objects.isNull(query.getQueryType())) {
@ -92,13 +91,18 @@ public class BomReportApi extends BaseApi {
return ResultVO.error(STATE.ParamErr, "错误的版本策略"); return ResultVO.error(STATE.ParamErr, "错误的版本策略");
} }
} }
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
if (StrUtil.isEmpty(query.getFacCode())) {
return ResultVO.error(STATE.ParamErr, "请选择工厂");
}
}
return null; return null;
} }
@PostMapping("forwardReport") @PostMapping("forwardReport")
@ApiOperation("bom-正查") @ApiOperation("bom-正查")
public ResultVO<ReportBomVO> forwardReport(@RequestBody ReverseReportQuery query) { public ResultVO<ReportBomVO> forwardReport(@RequestBody ReverseReportQuery query) {
@ -125,7 +129,7 @@ public class BomReportApi extends BaseApi {
return resultBom2VO; return resultBom2VO;
} }
if(!ObjectUtil.equal(query.getLeft().getQueryType(),query.getRight().getQueryType())){ if (!ObjectUtil.equal(query.getLeft().getQueryType(), query.getRight().getQueryType())) {
return ResultVO.error(STATE.ParamErr, "查询方式不一致"); return ResultVO.error(STATE.ParamErr, "查询方式不一致");
} }
@ -136,21 +140,21 @@ public class BomReportApi extends BaseApi {
@PostMapping("compareExport") @PostMapping("compareExport")
@ApiOperation("bom-比对导出") @ApiOperation("bom-比对导出")
public void compareExport(@RequestBody CompareReportQuery query,HttpServletResponse response) throws IOException { public void compareExport(@RequestBody CompareReportQuery query, HttpServletResponse response) throws IOException {
ResultVO resultBom1VO = checkQueryParam(query.getLeft()); ResultVO resultBom1VO = checkQueryParam(query.getLeft());
ResultVO resultBom2VO = checkQueryParam(query.getRight()); ResultVO resultBom2VO = checkQueryParam(query.getRight());
if (resultBom1VO != null) { if (resultBom1VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg()); new NflgBusinessException(STATE.Error, resultBom1VO.getMsg());
} }
if (resultBom2VO != null) { if (resultBom2VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg()); new NflgBusinessException(STATE.Error, resultBom1VO.getMsg());
} }
EecExcelUtil.setResponseExcelHeader(response, "BOM比对"); EecExcelUtil.setResponseExcelHeader(response, "BOM比对");
compareReportService.compareBomExport( response.getOutputStream(),query); compareReportService.compareBomExport(response.getOutputStream(), query);
} }
@ -160,22 +164,18 @@ public class BomReportApi extends BaseApi {
ResultVO resultVO = checkQueryParam(query); ResultVO resultVO = checkQueryParam(query);
if (resultVO != null) { if (resultVO != null) {
VUtils.isTure( true ).throwMessage(resultVO.getMsg()); VUtils.isTure(true).throwMessage(resultVO.getMsg());
} }
EecExcelUtil.setResponseExcelHeader(response, "Bom查看列表"); EecExcelUtil.setResponseExcelHeader(response, "Bom查看列表");
forwardReportService.bomExport(query,response.getOutputStream()); forwardReportService.bomExport(response.getOutputStream(), query);
} }
@PostMapping("forwardChildReport") @PostMapping("forwardChildReport")
@ApiOperation("bom-正查子级bom信息") @ApiOperation("bom-正查子级bom信息")
public ResultVO< List<ForwardReportVO>> forwardChildReport(@RequestBody ChildBomReportQuery query) { public ResultVO<List<ForwardReportVO>> forwardChildReport(@RequestBody ChildBomReportQuery query) {
if (Objects.isNull(query.getBomType())) { if (Objects.isNull(query.getBomType())) {
return ResultVO.error(STATE.ParamErr, "请选择BOM类型"); return ResultVO.error(STATE.ParamErr, "请选择BOM类型");
@ -193,7 +193,6 @@ public class BomReportApi extends BaseApi {
} }
return ResultVO.success(forwardReportService.chilidBom(query)); return ResultVO.success(forwardReportService.chilidBom(query));
} }
@ -210,9 +209,4 @@ public class BomReportApi extends BaseApi {
} }
} }

View File

@ -371,12 +371,12 @@ private void checkBackStatus( List<BomNewMbomBackMaterialEntity> backList){
} }
} }
} }

View File

@ -321,7 +321,7 @@ public class CompareReportService {
continue; continue;
} }
ForwardReportVO fromParent = leftBomRowIdMap.get(from.getParentRowId()).get(0); ForwardReportVO fromParent = leftBomRowIdMap.get(from.getParentRowId()).get(0);
ForwardReportVO toParent = rightBomRowIdMap.get(from.getParentRowId()).get(0); ForwardReportVO toParent = rightBomRowIdMap.get(to.getParentRowId()).get(0);
if (!compareFunc.apply(fromParent).equals(compareFunc.apply(toParent))) { if (!compareFunc.apply(fromParent).equals(compareFunc.apply(toParent))) {
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue()); compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
continue; continue;

View File

@ -33,7 +33,6 @@ public class ForwardReportService {
public ReportBomVersionVO factoryVersion(ReverseReportQuery query) { public ReportBomVersionVO factoryVersion(ReverseReportQuery query) {
//原始BOM //原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
OriginalBomForwardReport originalBomForwardReport = new OriginalBomForwardReport(query); OriginalBomForwardReport originalBomForwardReport = new OriginalBomForwardReport(query);
@ -44,7 +43,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
EBomForwardReport eBomForwardReport = new EBomForwardReport(query); EBomForwardReport eBomForwardReport = new EBomForwardReport(query);
return eBomForwardReport.bomVersion(); return eBomForwardReport.bomVersion();
} }
//PBOM //PBOM
@ -55,32 +53,23 @@ public class ForwardReportService {
//MBOM //MBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
MBomForwardReport mBomForwardReport=new MBomForwardReport(query); MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
return mBomForwardReport.bomVersion(); return mBomForwardReport.bomVersion();
} }
VUtils.isTure(true).throwMessage("错误的BOM类型"); VUtils.isTure(true).throwMessage("错误的BOM类型");
return null; return null;
} }
public List<ForwardReportVO> chilidBom(ChildBomReportQuery query) { public List<ForwardReportVO> chilidBom(ChildBomReportQuery query) {
//原始BOM //原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
return chilidOriginalBomList(query); return chilidOriginalBomList(query);
} }
//EBOM //EBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
return chilidEBomList(query); return chilidEBomList(query);
} }
//PBOM //PBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
return chilidPBomList(query); return chilidPBomList(query);
@ -89,7 +78,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
return chilidMBomList(query); return chilidMBomList(query);
} }
VUtils.isTure(true).throwMessage("错误的BOM类型"); VUtils.isTure(true).throwMessage("错误的BOM类型");
return null; return null;
} }
@ -105,7 +93,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
return queryEBom(query); return queryEBom(query);
} }
//PBOM //PBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
return queryPBom(query); return queryPBom(query);
@ -114,19 +101,16 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
return queryMBom(query); return queryMBom(query);
} }
VUtils.isTure(true).throwMessage("错误的BOM类型"); VUtils.isTure(true).throwMessage("错误的BOM类型");
return null; return null;
} }
public void bomExport(ReverseReportQuery query,OutputStream outputStream) throws IOException { public void bomExport(OutputStream outputStream,ReverseReportQuery query) throws IOException {
//原始BOM //原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query); OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query);
ReportBomVO reportBomVO = originalBomForwardReport.genReport(); ReportBomVO reportBomVO = originalBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream); exportExcel(reportBomVO.getChildNodes(),outputStream);
return; return;
} }
@ -135,7 +119,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
EBomForwardReport eBomForwardReport = new EBomForwardReport(query); EBomForwardReport eBomForwardReport = new EBomForwardReport(query);
ReportBomVO reportBomVO = eBomForwardReport.genReport(); ReportBomVO reportBomVO = eBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream); exportExcel(reportBomVO.getChildNodes(),outputStream);
return; return;
} }
@ -144,17 +127,13 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
PBomForwardReport pBomForwardReport=new PBomForwardReport(query); PBomForwardReport pBomForwardReport=new PBomForwardReport(query);
ReportBomVO reportBomVO = pBomForwardReport.genReport(); ReportBomVO reportBomVO = pBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream); exportExcel(reportBomVO.getChildNodes(),outputStream);
return; return;
} }
//MBOM //MBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) { if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
MBomForwardReport mBomForwardReport=new MBomForwardReport(query); MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
ReportBomVO reportBomVO = mBomForwardReport.genReport(); ReportBomVO reportBomVO = mBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream); exportExcel(reportBomVO.getChildNodes(),outputStream);
return; return;
} }
@ -165,16 +144,6 @@ public class ForwardReportService {
} }
public void exportExcel( List<ForwardReportVO> list,OutputStream outputStream) throws IOException { public void exportExcel( List<ForwardReportVO> list,OutputStream outputStream) throws IOException {
// final ListSheet<ForwardReportExcelVO> listSheet = new ListSheet<ForwardReportExcelVO>() {
// Long n = 0L;
// Long pages = 1L;
//
// @Override
// protected List<ForwardReportExcelVO> more() {
// return n++ < pages ? Convert.convert(new TypeReference<List<ForwardReportExcelVO>>() {
// }, list) : null;
// }
// };
List<ForwardReportExcelVO> exportList= Convert.convert( new TypeReference<List<ForwardReportExcelVO>>() { List<ForwardReportExcelVO> exportList= Convert.convert( new TypeReference<List<ForwardReportExcelVO>>() {
}, list); }, list);
ListSheet<ForwardReportExcelVO> listSheet=new ListSheet<>(exportList); ListSheet<ForwardReportExcelVO> listSheet=new ListSheet<>(exportList);
@ -228,7 +197,6 @@ public class ForwardReportService {
List<ForwardReportVO> childBomLit = Convert.convert( List<ForwardReportVO> childBomLit = Convert.convert(
new TypeReference<List<ForwardReportVO>>() { new TypeReference<List<ForwardReportVO>>() {
}, list); }, list);
return childBomLit; return childBomLit;
} }
@ -246,7 +214,6 @@ public class ForwardReportService {
ReportBomVO queryOriginalBom(ReverseReportQuery query) { ReportBomVO queryOriginalBom(ReverseReportQuery query) {
OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query); OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query);
return originalBomForwardReport.genReport(); return originalBomForwardReport.genReport();
} }
@ -269,9 +236,4 @@ public class ForwardReportService {
} }
} }

View File

@ -107,6 +107,13 @@ public abstract class BaseForwardReport {
} }
/**
* 可参考 https://www.doc88.com/p-9002887925771.html?s=rel&id=7
* 二叉树的前序遍历
* @param bomList
* @param parentRowId
* @return
*/
protected List<ForwardReportVO> listToList(List<ForwardReportVO> bomList, Long parentRowId) { protected List<ForwardReportVO> listToList(List<ForwardReportVO> bomList, Long parentRowId) {
Map<Long, List<ForwardReportVO>> listMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId)); Map<Long, List<ForwardReportVO>> listMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId));

View File

@ -1,11 +1,9 @@
package com.nflg.product.bomnew.service.domain.MBom; package com.nflg.product.bomnew.service.domain.MBom;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
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.map.MapUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -13,15 +11,15 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.MaterialMainConstant; import com.nflg.product.bomnew.constant.MaterialMainConstant;
import com.nflg.product.bomnew.constant.ReportConstant; import com.nflg.product.bomnew.constant.ReportConstant;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewMbomDetailEntity; import com.nflg.product.bomnew.pojo.entity.BomNewMbomDetailEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentFormalEntity;
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.BomNewMbomMiddleVO;
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
import com.nflg.product.bomnew.pojo.vo.ReportBomVersionVO;
import com.nflg.product.bomnew.service.BomNewMbomDetailService; import com.nflg.product.bomnew.service.BomNewMbomDetailService;
import com.nflg.product.bomnew.service.BomNewMbomParentService; import com.nflg.product.bomnew.service.BomNewMbomParentService;
import com.nflg.product.bomnew.service.BomNewPbomParentFormalService;
import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.service.domain.BaseForwardReport; import com.nflg.product.bomnew.service.domain.BaseForwardReport;
import nflg.product.common.constant.STATE; import nflg.product.common.constant.STATE;
@ -41,14 +39,13 @@ public class MBomForwardReport extends BaseForwardReport {
super(query); super(query);
init(); init();
} }
AtomicInteger orderNum = new AtomicInteger(); AtomicInteger orderNum = new AtomicInteger();
private List<BomNewMbomParentEntity> rootEntity; // private List<BomNewMbomParentEntity> rootEntity;
// private List<BomNewMbomDetailEntity> detailEntity;
List<BomNewMbomMiddleVO> parentList;
private List<BomNewMbomDetailEntity> detailEntity;
private BomNewMbomParentEntity rootNode;
void init() { void init() {
if (query.getMaterialNo().startsWith(MaterialMainConstant.MaterialNo_31)) { if (query.getMaterialNo().startsWith(MaterialMainConstant.MaterialNo_31)) {
@ -60,15 +57,19 @@ public class MBomForwardReport extends BaseForwardReport {
if (StrUtil.isNotEmpty(query.getStartDate()) && StrUtil.isNotEmpty(query.getEndDate())) { if (StrUtil.isNotEmpty(query.getStartDate()) && StrUtil.isNotEmpty(query.getEndDate())) {
queryParentWrapper.lambda().between(BomNewMbomParentEntity::getCreatedTime, query.getStartDate(), query.getEndDate()); queryParentWrapper.lambda().between(BomNewMbomParentEntity::getCreatedTime, query.getStartDate(), query.getEndDate());
} }
if (CollUtil.isEmpty(rootEntity)) { if (CollUtil.isEmpty(parentList)) {
rootEntity = SpringUtil.getBean(BomNewMbomParentService.class).list(queryParentWrapper); List<BomNewMbomParentEntity> rootEntity = SpringUtil.getBean(BomNewMbomParentService.class).list(queryParentWrapper);
parentList=Convert.convert(new TypeReference<List<BomNewMbomMiddleVO>>() {
},rootEntity);
parentList.forEach(item->{
item.setBomRowId(item.getRowId());
item.setBomExist(1);
});
} }
} else { } else {
QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getMaterialNo, query.getMaterialNo()); queryWrapper.lambda().eq(BomNewMbomDetailEntity::getMaterialNo, query.getMaterialNo());
if (StrUtil.isNotEmpty(query.getFacCode())) { if (StrUtil.isNotEmpty(query.getFacCode())) {
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getFacCode, query.getFacCode()); queryWrapper.lambda().eq(BomNewMbomDetailEntity::getFacCode, query.getFacCode());
@ -76,8 +77,17 @@ public class MBomForwardReport extends BaseForwardReport {
if (StrUtil.isNotEmpty(query.getStartDate()) && StrUtil.isNotEmpty(query.getEndDate())) { if (StrUtil.isNotEmpty(query.getStartDate()) && StrUtil.isNotEmpty(query.getEndDate())) {
queryWrapper.lambda().between(BomNewMbomDetailEntity::getCreatedTime, query.getStartDate(), query.getEndDate()); queryWrapper.lambda().between(BomNewMbomDetailEntity::getCreatedTime, query.getStartDate(), query.getEndDate());
} }
if (CollUtil.isEmpty(detailEntity)) { if (CollUtil.isEmpty(parentList)) {
detailEntity = SpringUtil.getBean(BomNewMbomDetailService.class).list(); List<BomNewMbomDetailEntity> detailEntity = SpringUtil.getBean(BomNewMbomDetailService.class).list(queryWrapper);
parentList=Convert.convert(new TypeReference<List<BomNewMbomMiddleVO>>() {
},detailEntity);
for (BomNewMbomMiddleVO vo:
parentList ) {
if(vo.getParentRowId().longValue()==0){
vo.setParentRowId(vo.getBomRowId());
}
}
} }
@ -86,40 +96,33 @@ public class MBomForwardReport extends BaseForwardReport {
} }
QueryWrapper<BomNewMbomDetailEntity> buildQuery() { // QueryWrapper<BomNewMbomDetailEntity> buildQuery() {
// QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>(); // if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) { // throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo())); // }
//
} // if (CollUtil.isNotEmpty(rootEntity)) {
// List<Long> bomRowId = rootEntity.stream().map(BomNewMbomParentEntity::getRowId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(rootEntity)) { // queryWrapper.lambda().in(BomNewMbomDetailEntity::getBomRowId, bomRowId);
List<Long> bomRowId = rootEntity.stream().map(BomNewMbomParentEntity::getRowId).collect(Collectors.toList()); // queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0);
queryWrapper.lambda().in(BomNewMbomDetailEntity::getBomRowId, bomRowId); //
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0); // } else if (CollUtil.isNotEmpty(detailEntity)) {
// List<Long> bomRowId = detailEntity.stream().map(BomNewMbomDetailEntity::getRowId).collect(Collectors.toList());
} else if (CollUtil.isNotEmpty(detailEntity)) { // queryWrapper.lambda().in(BomNewMbomDetailEntity::getParentRowId, bomRowId);
List<Long> bomRowId = detailEntity.stream().map(BomNewMbomDetailEntity::getRowId).collect(Collectors.toList()); // }
queryWrapper.lambda().in(BomNewMbomDetailEntity::getParentRowId, bomRowId); // return queryWrapper;
// }
}
return queryWrapper;
}
public ReportBomVersionVO bomVersion() { public ReportBomVersionVO bomVersion() {
String desc = null; String desc = null;
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) { if (CollUtil.isEmpty(parentList) ) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo())); throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
} }
if (CollUtil.isNotEmpty(rootEntity)) {
desc = rootEntity.get(0).getMaterialDesc();
} else if (CollUtil.isNotEmpty(detailEntity)) { desc = parentList.get(0).getMaterialDesc();
desc = detailEntity.get(0).getMaterialDesc();
}
ReportBomVersionVO reportBomVersionVO = new ReportBomVersionVO(); ReportBomVersionVO reportBomVersionVO = new ReportBomVersionVO();
reportBomVersionVO.setMaterialDesc(desc); reportBomVersionVO.setMaterialDesc(desc);
@ -130,15 +133,13 @@ public class MBomForwardReport extends BaseForwardReport {
ForwardReportVO getParent() { ForwardReportVO getParent() {
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) { if (CollUtil.isEmpty(parentList) ) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo())); throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
} }
ForwardReportVO forwardReportVO = null; ForwardReportVO forwardReportVO = null;
if (CollUtil.isNotEmpty(rootEntity)) {
forwardReportVO = Convert.convert(ForwardReportVO.class, rootEntity.get(0)); forwardReportVO = Convert.convert(ForwardReportVO.class, parentList.get(0) );
} else if (CollUtil.isNotEmpty(detailEntity)) {
forwardReportVO = Convert.convert(ForwardReportVO.class, detailEntity.get(0));
}
return forwardReportVO; return forwardReportVO;
} }
@ -147,7 +148,6 @@ public class MBomForwardReport extends BaseForwardReport {
for (BomNewMbomMiddleVO item: for (BomNewMbomMiddleVO item:
childList) { childList) {
Long bomRowId=item.getBomRowId(); Long bomRowId=item.getBomRowId();
item.setRemark(item.getBomMaterialNo()); item.setRemark(item.getBomMaterialNo());
item.setBomRowId(item.getBomVersionRowId()); item.setBomRowId(item.getBomVersionRowId());
@ -159,7 +159,6 @@ public class MBomForwardReport extends BaseForwardReport {
} }
} }
List<ForwardReportVO> nodeList = Convert.convert(new TypeReference<List<ForwardReportVO>>() { List<ForwardReportVO> nodeList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
}, childList); }, childList);
@ -199,20 +198,16 @@ public class MBomForwardReport extends BaseForwardReport {
*/ */
Map<Long, List<ForwardReportVO>> queryReport(boolean isMore) { Map<Long, List<ForwardReportVO>> queryReport(boolean isMore) {
Map<Long, List<ForwardReportVO>> listMap = new HashMap<>(); Map<Long, List<ForwardReportVO>> listMap = new HashMap<>();
//根数据表搜索到 //
if (CollUtil.isNotEmpty(rootEntity)) { if (CollUtil.isNotEmpty(parentList)) {
for (BomNewMbomParentEntity item : rootEntity) { for (BomNewMbomMiddleVO item : parentList) {
Long rowId = 0l; Long rowId = item.getRowId();
listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getRowId()));
}
} else if (CollUtil.isNotEmpty(detailEntity)) { // detail表搜索 if(ObjectUtil.equal(item.getRowId(),item.getBomRowId())){
for (BomNewMbomDetailEntity item : detailEntity) { rowId = 0l;
Long rowId = item.getRowId(); }
listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getBomRowId())); listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getBomRowId()));
} }
} }
return listMap; return listMap;