Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2024-01-16 21:51:02 +08:00
commit 39ccfb251b
22 changed files with 354 additions and 74 deletions

View File

@ -119,6 +119,7 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@ -129,6 +130,7 @@
<version>2.6.4</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -155,9 +155,9 @@ public class EbomApi extends BaseApi {
@PostMapping("upgradeChanges")
@ApiOperation("发起变更")
public ResultVO<Boolean> upgradeChanges(@RequestBody List<Long> bomRowIds) {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要发起变更的物料");
bomNewEbomParentService.upgradeChanges(bomRowIds);
public ResultVO<Boolean> upgradeChanges(@RequestBody EBomUpgradeChangesParamDTO param) {
VUtils.isTure(CollUtil.isEmpty(param.getBomRowIds())).throwMessage("请选择要发起变更的物料");
bomNewEbomParentService.upgradeChanges(param);
return ResultVO.success(true);

View File

@ -108,6 +108,10 @@ public class NacosConfig {
public static NacosConfig getNacosConfig(){
return SpringContextUtils.getBean(NacosConfig.class);
}

View File

@ -0,0 +1,21 @@
package com.nflg.product.bomnew.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class EBomUpgradeChangesParamDTO {
@ApiModelProperty("bom行ID")
private List<Long> bomRowIds;
@ApiModelProperty("升版说明")
private String changeDesc;
@ApiModelProperty("通知单号")
private String noticeNums;
}

View File

@ -0,0 +1,35 @@
package com.nflg.product.bomnew.pojo.dto.sap;
import lombok.Data;
@Data
public class ImportToSapChildDTO {
// 物料编码
private String IDNRK;
// 序号
private String POSNR;
// 项目类别
private String POSTP;
// 数量
private String MENGE;
// 单位
private String MEINS;
/** 暂时未用到的字段 */
// // 工厂
// private String WERKS;
// // 物料描述
// private String MAKTX;
// // 创建日期
// @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
// private String ANDAT;
// // 修改日期
// @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
// private String AEDAT;
// // 有效起始日
// private String DATUV;
// // 有效至
// private String DATUB;
// // 设计人员
// private String ANNAM;
}

View File

@ -0,0 +1,15 @@
package com.nflg.product.bomnew.pojo.dto.sap;
import lombok.Data;
import java.util.List;
@Data
public class ImportToSapDTO {
// 抬头
private ImportToSapParentDTO parent;
// 组件
private List<ImportToSapChildDTO> childList;
}

View File

@ -0,0 +1,29 @@
package com.nflg.product.bomnew.pojo.dto.sap;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
@Data
public class ImportToSapParentDTO {
// 工厂
private String WERKS;
// 物料号
private String MATNR;
// BOM用途
private String STLAN;
// 基本数量
private String BMENG;
// 单位
private String BMEIN;
// BOM状态1=EBOM生成2=暂存当编辑时状态改为暂存3=已发布
private String STLST;
// 有效起始日
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private String DATUV;
/** 暂时未用到的字段 */
// 物料描述
// private String MAKTX;
// 可选的bom
// private String STLAL;
}

View File

@ -1,4 +1,4 @@
package com.nflg.product.bomnew.util.sap;
package com.nflg.product.bomnew.pojo.dto.sap;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.nflg.product.bomnew.util.sap;
package com.nflg.product.bomnew.pojo.dto.sap;
import com.sap.conn.jco.JCoParameterList;
import lombok.Data;

View File

@ -313,7 +313,7 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
private Integer virtualPartIs;
@ApiModelProperty("0-非虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
private Integer virtualPartType;
private Integer virtualPartType=0;
@ApiModelProperty("生成虚拟包的跟节点物料编码")
private String virtualPartRootMaterialNo;

View File

@ -304,6 +304,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setBomExist(parentEntity.getBomExist());
child.setShouldBomExist(parentEntity.getShouldBomExist());
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
child.setChangeDesc(parentEntity.getChangeDesc());
child.setNoticeNums(parentEntity.getNoticeNums());
if (parentEntity.getStatus().equals(EBomStatusEnum.PUBLISHED.getValue()) && EBomStatusEnum.PUBLISHED.getValue()>parentEntity.getStatus()) {
@ -672,16 +674,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 发起变更
*
* @param bomRowIds
* @param paramDTO
*/
@Transactional(rollbackFor = Exception.class)
public void upgradeChanges(List<Long> bomRowIds) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, bomRowIds).list();
public void upgradeChanges(EBomUpgradeChangesParamDTO paramDTO) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list();
List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更");
List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : bomRowIds) {
for (Long bomRowId : paramDTO.getBomRowIds()) {
BomNewEbomParentEntity parent = this.getById(bomRowId);
List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list();
@ -691,10 +693,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
newParent.setLastVersionIs(1);
newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion()));
newParent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_11.getValue());
newParent.setChangeDesc(paramDTO.getChangeDesc());
newParent.setNoticeNums(paramDTO.getNoticeNums());
parent.setLastVersionIs(0);
parentResult.add(newParent);
parentResult.add(parent);
for (BomNewEbomChildEntity childEnt : child) {
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
BeanUtil.copyProperties(childEnt, newChild);

View File

@ -1,15 +1,12 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableList;
@ -19,26 +16,27 @@ 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.ImportToSapChildDTO;
import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO;
import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapParentDTO;
import com.nflg.product.bomnew.pojo.entity.*;
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.service.domain.PBom.*;
import com.nflg.product.bomnew.util.*;
import com.nflg.product.bomnew.util.sap.LevelNumUtil;
import io.swagger.models.auth.In;
import com.nflg.product.bomnew.util.LevelNumUtil;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.ttzero.excel.entity.ListMapSheet;
import org.ttzero.excel.entity.ListSheet;
import org.ttzero.excel.entity.Workbook;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutionException;
@ -93,6 +91,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
@Resource
BomNewPbomMaterialUseService pbomMaterialUseService;
@Resource
SapOpUtilService sapOpUtilService;
/**
* pbom-工作列表
*
@ -721,6 +722,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
*
* @param bomRowId
*/
@Transactional(rollbackFor = Exception.class)
public boolean realesePbom(Long bomRowId) {
BomNewPbomParentEntity parent = this.getById(bomRowId);
try {
@ -729,8 +731,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
Integer state = (parent.getMaterialNo().startsWith("31") && parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
bomRowIds.add(bomRowId);
this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
//保存订单号
// this.updateById(parent);
//同步sap
saySyncDEMO();
} catch (Exception ex) {
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败" + ex.getMessage());
}
@ -738,6 +741,86 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
private void saySyncDEMO(){
ImportToSapDTO result=new ImportToSapDTO();
SimpleDateFormat spt=new SimpleDateFormat("yyyy-MM-dd");
ImportToSapParentDTO sapParent=new ImportToSapParentDTO();
sapParent.setWERKS("1010");
sapParent.setMATNR("2100564157");
sapParent.setSTLAN("");
sapParent.setBMENG("1");
sapParent.setBMEIN("PC");
sapParent.setSTLST("3");
sapParent.setDATUV("2024-01-16");
result.setParent(sapParent);
List<ImportToSapChildDTO> childResult=new ArrayList<>();
ImportToSapChildDTO childEnt =new ImportToSapChildDTO();
childEnt.setIDNRK("1100021745");
childEnt.setPOSNR("045");
childEnt.setPOSTP("F");
childEnt.setMENGE("6");
childEnt.setMEINS("PC");
childResult.add(childEnt);
result.setChildList(childResult);
List<ImportToSapDTO> sapParams=new ArrayList<>();
sapParams.add(result);
ResultVO<Boolean> syncResult = sapOpUtilService.importPBomToSap(sapParams);
VUtils.isTure(!syncResult.getState().equals(STATE.Success)).throwMessage("同步SAP失败"+syncResult.getMsg());
}
private void importSap(BomNewPbomParentEntity parent, List<BomNewPbomParentVO> children){
List<BomNewPbomParentVO> pbom = children.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
List<BomNewPbomParentVO> parentChild = children.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList());
List<ImportToSapDTO> sapParams=new ArrayList<>();
sapParams.add(buildSapBom(Convert.convert(BomNewPbomParentVO.class, parent), parentChild));
for (BomNewPbomParentVO pt :pbom) {
List<BomNewPbomParentVO> pChild = children.stream().filter(u -> u.getParentRowId().equals(pt.getBomRowId())).collect(Collectors.toList());
sapParams.add(buildSapBom(Convert.convert(BomNewPbomParentVO.class, parent), pChild));
}
if(CollUtil.isNotEmpty(sapParams)) {
sapOpUtilService.importPBomToSap(sapParams);
}
}
private ImportToSapDTO buildSapBom(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> children){
ImportToSapDTO result=new ImportToSapDTO();
ImportToSapParentDTO sapParent=new ImportToSapParentDTO();
SimpleDateFormat spt=new SimpleDateFormat("yyyy-MM-dd");
sapParent.setWERKS(parentVO.getFacCode());
sapParent.setMATNR(parentVO.getMaterialNo());
sapParent.setSTLAN("");
sapParent.setBMENG(parentVO.getNum().toString());
sapParent.setBMEIN(parentVO.getMaterialUnit());
sapParent.setSTLST("3");
sapParent.setDATUV(spt.format( parentVO.getCreatedTime()));
List<ImportToSapChildDTO> childResult=new ArrayList<>();
for (BomNewPbomParentVO child :children) {
ImportToSapChildDTO childEnt =new ImportToSapChildDTO();
childEnt.setIDNRK(child.getMaterialNo());
childEnt.setPOSNR(child.getOrderNumber());
childEnt.setPOSTP(child.getProjectType());
childEnt.setMENGE(child.getNum().toString());
childEnt.setMEINS(child.getMaterialUnit());
childResult.add(childEnt);
}
result.setParent(sapParent);
result.setChildList(childResult);
return result;
}
/**
* 获取CRM 订单号
*

View File

@ -0,0 +1,73 @@
package com.nflg.product.bomnew.service;
import cn.hutool.core.collection.CollUtil;
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.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO;
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
import lombok.extern.slf4j.Slf4j;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class SapOpUtilService {
@Resource
SapService sapService;
public ResultVO<Boolean> importPBomToSap(List<ImportToSapDTO> sapList) {
if (CollUtil.isEmpty(sapList)) {
return null;
}
for (ImportToSapDTO importToSapDTO : sapList) {
SapReqParams params = new SapReqParams();
// 接口名
params.setFunName("ZRFC_PP_CREATEBOM");
Map<String, Map<String, Object>> inputStructure = new HashMap<>();
Map<String, Object> parentMap = Convert.convert(new TypeReference<Map<String, Object>>() {
}, importToSapDTO.getParent());
inputStructure.put("I_STKO", parentMap);
params.setInputStructure(inputStructure);
Map<String, List<Map<String, String>>> inputTables = new HashMap<>();
List<Map<String, String>> childMapList = Convert.convert(new TypeReference<List<Map<String, String>>>() {
}, importToSapDTO.getChildList());
inputTables.put("T_BOM", childMapList);
params.setInputTables(inputTables);
try {
log.info("PBOM导入到SAP--参数:" + JSON.toJSONString(params));
SapResult sapResult = sapService.doSapFun(params);
Map<String, Object> exportMap = sapResult.getExportMap();
if (!sapResult.isSuccess()) {
return ResultVO.error(STATE.Error, "接口连接失败");
}
log.info("PBOM导入到SAP--返回值:" + JSON.toJSONString(exportMap));
String eErrmsg = String.valueOf(exportMap.get("E_ERRMSG"));
if (StrUtil.isNotEmpty(eErrmsg)) {
return ResultVO.error(STATE.Error, eErrmsg);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return ResultVO.success();
}
}

View File

@ -1,24 +1,26 @@
package com.nflg.product.bomnew.util.sap;
package com.nflg.product.bomnew.service;
import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams;
import com.nflg.product.bomnew.pojo.dto.sap.SapResult;
import com.sap.conn.jco.*;
import com.sap.conn.jco.ext.DestinationDataProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.FileOutputStream;
import java.util.*;
/**
* SAP JCO3 连接池
* sap服務
*/
@Service
@Slf4j
@Component
public class ConnectPooled {
public class SapService implements ApplicationContextAware {
@Value("${custom.sap.host}")
private String sapHost;
@Value("${custom.sap.sysnr}")
@ -36,33 +38,31 @@ public class ConnectPooled {
@Value("${custom.sap.peak}")
private String sapPeak;
static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
private static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
/**
* 初始化SAP连接
* PostConstruct 注解的方法在项目启动的时候执行这个方法,也可以理解为在spring容器启动的时候执行,可作为一些数据的常规化加载,比如数据字典之类的
*/
@PostConstruct
private void initProperties() {
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, sapHost);
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, sapSysnr);
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, sapClient);
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,sapSysnr);
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT,sapClient);
// QAS800
connectProperties.setProperty(DestinationDataProvider.JCO_USER, sapUsername);
connectProperties.setProperty(DestinationDataProvider.JCO_USER,sapUsername);
// 密码是区分大小写的要注意大小写
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, sapPassword);
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, sapLang);
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD,sapPassword);
connectProperties.setProperty(DestinationDataProvider.JCO_LANG ,sapLang);
// *********连接池方式与直接不同的是设置了下面两个连接属性
// JCO_PEAK_LIMIT - 同时可创建的最大活动连接数0表示无限制默认为JCO_POOL_CAPACITY的值
// 如果小于JCO_POOL_CAPACITY的值则自动设置为该值在没有设置JCO_POOL_CAPACITY的情况下为0
connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, sapPeak);
connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,sapPeak);
// JCO_POOL_CAPACITY - 空闲连接数如果为0则没有连接池效果默认为1
connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, sapPool);
connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY,sapPool);
createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties);
}
static void createDataFile(String name, String suffix, Properties properties) {
void createDataFile(String name, String suffix, Properties properties) {
File cfg = new File(name + "." + suffix);
if (!cfg.exists()) {
try {
@ -75,6 +75,7 @@ public class ConnectPooled {
}
}
public static void connectWithPooled() throws JCoException {
JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
System.out.println("Attributes:");
@ -295,10 +296,8 @@ public class ConnectPooled {
return destination;
}
// public static void main(String[] args) throws JCoException {
//// connectWithPooled();
//// accessSAPStructure();
//// workWithTable();
// }
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
initProperties();
}
}

View File

@ -9,10 +9,7 @@ import cn.hutool.extra.spring.SpringUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.constant.EBomConstant;
import com.nflg.product.bomnew.constant.EBomExceptionStatusEnum;
import com.nflg.product.bomnew.constant.MaterialGetEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
@ -189,7 +186,7 @@ public class CheckEBomException {
}
for (BomNewEbomParentVO exItem : exceptionList) {
List<String> parentByLevel = BomLevelUtil.getParentByLevel(exItem.getLevelNo());
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> u.getBomRowId() > 0 && parentByLevel.contains(u.getLevelNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
List<BomNewEbomParentVO> warnList = allBomDetail.stream().filter(u -> !u.getVirtualPartType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && !u.getVirtualPartType().equals(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue()) && u.getBomRowId() > 0 && parentByLevel.contains(u.getLevelNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList());
for (BomNewEbomParentVO k :warnList) {
k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue());
}

View File

@ -305,9 +305,10 @@ public class EBomToPBom {
if (CollUtil.isNotEmpty(parentList)) {
sum = NumberUtil.mul(sum, parentList.get(0).getNum());
parentFullPathNum.add(parentList.get(0).getNum());
} else {
parentFullPathNum.add(parentList.get(0).getNum());
}
// else {
// parentFullPathNum.add(parentList.get(0).getNum());
// }
parentLevelNo = BomLevelUtil.getParentLevelNo(parentLevelNo);
}

View File

@ -61,11 +61,31 @@ public abstract class VirtualPackageBase {
* @param virtualPackageTypeEnums
* @return
*/
protected void generateVMNo(List<BomNewEbomParentVO> child,VirtualPackageTypeEnum ... virtualPackageTypeEnums){
protected void generateVMNoFor31(String parentDrawingNo, List<BomNewEbomParentVO> child,VirtualPackageTypeEnum ... virtualPackageTypeEnums){
List<AddVirtrualMaterialDTO> params=new ArrayList<>();
for ( BomNewEbomParentVO ch: child ) {
for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) {
params.add(buildAddMaterialParamDo(StrUtil.join("",ch.getRowId().toString(), vpy.getConMaterialName()), ch.getDrawingNo(), ch.getMaterialName(), vpy));
String vDrawingNo = String.join("","(",parentDrawingNo,")","(",ch.getMaterialName(),")","(",vpy.getConMaterialName(),")" );
params.add(buildAddMaterialParamDo(StrUtil.join("",ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy));
}
}
List<AddVirtrualMaterialDTO> addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
vMNos= SpringUtil.getBean(MaterialService.class).batchAddMaterial(addM);
}
/**
* 申请虚拟包
* @param child
* @param virtualPackageTypeEnums
* @return
*/
protected void generateVMNoF21(String materialDesc, List<BomNewEbomParentVO> child,VirtualPackageTypeEnum ... virtualPackageTypeEnums){
List<AddVirtrualMaterialDTO> params=new ArrayList<>();
for ( BomNewEbomParentVO ch: child ) {
for (VirtualPackageTypeEnum vpy : virtualPackageTypeEnums) {
String vDrawingNo = String.join("","(",materialDesc,")","(",vpy.getConMaterialName(),")" );
params.add(buildAddMaterialParamDo(StrUtil.join("",ch.getRowId().toString(), vpy.getConMaterialName()), vDrawingNo, vDrawingNo, vpy));
}
}
List<AddVirtrualMaterialDTO> addM = params.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
@ -76,16 +96,12 @@ public abstract class VirtualPackageBase {
//申请物料编码
private AddVirtrualMaterialDTO buildAddMaterialParamDo(String key, String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType){
String vDrawingNo = String.join("","(",drawingNo,")","(",virtualPackageType.getConMaterialName(),")" );
String vMaterialName = StrUtil.join("","(",materialName,")","(",virtualPackageType.getConMaterialName(),")");
String vMaterialDesc = StrUtil.join("", "(",drawingNo,")" ,"(", materialName,")","(",virtualPackageType.getConMaterialName(),")");
List<MaterialMainEntity> oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getDrawingNo, vDrawingNo)
List<MaterialMainEntity> oldMaterialList = SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(MaterialMainEntity::getDrawingNo, drawingNo)
.list();
AddVirtrualMaterialDTO ent=new AddVirtrualMaterialDTO();
if(CollUtil.isNotEmpty(oldMaterialList)){
ent.setKey(key);
ent.setDrawingNo(vDrawingNo);
ent.setDrawingNo(drawingNo);
ent.setMaterialNo(oldMaterialList.get(0).getMaterialNo());
ent.setMaterialName(oldMaterialList.get(0).getMaterialName());
ent.setMaterialDesc(oldMaterialList.get(0).getMaterialDesc());
@ -93,9 +109,9 @@ public abstract class VirtualPackageBase {
}
else {
ent.setKey(key);
ent.setDrawingNo(vDrawingNo);
ent.setMaterialName(vMaterialName);
ent.setMaterialDesc(vMaterialDesc);
ent.setDrawingNo(drawingNo);
ent.setMaterialName(materialName);
ent.setMaterialDesc(materialName);
ent.setMaterialCategoryCode(virtualPackageType.getMaterialCategoryCode());
}
return ent;

View File

@ -45,10 +45,10 @@ public class VirtualPackageFor21 extends VirtualPackageBase {
BomNewEbomParentVO vo= Convert.convert(BomNewEbomParentVO.class,parent );
if(virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (parent.getVirtrualPackageEnum()| VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue())!=VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()){
generateVMNo(ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
generateVMNoF21(parent.getMaterialDesc(), ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE,VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
}
else {
generateVMNo(ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
generateVMNoF21(parent.getMaterialDesc(),ImmutableList.of(vo),VirtualPackageTypeEnum.MAKING_PACKAGE, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
}

View File

@ -44,11 +44,11 @@ public class VirtualPackageFor31 extends VirtualPackageBase {
//生成虚拟包
if(CollUtil.isNotEmpty(child)) {
if (virtualPackageValue.contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()) && (VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue() & parent.getVirtrualPackageEnum()) != VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()){
generateVMNo(child , VirtualPackageTypeEnum.DELIVERY_PACKAGE,VirtualPackageTypeEnum.MAKING_PACKAGE
generateVMNoFor31(parent.getDrawingNo(), child , VirtualPackageTypeEnum.DELIVERY_PACKAGE,VirtualPackageTypeEnum.MAKING_PACKAGE
,VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
}
else {
generateVMNo(child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, VirtualPackageTypeEnum.MAKING_PACKAGE
generateVMNoFor31(parent.getDrawingNo(),child, VirtualPackageTypeEnum.DELIVERY_PACKAGE, VirtualPackageTypeEnum.MAKING_PACKAGE
, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
}

View File

@ -20,6 +20,6 @@ public class BomLevelUtil {
public static String getParentLevelNo(String levelNo){
List<String> result=new ArrayList<>();
String[] parts = levelNo.split("-");
return String.join("-", Arrays.copyOfRange(parts, 0, levelNo.length()-1));
return String.join("-", Arrays.copyOfRange(parts, 0, parts.length-1));
}
}

View File

@ -1,4 +1,4 @@
package com.nflg.product.bomnew.util.sap;
package com.nflg.product.bomnew.util;
import cn.hutool.core.util.StrUtil;

View File

@ -25,6 +25,6 @@
<delete id="delByVnoAndParentNo">
delete from t_bom_new_ebom_virtual_package_composition
where virtual_package_material_no=#{virtualPackageMaterialNo}
and parent_material_no=#{parentMaterialNo}}
and parent_material_no=#{parentMaterialNo}
</delete>
</mapper>