refactor(bom): 调整BOM维护方式为手工管理模式

- 注释自动同步生产BOM相关接口和实现逻辑
- 添加手工维护树形BOM的祖级链构建功能
- 实现BOM父子关系的手工调整和子级同步刷新机制
- 添加工厂管理全量查询接口支持
- 实现物料信息Excel导入导出功能
- 优化物料规格填充逻辑并支持批量导入
- 添加物料编码集合查询功能支持批量加载
master
zangch@mesnac.com 7 days ago
parent cfd0972889
commit e607a76630

@ -109,13 +109,15 @@ public class SAPTask {
}
/**
* BOM
*
*/
public void automaticSynchronizationBOM() {
baseBomInfoService.addAutomaticSynchronizationBOM(new BaseBomInfo());
}
// /**
// * 自动同步生产BOM定时任务
// *
// * 当前业务已经改为全部手动维护树形BOM这里注释掉定时任务入口避免定时器再次写入生产BOM。
// *
// */
// public void automaticSynchronizationBOM() {
// baseBomInfoService.addAutomaticSynchronizationBOM(new BaseBomInfo());
// }
/**
* MES

@ -46,6 +46,15 @@ public class BaseFactoryController extends BaseController {
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:factory:list')")
@GetMapping("/all")
public AjaxResult all(BaseFactory baseFactory) {
return success(baseFactoryService.selectBaseFactoryList(baseFactory));
}
/**
*
* @param baseFactory
@ -53,8 +62,8 @@ public class BaseFactoryController extends BaseController {
*/
@GetMapping("/findFactoryList")
public AjaxResult findFactoryList(BaseFactory baseFactory) {
List<BaseFactory> list = baseFactoryService.selectBaseFactoryList(baseFactory);
return success(list);
// 为什么保留旧接口:前端多个页面已在用该地址,这里继续复用全量查询能力,避免为了接口标准化引入联动回归。
return all(baseFactory);
}
/**

@ -1,9 +1,10 @@
package com.aucma.base.controller;
import java.io.InputStream;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.aucma.common.utils.DateUtils;
import com.aucma.base.utils.MaterialImportExcelHelper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -14,13 +15,16 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.common.utils.file.FileUtils;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.utils.StringUtils;
import com.aucma.common.core.page.TableDataInfo;
/**
@ -46,6 +50,15 @@ public class BaseMaterialInfoController extends BaseController {
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:materialInfo:list')" )
@GetMapping("/all" )
public AjaxResult all(BaseMaterialInfo baseMaterialInfo) {
return success(baseMaterialInfoService.selectBaseMaterialInfoList(baseMaterialInfo));
}
/**
*
*/
@ -58,6 +71,36 @@ public class BaseMaterialInfoController extends BaseController {
util.exportExcel(response, list, "物料信息数据" );
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:materialInfo:add')" )
@Log(title = "物料信息" , businessType = BusinessType.IMPORT)
@PostMapping("/importData" )
public AjaxResult importData(MultipartFile file, boolean updateSupport, String plantCode) throws Exception {
if (file == null || file.isEmpty()) {
return error("请选择需要导入的Excel文件");
}
if (StringUtils.isBlank(plantCode)) {
return error("请选择所属工厂");
}
try (InputStream inputStream = file.getInputStream()) {
String message = baseMaterialInfoService.importMaterialExcel(inputStream, updateSupport, getUsername(), plantCode);
return success(message);
}
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('base:materialInfo:add')" )
@PostMapping("/importTemplate" )
public void importTemplate(HttpServletResponse response) throws Exception {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
FileUtils.setAttachmentResponseHeader(response, "物料导入模板.xlsx");
MaterialImportExcelHelper.writeTemplate(response.getOutputStream());
}
/**
*
*/

@ -2,6 +2,7 @@ package com.aucma.base.mapper;
import java.util.List;
import com.aucma.base.domain.BaseMaterialInfo;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -35,6 +36,14 @@ public interface BaseMaterialinfoMapper
*/
public List<BaseMaterialInfo> selectPdaMaterialListByKeyword(String keyword);
/**
*
*
* @param materialCodes
* @return
*/
public List<BaseMaterialInfo> selectBaseMaterialInfoByMaterialCodes(@Param("materialCodes") List<String> materialCodes);
/**
*
*

@ -1,5 +1,6 @@
package com.aucma.base.service;
import java.io.InputStream;
import java.util.List;
import com.aucma.base.domain.BaseMaterialInfo;
@ -35,6 +36,17 @@ public interface IBaseMaterialInfoService
*/
public List<BaseMaterialInfo> selectPdaMaterialListByKeyword(String keyword);
/**
*
*
* @param inputStream Excel
* @param updateSupport
* @param operName
* @param plantCode
* @return
*/
public String importMaterialExcel(InputStream inputStream, Boolean updateSupport, String operName, String plantCode);
/**
*
*

@ -1,14 +1,22 @@
package com.aucma.base.service.impl;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.mapper.BaseMaterialinfoMapper;
import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.base.utils.MaterialConstants;
import com.aucma.base.utils.MaterialImportExcelHelper;
import com.aucma.common.exception.ServiceException;
import com.aucma.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.base.mapper.BaseMaterialinfoMapper;
import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.service.IBaseMaterialInfoService;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -55,6 +63,60 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
return baseMaterialInfoMapper.selectPdaMaterialListByKeyword(keyword);
}
/**
* BOM
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String importMaterialExcel(InputStream inputStream, Boolean updateSupport, String operName, String plantCode)
{
try
{
MaterialImportExcelHelper.ParseResult parseResult = MaterialImportExcelHelper.parse(inputStream);
List<MaterialImportExcelHelper.MaterialImportRow> importRows = parseResult.getMaterialRows();
Map<String, BaseMaterialInfo> existMap = loadExistMaterialMap(importRows);
int insertNum = 0;
int updateNum = 0;
int skipNum = 0;
Date now = DateUtils.getNowDate();
for (MaterialImportExcelHelper.MaterialImportRow importRow : importRows)
{
BaseMaterialInfo existed = existMap.get(importRow.getMaterialCode());
if (existed == null)
{
BaseMaterialInfo materialInfo = buildImportMaterial(importRow, operName, plantCode, now);
insertBaseMaterialInfo(materialInfo);
insertNum++;
continue;
}
if (!Boolean.TRUE.equals(updateSupport))
{
skipNum++;
continue;
}
// Why模板只有编码和对象描述更新时只覆盖模板能表达的字段避免把人工维护的单位/分类等数据刷成空值。
existed.setMaterialName(importRow.getMaterialName());
if (!isBlank(plantCode))
{
existed.setPlantCode(plantCode);
}
existed.setIncrementDate(now);
existed.setUpdatedBy(operName);
updateBaseMaterialInfo(existed);
updateNum++;
}
return buildImportResult(insertNum, updateNum, skipNum, parseResult.getDuplicateRows());
}
catch (ServiceException e)
{
throw e;
}
catch (Exception e)
{
throw new ServiceException("导入物料模板失败:" + e.getMessage());
}
}
/**
*
*
@ -64,22 +126,7 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
@Override
public int insertBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo)
{
//维护物料型号
String materialName = baseMaterialInfo.getMaterialName();
String materialSubclass = baseMaterialInfo.getMaterialSubclass();
if (materialSubclass.equals(MaterialConstants.FP_MATERIAL_TYPE)){
String[] split = materialName.split(",");
if (split.length > 0 && split[0].startsWith("BC")){
baseMaterialInfo.setMaterialSpecifications(split[0]);
}else {
baseMaterialInfo.setMaterialSpecifications(split[0].substring(1));
}
}else {
String[] split = materialName.split(",");
if (split.length > 1){
baseMaterialInfo.setMaterialSpecifications(split[1]);
}
}
fillMaterialSpecifications(baseMaterialInfo);
baseMaterialInfo.setCreatedTime(DateUtils.getNowDate());
return baseMaterialInfoMapper.insertBaseMaterialInfo(baseMaterialInfo);
}
@ -93,6 +140,7 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
@Override
public int updateBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo)
{
fillMaterialSpecifications(baseMaterialInfo);
baseMaterialInfo.setUpdatedTime(DateUtils.getNowDate());
return baseMaterialInfoMapper.updateBaseMaterialInfo(baseMaterialInfo);
}
@ -120,4 +168,119 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
{
return baseMaterialInfoMapper.deleteBaseMaterialInfoByObjId(objId);
}
private Map<String, BaseMaterialInfo> loadExistMaterialMap(List<MaterialImportExcelHelper.MaterialImportRow> importRows)
{
Map<String, BaseMaterialInfo> materialMap = new LinkedHashMap<>();
List<String> materialCodes = new ArrayList<>();
for (MaterialImportExcelHelper.MaterialImportRow importRow : importRows)
{
materialCodes.add(importRow.getMaterialCode());
}
int batchSize = 900;
for (int index = 0; index < materialCodes.size(); index += batchSize)
{
int endIndex = Math.min(index + batchSize, materialCodes.size());
List<String> subCodes = materialCodes.subList(index, endIndex);
List<BaseMaterialInfo> existedList = baseMaterialInfoMapper.selectBaseMaterialInfoByMaterialCodes(subCodes);
for (BaseMaterialInfo materialInfo : existedList)
{
materialMap.put(materialInfo.getMaterialCode(), materialInfo);
}
}
return materialMap;
}
private BaseMaterialInfo buildImportMaterial(MaterialImportExcelHelper.MaterialImportRow importRow, String operName, String plantCode, Date incrementDate)
{
BaseMaterialInfo materialInfo = new BaseMaterialInfo();
materialInfo.setMaterialCode(importRow.getMaterialCode());
materialInfo.setMaterialName(importRow.getMaterialName());
materialInfo.setPlantCode(plantCode);
materialInfo.setIsFlag(0L);
materialInfo.setIncrementDate(incrementDate);
materialInfo.setCreatedBy(operName);
return materialInfo;
}
private String buildImportResult(int insertNum, int updateNum, int skipNum, List<MaterialImportExcelHelper.DuplicateMaterialRow> duplicateRows)
{
StringBuilder builder = new StringBuilder("导入完成!");
builder.append("<br/>新增:").append(insertNum).append(" 条");
builder.append("<br/>更新:").append(updateNum).append(" 条");
if (skipNum > 0)
{
builder.append("<br/>跳过:").append(skipNum).append(" 条");
}
if (duplicateRows != null && !duplicateRows.isEmpty())
{
builder.append("<br/>模板内重复编码已跳过:").append(duplicateRows.size()).append(" 条");
int previewSize = Math.min(10, duplicateRows.size());
for (int index = 0; index < previewSize; index++)
{
MaterialImportExcelHelper.DuplicateMaterialRow duplicateRow = duplicateRows.get(index);
builder.append("<br/>重复编码[")
.append(duplicateRow.getDuplicateRow().getMaterialCode())
.append("],保留 ")
.append(duplicateRow.getFirstRow().getSheetName())
.append(" 第")
.append(duplicateRow.getFirstRow().getRowNum())
.append("行,跳过 ")
.append(duplicateRow.getDuplicateRow().getSheetName())
.append(" 第")
.append(duplicateRow.getDuplicateRow().getRowNum())
.append("行");
}
if (duplicateRows.size() > previewSize)
{
builder.append("<br/>其余重复编码共 ").append(duplicateRows.size() - previewSize).append(" 条未展开。");
}
}
return builder.toString();
}
private void fillMaterialSpecifications(BaseMaterialInfo baseMaterialInfo)
{
String materialName = trimToEmpty(baseMaterialInfo.getMaterialName());
String materialSubclass = trimToEmpty(baseMaterialInfo.getMaterialSubclass());
if (materialName.isEmpty() || materialSubclass.isEmpty())
{
return;
}
String[] split = materialName.split(",");
if (split.length == 0)
{
return;
}
// Why导入模板只有编码和描述只有在分类口径明确时才推导规格避免因为模板信息不全覆盖人工维护结果。
if (MaterialConstants.FP_MATERIAL_TYPE.equals(materialSubclass))
{
String firstPart = trimToEmpty(split[0]);
if (firstPart.isEmpty())
{
return;
}
if (firstPart.startsWith("BC") || firstPart.length() == 1)
{
baseMaterialInfo.setMaterialSpecifications(firstPart);
return;
}
baseMaterialInfo.setMaterialSpecifications(firstPart.substring(1));
return;
}
if (split.length > 1)
{
baseMaterialInfo.setMaterialSpecifications(trimToEmpty(split[1]));
}
}
private boolean isBlank(String text)
{
return text == null || text.trim().isEmpty();
}
private String trimToEmpty(String text)
{
return text == null ? "" : text.trim();
}
}

@ -11,7 +11,9 @@ import com.aucma.base.domain.BaseOrderInfo;
import com.aucma.base.mapper.BaseOrderInfoMapper;
import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.base.service.IBaseOrderInfoService;
import com.aucma.common.exception.ServiceException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -95,6 +97,7 @@ public class BaseOrderInfoServiceImpl implements IBaseOrderInfoService {
*/
@Override
public int insertBaseOrderInfo(BaseOrderInfo baseOrderInfo) {
syncMaterialMasterFields(baseOrderInfo);
baseOrderInfo.setCreatedTime(DateUtils.getNowDate());
return baseOrderInfoMapper.insertBaseOrderInfo(baseOrderInfo);
}
@ -107,6 +110,7 @@ public class BaseOrderInfoServiceImpl implements IBaseOrderInfoService {
*/
@Override
public int updateBaseOrderInfo(BaseOrderInfo baseOrderInfo) {
syncMaterialMasterFields(baseOrderInfo);
baseOrderInfo.setUpdatedTime(DateUtils.getNowDate());
return baseOrderInfoMapper.updateBaseOrderInfo(baseOrderInfo);
}
@ -339,4 +343,22 @@ public class BaseOrderInfoServiceImpl implements IBaseOrderInfoService {
return baseOrderInfoMapper.updateBaseOrderInfo(order);
}
private void syncMaterialMasterFields(BaseOrderInfo baseOrderInfo)
{
if (baseOrderInfo == null || StringUtils.isBlank(baseOrderInfo.getMaterialCode())) {
throw new ServiceException("物料编码不能为空,请先选择物料");
}
BaseMaterialInfo query = new BaseMaterialInfo();
query.setMaterialCode(baseOrderInfo.getMaterialCode().trim());
List<BaseMaterialInfo> materialInfoList = baseMaterialInfoService.selectBaseMaterialInfoList(query);
if (materialInfoList == null || materialInfoList.isEmpty()) {
throw new ServiceException("物料编码不存在,请重新选择物料");
}
BaseMaterialInfo materialInfo = materialInfoList.get(0);
baseOrderInfo.setMaterialCode(materialInfo.getMaterialCode());
// 为什么要以后端回填为准:订单的物料名称和物料组属于主数据快照,不能信任前端传参,避免绕过选择弹窗写入脏数据。
baseOrderInfo.setMaterialName(materialInfo.getMaterialName());
baseOrderInfo.setMatkl(materialInfo.getMaterialMatkl());
}
}

@ -2,7 +2,6 @@ package com.aucma.base.service.impl;
import java.util.List;
import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,20 +55,8 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
@Override
public int insertOrderBomInfo(OrderBomInfo orderBomInfo)
{
// OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode());
// if (StringUtils.isNotNull(bomInfo)){
// throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!");
// }
// if (StringUtils.isNotNull(orderBomInfo.getParentId())){
// OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId());
// if (StringUtils.isNotNull(info)){
// orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode());
// }else {
// orderBomInfo.setAncestors(orderBomInfo.getParentId() + "," + orderBomInfo.getMaterialCode());
// }
// }else {
// orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
// }
// 当前业务改为手工维护父子关系,这里只维护树查询必需的祖级链,不再做任何跨模块同步。
orderBomInfo.setAncestors(buildManualAncestors(orderBomInfo.getParentId(), orderBomInfo.getMaterialCode()));
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
return orderBomInfoMapper.insertOrderBomInfo(orderBomInfo);
}
@ -83,29 +70,52 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
@Override
public int updateOrderBomInfo(OrderBomInfo orderBom)
{
// List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(orderBom);
// for (OrderBomInfo orderBomInfo : orderBomInfos) {
// String parentId = orderBomInfo.getParentId();
// if (StringUtils.isNull(parentId)){
// orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
// }else {
// OrderBomInfo newParentBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(parentId);
// OrderBomInfo oldBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode());
// if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo))
// {
// String newAncestors = newParentBomInfo.getAncestors() + "," + orderBomInfo.getMaterialCode();
// String oldAncestors = oldBomInfo.getAncestors();
// orderBomInfo.setAncestors(newAncestors);
// updateBomChildren(orderBomInfo.getMaterialCode(), newAncestors, oldAncestors);
// }
// }
// orderBomInfo.setUpdatedTime(DateUtils.getNowDate());
// orderBomInfoMapper.updateOrderBomInfo(orderBomInfo);
// }
OrderBomInfo oldBomInfo = orderBomInfoMapper.selectOrderBomInfoByObjId(orderBom.getObjId());
String newAncestors = buildManualAncestors(orderBom.getParentId(), orderBom.getMaterialCode());
orderBom.setAncestors(newAncestors);
if (StringUtils.isNotNull(oldBomInfo) && StringUtils.isNotEmpty(oldBomInfo.getAncestors()))
{
// 手工调整父节点后,需要同步刷新当前节点下所有子节点的祖级链,否则树查询会失真。
updateBomChildren(oldBomInfo.getMaterialCode(), newAncestors, oldBomInfo.getAncestors());
}
orderBom.setUpdatedTime(DateUtils.getNowDate());
return orderBomInfoMapper.updateOrderBomInfo(orderBom);
}
/**
*
*
* @param parentId
* @param materialCode
* @return
*/
private String buildManualAncestors(String parentId, String materialCode)
{
// 根节点直接以自身编码作为祖级,便于前端按成品或顶层节点筛子树。
if (isRootNode(parentId))
{
return materialCode;
}
OrderBomInfo parentBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(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);
}
/**
*
*

@ -103,6 +103,14 @@
WHERE ROWNUM &lt;= 30
</select>
<select id="selectBaseMaterialInfoByMaterialCodes" resultMap="BaseMaterialInfoResult">
<include refid="selectBaseMaterialInfoVo"/>
where ml.material_code in
<foreach collection="materialCodes" item="materialCode" open="(" separator="," close=")">
#{materialCode}
</foreach>
</select>
<insert id="insertBaseMaterialInfo" parameterType="BaseMaterialInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_base_materialinfo.NEXTVAL as objId FROM DUAL

@ -88,17 +88,7 @@ public class DmsBaseMaintStationServiceImpl implements IDmsBaseMaintStationServi
List<DmsBaseMaintStation> dmsBaseMaintStationsNew = dmsBaseMaintStationMapper.
selectDmsBaseMaintStationList(dmsBaseMaintStation);
dmsBaseMaintStation.setMaintStationId(dmsBaseMaintStationsNew.get(0).getMaintStationId());
//若Long[] ProductIds不为空则分批添加
if (dmsBaseMaintStation.getProductIds().length > 0) {
List<DmsBaseStationProject> dmsBaseStationProjectList = new ArrayList<>();
for (Long productId : dmsBaseMaintStation.getProductIds()) {
DmsBaseStationProject dmsBaseStationProject = new DmsBaseStationProject();
dmsBaseStationProject.setMaintStationId(dmsBaseMaintStation.getMaintStationId());
dmsBaseStationProject.setMaintProjectId(productId);
dmsBaseStationProjectList.add(dmsBaseStationProject);
}
dmsBaseStationProjectService.batchInsertDmsBaseStationProject(dmsBaseStationProjectList);
}
saveStationProjects(dmsBaseMaintStation.getMaintStationId(), dmsBaseMaintStation.getProductIds(), false);
return i;
}
@ -116,7 +106,7 @@ public class DmsBaseMaintStationServiceImpl implements IDmsBaseMaintStationServi
MaintStation.setMaintStationCode(dmsBaseMaintStation.getMaintStationCode());
List<DmsBaseMaintStation> dmsBaseMaintStationlist = dmsBaseMaintStationMapper
.selectDmsBaseMaintStationList(MaintStation);
if (dmsBaseMaintStationlist.size() > 0 && !dmsBaseMaintStationlist.get(0).getMaintStationId()
if (!dmsBaseMaintStationlist.isEmpty() && !dmsBaseMaintStationlist.get(0).getMaintStationId()
.equals(dmsBaseMaintStation.getMaintStationId())) {
throw new ServiceException("保养部位信息编码已存在");
}
@ -124,39 +114,7 @@ public class DmsBaseMaintStationServiceImpl implements IDmsBaseMaintStationServi
dmsBaseMaintStation.setUpdateBy(user.getUserId());
dmsBaseMaintStation.setUpdateTime(DateUtils.getNowDate());
//若Long[] ProductIds不为空
if (dmsBaseMaintStation.getProductIds().length > 0) {
//根据部位id先去若StaionProject表中查询是否已有数据
DmsBaseStationProject dmsBaseStationProjectSearch = new DmsBaseStationProject();
dmsBaseStationProjectSearch.setMaintStationId(dmsBaseMaintStation.getMaintStationId());
List<DmsBaseStationProject> dmsBaseStationProjectSerchList = dmsBaseStationProjectService
.selectDmsBaseStationProjectList(dmsBaseStationProjectSearch);
//list存储每个实体
List<DmsBaseStationProject> dmsBaseStationProjectList = new ArrayList<>();
//若StaionProject表中有数据则更新先根据部位id删除再分批添加
if (dmsBaseStationProjectSerchList.size() > 0) {
//list存储每个实体每个实体设置属性
for (Long productId : dmsBaseMaintStation.getProductIds()) {
DmsBaseStationProject dmsBaseStationProject = new DmsBaseStationProject();
dmsBaseStationProject.setMaintStationId(dmsBaseMaintStation.getMaintStationId());
dmsBaseStationProject.setMaintProjectId(productId);
dmsBaseStationProjectList.add(dmsBaseStationProject);
}
dmsBaseStationProjectService.batchUpdateDmsBaseStationProject(dmsBaseStationProjectList);
} else {
//若StaionProject无数据则添加
for (Long productId : dmsBaseMaintStation.getProductIds()) {
DmsBaseStationProject dmsBaseStationProject = new DmsBaseStationProject();
dmsBaseStationProject.setMaintStationId(dmsBaseMaintStation.getMaintStationId());
dmsBaseStationProject.setMaintProjectId(productId);
dmsBaseStationProjectList.add(dmsBaseStationProject);
}
dmsBaseStationProjectService.batchInsertDmsBaseStationProject(dmsBaseStationProjectList);
}
} else {
//若ProductIds为空则根据maintStationId删除相关
dmsBaseStationProjectService.deleteDmsBaseStationProjectByMaintStationIds(dmsBaseMaintStation.getMaintStationId());
}
saveStationProjects(dmsBaseMaintStation.getMaintStationId(), dmsBaseMaintStation.getProductIds(), true);
return dmsBaseMaintStationMapper.updateDmsBaseMaintStation(dmsBaseMaintStation);
}
@ -193,4 +151,42 @@ public class DmsBaseMaintStationServiceImpl implements IDmsBaseMaintStationServi
dmsBaseStationProjectService.deleteDmsBaseStationProjectByMaintStationIds(maintStationId);
return dmsBaseMaintStationMapper.deleteDmsBaseMaintStationByMaintStationId(maintStationId);
}
private void saveStationProjects(Long maintStationId, Long[] productIds, boolean clearBeforeInsert)
{
if (maintStationId == null) {
return;
}
if (clearBeforeInsert) {
// 修改时先清空旧关联,再写入当前勾选结果,避免残留旧项目或重复关系。
dmsBaseStationProjectService.deleteDmsBaseStationProjectByMaintStationIds(maintStationId);
}
if (productIds == null || productIds.length == 0) {
return;
}
List<DmsBaseStationProject> dmsBaseStationProjectList = buildStationProjectList(maintStationId, productIds);
if (dmsBaseStationProjectList.isEmpty()) {
return;
}
dmsBaseStationProjectService.batchInsertDmsBaseStationProject(dmsBaseStationProjectList);
}
private List<DmsBaseStationProject> buildStationProjectList(Long maintStationId, Long[] productIds)
{
List<DmsBaseStationProject> dmsBaseStationProjectList = new ArrayList<>();
for (Long productId : productIds) {
if (productId == null) {
continue;
}
// 这里过滤空项目ID避免脏数据进入批量SQL后导致整批回滚。
DmsBaseStationProject dmsBaseStationProject = new DmsBaseStationProject();
dmsBaseStationProject.setMaintStationId(maintStationId);
dmsBaseStationProject.setMaintProjectId(productId);
dmsBaseStationProjectList.add(dmsBaseStationProject);
}
return dmsBaseStationProjectList;
}
}

@ -91,13 +91,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<!-- Oracle 11 对批量插入更稳妥的写法:统一走 insert into ... select ... union all避免 insert all 在不同驱动/SQL 组装场景下触发 ORA-00933。 -->
<insert id="batchInsertDmsBaseStationProject" parameterType="java.util.List">
insert all
<foreach collection="list" item="item" index="index">
into dms_base_station_project(maint_station_id, maint_project_id)
values (#{item.maintStationId}, #{item.maintProjectId})
insert into dms_base_station_project (maint_station_id, maint_project_id)
<foreach collection="list" item="item" separator=" union all ">
select #{item.maintStationId,jdbcType=NUMERIC}, #{item.maintProjectId,jdbcType=NUMERIC}
from dual
</foreach>
select 1 from dual
</insert>
</mapper>

@ -108,15 +108,18 @@ public class BaseBomInfoController extends BaseController {
return toAjax(baseBomInfoService.deleteBaseBomInfoByObjIds(objIds));
}
/**
* BOM
* @param baseBomInfo
* @return
*/
@GetMapping("/addAutomaticSynchronizationBOM" )
public AjaxResult addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
List<BaseBomInfo> list = baseBomInfoService.addAutomaticSynchronizationBOM(baseBomInfo);
return success(list);
}
// /**
// * 自动同步生产BOM
// *
// * 当前业务已经改为全部手动维护树形BOM这里注释掉历史同步入口避免页面或外部接口继续触发。
// *
// * @param baseBomInfo
// * @return
// */
// @GetMapping("/addAutomaticSynchronizationBOM" )
// public AjaxResult addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
// List<BaseBomInfo> list = baseBomInfoService.addAutomaticSynchronizationBOM(baseBomInfo);
// return success(list);
// }
}

@ -66,12 +66,15 @@ public interface IBaseBomInfoService
*/
void checkBomInfo(List<BaseBomInfo> baseBomInfoList);
/**
* BOM
* @param baseBomInfo
* @return
*/
List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo);
// /**
// * 自动同步生产BOM
// *
// * 当前业务已经改为全部手动维护树形BOM这里保留注释作为历史能力记录。
// *
// * @param baseBomInfo
// * @return
// */
// List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo);
/**
* BOM

@ -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);
// }
}

Loading…
Cancel
Save