|
|
|
|
@ -1,14 +1,14 @@
|
|
|
|
|
package com.aucma.production.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import com.aucma.base.domain.BaseMaterialInfo;
|
|
|
|
|
import com.aucma.base.domain.OrderBomInfo;
|
|
|
|
|
import com.aucma.base.mapper.BaseMaterialinfoMapper;
|
|
|
|
|
import com.aucma.base.service.IOrderBomInfoService;
|
|
|
|
|
import com.aucma.base.utils.MaterialConstants;
|
|
|
|
|
// import java.math.BigDecimal;
|
|
|
|
|
// import com.aucma.base.domain.BaseMaterialInfo;
|
|
|
|
|
// import com.aucma.base.domain.OrderBomInfo;
|
|
|
|
|
// import com.aucma.base.mapper.BaseMaterialinfoMapper;
|
|
|
|
|
// import com.aucma.base.service.IOrderBomInfoService;
|
|
|
|
|
// import com.aucma.base.utils.MaterialConstants;
|
|
|
|
|
import com.aucma.common.exception.ServiceException;
|
|
|
|
|
import com.aucma.common.exception.base.BaseException;
|
|
|
|
|
import com.aucma.common.utils.DateUtils;
|
|
|
|
|
@ -30,11 +30,11 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private BaseBomInfoMapper baseBomInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IOrderBomInfoService orderBomInfoService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private BaseMaterialinfoMapper materialInfoMapper;
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private IOrderBomInfoService orderBomInfoService;
|
|
|
|
|
//
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private BaseMaterialinfoMapper materialInfoMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询生产BOM
|
|
|
|
|
@ -133,12 +133,8 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService {
|
|
|
|
|
if (baseBomInfos.size() > 0) {
|
|
|
|
|
throw new BaseException("该物料编号:" + baseBomInfo.getMaterialCode() + "已存在!");
|
|
|
|
|
}
|
|
|
|
|
// if (StringUtils.isNotNull(baseBomInfo.getParentId())) {
|
|
|
|
|
// BaseBomInfo info = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getParentId());
|
|
|
|
|
// baseBomInfo.setAncestors(info.getAncestors() + "," + baseBomInfo.getMaterialCode());
|
|
|
|
|
// } else {
|
|
|
|
|
// baseBomInfo.setAncestors(baseBomInfo.getMaterialCode());
|
|
|
|
|
// }
|
|
|
|
|
// 当前业务改为手工维护父子关系,这里只维护树查询必需的祖级链,不再从订单BOM自动同步。
|
|
|
|
|
baseBomInfo.setAncestors(buildManualAncestors(baseBomInfo.getParentId(), baseBomInfo.getMaterialCode()));
|
|
|
|
|
baseBomInfo.setCreatedTime(DateUtils.getNowDate());
|
|
|
|
|
return baseBomInfoMapper.insertBaseBomInfo(baseBomInfo);
|
|
|
|
|
}
|
|
|
|
|
@ -151,23 +147,47 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int updateBaseBomInfo(BaseBomInfo baseBomInfo) {
|
|
|
|
|
// String parentId = baseBomInfo.getParentId();
|
|
|
|
|
// if (StringUtils.isNull(parentId)) {
|
|
|
|
|
// baseBomInfo.setAncestors(baseBomInfo.getMaterialCode());
|
|
|
|
|
// } else {
|
|
|
|
|
// BaseBomInfo newParentBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(parentId);
|
|
|
|
|
// BaseBomInfo oldBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getMaterialCode());
|
|
|
|
|
// if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo)) {
|
|
|
|
|
// String newAncestors = newParentBomInfo.getAncestors() + "," + baseBomInfo.getMaterialCode();
|
|
|
|
|
// String oldAncestors = oldBomInfo.getAncestors();
|
|
|
|
|
// baseBomInfo.setAncestors(newAncestors);
|
|
|
|
|
// updateBomChildren(baseBomInfo.getMaterialCode(), newAncestors, oldAncestors);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
BaseBomInfo oldBomInfo = baseBomInfoMapper.selectBaseBomInfoByObjId(baseBomInfo.getObjId());
|
|
|
|
|
String newAncestors = buildManualAncestors(baseBomInfo.getParentId(), baseBomInfo.getMaterialCode());
|
|
|
|
|
baseBomInfo.setAncestors(newAncestors);
|
|
|
|
|
if (StringUtils.isNotNull(oldBomInfo) && StringUtils.isNotEmpty(oldBomInfo.getAncestors())) {
|
|
|
|
|
// 手工调整树结构后,必须同步刷新下级祖级链,保证子树查询仍然命中正确成品路径。
|
|
|
|
|
updateBomChildren(oldBomInfo.getMaterialCode(), newAncestors, oldBomInfo.getAncestors());
|
|
|
|
|
}
|
|
|
|
|
baseBomInfo.setUpdatedTime(DateUtils.getNowDate());
|
|
|
|
|
return baseBomInfoMapper.updateBaseBomInfo(baseBomInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计算手工维护场景下的祖级链
|
|
|
|
|
*
|
|
|
|
|
* @param parentId 父物料编号
|
|
|
|
|
* @param materialCode 当前物料编号
|
|
|
|
|
* @return 祖级链
|
|
|
|
|
*/
|
|
|
|
|
private String buildManualAncestors(String parentId, String materialCode) {
|
|
|
|
|
// 根节点直接以自身编码作为祖级,便于页面按成品物料快速展开整棵树。
|
|
|
|
|
if (isRootNode(parentId)) {
|
|
|
|
|
return materialCode;
|
|
|
|
|
}
|
|
|
|
|
BaseBomInfo parentBomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(parentId);
|
|
|
|
|
if (StringUtils.isNotNull(parentBomInfo) && StringUtils.isNotEmpty(parentBomInfo.getAncestors())) {
|
|
|
|
|
// 优先沿用父节点已有祖级链,避免人工维护时额外维护完整路径字段。
|
|
|
|
|
return parentBomInfo.getAncestors() + "," + materialCode;
|
|
|
|
|
}
|
|
|
|
|
return parentId + "," + materialCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断是否顶级节点
|
|
|
|
|
*
|
|
|
|
|
* @param parentId 父物料编号
|
|
|
|
|
* @return 是否顶级节点
|
|
|
|
|
*/
|
|
|
|
|
private boolean isRootNode(String parentId) {
|
|
|
|
|
return StringUtils.isEmpty(parentId) || "0".equals(parentId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改子元素关系
|
|
|
|
|
*
|
|
|
|
|
@ -222,180 +242,181 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 自动同步生产BOM
|
|
|
|
|
*
|
|
|
|
|
* @param baseBomInfo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
|
|
|
|
|
// 获取成品物料
|
|
|
|
|
BaseMaterialInfo materialInfo = new BaseMaterialInfo();
|
|
|
|
|
materialInfo.setMaterialSubclass(MaterialConstants.FP_MATERIAL_TYPE);
|
|
|
|
|
List<BaseMaterialInfo> baseMaterialInfos = materialInfoMapper.selectBaseMaterialInfoList(materialInfo);
|
|
|
|
|
|
|
|
|
|
// 保存成品BOM信息
|
|
|
|
|
for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) {
|
|
|
|
|
BaseBomInfo bomInfo = new BaseBomInfo();
|
|
|
|
|
bomInfo.setMaterialCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
List<BaseBomInfo> baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(bomInfo);
|
|
|
|
|
if (baseBomInfos.size() == 0) {
|
|
|
|
|
BaseBomInfo info = new BaseBomInfo();
|
|
|
|
|
info.setBomCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
info.setMaterialCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
info.setMaterialName(baseMaterialInfo.getMaterialName());
|
|
|
|
|
info.setMaterialType(MaterialConstants.FP_MATERIAL_TYPE);
|
|
|
|
|
info.setStandardAmount(new BigDecimal(1));
|
|
|
|
|
info.setPlantCode(baseMaterialInfo.getPlantCode());
|
|
|
|
|
info.setCreatedTime(DateUtils.getNowDate());
|
|
|
|
|
info.setAncestors(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
try {
|
|
|
|
|
this.insertBaseBomInfo(info);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) {
|
|
|
|
|
OrderBomInfo cpPomInfo = new OrderBomInfo();
|
|
|
|
|
cpPomInfo.setParentId(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
List<OrderBomInfo> orderBomInfos = orderBomInfoService.selectOrderBomInfoList(cpPomInfo);
|
|
|
|
|
if (orderBomInfos.size() == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//根据成品产品BOM存箱体、门体
|
|
|
|
|
for (OrderBomInfo orderBomInfo : orderBomInfos) {
|
|
|
|
|
orderBomInfo.setAncestors(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
//箱体
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.BOX_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.BOX_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
//门体
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.DOOR_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.DOOR_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取箱体产品BOM信息
|
|
|
|
|
BaseBomInfo selectBoxBomInfo = new BaseBomInfo();
|
|
|
|
|
selectBoxBomInfo.setMaterialType(MaterialConstants.BOX_MATERIAL_TYPE);
|
|
|
|
|
List<BaseBomInfo> boxBaseBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectBoxBomInfo);
|
|
|
|
|
for (BaseBomInfo boxBomInfo : boxBaseBomInfoList) {
|
|
|
|
|
OrderBomInfo selectBomInfo = new OrderBomInfo();
|
|
|
|
|
selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
|
|
|
|
|
List<OrderBomInfo> bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo);
|
|
|
|
|
boolean isYZXTFlag = false; // 判断BOM是否含有预装箱体
|
|
|
|
|
for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
if (orderBomInfo.getMaterialName().contains("预装箱体")) {
|
|
|
|
|
isYZXTFlag = true;//此BOM有预装箱体
|
|
|
|
|
//预装箱体围板
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有预装箱体执行以下操作
|
|
|
|
|
if (!isYZXTFlag) {
|
|
|
|
|
for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
//内胆
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.LINER_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.LINER_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
//围板
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取围板产品BOM信息
|
|
|
|
|
BaseBomInfo selectWBomInfo = new BaseBomInfo();
|
|
|
|
|
selectWBomInfo.setMaterialType(MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
List<BaseBomInfo> boxBaseWBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectWBomInfo);
|
|
|
|
|
for (BaseBomInfo boxBomInfo : boxBaseWBomInfoList) {
|
|
|
|
|
OrderBomInfo selectBomInfo = new OrderBomInfo();
|
|
|
|
|
selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
|
|
|
|
|
List<OrderBomInfo> bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo);
|
|
|
|
|
if (boxBomInfo.getMaterialName().contains("预装箱体")) {
|
|
|
|
|
for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
//围板
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
//内胆
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.LINER_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.LINER_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
//前板
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.FORMER_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.FORMER_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
//后板
|
|
|
|
|
if (orderBomInfo.getMaterialType().equals(MaterialConstants.AFTER_MATERIAL_TYPE)) {
|
|
|
|
|
this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.AFTER_MATERIAL_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据物料类型存生产BOM
|
|
|
|
|
*
|
|
|
|
|
* @param orderBomInfo
|
|
|
|
|
* @param materialType
|
|
|
|
|
*/
|
|
|
|
|
private void saveBaseBomInfoByMaterialType(OrderBomInfo orderBomInfo, String materialType) {
|
|
|
|
|
List<BaseBomInfo> baseBomInfos = this.checkDuplicateBaseBom(orderBomInfo);
|
|
|
|
|
if (baseBomInfos.size() > 0) {
|
|
|
|
|
// 排除异常情况:生产BOM信息重复
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 保存BOM信息
|
|
|
|
|
BaseBomInfo info = new BaseBomInfo();
|
|
|
|
|
info.setBomCode(orderBomInfo.getMaterialCode());
|
|
|
|
|
info.setMaterialCode(orderBomInfo.getMaterialCode());
|
|
|
|
|
info.setMaterialName(orderBomInfo.getMaterialName());
|
|
|
|
|
info.setMaterialType(materialType);
|
|
|
|
|
info.setParentId(orderBomInfo.getParentId());
|
|
|
|
|
info.setStandardAmount(orderBomInfo.getStandardAmount());
|
|
|
|
|
info.setPlantCode(orderBomInfo.getFactoryCode());
|
|
|
|
|
info.setAncestors(orderBomInfo.getAncestors());
|
|
|
|
|
try {
|
|
|
|
|
info.setCreatedTime(DateUtils.getNowDate());
|
|
|
|
|
baseBomInfoMapper.insertBaseBomInfo(info);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.out.println("+++++根据物料类型存生产BOM异常++++:" + e);
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检测重复生产BOM
|
|
|
|
|
*
|
|
|
|
|
* @param bomInfo
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<BaseBomInfo> checkDuplicateBaseBom(OrderBomInfo bomInfo) {
|
|
|
|
|
BaseBomInfo baseBomOne = new BaseBomInfo();
|
|
|
|
|
baseBomOne.setMaterialCode(bomInfo.getMaterialCode());
|
|
|
|
|
baseBomOne.setParentId(bomInfo.getParentId());
|
|
|
|
|
baseBomOne.setPlantCode(bomInfo.getFactoryCode());
|
|
|
|
|
return baseBomInfoMapper.selectBaseBomInfoList(baseBomOne);
|
|
|
|
|
}
|
|
|
|
|
// /**
|
|
|
|
|
// * 自动同步生产BOM
|
|
|
|
|
// *
|
|
|
|
|
// * 当前业务已经改为全部手动维护树形BOM,这里完整注释历史同步实现,避免后续被误恢复或误调用。
|
|
|
|
|
// *
|
|
|
|
|
// * @param baseBomInfo
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// @Override
|
|
|
|
|
// public List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
|
|
|
|
|
// // 获取成品物料
|
|
|
|
|
// BaseMaterialInfo materialInfo = new BaseMaterialInfo();
|
|
|
|
|
// materialInfo.setMaterialSubclass(MaterialConstants.FP_MATERIAL_TYPE);
|
|
|
|
|
// List<BaseMaterialInfo> baseMaterialInfos = materialInfoMapper.selectBaseMaterialInfoList(materialInfo);
|
|
|
|
|
//
|
|
|
|
|
// // 保存成品BOM信息
|
|
|
|
|
// for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) {
|
|
|
|
|
// BaseBomInfo bomInfo = new BaseBomInfo();
|
|
|
|
|
// bomInfo.setMaterialCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// List<BaseBomInfo> baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(bomInfo);
|
|
|
|
|
// if (baseBomInfos.size() == 0) {
|
|
|
|
|
// BaseBomInfo info = new BaseBomInfo();
|
|
|
|
|
// info.setBomCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// info.setMaterialCode(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// info.setMaterialName(baseMaterialInfo.getMaterialName());
|
|
|
|
|
// info.setMaterialType(MaterialConstants.FP_MATERIAL_TYPE);
|
|
|
|
|
// info.setStandardAmount(new BigDecimal(1));
|
|
|
|
|
// info.setPlantCode(baseMaterialInfo.getPlantCode());
|
|
|
|
|
// info.setCreatedTime(DateUtils.getNowDate());
|
|
|
|
|
// info.setAncestors(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// try {
|
|
|
|
|
// this.insertBaseBomInfo(info);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// for (BaseMaterialInfo baseMaterialInfo : baseMaterialInfos) {
|
|
|
|
|
// OrderBomInfo cpPomInfo = new OrderBomInfo();
|
|
|
|
|
// cpPomInfo.setParentId(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// List<OrderBomInfo> orderBomInfos = orderBomInfoService.selectOrderBomInfoList(cpPomInfo);
|
|
|
|
|
// if (orderBomInfos.size() == 0) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
// // 根据成品产品BOM存箱体、门体
|
|
|
|
|
// for (OrderBomInfo orderBomInfo : orderBomInfos) {
|
|
|
|
|
// orderBomInfo.setAncestors(baseMaterialInfo.getMaterialCode());
|
|
|
|
|
// // 箱体
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.BOX_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.BOX_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// // 门体
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.DOOR_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.DOOR_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 获取箱体产品BOM信息
|
|
|
|
|
// BaseBomInfo selectBoxBomInfo = new BaseBomInfo();
|
|
|
|
|
// selectBoxBomInfo.setMaterialType(MaterialConstants.BOX_MATERIAL_TYPE);
|
|
|
|
|
// List<BaseBomInfo> boxBaseBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectBoxBomInfo);
|
|
|
|
|
// for (BaseBomInfo boxBomInfo : boxBaseBomInfoList) {
|
|
|
|
|
// OrderBomInfo selectBomInfo = new OrderBomInfo();
|
|
|
|
|
// selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
|
|
|
|
|
// List<OrderBomInfo> bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo);
|
|
|
|
|
// boolean isYZXTFlag = false; // 判断BOM是否含有预装箱体
|
|
|
|
|
// for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
// if (orderBomInfo.getMaterialName().contains("预装箱体")) {
|
|
|
|
|
// isYZXTFlag = true; // 此BOM有预装箱体
|
|
|
|
|
// // 预装箱体围板
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 没有预装箱体执行以下操作
|
|
|
|
|
// if (!isYZXTFlag) {
|
|
|
|
|
// for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
// orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
// // 内胆
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.LINER_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.LINER_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// // 围板
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 获取围板产品BOM信息
|
|
|
|
|
// BaseBomInfo selectWBomInfo = new BaseBomInfo();
|
|
|
|
|
// selectWBomInfo.setMaterialType(MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
// List<BaseBomInfo> boxBaseWBomInfoList = baseBomInfoMapper.selectBaseBomInfoList(selectWBomInfo);
|
|
|
|
|
// for (BaseBomInfo boxBomInfo : boxBaseWBomInfoList) {
|
|
|
|
|
// OrderBomInfo selectBomInfo = new OrderBomInfo();
|
|
|
|
|
// selectBomInfo.setParentId(boxBomInfo.getMaterialCode());
|
|
|
|
|
// List<OrderBomInfo> bomInfoList = orderBomInfoService.selectOrderBomInfoList(selectBomInfo);
|
|
|
|
|
// if (boxBomInfo.getMaterialName().contains("预装箱体")) {
|
|
|
|
|
// for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
// orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
// // 围板
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.COAMING_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.COAMING_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// // 内胆
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.LINER_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.LINER_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// for (OrderBomInfo orderBomInfo : bomInfoList) {
|
|
|
|
|
// orderBomInfo.setAncestors(boxBomInfo.getAncestors());
|
|
|
|
|
// // 前板
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.FORMER_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.FORMER_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// // 后板
|
|
|
|
|
// if (orderBomInfo.getMaterialType().equals(MaterialConstants.AFTER_MATERIAL_TYPE)) {
|
|
|
|
|
// this.saveBaseBomInfoByMaterialType(orderBomInfo, MaterialConstants.AFTER_MATERIAL_TYPE);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 根据物料类型存生产BOM
|
|
|
|
|
// *
|
|
|
|
|
// * @param orderBomInfo
|
|
|
|
|
// * @param materialType
|
|
|
|
|
// */
|
|
|
|
|
// private void saveBaseBomInfoByMaterialType(OrderBomInfo orderBomInfo, String materialType) {
|
|
|
|
|
// List<BaseBomInfo> baseBomInfos = this.checkDuplicateBaseBom(orderBomInfo);
|
|
|
|
|
// if (baseBomInfos.size() > 0) {
|
|
|
|
|
// // 排除异常情况:生产BOM信息重复
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// // 保存BOM信息
|
|
|
|
|
// BaseBomInfo info = new BaseBomInfo();
|
|
|
|
|
// info.setBomCode(orderBomInfo.getMaterialCode());
|
|
|
|
|
// info.setMaterialCode(orderBomInfo.getMaterialCode());
|
|
|
|
|
// info.setMaterialName(orderBomInfo.getMaterialName());
|
|
|
|
|
// info.setMaterialType(materialType);
|
|
|
|
|
// info.setParentId(orderBomInfo.getParentId());
|
|
|
|
|
// info.setStandardAmount(orderBomInfo.getStandardAmount());
|
|
|
|
|
// info.setPlantCode(orderBomInfo.getFactoryCode());
|
|
|
|
|
// info.setAncestors(orderBomInfo.getAncestors());
|
|
|
|
|
// try {
|
|
|
|
|
// info.setCreatedTime(DateUtils.getNowDate());
|
|
|
|
|
// baseBomInfoMapper.insertBaseBomInfo(info);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// System.out.println("+++++根据物料类型存生产BOM异常++++:" + e);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 检测重复生产BOM
|
|
|
|
|
// *
|
|
|
|
|
// * @param bomInfo
|
|
|
|
|
// * @return
|
|
|
|
|
// */
|
|
|
|
|
// private List<BaseBomInfo> checkDuplicateBaseBom(OrderBomInfo bomInfo) {
|
|
|
|
|
// BaseBomInfo baseBomOne = new BaseBomInfo();
|
|
|
|
|
// baseBomOne.setMaterialCode(bomInfo.getMaterialCode());
|
|
|
|
|
// baseBomOne.setParentId(bomInfo.getParentId());
|
|
|
|
|
// baseBomOne.setPlantCode(bomInfo.getFactoryCode());
|
|
|
|
|
// return baseBomInfoMapper.selectBaseBomInfoList(baseBomOne);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|