1、合并一般零部件

This commit is contained in:
大米 2024-05-11 14:49:51 +08:00
parent 9cfa61c5bd
commit 89ba5d49ce
7 changed files with 47 additions and 8 deletions

View File

@ -197,8 +197,8 @@ public class BomNewEbomChildEntity implements Serializable {
* 来源行ID(原始BOM中的行ID)
*/
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行ID(原始BOM中的行ID)")
private Long sourceRowId;
@ApiModelProperty(value = "来源行ID(原始BOM中的行ID),多个以逗号隔开")
private String sourceRowId;
/**
* 备注

View File

@ -223,7 +223,7 @@ public class BomNewEbomParentEntity implements Serializable {
*/
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行ID(原始BOM中的行ID)")
private Long sourceRowId;
private String sourceRowId;
/**
* 设计人员编码

View File

@ -163,7 +163,7 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
* 来源行ID(原始BOM中的行ID)
*/
@ApiModelProperty(value = "来源行ID(原始BOM中的行ID)")
private Long sourceRowId;
private String sourceRowId;
/**
* 设计人员编码

View File

@ -189,6 +189,9 @@ public class BomOriginalListVO extends BaseMaterialVO {
@ApiModelProperty(value = "原始单位-来自cad")
private String materialOriginalUnit;
@ApiModelProperty("来源行ID,多个以逗号隔开")
private String sourceRowId;
public Integer getVirtualPartType() {
if( drawingNo.contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())){
return VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue();

View File

@ -97,6 +97,39 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
}
/**
* 合并一般零部件
* @param list
* @return
*/
private List<BomOriginalListVO> mergeCommonPartBOM(List<BomOriginalListVO> list) {
List<BomOriginalListVO> result = new ArrayList();
//子级中一般零部件
List<BomOriginalListVO> commonPartList = list.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo()) && OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE.equals(u.getMaterialCategoryCode())).collect(Collectors.toList());
Map<String, List<BomOriginalListVO>> materialNoGroupMp =commonPartList.stream().collect(Collectors.groupingBy(BomOriginalListVO::getMaterialNo));
for (Map.Entry<String, List<BomOriginalListVO>> entry : materialNoGroupMp.entrySet()) {
List<BomOriginalListVO> list1 = entry.getValue();
BomOriginalListVO one = list1.get(0);
BigDecimal numResult = BigDecimal.ZERO;
BigDecimal totalWeightResult = BigDecimal.ZERO;
List<Long> rowIds=new ArrayList<>();
for (BomOriginalListVO item : list1) {
numResult = NumberUtil.add(numResult, Objects.nonNull(item.getNum()) ? item.getNum() : BigDecimal.ZERO);
totalWeightResult = NumberUtil.add(totalWeightResult, item.getTotalWeight());
rowIds.add(item.getRowId());
}
one.setNum(numResult);
one.setTotalWeight(totalWeightResult);
one.setSourceRowId(StrUtil.join(",",rowIds) );
result.add(one);
}
Set<Long> commonPartRowIds = commonPartList.stream().map(u -> u.getRowId()).collect(Collectors.toSet());
result.addAll(list.stream().filter(u->!commonPartRowIds.contains(u.getRowId())).collect(Collectors.toList()));
return result;
}
/**
* BOM-处理
@ -108,6 +141,9 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
//子节点
List<BomOriginalListVO> parentChild = bomDetail.stream().filter(u -> Objects.nonNull(u.getParentRowId()) && u.getParentRowId().equals(parentEnt.getBomRowId())).distinct().collect(Collectors.toList());
//合并一般零部件
mergeCommonPartBOM(parentChild);
BomNewEbomParentEntity oldEBom = ebomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parentEnt.getMaterialNo()).last(" order by current_version desc limit 1").one();
List<BomNewEbomChildEntity> oldParenChild = ebomChildService.getBaseMapper().getChildByMaterialNo(parentEnt.getMaterialNo());
//无Ebom时
@ -324,7 +360,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
eBomParent.setSource(EBomSourceEnum.FROM_BOM.getValue());
eBomParent.setCurrentVersion(VersionUtil.getNextVersion(Objects.isNull(ebom) ? "" : VersionUtil.getNextVersion(ebom.getCurrentVersion())));
eBomParent.setConvertToEbomTime(LocalDateTime.now());
eBomParent.setSourceRowId(parentEnt.getRowId());
eBomParent.setSourceRowId(StrUtil.isNotBlank(parentEnt.getSourceRowId())?parentEnt.getSourceRowId(): parentEnt.getRowId().toString());
eBomParent.setLastVersionIs(1);
eBomParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
//eBomParent.setModifyTime(LocalDateTime.now());
@ -376,7 +412,7 @@ public class OriginalBomToEBomV2Convert extends BaseConvert {
childEntity.setParentRowId(parentRowId);
childEntity.setIdentityNo(StrUtil.join("_", parentRowId.toString(), childEntity.getRowId()));
childEntity.setModifyTime(LocalDateTime.now());
childEntity.setSourceRowId(child.getRowId());
childEntity.setSourceRowId(StrUtil.isNotBlank(child.getSourceRowId())?child.getSourceRowId(): child.getRowId().toString());
//当为原材料时数量=总重 单位改为KG 图号=编码
// if((StrUtil.isNotBlank(childEntity.getMaterialCategoryCode())&& childEntity.getMaterialCategoryCode().startsWith("10") ) || (StrUtil.isNotBlank(childEntity.getMaterialNo()) && childEntity.getMaterialNo().startsWith("11"))){
// childEntity.setNum(childEntity.getTotalWeight());

View File

@ -29,7 +29,7 @@
<result column="exception_tag" property="exceptionTag" jdbcType="VARCHAR"/>
<result column="source" property="source" jdbcType="INTEGER"/>
<result column="source_row_id" property="sourceRowId" jdbcType="BIGINT"/>
<result column="source_row_id" property="sourceRowId" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="virtual_part_type" property="virtualPartType" jdbcType="INTEGER"/>
<result column="virtual_part_root_material_no" property="virtualPartRootMaterialNo" />

View File

@ -30,7 +30,7 @@
<result column="user_root_is" property="userRootIs" jdbcType="INTEGER"/>
<result column="exception_status" property="exceptionStatus" jdbcType="INTEGER"/>
<result column="virtual_package_is" property="virtualPackageIs" jdbcType="INTEGER"/>
<result column="source_row_id" property="sourceRowId" jdbcType="BIGINT"/>
<result column="source_row_id" property="sourceRowId" jdbcType="VARCHAR"/>
<result column="devise_user_code" property="deviseUserCode" jdbcType="VARCHAR"/>
<result column="devise_name" property="deviseName" jdbcType="VARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>