optimize(ebom反查): 修复一些问题;数量限制为1000条

This commit is contained in:
曹鹏飞 2024-06-26 10:06:17 +08:00
parent e64860e506
commit 80d321c4b2
3 changed files with 44 additions and 16 deletions

View File

@ -15,11 +15,11 @@ import java.util.Objects;
@Data
public class ReverseReportVO {
@ApiModelProperty("bom-rowId(parent表)")
private Long rowId;
// @ApiModelProperty("bom-rowId(parent表)")
// private Long rowId;
@ApiModelProperty("层级")
private String orderNumber;
// @ApiModelProperty("层级")
// private String orderNumber;
@ApiModelProperty("图号")
private String drawingNo;
@ -33,8 +33,8 @@ public class ReverseReportVO {
@ApiModelProperty("项目类别")
private String projectType;
@ApiModelProperty("物料类别名称")
private String materialCategoryName;
// @ApiModelProperty("物料类别名称")
// private String materialCategoryName;
@ApiModelProperty("物料描述")
private String materialDesc;
@ -54,11 +54,11 @@ public class ReverseReportVO {
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
private LocalDateTime expireEndTime;
@ApiModelProperty("是否子级 0-否 1-是")
private Integer childIs;
@ApiModelProperty("父级行ID")
private Long parentRowId;
// @ApiModelProperty("是否子级 0-否 1-是")
// private Integer childIs;
//
// @ApiModelProperty("父级行ID")
// private Long parentRowId;
@ApiModelProperty("子级报表")
private String childDrawingNo;

View File

@ -3,12 +3,14 @@ package com.nflg.product.bomnew.service.domain.ReverseReport;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.constant.OriginalConstant;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity;
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
import com.nflg.product.bomnew.util.VUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,12 +45,18 @@ public class EBomQueryService {
@Resource
MaterialMainService materialMainService;
private static final ThreadLocal<Boolean> ADD = new ThreadLocal<>();
public void report(ReverseReportQuery queryParam , List<ReverseReportVO> result) {
if(queryParam.getQueryType().equals(0)) {
result.addAll(singleLevelReport(queryParam));
}else {
result.addAll(multipleLevelReport(queryParam));
try {
ADD.set(true);
result.addAll(multipleLevelReport(queryParam));
} finally {
ADD.remove();
}
}
}
@ -100,7 +108,20 @@ public class EBomQueryService {
}
if (StrUtil.isBlank(version)) {
List<BomNewPbomParentVO> pVOs = ebomChildFormalService.getSuperiorByMaterialNo(queryParam.getMaterialNo());
List<String> materialNos = pVOs.stream().map(BomNewPbomParentVO::getMaterialNo).collect(Collectors.toList());
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(materialNos);
pVOs.forEach(p -> {
if (!ADD.get()) return;
BaseMaterialVO materialMainEntity = materialVOS.stream()
.filter(m -> StrUtil.equals(m.getMaterialNo(), p.getMaterialNo()))
.findFirst()
.orElse(null);
if (Objects.nonNull(materialMainEntity)) {
if (MaterialshouldBomExistUtil.checkShouldBomExist(materialMainEntity.getMaterialCategoryCode()
, materialMainEntity.getMaterialGetType())) {
p.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
}
}
vos.add(createVO(p, 1));
bindData(p, 1, vos);
});
@ -113,6 +134,7 @@ public class EBomQueryService {
List<BomNewPbomParentVO> pVOs = getSuperiors(parent.getRowId());
pVOs.forEach(p -> {
if (!ADD.get()) return;
vos.add(createVO(p, 1));
bindData(p, 1, vos);
});
@ -136,14 +158,20 @@ public class EBomQueryService {
}
private void bindData(BomNewPbomParentVO pVO, Integer level, List<ReverseReportVO> vos) {
if (!ADD.get()) return;
if (Objects.nonNull(pVO.getParentRowId())) {
List<BomNewPbomParentVO> parents = getSuperiors(pVO.getParentRowId());
level++;
Integer finalLevel = level;
parents.forEach(it -> {
for (BomNewPbomParentVO it : parents) {
if (!ADD.get()) return;
vos.add(createVO(it, finalLevel));
if (vos.size() >= 1000) {
ADD.set(false);
return;
}
bindData(it, finalLevel, vos);
});
}
}
}

View File

@ -51,9 +51,9 @@
</foreach>
</select>
<select id="getSuperiorByMaterialNo" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT cf.num, cf.project_type, cf.parent_row_id parentRowId, pf.*
SELECT pf.row_id parentRowId, pf.expire_end_time, pf.current_version, cf.*
FROM t_bom_new_ebom_child_formal cf
INNER JOIN t_bom_new_ebom_parent_formal pf ON cf.bom_version_row_id = pf.row_id
INNER JOIN t_bom_new_ebom_parent_formal pf ON cf.parent_row_id = pf.row_id
WHERE cf.material_no = #{materialNo}
</select>