Merge remote-tracking branch 'origin/feature/DM/nflg-bom-transition' into nflg-bom-transition-home-msg-lhj0812

This commit is contained in:
10002327 2024-08-19 08:08:30 +08:00
commit ebb8f338c7
12 changed files with 189 additions and 34 deletions

View File

@ -12,4 +12,8 @@ public class BomConstant {
public static final String PROJECT_TYPE_TEMPORARY = "T";
public static final String PROJECT_TYPE_TEMPORARY_MATERIAL_NO = "9000000000";
public static final Integer YES=1;
public static final Integer NO=0;
}

View File

@ -357,6 +357,10 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty("父级物料RowId")
private List<Long> parentRowIds=new ArrayList<>();
@ApiModelProperty("因子级都为F or Z 项而不转")
private Integer notToPBomForFZ=0;
private static final long serialVersionUID = 1L;
@Override

View File

@ -6,6 +6,7 @@ import org.apache.commons.lang.StringUtils;
import org.ttzero.excel.annotation.ExcelColumn;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author 曹鹏飞
@ -18,6 +19,14 @@ public class OperationErrorMsgVO extends OperationErrorMsgBaseVO implements Seri
@ExcelColumn("所在行")
public String primaryKey;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@ExcelColumn("创建时间")
private LocalDateTime createdTime;
public OperationErrorMsgVO() {
}

View File

@ -112,7 +112,7 @@ public class BomNewEbomExportToSAP {
private void handlerItem(BomNewEbomChildEntity it, BomNewEbomParentEntity p) {
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
addToT1(convert(it, p.getMaterialNo(), Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())));
addToT1(convert(it, p, Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())));
BomNewEbomParentEntity cp = getParent(it);
if (Objects.nonNull(cp)) {
buildChildrenForSap(cp);
@ -142,16 +142,16 @@ public class BomNewEbomExportToSAP {
}
}
private T1ExtDTO convert(BomNewEbomChildEntity child, String parentMaterialNo, boolean isZFB) {
private T1ExtDTO convert(BomNewEbomChildEntity child, BomNewEbomParentEntity p, boolean isZFB) {
T1ExtDTO t = new T1ExtDTO();
t.setID(RandomUtil.randomNumbers(5));
t.setMATNR(parentMaterialNo);
t.setMATNR(p.getMaterialNo());
t.setMENGE(child.getNum().toString());
t.setPOSTP(child.getProjectType());
t.setDATUM(dateYMD);
t.setMEINS(child.getMaterialUnit());
t.setIDNRK(child.getMaterialNo());
t.setIgnore(false);
t.setIgnore(Objects.equals(p.getSource(), EBomSourceEnum.FROM_SAP.getValue()));
t.setZFB(isZFB);
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
t.setIDNRK("");
@ -164,11 +164,12 @@ public class BomNewEbomExportToSAP {
private BomNewEbomParentEntity getParent(BomNewEbomChildEntity c) {
BomNewEbomParentEntity p = bomNewEbomParentService.lambdaQuery()
.select(BomNewEbomParentEntity::getRowId, BomNewEbomParentEntity::getMaterialNo
, BomNewEbomParentEntity::getMaterialDesc, BomNewEbomParentEntity::getUserRootIs)
, BomNewEbomParentEntity::getMaterialDesc, BomNewEbomParentEntity::getUserRootIs
, BomNewEbomParentEntity::getSource)
.eq(BomNewEbomParentEntity::getMaterialNo, c.getMaterialNo())
.eq(BomNewEbomParentEntity::getUserRootIs, 0)
// .eq(BomNewEbomParentEntity::getUserRootIs, 0)
.eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
.ne(BomNewEbomParentEntity::getSource, EBomSourceEnum.FROM_SAP.getValue())
// .ne(BomNewEbomParentEntity::getSource, EBomSourceEnum.FROM_SAP.getValue())
.orderByDesc(BomNewEbomParentEntity::getCurrentVersion)
.last(" limit 1")
.one();

View File

@ -359,6 +359,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 获取子级
*
@ -450,6 +453,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
//动态判断异常
//CheckEBomExceptoinDynamic.check(parentChild);
BomNewSortUtil.orderNumEbomSort(parentChild,0);
return parentChild;
}
@ -2482,7 +2486,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
//根据编号或图号搜索
//从顶级开始查找
List<BomNewEbomParentVO> roots = result.getRecords().stream()
.filter(r -> StrUtil.equals(r.getMaterialNo(), query.getMaterialNo()) || StrUtil.equals(r.getDrawingNo(), query.getDrawingNo()))
.filter(r -> (StrUtil.isNotBlank(query.getMaterialNo()) && StrUtil.equals(r.getMaterialNo(), query.getMaterialNo()))
|| (StrUtil.isNotBlank(query.getDrawingNo()) && StrUtil.equals(r.getDrawingNo(), query.getDrawingNo())))
.collect(Collectors.toList());
roots.forEach(this::buildChildren);
//从子级开始查找
@ -2812,7 +2817,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rowId)
.one();
if (Objects.isNull(sapErrorMsgEntity)) return Collections.emptyList();
return JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
List<OperationErrorMsgVO> resultList = JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
resultList.forEach(result -> result.setCreatedTime(sapErrorMsgEntity.getCreatedTime()));
return resultList;
}

View File

@ -87,7 +87,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
}
for (BomNewPbomChildEntity it : rcs) {
BomNewPbomParentEntity cp = getParent(it);
addToT1(convert(cp, it, root.getMaterialNo(), false));
addToT1(convert(cp, it, root, false));
if (Objects.nonNull(cp)) {
if (!is31) {
buildChildrenForSap(ddpRowId, cp, it, false);
@ -180,14 +180,14 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
* 转换为sap的t1
* @param parent 该节点对应的parent
* @param child 该节点对应的child
* @param parentMaterialNo 父级物料编号
* @param p 父级节点parent
* @param ignore 导入时是否忽略
* @return
*/
private T1ExtDTO convert(BomNewPbomParentEntity parent, BomNewPbomChildEntity child, String parentMaterialNo, Boolean ignore) {
private T1ExtDTO convert(BomNewPbomParentEntity parent, BomNewPbomChildEntity child, BomNewPbomParentEntity p, Boolean ignore) {
T1ExtDTO t = new T1ExtDTO();
t.setID(RandomUtil.randomNumbers(5));
t.setMATNR(parentMaterialNo);
t.setMATNR(p.getMaterialNo());
t.setMENGE(child.getNum().toString());
t.setPOSTP(child.getProjectType());
t.setDATUM(dateYMD);
@ -195,7 +195,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
t.setIDNRK(child.getMaterialNo());
t.setZSORT(BomUtil.generateSapOrderNum(child.getProjectType(), child.getMaterialCategoryCode()
, child.getFacCode(), child.getMaterialNo(), Objects.isNull(parent) ? 0 : parent.getBomExist()));
t.setIgnore(ignore);
t.setIgnore(ignore || Objects.equals(p.getSource(), PbomSourceEnum.FROM_SAP.getValue()));
if (BomConstant.PROJECT_TYPE_TEMPORARY.equals(child.getProjectType())) {
t.setIDNRK("");
t.setPOTX1(child.getMaterialDesc());
@ -236,7 +236,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
.orElse(null);
if (Objects.isNull(cct)) {
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
cct = convert(cp, it, p.getMaterialNo(), false);
cct = convert(cp, it, p, false);
cmap.get(cRowId).add(cct);
addToT1(cct);
} else {
@ -248,7 +248,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
// } else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
} else {
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
addToT1(convert(cp, it, p.getMaterialNo(), ignore));
addToT1(convert(cp, it, p, ignore));
}
if (Objects.nonNull(cp)) {
if (!ignore && cp.getUserRootIs() == 1) {
@ -282,7 +282,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
.ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
.ne(BomNewPbomParentEntity::getSource, PbomSourceEnum.FROM_SAP.getValue())
// .ne(BomNewPbomParentEntity::getSource, PbomSourceEnum.FROM_SAP.getValue())
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
.last(" limit 1")
.one();

View File

@ -165,7 +165,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
return new Page<>();
} else {
String queryFac= StrUtil.isBlank(query.getFacCode())? userRoleService.getUserFactory():query.getFacCode();
//查1020 时不限制只能查本人的
if(StrUtil.isNotBlank(query.getFacCode()) && EBomConstant.XIAN_TAO_FACTORY_CODE_1020.equals(query.getFacCode()) ){
query.setShowMySelfOnly(0);
}
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage()
, query.getPageSize()), query, queryFac, SessionUtil.getDepartRowId(), SessionUtil.getUserCode());
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
@ -400,6 +403,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
}
BomNewSortUtil.orderNumPbomSort(parentChild,0);
return parentChild;
}
@ -1568,7 +1573,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rowId)
.one();
if (Objects.isNull(sapErrorMsgEntity)) return Collections.emptyList();
return JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
List<OperationErrorMsgVO> resultList = JSON.parseArray(sapErrorMsgEntity.getData(), OperationErrorMsgVO.class);
resultList.forEach(result -> result.setCreatedTime(sapErrorMsgEntity.getCreatedTime()));
return resultList;
}
public List<BomNewPbomParentVO> getReverseBoms(Long parentRowId) {

View File

@ -76,6 +76,7 @@ public class DQBomImportService {
EecExcelUtil.handlerExcel(file.getInputStream(), DQbomExcelVO.class, this::handlerExcelRow);
List<DQbomExcelVO> datas = excelContextTL.get();
VUtils.isTure(datas.isEmpty()).throwMessage("未读取到数据,请检查表头是否正确");
List<OperationErrorMsgVO> errorMsg = checkExcel(datas);
if (!errorMsg.isEmpty()) {

View File

@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.*;
@ -34,7 +35,6 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
@ -616,7 +616,7 @@ public class DQBomService {
} else {
parent.setCurrentVersion(pp.getCurrentVersion());
bomNewPbomParentService.getBaseMapper().deleteById(pp.getRowId());
bomNewPbomChildService.getBaseMapper().delete(bomNewPbomChildService.lambdaQuery()
bomNewPbomChildService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewPbomChildEntity.class)
.eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId()));
}
}

View File

@ -309,12 +309,12 @@ public class EBomImportService {
);
}
numError = datas.stream().filter(u -> Objects.isNull(u.getNum()) || BigDecimal.ZERO.compareTo(u.getNum()) >= 0)
numError = datas.stream().filter(u -> Objects.isNull(u.getNum()) || BigDecimal.ZERO.compareTo(u.getNum()) == 0)
.map(BaseImportExcelDTO::getRowNum)
.collect(Collectors.toList());
if (!numError.isEmpty()) {
errorMsg.addAll(numError.stream().map(n -> OperationErrorMsgVO.create("" + n + "", "数量不正确"))
errorMsg.addAll(numError.stream().map(n -> OperationErrorMsgVO.create("" + n + "", "数量不正确(不能为空或0)"))
.collect(Collectors.toList())
);
}

View File

@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.excel.enums.BooleanEnum;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -173,7 +174,7 @@ public abstract class EBomToPbomBase {
if (Objects.isNull(oldParent)) {
return buildParentEntity(parentVo, facCode, oldParent, parentVo.getCurrentVersion());
return buildParentEntity(parentVo, facCode, oldParent, StrUtil.isBlank(parentVo.getCurrentVersion())? VersionUtil.getNextVersion(""):parentVo.getCurrentVersion());
}
//pbom 处于工作表
@ -197,7 +198,8 @@ public abstract class EBomToPbomBase {
return null;
} else { //pbom-处于正式表
String bomVersion = VersionUtil.compare(parentVo.getCurrentVersion(), oldParent.getCurrentVersion()) > 0 ? parentVo.getCurrentVersion() : VersionUtil.getNextVersion(oldParent.getCurrentVersion());
String version=StrUtil.isBlank(parentVo.getCurrentVersion())?VersionUtil.getNextVersion(""):parentVo.getCurrentVersion();
String bomVersion = VersionUtil.compare(version, oldParent.getCurrentVersion()) > 0 ? version : VersionUtil.getNextVersion(oldParent.getCurrentVersion());
return buildParentEntity(parentVo, facCode, oldParent, bomVersion);
}
@ -737,21 +739,59 @@ public abstract class EBomToPbomBase {
else {
addEBomNew.add(parentBom.getBomRowId());
}
//如子级都为F 项父级也不转
Set<String> projectSet = newParentChild.stream().map(u -> u.getProjectType().toUpperCase()).collect(Collectors.toSet());
if (CollUtil.isNotEmpty(projectSet)) {
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) &&
(ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F", "Z").equals(projectSet) || ImmutableSet.of("Z").equals(projectSet))) {
parentBom.setNoConvertToPBomIs(1);
childDelMaterialNos.add(parentBom.getMaterialNo());
}
}
//如子级都为F 项父级也不转
Set<String> projectSet = newParentChild.stream().map(u -> u.getProjectType().toUpperCase()).collect(Collectors.toSet());
if (CollUtil.isNotEmpty(projectSet)) {
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) &&
(ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F", "Z").equals(projectSet) || ImmutableSet.of("Z").equals(projectSet))) {
parentBom.setNoConvertToPBomIs(1);
parentBom.setNotToPBomForFZ(BomConstant.YES);
childDelMaterialNos.add(parentBom.getMaterialNo());
}
}
}
List<BomNewEbomParentVO> FzItem = allBomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getProjectType()) && ImmutableList.of("F", "Z").contains(u.getProjectType())).collect(Collectors.toList());
FzItem.forEach(u->{
u.setNotToPBomForFZ(BomConstant.YES);
});
//递归 FZ项所有父级
handlerFZEmptyBom();
}
/**
* 处理子级都是F项的空BOM
*/
private void handlerFZEmptyBom() {
List<BomNewEbomParentVO> parentBoms = getParentForAllSubNodeIsNotToPBomForFZ();
while (CollUtil.isNotEmpty(parentBoms)){
parentBoms.forEach(u->{
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(u.getVirtualPartType())) {
u.setNoConvertToPBomIs(1);
u.setNotToPBomForFZ(BomConstant.YES);
childDelMaterialNos.add(u.getMaterialNo());
}
});
parentBoms = getParentForAllSubNodeIsNotToPBomForFZ();
}
}
private List<BomNewEbomParentVO> getParentForAllSubNodeIsNotToPBomForFZ(){
Map<Long, List<BomNewEbomParentVO>> parentMp = allBomDetail.stream().filter(u->u.getParentRowId()>0).collect(Collectors.groupingBy(BomNewEbomParentVO::getParentRowId));
List<BomNewEbomParentVO> result=new ArrayList<>();
parentMp.forEach((k,v)->{
List<BomNewEbomParentVO> parent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(k)).collect(Collectors.toList());
if(Objects.nonNull(parent) && CollUtil.isNotEmpty(parent) && BomConstant.NO.equals(parent.get(0).getNotToPBomForFZ()) ) {
Optional<BomNewEbomParentVO> min = v.stream().min(Comparator.comparingInt(BomNewEbomParentVO::getNotToPBomForFZ));
if (min.isPresent() && BomConstant.YES.equals(min.get().getNotToPBomForFZ())) {
result.add(parent.get(0));
}
}
});
return result;
}
/**
@ -769,12 +809,20 @@ public abstract class EBomToPbomBase {
if (!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) &&
(ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F", "Z").equals(projectSet) || ImmutableSet.of("Z").equals(projectSet))) {
parentBom.setNoConvertToPBomIs(1);
parentBom.setNotToPBomForFZ(BomConstant.YES);
childDelMaterialNos.add(parentBom.getMaterialNo());
}
}
}
List<BomNewEbomParentVO> FzItem = allBomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getProjectType()) && ImmutableList.of("F", "Z").contains(u.getProjectType())).collect(Collectors.toList());
FzItem.forEach(u->{
u.setNotToPBomForFZ(BomConstant.YES);
});
//递归 FZ项所有父级
handlerFZEmptyBom();
}

View File

@ -0,0 +1,74 @@
package com.nflg.product.bomnew.util;
import cn.hutool.core.collection.CollUtil;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
public class BomNewSortUtil {
static int sortOrderNum(String o1,String o2,int sort){
if (Objects.isNull(o1)) {
return 0;
}
if (Objects.isNull(o2)) {
return 0;
}
int result = 0;
try {
if (sort == 0) { //
result = Integer.parseInt(o1 ) - Integer.parseInt(o2);
} else if (sort == 1) {//
result = Integer.parseInt(o2 ) - Integer.parseInt(o1 );
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void orderNumPbomSort(List<BomNewPbomParentVO> list, int sort) {
if (CollUtil.isEmpty(list)) {
return;
}
CollUtil.sort(list, new Comparator<BomNewPbomParentVO>() {
@Override
public int compare(BomNewPbomParentVO o1, BomNewPbomParentVO o2) {
return sortOrderNum(o1.getOrderNumber(),o2.getOrderNumber(),sort);
}
});
}
/**
* @param list
* @param sort
*/
public static void orderNumEbomSort(List<BomNewEbomParentVO> list, int sort) {
if (CollUtil.isEmpty(list)) {
return;
}
CollUtil.sort(list, new Comparator<BomNewEbomParentVO>() {
@Override
public int compare(BomNewEbomParentVO o1, BomNewEbomParentVO o2) {
return sortOrderNum(o1.getOrderNumber(),o2.getOrderNumber(),sort);
}
});
}
}