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

This commit is contained in:
10001392 2024-10-24 17:42:20 +08:00
commit 334dd5a393
16 changed files with 459 additions and 46 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

@ -36,6 +36,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;
@ -399,6 +400,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());
@ -576,7 +582,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();
@ -607,5 +612,21 @@ 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,
@RequestParam(value = "childBomRowId",required = false) Long childBomRowId) {
return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId));
}
@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

@ -80,18 +80,18 @@ public class PBomApi extends BaseApi {
public ResultVO<IPage<BomNewPbomParentVO>> workDetailsListByPage(@RequestBody BomNewPbomParentQuery query) {
IPage<BomNewPbomParentVO> r = bomNewPbomParentService.workDetailsListByPage(query);
//添加仓库地点 by 10002327 0830
if(!r.getRecords().isEmpty()){
List<String> materialNoList = Lists.newArrayList();
List<String> facList = Lists.newArrayList();
this.get(r.getRecords(),materialNoList,facList);
List<Map<String,Object>> lgproList = sapService.lgproByList(materialNoList,facList);
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m->
String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"))
,m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
this.set(r.getRecords(),lgproMap);
}
// if(!r.getRecords().isEmpty()){
// List<String> materialNoList = Lists.newArrayList();
// List<String> facList = Lists.newArrayList();
//
// this.get(r.getRecords(),materialNoList,facList);
// List<Map<String,Object>> lgproList = sapService.lgproByList(materialNoList,facList);
// Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m->
// String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"))
// ,m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
// this.set(r.getRecords(),lgproMap);
//
// }
return ResultVO.success(r);
}
@ -362,6 +362,15 @@ 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,
@RequestParam(value = "childBomRowId",required = false) Long childBomRowId) {
bomNewPbomParentService.bomDelete(bomRowId,childBomRowId);
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.*;
@ -52,6 +56,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
@ -124,6 +129,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);
@ -1022,14 +1030,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()) )
@ -1054,17 +1054,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());
@ -1481,6 +1487,171 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* BOM删除 by 10002327 241015
*
* @param bomRowId
*/
@Transactional(rollbackFor = Exception.class)
public Boolean bomDelete(Long bomRowId,Long childBomRowId){
BomNewEbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~"));
//检查物料是否冻结中冻结中无法删除
List<MaterialMainEntity> mList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery()
.eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo())
.in(MaterialMainEntity::getMaterialState, com.google.common.collect.Lists.newArrayList(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue(),MaterialGetEnum.MaterialStateEnum.STATE_NO_5.getValue())));
if(CollUtil.isNotEmpty(mList)){
VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0))
.map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结编码无法编辑删除BOM~"));
}
//检查是否存在发布前的版本有则不能发起 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, "存在发布前版本。"));
//如果bom 有且只有一条 [BOM已删除] 标记行时提示已删除无须重复删除
List<BomNewEbomChildEntity> ebomChildEntityList = ebomChildService.list(Wrappers.<BomNewEbomChildEntity>lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,bomRowId));
List<BomNewEbomChildEntity> kChildEntityList = ebomChildEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList());
VUtils.isTure(ebomChildEntityList.size() == 1 && kChildEntityList.size() == 1).throwMessage(StrUtil.join(",", bomRowId, "BOM已删除无须重复删除~"));
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.PUBLISHED.getValue());
newParent.setEditStatus(EbomEditStatusEnum.HANDLER_FINISHED.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.setRevertDesc(null);
newParent.setRevertTime(null);
newParent.setRevertUserName(null);
newParent.setAuditUserName(null);
newParent.setAuditTime(null);
newParent.setRootIs(1);
newParent.setUserRootIs(1);
newParent.setSapState(SapStatusEnum.PUB_SUCCESS.getValue());
newParent.setSapTime(null);
newParent.setModifyTime(null);
newParent.setCreatedTime(LocalDateTime.now());
newParent.setCreatedBy(SessionUtil.getUserCode());
newParent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue());
newParent.setReleaseTime(LocalDateTime.now());
newParent.setReleaseUserName(SessionUtil.getUserName());
newParent.setExpireEndTime(DateUtil.parseLocalDateTime("9999-12-31 23:59:59","yyyy-MM-dd HH:mm:ss"));
parent.setLastVersionIs(0);
parentResult.add(newParent);
parentResult.add(parent);
//将新增的newParent替换到旧bom的子表上
List<BomNewEbomChildEntity> childEntityList = Lists.newArrayList();
if(childBomRowId != null){
BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId);
if(oldBomChild != null){
BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity();
BeanUtil.copyProperties(oldBomChild, newBomChild);
newBomChild.setRowId(IdWorker.getId());
newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId());
newBomChild.setBomVersionRowId(newParent.getRowId());
newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue());
childEntityList.add(newBomChild);
}
}
//2子表增加一行项目类别为K标识删除
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
newChild.setRowId(IdWorker.getId());
newChild.setParentRowId(newParent.getRowId());
newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId());
newChild.setOrderNumber("001");
newChild.setMaterialDesc("[BOM已删除]");
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());
childEntityList.add(newChild);
//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.saveBatch(childEntityList);
if(childBomRowId != null){
ebomChildService.removeById(childBomRowId);
}
//将历史已发布版-转移到正式历史表
List<Long> addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId());
List<Long> delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId);
eBomToFormal(addRowIds, delRowIds);
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.setMaterialDesc("[BOM已删除]");
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();
@ -2426,6 +2597,10 @@ 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()));
//检查原始bom里过来数据是否包含正常数据
// List<BomNewEbomChildEntity> check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource())

View File

@ -27,6 +27,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.*;
@ -282,14 +284,14 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
result = this.getBaseMapper().releaseListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
}
//添加仓库地点 by 10002327 0830
if(!result.getRecords().isEmpty()){
List<Map<String,Object>> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
},m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
}
// if(!result.getRecords().isEmpty()){
// List<Map<String,Object>> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()),
// result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList()));
// Map<String,String> lgproMap = lgproList.stream().collect(Collectors.toMap(m-> {
// return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS"));
// },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1));
// result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode())));
// }
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
return result;
}
@ -591,6 +593,12 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<BomNewPbomChildEntity> childList = pbomChildService.getBaseMapper().selectBatchIds(paramDTO.getRowIdList());
List<BomNewPbomParentVO> childListVO = Convert.toList(BomNewPbomParentVO.class, childList);
materialMainService.intiMaterialInfo(childListVO);
//校验当前BOM中如果只有一行BOM已删除标记行时不让删除保存
List<BomNewPbomChildEntity> kChildList = childList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList());
if(kChildList.size() > 0){
int cnt = pbomChildService.count(Wrappers.<BomNewPbomChildEntity>lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId,paramDTO.getBomRowId()));
VUtils.isTure(cnt == childList.size()).throwMessage("当前BOM中有一行“BOM已删除”标记行时不能全部删除~");
}
// 判断是否是工艺包
List<BomNewPbomParentVO> technologypackages = childListVO.stream()
@ -1314,6 +1322,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
if(StrUtil.isNotBlank(newPBom.getEbomVersion()) ){
continue;
}
//旧bom除T项之外
List<BomNewPbomParentVO> oldBomDetail = this.getBaseMapper().getParentChild(oldParent.getRowId());
List<BomNewPbomParentVO> oldBomNoTChildren = oldBomDetail.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
@ -1427,8 +1436,144 @@ 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,Long childBomRowId){
BomNewPbomParentEntity parent = this.getById(bomRowId);
VUtils.isTure(Objects.isNull(parent)).throwMessage("该BOM版本不存在");
//检查物料是否冻结中冻结中无法删除
List<MaterialMainEntity> mList = materialMainService.list(Wrappers.<MaterialMainEntity>lambdaQuery()
.eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo())
.in(MaterialMainEntity::getMaterialState, com.google.common.collect.Lists.newArrayList(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue(),MaterialGetEnum.MaterialStateEnum.STATE_NO_5.getValue())));
if(CollUtil.isNotEmpty(mList)){
VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0))
.map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结编码无法编辑删除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() + "存在待发布的版本,无法删除");
//如果bom 有且只有一条 [BOM已删除] 标记行时提示已删除无须重复删除
List<BomNewPbomChildEntity> childEntityList = pbomChildService.list(Wrappers.<BomNewPbomChildEntity>lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId,bomRowId));
List<BomNewPbomChildEntity> kEntityList = childEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList());
VUtils.isTure(childEntityList.size() == 1 && kEntityList.size() == 1).throwMessage("BOM已删除无须重复删除~");
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.FACTORY_CONFIRM.getValue());
pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_FINISHED.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.setSapState(SapStatusEnum.PUB_SUCCESS.getValue());
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);
pbomParent.setEbomVersion(null);
pbomParent.setBomExist(1);
pbomParent.setReleaseTime(LocalDateTime.now());
pbomParent.setReleaseUserName(SessionUtil.getUserName());
pbomParent.setExpireEndTime(DateUtil.parseLocalDateTime("9999-12-31 23:59:59","yyyy-MM-dd HH:mm:ss"));
//设置旧版本
parent.setLastVersionIs(0);
parentList.add(pbomParent);
parentList.add(parent);
List<BomNewPbomChildEntity> newChildEntityList = Lists.newArrayList();
if(childBomRowId != null){
BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId);
if(oldBomChild!= null){
BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity();
BeanUtil.copyProperties(oldBomChild, newBomChild);
newBomChild.setRowId(IdWorker.getId());
newBomChild.setBomVersionRowId(pbomParent.getRowId());
newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue());
newChildEntityList.add(newBomChild);
}
}
//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.setMaterialDesc("[BOM已删除]");
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("");
newChildEntityList.add(child);
//调用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.saveBatch(newChildEntityList);
if(childBomRowId != null){
pbomChildService.removeById(childBomRowId);
}
List<Long> exceptRowIds = Lists.newArrayList(pbomParent.getRowId());
List<String> parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo());
//历史版本转移到formal正式工作表
pBomToFormal(exceptRowIds, parentMaterialNos, parent.getFacCode());
}
private void resetBomExist(Long rowId) {
@ -2213,6 +2358,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<String> materialNos = pbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, bom.getBomRowId())
.apply(" material_no != '' ")
.list()
.stream()
.map(BomNewPbomChildEntity::getMaterialNo)

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;
@ -182,14 +183,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

@ -799,7 +799,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)) {

View File

@ -52,6 +52,18 @@ public class PBomDetailTask extends RecursiveTask<List<BomNewPbomParentVO>> {
*/
public void handlerChildBomVersionDetail() {
List<String> materialNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(BomNewPbomParentVO::getMaterialNo).collect(Collectors.toList());
//项目列表为K项时没有物料编码相关属性取parent值 by 10002327 241018
// List<BomNewPbomParentVO> kList = bomDetail.stream().filter(u -> Objects.equals(u.getProjectType(),"K")).collect(Collectors.toList());
// kList.forEach(k -> {
// BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, k.getParentRowId()).one();
// k.setDeviseUserCode(parent.getDeviseUserCode());
// k.setDeviseName(parent.getDeviseName());
// k.setDeptName(parent.getDeptName());
// k.setDeptRowId(parent.getDeptRowId());
// k.setStatus(parent.getStatus());
// k.setEditStatus(parent.getEditStatus());
// k.setVirtualPackageIs(parent.getVirtualPackageIs());
// });
if (CollUtil.isNotEmpty(materialNos)) {