Mbom正查
This commit is contained in:
parent
0c55aa1734
commit
20b66b6d4c
|
|
@ -5,4 +5,7 @@ public class MaterialMainConstant {
|
|||
public static String keyDrawingNo= "DrawingNo";
|
||||
|
||||
public static final String VIRTUAL="V";
|
||||
|
||||
public static final String MaterialNo_31="31";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,21 @@ public class ReportConstant {
|
|||
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum TagEnum implements ValueEnum<Integer> {
|
||||
|
||||
//比对
|
||||
SIGMA (1, "Σ汇总"),
|
||||
EQ(2, "相等"),
|
||||
N_EQ(3, "不相等"),
|
||||
L_N(4, "左有右无"),
|
||||
N_R(5, "左无右有");
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ public interface BomNewMbomParentMapper extends BaseMapper<BomNewMbomParentEntit
|
|||
|
||||
/**
|
||||
* 下级
|
||||
* @param rowId
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
List<BomNewMbomMiddleVO> getParentChild(@Param("rowId") Long rowId ,@Param("bomRowId") Long bomRowId);
|
||||
List<BomNewMbomMiddleVO> getParentChild(@Param("rowIdList") List<Long> rowIdList ,@Param("bomRowId") Long bomRowId);
|
||||
|
||||
BomNewMbomMiddleVO getParentById(@Param("rowId") Long rowId );
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,18 @@ public class BomNewMbomMiddleVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "bom版本行ID,和mbom_parent表row_id关联")
|
||||
private Long bomRowId;
|
||||
|
||||
|
||||
private Long bomVersionRowId;
|
||||
|
||||
public Long getBomVersionRowId(){
|
||||
|
||||
if(bomExist>0){
|
||||
return rowId;
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 父级行ID
|
||||
*/
|
||||
|
|
@ -121,6 +133,9 @@ public class BomNewMbomMiddleVO extends BaseMaterialVO implements Serializable {
|
|||
@ApiModelProperty(value = "1、待发布(sap)、3=已发布")
|
||||
private Integer status;
|
||||
|
||||
private String bomMaterialNo;
|
||||
|
||||
|
||||
/**
|
||||
* 发布sap人员
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -63,8 +63,12 @@ public class ForwardReportVO extends BaseMaterialVO {
|
|||
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "标记: 0-忽略 1-汇总")
|
||||
private Integer tag=0;
|
||||
|
||||
|
||||
private List<ForwardReportVO> childNodes = Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.product.bomnew.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
|
@ -16,6 +17,8 @@ import com.nflg.product.bomnew.service.domain.MBom.IndexListTree;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -115,7 +118,9 @@ public class BomNewMbomParentService extends ServiceImpl<BomNewMbomParentMapper,
|
|||
if (Objects.equals(dto.getRowId(), dto.getBomRowId())) {
|
||||
_rowId = 0l;
|
||||
}
|
||||
List<BomNewMbomMiddleVO> listChild = this.getBaseMapper().getParentChild(_rowId,dto.getBomRowId());
|
||||
List<Long> rowIds= Arrays.asList(_rowId);
|
||||
|
||||
List<BomNewMbomMiddleVO> listChild = this.getBaseMapper().getParentChild(rowIds,dto.getBomRowId());
|
||||
if (CollectionUtil.isNotEmpty(listChild)) {
|
||||
listChild.forEach(child -> {
|
||||
IndexListTree.sysnParentParam(parent, child);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
|
|||
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.EBomForwardReport;
|
||||
import com.nflg.product.bomnew.service.domain.MBom.MBomForwardReport;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomForwardReport;
|
||||
import com.nflg.product.bomnew.service.domain.PBom.PBomForwardReport;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
|
|
@ -50,7 +51,10 @@ public class ForwardReportService {
|
|||
}
|
||||
//MBOM
|
||||
if (query.getBomType().compareTo(ReportConstant.BomTypeEnum.MBOM.getValue()) == 0) {
|
||||
return null;
|
||||
MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
|
||||
|
||||
|
||||
return mBomForwardReport.bomVersion();
|
||||
}
|
||||
|
||||
VUtils.isTure(true).throwMessage("错误的BOM类型");
|
||||
|
|
@ -221,7 +225,8 @@ public class ForwardReportService {
|
|||
}
|
||||
|
||||
ReportBomVO queryMBom(ReverseReportQuery query) {
|
||||
return null;
|
||||
MBomForwardReport mBomForwardReport=new MBomForwardReport(query);
|
||||
return mBomForwardReport.genReport();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public abstract class BaseForwardReport {
|
|||
for (int index = 1; index < valueList.size(); index++) {
|
||||
item0.setNum(item0.getNum().add(valueList.get(index).getNum()));
|
||||
}
|
||||
item0.setTag(1);
|
||||
}
|
||||
sumList.add(item0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,302 @@
|
|||
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.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
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.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.domain.BaseForwardReport;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* BOM查看、反查、对比,用户选择了MBOM时,不需要使用版本信息查询(隐藏版本策略、指定版本号和有效性)。
|
||||
* BOM查看时,用户选择了MBOM时,遇到相同的编码时,要全部显示,在表格中多加一个备注栏,备注栏的内容为31编码。其它BOM查看的时候,备注为空
|
||||
*/
|
||||
public class MBomForwardReport extends BaseForwardReport {
|
||||
|
||||
public MBomForwardReport(ReverseReportQuery query) {
|
||||
super(query);
|
||||
init();
|
||||
}
|
||||
|
||||
AtomicInteger orderNum = new AtomicInteger();
|
||||
private List<BomNewMbomParentEntity> rootEntity;
|
||||
|
||||
|
||||
private List<BomNewMbomDetailEntity> detailEntity;
|
||||
|
||||
private BomNewMbomParentEntity rootNode;
|
||||
|
||||
void init() {
|
||||
if (query.getMaterialNo().startsWith(MaterialMainConstant.MaterialNo_31)) {
|
||||
QueryWrapper<BomNewMbomParentEntity> queryParentWrapper = new QueryWrapper<>();
|
||||
queryParentWrapper.lambda().eq(BomNewMbomParentEntity::getMaterialNo, query.getMaterialNo());
|
||||
if (StrUtil.isNotEmpty(query.getFacCode())) {
|
||||
queryParentWrapper.lambda().eq(BomNewMbomParentEntity::getFacCode, query.getFacCode());
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} 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());
|
||||
}
|
||||
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();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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)) {
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
ReportBomVersionVO reportBomVersionVO = new ReportBomVersionVO();
|
||||
reportBomVersionVO.setMaterialDesc(desc);
|
||||
return reportBomVersionVO;
|
||||
|
||||
}
|
||||
|
||||
|
||||
ForwardReportVO getParent() {
|
||||
|
||||
if (CollUtil.isEmpty(rootEntity) && CollUtil.isEmpty(detailEntity)) {
|
||||
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));
|
||||
}
|
||||
return forwardReportVO;
|
||||
}
|
||||
|
||||
|
||||
List<ForwardReportVO> convertToReportData(List<BomNewMbomMiddleVO> childList, int levelNum) {
|
||||
|
||||
for (BomNewMbomMiddleVO item:
|
||||
childList) {
|
||||
|
||||
Long bomRowId=item.getBomRowId();
|
||||
item.setRemark(item.getBomMaterialNo());
|
||||
item.setBomRowId(item.getBomVersionRowId());
|
||||
item.setLevelNum(levelNum);
|
||||
item.setOrderNumber(orderNum.incrementAndGet() + "");
|
||||
if (item.getParentRowId().longValue() == 0l) {
|
||||
item.setParentRowId(bomRowId);
|
||||
// item.setBomVersionRowId(item.getBomRowId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<ForwardReportVO> nodeList = Convert.convert(new TypeReference<List<ForwardReportVO>>() {
|
||||
}, childList);
|
||||
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
|
||||
List<ForwardReportVO> queryDetail(boolean isMore, Long rowId, Long bomRowId) {
|
||||
|
||||
int levelNum = 1;
|
||||
List<Long> rowIdList = new ArrayList<>( Arrays.asList(rowId) );
|
||||
List<ForwardReportVO> reportVOList = new ArrayList<>();
|
||||
orderNum.set(0);
|
||||
while (!rowIdList.isEmpty()) {
|
||||
List<BomNewMbomMiddleVO> childList = SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().getParentChild(rowIdList, bomRowId);
|
||||
rowIdList.clear();
|
||||
if (CollUtil.isNotEmpty(childList)) {
|
||||
reportVOList.addAll(convertToReportData(childList, levelNum));
|
||||
levelNum++;
|
||||
|
||||
if (isMore) {
|
||||
List<Long> nextBomId = childList.stream().filter(u -> u.getBomVersionRowId() != null && u.getBomVersionRowId() > 0).map(BomNewMbomMiddleVO::getBomVersionRowId).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(nextBomId)) {
|
||||
rowIdList.addAll(nextBomId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return reportVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isMore 是否多层查
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
|
||||
} else if (CollUtil.isNotEmpty(detailEntity)) { // detail表搜索
|
||||
for (BomNewMbomDetailEntity item : detailEntity) {
|
||||
Long rowId = item.getRowId();
|
||||
listMap.put(item.getRowId(), queryDetail(isMore, rowId, item.getBomRowId()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return listMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单层
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ReportBomVO singleReport() {
|
||||
|
||||
List<ForwardReportVO> nodeList = new ArrayList<>();
|
||||
ForwardReportVO forwardReportVO = getParent();
|
||||
Map<Long, List<ForwardReportVO>> listMap = queryReport(false);
|
||||
listMap.forEach((key, data) -> {
|
||||
nodeList.addAll(data);
|
||||
});
|
||||
|
||||
return buildReportBomVo(forwardReportVO, nodeList);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总
|
||||
* @return
|
||||
*/
|
||||
ReportBomVO sumReport() {
|
||||
|
||||
ForwardReportVO forwardReportVO = getParent();
|
||||
Map<Long, List<ForwardReportVO>> listMap = queryReport(true);
|
||||
List<ForwardReportVO> allList=new ArrayList<>();
|
||||
listMap.forEach((key,list)->{
|
||||
|
||||
sumLevel(list);
|
||||
List<ForwardReportVO> sumList =leafMergeMaterialNo(list);
|
||||
allList.addAll(sumList);
|
||||
});
|
||||
|
||||
int noNum=1;
|
||||
for(ForwardReportVO vo:allList){
|
||||
vo.setOrderNumber(noNum+"");noNum++;
|
||||
}
|
||||
|
||||
return buildReportBomVo(forwardReportVO,allList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 多层
|
||||
* @return
|
||||
*/
|
||||
ReportBomVO multiReport() {
|
||||
ForwardReportVO forwardReportVO = getParent();
|
||||
|
||||
Map<Long, List<ForwardReportVO>> listMap = queryReport(true);
|
||||
List<ForwardReportVO> allList=new ArrayList<>();
|
||||
listMap.forEach((key,list)->{
|
||||
|
||||
sumLevel(list);
|
||||
List<ForwardReportVO> nodeList = showDataStyle(list, key);
|
||||
allList.addAll(nodeList);
|
||||
});
|
||||
|
||||
return buildReportBomVo(forwardReportVO,allList,query.getDataType());
|
||||
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -107,13 +107,18 @@
|
|||
<!-- </select>-->
|
||||
|
||||
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO">
|
||||
select t1.*,t2.status,
|
||||
select t1.*,t2.status,t2.material_no as bomMaterialNo,
|
||||
(SELECT count(1) from t_bom_new_mbom_detail where parent_row_id=t1.row_id) as bom_exist
|
||||
from t_bom_new_mbom_detail as t1
|
||||
left join t_bom_new_mbom_parent as t2
|
||||
on
|
||||
t1.bom_row_id=t2.row_id
|
||||
where t1.parent_row_id = #{rowId}
|
||||
where t1.parent_row_id in
|
||||
<foreach collection="rowIdList" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
||||
|
||||
<if test="bomRowId!=null and bomRowId!=0">
|
||||
and t1.bom_row_id=#{bomRowId}
|
||||
</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue