报表树形查询
This commit is contained in:
parent
96702f5e35
commit
1029cffc09
|
|
@ -48,6 +48,22 @@ public class ReportConstant {
|
|||
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum DataTypeEnum implements ValueEnum<Integer> {
|
||||
|
||||
//0-树形状 1-列表
|
||||
TREE(0, "树形"),
|
||||
LIST(1, "列表");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentFormalVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
|
||||
|
|
@ -20,5 +21,7 @@ import java.util.Set;
|
|||
*/
|
||||
public interface BomNewEbomParentFormalMapper extends BaseMapper<BomNewEbomParentFormalEntity > {
|
||||
|
||||
List<BomNewEbomParentFormalVO> getParentChild(@Param("rowId") Long rowId);
|
||||
|
||||
List<BomNewEbomParentFormalVO> getParentChildBatch(@Param("rowIds") List<Long> rowIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,4 +40,8 @@ public class ReverseReportQuery {
|
|||
@ApiModelProperty("有效性-结束时间")
|
||||
private String endDate;
|
||||
|
||||
|
||||
@ApiModelProperty("数据显示方式 0-树形状 1-列表")
|
||||
private Integer dataType;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,328 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_parent
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-12-14 10:49:36
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-vo-BomNewEbomParentFormalEntityVO")
|
||||
public class BomNewEbomParentFormalVO extends BaseMaterialVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键行ID-雪花
|
||||
*/
|
||||
@ApiModelProperty(value = "主键行ID-雪花")
|
||||
private Long rowId;
|
||||
|
||||
/**
|
||||
* 批号-来自plm-临时
|
||||
*/
|
||||
@ApiModelProperty(value = "批号-来自plm-临时")
|
||||
private String batchNo;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("物料BOM版本ID")
|
||||
private Long bomRowId=0L;
|
||||
|
||||
@ApiModelProperty("父级行ID")
|
||||
private Long parentRowId=0L;
|
||||
|
||||
|
||||
@ApiModelProperty("物料bom行ID")
|
||||
private Long childBomRowId;
|
||||
|
||||
|
||||
/**
|
||||
* 排序号
|
||||
*/
|
||||
@ApiModelProperty(value = "排序号")
|
||||
private String orderNumber;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 单重
|
||||
*/
|
||||
@ApiModelProperty(value = "单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
/**
|
||||
* 总重
|
||||
*/
|
||||
@ApiModelProperty(value = "总重")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
@ApiModelProperty(value = "版本号")
|
||||
private String currentVersion;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
/**
|
||||
* 来源1-原BOM转换 2-EXCE导入 3-MDM创建
|
||||
*/
|
||||
@ApiModelProperty(value = "来源1-原BOM转换 2-EXCE导入 3-MDM创建")
|
||||
private Integer source;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 项目类别输入方式: 0-自动匹配 1-手工录入 3-来自物料主数据 4-来自历史统计
|
||||
*/
|
||||
@ApiModelProperty(value = "项目类别输入方式: 0-自动匹配 1-手工录入 3-来自物料主数据 4-来自历史统计")
|
||||
private Integer projectTypeInputType;
|
||||
|
||||
/**
|
||||
* 是否跟节点 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否跟节点 0-否 1-是")
|
||||
private Integer rootIs;
|
||||
|
||||
/**
|
||||
* 是否应该有BOM 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否应该有BOM 0-否 1-是")
|
||||
private Integer shouldBomExist;
|
||||
|
||||
/**
|
||||
* 超级物料 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "超级物料 0-否 1-是")
|
||||
private Integer superMaterialStatus;
|
||||
|
||||
/**
|
||||
* 是否有BOM: 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
|
||||
private Integer bomExist;
|
||||
|
||||
|
||||
public Integer getBomExist(){
|
||||
if(Objects.isNull(bomExist)){
|
||||
bomExist=0;
|
||||
}
|
||||
return bomExist;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否最新版:0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否最新版:0-否 1-是")
|
||||
private Integer lastVersionIs;
|
||||
|
||||
/**
|
||||
* 1=待处理、2=已处理
|
||||
*/
|
||||
@ApiModelProperty(value = "1=待处理、2=已处理")
|
||||
private Integer editStatus;
|
||||
|
||||
/**
|
||||
* 1=待复核、2=已复核、3=已退回、4=定版(已发布PBOM)
|
||||
*/
|
||||
@ApiModelProperty(value = "1=待复核、2=已复核、3=已退回、4=定版(已发布PBOM)99=借用件 100=引用件")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否用户跟节点 0-否 1-是
|
||||
*/
|
||||
@ApiModelProperty(value = "是否用户跟节点 0-否 1-是")
|
||||
private Integer userRootIs;
|
||||
|
||||
/**
|
||||
* 异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常
|
||||
*/
|
||||
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常 7=物料主数据不存在 8=项目类别为空 9=项目赋值异常(父级物料的项目类型为Q时,子级中不能存在项目类别为Q的物料) 10=项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料) 11=未填写变更原因和技术通知单 12=数量需要用户确认 13=项目类型需要用户确认")
|
||||
private Integer exceptionStatus;
|
||||
|
||||
/**
|
||||
* 来源行ID(原始BOM中的行ID)
|
||||
*/
|
||||
@ApiModelProperty(value = "来源行ID(原始BOM中的行ID)")
|
||||
private Long sourceRowId;
|
||||
|
||||
/**
|
||||
* 设计人员编码
|
||||
*/
|
||||
@ApiModelProperty(value = "设计人员编码")
|
||||
private String deviseUserCode;
|
||||
|
||||
/**
|
||||
* 设计人员名称
|
||||
*/
|
||||
@ApiModelProperty(value = "设计人员名称")
|
||||
private String deviseName;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建人编码
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人编码")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
/**
|
||||
* 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
|
||||
private Integer createdJob;
|
||||
|
||||
/**
|
||||
* 复核时间
|
||||
*/
|
||||
@ApiModelProperty(value = "复核时间")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
/**
|
||||
* 复核人
|
||||
*/
|
||||
@ApiModelProperty(value = "复核人")
|
||||
private String auditUserName;
|
||||
|
||||
/**
|
||||
* 发布时间
|
||||
*/
|
||||
@ApiModelProperty(value = "发布时间")
|
||||
private LocalDateTime releaseTime;
|
||||
|
||||
/**
|
||||
* 发布人
|
||||
*/
|
||||
@ApiModelProperty(value = "发布人")
|
||||
private String releaseUserName;
|
||||
|
||||
/**
|
||||
* 退回时间
|
||||
*/
|
||||
@ApiModelProperty(value = "退回时间")
|
||||
private LocalDateTime revertTime;
|
||||
|
||||
/**
|
||||
* 退回人
|
||||
*/
|
||||
@ApiModelProperty(value = "退回人")
|
||||
private String revertUserName;
|
||||
|
||||
/**
|
||||
* 版本过期时间=下个版本的创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
|
||||
public LocalDateTime getExpireEndTime(){
|
||||
// new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("9999-12-31 23:59:59");
|
||||
|
||||
return LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换pbom时间
|
||||
*/
|
||||
@ApiModelProperty(value = "转换pbom时间")
|
||||
private LocalDateTime convertToEbomTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 设计维护部门名称
|
||||
*/
|
||||
@ApiModelProperty(value = "设计维护部门名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* bom树的高度
|
||||
*/
|
||||
@ApiModelProperty(value = "bom树的高度")
|
||||
private Integer levelNum;
|
||||
|
||||
/**
|
||||
* 升版说明
|
||||
*/
|
||||
@ApiModelProperty(value = "升版说明")
|
||||
private String changeDesc;
|
||||
|
||||
/**
|
||||
* 通知单号
|
||||
*/
|
||||
@ApiModelProperty(value = "通知单号")
|
||||
private String noticeNums;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
@ApiModelProperty("bom层级数")
|
||||
private BigDecimal levelNumber;
|
||||
|
||||
@ApiModelProperty("层级号如:1-1")
|
||||
private String levelNo;
|
||||
|
||||
@ApiModelProperty("来源行-父项物料编码")
|
||||
private String sourceParentMaterialNo;
|
||||
|
||||
@ApiModelProperty("是否虚拟包 0-否 1-是")
|
||||
private Integer virtualPackageIs;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("是否虚拟件")
|
||||
private Integer virtualPartIs;
|
||||
|
||||
@ApiModelProperty("0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
|
||||
private Integer virtualPartType=0;
|
||||
|
||||
@ApiModelProperty("生成虚拟包的跟节点物料编码")
|
||||
private String virtualPartRootMaterialNo;
|
||||
|
||||
|
||||
|
||||
|
||||
private List<BomNewEbomParentFormalVO> childNodes = Collections.emptyList();
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,76 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class ForwardReportVO extends ReverseReportVO{
|
||||
public class ForwardReportVO extends BaseMaterialVO {
|
||||
|
||||
@ApiModelProperty("行id")
|
||||
private Long rowId=0L;
|
||||
|
||||
@ApiModelProperty("BOM版本ID")
|
||||
private Long bomRowId=0L;
|
||||
|
||||
@ApiModelProperty("父级行ID")
|
||||
private Long parentRowId=0L;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("排序号")
|
||||
private String orderNumber;
|
||||
|
||||
@ApiModelProperty("层级")
|
||||
private Integer levelNum;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("版本号")
|
||||
private String currentVersion;
|
||||
|
||||
// @ApiModelProperty("项目类别")
|
||||
// private String projectType;
|
||||
// @ApiModelProperty("物料编码")
|
||||
// private String materialNo;
|
||||
// @ApiModelProperty("物料类别名称")
|
||||
// private String materialCategoryName;
|
||||
//
|
||||
// @ApiModelProperty("物料描述")
|
||||
// private String materialDesc;
|
||||
// @ApiModelProperty("单位")
|
||||
// private String materialUnit;
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "创建人编码")
|
||||
private String createdBy;
|
||||
|
||||
@ApiModelProperty(value = "创建时间-有效开始时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
|
||||
private LocalDateTime expireEndTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private List<ForwardReportVO> childNodes = Collections.emptyList();
|
||||
public LocalDateTime getExpireEndTime(){
|
||||
return Objects.isNull(expireEndTime)? LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")):expireEndTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,13 +75,8 @@ public class ForwardReportService {
|
|||
|
||||
|
||||
ReportBomVO queryEBom(ReverseReportQuery query) {
|
||||
|
||||
|
||||
EBomForwardReport eBomForwardReport = new EBomForwardReport(query);
|
||||
|
||||
return eBomForwardReport.genReport();
|
||||
|
||||
|
||||
}
|
||||
|
||||
ReportBomVO queryPBom(ReverseReportQuery query) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentFormalVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentFormalService;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class EBomFormalTreeTask extends RecursiveTask<List<BomNewEbomParentFormalVO>> {
|
||||
|
||||
private List<BomNewEbomParentFormalVO> bomDetail;
|
||||
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static int levelNum=1;
|
||||
|
||||
List<BomNewEbomParentFormalVO> result = new ArrayList<>();
|
||||
|
||||
public EBomFormalTreeTask(List<BomNewEbomParentFormalVO> inBomDetail) {
|
||||
bomDetail = inBomDetail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理BOM明细中未选择Bom版本的明细;使用最新版
|
||||
*/
|
||||
public void handlerChildBomVersionDetail() {
|
||||
|
||||
|
||||
for (BomNewEbomParentFormalVO vo:
|
||||
bomDetail ) {
|
||||
vo.setLevelNum(levelNum);
|
||||
}
|
||||
|
||||
List<Long> bomRowIds=bomDetail.stream().filter(u -> u.getBomRowId()>0 ).map(BomNewEbomParentFormalVO::getBomRowId).collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(bomRowIds)) {
|
||||
|
||||
List<BomNewEbomParentFormalEntity > bomlist = SpringUtil.getBean(BomNewEbomParentFormalService.class ).lambdaQuery().in(BomNewEbomParentFormalEntity::getRowId, bomRowIds).list();
|
||||
Map<Long, BomNewEbomParentFormalEntity> parentEntityMap = ListCommonUtil.listToMap(bomlist, BomNewEbomParentFormalEntity::getRowId);
|
||||
for (BomNewEbomParentFormalVO detailVO : bomDetail) {
|
||||
if (parentEntityMap.containsKey(detailVO.getBomRowId())) {
|
||||
BomNewEbomParentFormalEntity ebomParentEntity = parentEntityMap.get(detailVO.getBomRowId());
|
||||
detailVO.setChildBomRowId(ebomParentEntity.getRowId());
|
||||
// detailVO.setBomRowId(ebomParentEntity.getRowId());
|
||||
detailVO.setSourceRowId(ebomParentEntity.getSourceRowId());
|
||||
detailVO.setCurrentVersion(ebomParentEntity.getCurrentVersion());
|
||||
detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode());
|
||||
detailVO.setDeptName(ebomParentEntity.getDeptName());
|
||||
detailVO.setDeviseName(ebomParentEntity.getDeviseName());
|
||||
detailVO.setBomExist(ebomParentEntity.getBomExist());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归调用零部件BOM
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected List<BomNewEbomParentFormalVO > compute() {
|
||||
|
||||
handlerChildBomVersionDetail();
|
||||
// 最新 BOM 版本
|
||||
result.addAll(bomDetail);
|
||||
|
||||
if (CollUtil.isNotEmpty(bomDetail)) {
|
||||
levelNumAdd();
|
||||
List<Long> childBowIds = bomDetail.stream().filter(u-> u.getBomRowId()!=null && u.getBomRowId() > 0).map(u->u.getBomRowId()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(childBowIds)) {
|
||||
List<BomNewEbomParentFormalVO> bom = SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChildBatch(childBowIds);
|
||||
EBomFormalTreeTask task = new EBomFormalTreeTask(bom);
|
||||
task.fork();
|
||||
bomDetail.addAll(task.join());
|
||||
return bomDetail;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public synchronized void levelNumAdd(){
|
||||
levelNum++;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,27 +2,33 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildFormalEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentFormalEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.ReverseReportQuery;
|
||||
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.pojo.vo.*;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomChildFormalService;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentFormalService;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EBomForwardReport {
|
||||
|
||||
|
|
@ -39,7 +45,10 @@ public class EBomForwardReport {
|
|||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getDrawingNo,query.getDrawingNo());
|
||||
}
|
||||
if(query.getVersionStrategy().compareTo(ReportConstant.VersionStrategyEnum.NEW.getValue()) ==0){
|
||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getLastVersionIs,1);
|
||||
// queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getLastVersionIs,1);
|
||||
|
||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getCurrentVersion,getMaxVersion());
|
||||
|
||||
}else {
|
||||
queryWrapper.lambda().eq(BomNewEbomParentFormalEntity::getCurrentVersion,query.getBomVersion());
|
||||
}
|
||||
|
|
@ -63,8 +72,25 @@ public class EBomForwardReport {
|
|||
}
|
||||
|
||||
BomNewEbomParentFormalEntity parentFormal=list.get(0);
|
||||
parentFormal.setLevelNum(null);
|
||||
parentFormal.setOrderNumber(null);
|
||||
return parentFormal;
|
||||
}
|
||||
public String getMaxVersion(){
|
||||
ReportBomVersionVO reportBomVersionVO= bomVersion();
|
||||
if(reportBomVersionVO.getVList().size()==1){
|
||||
return reportBomVersionVO.getVList().get(0).getVersion();
|
||||
}
|
||||
|
||||
String maxVersion=reportBomVersionVO.getVList().get(0).getVersion();
|
||||
for(int index=1;index<reportBomVersionVO.getVList().size();index++){
|
||||
String version=reportBomVersionVO.getVList().get(index).getVersion();
|
||||
if(VersionUtil.compare(version,maxVersion)>0){
|
||||
maxVersion=version;
|
||||
}
|
||||
}
|
||||
return maxVersion;
|
||||
}
|
||||
|
||||
ReportBomVO singleReport(){
|
||||
|
||||
|
|
@ -85,7 +111,7 @@ public class EBomForwardReport {
|
|||
for (ForwardReportVO vo:
|
||||
nodeList ) {
|
||||
vo.setCreatedTime(reportBomVO.getParent().getCreatedTime());
|
||||
vo.setOrderNumber("");
|
||||
// vo.setOrderNumber("");
|
||||
}
|
||||
reportBomVO.setChildNodes(nodeList);
|
||||
}
|
||||
|
|
@ -95,21 +121,6 @@ public class EBomForwardReport {
|
|||
}
|
||||
|
||||
|
||||
public String getMaxVersion(){
|
||||
ReportBomVersionVO reportBomVersionVO= bomVersion();
|
||||
if(reportBomVersionVO.getVList().size()==1){
|
||||
return reportBomVersionVO.getVList().get(0).getVersion();
|
||||
}
|
||||
|
||||
String maxVersion=reportBomVersionVO.getVList().get(0).getVersion();
|
||||
for(int index=1;index<reportBomVersionVO.getVList().size();index++){
|
||||
String version=reportBomVersionVO.getVList().get(index).getVersion();
|
||||
if(VersionUtil.compare(version,maxVersion)>0){
|
||||
maxVersion=version;
|
||||
}
|
||||
}
|
||||
return maxVersion;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -142,17 +153,99 @@ public class EBomForwardReport {
|
|||
return reportBomVersionVO;
|
||||
}
|
||||
|
||||
ReportBomVO multiReport(){
|
||||
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> childList=SpringUtil.getBean(BomNewEbomParentFormalService.class).getBaseMapper().getParentChild(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>>() {
|
||||
},bomList);
|
||||
// System.out.println(JSON.toJSONString(bomList));
|
||||
|
||||
sumLevel(convertBomList);
|
||||
//分组数据
|
||||
List<ForwardReportVO> rootList= listToTree(convertBomList, parentFormal.getRowId());
|
||||
|
||||
sumLevel(rootList);
|
||||
// System.out.println(JSON.toJSONString(rootList));
|
||||
reportBomVO.setChildNodes(rootList);
|
||||
return reportBomVO;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void sumLevel(List<ForwardReportVO> bomList){
|
||||
|
||||
Map<Integer, List<ForwardReportVO>> listMap=bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getLevelNum));
|
||||
Map<Long, List<ForwardReportVO>> bomParentMap=bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId));
|
||||
listMap.forEach((key,value)-> {
|
||||
|
||||
value.forEach(parent->{
|
||||
|
||||
List<ForwardReportVO> dataList=bomParentMap.get(parent.getBomRowId());
|
||||
if(CollectionUtil.isNotEmpty(dataList)){
|
||||
for (ForwardReportVO data:
|
||||
dataList) {
|
||||
data.setNum(parent.getNum().multiply(data.getNum()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<ForwardReportVO> listToTree( List<ForwardReportVO> bomList,Long parentRowId){
|
||||
|
||||
Map<Long, List<ForwardReportVO>> listMap=bomList.stream().collect(Collectors.groupingBy(ForwardReportVO::getParentRowId));
|
||||
|
||||
bomList.forEach(item -> {
|
||||
item.setChildNodes(listMap.get(item.getBomRowId()));
|
||||
});
|
||||
|
||||
List<ForwardReportVO> rootList= bomList.stream().filter(item ->Objects.equals(parentRowId,item.getParentRowId())).collect(Collectors.toList());
|
||||
|
||||
return rootList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,18 @@
|
|||
notice_nums, modify_time
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
<select id="getParentChildBatch" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentFormalVO">
|
||||
select *
|
||||
from t_bom_new_ebom_child_formal
|
||||
where parent_row_id in
|
||||
<foreach collection="rowIds" item="rowId" open="(" separator="," close=")">
|
||||
#{rowId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewEbomParentFormalVO">
|
||||
select *
|
||||
from t_bom_new_ebom_child
|
||||
where parent_row_id = #{rowId}
|
||||
order by order_number
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue