Merge branch '20260519-3.9.2版本-葛昊天分支'
This commit is contained in:
@@ -62,12 +62,6 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
|
||||
private static final Set<String> RUBBER_CATEGORY_KEYS = Set.of("S", "P", "T", "C");
|
||||
private static final Pattern RUBBER_CODE_VERSION_PATTERN = Pattern.compile("([A-Z])01$");
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A48】生成混炼示方同步B/F段胶至密炼物料-----------
|
||||
private static final String CATEGORY_MASTER_MAJOR = "XSLMES_MATERIAL_MASTER";
|
||||
private static final String CATEGORY_MASTER_MINOR_A = "XSLMES_MATERIAL_MASTER_A";
|
||||
private static final String CATEGORY_FINAL_MAJOR = "XSLMES_MATERIAL_FINAL";
|
||||
private static final String CATEGORY_FINAL_MINOR_Q = "XSLMES_MATERIAL_FINAL_Q";
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A48】生成混炼示方同步B/F段胶至密炼物料-----------
|
||||
|
||||
@Resource
|
||||
private MesXslFormulaSpecLineMapper lineMapper;
|
||||
@@ -776,10 +770,10 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A44】生成混炼示方时按设备有效体积计算填充体积-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A48】生成混炼示方同步B/F段胶至密炼物料-----------
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】生成混炼示方改为同步B/F段胶至胶料信息-----------
|
||||
/**
|
||||
* 生成混炼示方时,将 B 段/F 段胶料同步写入密炼物料:
|
||||
* B 段 -> 物料大类「母炼胶」+ 小类「A胶」;F 段 -> 物料大类「终炼胶」+ 小类「Q胶」。
|
||||
* 生成混炼示方时,将 B 段/F 段胶料同步写入「胶料信息」(mes_material):
|
||||
* 胶料类别取配合示方所选「胶料代号」对应胶料的类别;不再写入密炼物料,也不再维护比重。
|
||||
*/
|
||||
private void syncGeneratedRubberMixerMaterial(
|
||||
MesXslFormulaMixingGenerateRowVO row,
|
||||
@@ -791,26 +785,13 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
}
|
||||
String specCode = row.getSpecCode().trim();
|
||||
boolean isFinalStage = "Q".equalsIgnoreCase(resolveMixingMaterialStep(row));
|
||||
String majorCode = isFinalStage ? CATEGORY_FINAL_MAJOR : CATEGORY_MASTER_MAJOR;
|
||||
String minorCode = isFinalStage ? CATEGORY_FINAL_MINOR_Q : CATEGORY_MASTER_MINOR_A;
|
||||
String majorCategoryId = resolveCategoryIdByCode(majorCode, categoryIdCache);
|
||||
String minorCategoryId = resolveCategoryIdByCode(minorCode, categoryIdCache);
|
||||
if (StringUtils.isBlank(majorCategoryId) || StringUtils.isBlank(minorCategoryId)) {
|
||||
throw new IllegalArgumentException(
|
||||
"未找到物料分类「" + (isFinalStage ? "终炼胶/Q胶" : "母炼胶/A胶") + "」,请先维护 MES 物料分类字典");
|
||||
}
|
||||
BigDecimal specificGravity = isFinalStage ? compoundSpecificGravity : formula.getARubberSg();
|
||||
String categoryId = resolveGeneratedRubberCategoryId(formula);
|
||||
String rubberName = resolveRubberName(formula);
|
||||
String materialDesc = StringUtils.isNotBlank(formula.getPurpose()) ? formula.getPurpose().trim() : rubberName;
|
||||
|
||||
MesMixerMaterial existing = findMixerMaterialByCodeOrName(specCode);
|
||||
MesMaterial existing = findRubberMaterialByCodeOrName(specCode);
|
||||
Date now = new Date();
|
||||
if (existing != null) {
|
||||
existing.setMajorCategoryId(majorCategoryId);
|
||||
existing.setMinorCategoryId(minorCategoryId);
|
||||
existing.setSpecificGravity(specificGravity);
|
||||
if (StringUtils.isNotBlank(materialDesc)) {
|
||||
existing.setMaterialDesc(materialDesc);
|
||||
if (StringUtils.isNotBlank(categoryId)) {
|
||||
existing.setCategoryId(categoryId);
|
||||
}
|
||||
if (StringUtils.isBlank(existing.getMaterialCode())) {
|
||||
existing.setMaterialCode(specCode);
|
||||
@@ -818,74 +799,68 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
if (StringUtils.isBlank(existing.getMaterialName())) {
|
||||
existing.setMaterialName(specCode);
|
||||
}
|
||||
existing.setUseStatus(existing.getUseStatus() == null ? 1 : existing.getUseStatus());
|
||||
if (StringUtils.isBlank(existing.getAliasName()) && StringUtils.isNotBlank(rubberName)) {
|
||||
existing.setAliasName(rubberName);
|
||||
}
|
||||
existing.setEnableFlag(existing.getEnableFlag() == null ? 1 : existing.getEnableFlag());
|
||||
existing.setUpdateTime(now);
|
||||
mesMixerMaterialService.updateById(existing);
|
||||
mesMaterialService.updateById(existing);
|
||||
log.info(
|
||||
"[混炼示方生成] 更新密炼物料 id={}, code={}, major={}, minor={}, sg={}",
|
||||
"[混炼示方生成] 更新胶料信息 id={}, code={}, categoryId={}, isFinal={}",
|
||||
existing.getId(),
|
||||
specCode,
|
||||
majorCode,
|
||||
minorCode,
|
||||
specificGravity);
|
||||
categoryId,
|
||||
isFinalStage);
|
||||
return;
|
||||
}
|
||||
|
||||
MesMixerMaterial material = new MesMixerMaterial();
|
||||
MesMaterial material = new MesMaterial();
|
||||
material.setMaterialCode(specCode);
|
||||
material.setMaterialName(specCode);
|
||||
material.setMaterialDesc(materialDesc);
|
||||
material.setAliasName(StringUtils.isNotBlank(rubberName) ? rubberName : null);
|
||||
material.setMajorCategoryId(majorCategoryId);
|
||||
material.setMinorCategoryId(minorCategoryId);
|
||||
material.setSpecificGravity(specificGravity);
|
||||
material.setFeedManageStatus(0);
|
||||
material.setUseStatus(1);
|
||||
material.setCategoryId(categoryId);
|
||||
material.setEnableFlag(1);
|
||||
material.setIsSpecialRubber(0);
|
||||
material.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
material.setCreateTime(now);
|
||||
material.setUpdateTime(now);
|
||||
mesMixerMaterialService.save(material);
|
||||
mesMaterialService.save(material);
|
||||
log.info(
|
||||
"[混炼示方生成] 新增密炼物料 id={}, code={}, major={}, minor={}, sg={}",
|
||||
"[混炼示方生成] 新增胶料信息 id={}, code={}, categoryId={}, isFinal={}",
|
||||
material.getId(),
|
||||
specCode,
|
||||
majorCode,
|
||||
minorCode,
|
||||
specificGravity);
|
||||
categoryId,
|
||||
isFinalStage);
|
||||
}
|
||||
|
||||
private MesMixerMaterial findMixerMaterialByCodeOrName(String specCode) {
|
||||
MesMixerMaterial byCode = mesMixerMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMixerMaterial>()
|
||||
.eq(MesMixerMaterial::getMaterialCode, specCode)
|
||||
.and(w -> w.eq(MesMixerMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMixerMaterial::getDelFlag))
|
||||
/** 生成的 B/F 段胶料类别:取配合示方所选「胶料代号」对应胶料(mes_material)的类别 */
|
||||
private String resolveGeneratedRubberCategoryId(MesXslFormulaSpec formula) {
|
||||
if (formula == null || StringUtils.isBlank(formula.getRubberMaterialId())) {
|
||||
return null;
|
||||
}
|
||||
MesMaterial rubber = mesMaterialService.getById(formula.getRubberMaterialId());
|
||||
return rubber != null ? rubber.getCategoryId() : null;
|
||||
}
|
||||
|
||||
private MesMaterial findRubberMaterialByCodeOrName(String specCode) {
|
||||
if (StringUtils.isBlank(specCode)) {
|
||||
return null;
|
||||
}
|
||||
MesMaterial byCode = mesMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialCode, specCode)
|
||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
||||
.last("limit 1"));
|
||||
if (byCode != null) {
|
||||
return byCode;
|
||||
}
|
||||
return mesMixerMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMixerMaterial>()
|
||||
.eq(MesMixerMaterial::getMaterialName, specCode)
|
||||
.and(w -> w.eq(MesMixerMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMixerMaterial::getDelFlag))
|
||||
return mesMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialName, specCode)
|
||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
private String resolveCategoryIdByCode(String categoryCode, Map<String, String> cache) {
|
||||
if (StringUtils.isBlank(categoryCode)) {
|
||||
return null;
|
||||
}
|
||||
if (cache != null && cache.containsKey(categoryCode)) {
|
||||
return cache.get(categoryCode);
|
||||
}
|
||||
SysCategory category = sysCategoryService.getOne(
|
||||
new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, categoryCode.trim()).last("limit 1"));
|
||||
String categoryId = category != null ? category.getId() : null;
|
||||
if (cache != null) {
|
||||
cache.put(categoryCode, categoryId);
|
||||
}
|
||||
return categoryId;
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A48】生成混炼示方同步B/F段胶至密炼物料-----------
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】生成混炼示方改为同步B/F段胶至胶料信息-----------
|
||||
|
||||
private int normalizeMixingStages(Integer mixingStages) {
|
||||
if (mixingStages == null || mixingStages <= 0) {
|
||||
@@ -1129,39 +1104,40 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
Map<String, MesMixerMaterial> mixerCache,
|
||||
Map<String, String> categoryNameCache,
|
||||
MesXslMixerMaterialKindLookupVO kindLookup) {
|
||||
ensureMotherRubberMixerMaterialSynced(motherSpecCode, formula, compoundSpecificGravity, categoryIdCache);
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】上一段母胶明细行改绑胶料信息-----------
|
||||
ensureMotherRubberMaterialSynced(motherSpecCode, formula, categoryIdCache);
|
||||
MesXslMixingSpecMaterial material = new MesXslMixingSpecMaterial();
|
||||
material.setSortNo(sortNo);
|
||||
material.setUnitWeight(unitWeight);
|
||||
MesMixerMaterial mixer = findMixerMaterialByCodeOrName(motherSpecCode.trim());
|
||||
if (mixer != null) {
|
||||
fillMixingMaterialFromMixerMaterial(material, mixer, null, mixerCache, categoryNameCache, kindLookup);
|
||||
MesMaterial rubber = findRubberMaterialByCodeOrName(motherSpecCode.trim());
|
||||
if (rubber != null) {
|
||||
fillMixingMaterialFromRubberMaterial(material, rubber, categoryNameCache, kindLookup);
|
||||
return material;
|
||||
}
|
||||
log.warn("[混炼示方生成] 未找到上一段密炼物料 {},明细行回退为示方编号展示", motherSpecCode);
|
||||
log.warn("[混炼示方生成] 未找到上一段胶料信息 {},明细行回退为示方编号展示", motherSpecCode);
|
||||
material.setMixerMaterialName(motherSpecCode);
|
||||
material.setMixerMaterialDesc(motherSpecCode);
|
||||
fillMotherRubberCategoryFallback(material, categoryIdCache, categoryNameCache, kindLookup);
|
||||
fillMotherRubberCategoryFallback(material, formula, categoryNameCache, kindLookup);
|
||||
return material;
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】上一段母胶明细行改绑胶料信息-----------
|
||||
}
|
||||
|
||||
/** 上一段 B 段胶尚未写入主数据时,按母炼胶/A胶分类补建一条密炼物料 */
|
||||
private void ensureMotherRubberMixerMaterialSynced(
|
||||
/** 上一段 B 段胶尚未写入胶料信息时,按配合示方胶料类别补建一条胶料信息 */
|
||||
private void ensureMotherRubberMaterialSynced(
|
||||
String motherSpecCode,
|
||||
MesXslFormulaSpec formula,
|
||||
BigDecimal compoundSpecificGravity,
|
||||
Map<String, String> categoryIdCache) {
|
||||
if (StringUtils.isBlank(motherSpecCode)) {
|
||||
return;
|
||||
}
|
||||
String normalized = motherSpecCode.trim();
|
||||
if (findMixerMaterialByCodeOrName(normalized) != null) {
|
||||
if (findRubberMaterialByCodeOrName(normalized) != null) {
|
||||
return;
|
||||
}
|
||||
MesXslFormulaMixingGenerateRowVO stub = new MesXslFormulaMixingGenerateRowVO();
|
||||
stub.setSpecCode(normalized);
|
||||
stub.setStepType("A");
|
||||
syncGeneratedRubberMixerMaterial(stub, formula, compoundSpecificGravity, categoryIdCache);
|
||||
syncGeneratedRubberMixerMaterial(stub, formula, null, categoryIdCache);
|
||||
}
|
||||
|
||||
/** 按密炼物料主数据回填混炼示方明细行(名称/大小类/种类) */
|
||||
@@ -1195,20 +1171,44 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
||||
}
|
||||
}
|
||||
|
||||
/** 未查到密炼物料时,按母炼胶/A胶分类从配置表解析种类 */
|
||||
private void fillMotherRubberCategoryFallback(
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】母胶明细行按胶料信息回填-----------
|
||||
/** 按胶料信息主数据回填混炼示方明细行(名称/类别/种类) */
|
||||
private void fillMixingMaterialFromRubberMaterial(
|
||||
MesXslMixingSpecMaterial material,
|
||||
Map<String, String> categoryIdCache,
|
||||
MesMaterial rubber,
|
||||
Map<String, String> categoryNameCache,
|
||||
MesXslMixerMaterialKindLookupVO kindLookup) {
|
||||
String majorCategoryId = resolveCategoryIdByCode(CATEGORY_MASTER_MAJOR, categoryIdCache);
|
||||
String minorCategoryId = resolveCategoryIdByCode(CATEGORY_MASTER_MINOR_A, categoryIdCache);
|
||||
material.setMaterialMajor(resolveCategoryName(majorCategoryId, categoryNameCache));
|
||||
material.setMaterialMinor(resolveCategoryName(minorCategoryId, categoryNameCache));
|
||||
if (material == null || rubber == null) {
|
||||
return;
|
||||
}
|
||||
String displayName =
|
||||
StringUtils.isNotBlank(rubber.getMaterialName()) ? rubber.getMaterialName() : rubber.getMaterialCode();
|
||||
material.setMixerMaterialName(displayName);
|
||||
material.setMixerMaterialDesc(displayName);
|
||||
String categoryName = resolveCategoryName(rubber.getCategoryId(), categoryNameCache);
|
||||
material.setMaterialMajor(null);
|
||||
material.setMaterialMinor(categoryName);
|
||||
material.setMixerMaterialId(rubber.getId());
|
||||
material.setMaterialKind(
|
||||
mesXslMixerMaterialKindCfgService.resolveMixingMaterialKind(
|
||||
kindLookup, minorCategoryId, null, material.getMaterialMinor()));
|
||||
kindLookup, rubber.getCategoryId(), null, categoryName));
|
||||
}
|
||||
|
||||
/** 未查到胶料信息时,按配合示方胶料类别从配置表解析种类 */
|
||||
private void fillMotherRubberCategoryFallback(
|
||||
MesXslMixingSpecMaterial material,
|
||||
MesXslFormulaSpec formula,
|
||||
Map<String, String> categoryNameCache,
|
||||
MesXslMixerMaterialKindLookupVO kindLookup) {
|
||||
String categoryId = resolveGeneratedRubberCategoryId(formula);
|
||||
String categoryName = resolveCategoryName(categoryId, categoryNameCache);
|
||||
material.setMaterialMajor(null);
|
||||
material.setMaterialMinor(categoryName);
|
||||
material.setMaterialKind(
|
||||
mesXslMixerMaterialKindCfgService.resolveMixingMaterialKind(
|
||||
kindLookup, categoryId, null, categoryName));
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】母胶明细行按胶料信息回填-----------
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A54】母炼胶明细行绑定已同步密炼物料主数据-----------
|
||||
|
||||
/** 混合段累计合计:优先主表 stageNTotal,否则按明细该列求和 */
|
||||
|
||||
@@ -290,6 +290,9 @@ public class MesXslMixerMaterialKindCfgServiceImpl
|
||||
MesXslMixerMaterialKindLookupVO lookup = new MesXslMixerMaterialKindLookupVO();
|
||||
Map<String, String> byRefId = new LinkedHashMap<>();
|
||||
Map<String, String> byRefCode = new LinkedHashMap<>();
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
Map<String, String> byRefName = new LinkedHashMap<>();
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
String rubberKindName = null;
|
||||
if (rows != null) {
|
||||
for (MesXslMixerMaterialKindCfg row : rows) {
|
||||
@@ -310,6 +313,14 @@ public class MesXslMixerMaterialKindCfgServiceImpl
|
||||
byRefCode.put(lowerCode, kindName);
|
||||
}
|
||||
}
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
if (oConvertUtils.isNotEmpty(row.getCategoryRefName())) {
|
||||
String refName = row.getCategoryRefName().trim();
|
||||
if (!byRefName.containsKey(refName)) {
|
||||
byRefName.put(refName, kindName);
|
||||
}
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
if (rubberKindName == null && DEFAULT_RUBBER_KIND_NAME.equals(kindName)) {
|
||||
rubberKindName = kindName;
|
||||
}
|
||||
@@ -317,6 +328,9 @@ public class MesXslMixerMaterialKindCfgServiceImpl
|
||||
}
|
||||
lookup.setByRefId(byRefId);
|
||||
lookup.setByRefCode(byRefCode);
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
lookup.setByRefName(byRefName);
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
lookup.setRubberKindName(oConvertUtils.isNotEmpty(rubberKindName) ? rubberKindName : DEFAULT_RUBBER_KIND_NAME);
|
||||
return lookup;
|
||||
}
|
||||
@@ -342,6 +356,17 @@ public class MesXslMixerMaterialKindCfgServiceImpl
|
||||
return fromMinor;
|
||||
}
|
||||
}
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类解析支持胶料类别名称-----------
|
||||
if (oConvertUtils.isNotEmpty(minorCategoryName)) {
|
||||
Map<String, String> byRefName = lookup.getByRefName();
|
||||
if (byRefName != null) {
|
||||
String fromName = byRefName.get(minorCategoryName.trim());
|
||||
if (oConvertUtils.isNotEmpty(fromName)) {
|
||||
return fromName;
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类解析支持胶料类别名称-----------
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A53】种类未命中配置时不回退小类名-----------
|
||||
return null;
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A53】种类未命中配置时不回退小类名-----------
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,10 +22,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
|
||||
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||
import org.jeecg.modules.mes.material.service.IMesMaterialService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpec;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpecDownStep;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpecMaterial;
|
||||
@@ -53,13 +50,9 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
|
||||
private static final String TCU_UP = "up_mixer";
|
||||
private static final String TCU_DOWN = "down_mixer";
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A49】删除混炼示方时同步删除B/F段胶密炼物料-----------
|
||||
private static final String CATEGORY_MASTER_MAJOR = "XSLMES_MATERIAL_MASTER";
|
||||
private static final String CATEGORY_MASTER_MINOR_A = "XSLMES_MATERIAL_MASTER_A";
|
||||
private static final String CATEGORY_FINAL_MAJOR = "XSLMES_MATERIAL_FINAL";
|
||||
private static final String CATEGORY_FINAL_MINOR_Q = "XSLMES_MATERIAL_FINAL_Q";
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除混炼示方时同步删除自动生成的B/F段胶料信息-----------
|
||||
private static final Pattern GENERATED_B_RUBBER_SPEC_PATTERN = Pattern.compile("^B\\d", Pattern.CASE_INSENSITIVE);
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A49】删除混炼示方时同步删除B/F段胶密炼物料-----------
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除混炼示方时同步删除自动生成的B/F段胶料信息-----------
|
||||
|
||||
@Resource
|
||||
private MesXslMixingSpecMaterialMapper materialMapper;
|
||||
@@ -70,11 +63,10 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
@Resource
|
||||
private MesXslMixingSpecTcuMapper tcuMapper;
|
||||
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除联动改为针对胶料信息-----------
|
||||
@Resource
|
||||
private IMesMixerMaterialService mesMixerMaterialService;
|
||||
|
||||
@Resource
|
||||
private ISysCategoryService sysCategoryService;
|
||||
private IMesMaterialService mesMaterialService;
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除联动改为针对胶料信息-----------
|
||||
|
||||
@Resource
|
||||
private IMesXslFormulaSpecEditLogService mesXslFormulaSpecEditLogService;
|
||||
@@ -684,9 +676,10 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
return rows;
|
||||
}
|
||||
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A49】删除混炼示方时同步删除B/F段胶密炼物料-----------
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除混炼示方时同步删除自动生成的B/F段胶料信息-----------
|
||||
/**
|
||||
* 删除混炼示方后,若该示方编号已无其它混炼示方且未被其它示方明细引用,则同步删除生成时写入的 B/F 段胶密炼物料。
|
||||
* 删除混炼示方后,若该 B/F 段胶示方编号已无其它混炼示方、未被其它示方明细引用、且未被配合示方选作胶料代号,
|
||||
* 则同步删除生成时写入的「胶料信息」(mes_material)。仅处理 F 段或 B+数字 形态的自动生成编号,避免误删人工维护胶料。
|
||||
*/
|
||||
private void syncDeleteGeneratedRubberMixerMaterial(String specName) {
|
||||
if (StringUtils.isBlank(specName)) {
|
||||
@@ -700,41 +693,33 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
long remainingSpecCount =
|
||||
this.count(new LambdaQueryWrapper<MesXslMixingSpec>().eq(MesXslMixingSpec::getSpecName, specCode));
|
||||
if (remainingSpecCount > 0) {
|
||||
log.debug("[混炼示方删除] 示方编号 {} 仍有 {} 条混炼示方,跳过密炼物料同步删除", specCode, remainingSpecCount);
|
||||
log.debug("[混炼示方删除] 示方编号 {} 仍有 {} 条混炼示方,跳过胶料信息同步删除", specCode, remainingSpecCount);
|
||||
return;
|
||||
}
|
||||
long referencedCount = countMaterialReference(specCode, null);
|
||||
if (referencedCount > 0) {
|
||||
log.info(
|
||||
"[混炼示方删除] 示方编号 {} 仍被 {} 条混炼示方明细引用,跳过密炼物料同步删除",
|
||||
"[混炼示方删除] 示方编号 {} 仍被 {} 条混炼示方明细引用,跳过胶料信息同步删除",
|
||||
specCode,
|
||||
referencedCount);
|
||||
return;
|
||||
}
|
||||
MesMixerMaterial material = findMixerMaterialByCodeOrName(specCode);
|
||||
MesMaterial material = findRubberMaterialByCodeOrName(specCode);
|
||||
if (material == null) {
|
||||
log.debug("[混炼示方删除] 未找到示方编号 {} 对应密炼物料,跳过同步删除", specCode);
|
||||
log.debug("[混炼示方删除] 未找到示方编号 {} 对应胶料信息,跳过同步删除", specCode);
|
||||
return;
|
||||
}
|
||||
referencedCount = countMaterialReference(specCode, material.getId());
|
||||
if (referencedCount > 0) {
|
||||
log.info(
|
||||
"[混炼示方删除] 密炼物料 id={}, code={} 仍被 {} 条混炼示方明细引用,跳过同步删除",
|
||||
"[混炼示方删除] 胶料信息 id={}, code={} 仍被 {} 条混炼示方明细引用,跳过同步删除",
|
||||
material.getId(),
|
||||
specCode,
|
||||
referencedCount);
|
||||
return;
|
||||
}
|
||||
Map<String, String> categoryIdCache = new HashMap<>();
|
||||
if (!isGeneratedRubberMixerMaterial(material, isFinalStage, categoryIdCache)) {
|
||||
log.info(
|
||||
"[混炼示方删除] 密炼物料 id={}, code={} 分类非生成示方自动同步类型,跳过删除",
|
||||
material.getId(),
|
||||
specCode);
|
||||
return;
|
||||
}
|
||||
mesMixerMaterialService.removeById(material.getId());
|
||||
log.info("[混炼示方删除] 同步删除密炼物料 id={}, code={}", material.getId(), specCode);
|
||||
mesMaterialService.removeById(material.getId());
|
||||
log.info("[混炼示方删除] 同步删除胶料信息 id={}, code={}", material.getId(), specCode);
|
||||
}
|
||||
|
||||
/** 判断是否为生成混炼示方时自动同步的 B/F 段胶示方编号;true=F段,false=B段,null=非自动生成胶料编号 */
|
||||
@@ -752,38 +737,26 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
return null;
|
||||
}
|
||||
|
||||
private MesMixerMaterial findMixerMaterialByCodeOrName(String specCode) {
|
||||
MesMixerMaterial byCode = mesMixerMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMixerMaterial>()
|
||||
.eq(MesMixerMaterial::getMaterialCode, specCode)
|
||||
.and(w -> w.eq(MesMixerMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMixerMaterial::getDelFlag))
|
||||
private MesMaterial findRubberMaterialByCodeOrName(String specCode) {
|
||||
if (StringUtils.isBlank(specCode)) {
|
||||
return null;
|
||||
}
|
||||
MesMaterial byCode = mesMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialCode, specCode)
|
||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
||||
.last("limit 1"));
|
||||
if (byCode != null) {
|
||||
return byCode;
|
||||
}
|
||||
return mesMixerMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMixerMaterial>()
|
||||
.eq(MesMixerMaterial::getMaterialName, specCode)
|
||||
.and(w -> w.eq(MesMixerMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMixerMaterial::getDelFlag))
|
||||
return mesMaterialService.getOne(
|
||||
new LambdaQueryWrapper<MesMaterial>()
|
||||
.eq(MesMaterial::getMaterialName, specCode)
|
||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
private boolean isGeneratedRubberMixerMaterial(
|
||||
MesMixerMaterial material, boolean isFinalStage, Map<String, String> categoryIdCache) {
|
||||
if (material == null) {
|
||||
return false;
|
||||
}
|
||||
String majorCode = isFinalStage ? CATEGORY_FINAL_MAJOR : CATEGORY_MASTER_MAJOR;
|
||||
String minorCode = isFinalStage ? CATEGORY_FINAL_MINOR_Q : CATEGORY_MASTER_MINOR_A;
|
||||
String expectedMajorId = resolveCategoryIdByCode(majorCode, categoryIdCache);
|
||||
String expectedMinorId = resolveCategoryIdByCode(minorCode, categoryIdCache);
|
||||
if (StringUtils.isBlank(expectedMajorId) || StringUtils.isBlank(expectedMinorId)) {
|
||||
return false;
|
||||
}
|
||||
return expectedMajorId.equals(material.getMajorCategoryId()) && expectedMinorId.equals(material.getMinorCategoryId());
|
||||
}
|
||||
|
||||
/** 统计混炼示方明细对某示方编号/密炼物料 ID 的引用次数 */
|
||||
/** 统计混炼示方明细对某示方编号/胶料信息 ID 的引用次数 */
|
||||
private long countMaterialReference(String specCode, String mixerMaterialId) {
|
||||
LambdaQueryWrapper<MesXslMixingSpecMaterial> qw = new LambdaQueryWrapper<>();
|
||||
qw.and(wrapper -> {
|
||||
@@ -794,23 +767,7 @@ public class MesXslMixingSpecServiceImpl extends ServiceImpl<MesXslMixingSpecMap
|
||||
});
|
||||
return materialMapper.selectCount(qw);
|
||||
}
|
||||
|
||||
private String resolveCategoryIdByCode(String categoryCode, Map<String, String> cache) {
|
||||
if (StringUtils.isBlank(categoryCode)) {
|
||||
return null;
|
||||
}
|
||||
if (cache != null && cache.containsKey(categoryCode)) {
|
||||
return cache.get(categoryCode);
|
||||
}
|
||||
SysCategory category = sysCategoryService.getOne(
|
||||
new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, categoryCode.trim()).last("limit 1"));
|
||||
String categoryId = category != null ? category.getId() : null;
|
||||
if (cache != null) {
|
||||
cache.put(categoryCode, categoryId);
|
||||
}
|
||||
return categoryId;
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A49】删除混炼示方时同步删除B/F段胶密炼物料-----------
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】删除混炼示方时同步删除自动生成的B/F段胶料信息-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A61】混炼示方密炼PS审批联动同步审批人-----------
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,11 @@ public class MesXslMixerMaterialKindLookupVO implements Serializable {
|
||||
@Schema(description = "对应分类/字典项编码 -> 种类名称")
|
||||
private Map<String, String> byRefCode = new LinkedHashMap<>();
|
||||
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
@Schema(description = "对应分类名称 -> 种类名称(胶料信息 categoryId_dictText)")
|
||||
private Map<String, String> byRefName = new LinkedHashMap<>();
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持按胶料类别名称匹配-----------
|
||||
|
||||
@Schema(description = "胶料种类名称(母炼胶行兜底)")
|
||||
private String rubberKindName;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ spring:
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://xsl.qdxsl.top:50768/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# url: jdbc:mysql://10.30.1.60:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# url: jdbc:mysql://localhost:3307/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
Reference in New Issue
Block a user