EBOM修复

This commit is contained in:
大米 2024-01-09 12:19:24 +08:00
parent 55da2e01c0
commit f6cb5cf326
13 changed files with 372 additions and 198 deletions

View File

@ -15,6 +15,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.*;
import com.nflg.product.bomnew.service.cache.MaterialMateCache;
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase;
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31;
import com.nflg.product.bomnew.util.EecExcelUtil;
@ -353,6 +354,16 @@ public class EbomApi extends BaseApi {
@GetMapping("getrel")
@ApiOperation("模糊匹配物料")
public ResultVO<MaterialMateVO> getRelMaterial(@RequestParam(value = "materialName", required = false) String materialName ,@RequestParam(value = "materialTexture" ,required = false) String materialTexture ){
MaterialMateCache mateCache = new MaterialMateCache();
MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(materialName,materialTexture);
return ResultVO.success(materialMate) ;
}

View File

@ -16,6 +16,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewTechnologyPackageTypeVO;
import com.nflg.product.bomnew.service.BomNewPbomParentService;
import com.nflg.product.bomnew.service.BomNewTechnologyPackageTypeService;
import com.nflg.product.bomnew.service.UserRoleService;
import com.nflg.product.bomnew.util.VUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -52,6 +53,9 @@ public class PBomApi extends BaseApi {
@Resource
private BomNewTechnologyPackageTypeService technologyPackageTypeService;
@Resource
private UserRoleService userRoleService;
@PostMapping("workDetailsListByPage")
@ApiOperation("PBom工作列表")
@ -199,6 +203,14 @@ public class PBomApi extends BaseApi {
}
@GetMapping("getUserFacCode")
@ApiOperation("获取当前用户所在工厂")
public ResultVO<List<String>> getUserFacCode(@RequestParam("bomRowId") Long bomRowId) {
return ResultVO.success(userRoleService.getUserOfFactory());
}

View File

@ -2,308 +2,326 @@ package com.nflg.product.bomnew.pojo.entity;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.time.LocalDate;
/**
* t_bom_new_pbom_parent
*
* t_bom_new_pbom_parent
*
* @author makejava
* @since 2024-01-01 10:39:58
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-entity-BomNewPbomParentEntity")
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-entity-BomNewPbomParentEntity")
@TableName(value = "t_bom_new_pbom_parent")
public class BomNewPbomParentEntity implements Serializable {
/**
* 主键行ID-雪花
*/
@TableId(value = "row_id", type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键行ID-雪花")
private Long rowId;
/**
* 批号-来自plm-临时
*/
@TableField(value = "batch_no")
@ApiModelProperty(value = "批号-来自plm-临时")
@TableField(value = "batch_no")
@ApiModelProperty(value = "批号-来自plm-临时")
private String batchNo;
/**
* 图号
*/
@TableField(value = "drawing_no")
@ApiModelProperty(value = "图号")
@TableField(value = "drawing_no")
@ApiModelProperty(value = "图号")
private String drawingNo;
/**
* 工厂编码
*/
@TableField(value = "fac_code")
@ApiModelProperty(value = "工厂编码")
@TableField(value = "fac_code")
@ApiModelProperty(value = "工厂编码")
private String facCode;
/**
* 物料编码
*/
@TableField(value = "material_no")
@ApiModelProperty(value = "物料编码")
@TableField(value = "material_no")
@ApiModelProperty(value = "物料编码")
private String materialNo;
/**
* 排序号
*/
@TableField(value = "order_number")
@ApiModelProperty(value = "排序号")
@TableField(value = "order_number")
@ApiModelProperty(value = "排序号")
private String orderNumber;
/**
* 物料名称
*/
@TableField(value = "material_name")
@ApiModelProperty(value = "物料名称")
@TableField(value = "material_name")
@ApiModelProperty(value = "物料名称")
private String materialName;
/**
* 物料描述
*/
@TableField(value = "material_desc")
@ApiModelProperty(value = "物料描述")
@TableField(value = "material_desc")
@ApiModelProperty(value = "物料描述")
private String materialDesc;
/**
* 材质材料
*/
@TableField(value = "material_texture")
@ApiModelProperty(value = "材质,材料")
@TableField(value = "material_texture")
@ApiModelProperty(value = "材质,材料")
private String materialTexture;
/**
* 单位
*/
@TableField(value = "material_unit")
@ApiModelProperty(value = "单位")
@TableField(value = "material_unit")
@ApiModelProperty(value = "单位")
private String materialUnit;
/**
* 单重
*/
@TableField(value = "unit_weight")
@ApiModelProperty(value = "单重")
@TableField(value = "unit_weight")
@ApiModelProperty(value = "单重")
private BigDecimal unitWeight;
/**
* 总重
*/
@TableField(value = "total_weight")
@ApiModelProperty(value = "总重")
@TableField(value = "total_weight")
@ApiModelProperty(value = "总重")
private BigDecimal totalWeight;
/**
* 版本号
*/
@TableField(value = "current_version")
@ApiModelProperty(value = "版本号")
@TableField(value = "current_version")
@ApiModelProperty(value = "版本号")
private String currentVersion;
/**
* 数量
*/
@TableField(value = "num")
@ApiModelProperty(value = "数量")
@TableField(value = "num")
@ApiModelProperty(value = "数量")
private BigDecimal num;
/**
* 项目类别
*/
@TableField(value = "project_type")
@ApiModelProperty(value = "项目类别")
@TableField(value = "project_type")
@ApiModelProperty(value = "项目类别")
private String projectType;
/**
* 是否跟节点 0- 1-
*/
@TableField(value = "root_is")
@ApiModelProperty(value = "是否跟节点 0-否 1-是")
@TableField(value = "root_is")
@ApiModelProperty(value = "是否跟节点 0-否 1-是")
private Integer rootIs;
/**
* 是否应该有BOM 0- 1-
*/
@TableField(value = "should_bom_exist")
@ApiModelProperty(value = "是否应该有BOM 0-否 1-是")
@TableField(value = "should_bom_exist")
@ApiModelProperty(value = "是否应该有BOM 0-否 1-是")
private Integer shouldBomExist;
/**
* 超级物料 0- 1-
*/
@TableField(value = "super_material_status")
@ApiModelProperty(value = "超级物料 0-否 1-是")
@TableField(value = "super_material_status")
@ApiModelProperty(value = "超级物料 0-否 1-是")
private Integer superMaterialStatus;
/**
* 是否有BOM: 0- 1-
*/
@TableField(value = "bom_exist")
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
@TableField(value = "bom_exist")
@ApiModelProperty(value = "是否有BOM: 0-否 1-是")
private Integer bomExist;
/**
* 是否最新版0- 1-
*/
@TableField(value = "last_version_is")
@ApiModelProperty(value = "是否最新版0-否 1-是")
@TableField(value = "last_version_is")
@ApiModelProperty(value = "是否最新版0-否 1-是")
private Integer lastVersionIs;
/**
* 1=待处理2=暂存 3=已处理
*/
@TableField(value = "edit_status")
@ApiModelProperty(value = "1=待处理、2=暂存 3=已处理")
@TableField(value = "edit_status")
@ApiModelProperty(value = "1=待处理、2=暂存 3=已处理")
private Integer editStatus;
/**
* BOM状态1=待发布 2=待分配工厂 3=已分配工厂 4=已发布
*/
@TableField(value = "status")
@ApiModelProperty(value = "BOM状态1=待发布 4=已发布 8=待分配工厂 16=已分配工厂")
@TableField(value = "status")
@ApiModelProperty(value = "BOM状态1=待发布 4=已发布 8=待分配工厂 16=已分配工厂")
private Integer status;
/**
* 是否用户跟节点 0- 1-
*/
@TableField(value = "user_root_is")
@ApiModelProperty(value = "是否用户跟节点 0-否 1-是")
@TableField(value = "user_root_is")
@ApiModelProperty(value = "是否用户跟节点 0-否 1-是")
private Integer userRootIs;
/**
* 是否虚拟包 0- 1-
*/
@TableField(value = "virtual_package_is")
@ApiModelProperty(value = "是否虚拟包 0-否 1-是")
@TableField(value = "virtual_package_is")
@ApiModelProperty(value = "是否虚拟包 0-否 1-是")
private Integer virtualPackageIs;
/**
* 来源行ID(EBOM中的行ID)
*/
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行ID(EBOM中的行ID)")
@TableField(value = "source_row_id")
@ApiModelProperty(value = "来源行ID(EBOM中的行ID)")
private Long sourceRowId;
/**
* 设计人员编码
*/
@TableField(value = "devise_user_code")
@ApiModelProperty(value = "设计人员编码")
@TableField(value = "devise_user_code")
@ApiModelProperty(value = "设计人员编码")
private String deviseUserCode;
/**
* 设计人员名称
*/
@TableField(value = "devise_name")
@ApiModelProperty(value = "设计人员名称")
@TableField(value = "devise_name")
@ApiModelProperty(value = "设计人员名称")
private String deviseName;
/**
* 工艺人员编码
*/
@TableField(value = "technology_user_code")
@ApiModelProperty(value = "工艺人员编码")
private String technologyUserCode;
/**
* 工艺人员名称
*/
@TableField(value = "technology_user_name")
@ApiModelProperty(value = "工艺人员名称")
private String technologyUserName;
/**
* 创建人编码
*/
@TableField(value = "created_by")
@ApiModelProperty(value = "创建人编码")
@TableField(value = "created_by")
@ApiModelProperty(value = "创建人编码")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_time")
@ApiModelProperty(value = "创建时间")
@TableField(value = "created_time")
@ApiModelProperty(value = "创建时间")
private LocalDateTime createdTime;
/**
* 创建人员所属岗位 0-设计人员 1-工艺人员 2-其他
*/
@TableField(value = "created_job")
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
@TableField(value = "created_job")
@ApiModelProperty(value = "创建人员所属岗位 0-设计人员 1-工艺人员 2-其他")
private Integer createdJob;
/**
* 发布时间
*/
@TableField(value = "release_time")
@ApiModelProperty(value = "发布时间")
@TableField(value = "release_time")
@ApiModelProperty(value = "发布时间")
private LocalDateTime releaseTime;
/**
* 发布人
*/
@TableField(value = "release_user_name")
@ApiModelProperty(value = "发布人")
@TableField(value = "release_user_name")
@ApiModelProperty(value = "发布人")
private String releaseUserName;
/**
* 版本过期时间=下个版本的创建时间
*/
@TableField(value = "expire_end_time")
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
@TableField(value = "expire_end_time")
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
private LocalDateTime expireEndTime;
/**
* 备注
*/
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
@TableField(value = "remark")
@ApiModelProperty(value = "备注")
private String remark;
/**
* 设计维护部门名称
*/
@TableField(value = "dept_name")
@ApiModelProperty(value = "设计维护部门名称")
@TableField(value = "dept_name")
@ApiModelProperty(value = "设计维护部门名称")
private String deptName;
/**
* bom树的高度
*/
@TableField(value = "level_num")
@ApiModelProperty(value = "bom树的高度")
@TableField(value = "level_num")
@ApiModelProperty(value = "bom树的高度")
private Integer levelNum;
/**
* 升版说明
*/
@TableField(value = "change_desc")
@ApiModelProperty(value = "升版说明")
@TableField(value = "change_desc")
@ApiModelProperty(value = "升版说明")
private String changeDesc;
/**
* 通知单号
*/
@TableField(value = "notice_nums")
@ApiModelProperty(value = "通知单号")
@TableField(value = "notice_nums")
@ApiModelProperty(value = "通知单号")
private String noticeNums;
/**
* 订单号
*/
@TableField(value = "order_no")
@ApiModelProperty(value = "订单号")
@TableField(value = "order_no")
@ApiModelProperty(value = "订单号")
private String orderNo;
/**
* 修改时间
*/
@TableField(value = "modify_time")
@ApiModelProperty(value = "修改时间")
@TableField(value = "modify_time")
@ApiModelProperty(value = "修改时间")
private LocalDateTime modifyTime;
private static final long serialVersionUID = -31999878274445137L;
}

View File

@ -1,5 +1,6 @@
package com.nflg.product.bomnew.pojo.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -178,6 +179,9 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty(value = "设计人员名称")
private String deviseName;
/**
* 创建人编码
*/

View File

@ -2,6 +2,8 @@ package com.nflg.product.bomnew.pojo.vo;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import cn.hutool.core.date.LocalDateTimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
@ -158,6 +160,19 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
*/
@ApiModelProperty(value = "设计人员名称")
private String deviseName;
/**
* 工艺人员编码
*/
@ApiModelProperty(value = "工艺人员编码")
private String technologyUserCode;
/**
* 工艺人员名称
*/
@ApiModelProperty(value = "工艺人员名称")
private String technologyUserName;
/**
* 创建人编码
@ -194,7 +209,11 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
*/
@ApiModelProperty(value = "版本过期时间=下个版本的创建时间")
private LocalDateTime expireEndTime;
public String getExpireEndTime() {
return expireEndTime==null? LocalDateTimeUtil.format(LocalDateTime.MAX,"yy-MM-dd HH:mm:ss"):LocalDateTimeUtil.format(expireEndTime,"yyyy-MM-dd HH:mm:ss");
}
/**
* 备注
*/

View File

@ -133,7 +133,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
returnResult = result;
}
//动态判断异常
// CheckEBomExceptoinDynamic.check(returnResult.getRecords());
// CheckEBomExceptoinDynamic.check(returnResult.getRecords());
return returnResult;
}
@ -148,12 +148,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
resutlData.setPages(1);
resutlData.setCurrent(1L);
List<BomNewEbomParentVO> all = new ArrayList<>();
// all.addAll(resultParents);
// all.addAll(resultParents);
all.addAll(childs);
List<BomNewEbomParentVO> result = new ArrayList<>();
for (BomNewEbomParentVO vo : resultParents) {
//vo.setParentRowId(0L);
List<BomNewEbomParentVO> da=new ArrayList<>();
List<BomNewEbomParentVO> da = new ArrayList<>();
da.addAll(childs);
da.add(vo);
result.addAll(CTreeUtils.toTree(0L, da, BomNewEbomParentVO::getParentRowId, BomNewEbomParentVO::getBomRowId));
@ -272,13 +272,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
//排除项目类别的赋值
materialMainService.intiMaterialInfoInPattern(parentChild,"^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
materialMainService.intiMaterialInfoInPattern(parentChild, "^21 | ^31", EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
if (CollUtil.isNotEmpty(parentChild)) {
List<String> materialNos = parentChild.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(BomNewEbomParentEntity::getLastVersionIs, 1)
.eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()),BomNewEbomParentEntity::getStatus,EBomStatusEnum.PUBLISHED.getValue() ).list();
.eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
Map<String, BomNewEbomParentEntity> bomListMap = ListCommonUtil.listToMap(list, BomNewEbomParentEntity::getMaterialNo);
for (BomNewEbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) {
@ -340,7 +340,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
return result;
}
/**
* 获取整个BOM树
*
@ -355,10 +354,38 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewEbomParentVO> result = submit.join();
EBomToPBom eBomToPBom = new EBomToPBom();
eBomToPBom.generateDrawingNo(bomDetail, rowId, "");
return result;
}
/**
* 获取整个BOM树
*
* @param rowId
* @return
* @throws ExecutionException
* @throws InterruptedException
*/
public List<BomNewEbomParentVO> getBomTree(Long rowId, Boolean generateLevelNumberFlag) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
List<BomNewEbomParentVO> result = submit.join();
if (generateLevelNumberFlag) {
EBomToPBom eBomToPBom = new EBomToPBom();
eBomToPBom.generateDrawingNo(bomDetail, rowId, "");
}
return result;
}
public List<BomNewEbomParentVO> buildBomTreeContainSelf(Long rowId) throws ExecutionException, InterruptedException {
List<BomNewEbomParentVO> list = getBomTree(rowId);
@ -538,10 +565,10 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
*/
public void generateVirtualPackage(VirtualPackageParamDto paramDto) {
try {
BomNewEbomParentEntity root= this.getById(paramDto.getBomRowId());
Boolean flag=true;
for (Integer f :paramDto.getVirtualPackageValue()) {
flag=flag & ( (root.getVirtrualPackageEnum() & f)==f);
BomNewEbomParentEntity root = this.getById(paramDto.getBomRowId());
Boolean flag = true;
for (Integer f : paramDto.getVirtualPackageValue()) {
flag = flag & ((root.getVirtrualPackageEnum() & f) == f);
}
VUtils.isTure(flag).throwMessage("已生成虚拟包,无需重复生成");
@ -1409,17 +1436,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
vo.setDeviseName(SessionUtil.getRealName());
vo.setCreatedBy(SessionUtil.getUserCode());
if (vo.getUnitWeight() == null ||BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) {
if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) {
vo.setUnitWeight(vo.getMaterialWeight());
}
vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
}
}
}
}
return dto.getDatas();
}
}
}

View File

@ -208,6 +208,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
child.setTechnologyUserCode(parentEntity.getTechnologyUserCode());
child.setTechnologyUserName(parentEntity.getTechnologyUserName());
if (parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
@ -222,6 +224,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setStatus(parent.getStatus());
child.setEditStatus(parent.getEditStatus());
child.setVirtualPackageIs(parent.getVirtualPackageIs());
child.setTechnologyUserCode(parent.getTechnologyUserCode());
child.setTechnologyUserName(parent.getTechnologyUserName());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus());
@ -285,7 +289,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
//删除辅助物料
List<BomNewPbomParentVO> noDelList = childListVO.stream().filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021")).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料,以下物料为非辅助物料:" + StrUtil.join(",", noDelList));
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.service;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.UserJobEnum;
@ -65,4 +66,19 @@ public class UserRoleService {
return SessionUtil.getFullDeptName().contains("仙桃公司")?"1020":"1010";
}
}
/**
* 获取用户工厂
* 多工厂权限时返回空
* @return
*/
public List<String> getUserOfFactory(){
Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId());
if(userMultiplantFacRoleCount>0){
return ImmutableList.of("1010","1020");
}else {
return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of("1020") : ImmutableList.of("1010") ;
}
}
}

View File

@ -36,13 +36,13 @@ import java.util.stream.Collectors;
public class CheckEBomException {
@Getter
List<BomNewEbomParentVO> allBomDetail ;
@Setter
List<BomNewEbomParentVO> allBomDetail;
@Setter
List<Integer> unCheckExcept;
public static void checkMaterialNoInMain1(List<String> materialNos){
// List<String> materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
public static void checkMaterialNoInMain1(List<String> materialNos) {
// List<String> materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
//检查物料编码是否在主数据中存在
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
@ -50,28 +50,28 @@ public class CheckEBomException {
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
}
public static void checkMaterialNoInMain(List<BomNewEbomParentVO> list){
List<String> materialNos = list.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
public static void checkMaterialNoInMain(List<BomNewEbomParentVO> list) {
List<String> materialNos = list.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
checkMaterialNoInMain1(materialNos);
}
}
public CheckEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId);
allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).getBomTree(bomRowId, true);
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).getById(bomRowId);
BomNewEbomParentVO convert = Convert.convert(BomNewEbomParentVO.class, parent);
convert.setBomRowId(convert.getRowId());
convert.setParentRowId(0L);
convert.setLevelNumber(BigDecimal.ZERO);
allBomDetail.add(convert);
// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
// allBomDetail = SpringUtil.getBean(BomNewEbomParentService.class).buildBomTreeContainSelf(bomRowId);
}
/**
*
* @param allBom 整颗BOM树包含跟节点
* @param allBom 整颗BOM树包含跟节点
*/
public CheckEBomException(List<BomNewEbomParentVO> allBom) {
allBomDetail = allBom;
@ -88,26 +88,25 @@ public class CheckEBomException {
}
public void initException( String ... ignorePropertyList) {
public void initException(String... ignorePropertyList) {
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail,ignorePropertyList);
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(allBomDetail, ignorePropertyList);
checkException();
}
public void checkException(){
public void checkException() {
for (BomNewEbomParentVO vo : allBomDetail) {
// if(Objects.isNull(vo.getExceptionStatus())) {
// if(Objects.isNull(vo.getExceptionStatus())) {
//忽略不检查的如14
if(CollectionUtil.isNotEmpty(unCheckExcept)
&& vo.getExceptionStatus()!=null
&&unCheckExcept.contains(vo.getExceptionStatus())){
continue;
if (CollectionUtil.isNotEmpty(unCheckExcept)
&& vo.getExceptionStatus() != null
&& unCheckExcept.contains(vo.getExceptionStatus())) {
continue;
}
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
// }
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()))) {
@ -119,10 +118,9 @@ public class CheckEBomException {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_4.getValue());
} else if (StrUtil.isNotBlank(vo.getMaterialNo()) && Objects.isNull(vo.getMaterialState())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
} else if (StrUtil.isBlank(vo.getProjectType()) && (vo.getRootIs()==null || vo.getRootIs()==0)) {
} else if (StrUtil.isBlank(vo.getProjectType()) && (vo.getRootIs() == null || vo.getRootIs() == 0)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())){
} else if (StrUtil.isNotBlank(vo.getNoticeNums()) && EBomExceptionStatusEnum.EXCEPT_NO_11.equalsValue(vo.getExceptionStatus())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
}
@ -131,15 +129,13 @@ public class CheckEBomException {
}
/**
* 检查 EXCEPT_NO_3 EXCEPT_NO_6 EXCEPT_NO_9 EXCEPT_NO_10
*
* @param
*/
private void checkOther() {
// List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
// List<CheckEBomExceptionDTO> checkEBomExceptionDTOS=new ArrayList<>();
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
for (BomNewEbomParentVO parent : parents) {
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getBomRowId())).collect(Collectors.toList());
@ -184,20 +180,30 @@ public class CheckEBomException {
}
/**
* 黄色警号异常
* 黄色警号异常
*
* @param list
*/
public void initExceptionYellowWarn( List<BomNewEbomParentVO> list ){
public void initExceptionYellowWarn(List<BomNewEbomParentVO> list) {
List<BomNewEbomParentVO> exceptionList = allBomDetail.stream().filter(u -> u.getExceptionStatus() > 1).collect(Collectors.toList());
List<String> exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if(CollUtil.isEmpty(exceptionMaterialNos)){
// List<String> exceptionMaterialNos = exceptionList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
if (CollUtil.isEmpty(exceptionList)) {
return;
}
List<String> allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos);
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
warnList.forEach(k->{
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
});
for (BomNewEbomParentVO exItem : list) {
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> exItem.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
warnList.forEach(k -> {
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
});
}
// List<String> allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos);
// List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
// warnList.forEach(k->{
// k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
// });
}
@ -205,10 +211,10 @@ public class CheckEBomException {
* 检查循环依赖
*/
private void checkCircularDependency(List<CheckEBomExceptionDTO> list) {
List<Long> result = TreeUtils.checkParentChildRelationship(list, CheckEBomExceptionDTO::getParentMaterialNo, CheckEBomExceptionDTO::getChildMaterialNo, CheckEBomExceptionDTO::getRowId);
if(CollUtil.isNotEmpty(result)){
List<Long> result = TreeUtils.checkParentChildRelationship(list, CheckEBomExceptionDTO::getParentMaterialNo, CheckEBomExceptionDTO::getChildMaterialNo, CheckEBomExceptionDTO::getRowId);
if (CollUtil.isNotEmpty(result)) {
List<BomNewEbomParentVO> collect = allBomDetail.stream().filter(u -> result.contains(u.getRowId())).collect(Collectors.toList());
collect.forEach(u->{
collect.forEach(u -> {
u.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_3.getValue());
});
@ -216,31 +222,26 @@ public class CheckEBomException {
}
public void checkContainExcept(List<Integer> codeList) throws NflgBusinessException {
public void checkContainExcept(List<Integer> codeList) throws NflgBusinessException {
if (CollUtil.isEmpty(codeList)) return;
if(CollUtil.isEmpty(codeList))return;
for (BomNewEbomParentVO item:
allBomDetail) {
for (BomNewEbomParentVO item :
allBomDetail) {
//并集 寻找相同
List<Integer> list=CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());;
List<Integer> list = CollectionUtil.intersection(codeList, ImmutableList.of(item.getExceptionStatus())).stream().collect(Collectors.toList());
;
if(CollUtil.isNotEmpty(list)){
if (CollUtil.isNotEmpty(list)) {
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编码{} 异常情况 {}",item.getMaterialNo(),EBomExceptionStatusEnum.code2description(list.get(0)) ));
throw new NflgBusinessException(STATE.BusinessError, StrUtil.format("物料编码{} 异常情况 {}", item.getMaterialNo(), EBomExceptionStatusEnum.code2description(list.get(0))));
}
}
}
}
}

View File

@ -24,6 +24,7 @@ import com.nflg.product.bomnew.util.ListCommonUtil;
import com.nflg.product.bomnew.util.VUtils;
import com.nflg.product.bomnew.util.VersionUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.bouncycastle.crypto.engines.EthereumIESEngine;
import java.math.BigDecimal;
@ -34,6 +35,7 @@ import java.util.stream.Collectors;
/**
* Ebom 转Pbom
*/
@NoArgsConstructor
public class EBomToPBom {
private BomNewEbomParentVO parent;
@ -93,7 +95,9 @@ public class EBomToPBom {
//子级
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(child)) {
for (BomNewEbomParentVO eb : child) {
//合并子级
List<BomNewEbomParentVO> mergeChild = mergeChild(child);
for (BomNewEbomParentVO eb : mergeChild) {
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
BeanUtil.copyProperties(eb, childEnt);
childEnt.setRowId(IdWorker.getId());
@ -102,10 +106,28 @@ public class EBomToPBom {
childEnt.setIdentityNo(StrUtil.join("-", parentEnt.getMaterialNo(), eb.getMaterialNo()));
this.pBomChildResult.add(childEnt);
}
}
}
}
}
//合并子级
public List<BomNewEbomParentVO> mergeChild (List<BomNewEbomParentVO> child){
List<BomNewEbomParentVO> result=child.stream().filter(u->StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
Map<String, List<BomNewEbomParentVO>> listMp = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo);
for ( String key: listMp.keySet()) {
List<BomNewEbomParentVO> voList = listMp.get(key);
BomNewEbomParentVO ent = voList.get(0);
ent.setNum(voList.stream().map(aa -> aa.getNum()).reduce(BigDecimal.ZERO, BigDecimal::add));
result.add(ent);
}
return result;
}
/**
* 数据效验
@ -142,6 +164,9 @@ public class EBomToPBom {
pBomParent.setRowId(IdWorker.getId());
pBomParent.setLastVersionIs(1);
pBomParent.setFacCode(facCode);
pBomParent.setTechnologyUserCode(SessionUtil.getUserCode());
pBomParent.setTechnologyUserName(SessionUtil.getRealName());
this.pBomParentResult.add(pBomParent);
return pBomParent;
}
@ -331,7 +356,7 @@ public class EBomToPBom {
* @param bomRowID
* @param parentDrawingNo
*/
private void generateDrawingNo(List<BomNewEbomParentVO> saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) {
public void generateDrawingNo(List<BomNewEbomParentVO> saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) {
List<BomNewEbomParentVO> firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList());
parentDrawingNo = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : "";
Integer gNo = 1;

View File

@ -52,9 +52,9 @@ public abstract class VirtualPackageBase {
protected BomNewEbomParentEntity buildParentVirtualPackage(String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType) throws IOException {
//申请物料
String vDrawingNo = String.join("",drawingNo,"(",virtualPackageType.getConMaterialName(),")" );
String vMaterialName = StrUtil.join("",materialName,"(",virtualPackageType.getConMaterialName(),")");
String vMaterialDesc = StrUtil.join("", drawingNo ," ", materialName,"(",virtualPackageType.getConMaterialName(),")");
String vDrawingNo = String.join("","(",drawingNo,")","(",virtualPackageType.getConMaterialName(),")" );
String vMaterialName = StrUtil.join("","(",materialName,")","(",virtualPackageType.getConMaterialName(),")");
String vMaterialDesc = StrUtil.join("", "(",drawingNo,")" ,"(", materialName,")","(",virtualPackageType.getConMaterialName(),")");
BomNewEbomParentEntity oldParent=null;
List<MaterialMainEntity> oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getMaterialName, vMaterialName)
.eq(MaterialMainEntity::getMaterialDesc, vMaterialDesc).list();
@ -87,6 +87,7 @@ public abstract class VirtualPackageBase {
// parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
parent.setShouldBomExist(1);
parent.setBomExist(1);
parent.setMaterialUnit("PC");
parent.setSourceRowId(0L);
parent.setLastVersionIs(1);
parent.setNum(new BigDecimal(1));
@ -115,6 +116,9 @@ public abstract class VirtualPackageBase {
childEntity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
childEntity.setSource(EBomSourceEnum.FROM_MDM.getValue());
childEntity.setVirtualPartType(virtualPackageTypeEnum.getValue());
childEntity.setProjectType("L");
childEntity.setMaterialUnit("PC");
childEntity.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
this.childResult.add(childEntity);
return childEntity;
}

View File

@ -0,0 +1,31 @@
package com.nflg.product.bomnew.util.sap;
import cn.hutool.core.util.StrUtil;
import java.math.BigDecimal;
/**
* 大米
*/
public class LevelNumUtil {
public static BigDecimal levelToNum(String strLevel) {
if (StrUtil.isEmpty(strLevel)) {
return null;
}
if (strLevel.indexOf('-') == -1) {
return new BigDecimal(strLevel);
}
String[] fromArray = strLevel.split("-");
String reuslt = "";
for (int i = 0; i < fromArray.length; i++) {
if (i == 0) {
reuslt = fromArray[i] + '.';
} else {
reuslt += StrUtil.padPre(fromArray[i], 2, '0');
}
}
return new BigDecimal(reuslt);
}
}

View File

@ -31,6 +31,8 @@
<result column="source_row_id" property="sourceRowId" jdbcType="BIGINT"/>
<result column="devise_user_code" property="deviseUserCode" jdbcType="VARCHAR"/>
<result column="devise_name" property="deviseName" jdbcType="VARCHAR"/>
<result column="technology_user_code" property="technologyUserCode" />
<result column="technology_user_name" property="technologyUserName" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="created_job" property="createdJob" jdbcType="INTEGER"/>
@ -51,7 +53,7 @@
row_id, batch_no, drawing_no, fac_code, material_no, order_number, material_name, material_desc,
material_texture, material_unit, unit_weight, total_weight, current_version, num, project_type, 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, 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, expire_end_time, remark, dept_name, level_num, change_desc, notice_nums,
order_no, modify_time
</sql>