|
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.excel.enums.BooleanEnum;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
@ -38,6 +39,7 @@ import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.concurrent.ForkJoinPool;
|
|
|
|
|
@ -114,8 +116,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
List<String> parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList());
|
|
|
|
|
parentMaterialByMaterialNo.add(materialNo);
|
|
|
|
|
if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) {
|
|
|
|
|
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo );
|
|
|
|
|
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo, materialNo);
|
|
|
|
|
List<BomNewPbomParentVO> parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo);
|
|
|
|
|
List<BomNewPbomParentVO> childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo, materialNo);
|
|
|
|
|
List<BomNewPbomParentVO> data = new ArrayList<>();
|
|
|
|
|
data.addAll(parents);
|
|
|
|
|
data.addAll(childs);
|
|
|
|
|
@ -123,7 +125,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
return handSeachToTree(parents, childs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new Page<BomNewPbomParentVO>() ;
|
|
|
|
|
return new Page<BomNewPbomParentVO>();
|
|
|
|
|
} else {
|
|
|
|
|
Page<BomNewPbomParentVO> result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory());
|
|
|
|
|
materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
@ -158,6 +160,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取物料所有子级
|
|
|
|
|
*
|
|
|
|
|
* @param materialNo
|
|
|
|
|
* @param
|
|
|
|
|
* @return
|
|
|
|
|
@ -185,7 +188,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 已
|
|
|
|
|
*
|
|
|
|
|
@ -200,6 +202,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出工作列表
|
|
|
|
|
*
|
|
|
|
|
* @param query
|
|
|
|
|
* @param response
|
|
|
|
|
* @throws IOException
|
|
|
|
|
@ -207,12 +210,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
public void workDetailsExcel(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
|
|
|
|
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
|
|
|
|
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().workDetailsExcel(userRoleService.getUserFactory());
|
|
|
|
|
materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
new Workbook().addSheet(result).writeTo(response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出正式工作表
|
|
|
|
|
*
|
|
|
|
|
* @param query
|
|
|
|
|
* @param response
|
|
|
|
|
* @throws IOException
|
|
|
|
|
@ -220,7 +224,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
public void releaseListExcel(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
|
|
|
|
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
|
|
|
|
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().releaseListExcel(query);
|
|
|
|
|
materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
|
|
|
|
|
new Workbook().addSheet(result).writeTo(response.getOutputStream());
|
|
|
|
|
}
|
|
|
|
|
@ -442,13 +446,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
* @param targetFacCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode,Long rowId) throws ExecutionException, InterruptedException {
|
|
|
|
|
public List<BomCopyCheckResultVO> copyBomCheck(Long sourceBomRowId, String targetFacCode, Long rowId) throws ExecutionException, InterruptedException {
|
|
|
|
|
|
|
|
|
|
BomNewPbomParentEntity root = this.getById(sourceBomRowId);
|
|
|
|
|
VUtils.isTure(root.getMaterialNo().startsWith("31")).throwMessage("31码物料不能进行复制");
|
|
|
|
|
|
|
|
|
|
BomNewPbomChildEntity child = pbomChildService.getById(rowId);
|
|
|
|
|
if(child.getVirtualPartRootMaterialNo().startsWith("31") && child.getVirtualPartType()>0){
|
|
|
|
|
if (child.getVirtualPartRootMaterialNo().startsWith("31") && child.getVirtualPartType() > 0) {
|
|
|
|
|
VUtils.isTure(true).throwMessage("31下的虚拟包不能删除");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -485,7 +489,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
* @throws ExecutionException
|
|
|
|
|
* @throws InterruptedException
|
|
|
|
|
*/
|
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum ) throws ExecutionException, InterruptedException {
|
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException {
|
|
|
|
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
|
|
|
|
AtomicInteger levelNum = new AtomicInteger(1);
|
|
|
|
|
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
|
|
|
|
|
@ -496,7 +500,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum ,Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
|
|
|
|
|
public List<BomNewPbomParentVO> getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException {
|
|
|
|
|
List<BomNewPbomParentVO> bomDetail = this.getBaseMapper().getParentChild(rowId);
|
|
|
|
|
AtomicInteger levelNum = new AtomicInteger(1);
|
|
|
|
|
PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum);
|
|
|
|
|
@ -504,12 +508,13 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> result = submit.join();
|
|
|
|
|
|
|
|
|
|
if(generateDrawingNumberFalg){
|
|
|
|
|
generateDrawingNo(result,rowId,"");
|
|
|
|
|
if (generateDrawingNumberFalg) {
|
|
|
|
|
generateDrawingNo(result, rowId, "");
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void generateDrawingNo(List<BomNewPbomParentVO> saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) {
|
|
|
|
|
List<BomNewPbomParentVO> firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList());
|
|
|
|
|
parentDrawingNo = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : "";
|
|
|
|
|
@ -555,16 +560,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
VUtils.isTure(StrUtil.isBlank(params.getRuleGroupCode())).throwMessage("规则编码不能为空");
|
|
|
|
|
|
|
|
|
|
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0);
|
|
|
|
|
List<BomNewPbomParentVO> childrenVO = getAllBom(params.getBomRowId(), 0, true);
|
|
|
|
|
materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
|
|
|
|
List<BomFactorySplitRuleEntity> relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list();
|
|
|
|
|
StringBuilder relPattern = new StringBuilder();
|
|
|
|
|
List<BomNewPbomChildEntity> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (BomNewPbomParentVO child : childrenVO) {
|
|
|
|
|
if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
for (BomFactorySplitRuleEntity role : relList) {
|
|
|
|
|
Boolean match = true;
|
|
|
|
|
if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) {
|
|
|
|
|
@ -602,50 +607,59 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(child.getProjectType().equals("Q")){
|
|
|
|
|
intiQFac(child,childrenVO);
|
|
|
|
|
}else {
|
|
|
|
|
intiNotQFac(child,childrenVO);
|
|
|
|
|
}
|
|
|
|
|
//Q项
|
|
|
|
|
List<BomNewPbomParentVO> qList = childrenVO.stream().filter(u -> u.getProjectType().equals("Q")).collect(Collectors.toList());
|
|
|
|
|
{
|
|
|
|
|
for (BomNewPbomParentVO qVo : qList) {
|
|
|
|
|
intiQFac(qVo, childrenVO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//非Q
|
|
|
|
|
// List<BomNewPbomParentVO> noQList = childrenVO.stream().filter(u -> !u.getProjectType().equals("Q")).collect(Collectors.toList());
|
|
|
|
|
// {
|
|
|
|
|
// for (BomNewPbomParentVO noQVo : noQList) {
|
|
|
|
|
// intiNotQFac(noQVo, childrenVO);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (CollUtil.isNotEmpty(result)) {
|
|
|
|
|
pbomChildService.saveOrUpdateBatch(result);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理Q下子级分工厂
|
|
|
|
|
private void intiQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child){
|
|
|
|
|
private void intiQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setSubNodeFac(parentVO, child,parentVO.getProductionFactoryCode() );
|
|
|
|
|
setSubNodeFac(parentVO, child, parentVO.getProductionFactoryCode());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//非Q
|
|
|
|
|
private void intiNotQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child){
|
|
|
|
|
private void intiNotQFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child) {
|
|
|
|
|
|
|
|
|
|
//当为1020时 ,子级为1020
|
|
|
|
|
if(parentVO.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)){
|
|
|
|
|
if (parentVO.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) {
|
|
|
|
|
|
|
|
|
|
setSubNodeFac(parentVO,child, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
|
|
|
|
setSubNodeFac(parentVO, child, EBomConstant.XIAN_TAO_FACTORY_CODE_1020);
|
|
|
|
|
}
|
|
|
|
|
if(parentVO.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)){
|
|
|
|
|
if (parentVO.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
|
|
|
|
//父级
|
|
|
|
|
setParentFac(parentVO,child,EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
|
|
|
setParentFac(parentVO, child, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
|
|
|
//子级
|
|
|
|
|
setSubNodeFac(parentVO,child, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
|
|
|
setSubNodeFac(parentVO, child, EBomConstant.MAIN_FACTORY_CODE_1010);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setParentFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){
|
|
|
|
|
private void setParentFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child, String facCode) {
|
|
|
|
|
List<String> parentByLevel = BomLevelUtil.getParentByLevel(parentVO.getLevelNo());
|
|
|
|
|
for ( String level: parentByLevel) {
|
|
|
|
|
for (String level : parentByLevel) {
|
|
|
|
|
List<BomNewPbomParentVO> parents = child.stream().filter(u -> u.getLevelNo().equals(level) && u.getVirtualPartIs().equals(0)).collect(Collectors.toList());
|
|
|
|
|
if(CollUtil.isNotEmpty(parents)){
|
|
|
|
|
if (CollUtil.isNotEmpty(parents)) {
|
|
|
|
|
parents.get(0).setProductionFactoryCode(facCode);
|
|
|
|
|
parents.get(0).setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue());
|
|
|
|
|
}
|
|
|
|
|
@ -653,9 +667,10 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setSubNodeFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child , String facCode){
|
|
|
|
|
String zero ="1"+ StrUtil.padAfter("0", parentVO.getLevelNum().toString().split(".")[1].length(), "0");
|
|
|
|
|
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), new BigDecimal(1).divide(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) );
|
|
|
|
|
private void setSubNodeFac(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> child, String facCode) {
|
|
|
|
|
String[] numSplit = parentVO.getLevelNumber().toString().split(".");
|
|
|
|
|
String zero = "1" + StrUtil.padAfter("0", (numSplit.length > 1 ? numSplit[1].length() : 0), "0");
|
|
|
|
|
BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), (NumberUtil.div(new BigDecimal(1), new BigDecimal(zero))));
|
|
|
|
|
List<BomNewPbomParentVO> subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList());
|
|
|
|
|
for (BomNewPbomParentVO node : subNodes) {
|
|
|
|
|
node.setProductionFactoryCode(facCode);
|
|
|
|
|
@ -664,8 +679,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void reConvertToMBom(Long bomRowId, List<Long> backRowId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -696,7 +709,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
|
|
|
|
VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布");
|
|
|
|
|
ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild);
|
|
|
|
|
convertToMBom.convertToMBom();
|
|
|
|
|
convertToMBom.convertToMBom(true, true);
|
|
|
|
|
if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) {
|
|
|
|
|
mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult());
|
|
|
|
|
}
|
|
|
|
|
@ -717,6 +730,40 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MBOM退回后,重新发布调用
|
|
|
|
|
*
|
|
|
|
|
* @param bomRowId
|
|
|
|
|
* @return
|
|
|
|
|
* @throws ExecutionException
|
|
|
|
|
* @throws InterruptedException
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public Boolean convertToMBomFor1020(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
|
|
|
|
|
|
BomNewPbomParentEntity rootParent = this.getById(bomRowId);
|
|
|
|
|
List<BomNewPbomParentVO> allChild = getAllBom(bomRowId, 0);
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isBlank(rootParent.getOrderNo())) {
|
|
|
|
|
String orderNo = crmService.getOrderNo(rootParent.getMaterialNo());
|
|
|
|
|
rootParent.setOrderNo(orderNo);
|
|
|
|
|
}
|
|
|
|
|
VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号");
|
|
|
|
|
|
|
|
|
|
List<String> noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
|
|
|
|
VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布");
|
|
|
|
|
ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild);
|
|
|
|
|
convertToMBom.convertToMBom(false, true);
|
|
|
|
|
if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) {
|
|
|
|
|
mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult());
|
|
|
|
|
}
|
|
|
|
|
if (CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())) {
|
|
|
|
|
mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult());
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发布Pbom
|
|
|
|
|
*
|
|
|
|
|
@ -732,7 +779,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
bomRowIds.add(bomRowId);
|
|
|
|
|
this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
|
|
|
|
|
//同步sap
|
|
|
|
|
saySyncDEMO();
|
|
|
|
|
// saySyncDEMO();
|
|
|
|
|
// importSap(parent,allBom);
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
throw new NflgBusinessException(STATE.BusinessError, "发布Pbom失败:" + ex.getMessage());
|
|
|
|
|
@ -741,21 +789,21 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saySyncDEMO(){
|
|
|
|
|
ImportToSapDTO result=new ImportToSapDTO();
|
|
|
|
|
SimpleDateFormat spt=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
ImportToSapParentDTO sapParent=new ImportToSapParentDTO();
|
|
|
|
|
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.setSTLAN("2");
|
|
|
|
|
sapParent.setBMENG("1");
|
|
|
|
|
sapParent.setBMEIN("PC");
|
|
|
|
|
sapParent.setSTLST("3");
|
|
|
|
|
sapParent.setDATUV("2024-01-16");
|
|
|
|
|
sapParent.setDATUV("20240116");
|
|
|
|
|
|
|
|
|
|
result.setParent(sapParent);
|
|
|
|
|
List<ImportToSapChildDTO> childResult=new ArrayList<>();
|
|
|
|
|
ImportToSapChildDTO childEnt =new ImportToSapChildDTO();
|
|
|
|
|
List<ImportToSapChildDTO> childResult = new ArrayList<>();
|
|
|
|
|
ImportToSapChildDTO childEnt = new ImportToSapChildDTO();
|
|
|
|
|
childEnt.setIDNRK("1100021745");
|
|
|
|
|
childEnt.setPOSNR("045");
|
|
|
|
|
childEnt.setPOSTP("F");
|
|
|
|
|
@ -766,46 +814,47 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
result.setChildList(childResult);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ImportToSapDTO> sapParams=new ArrayList<>();
|
|
|
|
|
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());
|
|
|
|
|
VUtils.isTure(!syncResult.getState().equals(STATE.Success)).throwMessage("同步SAP失败:" + syncResult.getMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void importSap(BomNewPbomParentEntity parent, List<BomNewPbomParentVO> children){
|
|
|
|
|
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<>();
|
|
|
|
|
List<ImportToSapDTO> sapParams = new ArrayList<>();
|
|
|
|
|
sapParams.add(buildSapBom(Convert.convert(BomNewPbomParentVO.class, parent), parentChild));
|
|
|
|
|
|
|
|
|
|
for (BomNewPbomParentVO pt :pbom) {
|
|
|
|
|
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);
|
|
|
|
|
if (CollUtil.isNotEmpty(sapParams)) {
|
|
|
|
|
ResultVO<Boolean> booleanResultVO = sapOpUtilService.importPBomToSap(sapParams);
|
|
|
|
|
VUtils.isTure(!booleanResultVO.getState().equals(STATE.Success)).throwMessage("同步SAP失败:" + booleanResultVO.getMsg());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ImportToSapDTO buildSapBom(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> children){
|
|
|
|
|
private ImportToSapDTO buildSapBom(BomNewPbomParentVO parentVO, List<BomNewPbomParentVO> children) {
|
|
|
|
|
|
|
|
|
|
ImportToSapDTO result=new ImportToSapDTO();
|
|
|
|
|
ImportToSapParentDTO sapParent=new ImportToSapParentDTO();
|
|
|
|
|
SimpleDateFormat spt=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
ImportToSapDTO result = new ImportToSapDTO();
|
|
|
|
|
ImportToSapParentDTO sapParent = new ImportToSapParentDTO();
|
|
|
|
|
DateTimeFormatter ymd = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
sapParent.setWERKS(parentVO.getFacCode());
|
|
|
|
|
sapParent.setMATNR(parentVO.getMaterialNo());
|
|
|
|
|
sapParent.setSTLAN("");
|
|
|
|
|
sapParent.setSTLAN("2");
|
|
|
|
|
sapParent.setBMENG(parentVO.getNum().toString());
|
|
|
|
|
sapParent.setBMEIN(parentVO.getMaterialUnit());
|
|
|
|
|
sapParent.setSTLST("3");
|
|
|
|
|
sapParent.setDATUV(spt.format( parentVO.getCreatedTime()));
|
|
|
|
|
sapParent.setDATUV(parentVO.getCreatedTime().format(ymd));
|
|
|
|
|
|
|
|
|
|
List<ImportToSapChildDTO> childResult=new ArrayList<>();
|
|
|
|
|
for (BomNewPbomParentVO child :children) {
|
|
|
|
|
ImportToSapChildDTO childEnt =new ImportToSapChildDTO();
|
|
|
|
|
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());
|
|
|
|
|
@ -820,7 +869,6 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取CRM 订单号
|
|
|
|
|
*
|
|
|
|
|
@ -834,18 +882,19 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发起变更
|
|
|
|
|
*
|
|
|
|
|
* @param bomRowId
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void upgrade(Long bomRowId) throws ExecutionException, InterruptedException {
|
|
|
|
|
BomNewPbomParentEntity parent = this.getById(bomRowId);
|
|
|
|
|
VUtils.isTure(parent.getStatus()< PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能发起变更");
|
|
|
|
|
PBomUpgrade upgrade=new PBomUpgrade(parent,getAllBom(bomRowId,0));
|
|
|
|
|
VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能发起变更");
|
|
|
|
|
PBomUpgrade upgrade = new PBomUpgrade(parent, getAllBom(bomRowId, 0));
|
|
|
|
|
upgrade.upgrade();
|
|
|
|
|
if(CollUtil.isNotEmpty(upgrade.getParentResult())){
|
|
|
|
|
if (CollUtil.isNotEmpty(upgrade.getParentResult())) {
|
|
|
|
|
this.saveOrUpdateBatch(upgrade.getParentResult());
|
|
|
|
|
}
|
|
|
|
|
if(CollUtil.isNotEmpty(upgrade.getChildResult())){
|
|
|
|
|
if (CollUtil.isNotEmpty(upgrade.getChildResult())) {
|
|
|
|
|
pbomChildService.saveOrUpdateBatch(upgrade.getChildResult());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|