临时转原始BOM
This commit is contained in:
parent
b8c801d01a
commit
5a45de659b
|
|
@ -0,0 +1,12 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/11 20:09
|
||||
*/
|
||||
public class OriginalConstant {
|
||||
|
||||
//一般零部件物料分类编码
|
||||
public static final String COMMON_MATERIAL_CATEGORY_CODE = "200901";
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import lombok.Getter;
|
|||
@Getter
|
||||
public enum OriginalEditStatusEnum implements ValueEnum<Integer> {
|
||||
|
||||
HANDLER_CREATED(1, "处理中"),
|
||||
HANDLER_CREATED(1, "待处理 "),
|
||||
HANDLER_FINISHED(2, "处理完成");
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 数据来源
|
||||
* @author 大米
|
||||
* @date 2023/11/10 9:36
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum OriginalSourceEnum implements ValueEnum<Integer>{
|
||||
|
||||
//来源:1=PLM推送、2=人工导入、3=MDM创建、4=CAD导入、5=SW导入
|
||||
|
||||
PLM_PUSH(1,"PLM推送"),
|
||||
MANUAL_IMPORT(2,"人工导入"),
|
||||
MDM_CREATE(3,"MDM创建"),
|
||||
CAD_IMPORT(4,"CAD导入"),
|
||||
SW_IMPORT(5,"SW导入");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.nflg.product.bomnew.pojo.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -84,7 +86,7 @@ public class BomNewOriginalChildEntity implements Serializable {
|
|||
*/
|
||||
@TableField(value = "num")
|
||||
@ApiModelProperty(value = "数量")
|
||||
private BigDecimal num;
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* 重量
|
||||
|
|
@ -92,7 +94,11 @@ public class BomNewOriginalChildEntity implements Serializable {
|
|||
@TableField(value = "total_weight")
|
||||
@ApiModelProperty(value = "重量")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
|
||||
public BigDecimal getTotalWeight() {
|
||||
return NumberUtil.mul(this.getUnitWeight(),this.num);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -61829104329368344L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class BomNewOriginalParentEntity implements Serializable {
|
|||
*/
|
||||
@TableField(value = "dept_row_id")
|
||||
@ApiModelProperty(value = "设计维护部门行ID")
|
||||
private Integer deptRowId;
|
||||
private Long deptRowId;
|
||||
|
||||
/**
|
||||
* 设计维护部门名称
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ public class BaseMaterialVO {
|
|||
@ApiModelProperty("物料状态 1:激活 2:禁止采购 3:售后专用 4:冻结 5:完全弃用")
|
||||
private Integer materialState;
|
||||
|
||||
@ApiModelProperty("图号")
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 材料
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -37,12 +37,7 @@ public class BomNewOriginalChildVO extends BaseMaterialVO implements Serializabl
|
|||
@ApiModelProperty(value = "序号")
|
||||
private String orderNumber;
|
||||
|
||||
/**
|
||||
* 图号
|
||||
*/
|
||||
@ApiModelProperty(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class BomOriginalPlmBomVO extends BaseMaterialVO implements Serializable
|
|||
* 上一级id
|
||||
*/
|
||||
@ApiModelProperty(value = "上一级id")
|
||||
private Integer parentRowId;
|
||||
private Long parentRowId;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,14 +5,31 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewOriginalParentDTO;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.OriginalEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalSourceEnum;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialMateVO;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalChildService;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.service.BomOriginalPlmChildService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.cache.MaterialMateCache;
|
||||
import com.nflg.product.bomnew.util.ClassCompareUtil;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -25,26 +42,29 @@ public abstract class BaseConvert {
|
|||
|
||||
protected BomOriginalPlmBomVO parent;
|
||||
|
||||
protected List<BomOriginalPlmBomVO> childs;
|
||||
|
||||
//转换后父级数据
|
||||
protected List<BomNewOriginalParentDTO> resultParent;
|
||||
protected List<BomNewOriginalParentEntity> resultParent = new ArrayList<>();
|
||||
|
||||
//转换后-子级数据
|
||||
protected List<BomNewOriginalChildEntity> resultChild;
|
||||
protected List<BomNewOriginalChildEntity> resultChild = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化物料基本信息
|
||||
*
|
||||
* @param data
|
||||
* @param <T>
|
||||
*/
|
||||
public <T extends BaseMaterialVO> void intiMaterialInfo(List<T> data){
|
||||
List<String> materialNos=data.stream().filter(u-> StrUtil.isNotBlank(u.getMaterialNo())).map(u->u.getMaterialNo()).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(materialNos)){
|
||||
public <T extends BaseMaterialVO> void intiMaterialInfo(List<T> data) {
|
||||
List<String> materialNos = data.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(materialNos)) {
|
||||
List<BaseMaterialVO> materialBaseInfos = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
|
||||
Map<String, BaseMaterialVO> materialMp = ListCommonUtil.listToMap(materialBaseInfos, BaseMaterialVO::getMaterialNo);
|
||||
for ( T t: data) {
|
||||
if(StrUtil.isNotBlank(t.getMaterialNo()) && materialMp.containsKey(t.getMaterialNo())){
|
||||
BeanUtil.copyProperties(materialMp.get(t.getMaterialNo()),t);
|
||||
for (T t : data) {
|
||||
if (StrUtil.isNotBlank(t.getMaterialNo()) && materialMp.containsKey(t.getMaterialNo())) {
|
||||
BeanUtil.copyProperties(materialMp.get(t.getMaterialNo()), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,18 +73,169 @@ public abstract class BaseConvert {
|
|||
|
||||
/**
|
||||
* 是否一般物料(物料分类为200901)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isCommonMaterial(BaseMaterialVO data){
|
||||
String commonCategoryCode="200901" ;
|
||||
if(StrUtil.isNotBlank(data.getMaterialCategoryCode()) && data.getMaterialCategoryCode().equals(commonCategoryCode)){
|
||||
public boolean isCommonMaterial(BaseMaterialVO data) {
|
||||
String commonCategoryCode = "200901";
|
||||
if (StrUtil.isNotBlank(data.getMaterialCategoryCode()) && data.getMaterialCategoryCode().equals(commonCategoryCode)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始BOM(一般零部件200901)
|
||||
*/
|
||||
public BomNewOriginalParentEntity getOriginalBomForCommonMaterial(String materialNo, BigDecimal unitWeight) {
|
||||
return SpringUtil.getBean(BomNewOriginalParentService.class).lambdaQuery().eq(BomNewOriginalParentEntity::getMaterialNo, materialNo)
|
||||
.eq(BomNewOriginalParentEntity::getUnitWeight, unitWeight)
|
||||
.eq(BomNewOriginalParentEntity::getLastVersionIs, 1).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始BOM(非一般零部件)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BomNewOriginalParentEntity getOriginalBomForMaterial(String drawingNo) {
|
||||
return SpringUtil.getBean(BomNewOriginalParentService.class).lambdaQuery().eq(BomNewOriginalParentEntity::getDrawingNo, drawingNo)
|
||||
.eq(BomNewOriginalParentEntity::getLastVersionIs, 1).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建Bom-父级
|
||||
*
|
||||
* @param material
|
||||
*/
|
||||
protected BomNewOriginalParentEntity buildParentEntity(BomOriginalPlmBomVO material) {
|
||||
BomNewOriginalParentEntity parentEntity = new BomNewOriginalParentEntity();
|
||||
parentEntity.setRowId(IdWorker.getId());
|
||||
parentEntity.setBatchNo(material.getBatchNo());
|
||||
parentEntity.setDrawingNo(material.getChartNo());
|
||||
parentEntity.setMaterialNo(material.getMaterialNo());
|
||||
parentEntity.setMaterialName(material.getMaterialName());
|
||||
parentEntity.setMaterialDesc(material.getMaterialDesc());
|
||||
parentEntity.setCurrentVersion(VersionUtil.getNextVersion(""));
|
||||
parentEntity.setNum(material.getQty());
|
||||
parentEntity.setBomExist(0);
|
||||
parentEntity.setShouldBomExist(1);
|
||||
parentEntity.setLastVersionIs(1);
|
||||
parentEntity.setMaterialTexture(material.getMaterial());
|
||||
parentEntity.setUnitWeight(material.getWeight());
|
||||
parentEntity.setDeviseUserCode(material.getDesignBy());
|
||||
parentEntity.setDeviseName(SessionUtil.getUserName());
|
||||
parentEntity.setStatus(OriginalStatusEnum.UN_CONVERT.getValue());
|
||||
parentEntity.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
parentEntity.setDeptRowId(SessionUtil.getPartRowId());
|
||||
parentEntity.setDeptName(SessionUtil.getFullDeptName());
|
||||
parentEntity.setSource(OriginalSourceEnum.PLM_PUSH.getValue());
|
||||
parentEntity.setCreatedBy(material.getCreatedBy());
|
||||
parentEntity.setCreatedTime(LocalDateTime.now());
|
||||
this.resultParent.add(parentEntity);
|
||||
return parentEntity;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected BomNewOriginalChildEntity buildChildEntity(BomOriginalPlmBomVO material, BomNewOriginalParentEntity parent) {
|
||||
BomNewOriginalChildEntity childEntity = new BomNewOriginalChildEntity();
|
||||
|
||||
childEntity.setRowId(IdWorker.getId());
|
||||
childEntity.setParentRowId(parent.getRowId());
|
||||
childEntity.setOrderNumber(material.getOrderNo().toString());
|
||||
childEntity.setDrawingNo(material.getChartNo());
|
||||
childEntity.setMaterialNo(material.getMaterialNo());
|
||||
childEntity.setMaterialName(material.getMaterialName());
|
||||
childEntity.setMaterialDesc(material.getMaterialDesc());
|
||||
childEntity.setUnitWeight(material.getWeight());
|
||||
childEntity.setNum(material.getQty());
|
||||
this.resultChild.add(childEntity);
|
||||
return childEntity;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建一般零部件Bom-子级
|
||||
*
|
||||
* @param material
|
||||
*/
|
||||
protected BomNewOriginalChildEntity buildCommonChildEntity(BaseMaterialVO material, BomNewOriginalParentEntity parent) {
|
||||
BomNewOriginalChildEntity childEntity = new BomNewOriginalChildEntity();
|
||||
|
||||
|
||||
childEntity.setParentRowId(parent.getRowId());
|
||||
childEntity.setOrderNumber("001");
|
||||
childEntity.setDrawingNo(material.getDrawingNo());
|
||||
childEntity.setMaterialNo(material.getMaterialNo());
|
||||
childEntity.setMaterialName(material.getMaterialName());
|
||||
childEntity.setMaterialDesc(material.getMaterialDesc());
|
||||
childEntity.setUnitWeight(parent.getUnitWeight());
|
||||
childEntity.setNum(parent.getNum());
|
||||
this.resultChild.add(childEntity);
|
||||
return childEntity;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过规则获取编码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected MaterialMateVO getMaterialByRel(BomOriginalPlmBomVO originalPlmBomVO) {
|
||||
MaterialMateCache mateCache = new MaterialMateCache();
|
||||
MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(originalPlmBomVO.getMaterialName(), originalPlmBomVO.getMaterial());
|
||||
return materialMate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过规则获取编码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected MaterialMateVO getMaterialByRel(BomNewOriginalParentEntity originalPlmBomVO) {
|
||||
MaterialMateCache mateCache = new MaterialMateCache();
|
||||
MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(originalPlmBomVO.getMaterialName(), originalPlmBomVO.getMaterialTexture());
|
||||
return materialMate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除父几点内容
|
||||
*
|
||||
* @param parentId
|
||||
*/
|
||||
protected void delBomChild(Long parentId) {
|
||||
SpringUtil.getBean(BomNewOriginalChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", parentId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取原始BOM
|
||||
*
|
||||
* @param parentId
|
||||
*/
|
||||
protected List<BomNewOriginalChildEntity> getBomChild(Long parentId) {
|
||||
return SpringUtil.getBean(BomNewOriginalChildService.class).lambdaQuery().eq(BomNewOriginalChildEntity::getParentRowId, parentId).list();
|
||||
}
|
||||
|
||||
/**
|
||||
* bom-子节点对比
|
||||
*
|
||||
* @param oldChildList
|
||||
* @param newChildList
|
||||
*/
|
||||
protected boolean isSame(List<BomNewOriginalChildEntity> oldChildList, List<BomNewOriginalChildEntity> newChildList) {
|
||||
if (oldChildList.size() != newChildList.size()) {
|
||||
return false;
|
||||
}
|
||||
final List<String> compareFields = ImmutableList.of("drawingNo", "num");
|
||||
Map<String, Map<String, Object>> stringMapMap = ClassCompareUtil.compareObject(oldChildList, newChildList, compareFields);
|
||||
if (stringMapMap.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,54 @@
|
|||
package com.nflg.product.bomnew.service.domain.OriginalBom;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialMateVO;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.service.cache.MaterialMateCache;
|
||||
import org.apache.catalina.authenticator.jaspic.CallbackHandlerImpl;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 一般零部件处理类
|
||||
* @author 大米
|
||||
* @date 2023/11/9 17:58
|
||||
*/
|
||||
public class CommonMaterialConvert extends BaseConvert{
|
||||
* 一般零部件处理类(200901)
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/9 17:58
|
||||
*/
|
||||
public class CommonMaterialConvert extends BaseConvert {
|
||||
|
||||
public static void handler(BomOriginalPlmBomVO material){
|
||||
|
||||
/**
|
||||
* 处理一般零部件
|
||||
*
|
||||
* @param material
|
||||
* @param parent
|
||||
*/
|
||||
public void handler(BomOriginalPlmBomVO material, BomNewOriginalParentEntity parent) {
|
||||
|
||||
//通过规则获取物料编码
|
||||
MaterialMateCache mateCache =new MaterialMateCache();
|
||||
MaterialMateCache mateCache = new MaterialMateCache();
|
||||
MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(material.getMaterialName(), material.getMaterial());
|
||||
|
||||
//找到对应物料
|
||||
if(Objects.nonNull(materialMate)){
|
||||
if (Objects.nonNull(materialMate)) {
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//通过编码+单重找原始BOM
|
||||
BomNewOriginalParentEntity origianBom = SpringUtil.getBean(BomNewOriginalParentService.class).lambdaQuery().eq(BomNewOriginalParentEntity::getMaterialNo, material.getMaterialNo())
|
||||
.eq(BomNewOriginalParentEntity::getUnitWeight, material.getWeight())
|
||||
.eq(BomNewOriginalParentEntity::getLastVersionIs,1).one();
|
||||
//包含原始BOM -保存到关系表
|
||||
if(Objects.nonNull(origianBom)){
|
||||
|
||||
|
||||
BomNewOriginalParentEntity origianBom = getOriginalBomForCommonMaterial(material.getMaterialNo(), material.getWeight());
|
||||
//没有原始BOM 则创建BOM-版本
|
||||
if (Objects.isNull(origianBom)) {
|
||||
buildParentEntity(material);
|
||||
buildChildEntity(material, parent);
|
||||
} else {
|
||||
if (origianBom.getStatus().equals(OriginalStatusEnum.UN_CONVERT.getValue())) {
|
||||
buildChildEntity(material, parent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BomNewOriginalChildEntity buildChildEntity(BomOriginalPlmBomVO material){
|
||||
BomNewOriginalChildEntity childEntity=new BomNewOriginalChildEntity();
|
||||
childEntity.setRowId(IdWorker.getId());
|
||||
childEntity.setParentRowId(0L);
|
||||
return childEntity;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package com.nflg.product.bomnew.service.domain.OriginalBom;
|
||||
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 非一般零部件处理类(200901)
|
||||
* @author 大米
|
||||
* @date 2023/11/10 9:50
|
||||
*/
|
||||
public class NoCommonMaterialConvert extends BaseConvert {
|
||||
|
||||
|
||||
|
||||
public void handler(BomOriginalPlmBomVO material) {
|
||||
BomNewOriginalParentEntity originalBom = getOriginalBomForMaterial(material.getChartNo());
|
||||
|
||||
if(Objects.isNull(originalBom)){
|
||||
//创建父级
|
||||
buildParentEntity(material);
|
||||
|
||||
}
|
||||
else {
|
||||
//草稿数据
|
||||
if(OriginalStatusEnum.UN_CONVERT.equalsValue(originalBom.getStatus())){
|
||||
|
||||
}
|
||||
//非草稿数据
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,57 +1,133 @@
|
|||
package com.nflg.product.bomnew.service.domain.OriginalBom;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.nflg.product.bomnew.constant.OriginalConstant;
|
||||
import com.nflg.product.bomnew.constant.OriginalStatusEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.MaterialMainMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomOriginalPlmChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomOriginalPlmParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialMateVO;
|
||||
import com.nflg.product.bomnew.service.BomOriginalPlmChildService;
|
||||
import com.nflg.product.bomnew.service.cache.MaterialMateCache;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* plm-bom转原始BOM
|
||||
* @author 大米
|
||||
* @date 2023/11/9 14:21
|
||||
*/
|
||||
* plm-bom转原始BOM
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/9 14:21
|
||||
*/
|
||||
public class PlmBomToOriginalConvert extends BaseConvert {
|
||||
|
||||
|
||||
List<BomOriginalPlmBomVO> data=new ArrayList<>();
|
||||
public PlmBomToOriginalConvert(BomOriginalPlmParentEntity inParent){
|
||||
List<BomOriginalPlmBomVO> data = new ArrayList<>();
|
||||
|
||||
this.parent=Convert.convert(BomOriginalPlmBomVO.class, inParent);
|
||||
data.add(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转原始BOM
|
||||
*/
|
||||
public void convertOriginalBom(){
|
||||
List<BomOriginalPlmBomVO> childs = Convert.toList(BomOriginalPlmBomVO.class, SpringUtil.getBean(BomOriginalPlmChildService.class).lambdaQuery().eq(BomOriginalPlmChildEntity::getParentRowId, parent.getRowId()).list());
|
||||
data.addAll(childs);
|
||||
|
||||
intiMaterialInfo(data);
|
||||
|
||||
|
||||
public void convertOriginalBom(BomOriginalPlmParentEntity inParent) {
|
||||
childs = Convert.toList(BomOriginalPlmBomVO.class, SpringUtil.getBean(BomOriginalPlmChildService.class).lambdaQuery().eq(BomOriginalPlmChildEntity::getParentRowId, parent.getRowId()).list());
|
||||
parent = Convert.convert(BomOriginalPlmBomVO.class, inParent);
|
||||
//初始化物料信息
|
||||
intiMaterialInfo(ImmutableList.of(parent));
|
||||
intiMaterialInfo(childs);
|
||||
//开始转原始BOM
|
||||
handlerBom();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理父类
|
||||
*/
|
||||
private void handlerParent(){
|
||||
//一般零部件
|
||||
if(isCommonMaterial(parent)){
|
||||
private void handlerBom() {
|
||||
//获取原始BOM
|
||||
BomNewOriginalParentEntity originalBom = getOriginalBomForMaterial(parent.getChartNo());
|
||||
//沒有原始BOM
|
||||
if (Objects.isNull(originalBom)) {
|
||||
BomNewOriginalParentEntity parentEntity = buildParentEntity(parent);
|
||||
if (parent.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE) && CollUtil.isEmpty(childs)) {
|
||||
handlerCommonMaterial(parentEntity);
|
||||
} else {
|
||||
handlerChild(parentEntity);
|
||||
}
|
||||
} else { //有原始BOM
|
||||
//草稿状态
|
||||
if(OriginalStatusEnum.UN_CONVERT.equalsValue(originalBom.getStatus())){
|
||||
if (CollUtil.isNotEmpty(childs)){
|
||||
//用户一致:覆盖
|
||||
if(originalBom.getCreatedBy()==parent.getCreatedBy()){
|
||||
// 删除旧的内容
|
||||
delBomChild(originalBom.getRowId());
|
||||
handlerChild(originalBom);
|
||||
}
|
||||
else { //用户不一致
|
||||
if( isSame(getBomChild(originalBom.getRowId()),Convert.toList(BomNewOriginalChildEntity.class,childs) )){
|
||||
VUtils.isTure(true).throwMessage("数据和"+originalBom.getCreatedBy()+"导入的数据不一致,请沟通处理");
|
||||
}
|
||||
else {
|
||||
VUtils.isTure(true).throwMessage(originalBom.getCreatedBy()+"已导入了相同的BOM,直接引用");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else { //非草稿状态
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void handlerChild(BomNewOriginalParentEntity parentEntity) {
|
||||
|
||||
for (BomOriginalPlmBomVO childVo : childs) {
|
||||
buildChildEntity(childVo, parentEntity);
|
||||
|
||||
//一般零部件
|
||||
if (childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
BomNewOriginalParentEntity parentEntityCommon = buildParentEntity(childVo);
|
||||
handlerCommonMaterial(parentEntityCommon);
|
||||
|
||||
}
|
||||
//非一般零部件
|
||||
else {
|
||||
buildChildEntity(childVo, parentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理一般零部件的自己
|
||||
*/
|
||||
|
||||
|
||||
private void handlerCommonMaterial(BomNewOriginalParentEntity parentEntity) {
|
||||
//通过规则获取物料编码
|
||||
MaterialMateVO materialMate = getMaterialByRel(parentEntity);
|
||||
//找到对应物料
|
||||
if (Objects.nonNull(materialMate)) {
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialMate.getMaterialNo()));
|
||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
||||
//根据物料编码-
|
||||
buildCommonChildEntity(materialBaseInfo.get(0), parentEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 对象属性值对比
|
||||
* @Author luo
|
||||
* @Date 2021-06-17
|
||||
*/
|
||||
public class ClassCompareUtil {
|
||||
|
||||
final static Logger logger= LoggerFactory.getLogger(ClassCompareUtil.class);
|
||||
/**
|
||||
* 对比对象属性值
|
||||
* @param oldObject
|
||||
* @param newObject
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Map<String,Object>> compareObject(Object oldObject, Object newObject ,List<String> needCompareFields) {
|
||||
Map<String, Map<String,Object>> resultMap= compareFields(oldObject,newObject,needCompareFields);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
private static Map<String, Map<String,Object>> compareFields(Object oldObject, Object newObject,List<String> needCompareFields) {
|
||||
Map<String, Map<String, Object>> map = null;
|
||||
|
||||
try{
|
||||
/**
|
||||
* 只有两个对象都是同一类型的才有可比性
|
||||
*/
|
||||
if (oldObject.getClass() == newObject.getClass()) {
|
||||
map = new HashMap<String, Map<String,Object>>(16);
|
||||
|
||||
Class clazz = oldObject.getClass();
|
||||
//获取object的所有属性
|
||||
PropertyDescriptor[] pds = Introspector.getBeanInfo(clazz,Object.class).getPropertyDescriptors();
|
||||
|
||||
for (PropertyDescriptor pd : pds) {
|
||||
//遍历获取属性名
|
||||
String name = pd.getName();
|
||||
//判断是否为需比较的字段
|
||||
if(needCompareFields.contains(name) ) {
|
||||
//获取属性的get方法
|
||||
Method readMethod = pd.getReadMethod();
|
||||
|
||||
// 在oldObject上调用get方法等同于获得oldObject的属性值
|
||||
Object oldValue = readMethod.invoke(oldObject);
|
||||
// 在newObject上调用get方法等同于获得newObject的属性值
|
||||
Object newValue = readMethod.invoke(newObject);
|
||||
|
||||
if (oldValue instanceof List) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newValue instanceof List) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oldValue == null && newValue == null) {
|
||||
continue;
|
||||
|
||||
} else if (oldValue == null && newValue != null) {
|
||||
Map<String, Object> valueMap = new HashMap<String, Object>(16);
|
||||
valueMap.put("oldValue", oldValue);
|
||||
valueMap.put("newValue", newValue);
|
||||
map.put(name, valueMap);
|
||||
continue;
|
||||
}
|
||||
// 比较这两个值是否相等,不等就可以放入map了
|
||||
if (!oldValue.equals(newValue)) {
|
||||
Map<String, Object> valueMap = new HashMap<String, Object>(16);
|
||||
valueMap.put("oldValue", oldValue);
|
||||
valueMap.put("newValue", newValue);
|
||||
map.put(name, valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.error("bom 版本对比字段比较失败".concat(e.getMessage()));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 版本 工具类
|
||||
*
|
||||
* @author 大米
|
||||
* @date 2023/11/10 9:09
|
||||
*/
|
||||
public class VersionUtil {
|
||||
|
||||
static final String versionPrefix = "A";
|
||||
|
||||
public static String getNextVersion(String preVersion) {
|
||||
if (StrUtil.isBlank(preVersion)) {
|
||||
return versionPrefix + "-1";
|
||||
}
|
||||
|
||||
Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, "A", "")) + 1;
|
||||
return versionPrefix + StrUtil.padPre(versionNum.toString(), 2, '0');
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
<result column="material_name" property="materialName" jdbcType="VARCHAR"/>
|
||||
<result column="material_desc" property="materialDesc" jdbcType="VARCHAR"/>
|
||||
<result column="unit_weight" property="unitWeight" jdbcType="DECIMAL"/>
|
||||
<result column="num" property="num" jdbcType="DECIMAL"/>
|
||||
<result column="num" property="num" jdbcType="INTEGER"/>
|
||||
<result column="total_weight" property="totalWeight" jdbcType="DECIMAL"/>
|
||||
</resultMap>
|
||||
|
||||
|
|
@ -21,7 +21,5 @@
|
|||
<!--@mbg.generated-->
|
||||
row_id, parent_row_id, order_number, drawing_no, material_no, material_name, material_desc, unit_weight, num, total_weight </sql>
|
||||
|
||||
<select id="getOrigianlBomList">
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="edit_status" property="editStatus" jdbcType="INTEGER"/>
|
||||
<result column="convert_to_ebom_time" property="convertToEbomTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="dept_row_id" property="deptRowId" jdbcType="INTEGER"/>
|
||||
<result column="dept_row_id" property="deptRowId" jdbcType="BIGINT"/>
|
||||
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
|
||||
<result column="source" property="source" jdbcType="INTEGER"/>
|
||||
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
|
||||
<select id="getMaterialBaseInfo" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO">
|
||||
select material_no, material_name, material_desc, procure_type, project_type, material_state
|
||||
select material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no
|
||||
from t_material_main
|
||||
where material_no in
|
||||
<foreach collection="materialNos" item="item" open="(" close=")">
|
||||
|
|
|
|||
Loading…
Reference in New Issue