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.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.exception.NflgBusinessException;
@ -46,7 +47,6 @@ public class BomReportApi extends BaseApi {
CompareReportService compareReportService;
@PostMapping("reverseReport")
@ApiOperation("bom-反查")
public ResultVO<Page<ReverseReportVO>> reverseReport(@RequestBody ReverseReportQuery query) {
@ -62,7 +62,7 @@ public class BomReportApi extends BaseApi {
if (Objects.isNull(query.getBomType())) {
return ResultVO.error(STATE.ParamErr, "请选择BOM类型");
} 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.PBOM.getValue()) == 0
|| query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0)) {
@ -70,7 +70,6 @@ public class BomReportApi extends BaseApi {
}
}
if (Objects.isNull(query.getQueryType())) {
@ -92,13 +91,18 @@ public class BomReportApi extends BaseApi {
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;
}
@PostMapping("forwardReport")
@ApiOperation("bom-正查")
public ResultVO<ReportBomVO> forwardReport(@RequestBody ReverseReportQuery query) {
@ -125,7 +129,7 @@ public class BomReportApi extends BaseApi {
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, "查询方式不一致");
}
@ -136,21 +140,21 @@ public class BomReportApi extends BaseApi {
@PostMapping("compareExport")
@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 resultBom2VO = checkQueryParam(query.getRight());
if (resultBom1VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg());
new NflgBusinessException(STATE.Error, resultBom1VO.getMsg());
}
if (resultBom2VO != null) {
new NflgBusinessException(STATE.Error,resultBom1VO.getMsg());
new NflgBusinessException(STATE.Error, resultBom1VO.getMsg());
}
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);
if (resultVO != null) {
VUtils.isTure( true ).throwMessage(resultVO.getMsg());
VUtils.isTure(true).throwMessage(resultVO.getMsg());
}
EecExcelUtil.setResponseExcelHeader(response, "Bom查看列表");
forwardReportService.bomExport(query,response.getOutputStream());
forwardReportService.bomExport(response.getOutputStream(), query);
}
@PostMapping("forwardChildReport")
@ApiOperation("bom-正查子级bom信息")
public ResultVO< List<ForwardReportVO>> forwardChildReport(@RequestBody ChildBomReportQuery query) {
public ResultVO<List<ForwardReportVO>> forwardChildReport(@RequestBody ChildBomReportQuery query) {
if (Objects.isNull(query.getBomType())) {
return ResultVO.error(STATE.ParamErr, "请选择BOM类型");
@ -193,7 +193,6 @@ public class BomReportApi extends BaseApi {
}
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;
}
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))) {
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
continue;

View File

@ -33,7 +33,6 @@ public class ForwardReportService {
public ReportBomVersionVO factoryVersion(ReverseReportQuery query) {
//原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
OriginalBomForwardReport originalBomForwardReport = new OriginalBomForwardReport(query);
@ -44,7 +43,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
EBomForwardReport eBomForwardReport = new EBomForwardReport(query);
return eBomForwardReport.bomVersion();
}
//PBOM
@ -55,32 +53,23 @@ public class ForwardReportService {
//MBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
return mBomForwardReport.bomVersion();
}
VUtils.isTure(true).throwMessage("错误的BOM类型");
return null;
}
public List<ForwardReportVO> chilidBom(ChildBomReportQuery query) {
//原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
return chilidOriginalBomList(query);
}
//EBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
return chilidEBomList(query);
}
//PBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
return chilidPBomList(query);
@ -89,7 +78,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
return chilidMBomList(query);
}
VUtils.isTure(true).throwMessage("错误的BOM类型");
return null;
}
@ -105,7 +93,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
return queryEBom(query);
}
//PBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
return queryPBom(query);
@ -114,19 +101,16 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
return queryMBom(query);
}
VUtils.isTure(true).throwMessage("错误的BOM类型");
return null;
}
public void bomExport(ReverseReportQuery query,OutputStream outputStream) throws IOException {
public void bomExport(OutputStream outputStream,ReverseReportQuery query) throws IOException {
//原始BOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query);
ReportBomVO reportBomVO = originalBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream);
return;
}
@ -135,7 +119,6 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
EBomForwardReport eBomForwardReport = new EBomForwardReport(query);
ReportBomVO reportBomVO = eBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream);
return;
}
@ -144,17 +127,13 @@ public class ForwardReportService {
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
PBomForwardReport pBomForwardReport=new PBomForwardReport(query);
ReportBomVO reportBomVO = pBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream);
return;
}
//MBOM
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
ReportBomVO reportBomVO = mBomForwardReport.genReport();
exportExcel(reportBomVO.getChildNodes(),outputStream);
return;
}
@ -165,16 +144,6 @@ public class ForwardReportService {
}
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);
ListSheet<ForwardReportExcelVO> listSheet=new ListSheet<>(exportList);
@ -228,7 +197,6 @@ public class ForwardReportService {
List<ForwardReportVO> childBomLit = Convert.convert(
new TypeReference<List<ForwardReportVO>>() {
}, list);
return childBomLit;
}
@ -246,7 +214,6 @@ public class ForwardReportService {
ReportBomVO queryOriginalBom(ReverseReportQuery query) {
OriginalBomForwardReport originalBomForwardReport=new OriginalBomForwardReport(query);
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) {
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;
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.lang.TypeReference;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
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.MaterialMainConstant;
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.BomNewMbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentFormalEntity;
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.BomNewMbomParentService;
import com.nflg.product.bomnew.service.BomNewPbomParentFormalService;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.service.domain.BaseForwardReport;
import nflg.product.common.constant.STATE;
@ -41,14 +39,13 @@ public class MBomForwardReport extends BaseForwardReport {
super(query);
init();
}
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() {
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())) {
queryParentWrapper.lambda().between(BomNewMbomParentEntity::getCreatedTime, query.getStartDate(), query.getEndDate());
}
if (CollUtil.isEmpty(rootEntity)) {
rootEntity = SpringUtil.getBean(BomNewMbomParentService.class).list(queryParentWrapper);
if (CollUtil.isEmpty(parentList)) {
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 {
QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BomNewMbomDetailEntity::getMaterialNo, query.getMaterialNo());
if (StrUtil.isNotEmpty(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())) {
queryWrapper.lambda().between(BomNewMbomDetailEntity::getCreatedTime, query.getStartDate(), query.getEndDate());
}
if (CollUtil.isEmpty(detailEntity)) {
detailEntity = SpringUtil.getBean(BomNewMbomDetailService.class).list();
if (CollUtil.isEmpty(parentList)) {
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> queryWrapper = new QueryWrapper<>();
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
}
if (CollUtil.isNotEmpty(rootEntity)) {
List<Long> bomRowId = rootEntity.stream().map(BomNewMbomParentEntity::getRowId).collect(Collectors.toList());
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());
queryWrapper.lambda().in(BomNewMbomDetailEntity::getParentRowId, bomRowId);
}
return queryWrapper;
}
// QueryWrapper<BomNewMbomDetailEntity> buildQuery() {
// QueryWrapper<BomNewMbomDetailEntity> queryWrapper = new QueryWrapper<>();
// if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
// throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
// }
//
// if (CollUtil.isNotEmpty(rootEntity)) {
// List<Long> bomRowId = rootEntity.stream().map(BomNewMbomParentEntity::getRowId).collect(Collectors.toList());
// 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());
// queryWrapper.lambda().in(BomNewMbomDetailEntity::getParentRowId, bomRowId);
// }
// return queryWrapper;
// }
public ReportBomVersionVO bomVersion() {
String desc = null;
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
if (CollUtil.isEmpty(parentList) ) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
}
if (CollUtil.isNotEmpty(rootEntity)) {
desc = rootEntity.get(0).getMaterialDesc();
} else if (CollUtil.isNotEmpty(detailEntity)) {
desc = detailEntity.get(0).getMaterialDesc();
desc = parentList.get(0).getMaterialDesc();
}
ReportBomVersionVO reportBomVersionVO = new ReportBomVersionVO();
reportBomVersionVO.setMaterialDesc(desc);
@ -130,15 +133,13 @@ public class MBomForwardReport extends BaseForwardReport {
ForwardReportVO getParent() {
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
if (CollUtil.isEmpty(parentList) ) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
}
ForwardReportVO forwardReportVO = null;
if (CollUtil.isNotEmpty(rootEntity)) {
forwardReportVO = Convert.convert(ForwardReportVO.class, rootEntity.get(0));
} else if (CollUtil.isNotEmpty(detailEntity)) {
forwardReportVO = Convert.convert(ForwardReportVO.class, detailEntity.get(0));
}
forwardReportVO = Convert.convert(ForwardReportVO.class, parentList.get(0) );
return forwardReportVO;
}
@ -147,7 +148,6 @@ public class MBomForwardReport extends BaseForwardReport {
for (BomNewMbomMiddleVO item:
childList) {
Long bomRowId=item.getBomRowId();
item.setRemark(item.getBomMaterialNo());
item.setBomRowId(item.getBomVersionRowId());
@ -159,7 +159,6 @@ public class MBomForwardReport extends BaseForwardReport {
}
}
List<ForwardReportVO> nodeList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
}, childList);
@ -199,20 +198,16 @@ public class MBomForwardReport extends BaseForwardReport {
*/
Map<Long, List<ForwardReportVO>> queryReport(boolean isMore) {
Map<Long, List<ForwardReportVO>> listMap = new HashMap<>();
//根数据表搜索到
if (CollUtil.isNotEmpty(rootEntity)) {
for (BomNewMbomParentEntity item : rootEntity) {
Long rowId = 0l;
listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getRowId()));
}
//
if (CollUtil.isNotEmpty(parentList)) {
for (BomNewMbomMiddleVO item : parentList) {
Long rowId = item.getRowId();
} else if (CollUtil.isNotEmpty(detailEntity)) { // detail表搜索
for (BomNewMbomDetailEntity item : detailEntity) {
Long rowId = item.getRowId();
if(ObjectUtil.equal(item.getRowId(),item.getBomRowId())){
rowId = 0l;
}
listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getBomRowId()));
}
}
return listMap;