This commit is contained in:
parent
bafa5b2478
commit
37bcabe40b
|
|
@ -2,12 +2,15 @@ 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 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.ChildBomReportQuery;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.CompareReportQuery;
|
||||||
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.CompareReportService;
|
||||||
import com.nflg.product.bomnew.service.ForwardReportService;
|
import com.nflg.product.bomnew.service.ForwardReportService;
|
||||||
import com.nflg.product.bomnew.service.ReverseReportService;
|
import com.nflg.product.bomnew.service.ReverseReportService;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
|
@ -37,6 +40,11 @@ public class BomReportApi extends BaseApi {
|
||||||
@Resource
|
@Resource
|
||||||
ForwardReportService forwardReportService;
|
ForwardReportService forwardReportService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
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) {
|
||||||
|
|
@ -86,6 +94,9 @@ public class BomReportApi extends BaseApi {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("forwardReport")
|
@PostMapping("forwardReport")
|
||||||
@ApiOperation("bom-正查")
|
@ApiOperation("bom-正查")
|
||||||
public ResultVO<ReportBomVO> forwardReport(@RequestBody ReverseReportQuery query) {
|
public ResultVO<ReportBomVO> forwardReport(@RequestBody ReverseReportQuery query) {
|
||||||
|
|
@ -97,7 +108,33 @@ public class BomReportApi extends BaseApi {
|
||||||
return ResultVO.success(forwardReportService.factoryBomType(query));
|
return ResultVO.success(forwardReportService.factoryBomType(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("compareReport")
|
||||||
|
@ApiOperation("bom-比对")
|
||||||
|
public ResultVO<CompareReportListVO> compareReport(@RequestBody CompareReportQuery query) {
|
||||||
|
ResultVO resultBom1VO = checkQueryParam(query.getLeft());
|
||||||
|
ResultVO resultBom2VO = checkQueryParam(query.getRight());
|
||||||
|
|
||||||
|
if (resultBom1VO != null) {
|
||||||
|
return resultBom1VO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultBom2VO != null) {
|
||||||
|
return resultBom2VO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ObjectUtil.equal(query.getLeft().getQueryType(),query.getRight().getQueryType())){
|
||||||
|
|
||||||
|
return ResultVO.error(STATE.ParamErr, "查询方式不一致");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultVO.success(compareReportService.compareBom(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("forwardExport")
|
@PostMapping("forwardExport")
|
||||||
|
@ApiOperation("bom-正查导出")
|
||||||
public void export(@RequestBody ReverseReportQuery query, HttpServletResponse response) throws IOException {
|
public void export(@RequestBody ReverseReportQuery query, HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
ResultVO resultVO = checkQueryParam(query);
|
ResultVO resultVO = checkQueryParam(query);
|
||||||
|
|
@ -115,7 +152,7 @@ public class BomReportApi extends BaseApi {
|
||||||
|
|
||||||
|
|
||||||
@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())) {
|
||||||
|
|
@ -140,7 +177,7 @@ public class BomReportApi extends BaseApi {
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("forwardVersion")
|
@PostMapping("forwardVersion")
|
||||||
@ApiOperation("bom-物料版本及描述")
|
@ApiOperation("bom-正查物料版本及描述")
|
||||||
public ResultVO<ReportBomVersionVO> forwardVersion(@RequestBody ReverseReportQuery query) {
|
public ResultVO<ReportBomVersionVO> forwardVersion(@RequestBody ReverseReportQuery query) {
|
||||||
ResultVO resultVO = checkQueryParam(query);
|
ResultVO resultVO = checkQueryParam(query);
|
||||||
if (resultVO != null) {
|
if (resultVO != null) {
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,24 @@ public class ReportConstant {
|
||||||
@Getter
|
@Getter
|
||||||
public enum TagEnum implements ValueEnum<Integer> {
|
public enum TagEnum implements ValueEnum<Integer> {
|
||||||
|
|
||||||
|
//是否有汇总
|
||||||
|
NORMAL (0, "默认"),
|
||||||
|
SIGMA (1, "Σ汇总");
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum SymbolEnum implements ValueEnum<Integer> {
|
||||||
|
|
||||||
//比对
|
//比对
|
||||||
SIGMA (1, "Σ汇总"),
|
EQ(1, "相等"),
|
||||||
EQ(2, "相等"),
|
NON_EQ(0, "不相等"),
|
||||||
N_EQ(3, "不相等"),
|
L_NULL(2, "左有右无"),
|
||||||
L_N(4, "左有右无"),
|
NULL_R(3, "左无右有");
|
||||||
N_R(5, "左无右有");
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,15 @@
|
||||||
package com.nflg.product.bomnew.pojo.query;public class CompareReportQuery {
|
package com.nflg.product.bomnew.pojo.query;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CompareReportQuery {
|
||||||
|
|
||||||
|
@ApiModelProperty("bom1查询参数")
|
||||||
|
private ReverseReportQuery left;
|
||||||
|
|
||||||
|
@ApiModelProperty("bom2查询参数")
|
||||||
|
private ReverseReportQuery right;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,30 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;public class CompareReportListVO {
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CompareReportListVO {
|
||||||
|
@ApiModelProperty("左侧bom1父级")
|
||||||
|
private ForwardReportVO leftParent;
|
||||||
|
|
||||||
|
@ApiModelProperty("右侧bom2父级")
|
||||||
|
private ForwardReportVO rightParent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("BOM 类型 0-原始BOM 1-EBom 2-PBom")
|
||||||
|
private Integer leftBomType;
|
||||||
|
private Integer rightBomType;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("列表")
|
||||||
|
private List<CompareReportVO> childNodes;
|
||||||
|
|
||||||
|
@ApiModelProperty("查询方式 0-单层 1-多层 2-汇总")
|
||||||
|
private Integer queryType;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,37 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;public class CompareReportVO {
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比对
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CompareReportVO {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("左侧bom1")
|
||||||
|
private ForwardReportVO left;
|
||||||
|
|
||||||
|
@ApiModelProperty("右侧bom2")
|
||||||
|
private ForwardReportVO right;
|
||||||
|
@ApiModelProperty("符号: 0-不相等 1-相等, 2-左有右缺 ,3-左缺右有")
|
||||||
|
private Integer symbol;
|
||||||
|
public CompareReportVO(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public CompareReportVO(ForwardReportVO lt,Integer symbol,ForwardReportVO rt){
|
||||||
|
this.left=lt;
|
||||||
|
this.symbol=symbol;
|
||||||
|
this.right=rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ public class ForwardReportVO extends BaseMaterialVO {
|
||||||
@ApiModelProperty("层级")
|
@ApiModelProperty("层级")
|
||||||
private Integer levelNum;
|
private Integer levelNum;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工厂编码")
|
||||||
|
private String facCode;
|
||||||
|
|
||||||
@ApiModelProperty("版本号")
|
@ApiModelProperty("版本号")
|
||||||
private String currentVersion;
|
private String currentVersion;
|
||||||
|
|
@ -67,7 +68,7 @@ public class ForwardReportVO extends BaseMaterialVO {
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "标记: 0-忽略 1-汇总")
|
@ApiModelProperty(value = "标记0-未汇总 1-汇总")
|
||||||
private Integer tag=0;
|
private Integer tag=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,237 @@
|
||||||
package com.nflg.product.bomnew.service;public class CompareReportService {
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||||
|
import com.nflg.product.bomnew.pojo.query.CompareReportQuery;
|
||||||
|
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.CompareReportListVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.CompareReportVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
|
||||||
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 比对
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CompareReportService {
|
||||||
|
|
||||||
|
|
||||||
|
public CompareReportListVO compareBom(CompareReportQuery query) {
|
||||||
|
ReportBomVO left = SpringUtil.getBean(ForwardReportService.class).factoryBomType(query.getLeft());
|
||||||
|
ReportBomVO right = SpringUtil.getBean(ForwardReportService.class).factoryBomType(query.getRight());
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(left.getChildNodes()) && CollUtil.isEmpty(right.getChildNodes())) {
|
||||||
|
VUtils.isTure(true).throwMessage(StrUtil.format("{}和{}下无物料数据 ", left.getParent().getMaterialNo(), right.getParent().getMaterialNo()));
|
||||||
|
}
|
||||||
|
CompareReportListVO compareReportListVO = new CompareReportListVO();
|
||||||
|
compareReportListVO.setQueryType(query.getLeft().getQueryType());
|
||||||
|
compareReportListVO.setLeftParent(left.getParent());
|
||||||
|
compareReportListVO.setRightParent(right.getParent());
|
||||||
|
compareReportListVO.setLeftBomType(left.getBomType());
|
||||||
|
compareReportListVO.setRightBomType(right.getBomType());
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(left.getChildNodes()) || CollUtil.isEmpty(right.getChildNodes())) {
|
||||||
|
compareReportListVO.setChildNodes(obliqueBom(left.getChildNodes(), right.getChildNodes()));
|
||||||
|
} else {
|
||||||
|
if (left.getBomType().equals(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue())
|
||||||
|
|| right.getBomType().equals(ReportConstant.BomTypeEnum.ORIGINALBOM.getValue())) {
|
||||||
|
compareReportListVO.setChildNodes(compareBomResult(left, right, query.getLeft().getQueryType(), ForwardReportVO::getDrawingNo));
|
||||||
|
} else {
|
||||||
|
compareReportListVO.setChildNodes(compareBomResult(left, right, query.getLeft().getQueryType(), ForwardReportVO::getMaterialNo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return compareReportListVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 左倾斜 或右倾斜
|
||||||
|
* @param leftNode
|
||||||
|
* @param rightNode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CompareReportVO> obliqueBom(List<ForwardReportVO> leftNode, List<ForwardReportVO> rightNode) {
|
||||||
|
if (CollUtil.isEmpty(leftNode) && CollUtil.isEmpty(rightNode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(leftNode) && CollUtil.isNotEmpty(rightNode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<CompareReportVO> compareReportVOList = new ArrayList<>();
|
||||||
|
if (CollUtil.isNotEmpty(leftNode)) {
|
||||||
|
for (ForwardReportVO vo :
|
||||||
|
leftNode) {
|
||||||
|
compareReportVOList.add(new CompareReportVO(vo, ReportConstant.SymbolEnum.L_NULL.getValue(), null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(rightNode)) {
|
||||||
|
for (ForwardReportVO vo :
|
||||||
|
rightNode) {
|
||||||
|
compareReportVOList.add(new CompareReportVO(null, ReportConstant.SymbolEnum.NULL_R.getValue(), vo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return compareReportVOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇总:比较物料编号、数量、单位
|
||||||
|
* 单层:比较 物料编号、数量、单位
|
||||||
|
* 多层:物料编号、数量、父级物料编码
|
||||||
|
*
|
||||||
|
* @param left
|
||||||
|
* @param right
|
||||||
|
* @param queryType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CompareReportVO> compareBomResult(ReportBomVO left, ReportBomVO right, Integer queryType, Function<ForwardReportVO, String> compareFunc) {
|
||||||
|
|
||||||
|
List<CompareReportVO> compareReportVOList = new ArrayList<>();
|
||||||
|
Map<Long, List<ForwardReportVO>> leftBomRowIdMap = left.getChildNodes().stream().filter(item -> item.getBomRowId() != null && item.getBomRowId() > 0).collect(Collectors.groupingBy(ForwardReportVO::getBomRowId));
|
||||||
|
leftBomRowIdMap.put(left.getParent().getBomRowId(), new ArrayList<>(Arrays.asList(left.getParent())));
|
||||||
|
|
||||||
|
Map<Long, List<ForwardReportVO>> rightBomRowIdMap = right.getChildNodes().stream().filter(item -> item.getBomRowId() != null && item.getBomRowId() > 0).collect(Collectors.groupingBy(ForwardReportVO::getBomRowId));
|
||||||
|
rightBomRowIdMap.put(right.getParent().getBomRowId(), new ArrayList<>(Arrays.asList(right.getParent())));
|
||||||
|
|
||||||
|
Map<String, List<ForwardReportVO>> leftMaterialNoMap = left.getChildNodes().stream().collect(Collectors.groupingBy(compareFunc));
|
||||||
|
Map<String, List<ForwardReportVO>> rightMaterialNoMap = right.getChildNodes().stream().collect(Collectors.groupingBy(compareFunc));
|
||||||
|
//以左基准比较
|
||||||
|
doCompareBom(compareReportVOList,
|
||||||
|
leftBomRowIdMap,
|
||||||
|
rightBomRowIdMap,
|
||||||
|
leftMaterialNoMap,
|
||||||
|
rightMaterialNoMap,
|
||||||
|
compareFunc, queryType,
|
||||||
|
ReportConstant.SymbolEnum.L_NULL);
|
||||||
|
|
||||||
|
//以右基准比较
|
||||||
|
doCompareBom(compareReportVOList,
|
||||||
|
rightBomRowIdMap,
|
||||||
|
leftBomRowIdMap,
|
||||||
|
rightMaterialNoMap,
|
||||||
|
leftMaterialNoMap,
|
||||||
|
compareFunc, queryType,
|
||||||
|
ReportConstant.SymbolEnum.NULL_R);
|
||||||
|
|
||||||
|
return compareReportVOList;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void doCompareBom(List<CompareReportVO> compareReportVOList,
|
||||||
|
Map<Long, List<ForwardReportVO>> leftBomRowIdMap,
|
||||||
|
Map<Long, List<ForwardReportVO>> rightBomRowIdMap,
|
||||||
|
Map<String, List<ForwardReportVO>> leftMaterialNoMap,
|
||||||
|
Map<String, List<ForwardReportVO>> rightMaterialNoMap,
|
||||||
|
Function<ForwardReportVO, String> compareFunc,
|
||||||
|
Integer queryType,
|
||||||
|
ReportConstant.SymbolEnum defaultSymbol
|
||||||
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
Iterator<Map.Entry<String, List<ForwardReportVO>>> leftIterator = leftMaterialNoMap.entrySet().iterator();
|
||||||
|
while (leftIterator.hasNext()) {
|
||||||
|
Map.Entry<String, List<ForwardReportVO>> entry = leftIterator.next();
|
||||||
|
String materialNo = entry.getKey();
|
||||||
|
List<ForwardReportVO> fromCompareList = entry.getValue();
|
||||||
|
|
||||||
|
|
||||||
|
Iterator<ForwardReportVO> fromIter = fromCompareList.iterator();
|
||||||
|
while (fromIter.hasNext()) {
|
||||||
|
ForwardReportVO from = fromIter.next();
|
||||||
|
|
||||||
|
List<ForwardReportVO> toCompareList = rightMaterialNoMap.get(materialNo);
|
||||||
|
|
||||||
|
CompareReportVO compareReportVO = null;
|
||||||
|
if (defaultSymbol.getValue().equals(ReportConstant.SymbolEnum.L_NULL.getValue())) {
|
||||||
|
compareReportVO = new CompareReportVO(from, defaultSymbol.getValue(), null);
|
||||||
|
}
|
||||||
|
if (defaultSymbol.getValue().equals(ReportConstant.SymbolEnum.NULL_R.getValue())) {
|
||||||
|
compareReportVO = new CompareReportVO(null, defaultSymbol.getValue(), from);
|
||||||
|
}
|
||||||
|
|
||||||
|
compareReportVOList.add(compareReportVO);
|
||||||
|
if (CollUtil.isNotEmpty(toCompareList)) {
|
||||||
|
compareReportVOList.add(compareReportVO);
|
||||||
|
ForwardReportVO to = null;
|
||||||
|
for (ForwardReportVO item :
|
||||||
|
toCompareList) {
|
||||||
|
to = item;
|
||||||
|
|
||||||
|
if (defaultSymbol.getValue().equals(ReportConstant.SymbolEnum.L_NULL.getValue())) {
|
||||||
|
compareReportVO.setRight(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultSymbol.getValue().equals(ReportConstant.SymbolEnum.NULL_R.getValue())) {
|
||||||
|
compareReportVO.setLeft(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
//比较数量
|
||||||
|
if (!ObjectUtil.equal(from.getNum(), to.getNum())) {
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//多层比较父级物料编码/图号
|
||||||
|
if (queryType.compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
||||||
|
if (CollUtil.isEmpty(leftMaterialNoMap.get(from.getParentRowId()))
|
||||||
|
|| CollUtil.isEmpty(rightMaterialNoMap.get(to.getParentRowId()))) {
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ForwardReportVO fromParent = leftBomRowIdMap.get(from.getParentRowId()).get(0);
|
||||||
|
ForwardReportVO toParent = rightBomRowIdMap.get(from.getParentRowId()).get(0);
|
||||||
|
if (!compareFunc.apply(fromParent).equals(compareFunc.apply(toParent))) {
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//比较单位
|
||||||
|
if (!ObjectUtil.equal(from.getMaterialUnit(), to.getMaterialUnit())) {
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//找到相等退出
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.EQ.getValue());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//删除已比较数据
|
||||||
|
ForwardReportVO finalTo = to;
|
||||||
|
if (finalTo != null) {
|
||||||
|
toCompareList.removeIf(item -> ObjectUtil.equal(item.getRowId(), finalTo.getRowId()));
|
||||||
|
}
|
||||||
|
//分组里无数据删除
|
||||||
|
if (CollUtil.isEmpty(toCompareList)) {
|
||||||
|
rightMaterialNoMap.remove(materialNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//已比较的移除
|
||||||
|
fromIter.remove();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(fromCompareList)) {
|
||||||
|
leftIterator.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,7 @@ public abstract class BaseForwardReport {
|
||||||
reportBomVO.setBomType(query.getBomType());
|
reportBomVO.setBomType(query.getBomType());
|
||||||
reportBomVO.setQueryType(query.getQueryType());
|
reportBomVO.setQueryType(query.getQueryType());
|
||||||
reportBomVO.setDataType(dataType);
|
reportBomVO.setDataType(dataType);
|
||||||
|
parent.setBomRowId(parent.getRowId());
|
||||||
reportBomVO.setParent(parent);
|
reportBomVO.setParent(parent);
|
||||||
reportBomVO.setChildNodes(childNode);
|
reportBomVO.setChildNodes(childNode);
|
||||||
return reportBomVO;
|
return reportBomVO;
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ public class EBomForwardReport extends BaseForwardReport {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,197 +7,25 @@ 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;
|
||||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
|
||||||
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.pojo.entity.BomNewOriginalParentEntity;
|
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||||
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.BomOriginalListVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewEbomParentFormalService;
|
import com.nflg.product.bomnew.pojo.vo.ForwardReportVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.ReportBomVO;
|
||||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||||
import com.nflg.product.bomnew.service.domain.BaseForwardReport;
|
import com.nflg.product.bomnew.service.domain.BaseForwardReport;
|
||||||
import com.nflg.product.bomnew.service.domain.EBom.EBomFormalTreeTask;
|
|
||||||
import com.nflg.product.bomnew.util.VersionUtil;
|
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原始bom报表统计
|
* 原始bom 比对报表统计
|
||||||
*/
|
*/
|
||||||
public class OriginalBomForwardReport extends BaseForwardReport {
|
public class OriginalBomCompareReport {
|
||||||
|
|
||||||
|
|
||||||
public OriginalBomForwardReport(ReverseReportQuery query) {
|
|
||||||
|
|
||||||
super(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QueryWrapper<BomNewOriginalParentEntity> buildQuery() {
|
|
||||||
QueryWrapper<BomNewOriginalParentEntity> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.lambda().eq(BomNewOriginalParentEntity::getDrawingNo, query.getDrawingNo());
|
|
||||||
if (StrUtil.isNotBlank(query.getMaterialNo())) {
|
|
||||||
queryWrapper.lambda().eq(BomNewOriginalParentEntity::getMaterialNo, query.getMaterialNo());
|
|
||||||
}
|
|
||||||
|
|
||||||
queryWrapper.lambda().eq(BomNewOriginalParentEntity::getLastVersionIs,1);
|
|
||||||
// queryWrapper.lambda().eq(BomNewOriginalParentEntity::getStatus, OriginalStatusEnum.OVER_CONVERT.getValue());
|
|
||||||
if (StrUtil.isNotBlank(query.getStartDate()) && StrUtil.isNotBlank(query.getEndDate())) {
|
|
||||||
queryWrapper.lambda().between(BomNewOriginalParentEntity::getConvertToEbomTime, query.getStartDate(), query.getEndDate());
|
|
||||||
}
|
|
||||||
return queryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BomNewOriginalParentEntity getParent() {
|
|
||||||
QueryWrapper<BomNewOriginalParentEntity> queryWrapper = buildQuery();
|
|
||||||
List<BomNewOriginalParentEntity> list = SpringUtil.getBean(BomNewOriginalParentService.class).list(queryWrapper);
|
|
||||||
if (CollectionUtil.isEmpty(list)) {
|
|
||||||
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("未查到图号为{}的数据信息", query.getDrawingNo()));
|
|
||||||
}
|
|
||||||
BomNewOriginalParentEntity parentFormal = list.get(0);
|
|
||||||
parentFormal.setLevelNum(null);
|
|
||||||
|
|
||||||
return parentFormal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 单层
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ReportBomVO singleReport() {
|
|
||||||
|
|
||||||
BomNewOriginalParentEntity parentFormal = getParent();
|
|
||||||
ForwardReportVO forwardReportVO = Convert.convert(ForwardReportVO.class, parentFormal);
|
|
||||||
forwardReportVO.setCreatedTime(parentFormal.getConvertToEbomTime());
|
|
||||||
|
|
||||||
// QueryWrapper<BomNewEbomChildFormalEntity> queryWrapper = new QueryWrapper<>();
|
|
||||||
// queryWrapper.lambda().eq(BomNewEbomChildFormalEntity::getParentRowId, parentFormal.getRowId());
|
|
||||||
//
|
|
||||||
// List<BomNewEbomChildFormalEntity> list = SpringUtil.getBean(BomNewEbomChildFormalService.class).list(queryWrapper);
|
|
||||||
//
|
|
||||||
List<BomOriginalListVO> list = SpringUtil.getBean(BomNewOriginalParentService.class).getBaseMapper().getParentChild(parentFormal.getRowId());
|
|
||||||
List<ForwardReportVO> nodeList=null;
|
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
|
||||||
int noNum=1;
|
|
||||||
nodeList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
|
||||||
}, list);
|
|
||||||
for (ForwardReportVO vo :
|
|
||||||
nodeList) {
|
|
||||||
vo.setCreatedTime(parentFormal.getConvertToEbomTime());
|
|
||||||
vo.setLevelNum(1);
|
|
||||||
vo.setOrderNumber(noNum+"");noNum++;
|
|
||||||
// vo.setOrderNumber("");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return buildReportBomVo(forwardReportVO,nodeList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bomid下所有数据
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<BomOriginalListVO> bomDetailList(Long bomRowId) {
|
|
||||||
List<BomOriginalListVO> childList = SpringUtil.getBean(BomNewOriginalParentService.class).getBaseMapper().getParentChild(bomRowId);
|
|
||||||
OriginalBomFormalTreeTask task = new OriginalBomFormalTreeTask(childList);
|
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
|
||||||
ForkJoinTask<List<BomOriginalListVO>> submit = pool.submit(task);
|
|
||||||
|
|
||||||
List<BomOriginalListVO> bomList = submit.join();
|
|
||||||
return bomList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多层
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ReportBomVO multiReport() {
|
|
||||||
BomNewOriginalParentEntity parentFormal = getParent();
|
|
||||||
|
|
||||||
|
|
||||||
ForwardReportVO forwardReportVO = Convert.convert(ForwardReportVO.class, parentFormal);
|
|
||||||
forwardReportVO.setCreatedTime(parentFormal.getConvertToEbomTime());
|
|
||||||
|
|
||||||
List<BomOriginalListVO> bomList = bomDetailList(parentFormal.getRowId());
|
|
||||||
List<ForwardReportVO> convertBomList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
|
||||||
}, bomList);
|
|
||||||
|
|
||||||
sumLevel(convertBomList);
|
|
||||||
List<ForwardReportVO> rootList;
|
|
||||||
//转化为树结构
|
|
||||||
rootList = showDataStyle(convertBomList, parentFormal.getRowId());
|
|
||||||
|
|
||||||
return buildReportBomVo(forwardReportVO,rootList,query.getDataType());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 汇总
|
|
||||||
* 1. 查询所有不含子级的物料信息,并对数据进行汇总。
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ReportBomVO sumReport() {
|
|
||||||
|
|
||||||
BomNewOriginalParentEntity parentFormal = getParent();
|
|
||||||
|
|
||||||
|
|
||||||
ForwardReportVO forwardReportVO = Convert.convert(ForwardReportVO.class, parentFormal);
|
|
||||||
forwardReportVO.setCreatedTime(parentFormal.getConvertToEbomTime());
|
|
||||||
|
|
||||||
List<BomOriginalListVO> bomList = bomDetailList(parentFormal.getRowId());
|
|
||||||
List<ForwardReportVO> convertBomList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
|
||||||
}, bomList);
|
|
||||||
|
|
||||||
sumLevel(convertBomList);
|
|
||||||
|
|
||||||
//无子级的数据
|
|
||||||
List<ForwardReportVO> sumList =leafMergeMaterialNo(convertBomList);
|
|
||||||
int noNum=1;
|
|
||||||
for (ForwardReportVO vo :
|
|
||||||
sumList) {
|
|
||||||
vo.setOrderNumber(noNum+"");noNum++;
|
|
||||||
|
|
||||||
}
|
|
||||||
return buildReportBomVo(forwardReportVO,sumList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ReportBomVO genReport() {
|
|
||||||
//单层
|
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SINGLE.getValue()) == 0) {
|
|
||||||
return singleReport();
|
|
||||||
}
|
|
||||||
//多层
|
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
|
||||||
return multiReport();
|
|
||||||
}
|
|
||||||
//汇总
|
|
||||||
if (query.getQueryType().compareTo(ReportConstant.QueryTypeEnum.SUM.getValue()) == 0) {
|
|
||||||
return sumReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue