BOM删除

This commit is contained in:
10002327 2024-10-17 15:44:56 +08:00
parent 9bd0a9c664
commit 6b6c1588fc
15 changed files with 333 additions and 26 deletions

View File

@ -173,7 +173,7 @@ public class BomReportApi extends BaseApi {
return ResultVO.error("查无数据~");
}
if(CollUtil.isNotEmpty(r.getChildNodes())){
Set<String> materialNoSet = r.getChildNodes().stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet());
Set<String> materialNoSet = r.getChildNodes().stream().filter(m -> StrUtil.isNotBlank(m.getMaterialNo())).map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet());
List<MaterialMainEntity> materialMainList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery().in(MaterialMainEntity::getMaterialNo,materialNoSet));
Map<String,String> materialMainMap = materialMainList.stream().collect(Collectors.toMap(MaterialMainEntity::getMaterialNo,MaterialMainEntity::getMaterialDesc,(k1, k2)->k1));
r.getChildNodes().forEach(c -> c.setMaterialDesc(materialMainMap.getOrDefault(c.getMaterialNo(),c.getMaterialDesc())));

View File

@ -35,6 +35,7 @@ import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.ttzero.excel.entity.ListSheet;
@ -391,6 +392,11 @@ public class EbomApi extends BaseApi {
&& dto.getDelDatas().stream().anyMatch(it -> Objects.equals(it.getSource(), EBomSourceEnum.FROM_MDM.getValue())
&& !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())))
.throwMessage("要删除发货包请在生成发货包页面取消选中");
//校验当前BOM中如果只有一行BOM已删除标记行时不让删除保存
List<BomNewEbomParentVO> delBomList = dto.getDelDatas().stream().filter(b-> Objects.equals(b.getProjectType(),"K")).collect(Collectors.toList());
if(!delBomList.isEmpty()){
VUtils.isTure(dto.getDatas().isEmpty()).throwMessage("当前BOM没有其他下级物料时“BOM删除”标记行不能删除");
}
if(CollUtil.isNotEmpty(dto.getDelDatas()) && CollUtil.isNotEmpty(dto.getDatas())){
List<Long> delList=dto.getDelDatas().stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
@ -568,7 +574,6 @@ public class EbomApi extends BaseApi {
return ResultVO.success(true);
}
@GetMapping("byHome")
public ResultVO<Map<String,List<BomNewHomeBomVO>>> byHome(){
Map<String,List<BomNewHomeBomVO>> mp = Maps.newHashMap();
@ -599,5 +604,20 @@ public class EbomApi extends BaseApi {
return ResultVO.success(mp);
}
@GetMapping("bomDelete")
@ApiOperation("BOM删除")
@LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除")
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId) {
return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId));
}
@GetMapping("changeBomDelete")
@ApiOperation("BOM变更后BOM删除 ")
@LogRecord(success = "Ebom-BOM变更后删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM变更后删除")
public ResultVO<Void> changeBomDelete(@RequestParam("bomRowId") Long bomRowId){
bomNewEbomParentService.changeBomDelete(bomRowId);
return ResultVO.success();
}
}

View File

@ -360,6 +360,14 @@ public class PBomApi extends BaseApi {
}
}
@GetMapping("bomDelete")
@ApiOperation("BOM删除")
@LogRecord(success = "PBom删除操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除")
public ResultVO<Boolean> bomDelete(@RequestParam("bomRowId") Long bomRowId) {
bomNewPbomParentService.bomDelete(bomRowId);
return ResultVO.success(true);
}
@Resource
MaterialService materialService;

View File

