单层bom下级
This commit is contained in:
parent
17bcd18396
commit
43ddc86057
|
|
@ -4,6 +4,7 @@ package com.nflg.product.bomnew.api.user;
|
||||||
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.bomnew.constant.ReportConstant;
|
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||||
|
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.*;
|
||||||
import com.nflg.product.bomnew.service.ForwardReportService;
|
import com.nflg.product.bomnew.service.ForwardReportService;
|
||||||
|
|
@ -92,6 +93,32 @@ public class BomReportApi extends BaseApi {
|
||||||
return ResultVO.success(forwardReportService.factoryBomType(query));
|
return ResultVO.success(forwardReportService.factoryBomType(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("forwardChildReport")
|
||||||
|
@ApiOperation("bom-子级bom信息")
|
||||||
|
public ResultVO< List<ForwardReportVO>> forwardChildReport(@RequestBody ChildBomReportQuery query) {
|
||||||
|
|
||||||
|
if (Objects.isNull(query.getBomType())) {
|
||||||
|
return ResultVO.error(STATE.ParamErr, "请选择BOM类型");
|
||||||
|
} else {
|
||||||
|
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) {
|
||||||
|
return ResultVO.error(STATE.ParamErr, "错误的BOM类型");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (Objects.isNull(query.getBomRowId())) {
|
||||||
|
return ResultVO.error(STATE.ParamErr, "bomRowId不能空");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ResultVO.success(forwardReportService.chilidBom(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("forwardVersion")
|
@PostMapping("forwardVersion")
|
||||||
@ApiOperation("bom-物料版本及描述")
|
@ApiOperation("bom-物料版本及描述")
|
||||||
public ResultVO<ReportBomVersionVO> forwardVersion(@RequestBody ReverseReportQuery query) {
|
public ResultVO<ReportBomVersionVO> forwardVersion(@RequestBody ReverseReportQuery query) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.query;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bom
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ChildBomReportQuery {
|
||||||
|
|
||||||
|
@ApiModelProperty("BOM 类型 0-原始BOM 1-EBom 2-PBom 3-MBom")
|
||||||
|
@NotNull(message = "BOM类型不能为空")
|
||||||
|
private Integer bomType;
|
||||||
|
|
||||||
|
@ApiModelProperty("子级Bom")
|
||||||
|
private Long bomRowId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -44,4 +44,6 @@ public class ReverseReportQuery {
|
||||||
@ApiModelProperty("数据显示方式 0-树形状 1-列表")
|
@ApiModelProperty("数据显示方式 0-树形状 1-列表")
|
||||||
private Integer dataType;
|
private Integer dataType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
package com.nflg.product.bomnew.service;
|
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.lang.TypeReference;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.nflg.product.bomnew.constant.ReportConstant;
|
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildFormalEntity;
|
||||||
|
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.BomNewEbomParentFormalVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
|
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
|
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
|
||||||
import com.nflg.product.bomnew.pojo.vo.ReportBomVersionVO;
|
import com.nflg.product.bomnew.pojo.vo.ReportBomVersionVO;
|
||||||
|
|
@ -10,6 +17,7 @@ import com.nflg.product.bomnew.service.domain.EBom.EBomForwardReport;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
@ -45,6 +53,36 @@ public class ForwardReportService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<ForwardReportVO> chilidBom(ChildBomReportQuery query) {
|
||||||
|
//原始BOM
|
||||||
|
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//EBOM
|
||||||
|
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.EBOM.getValue()) == 0) {
|
||||||
|
|
||||||
|
return chilidEBomList(query);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//PBOM
|
||||||
|
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.PBOM.getValue()) == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
//MBOM
|
||||||
|
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VUtils.isTure(true).throwMessage("错误的BOM类型");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ReportBomVO factoryBomType(ReverseReportQuery query) {
|
public ReportBomVO factoryBomType(ReverseReportQuery query) {
|
||||||
//原始BOM
|
//原始BOM
|
||||||
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
|
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue()) == 0) {
|
||||||
|
|
@ -69,6 +107,20 @@ public class ForwardReportService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<ForwardReportVO> chilidEBomList(ChildBomReportQuery query) {
|
||||||
|
QueryWrapper<BomNewEbomChildFormalEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.lambda().eq(BomNewEbomChildFormalEntity::getParentRowId, query.getBomRowId());
|
||||||
|
List<BomNewEbomChildFormalEntity> list = SpringUtil.getBean(BomNewEbomChildFormalService.class).list(queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
List<ForwardReportVO> childBomLit = Convert.convert(
|
||||||
|
new TypeReference<List<ForwardReportVO>>() {
|
||||||
|
|
||||||
|
}, list);
|
||||||
|
return childBomLit;
|
||||||
|
}
|
||||||
|
|
||||||
ReportBomVO queryOriginalBom(ReverseReportQuery query) {
|
ReportBomVO queryOriginalBom(ReverseReportQuery query) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -86,4 +138,6 @@ public class ForwardReportService {
|
||||||
ReportBomVO queryMBom(ReverseReportQuery query) {
|
ReportBomVO queryMBom(ReverseReportQuery query) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,20 @@ import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ebom报表统计
|
||||||
|
*/
|
||||||
public class EBomForwardReport {
|
public class EBomForwardReport {
|
||||||
|
|
||||||
ReverseReportQuery query;
|
ReverseReportQuery query;
|
||||||
|
|
||||||
public EBomForwardReport(ReverseReportQuery query) {
|
public EBomForwardReport(ReverseReportQuery query) {
|
||||||
this.query = query;
|
this.query = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EBomForwardReport(){
|
||||||
|
|
||||||
|
}
|
||||||
QueryWrapper<BomNewEbomParentFormalEntity> buildQuery() {
|
QueryWrapper<BomNewEbomParentFormalEntity> buildQuery() {
|
||||||
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getMaterialNo, query.getMaterialNo());
|
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getMaterialNo, query.getMaterialNo());
|
||||||
|
|
@ -45,7 +51,6 @@ public class EBomForwardReport {
|
||||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getDrawingNo, query.getDrawingNo());
|
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getDrawingNo, query.getDrawingNo());
|
||||||
}
|
}
|
||||||
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
|
if (query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) == 0) {
|
||||||
// queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getLastVersionIs,1);
|
|
||||||
|
|
||||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getCurrentVersion, getMaxVersion());
|
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getCurrentVersion, getMaxVersion());
|
||||||
|
|
||||||
|
|
@ -56,26 +61,26 @@ public class EBomForwardReport {
|
||||||
if (StrUtil.isNotBlank(query.getStartDate()) && StrUtil.isNotBlank(query.getEndDate())) {
|
if (StrUtil.isNotBlank(query.getStartDate()) && StrUtil.isNotBlank(query.getEndDate())) {
|
||||||
queryWrapper.lambda().between(BomNewEbomParentFormalEntity::getConvertToEbomTime, query.getStartDate(), query.getEndDate());
|
queryWrapper.lambda().between(BomNewEbomParentFormalEntity::getConvertToEbomTime, query.getStartDate(), query.getEndDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BomNewEbomParentFormalEntity getParent() {
|
BomNewEbomParentFormalEntity getParent() {
|
||||||
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = buildQuery();
|
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = buildQuery();
|
||||||
|
|
||||||
List<BomNewEbomParentFormalEntity> list = SpringUtil.getBean(BomNewEbomParentFormalService.class).list(queryWrapper);
|
List<BomNewEbomParentFormalEntity> list = SpringUtil.getBean(BomNewEbomParentFormalService.class).list(queryWrapper);
|
||||||
|
|
||||||
if (CollectionUtil.isEmpty(list)) {
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
|
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到物料编码为{}的数据信息", query.getMaterialNo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BomNewEbomParentFormalEntity parentFormal = list.get(0);
|
BomNewEbomParentFormalEntity parentFormal = list.get(0);
|
||||||
parentFormal.setLevelNum(null);
|
parentFormal.setLevelNum(null);
|
||||||
parentFormal.setOrderNumber(null);
|
parentFormal.setOrderNumber(null);
|
||||||
return parentFormal;
|
return parentFormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大的版本号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getMaxVersion() {
|
public String getMaxVersion() {
|
||||||
ReportBomVersionVO reportBomVersionVO = bomVersion();
|
ReportBomVersionVO reportBomVersionVO = bomVersion();
|
||||||
if (reportBomVersionVO.getVList().size() == 1) {
|
if (reportBomVersionVO.getVList().size() == 1) {
|
||||||
|
|
@ -92,6 +97,11 @@ public class EBomForwardReport {
|
||||||
return maxVersion;
|
return maxVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单层
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ReportBomVO singleReport() {
|
ReportBomVO singleReport() {
|
||||||
|
|
||||||
BomNewEbomParentFormalEntity parentFormal = getParent();
|
BomNewEbomParentFormalEntity parentFormal = getParent();
|
||||||
|
|
@ -102,6 +112,7 @@ public class EBomForwardReport {
|
||||||
reportBomVO.setParent(forwardReportVO);
|
reportBomVO.setParent(forwardReportVO);
|
||||||
QueryWrapper<BomNewEbomChildFormalEntity> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BomNewEbomChildFormalEntity> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(BomNewEbomChildFormalEntity::getParentRowId, parentFormal.getRowId());
|
queryWrapper.lambda().eq(BomNewEbomChildFormalEntity::getParentRowId, parentFormal.getRowId());
|
||||||
|
|
||||||
List<BomNewEbomChildFormalEntity> list = SpringUtil.getBean(BomNewEbomChildFormalService.class).list(queryWrapper);
|
List<BomNewEbomChildFormalEntity> list = SpringUtil.getBean(BomNewEbomChildFormalService.class).list(queryWrapper);
|
||||||
if (CollectionUtil.isEmpty(list)) {
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
reportBomVO.setChildNodes(new ArrayList<>());
|
reportBomVO.setChildNodes(new ArrayList<>());
|
||||||
|
|
@ -121,9 +132,11 @@ public class EBomForwardReport {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public ReportBomVersionVO bomVersion() {
|
public ReportBomVersionVO bomVersion() {
|
||||||
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<BomNewEbomParentFormalEntity> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getMaterialNo, query.getMaterialNo());
|
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getMaterialNo, query.getMaterialNo());
|
||||||
|
|
@ -153,6 +166,28 @@ public class EBomForwardReport {
|
||||||
return reportBomVersionVO;
|
return reportBomVersionVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bomid下所有数据
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BomNewEbomParentFormalVO> bomDetailList(Long bomRowId) {
|
||||||
|
List<BomNewEbomParentFormalVO> childList = SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChild(bomRowId);
|
||||||
|
EBomFormalTreeTask task = new EBomFormalTreeTask(childList);
|
||||||
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
|
ForkJoinTask<List<BomNewEbomParentFormalVO>> submit = pool.submit(task);
|
||||||
|
|
||||||
|
List<BomNewEbomParentFormalVO> bomList = submit.join();
|
||||||
|
return bomList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 多层
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ReportBomVO multiReport() {
|
ReportBomVO multiReport() {
|
||||||
BomNewEbomParentFormalEntity parentFormal = getParent();
|
BomNewEbomParentFormalEntity parentFormal = getParent();
|
||||||
ReportBomVO reportBomVO = new ReportBomVO();
|
ReportBomVO reportBomVO = new ReportBomVO();
|
||||||
|
|
@ -164,69 +199,98 @@ public class EBomForwardReport {
|
||||||
reportBomVO.setParent(forwardReportVO);
|
reportBomVO.setParent(forwardReportVO);
|
||||||
|
|
||||||
|
|
||||||
List<BomNewEbomParentFormalVO> childList=SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChild(parentFormal.getRowId());
|
List<BomNewEbomParentFormalVO> bomList = bomDetailList(parentFormal.getRowId());
|
||||||
EBomFormalTreeTask task=new EBomFormalTreeTask(childList);
|
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
|
||||||
ForkJoinTask<List<BomNewEbomParentFormalVO>> submit = pool.submit(task);
|
|
||||||
|
|
||||||
List<BomNewEbomParentFormalVO> bomList= submit.join();
|
|
||||||
|
|
||||||
|
|
||||||
List<ForwardReportVO> convertBomList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
List<ForwardReportVO> convertBomList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
||||||
}, bomList);
|
}, bomList);
|
||||||
// System.out.println(JSON.toJSONString(bomList));
|
|
||||||
|
|
||||||
sumLevel(convertBomList);
|
sumLevel(convertBomList);
|
||||||
//分组数据
|
//转化为树结构
|
||||||
List<ForwardReportVO> rootList = listToTree(convertBomList, parentFormal.getRowId());
|
List<ForwardReportVO> rootList = listToTree(convertBomList, parentFormal.getRowId());
|
||||||
|
|
||||||
sumLevel(rootList);
|
|
||||||
// System.out.println(JSON.toJSONString(rootList));
|
|
||||||
reportBomVO.setChildNodes(rootList);
|
reportBomVO.setChildNodes(rootList);
|
||||||
return reportBomVO;
|
return reportBomVO;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇总
|
||||||
|
* 1. 查询所有不含子级的物料信息,并对数据进行汇总。
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ReportBomVO sumReport() {
|
||||||
|
|
||||||
|
BomNewEbomParentFormalEntity parentFormal = getParent();
|
||||||
|
ReportBomVO reportBomVO = new ReportBomVO();
|
||||||
|
reportBomVO.setBomType(query.getBomType());
|
||||||
|
reportBomVO.setQueryType(query.getQueryType());
|
||||||
|
|
||||||
|
ForwardReportVO forwardReportVO = Convert.convert(ForwardReportVO.class, parentFormal);
|
||||||
|
forwardReportVO.setCreatedTime(parentFormal.getConvertToEbomTime());
|
||||||
|
reportBomVO.setParent(forwardReportVO);
|
||||||
|
List<BomNewEbomParentFormalVO> bomList = bomDetailList(parentFormal.getRowId());
|
||||||
|
List<ForwardReportVO> convertBomList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
||||||
|
}, bomList);
|
||||||
|
|
||||||
|
sumLevel(convertBomList);
|
||||||
|
|
||||||
|
//无子级的数据
|
||||||
|
List<ForwardReportVO> leafList = convertBomList.stream().filter(item -> (item.getBomRowId() == null || item.getBomRowId().longValue() ==0)).collect(Collectors.toList());
|
||||||
|
//相同物料合并统计
|
||||||
|
Map<String, List<ForwardReportVO>> materialNoListMap = leafList.stream().collect(Collectors.groupingBy(ForwardReportVO::getMaterialNo));
|
||||||
|
List<ForwardReportVO> sumList = new ArrayList<>();
|
||||||
|
materialNoListMap.forEach((key, valueList) -> {
|
||||||
|
if (CollectionUtil.isNotEmpty(valueList)) {
|
||||||
|
ForwardReportVO item0 = valueList.get(0);
|
||||||
|
//相同物料合并数量
|
||||||
|
if (valueList.size() > 1) {
|
||||||
|
for (int index = 1; index < valueList.size(); index++) {
|
||||||
|
item0.setNum(item0.getNum().add(valueList.get(index).getNum()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sumList.add(item0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
reportBomVO.setChildNodes(sumList);
|
||||||
|
return reportBomVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 各层汇总
|
||||||
|
*1.按层分组 和 parent分组
|
||||||
|
* 2.下层数量=下层数量*上层数量
|
||||||
|
* @param bomList
|
||||||
|
*/
|
||||||
void sumLevel(List<ForwardReportVO> bomList) {
|
void sumLevel(List<ForwardReportVO> bomList) {
|
||||||
|
//分层统计,避免使用遍历树统计
|
||||||
Map<Integer, List<ForwardReportVO>> listMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getLevelNum));
|
Map<Integer, List<ForwardReportVO>> listMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getLevelNum));
|
||||||
Map<Long, List<ForwardReportVO>> bomParentMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId));
|
Map<Long, List<ForwardReportVO>> bomParentMap = bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId));
|
||||||
listMap.forEach((key, value) -> {
|
listMap.forEach((key, value) -> {
|
||||||
|
|
||||||
value.forEach(parent -> {
|
value.forEach(parent -> {
|
||||||
|
|
||||||
List<ForwardReportVO> dataList = bomParentMap.get(parent.getBomRowId());
|
List<ForwardReportVO> dataList = bomParentMap.get(parent.getBomRowId());
|
||||||
if (CollectionUtil.isNotEmpty(dataList)) {
|
if (CollectionUtil.isNotEmpty(dataList)) {
|
||||||
for (ForwardReportVO data :
|
for (ForwardReportVO data :
|
||||||
dataList) {
|
dataList) {
|
||||||
data.setNum(parent.getNum().multiply(data.getNum()));
|
data.setNum(parent.getNum().multiply(data.getNum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<ForwardReportVO> listToTree(List<ForwardReportVO> bomList, Long parentRowId) {
|
List<ForwardReportVO> listToTree(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));
|
||||||
|
|
||||||
bomList.forEach(item -> {
|
bomList.forEach(item -> {
|
||||||
item.setChildNodes(listMap.get(item.getBomRowId()));
|
item.setChildNodes(listMap.get(item.getBomRowId()));
|
||||||
});
|
});
|
||||||
|
|
||||||
List<ForwardReportVO> rootList = bomList.stream().filter(item -> Objects.equals(parentRowId, item.getParentRowId())).collect(Collectors.toList());
|
List<ForwardReportVO> rootList = bomList.stream().filter(item -> Objects.equals(parentRowId, item.getParentRowId())).collect(Collectors.toList());
|
||||||
|
|
||||||
return rootList;
|
return rootList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,8 +299,6 @@ public class EBomForwardReport {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ReportBomVO genReport() {
|
public ReportBomVO genReport() {
|
||||||
//单层
|
//单层
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SINGLE.getValue()) == 0) {
|
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SINGLE.getValue()) == 0) {
|
||||||
|
|
@ -244,12 +306,13 @@ public class EBomForwardReport {
|
||||||
}
|
}
|
||||||
//多层
|
//多层
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
||||||
|
|
||||||
return multiReport();
|
return multiReport();
|
||||||
}
|
}
|
||||||
|
//汇总
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SUM.getValue()) == 0) {
|
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SUM.getValue()) == 0) {
|
||||||
|
return sumReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue