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,19 +2,22 @@ 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
*
*
* @author makejava
* @since 2024-01-01 10:39:58
*/
@ -213,6 +216,21 @@ public class BomNewPbomParentEntity implements Serializable {
@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;
/**
* 创建人编码
*/

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;
@ -159,6 +161,19 @@ public class BomNewPbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty(value = "设计人员名称")
private String deviseName;
/**
* 工艺人员编码
*/
@ApiModelProperty(value = "工艺人员编码")
private String technologyUserCode;
/**
* 工艺人员名称
*/
@ApiModelProperty(value = "工艺人员名称")
private String technologyUserName;
/**
* 创建人编码
*/
@ -195,6 +210,10 @@ 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

@ -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);

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

@ -58,11 +58,12 @@ public class CheckEBomException {
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);
@ -70,7 +71,6 @@ public class CheckEBomException {
}
/**
*
* @param allBom 整颗BOM树包含跟节点
*/
public CheckEBomException(List<BomNewEbomParentVO> allBom) {
@ -95,7 +95,6 @@ public class CheckEBomException {
}
public void checkException() {
for (BomNewEbomParentVO vo : allBomDetail) {
// if(Objects.isNull(vo.getExceptionStatus())) {
@ -121,8 +120,7 @@ public class CheckEBomException {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
} 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,8 +129,6 @@ public class CheckEBomException {
}
/**
* 检查 EXCEPT_NO_3 EXCEPT_NO_6 EXCEPT_NO_9 EXCEPT_NO_10
*
@ -185,22 +181,32 @@ public class CheckEBomException {
/**
* 黄色警号异常
*
* @param 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());
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());
// });
}
/**
* 检查循环依赖
*/
@ -216,7 +222,6 @@ public class CheckEBomException {
}
public void checkContainExcept(List<Integer> codeList) throws NflgBusinessException {
if (CollUtil.isEmpty(codeList)) return;
@ -224,7 +229,8 @@ public class CheckEBomException {
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)) {
@ -235,12 +241,7 @@ public class CheckEBomException {
}
}
}

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>