@ -13,7 +13,8 @@ public enum EBomSourceEnum implements ValueEnum<Integer> {
FROM_EXCE(2, "EXCE导入"),
FROM_MDM(3, "MDM创建"),
FROM_SAP(4, "从SAP导入"),
FROM_CHANGE(5, "变更");
FROM_CHANGE(5, "变更"),
FROM_DELETE(6, "BOM删除");
private final Integer value;
private final String description;

View File

@ -15,7 +15,8 @@ public enum PbomSourceEnum implements ValueEnum<Integer> {
FROM_DQBOM(2, "DQBOM转换"),
FROM_SAP(3, "从SAP导入"),
FROM_COPY(4, "复制"),
FROM_CHANGE(5, "变更");
FROM_CHANGE(5, "变更"),
FROM_DELETE(6, "BOM删除");
private final Integer value;
private final String description;

View File

@ -37,7 +37,8 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
TYPE_Q("Q", "清点项"),
TYPE_F("F", "直发包"),
TYPE_Z("Z", "发货前装配包"),
TYPE_L("L", "普通物料");
TYPE_L("L", "普通物料"),
TYPE_K("K", "BOM删除");
private final String value;
private final String description;

View File

@ -32,4 +32,7 @@ public class ImportSapParamDTO {
@ApiModelProperty("详情")
private List<T1DTO> T1;
@ApiModelProperty("删除物料")
private List<T3DTO> T3;
}

View File

@ -0,0 +1,13 @@
package com.nflg.product.bomnew.pojo.dto.sap.impart2;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class T3DTO {
@ApiModelProperty("父级物料")
protected String MATNR = "";
}

View File

@ -85,6 +85,11 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
@ApiModelProperty(value = "数量")
private BigDecimal num;
public BigDecimal getNum() {
return num==null?null:num.stripTrailingZeros();
}
/**
* 来源1-原BOM转换 2-EXCE导入 3-MDM创建
*/

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
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.toolkit.Wrappers;
@ -16,6 +17,7 @@ import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
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.T1ExtDTO;
import com.nflg.product.bomnew.pojo.dto.sap.impart2.T3DTO;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
@ -23,6 +25,7 @@ import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.SapErrorMsgUtil;
import com.nflg.product.bomnew.util.VUtils;
import nflg.product.common.constant.STATE;
import org.apache.commons.compress.utils.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,6 +80,22 @@ public class BomNewEbomExportToSAP {
sapDto.setI_STLAN("2");
sapDto.setI_EMPNO(root.getCreatedBy());
sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList())));
//BOM的子表仅有一行BOM删除项目类别为K的数据 by 10002327 241017
// Map<String,List<T1ExtDTO>> t1Map = this.children.stream().collect(Collectors.groupingBy(T1ExtDTO::getMATNR));
// List<T3DTO> t3List = Lists.newArrayList();
// t1Map.forEach((k,v) -> {
// if(CollUtil.isNotEmpty(v) && v.size() == 1){
// if(StrUtil.equalsIgnoreCase("K",Optional.ofNullable(v.get(0)).map(T1ExtDTO::getPOSTP).orElse(""))){
// T3DTO t3DTO = new T3DTO();
// t3DTO.setMATNR(k);
// t3List.add(t3DTO);
// }
// }
// });
// if(!t3List.isEmpty()){
// sapDto.setT3(t3List);
// }
liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null);
if (CollUtil.isEmpty(liErrMsg)) {
state = SapStatusEnum.PUB_SUCCESS;

View File

@ -1,4 +1,6 @@
package com.nflg.product.bomnew.service;
import com.sap.conn.jco.JCoParameterList;
import com.google.common.collect.Maps;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
@ -25,6 +27,8 @@ import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper;
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
import com.nflg.product.bomnew.mapper.master.MaterialMainMapper;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
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.*;
@ -124,6 +128,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
@Resource
private BomNewNoticeNumDetail2Service bomNewNoticeNumDetail2Service;
@Resource
SapService sapService;
public List<BomNewEbomParentVO> getParentChild( Long rowId) {
return this.getBaseMapper().getParentChild(rowId);
@ -1019,14 +1026,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.collect(Collectors.toList());
eBomToPBom.getPBomChildResult().removeAll(pbomChild);
//仅删除PBOM 保留EBOM的数据
// if(!pbomParent.isEmpty()){
// //3删掉ebom 父级的数据
// List<Long> ebomParentIdList = pbomParent.stream().map(BomNewPbomParentEntity::getSourceRowId).collect(Collectors.toList());
// this.delBatch(ebomParentIdList);
// //4删掉ebom 子级的数据
// ebomChildService.remove(Wrappers.<BomNewEbomChildEntity>lambdaQuery().in(BomNewEbomChildEntity::getParentRowId,ebomParentIdList));
// }
//3判断parent下是否有子级排除电控系统和仙桃的如果没有的话把parent给删除了 物料****因下级全部是F项仅保存EBOM未生成PBOM数据 仙桃)
List<BomNewPbomParentEntity> emptyChildParentList = eBomToPBom.getPBomParentResult().stream()
.filter(p -> !p.getMaterialDesc().contains("电控系统") && !p.getMaterialDesc().contains("仙桃)")
&& !eBomToPBom.getPBomChildResult().stream().map(BomNewPbomChildEntity::getParentRowId).collect(Collectors.toList()).contains(p.getRowId()) )
@ -1051,17 +1050,23 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
oem.msg = String.format("物料%s因下级全部是F项仅保存EBOM未生成PBOM数据",m);
rList.add(oem);
}
// rList = emptyChildParentList.stream().map(BomNewPbomParentEntity::getMaterialNo).distinct()
// .map(m -> {
// OperationErrorMsgVO oem = new OperationErrorMsgVO();
// oem.setPrimaryKey(m);
// oem.msg = String.format("物料%s因下级全部是F项仅保存EBOM未生成PBOM数据",m);
// return oem;
// }).collect(Collectors.toList());
eBomToPBom.getPBomParentResult().removeAll(emptyChildParentList);
}
//3如果ebom的子表只有一条项目类别为K的数据则不发布到PBOM中
List<Long> kParentList = eBomToPBom.getPBomChildResult().stream().filter(child -> StrUtil.equalsIgnoreCase("K",child.getProjectType()))
.map(BomNewPbomChildEntity::getParentRowId).distinct().collect(Collectors.toList());
List<BomNewPbomParentEntity> delPbomList = eBomToPBom.getPBomParentResult().stream()
.filter(b -> kParentList.contains(b.getRowId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(delPbomList)) {
delPbomList.forEach(pbom -> {
List<BomNewPbomChildEntity> pbomChildList = eBomToPBom.getPBomChildResult().stream().filter(child -> Objects.equals(child.getParentRowId(),pbom.getRowId())).collect(Collectors.toList());
if(CollUtil.isNotEmpty(pbomChildList) && pbomChildList.size() == 1 && StrUtil.equalsIgnoreCase("K",pbomChildList.get(0).getProjectType())){
eBomToPBom.getPBomParentResult().remove(pbom);
eBomToPBom.getPBomChildResult().removeAll(pbomChildList);
}
});
}
}
if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) {
//将物料标记为用户跟节点
List<BomNewPbomParentEntity> rootParent = eBomToPBom.getPBomParentResult().stream().filter(u -> u.getMaterialNo().equals(parent.getMaterialNo())).collect(Collectors.toList());
@ -1475,6 +1480,128 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* BOM删除 by 10002327 241015
* @param bomRowId
*/
@Transactional(rollbackFor = Exception.class)
public Boolean bomDelete(Long bomRowId){
BomNewEbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~"));
//检查是否存在发布前的版本有则不能发起 BOM删除
List<BomNewEbomParentEntity> existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo())
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
Set<String> existMaterialNos = existEnt.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet());
VUtils.isTure(CollUtil.isNotEmpty(existMaterialNos)).throwMessage(StrUtil.join(",", existMaterialNos, "存在发布前版本。"));
List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
//1生成一个新版本号的空BOM
LogRecordContext.putVariable("bom", parent);
BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, newParent);
newParent.setRowId(IdWorker.getId());
newParent.setLastVersionIs(1);
newParent.setCurrentVersion(VersionUtil.getNextVersion(parent.getCurrentVersion()));
newParent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
newParent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
newParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
newParent.setDeptRowId(SessionUtil.getDepartRowId());
newParent.setDeptName(SessionUtil.getDepartName());
newParent.setDeviseName(SessionUtil.getRealName());
newParent.setDeviseUserCode(SessionUtil.getUserCode());
newParent.setRemark("");
newParent.setSource(EBomSourceEnum.FROM_DELETE.getValue());
newParent.setConvertToEbomTime(null);
newParent.setReleaseUserName(null);
newParent.setReleaseTime(null);
newParent.setRevertDesc(null);
newParent.setRevertTime(null);
newParent.setRevertUserName(null);
newParent.setAuditUserName(null);
newParent.setAuditTime(null);
newParent.setRootIs(1);
newParent.setUserRootIs(1);
newParent.setSapState(1);
newParent.setSapTime(null);
newParent.setModifyTime(null);
newParent.setCreatedTime(LocalDateTime.now());
newParent.setCreatedBy(SessionUtil.getUserCode());
newParent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
parent.setLastVersionIs(0);
parentResult.add(newParent);
parentResult.add(parent);
//2子表增加一行项目类别为K标识删除
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
newChild.setRowId(IdWorker.getId());
newChild.setParentRowId(newParent.getRowId());
newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId());
newChild.setOrderNumber("001");
newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue());
newChild.setProjectTypeInputType(0);
newChild.setCreatedBy(SessionUtil.getUserCode());
newChild.setVirtualPartIs(1);
newChild.setCreatedTime(LocalDateTime.now());
newChild.setModifyTime(LocalDateTime.now());
newChild.setEditStatus(1);
newChild.setExceptionStatus(1);
newChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
//3调用SAP接口删除BOM
SapReqParams sapReqParams = new SapReqParams();
sapReqParams.setFunName("ZRFC_PP_005");
Map<String,Object> inputParam = Maps.newHashMap();
inputParam.put("I_LCBT","主数据平台");
inputParam.put("I_ACT","X");
inputParam.put("ZID",RandomUtil.randomNumbers(5));
inputParam.put("I_WERKS","1");
inputParam.put("I_STLAN","2");
inputParam.put("I_EMPNO",SessionUtil.getUserCode());
sapReqParams.setInputParams(inputParam);
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
List<Map<String, String>> parentMapList = Lists.newArrayList();
Map<String, String> parentMap = Maps.newHashMap();
parentMap.put("MATNR", newParent.getMaterialNo());
parentMapList.add(parentMap);
inputTables.put("T3", parentMapList);
sapReqParams.setInputTables(inputTables);
SapResult sapResult = sapService.doSapFun(sapReqParams);
if (!sapResult.isSuccess()) {
throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg());
}
this.saveOrUpdateBatch(parentResult);
ebomChildService.save(newChild);
return true;
}
/**
* BOM变更后 BOM删除 by 10002327 241015
* @param bomRowId
*/
@Transactional(rollbackFor = Exception.class)
public void changeBomDelete(Long bomRowId){
BomNewEbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~"));
VUtils.isTure(!Objects.equals(parent.getSource(),EBomSourceEnum.FROM_CHANGE.getValue())).throwMessage(StrUtil.join(",", parent.getMaterialNo(), "删除失败仅支持变更后的BOM删除"));
//1删除旧的子表数据
ebomChildService.remove(Wrappers.<BomNewEbomChildEntity>lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,bomRowId));
//2子表增加一行项目类别为K标识删除
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
newChild.setRowId(IdWorker.getId());
newChild.setParentRowId(bomRowId);
newChild.setIdentityNo(bomRowId + "_" + newChild.getRowId());
newChild.setOrderNumber("001");
newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue());
newChild.setProjectTypeInputType(0);
newChild.setCreatedBy(SessionUtil.getUserCode());
newChild.setVirtualPartIs(1);
newChild.setCreatedTime(LocalDateTime.now());
newChild.setModifyTime(LocalDateTime.now());
newChild.setEditStatus(1);
newChild.setExceptionStatus(1);
newChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
ebomChildService.save(newChild);
}
public void editExportBom(EbomEditExportDTO param, OutputStream response) throws IOException {
List<BomNewEbomParentVO> result = param.getList();
@ -2420,6 +2547,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomChildEntity> delChildList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper);
List<BomNewEbomChildEntity> delTagList = new ArrayList<>();
//BOM已删除标记行删除项目类别为K by 10002327 241016
delTagList.addAll(delChildList.stream().filter(b -> Objects.equals(b.getProjectType(),"K")).collect(Collectors.toList()));
//检查原始bom里过来数据是否包含正常数据
// List<BomNewEbomChildEntity> check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())

View File

@ -22,6 +22,8 @@ import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper;
import com.nflg.product.bomnew.pojo.dto.*;
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
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.*;
@ -1360,8 +1362,105 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
if (CollUtil.isNotEmpty(upgrade.getChildResult())) {
pbomChildService.saveOrUpdateBatch(upgrade.getChildResult());
}
}
/**
* BOM删除
*
* @param bomRowId
*/
@Transactional(rollbackFor = Exception.class)
public void bomDelete(Long bomRowId){
BomNewPbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(Objects.isNull(parent)).throwMessage("该BOM版本不存在");
VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能删除");
//检查当前用户是否有该工厂权限
if(!userRoleService.getUserOfFactory().contains(parent.getFacCode())){
VUtils.isTure(true).throwMessage("您没有该工厂的权限,无法删除");
}
LogRecordContext.putVariable("bom",parent);
List<BomNewPbomParentEntity> waitPublishList = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, parent.getFacCode())
.lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).list();
VUtils.isTure(CollUtil.isNotEmpty(waitPublishList)).throwMessage(parent.getMaterialNo() + "存在待发布的版本,无法删除");
BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, parent);
rootVo.setBomRowId(rootVo.getRowId());
//1parent增加一行大版本号记录
BomNewPbomParentEntity pbomParent = new BomNewPbomParentEntity();
List<BomNewPbomParentEntity> parentList = Lists.newArrayList();
BeanUtil.copyProperties(rootVo, pbomParent);
pbomParent.setRowId(IdWorker.getId());
pbomParent.setCreatedTime(LocalDateTime.now());
pbomParent.setCreatedBy(SessionUtil.getUserCode());
pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue());
pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue());
//获取大版本号
pbomParent.setCurrentVersion(VersionUtil.getNextVersion(rootVo.getCurrentVersion()));
pbomParent.setDeptRowId(SessionUtil.getDepartRowId());
pbomParent.setDeptName(SessionUtil.getDepartName());
pbomParent.setDeviseName(SessionUtil.getRealName());
pbomParent.setDeviseUserCode(SessionUtil.getUserCode());
pbomParent.setTechnologyUserName(SessionUtil.getUserName());
pbomParent.setTechnologyUserCode(SessionUtil.getUserCode());
pbomParent.setRemark("");
pbomParent.setSource(PbomSourceEnum.FROM_DELETE.getValue());
pbomParent.setReleaseTime(null);
pbomParent.setReleaseUserName(null);
pbomParent.setSapState(1);
pbomParent.setSapTime(null);
pbomParent.setModifyTime(null);
pbomParent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
pbomParent.setRootIs(1);
pbomParent.setUserRootIs(1);
pbomParent.setLastVersionIs(1);
//设置旧版本
parent.setLastVersionIs(0);
parentList.add(pbomParent);
parentList.add(parent);
//2子表新增一行项目类别为K的标识行
BomNewPbomChildEntity child = new BomNewPbomChildEntity();
child.setRowId(IdWorker.getId());
child.setParentRowId(pbomParent.getRowId());
child.setFacCode(pbomParent.getFacCode());
child.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue());
child.setOrderNumber("001");
child.setNum(new BigDecimal(1));
child.setIdentityNo(pbomParent.getRowId() + "_" + child.getRowId());
child.setCreatedTime(LocalDateTime.now());
child.setCreatedBy(SessionUtil.getUserCode());
child.setModifyTime(null);
child.setSource(PbomSourceEnum.FROM_DELETE.getValue());
child.setRemark("");
//调用SAP接口 删除pbom
SapReqParams sapReqParams = new SapReqParams();
sapReqParams.setFunName("ZRFC_PP_005");
Map<String,Object> inputParam = Maps.newHashMap();
inputParam.put("I_LCBT","主数据平台");
inputParam.put("I_ACT","X");
inputParam.put("ZID",RandomUtil.randomNumbers(5));
inputParam.put("I_WERKS","1");
if (StrUtil.equals(parent.getFacCode(), EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) {
inputParam.put("I_WERKS","2");
}
inputParam.put("I_STLAN","1");
inputParam.put("I_EMPNO",SessionUtil.getUserCode());
sapReqParams.setInputParams(inputParam);
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
List<Map<String, String>> parentMapList = org.apache.commons.compress.utils.Lists.newArrayList();
Map<String, String> parentMap = Maps.newHashMap();
parentMap.put("MATNR", parent.getMaterialNo());
parentMapList.add(parentMap);
inputTables.put("T3", parentMapList);
sapReqParams.setInputTables(inputTables);
SapResult sapResult = sapService.doSapFun(sapReqParams);
if (!sapResult.isSuccess()) {
throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg());
}
this.saveOrUpdateBatch(parentList);
pbomChildService.save(child);
}
private void resetBomExist(Long rowId) {

View File

@ -6,6 +6,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.BomConstant;
import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO;
@ -180,14 +181,15 @@ public class SapOpUtilService {
Map<String, List<Map<String, Object>>> outTablesMap = sapResult.getOutTablesMap();
log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap));
List<Map<String, Object>> tOut = outTablesMap.get("T1");
List<T1ResultDTO> list = null;
List<T1ResultDTO> list = Lists.newArrayList();
if (!CollectionUtils.isEmpty(tOut)) {
list = Convert.convert(new TypeReference<List<T1ResultDTO>>() {
}, tOut);
}
if (CollUtil.isEmpty(list)) {
throw new NflgBusinessException(STATE.BusinessError, "获取sap返回数据转换异常");
}
//BOM删除 新增项目类别K,没有返回
// if (CollUtil.isEmpty(list)) {
// throw new NflgBusinessException(STATE.BusinessError, "获取sap返回数据转换异常");
// }
if (!Objects.isNull(backList)) {
backList.addAll(list);
}

View File

@ -120,6 +120,10 @@ public class CheckEBomException {
&& unCheckExcept.contains(vo.getExceptionStatus())) {
continue;
}
//项目类别为K 不做检查 10002327 241016
if(Objects.equals(vo.getProjectType(),"K")){
continue;
}
vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue());
if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, vo.getProjectType(), true)) {
if (StrUtil.isBlank(vo.getMaterialDesc())) {

View File

@ -795,7 +795,8 @@ public abstract class EBomToPbomBase {
if (oldChildList.size() != newChildList.size()) {
return false;
}
Map<String, List<BomNewEbomChildEntity>> oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getProjectType(), u.getNum())));
Map<String, List<BomNewEbomChildEntity>> oldChildMap = oldChildList.stream().collect(
Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getProjectType(), u.getNum())));
for (BomNewEbomParentVO newChild : newChildList) {
String key = MyStrUtil.joinStr(newChild.getMaterialNo(), newChild.getProjectType(), newChild.getNum());
if (!oldChildMap.containsKey(key)) {