Merge remote-tracking branch 'origin/DM/10月需求'
# Conflicts: # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomReportApi.java # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/BomConstant.java # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/entity/BomNewPbomParentEntity.java # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewPbomParentVO.java # nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml
This commit is contained in:
commit
9bf3f65c5f
|
|
@ -13,6 +13,8 @@ import com.nflg.product.base.core.api.BaseApi;
|
||||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.base.core.vo.PageVO;
|
import com.nflg.product.base.core.vo.PageVO;
|
||||||
import com.nflg.product.bomnew.constant.ReportConstant;
|
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||||
|
import com.nflg.product.bomnew.pojo.dto.PdateLogDTO;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
|
||||||
import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO;
|
import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO;
|
||||||
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
|
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
|
||||||
import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
|
import com.nflg.product.bomnew.pojo.query.ChildBomReportQuery;
|
||||||
|
|
@ -27,12 +29,10 @@ import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import nflg.product.common.constant.STATE;
|
import nflg.product.common.constant.STATE;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.ttzero.excel.entity.ListSheet;
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -59,12 +59,14 @@ public class BomReportApi extends BaseApi {
|
||||||
@Resource
|
@Resource
|
||||||
MaterialMainService materialMainService;
|
MaterialMainService materialMainService;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("reverseReport")
|
@PostMapping("reverseReport")
|
||||||
@ApiOperation("bom-反查")
|
@ApiOperation("bom-反查")
|
||||||
public ResultVO<List<ReverseReportVO>> reverseReport(@Valid @RequestBody ReverseReportQuery query) {
|
public ResultVO<List<ReverseReportVO>> reverseReport(@Valid @RequestBody ReverseReportQuery query) {
|
||||||
|
|
||||||
VUtils.isTure(!ImmutableList.of(1,2).contains(query.getBomType())).throwMessage("只能查询EBom和PBom");
|
VUtils.isTure(!ImmutableList.of(1,2).contains(query.getBomType())).throwMessage("只能查询EBom和PBom");
|
||||||
VUtils.isTure(StrUtil.isBlank(query.getMaterialNo())).throwMessage("物料编码不能为空");
|
//图号查询
|
||||||
|
checkAndDrawingNoToMaterialNo(query);
|
||||||
if(query.getBomType().equals(1)){
|
if(query.getBomType().equals(1)){
|
||||||
return ResultVO.success(reverseReportService.queryEBom(query));
|
return ResultVO.success(reverseReportService.queryEBom(query));
|
||||||
}
|
}
|
||||||
|
|
@ -74,6 +76,39 @@ public class BomReportApi extends BaseApi {
|
||||||
return ResultVO.success();
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图号转物料编码
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private void checkAndDrawingNoToMaterialNo(ReverseReportQuery query){
|
||||||
|
VUtils.isTure(StrUtil.isBlank(query.getMaterialNo()) && StrUtil.isBlank(query.getDrawingNo())).throwMessage("请输入物料编码或图号");
|
||||||
|
if(StrUtil.isBlank(query.getMaterialNo()) && StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||||
|
List<MaterialMainEntity> materials = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(materials)).throwMessage("图号在物料库不存在");
|
||||||
|
query.setMaterialNo(materials.get(0).getMaterialNo());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理图号查询
|
||||||
|
* 1.当输入物料编码时,物料编码优先
|
||||||
|
* @param query
|
||||||
|
*/
|
||||||
|
private void handlerDrawingNoQuery(ReverseReportQuery query){
|
||||||
|
|
||||||
|
if(StrUtil.isBlank(query.getMaterialNo()) && StrUtil.isNotBlank(query.getDrawingNo())) {
|
||||||
|
List<MaterialMainEntity> materials = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
|
||||||
|
if(CollUtil.isNotEmpty(materials)) {
|
||||||
|
query.setMaterialNo(materials.get(0).getMaterialNo());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ResultVO checkQueryParam(ReverseReportQuery query) {
|
ResultVO checkQueryParam(ReverseReportQuery query) {
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
|
|
@ -131,6 +166,8 @@ public class BomReportApi extends BaseApi {
|
||||||
if (resultVO != null) {
|
if (resultVO != null) {
|
||||||
return resultVO;
|
return resultVO;
|
||||||
}
|
}
|
||||||
|
handlerDrawingNoQuery(query);
|
||||||
|
return ResultVO.success(forwardReportService.factoryBomType(query));
|
||||||
//物料描述从 物料主数据获取 by 10002327 240926
|
//物料描述从 物料主数据获取 by 10002327 240926
|
||||||
ReportBomVO r = forwardReportService.factoryBomType(query);
|
ReportBomVO r = forwardReportService.factoryBomType(query);
|
||||||
if(r == null){
|
if(r == null){
|
||||||
|
|
@ -145,6 +182,12 @@ public class BomReportApi extends BaseApi {
|
||||||
return ResultVO.success(r);
|
return ResultVO.success(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("getUpdateLog")
|
||||||
|
@ApiOperation("bom-变更记录(和上一版本对比)")
|
||||||
|
public ResultVO<List<UpdateLogVO>> getUpdateLog(@RequestBody PdateLogDTO pdateLogDTO) {
|
||||||
|
return ResultVO.success(forwardReportService.getUpdateLog(pdateLogDTO.getBomRowId(),pdateLogDTO.getBomType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("compareReport")
|
@PostMapping("compareReport")
|
||||||
@ApiOperation("bom-比对")
|
@ApiOperation("bom-比对")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.mzt.logapi.context.LogRecordContext;
|
import com.mzt.logapi.context.LogRecordContext;
|
||||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||||
import com.nflg.product.base.core.api.BaseApi;
|
import com.nflg.product.base.core.api.BaseApi;
|
||||||
|
|
@ -25,6 +26,7 @@ import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
import nflg.product.common.vo.ResultVO;
|
import nflg.product.common.vo.ResultVO;
|
||||||
import org.apache.commons.compress.utils.Lists;
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -35,10 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -439,4 +438,20 @@ public class PBomApi extends BaseApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("checkException")
|
||||||
|
@ApiOperation("PBOM-数据异常检查")
|
||||||
|
public ResultVO<Boolean> checkException(@RequestBody PBomCheckExceptionDTO checkExceptionDTO) {
|
||||||
|
VUtils.isTure(CollUtil.isEmpty(checkExceptionDTO.getBomRowIds())).throwMessage("请选择要检查的BOM");
|
||||||
|
List<BomNewPbomParentEntity> pBoms = bomNewPbomParentService.lambdaQuery().in(BomNewPbomParentEntity::getRowId, checkExceptionDTO.getBomRowIds()).list();
|
||||||
|
Set<Long> exitsBoms = pBoms.stream().map(u -> u.getRowId()).collect(Collectors.toSet());
|
||||||
|
Set<Long> noBomParams= Sets.difference(Sets.newHashSet(checkExceptionDTO.getBomRowIds()) , exitsBoms);
|
||||||
|
VUtils.isTure(CollUtil.isNotEmpty(noBomParams)).throwMessage(StrUtil.join(",", noBomParams)+ "PBom版本不存在,请检查参数是否正确.");
|
||||||
|
|
||||||
|
for(Long rowId : checkExceptionDTO.getBomRowIds()) {
|
||||||
|
bomNewPbomParentService.checkException(rowId, checkExceptionDTO.getBomType());
|
||||||
|
};
|
||||||
|
return ResultVO.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,8 @@ public class BomConstant {
|
||||||
|
|
||||||
//工艺包物料类别编码
|
//工艺包物料类别编码
|
||||||
public static final String ART_PACKAGE_MATERIAL_CATEGORY_CODE="201201";
|
public static final String ART_PACKAGE_MATERIAL_CATEGORY_CODE="201201";
|
||||||
|
|
||||||
|
public static final String ADD="新增";
|
||||||
|
public static final String UP="修改";
|
||||||
|
public static final String DEL="删除";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,9 +85,16 @@ public class ReportConstant {
|
||||||
|
|
||||||
//比对
|
//比对
|
||||||
EQ(1, "相等"),
|
EQ(1, "相等"),
|
||||||
NON_EQ(0, "不相等"),
|
// NON_EQ(0, "不相等"),
|
||||||
L_NULL(2, "左有右无"),
|
L_NULL(2, "左有右无"),
|
||||||
NULL_R(3, "左无右有");
|
NULL_R(3, "左无右有"),
|
||||||
|
NON_EQ_NUM(10, "数量不相等"),
|
||||||
|
NON_EQ_UNIT(11, "单位不相等"),
|
||||||
|
NON_EQ_PROJECT_TYPE(12, "项目类型不相等"),
|
||||||
|
NON_EQ_PARENT_MaterialNo(13, "父级物料编码不相等")
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PBomCheckExceptionDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("BOM版本ID")
|
||||||
|
private List<Long> bomRowIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("pbom类型: 0- pBom工作表 1-pBOM正式表")
|
||||||
|
private Integer bomType;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PdateLogDTO {
|
||||||
|
|
||||||
|
@ApiModelProperty("bom版本RowId")
|
||||||
|
private Long bomRowId;
|
||||||
|
|
||||||
|
@ApiModelProperty("BOM 类型 1-EBom 2-PBom")
|
||||||
|
private Integer bomType;
|
||||||
|
}
|
||||||
|
|
@ -256,6 +256,10 @@ public class BomNewPbomChildEntity implements Serializable {
|
||||||
@ApiModelProperty(value = "原始项目类别-来自ebom(不会变)")
|
@ApiModelProperty(value = "原始项目类别-来自ebom(不会变)")
|
||||||
private String originalProjectType;
|
private String originalProjectType;
|
||||||
|
|
||||||
|
@TableField(value = "exception_status")
|
||||||
|
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常")
|
||||||
|
private Integer exceptionStatus;
|
||||||
|
|
||||||
private static final long serialVersionUID = -76633783850936076L;
|
private static final long serialVersionUID = -76633783850936076L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -378,6 +378,10 @@ public class BomNewPbomParentEntity implements Serializable {
|
||||||
@ApiModelProperty(value = "ebom-发布后的版本")
|
@ApiModelProperty(value = "ebom-发布后的版本")
|
||||||
private String ebomVersion;
|
private String ebomVersion;
|
||||||
|
|
||||||
|
@TableField(value = "exception_status")
|
||||||
|
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常")
|
||||||
|
private Integer exceptionStatus;
|
||||||
|
|
||||||
private static final long serialVersionUID = -31999878274445137L;
|
private static final long serialVersionUID = -31999878274445137L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -348,6 +348,10 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
|
||||||
@ApiModelProperty(value = "ebom-发布后的版本")
|
@ApiModelProperty(value = "ebom-发布后的版本")
|
||||||
private String ebomVersion;
|
private String ebomVersion;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常 7=物料主数据不存在 8=项目类别为空 9=项目赋值异常(父级物料的项目类型为Q时,子级中不能存在项目类别为Q的物料) 10=项目赋值异常(当父级物料的项目类型为F时,子级中不能存在项目类型为F的物料) 11=未填写变更原因和技术通知单 12=数量需要用户确认 13=项目类型需要用户确认")
|
||||||
|
private Integer exceptionStatus=1;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,19 @@ public class CompareReportField {
|
||||||
// @ExcelProperty(value = "单位")
|
// @ExcelProperty(value = "单位")
|
||||||
@ExcelColumn(value="单位")
|
@ExcelColumn(value="单位")
|
||||||
private String materialUnit;
|
private String materialUnit;
|
||||||
|
|
||||||
|
@ApiModelProperty("项目类型")
|
||||||
|
// @ExcelProperty(value = "单位")
|
||||||
|
@ExcelColumn(value="项目类型")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
@ApiModelProperty("层级")
|
@ApiModelProperty("层级")
|
||||||
// @ExcelProperty(value="层级")
|
// @ExcelProperty(value="层级")
|
||||||
@ExcelColumn(value="层级")
|
@ExcelColumn(value="层级")
|
||||||
private Integer levelNum;
|
private Integer levelNum;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty("比对结果")
|
@ApiModelProperty("比对结果")
|
||||||
//@ExcelProperty("比对结果")
|
//@ExcelProperty("比对结果")
|
||||||
@MediaColumn
|
@MediaColumn
|
||||||
|
|
@ -65,6 +73,15 @@ public class CompareReportField {
|
||||||
// @ExcelProperty(value = "单位2")
|
// @ExcelProperty(value = "单位2")
|
||||||
@ExcelColumn(value="单位 ")
|
@ExcelColumn(value="单位 ")
|
||||||
private String materialUnit2;
|
private String materialUnit2;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("项目类型")
|
||||||
|
// @ExcelProperty(value = "单位")
|
||||||
|
@ExcelColumn(value="项目类型")
|
||||||
|
private String projectType2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty("层级")
|
@ApiModelProperty("层级")
|
||||||
@ExcelColumn(value="层级 ")
|
@ExcelColumn(value="层级 ")
|
||||||
//@ExcelProperty(value="层级2")
|
//@ExcelProperty(value="层级2")
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
package com.nflg.product.bomnew.pojo.vo;
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.nflg.product.bomnew.constant.ReportConstant;
|
||||||
|
import com.nflg.product.bomnew.constant.SapErrorMsgTypeEnum;
|
||||||
|
import com.nflg.product.bomnew.util.EnumUtils;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比对
|
* 比对
|
||||||
*/
|
*/
|
||||||
|
|
@ -18,9 +23,21 @@ public class CompareReportVO {
|
||||||
|
|
||||||
@ApiModelProperty("右侧bom2")
|
@ApiModelProperty("右侧bom2")
|
||||||
private ForwardReportVO right;
|
private ForwardReportVO right;
|
||||||
@ApiModelProperty("符号: 0-不相等 1-相等, 2-左有右缺 ,3-左缺右有")
|
@ApiModelProperty("符号: 1-相等, 2-左有右缺 ,3-左缺右有,10-数量不相等,11-单位不相等,12-项目类型不相等,13-父级物料编码不相等")
|
||||||
private Integer symbol;
|
private Integer symbol;
|
||||||
public CompareReportVO(){
|
@ApiModelProperty("比较描述")
|
||||||
|
private String symbolDesc;
|
||||||
|
|
||||||
|
public String getSymbolDesc() {
|
||||||
|
|
||||||
|
if(Objects.isNull(symbol)){
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
return EnumUtils.getEnumDescription(ReportConstant.SymbolEnum.class,symbol);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompareReportVO(){
|
||||||
|
|
||||||
}
|
}
|
||||||
public CompareReportVO(ForwardReportVO lt,Integer symbol,ForwardReportVO rt){
|
public CompareReportVO(ForwardReportVO lt,Integer symbol,ForwardReportVO rt){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.nflg.product.bomnew.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本变更-记录VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateLogVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "序号")
|
||||||
|
private String orderNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "版本号")
|
||||||
|
private String currentVersion;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("项目类别")
|
||||||
|
private String projectType;
|
||||||
|
|
||||||
|
@ApiModelProperty("物料编码")
|
||||||
|
private String materialNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("物料名称")
|
||||||
|
private String materialName;
|
||||||
|
|
||||||
|
@ApiModelProperty("物料描述")
|
||||||
|
private String materialDesc;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数量")
|
||||||
|
private BigDecimal num;
|
||||||
|
|
||||||
|
public BigDecimal getNum() {
|
||||||
|
return num!=null ?num.stripTrailingZeros():null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty("单位")
|
||||||
|
private String materialUnit;
|
||||||
|
|
||||||
|
@ApiModelProperty("排序字符串")
|
||||||
|
private String orderStr;
|
||||||
|
|
||||||
|
@ApiModelProperty("操作类型")
|
||||||
|
private String opType;
|
||||||
|
|
||||||
|
@ApiModelProperty("旧版或新版 0-旧版 1-新版")
|
||||||
|
private Integer oldOrNewVersion=0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||||
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
|
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
|
||||||
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
|
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
|
||||||
import com.nflg.product.bomnew.pojo.vo.*;
|
import com.nflg.product.bomnew.pojo.vo.*;
|
||||||
|
import com.nflg.product.bomnew.service.domain.EBom.CheckPBomException;
|
||||||
import com.nflg.product.bomnew.service.domain.PBom.*;
|
import com.nflg.product.bomnew.service.domain.PBom.*;
|
||||||
import com.nflg.product.bomnew.service.domain.Sap;
|
import com.nflg.product.bomnew.service.domain.Sap;
|
||||||
import com.nflg.product.bomnew.util.*;
|
import com.nflg.product.bomnew.util.*;
|
||||||
|
|
@ -771,6 +772,24 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取正式版-bom
|
||||||
|
* @param rowId
|
||||||
|
* @param countLevelNum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<BomNewPbomParentVO> getFormalAllBom(Long rowId, Integer countLevelNum) {
|
||||||
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
||||||
|
AtomicInteger levelNum = new AtomicInteger(1);
|
||||||
|
BomNewPbomParentEntity parent = this.getBaseMapper().selectById(rowId);
|
||||||
|
PBomFormalTreeTask detailTask = new PBomFormalTreeTask(bomDetail, countLevelNum, levelNum,parent.getFacCode());
|
||||||
|
ForkJoinTask<List<BomNewPbomParentVO>> submit = bomDetailPool.submit(detailTask);
|
||||||
|
|
||||||
|
List<BomNewPbomParentVO> result = submit.join();
|
||||||
|
return result.stream().distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
|
||||||
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
||||||
AtomicInteger levelNum = new AtomicInteger(1);
|
AtomicInteger levelNum = new AtomicInteger(1);
|
||||||
|
|
@ -2041,5 +2060,57 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PBOM-数据异常检查
|
||||||
|
* @param rowId
|
||||||
|
*/
|
||||||
|
public void checkException(Long rowId,Integer bomType){
|
||||||
|
BomNewPbomParentEntity parent = this.getById(rowId);
|
||||||
|
List<BomNewPbomParentVO> allBom =new ArrayList<>();
|
||||||
|
if(bomType==0){
|
||||||
|
allBom= this.getAllBom(rowId, 0);
|
||||||
|
}else {
|
||||||
|
this.getFormalAllBom(rowId,0);
|
||||||
|
}
|
||||||
|
BomNewPbomParentVO convert = Convert.convert(BomNewPbomParentVO.class, parent);
|
||||||
|
convert.setBomRowId(convert.getRowId());
|
||||||
|
convert.setParentRowId(0L);
|
||||||
|
allBom.add(convert);
|
||||||
|
CheckPBomException checkException=new CheckPBomException(allBom);
|
||||||
|
checkException.initException();
|
||||||
|
savePBomException(allBom);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void savePBomException(List<BomNewPbomParentVO> allBom){
|
||||||
|
//父级
|
||||||
|
List<BomNewPbomParentVO> parents = allBom.stream().filter(u -> u.getBomRowId() != null && u.getBomRowId() > 0).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(parents)) {
|
||||||
|
List<BomNewPbomParentEntity> pentList = new ArrayList<>();
|
||||||
|
parents.forEach(k -> {
|
||||||
|
BomNewPbomParentEntity pEnt = new BomNewPbomParentEntity();
|
||||||
|
pEnt.setRowId(k.getBomRowId());
|
||||||
|
pEnt.setExceptionStatus(k.getExceptionStatus());
|
||||||
|
pentList.add(pEnt);
|
||||||
|
});
|
||||||
|
if (CollUtil.isNotEmpty(pentList)) {
|
||||||
|
this.updateBatchById(pentList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//子级
|
||||||
|
List<BomNewPbomParentVO> child = allBom.stream().filter(u -> u.getRowId() != null && u.getRowId() > 0).collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(parents)) {
|
||||||
|
List<BomNewPbomChildEntity> childList = new ArrayList<>();
|
||||||
|
child.forEach(k -> {
|
||||||
|
BomNewPbomChildEntity pEnt = new BomNewPbomChildEntity();
|
||||||
|
pEnt.setRowId(k.getRowId());
|
||||||
|
pEnt.setExceptionStatus(k.getExceptionStatus());
|
||||||
|
childList.add(pEnt);
|
||||||
|
});
|
||||||
|
if (CollUtil.isNotEmpty(childList)) {
|
||||||
|
pbomChildService.updateBatchById(childList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,13 +92,16 @@ public class CompareReportService {
|
||||||
}
|
}
|
||||||
excelList.add(compareReportField);
|
excelList.add(compareReportField);
|
||||||
if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.EQ.getValue())
|
if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.EQ.getValue())
|
||||||
|| ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.NON_EQ.getValue())) {
|
|| compareReportVO.getSymbol()>=ReportConstant.SymbolEnum.NON_EQ_NUM.getValue()) {
|
||||||
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
|
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
|
||||||
compareReportField.setNum(compareReportVO.getLeft().getNum());
|
compareReportField.setNum(compareReportVO.getLeft().getNum());
|
||||||
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
|
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
|
||||||
|
compareReportField.setProjectType(compareReportVO.getLeft().getProjectType());
|
||||||
|
|
||||||
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
|
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
|
||||||
compareReportField.setNum2(compareReportVO.getRight().getNum());
|
compareReportField.setNum2(compareReportVO.getRight().getNum());
|
||||||
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
|
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
|
||||||
|
compareReportField.setProjectType2(compareReportVO.getRight().getProjectType());
|
||||||
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())
|
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())
|
||||||
|| ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
|| ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
||||||
compareReportField.setSumSymbol("Σ");
|
compareReportField.setSumSymbol("Σ");
|
||||||
|
|
@ -107,19 +110,23 @@ public class CompareReportService {
|
||||||
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
|
compareReportField.setLevelNum(compareReportVO.getLeft().getLevelNum());
|
||||||
compareReportField.setNum(compareReportVO.getLeft().getNum());
|
compareReportField.setNum(compareReportVO.getLeft().getNum());
|
||||||
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
|
compareReportField.setMaterialUnit(compareReportVO.getLeft().getMaterialUnit());
|
||||||
|
compareReportField.setProjectType(compareReportVO.getLeft().getProjectType());
|
||||||
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
if (ObjectUtil.equal(compareReportVO.getLeft().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
||||||
compareReportField.setSumSymbol("Σ");
|
compareReportField.setSumSymbol("Σ");
|
||||||
}
|
}
|
||||||
compareReportField.setLevelNum2(null);
|
compareReportField.setLevelNum2(null);
|
||||||
compareReportField.setNum2(null);
|
compareReportField.setNum2(null);
|
||||||
compareReportField.setMaterialUnit2(null);
|
compareReportField.setMaterialUnit2(null);
|
||||||
|
compareReportField.setProjectType2(null);
|
||||||
} else if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.NULL_R.getValue())) {
|
} else if (ObjectUtil.equal(compareReportVO.getSymbol(), ReportConstant.SymbolEnum.NULL_R.getValue())) {
|
||||||
compareReportField.setLevelNum(null);
|
compareReportField.setLevelNum(null);
|
||||||
compareReportField.setNum(null);
|
compareReportField.setNum(null);
|
||||||
compareReportField.setMaterialUnit(null);
|
compareReportField.setMaterialUnit(null);
|
||||||
|
compareReportField.setProjectType(null);
|
||||||
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
|
compareReportField.setLevelNum2(compareReportVO.getRight().getLevelNum());
|
||||||
compareReportField.setNum2(compareReportVO.getRight().getNum());
|
compareReportField.setNum2(compareReportVO.getRight().getNum());
|
||||||
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
|
compareReportField.setMaterialUnit2(compareReportVO.getRight().getMaterialUnit());
|
||||||
|
compareReportField.setProjectType2(compareReportVO.getRight().getProjectType());
|
||||||
if (ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
if (ObjectUtil.equal(compareReportVO.getRight().getTag(), ReportConstant.TagEnum.SIGMA.getValue())) {
|
||||||
compareReportField.setSumSymbol("Σ");
|
compareReportField.setSumSymbol("Σ");
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +168,7 @@ public class CompareReportService {
|
||||||
|
|
||||||
filePath = "1.png";
|
filePath = "1.png";
|
||||||
|
|
||||||
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.NON_EQ.getValue())) {
|
} else if ( type>=ReportConstant.SymbolEnum.NON_EQ_NUM.getValue() ) {
|
||||||
filePath = "0.png";
|
filePath = "0.png";
|
||||||
|
|
||||||
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.L_NULL.getValue())) {
|
} else if (ObjectUtil.equal(type, ReportConstant.SymbolEnum.L_NULL.getValue())) {
|
||||||
|
|
@ -359,29 +366,45 @@ public class CompareReportService {
|
||||||
|
|
||||||
//比较数量
|
//比较数量
|
||||||
if(ObjectUtil.isNull(from.getNum()) || ObjectUtil.isNull(to.getNum())){
|
if(ObjectUtil.isNull(from.getNum()) || ObjectUtil.isNull(to.getNum())){
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_NUM.getValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( from.getNum().compareTo(to.getNum()) !=0) {
|
if ( from.getNum().compareTo(to.getNum()) !=0) {
|
||||||
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_NUM.getValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
//项目类型比较
|
||||||
|
if(ObjectUtil.isNull(from.getProjectType()) || ObjectUtil.isNull(to.getProjectType())){
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_PROJECT_TYPE.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!StrUtil.equals(from.getProjectType().toUpperCase(),to.getProjectType().toUpperCase()) ) {
|
||||||
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_PROJECT_TYPE.getValue());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//多层比较父级物料编码/图号
|
//多层比较父级物料编码/图号
|
||||||
if (queryType.compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
if (queryType.compareTo(ReportConstant.QueryTypeEnum.MULTI.getValue()) == 0) {
|
||||||
|
|
||||||
//根节点下面不用比较
|
|
||||||
if ( (Objects.nonNull(from.getParentRowId()) &&from.getParentRowId()>0)
|
if ( (Objects.nonNull(from.getParentRowId()) &&from.getParentRowId()>0)
|
||||||
&& (Objects.nonNull(to.getParentRowId()) &&to.getParentRowId()>0) ) {
|
&& (Objects.nonNull(to.getParentRowId()) &&to.getParentRowId()>0) ) {
|
||||||
|
|
||||||
if (CollUtil.isEmpty(leftBomRowIdMap.get(from.getParentRowId()))
|
if (CollUtil.isEmpty(leftBomRowIdMap.get(from.getParentRowId()))
|
||||||
|| CollUtil.isEmpty(rightBomRowIdMap.get(to.getParentRowId()))) {
|
|| CollUtil.isEmpty(rightBomRowIdMap.get(to.getParentRowId()))) {
|
||||||
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_PARENT_MaterialNo.getValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//父级物料比
|
||||||
ForwardReportVO fromParent = leftBomRowIdMap.get(from.getParentRowId()).get(0);
|
ForwardReportVO fromParent = leftBomRowIdMap.get(from.getParentRowId()).get(0);
|
||||||
ForwardReportVO toParent = rightBomRowIdMap.get(to.getParentRowId()).get(0);
|
ForwardReportVO toParent = rightBomRowIdMap.get(to.getParentRowId()).get(0);
|
||||||
|
|
||||||
if (!compareFunc.apply(fromParent).equals(compareFunc.apply(toParent))) {
|
if (!compareFunc.apply(fromParent).equals(compareFunc.apply(toParent))) {
|
||||||
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_PARENT_MaterialNo.getValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,12 +412,12 @@ public class CompareReportService {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//比较单位
|
//比较单位
|
||||||
if (!ObjectUtil.equal(from.getMaterialUnit().toUpperCase(), to.getMaterialUnit().toUpperCase())) {
|
if (!StrUtil.equals(from.getMaterialUnit().toUpperCase(), to.getMaterialUnit().toUpperCase())) {
|
||||||
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ.getValue());
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.NON_EQ_UNIT.getValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//找到相等退出
|
//上面条件都不满足即为相等
|
||||||
compareReportVO.setSymbol(ReportConstant.SymbolEnum.EQ.getValue());
|
compareReportVO.setSymbol(ReportConstant.SymbolEnum.EQ.getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.lang.TypeReference;
|
import cn.hutool.core.lang.TypeReference;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
import com.nflg.product.bomnew.constant.*;
|
import com.nflg.product.bomnew.constant.*;
|
||||||
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
|
||||||
import com.nflg.product.bomnew.pojo.entity.*;
|
import com.nflg.product.bomnew.pojo.entity.*;
|
||||||
|
|
@ -19,9 +22,12 @@ import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||||
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
||||||
import com.nflg.product.bomnew.util.VUtils;
|
import com.nflg.product.bomnew.util.VUtils;
|
||||||
|
import nflg.product.common.constant.STATE;
|
||||||
|
import org.apache.ibatis.builder.ParameterExpression;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.ttzero.excel.entity.ListSheet;
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -32,6 +38,19 @@ import java.util.stream.Collectors;
|
||||||
@Service
|
@Service
|
||||||
public class ForwardReportService {
|
public class ForwardReportService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BomNewEbomParentFormalService ebomParentFormalService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BomNewEbomChildFormalService ebomChildFormalService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BomNewPbomParentFormalService pbomParentFormalService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BomNewPbomChildFormalService pbomChildFormalService;
|
||||||
|
|
||||||
|
|
||||||
public ReportBomVersionVO factoryVersion(ReverseReportQuery query) {
|
public ReportBomVersionVO factoryVersion(ReverseReportQuery query) {
|
||||||
//原始BOM
|
//原始BOM
|
||||||
|
|
@ -402,4 +421,101 @@ public class ForwardReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取BOM变更记录
|
||||||
|
* @param bomRowId bom版本rowId
|
||||||
|
* @param bomType BOM 类型 0-原始BOM 1-EBom 2-PBom
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<UpdateLogVO> getUpdateLog(Long bomRowId ,Integer bomType){
|
||||||
|
//结果
|
||||||
|
List<UpdateLogVO> result=new ArrayList<>();
|
||||||
|
//eBom
|
||||||
|
if(bomType==1){
|
||||||
|
BomNewEbomParentFormalEntity ebomVersion = ebomParentFormalService.getById(bomRowId);
|
||||||
|
if(Objects.nonNull(ebomVersion)){
|
||||||
|
//上一个BOM版本
|
||||||
|
BomNewEbomParentFormalEntity preBomVersion = ebomParentFormalService.lambdaQuery().eq(BomNewEbomParentFormalEntity::getMaterialNo, ebomVersion.getMaterialNo())
|
||||||
|
.lt(BomNewEbomParentFormalEntity::getCurrentVersion, ebomVersion.getCurrentVersion()).orderByDesc(BomNewEbomParentFormalEntity::getCurrentVersion).last(" limit 1").one();
|
||||||
|
if(Objects.nonNull(preBomVersion)) {
|
||||||
|
List<BomNewEbomChildFormalEntity> newBomDetail = ebomChildFormalService.lambdaQuery().eq(BomNewEbomChildFormalEntity::getParentRowId, bomRowId).list();
|
||||||
|
|
||||||
|
List<BomNewEbomChildFormalEntity> oldBomDetail = ebomChildFormalService.lambdaQuery().eq(BomNewEbomChildFormalEntity::getParentRowId, preBomVersion.getRowId()).list();
|
||||||
|
List<UpdateLogVO> newBomChild = Convert.toList(UpdateLogVO.class, newBomDetail);
|
||||||
|
List<UpdateLogVO> oldBomChild = Convert.toList(UpdateLogVO.class, oldBomDetail);
|
||||||
|
newBomChild.forEach(item->{item.setCurrentVersion(ebomVersion.getCurrentVersion()); item.setOldOrNewVersion(1);});
|
||||||
|
oldBomChild.forEach(item->item.setCurrentVersion(preBomVersion.getCurrentVersion()));
|
||||||
|
result=compare(oldBomChild,newBomChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//pBom
|
||||||
|
else if(bomType==2){
|
||||||
|
BomNewPbomParentFormalEntity pbomVersion = pbomParentFormalService.getById(bomRowId);
|
||||||
|
if(Objects.nonNull(pbomVersion)){
|
||||||
|
//上一个BOM版本
|
||||||
|
BomNewPbomParentFormalEntity preBomVersion = pbomParentFormalService.lambdaQuery().eq(BomNewPbomParentFormalEntity::getMaterialNo, pbomVersion.getMaterialNo())
|
||||||
|
.lt(BomNewPbomParentFormalEntity::getCurrentVersion, pbomVersion.getCurrentVersion()).orderByDesc(BomNewPbomParentFormalEntity::getCurrentVersion).last(" limit 1").one();
|
||||||
|
if(Objects.nonNull(preBomVersion)) {
|
||||||
|
List<BomNewPbomChildFormalEntity> newBomDetail = pbomChildFormalService.lambdaQuery().eq(BomNewPbomChildFormalEntity::getParentRowId, bomRowId).list();
|
||||||
|
|
||||||
|
List<BomNewPbomChildFormalEntity> oldBomDetail = pbomChildFormalService.lambdaQuery().eq(BomNewPbomChildFormalEntity::getParentRowId, preBomVersion.getRowId()).list();
|
||||||
|
List<UpdateLogVO> newBomChild = Convert.toList(UpdateLogVO.class, newBomDetail);
|
||||||
|
List<UpdateLogVO> oldBomChild = Convert.toList(UpdateLogVO.class, oldBomDetail);
|
||||||
|
newBomChild.forEach(item->{item.setCurrentVersion(pbomVersion.getCurrentVersion()); item.setOldOrNewVersion(1);});
|
||||||
|
oldBomChild.forEach(item->item.setCurrentVersion(preBomVersion.getCurrentVersion()));
|
||||||
|
result=compare(oldBomChild,newBomChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new NflgBusinessException(STATE.ParamErr ,"bomType参数错误:暂不支持该类型BOM");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bom-对比(变更记录)
|
||||||
|
* @param oldBom
|
||||||
|
* @param newBom
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<UpdateLogVO> compare(List<UpdateLogVO> oldBom, List<UpdateLogVO> newBom){
|
||||||
|
List<UpdateLogVO> result =new ArrayList<>();
|
||||||
|
|
||||||
|
Set<String> oldSet = oldBom.stream().map(u -> u.getOrderNumber()).collect(Collectors.toSet());
|
||||||
|
Set<String> newSet =newBom.stream().map(u->u.getOrderNumber()).collect(Collectors.toSet());
|
||||||
|
//删除的
|
||||||
|
Set<String> del = Sets.difference(oldSet, newSet);
|
||||||
|
for (String item: del) {
|
||||||
|
UpdateLogVO oldEnd=oldBom.stream().filter(u->u.getOrderNumber().equals(item)).findFirst().get();
|
||||||
|
result.add(oldEnd);
|
||||||
|
UpdateLogVO newEnt =new UpdateLogVO();
|
||||||
|
BeanUtil.copyProperties(oldEnd,newEnt);
|
||||||
|
newEnt.setCurrentVersion(newBom.get(0).getCurrentVersion());
|
||||||
|
newEnt.setOpType(BomConstant.DEL);
|
||||||
|
result.add(newEnt);
|
||||||
|
}
|
||||||
|
//新增
|
||||||
|
Set<String> add= Sets.difference(newSet,oldSet);
|
||||||
|
for (String item: add) {
|
||||||
|
UpdateLogVO updateLogVO=newBom.stream().filter(u->u.getOrderNumber().equals(item)).findFirst().get();
|
||||||
|
updateLogVO.setOpType(BomConstant.ADD);
|
||||||
|
result.add(updateLogVO);
|
||||||
|
}
|
||||||
|
//都有比较编辑字段
|
||||||
|
Set<String> intersection = Sets.intersection(oldSet,newSet);
|
||||||
|
for (String item: intersection) {
|
||||||
|
UpdateLogVO oldEnt = oldBom.stream().filter(u -> u.getOrderNumber().equals(item)).findFirst().get();
|
||||||
|
UpdateLogVO newEnt = newBom.stream().filter(u -> u.getOrderNumber().equals(item)).findFirst().get();
|
||||||
|
if(!oldEnt.getMaterialNo().equals(newEnt.getMaterialNo()) || !oldEnt.getNum().equals(newEnt.getNum()) || !oldEnt.getProjectType().equals(newEnt.getProjectType())){
|
||||||
|
result.add(oldEnt);
|
||||||
|
newEnt.setOpType(BomConstant.UP);
|
||||||
|
result.add(newEnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
package com.nflg.product.bomnew.service.domain.EBom;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||||
|
import com.nflg.product.bomnew.constant.*;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||||
|
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||||
|
import com.nflg.product.bomnew.service.BomNewEbomChildService;
|
||||||
|
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||||
|
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||||
|
import com.nflg.product.bomnew.util.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import nflg.product.common.constant.STATE;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查BOM 异常
|
||||||
|
*/
|
||||||
|
public class CheckPBomException {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
List<BomNewPbomParentVO> allBomDetail;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param allBom 整颗BOM树(包含跟节点)
|
||||||
|
*/
|
||||||
|
public CheckPBomException(List<BomNewPbomParentVO> allBom) {
|
||||||
|
allBomDetail = allBom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化异常
|
||||||
|
*/
|
||||||
|
public void initException() {
|
||||||
|
//初始化物料信息
|
||||||
|
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||||
|
|
||||||
|
checkException();
|
||||||
|
}
|
||||||
|
public void checkException() {
|
||||||
|
for (BomNewPbomParentVO vo : allBomDetail) {
|
||||||
|
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(vo.getMaterialNo())
|
||||||
|
&& (MaterialGetEnum.MaterialStateEnum.STATE_NO_4.equalsValue(vo.getMaterialState())
|
||||||
|
|| MaterialGetEnum.MaterialStateEnum.STATE_NO_5.equalsValue(vo.getMaterialState()))) {
|
||||||
|
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
|
||||||
|
}
|
||||||
|
if(StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState()) ){
|
||||||
|
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initExceptionYellowWarn();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 黄色警号异常
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public void initExceptionYellowWarn() {
|
||||||
|
Set<BomNewPbomParentVO> exceptionItems = allBomDetail.stream().filter(u -> EBomExceptionStatusEnum.EXCEPT_NO_2.equalsValue(u.getExceptionStatus()) || EBomExceptionStatusEnum.EXCEPT_NO_7.equalsValue(u.getExceptionStatus()) ).collect(Collectors.toSet());
|
||||||
|
for (BomNewPbomParentVO vo : exceptionItems) {
|
||||||
|
initExceptionParent(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化上级警告
|
||||||
|
* @param vo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected void initExceptionParent(BomNewPbomParentVO vo) {
|
||||||
|
|
||||||
|
List<BomNewPbomParentVO> parentEnts = initExceptionParentDo(ImmutableList.of(vo));
|
||||||
|
|
||||||
|
while (CollUtil.isNotEmpty(parentEnts) ) {
|
||||||
|
parentEnts = initExceptionParentDo(parentEnts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<BomNewPbomParentVO> initExceptionParentDo(List<BomNewPbomParentVO> vos) {
|
||||||
|
Set<Long> parentRowIds = vos.stream().filter(u->u.getParentRowId()>0).map(u -> u.getParentRowId()).collect(Collectors.toSet());
|
||||||
|
List<BomNewPbomParentVO> parents = allBomDetail.stream().filter(u ->parentRowIds.contains(u.getBomRowId())).collect(Collectors.toList());
|
||||||
|
parents.forEach(u->u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()));
|
||||||
|
return parents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -38,11 +38,12 @@
|
||||||
<result column="original_material_no" property="originalMaterialNo" jdbcType="VARCHAR"/>
|
<result column="original_material_no" property="originalMaterialNo" jdbcType="VARCHAR"/>
|
||||||
<result column="original_num" property="orderNumber" jdbcType="DECIMAL" />
|
<result column="original_num" property="orderNumber" jdbcType="DECIMAL" />
|
||||||
<result column="original_project_type" property="originalProjectType" jdbcType="VARCHAR"/>
|
<result column="original_project_type" property="originalProjectType" jdbcType="VARCHAR"/>
|
||||||
|
<result column="exception_status" property="exceptionStatus" jdbcType="INTEGER"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
row_id, parent_row_id, identity_no, fac_code, order_number, drawing_no, material_no, material_name, material_desc, material_texture, material_unit, material_category_code, unit_weight, num, total_weight, project_type, production_factory_code,production_factory_code_input_type, set_production_factory_time, super_material_status, virtual_part_is, created_by, created_time, modify_time, source_row_id, remark, source_parent_material_no ,virtual_part_type ,virtual_part_root_material_no ,bom_version_row_id ,original_material_no , original_num, original_project_type </sql>
|
row_id, parent_row_id, identity_no, fac_code, order_number, drawing_no, material_no, material_name, material_desc, material_texture, material_unit, material_category_code, unit_weight, num, total_weight, project_type, production_factory_code,production_factory_code_input_type, set_production_factory_time, super_material_status, virtual_part_is, created_by, created_time, modify_time, source_row_id, remark, source_parent_material_no ,virtual_part_type ,virtual_part_root_material_no ,bom_version_row_id ,original_material_no , original_num, original_project_type ,exception_status</sql>
|
||||||
|
|
||||||
|
|
||||||
<delete id="delByRowId">
|
<delete id="delByRowId">
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
<result column="order_no" property="orderNo" jdbcType="VARCHAR"/>
|
<result column="order_no" property="orderNo" jdbcType="VARCHAR"/>
|
||||||
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
|
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"/>
|
||||||
<result column="ebom_version" property="ebomVersion" jdbcType="VARCHAR"/>
|
<result column="ebom_version" property="ebomVersion" jdbcType="VARCHAR"/>
|
||||||
|
<result column="exception_status" property="exceptionStatus" jdbcType="INTEGER"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
|
|
@ -58,7 +59,7 @@
|
||||||
should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is,
|
should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is,
|
||||||
virtual_package_is, source_row_id, devise_user_code, devise_name,technology_user_code,technology_user_name, created_by, created_time, created_job,
|
virtual_package_is, source_row_id, devise_user_code, devise_name,technology_user_code,technology_user_name, created_by, created_time, created_job,
|
||||||
release_time, release_user_name,last_convert_mbom_user_name,last_convert_mbom_time, expire_end_time, remark, dept_name, level_num, change_desc, notice_nums,
|
release_time, release_user_name,last_convert_mbom_user_name,last_convert_mbom_time, expire_end_time, remark, dept_name, level_num, change_desc, notice_nums,
|
||||||
order_no, modify_time,ebom_version
|
order_no, modify_time,ebom_version,exception_status
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="whr">
|
<sql id="whr">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue