Merge remote-tracking branch 'origin/master' into master-delBom-lhj1015

# Conflicts:
#	nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java
This commit is contained in:
10002327 2024-10-18 08:43:54 +08:00
commit 8fd2e93252
17 changed files with 374 additions and 57 deletions

View File

@ -20,6 +20,7 @@ import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery;
@ -107,6 +108,13 @@ public class EbomApi extends BaseApi {
public ResultVO<Page<BomNewEbomUpgradeChangeVO>> changeImpact(@RequestBody BomNewEbomParentQuery query) {
return ResultVO.success(bomNewEbomParentService.getUpgradeChangeList(query));
}
@GetMapping("changeImpactCntByUser")
@ApiOperation("当前登录人的变更影响数量")
public ResultVO<Integer> changeImpactCntByUser(){
return ResultVO.success(upgradeChangeService.count(Wrappers.<BomNewEbomUpgradeChangeEntity>lambdaQuery()
.eq(BomNewEbomUpgradeChangeEntity::getStatus,0)
.eq(BomNewEbomUpgradeChangeEntity::getDeviseName,SessionUtil.getRealName())));
}
@PostMapping("delChangeImpact")
@ApiOperation("变更影响-删除")

View File

@ -8,6 +8,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets;
import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.starter.annotation.LogRecord;
import com.nflg.product.base.core.api.BaseApi;
@ -18,7 +19,9 @@ import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewTechnologyPackageTypeEntity;
import com.nflg.product.bomnew.pojo.query.BomExceptionQuery;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.query.PBomExceptionQuery;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.*;
@ -29,17 +32,16 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.compress.utils.Lists;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
@ -445,6 +447,28 @@ public class PBomApi extends BaseApi {
return ResultVO.success(bomNewPbomParentService.checkBomExist(bomRowId,type));
}
/**
* 获取节点异常状态
* @param query query
* @return 节点异常状态
*/
@PostMapping("getBomException")
@ApiOperation("获取节点异常状态")
public ResultVO<List<BomExceptionVO>> getBomException(@Valid @RequestBody @NotEmpty List<BomExceptionQuery> query) {
return ResultVO.success(bomNewPbomParentService.getBomException(query));
}
/**
* 获取单个节点异常状态
* @param query query
* @return 节点异常状态
*/
@PostMapping("getSingleBomException")
@ApiOperation("获取单个节点异常状态")
public ResultVO<BomExceptionVO> getSingleBomException(@Valid @RequestBody @NotEmpty PBomExceptionQuery query) {
return ResultVO.success(bomNewPbomParentService.getSingleBomException(query));
}
@PostMapping("checkBomExport")
@ApiOperation("BOM完整性检查结果导出")
public void checkBomExport(@Valid @RequestBody @NotNull List<CheckBomVO> messages
@ -466,6 +490,4 @@ public class PBomApi extends BaseApi {
};
return ResultVO.success(true);
}
}

View File

@ -0,0 +1,38 @@
package com.nflg.product.bomnew.pojo.query;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* @author 曹鹏飞
* @date 2024/9/25 17:38:14
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-query-PBomExceptionQuery")
public class PBomExceptionQuery implements Serializable {
/**
* materialNo 物料编号
*/
@ApiModelProperty(value = "物料编号")
protected String materialNo;
/**
* drawingNo 图号
*/
@ApiModelProperty(value = "图号")
protected String drawingNo;
/**
* facCode 工厂编号
*/
@ApiModelProperty(value = "工厂编号")
@NotEmpty(message = "工厂编号不能为空")
protected String facCode;
}

View File

@ -363,6 +363,8 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty("父级物料RowId")
private List<Long> parentRowIds=new ArrayList<>();
@ApiModelProperty("父级物料Id")
private List<Long> parenIds=new ArrayList<>();
@ApiModelProperty("因子级都为F or Z 项而不转")
private Integer notToPBomForFZ=0;

View File

@ -42,9 +42,15 @@ public class ReverseReportVO {
@ApiModelProperty(value = "数量")
private BigDecimal num;
@ApiModelProperty(value = "子级数量")
private BigDecimal childNum;
@ApiModelProperty("单位")
private String materialUnit;
@ApiModelProperty("子级单位")
private String childMaterialUnit;
@ApiModelProperty(value = "创建人编码")
private String createdBy;

View File

@ -1005,6 +1005,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setUserRootIs(1);
bomTree.add(parent);
//物料名称,描述使用主数据的
materialMainService.initMaterialNameAndDesc(bomTree);
EBomToPbomBase eBomToPBom =parent.getMaterialNo().startsWith("31")? new EBomToPBomFor31(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode())):new EBomToPBom(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode()));
eBomToPBom.convert();
//电控系统 发货包优化 删除 直发制作下的物料 by 10002327 240914
@ -1194,6 +1197,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parent.setParentRowId(0L);
parent.setUserRootIs(1);
bomTree.add(parent);
//物料名称,描述使用主数据的
materialMainService.initMaterialNameAndDesc(bomTree);
FormalEBomToPbomBase eBomToPBom =parent.getMaterialNo().startsWith("31")? new EBomToPBomForFormal31New(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode())):new EBomToPBomForFormalNew(parent, bomTree, paramDto.getFacCodes(), 0L,EnumUtils.getValueEnum(ConvertToPBomModelEnum.class,paramDto.getConvertMode()));
eBomToPBom.convert();
// if(CollUtil.isNotEmpty(eBomToPBom.getDelParentRowIds())){
@ -2546,6 +2552,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomChildEntity> delChildList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
List<BomNewEbomChildEntity> deletingTagList = new ArrayList<>();
List<BomNewEbomChildEntity> delTagList = new ArrayList<>();
//BOM已删除标记行删除项目类别为K by 10002327 241016
delTagList.addAll(delChildList.stream().filter(b -> Objects.equals(b.getProjectType(),"K")).collect(Collectors.toList()));
@ -2572,30 +2579,34 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
// }
//原始bom不正常
List<BomNewEbomChildEntity> s1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
&& !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(s1List)) {
delTagList.addAll(s1List);
}
//原始bom不正常
//24/10/15需求变更原始bom正常数据可删除
// List<BomNewEbomChildEntity> toDel1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
// && !Objects.equals(u.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(s1List)) {
// delTagList.addAll(s1List);
// }
//手动创建
List<BomNewEbomChildEntity> s2List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
|| Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())
|| Objects.equals(EBomSourceEnum.FROM_CHANGE.getValue(), u.getSource())
).collect(Collectors.toList());
//可删数据来源包含全部
// List<BomNewEbomChildEntity> toDel2List = delChildList.stream().filter(u ->
// Objects.equals(EBomSourceEnum.FROM_EXCE.getValue(), u.getSource())
// || Objects.equals(EBomSourceEnum.FROM_MDM.getValue(), u.getSource())
// || Objects.equals(EBomSourceEnum.FROM_CHANGE.getValue(), u.getSource())
// || Objects.equals(EBomSourceEnum.FROM_SAP.getValue(), u.getSource())
// || Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())
// ).collect(Collectors.toList());
//工艺岗可以删自己的和设计岗(手动excel),
// 设计自己删除自己
//工艺岗用户1 可以删工艺岗用户2 的数据
if (CollectionUtil.isNotEmpty(s2List)) {
if (CollectionUtil.isNotEmpty(delChildList)) {
for (BomNewEbomChildEntity vo :
s2List) {
delChildList) {
if (userRoleService.technician()) { //工艺岗可删
delTagList.add(vo);
deletingTagList.add(vo);
} else if (userRoleService.designer() && vo.getCreatedBy().equals(SessionUtil.getUserCode())) { //自己的数据可删
delTagList.add(vo);
deletingTagList.add(vo);
} else {
throw new NflgBusinessException(STATE.Error, StrUtil.format("{}数据不是你的,无权删除", vo.getMaterialNo()));
@ -2603,12 +2614,12 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
if (CollectionUtil.isNotEmpty(delTagList)) {
List<Long> rowIdList = delTagList.stream().map(BomNewEbomChildEntity::getRowId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(deletingTagList)) {
List<Long> rowIdList = deletingTagList.stream().map(BomNewEbomChildEntity::getRowId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(rowIdList)) {
ebomChildService.removeByIds(rowIdList);
//将对应的parent设置为根节点
setRootIs1(delTagList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()), SessionUtil.getUserCode());
setRootIs1(deletingTagList.stream().map(BomNewEbomChildEntity::getMaterialNo).collect(Collectors.toList()), SessionUtil.getUserCode());
}
}
}

View File

@ -6,7 +6,12 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import cn.hutool.core.util.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@ -27,9 +32,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.query.CopyPBomV2Query;
import com.nflg.product.bomnew.pojo.query.PbomImportToSAPQuery;
import com.nflg.product.bomnew.pojo.query.*;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.EBom.CheckPBomException;
import com.nflg.product.bomnew.service.domain.PBom.*;
@ -47,13 +50,13 @@ import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BinaryOperator;
import java.util.function.Function;
@ -125,6 +128,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource
SapService sapService;
/**
* pbom-工作列表
*
@ -435,6 +439,69 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
/**
* 获取pbom子表信息仅用于BOM完整性检查 by 10002327 241015
* @param parent
* @param type
* @return
*/
public List<BomNewPbomParentVO> getChildByCheckBom(BomNewPbomParentEntity parent, Integer type){
List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(parent.getRowId());
if (CollUtil.isNotEmpty(parentChild)) {
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewPbomParentEntity> list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos)
.eq(type.equals(0), BomNewPbomParentEntity::getLastVersionIs, 1)
.ge(type.equals(1), BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode,parent.getFacCode())
.list();
Map<String, BomNewPbomParentEntity> bomListMap= list.parallelStream()
.collect(Collectors.toMap(
BomNewPbomParentEntity::getMaterialNo, // key: DrawingNo
Function.identity(),
BinaryOperator.maxBy(Comparator.comparing(BomNewPbomParentEntity::getCurrentVersion))
));
for (BomNewPbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewPbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
// if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
// }
child.setSourceRowId(parentEntity.getSourceRowId());
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
if ((type == 0 || parent.getStatus() < PBomStatusEnum.PUBLISH.getValue())
&& parentEntity.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
} else { //无BOM-版本时 确定版本号
//child.setSource(Objects.nonNull(parent) ? parent.getSource() : EBomSourceEnum.FROM_BOM.getValue());
child.setBomRowId(0L);
// 1040506070大类以及200201小类这些不需要BOM的物料版本号显示B00 by 10002327 241012
if(MaterialshouldBomExistUtil.checkNoNeedBom(child)){
child.setCurrentVersion(OriginalConstant.NO_NEED_BOM);
}else if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
if (type == 0 && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
}
}
}
}
return parentChild;
}
/**
* 编辑暂存
*
@ -2138,7 +2205,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
private void checkChild(List<CheckBomVO> checkBomList ,BomNewPbomParentEntity parent, Integer type,int currLevel,String currNos){
List<BomNewPbomParentVO> cList = getChild(parent,type);
List<BomNewPbomParentVO> cList = getChildByCheckBom(parent,type);
List<Long> bomRowIdList = cList.stream().filter(c -> c.getBomRowId() > 0).map(BomNewPbomParentVO::getBomRowId).distinct().collect(Collectors.toList());
List<BomNewPbomParentEntity> pList = Lists.newArrayList();
Map<Long,BomNewPbomParentEntity> pMap = Maps.newHashMap();
@ -2158,13 +2225,20 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
checkBomVO.setDrawingNo(c.getDrawingNo());
checkBomList.add(checkBomVO);
}
//不为空则进行递归 currLevel < 200 不再递归判断为死循环
if(finalPMap.get(c.getBomRowId()) != null && currLevel < 200){
//不为空则进行递归 currLevel < 400 不再递归判断为死循环
if(finalPMap.get(c.getBomRowId()) != null && currLevel < 400){
finalCurrLevel.getAndIncrement();
checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo());
//checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo());
CompletableFuture.runAsync(()-> checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo())).join();
// try {
// CompletableFuture.runAsync(()-> checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo())).get();
// } catch (Exception e) {
// log.error(e.getMessage());
// }
}
});
}
/**
@ -2220,4 +2294,83 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public List<BomExceptionVO> getBomException(@Valid @NotEmpty List<BomExceptionQuery> query) {
List<BomExceptionVO> datas = new ArrayList<>();
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(query.stream().map(BomExceptionQuery::getMaterialNo).collect(Collectors.toList()));
for (BomExceptionQuery bom : query) {
BomExceptionVO vo = new BomExceptionVO();
vo.setBomRowId(bom.getBomRowId());
vo.setRowId(bom.getRowId());
vo.setMaterialNo(bom.getMaterialNo());
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mv = materialVOS.stream().filter(f -> StrUtil.equals(f.getMaterialNo(), bom.getMaterialNo())).findFirst().orElse(null);
if (Objects.isNull(mv)) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_7.getValue());
} else if (!Objects.equals(mv.getMaterialState(), MateiralStateEnum.ACTIVE.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
List<String> materialNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, bom.getBomRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BaseMaterialVO> vos = materialMainService.initMaterialForAnyNo(materialNos);
if (CollUtil.isNotEmpty(vos)) {
if (vos.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
datas.add(vo);
}
Collections.reverse(datas);
return datas;
}
public BomExceptionVO getSingleBomException(@Valid @NotEmpty PBomExceptionQuery query) {
List<String> materialNosOrDrawingNos = Collections.singletonList(StrUtil.isNotBlank(query.getMaterialNo()) ? query.getMaterialNo() : query.getDrawingNo());
List<BaseMaterialVO> materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
BomExceptionVO vo = new BomExceptionVO();
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
BaseMaterialVO mVO = materialVOS.stream().findFirst().orElse(null);
if (Objects.nonNull(mVO)) {
vo.setMaterialNo(mVO.getMaterialNo());
if (!Objects.equals(mVO.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_2.getValue());
} else {
BomNewPbomParentEntity p = this.lambdaQuery()
.select(BomNewPbomParentEntity::getRowId)
.eq(StrUtil.isNotBlank(query.getMaterialNo()), BomNewPbomParentEntity::getMaterialNo, query.getMaterialNo())
.eq(StrUtil.isNotBlank(query.getDrawingNo()), BomNewPbomParentEntity::getDrawingNo, query.getDrawingNo())
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, query.getFacCode())
.list()
.stream()
.findFirst()
.orElse(null);
if (Objects.nonNull(p)) {
materialNosOrDrawingNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, p.getRowId())
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNosOrDrawingNos)) {
materialVOS = materialMainService.initMaterialForAnyNo(materialNosOrDrawingNos);
if (CollUtil.isNotEmpty(materialVOS)) {
if (materialVOS.stream().anyMatch(f -> !Objects.equals(f.getMaterialState(), MaterialGetEnum.MaterialStateEnum.OK.getValue()))) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}
}
}
}
}
}
return vo;
}
}

View File

@ -332,6 +332,27 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
}
/**
* 初始化物料名称and 描述
* @param list
* @param <T>
*/
public <T extends BaseMaterialVO> void initMaterialNameAndDesc(List<T> list) {
List<String> materialNos = list.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 : list) {
if (StrUtil.isNotBlank(t.getMaterialNo()) && materialMp.containsKey(t.getMaterialNo())) {
t.setMaterialName(materialMp.get(t.getMaterialNo()).getMaterialName());
t.setMaterialDesc(materialMp.get(t.getMaterialNo()).getMaterialDesc());
}
}
}
}

View File

@ -17,7 +17,6 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ResultDTO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.VUtils;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
@ -143,7 +142,10 @@ public class SapOpUtilService {
public List<OperationErrorMsgVO> importToSapV2(ImportSapParamDTO impartSapParamDTO, List<T1DTO> backList) {
VUtils.isTure(CollUtil.isEmpty(impartSapParamDTO.getT1())).throwMessage("没有需要同步的数据");
if (CollUtil.isEmpty(impartSapParamDTO.getT1())) {
log.info("没有需要同步的数据");
return Collections.emptyList();
}
SapReqParams params = new SapReqParams();
// 接口名
params.setFunName("ZRFC_PP_005");

View File

@ -330,6 +330,9 @@ public class SapService implements ApplicationContextAware {
params.setInputTables(inputTables);
SapResult sapResult = doSapFun(params);
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
return outTablesMap.get("OUTPUT");
if(Objects.nonNull(outTablesMap)) {
return outTablesMap.get("OUTPUT");
}
return Collections.emptyList();
}
}

View File

@ -191,7 +191,7 @@ public abstract class EBomToPbomBase {
//if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy())) {
if (ConvertToPBomModelEnum.OVERRIDE.equalsValue(convertMode.getValue())) {
//当bom创建人为本人 版本大于当前版本则覆盖
if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0){
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentVo.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(parentVo.getVirtualPartType()) || oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0){
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
// this.delParentRowIds.add(oldParent.getRowId());
oldParent.setSourceRowId(parentVo.getBomRowId());
@ -375,7 +375,7 @@ public abstract class EBomToPbomBase {
*/
protected void liftingLayer() {
result.add(parent);
liftingLayerDo(parent, null, null, ImmutableList.of());
liftingLayerDo(parent, null, null, ImmutableList.of() ,ImmutableList.of());
}
private List<Long> hasCupmVo = new ArrayList<>();
@ -385,7 +385,7 @@ public abstract class EBomToPbomBase {
* @param directDeliveryVo 直发包
* @param preAssemblyVo 发货前装配包
*/
public void liftingLayerDo(BomNewEbomParentVO parentVO, BomNewEbomParentVO directDeliveryVo, BomNewEbomParentVO preAssemblyVo, List<Long> parentRowIds) {
public void liftingLayerDo(BomNewEbomParentVO parentVO, BomNewEbomParentVO directDeliveryVo, BomNewEbomParentVO preAssemblyVo, List<Long> parentRowIds,List<Long> rowIds) {
List<BomNewEbomParentVO> firstLevelBoms = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentVO.getBomRowId())).sorted(Comparator.comparing(BomNewEbomParentVO::getVirtualPartType).reversed()).collect(Collectors.toList());
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
@ -395,6 +395,8 @@ public abstract class EBomToPbomBase {
//直发包
firstLevelBom.getParentRowIds().add(firstLevelBom.getParentRowId());
firstLevelBom.getParentRowIds().addAll(parentRowIds);
firstLevelBom.getParenIds().add(parentVO.getRowId());
firstLevelBom.getParenIds().addAll(rowIds);
List<BomNewEbomParentVO> directDeliveryVoList = firstLevelBoms.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(directDeliveryVoList)) {
directDeliveryVo = directDeliveryVoList.get(0);
@ -413,6 +415,7 @@ public abstract class EBomToPbomBase {
} else if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(firstLevelBom.getProjectType())) {
if (Objects.nonNull(directDeliveryVo)) {
BomNewEbomParentVO newEnt = liftingLayerSummary(directDeliveryVo, firstLevelBom);
firstLevelBom.getParenIds().clear();
newEnt.setRowId(IdWorker.getId());
newEnt.setSourceRowId(String.valueOf(firstLevelBom.getParentRowId()));
newEnt.setSourceParentMaterialNo(parentVO.getMaterialNo());
@ -422,6 +425,7 @@ public abstract class EBomToPbomBase {
} else if (firstLevelBom.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
if (Objects.nonNull(preAssemblyVo)) {
BomNewEbomParentVO newEnt = liftingLayerSummary(preAssemblyVo, firstLevelBom);
firstLevelBom.getParenIds().clear();
newEnt.setRowId(IdWorker.getId());
newEnt.setSourceRowId(String.valueOf(firstLevelBom.getParentRowId()));
newEnt.setSourceParentMaterialNo(parentVO.getMaterialNo());
@ -433,7 +437,7 @@ public abstract class EBomToPbomBase {
}
hasCupmVo.add(firstLevelBom.getRowId());
if (firstLevelBom.getBomRowId() > 0) {
liftingLayerDo(firstLevelBom, directDeliveryVo, preAssemblyVo, firstLevelBom.getParentRowIds());
liftingLayerDo(firstLevelBom, directDeliveryVo, preAssemblyVo, firstLevelBom.getParentRowIds() ,firstLevelBom.getParenIds());
}
}
}
@ -702,7 +706,7 @@ public abstract class EBomToPbomBase {
}
private BomNewEbomParentVO getParent(BomNewEbomParentVO vo) {
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> vo.getParentRowIds().contains(u.getParentRowId()) && u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> vo.getParentRowIds().contains(u.getParentRowId()) && u.getBomRowId().equals(vo.getParentRowId()) && vo.getParenIds().contains(u.getRowId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) {
return parents.get(0);
}

View File

@ -193,7 +193,7 @@ public abstract class FormalEBomToPbomBase {
else if (Objects.nonNull(oldParent) && oldParent.getStatus() < EBomStatusEnum.PUBLISHED.getValue()) {
//if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy())) {
if (ConvertToPBomModelEnum.OVERRIDE.equalsValue(convertMode.getValue())) {
if (oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0) {
if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(parentVo.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(parentVo.getVirtualPartType()) || oldParent.getCreatedBy().equals(parentVo.getCreatedBy()) || parentVo.getCurrentVersion()==null || VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0) {
SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId()));
oldParent.setSourceRowId(parentVo.getBomRowId());
oldParent.setCreatedTime(LocalDateTime.now());
@ -355,7 +355,7 @@ public abstract class FormalEBomToPbomBase {
*/
protected void liftingLayer() {
result.add(parent);
liftingLayerDo(parent, null, null, ImmutableList.of());
liftingLayerDo(parent, null, null, ImmutableList.of() ,ImmutableList.of());
}
private List<Long> hasCupmVo = new ArrayList<>();
@ -365,7 +365,7 @@ public abstract class FormalEBomToPbomBase {
* @param directDeliveryVo 直发包
* @param preAssemblyVo 发货前装配包
*/
public void liftingLayerDo(BomNewEbomParentVO parentVO, BomNewEbomParentVO directDeliveryVo, BomNewEbomParentVO preAssemblyVo, List<Long> parentRowIds) {
public void liftingLayerDo(BomNewEbomParentVO parentVO, BomNewEbomParentVO directDeliveryVo, BomNewEbomParentVO preAssemblyVo, List<Long> parentRowIds ,List<Long> rowIds) {
List<BomNewEbomParentVO> firstLevelBoms = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parentVO.getBomRowId())).sorted(Comparator.comparing(BomNewEbomParentVO::getVirtualPartType).reversed()).collect(Collectors.toList());
for (BomNewEbomParentVO firstLevelBom : firstLevelBoms) {
@ -375,6 +375,8 @@ public abstract class FormalEBomToPbomBase {
//直发包
firstLevelBom.getParentRowIds().add(firstLevelBom.getParentRowId());
firstLevelBom.getParentRowIds().addAll(parentRowIds);
firstLevelBom.getParenIds().add(parentVO.getRowId());
firstLevelBom.getParenIds().addAll(rowIds);
List<BomNewEbomParentVO> directDeliveryVoList = firstLevelBoms.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(directDeliveryVoList)) {
directDeliveryVo = directDeliveryVoList.get(0);
@ -393,6 +395,7 @@ public abstract class FormalEBomToPbomBase {
} else if (VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(firstLevelBom.getProjectType())) {
if (Objects.nonNull(directDeliveryVo)) {
BomNewEbomParentVO newEnt = liftingLayerSummary(directDeliveryVo, firstLevelBom);
firstLevelBom.getParenIds().clear();
newEnt.setRowId(IdWorker.getId());
newEnt.setSourceRowId(String.valueOf(firstLevelBom.getParentRowId()));
newEnt.setSourceParentMaterialNo(parentVO.getMaterialNo());
@ -402,6 +405,7 @@ public abstract class FormalEBomToPbomBase {
} else if (firstLevelBom.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) {
if (Objects.nonNull(preAssemblyVo)) {
BomNewEbomParentVO newEnt = liftingLayerSummary(preAssemblyVo, firstLevelBom);
firstLevelBom.getParenIds().clear();
newEnt.setRowId(IdWorker.getId());
newEnt.setSourceRowId(String.valueOf(firstLevelBom.getParentRowId()));
newEnt.setSourceParentMaterialNo(parentVO.getMaterialNo());
@ -413,7 +417,7 @@ public abstract class FormalEBomToPbomBase {
}
hasCupmVo.add(firstLevelBom.getRowId());
if (firstLevelBom.getBomRowId() > 0) {
liftingLayerDo(firstLevelBom, directDeliveryVo, preAssemblyVo, firstLevelBom.getParentRowIds());
liftingLayerDo(firstLevelBom, directDeliveryVo, preAssemblyVo, firstLevelBom.getParentRowIds(),firstLevelBom.getParenIds());
}
}
}
@ -450,7 +454,7 @@ public abstract class FormalEBomToPbomBase {
}
@Deprecated
protected List<BomNewEbomParentVO> getAllParent(BomNewEbomParentVO vo) {
List<BomNewEbomParentVO> result = new ArrayList<>();
BomNewEbomParentVO parentEnt = getParent(vo);
@ -682,7 +686,7 @@ public abstract class FormalEBomToPbomBase {
}
private BomNewEbomParentVO getParent(BomNewEbomParentVO vo) {
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> vo.getParentRowIds().contains(u.getParentRowId()) && u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList());
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> vo.getParentRowIds().contains(u.getParentRowId()) && u.getBomRowId().equals(vo.getParentRowId()) && vo.getParenIds().contains(u.getRowId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) {
return parents.get(0);
}

View File

@ -164,7 +164,17 @@ public class EBomQueryService {
&& Objects.equals(v.getNum(), it.getNum())
&& StrUtil.equals(v.getMaterialUnit(), it.getMaterialUnit())
&& StrUtil.equals(v.getCreatedBy(), it.getCreatedBy()))) {
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1)));
ReverseReportVO levelVO = null;
if (level > 1) {
for (int i = vos.size() - 1; i >= 0; i--) {
ReverseReportVO vo = vos.get(i);
if (Objects.equals(level - 1, vo.getLevelNum())) {
levelVO = vo;
break;
}
}
}
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1), pVO, levelVO));
}
bindData(it, level + 1, vos);
}
@ -175,7 +185,7 @@ public class EBomQueryService {
return ebomParentService.getReverseBoms(parentRowId);
}
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO) {
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO, BomNewPbomParentVO pVO, ReverseReportVO levelVO) {
ReverseReportVO vo = Convert.convert(ReverseReportVO.class, parentVO);
vo.setLevelNum(level);
if (Objects.isNull(lastVO)) {
@ -183,6 +193,13 @@ public class EBomQueryService {
} else {
vo.setBomVersion(level >= lastVO.getLevelNum() ? lastVO.getBomVersion() : String.valueOf(Integer.parseInt(lastVO.getBomVersion()) + 1));
}
if (Objects.nonNull(levelVO)) {
vo.setChildNum(levelVO.getNum());
vo.setChildMaterialUnit(levelVO.getMaterialUnit());
} else {
vo.setChildNum(pVO.getNum());
vo.setChildMaterialUnit(pVO.getMaterialUnit());
}
return vo;
}
}

View File

@ -158,7 +158,17 @@ public class PBomQueryService {
&& Objects.equals(v.getNum(), it.getNum())
&& StrUtil.equals(v.getMaterialUnit(), it.getMaterialUnit())
&& StrUtil.equals(v.getCreatedBy(), it.getCreatedBy()))) {
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1)));
ReverseReportVO levelVO = null;
if (level > 1) {
for (int i = vos.size() - 1; i >= 0; i--) {
ReverseReportVO vo = vos.get(i);
if (Objects.equals(level - 1, vo.getLevelNum())) {
levelVO = vo;
break;
}
}
}
vos.add(createVO(it, level, vos.isEmpty() ? null : vos.get(vos.size() - 1), pVO, levelVO));
}
bindData(it, level + 1, vos);
}
@ -169,7 +179,7 @@ public class PBomQueryService {
return pbomParentService.getReverseBoms(parentRowId);
}
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO) {
private ReverseReportVO createVO(BomNewPbomParentVO parentVO, Integer level, ReverseReportVO lastVO, BomNewPbomParentVO pVO, ReverseReportVO levelVO) {
ReverseReportVO vo = Convert.convert(ReverseReportVO.class, parentVO);
vo.setLevelNum(level);
if (Objects.isNull(lastVO)) {
@ -177,6 +187,13 @@ public class PBomQueryService {
} else {
vo.setBomVersion(level >= lastVO.getLevelNum() ? lastVO.getBomVersion() : String.valueOf(Integer.parseInt(lastVO.getBomVersion()) + 1));
}
if (Objects.nonNull(levelVO)) {
vo.setChildNum(levelVO.getNum());
vo.setChildMaterialUnit(levelVO.getMaterialUnit());
} else {
vo.setChildNum(pVO.getNum());
vo.setChildMaterialUnit(pVO.getMaterialUnit());
}
return vo;
}
}

View File

@ -412,9 +412,9 @@
<!--ebom单层反查-->
<select id="eBomReverseReport" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select b.* , a.drawing_no as childDrawingNo from t_bom_new_ebom_child_formal a
select b.* , a.drawing_no as childDrawingNo,a.num AS childNum,a.material_unit AS childMaterialUnit
from t_bom_new_ebom_child_formal a
join t_bom_new_ebom_parent_formal b on a.parent_row_id=b.row_id
where true
<if test="bomVersionRowId!=null and bomVersionRowId>0">
and a.bom_version_row_id=#{bomVersionRowId}
@ -427,7 +427,8 @@
<!--ebom单层反查-->
<select id="eBomReverseReportNewst" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select b.* , a.drawing_no as childDrawingNo from t_bom_new_ebom_child a
select b.*, a.drawing_no as childDrawingNo, a.num AS childNum, a.material_unit AS childMaterialUnit
from t_bom_new_ebom_child a
join t_bom_new_ebom_parent b on a.parent_row_id=b.row_id
where a.material_no =#{materialNo} and b.status=4
</select>
@ -621,7 +622,11 @@
</foreach>;
</select>
<select id="getReverseBoms" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT IFNULL(c.num, p.num) AS num, c.project_type projectType, c.project_type, p1.row_id parentRowId, p.*
SELECT IFNULL(IFNULL(c.num, p.num), 1) AS num,
c.project_type projectType,
c.project_type,
p1.row_id parentRowId,
p.*
FROM t_bom_new_ebom_child c
RIGHT JOIN t_bom_new_ebom_parent p ON c.material_no = p.material_no
LEFT JOIN t_bom_new_ebom_parent p1 ON c.parent_row_id = p1.row_id AND p1.status = 4

View File

@ -78,8 +78,8 @@
<!--pbom单层反查-->
<select id="pBomSingleReverseReport" resultType="com.nflg.product.bomnew.pojo.vo.ReverseReportVO">
select IFNULL(a.num,1)*IFNULL(b.num,1) AS num,b.* , a.drawing_no as childDrawingNo from
t_bom_new_pbom_child_formal a
select b.* , a.drawing_no as childDrawingNo,a.num AS childNum,a.material_unit AS childMaterialUnit
from t_bom_new_pbom_child_formal a
join t_bom_new_pbom_parent_formal b on a.parent_row_id=b.row_id
where true

View File

@ -298,7 +298,11 @@
WHERE p.created_by = #{userCode}
</select>
<select id="getReverseBoms" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
SELECT IFNULL(c.num, p.num) AS num, c.project_type projectType, c.project_type, p1.row_id parentRowId, p.*
SELECT IFNULL(IFNULL(c.num, p.num), 1) AS num,
c.project_type projectType,
c.project_type,
p1.row_id parentRowId,
p.*
FROM t_bom_new_pbom_child c
RIGHT JOIN t_bom_new_pbom_parent p ON c.material_no = p.material_no AND c.fac_code = p.fac_code
LEFT JOIN t_bom_new_pbom_parent p1