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
|
||||
|
||||
@@ -17,8 +17,10 @@ export const MIXING_MATERIAL_ROW_NUMBER_WIDTH = 60;
|
||||
/** 橡胶及配合剂明细列可缩小到的最小宽度 */
|
||||
export const MIXING_MATERIAL_MIN_COLUMN_WIDTH = 40;
|
||||
|
||||
/** 默认隐藏的明细列 */
|
||||
export const MIXING_MATERIAL_DEFAULT_HIDDEN_COLUMN_KEYS = ['materialMajor', 'materialKind'];
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】橡胶及配合剂明细默认展示种类列-----------
|
||||
/** 默认隐藏的明细列(种类列默认展示,物料小类默认隐藏) */
|
||||
export const MIXING_MATERIAL_DEFAULT_HIDDEN_COLUMN_KEYS = ['materialMajor', 'materialMinor'];
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】橡胶及配合剂明细默认展示种类列-----------
|
||||
|
||||
/** 不允许隐藏的明细列 */
|
||||
export const MIXING_MATERIAL_LOCKED_COLUMN_KEYS = ['mixerMaterialName'];
|
||||
@@ -92,8 +94,17 @@ export const materialColumns: JVxeColumn[] = [
|
||||
{ title: '密炼物料ID', key: 'mixerMaterialId', type: JVxeTypes.hidden },
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A55】混炼示方明细关联密炼物料ID-----------
|
||||
{ title: '物料大类', key: 'materialMajor', type: JVxeTypes.input, width: 100, minWidth: MIXING_MATERIAL_MIN_COLUMN_WIDTH },
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类列置于首列展示且只读-----------
|
||||
{
|
||||
title: '种类',
|
||||
key: 'materialKind',
|
||||
type: JVxeTypes.input,
|
||||
width: 100,
|
||||
minWidth: MIXING_MATERIAL_MIN_COLUMN_WIDTH,
|
||||
disabled: true,
|
||||
},
|
||||
{ title: '物料小类', key: 'materialMinor', type: JVxeTypes.input, width: 120, minWidth: MIXING_MATERIAL_MIN_COLUMN_WIDTH },
|
||||
{ title: '种类', key: 'materialKind', type: JVxeTypes.input, width: 80, minWidth: MIXING_MATERIAL_MIN_COLUMN_WIDTH },
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类列置于首列展示且只读-----------
|
||||
{
|
||||
title: '密炼物料名称',
|
||||
key: 'mixerMaterialName',
|
||||
@@ -134,9 +145,16 @@ export function loadMixingMaterialHiddenColumnKeys(): string[] {
|
||||
if (!Array.isArray(saved)) {
|
||||
return MIXING_MATERIAL_DEFAULT_HIDDEN_COLUMN_KEYS.filter((key) => validKeys.has(key));
|
||||
}
|
||||
return saved.filter(
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】迁移列显示偏好:原隐藏种类改为隐藏物料小类-----------
|
||||
let keys = saved.filter(
|
||||
(key) => typeof key === 'string' && !MIXING_MATERIAL_LOCKED_COLUMN_KEYS.includes(key) && validKeys.has(key),
|
||||
);
|
||||
if (keys.includes('materialKind') && !keys.includes('materialMinor')) {
|
||||
keys = keys.filter((key) => key !== 'materialKind');
|
||||
keys.push('materialMinor');
|
||||
}
|
||||
return keys;
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】迁移列显示偏好:原隐藏种类改为隐藏物料小类-----------
|
||||
}
|
||||
|
||||
/** 保存已隐藏的橡胶及配合剂明细列 key */
|
||||
@@ -1047,12 +1065,16 @@ export function sanitizeMixingMaterialPickerHiddenCategoryIds(allMinorIds: strin
|
||||
export interface MixerMaterialKindLookup {
|
||||
byRefId: Record<string, string>;
|
||||
byRefCode: Record<string, string>;
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持胶料类别名称-----------
|
||||
byRefName?: Record<string, string>;
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】种类查找表支持胶料类别名称-----------
|
||||
rubberKindName?: string;
|
||||
}
|
||||
|
||||
export const EMPTY_MIXER_MATERIAL_KIND_LOOKUP: MixerMaterialKindLookup = {
|
||||
byRefId: {},
|
||||
byRefCode: {},
|
||||
byRefName: {},
|
||||
rubberKindName: '胶料',
|
||||
};
|
||||
|
||||
@@ -1074,6 +1096,9 @@ export async function loadMixingMaterialKindLookup(forceReload = false): Promise
|
||||
const lookup: MixerMaterialKindLookup = {
|
||||
byRefId: raw?.byRefId || {},
|
||||
byRefCode: raw?.byRefCode || {},
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】加载种类配置含类别名称映射-----------
|
||||
byRefName: raw?.byRefName || {},
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】加载种类配置含类别名称映射-----------
|
||||
rubberKindName: raw?.rubberKindName || '胶料',
|
||||
};
|
||||
mixingMaterialKindLookupCache = lookup;
|
||||
@@ -1116,12 +1141,12 @@ function matchKindFromLookup(lookup: MixerMaterialKindLookup | null | undefined,
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 解析混炼示方明细种类:称量方式优先,其次物料小类 ID(未命中返回空,由配置表维护) */
|
||||
/** 解析混炼示方明细种类:称量方式优先,其次分类 ID,再按分类名称(未命中返回空) */
|
||||
export function resolveMixingMaterialKindFromLookup(
|
||||
lookup: MixerMaterialKindLookup | null | undefined,
|
||||
weighMode?: string,
|
||||
minorCategoryId?: string,
|
||||
_minorCategoryName?: string,
|
||||
minorCategoryName?: string,
|
||||
) {
|
||||
const fromWeighMode = matchKindFromLookup(lookup, weighMode);
|
||||
if (fromWeighMode) {
|
||||
@@ -1131,9 +1156,35 @@ export function resolveMixingMaterialKindFromLookup(
|
||||
if (fromMinorId) {
|
||||
return fromMinorId;
|
||||
}
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】按胶料类别名称匹配种类配置-----------
|
||||
if (minorCategoryName != null && String(minorCategoryName).trim() !== '') {
|
||||
const refName = String(minorCategoryName).trim();
|
||||
if (lookup?.byRefName?.[refName]) {
|
||||
return lookup.byRefName[refName];
|
||||
}
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】按胶料类别名称匹配种类配置-----------
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 胶料页签解析种类:配置匹配后可用 rubberKindName(如「胶料」)兜底 */
|
||||
export function resolveMixingRubberKindForPicker(
|
||||
lookup: MixerMaterialKindLookup | null | undefined,
|
||||
weighMode?: string,
|
||||
categoryId?: string,
|
||||
categoryName?: string,
|
||||
categoryCode?: string,
|
||||
) {
|
||||
let kind = resolveMixingMaterialKindFromLookup(lookup, weighMode, categoryId, categoryName);
|
||||
if (!kind && categoryCode) {
|
||||
kind = matchKindFromLookup(lookup, categoryCode);
|
||||
}
|
||||
if (!kind && lookup?.rubberKindName) {
|
||||
kind = lookup.rubberKindName;
|
||||
}
|
||||
return kind;
|
||||
}
|
||||
|
||||
/** @deprecated 保留兼容,请改用 resolveMixingMaterialKindFromLookup */
|
||||
export function resolveMixingMaterialKindFromCategory(_isRubber?: unknown, minorName?: string) {
|
||||
return minorName != null && String(minorName).trim() !== '' ? String(minorName).trim() : '';
|
||||
@@ -1189,6 +1240,33 @@ export function applyMixingMaterialFromSelection(row: Recordable, material: Reco
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A50】混炼示方密炼物料选料弹窗与种类解析-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗新增胶料页签(查询胶料信息)-----------
|
||||
/** 选料弹窗「胶料」页签表格列(数据源为胶料信息 mes_material) */
|
||||
export const mixingRubberPickerTableColumns: BasicColumn[] = [
|
||||
{ title: '胶料编码', align: 'center', width: 140, dataIndex: 'materialCode' },
|
||||
{ title: '胶料名称', align: 'center', width: 180, dataIndex: 'materialName' },
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签补齐自动/人工称量列-----------
|
||||
{ title: '自动/人工称量', align: 'center', width: 132, dataIndex: 'pickerWeighMode' },
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签补齐自动/人工称量列-----------
|
||||
{ title: '种类', align: 'center', width: 100, dataIndex: 'pickerMaterialKind' },
|
||||
{ title: '胶料类别', align: 'center', width: 140, dataIndex: 'categoryId_dictText' },
|
||||
{ title: '胶料别名', align: 'center', width: 140, dataIndex: 'aliasName' },
|
||||
];
|
||||
|
||||
/** 选择胶料信息后回填混炼示方橡胶及配合剂明细行(复用 mixerMaterialId 存 mes_material.id) */
|
||||
export function applyMixingRubberFromSelection(row: Recordable, material: Recordable, materialKind: string) {
|
||||
if (!row || !material) {
|
||||
return;
|
||||
}
|
||||
row.mixerMaterialId = material.id || '';
|
||||
row.mixerMaterialName = material.materialName || material.materialCode || '';
|
||||
row.mixerMaterialDesc = material.materialName || material.materialCode || '';
|
||||
row.materialMajor = '';
|
||||
row.materialMinor = material.categoryId_dictText || '';
|
||||
row.materialKind = materialKind != null && String(materialKind).trim() !== '' ? String(materialKind).trim() : '';
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗新增胶料页签(查询胶料信息)-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
/** 混合步骤可复制的业务字段 */
|
||||
export const MIXING_STEP_COPY_FIELD_KEYS = [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
title="选择密炼物料"
|
||||
title="选择物料"
|
||||
:width="1280"
|
||||
:zIndex="1500"
|
||||
wrapClassName="mixing-material-picker-modal-wrap"
|
||||
@@ -13,12 +13,14 @@
|
||||
<a-input
|
||||
v-model:value="keyword"
|
||||
allow-clear
|
||||
placeholder="关键字(物料编码/名称/描述)"
|
||||
placeholder="关键字(编码/名称/描述)"
|
||||
style="width: 280px"
|
||||
@pressEnter="reloadTable"
|
||||
/>
|
||||
<a-button type="primary" @click="reloadTable">搜索</a-button>
|
||||
<!--update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】仅密炼物料页签展示小类设置------------->
|
||||
<MesXslMixingMaterialCategorySetting
|
||||
v-if="pickerType === 'mixer'"
|
||||
v-model:hiddenCategoryIds="hiddenCategoryIds"
|
||||
:categories="allMinorCategories"
|
||||
:loading="treeLoading"
|
||||
@@ -26,20 +28,42 @@
|
||||
@change="handleCategoryVisibilityChange"
|
||||
@refresh="handleRefreshCategoryTree"
|
||||
/>
|
||||
<!--update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】仅密炼物料页签展示小类设置------------->
|
||||
</div>
|
||||
<div class="mixing-material-picker-body">
|
||||
<aside class="mixing-material-picker-sider">
|
||||
<div class="mixing-material-picker-sider-title">物料小类</div>
|
||||
<Spin :spinning="treeLoading">
|
||||
<BasicTree
|
||||
:treeData="visibleCategoryTree"
|
||||
:selectedKeys="selectedCategoryKeys"
|
||||
:expandedKeys="expandedCategoryKeys"
|
||||
defaultExpandLevel="2"
|
||||
@update:selectedKeys="onCategorySelect"
|
||||
@update:expandedKeys="onExpandedKeysChange"
|
||||
/>
|
||||
</Spin>
|
||||
<!--update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗左侧密炼物料/胶料页签------------->
|
||||
<a-radio-group v-model:value="pickerType" button-style="solid" size="small" class="mixing-material-picker-tabs" @change="handleSwitchPickerType">
|
||||
<a-radio-button value="mixer">密炼物料</a-radio-button>
|
||||
<a-radio-button value="rubber">胶料</a-radio-button>
|
||||
</a-radio-group>
|
||||
<template v-if="pickerType === 'mixer'">
|
||||
<div class="mixing-material-picker-sider-title">物料小类</div>
|
||||
<Spin :spinning="treeLoading">
|
||||
<BasicTree
|
||||
:treeData="visibleCategoryTree"
|
||||
:selectedKeys="selectedCategoryKeys"
|
||||
:expandedKeys="expandedCategoryKeys"
|
||||
defaultExpandLevel="2"
|
||||
@update:selectedKeys="onCategorySelect"
|
||||
@update:expandedKeys="onExpandedKeysChange"
|
||||
/>
|
||||
</Spin>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="mixing-material-picker-sider-title">胶料类别</div>
|
||||
<Spin :spinning="rubberTreeLoading">
|
||||
<BasicTree
|
||||
:treeData="visibleRubberTree"
|
||||
:selectedKeys="selectedRubberCategoryKeys"
|
||||
:expandedKeys="expandedRubberCategoryKeys"
|
||||
defaultExpandLevel="2"
|
||||
@update:selectedKeys="onRubberCategorySelect"
|
||||
@update:expandedKeys="onRubberExpandedKeysChange"
|
||||
/>
|
||||
</Spin>
|
||||
</template>
|
||||
<!--update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗左侧密炼物料/胶料页签------------->
|
||||
</aside>
|
||||
<div class="mixing-material-picker-main">
|
||||
<BasicTable @register="registerTable">
|
||||
@@ -77,11 +101,20 @@
|
||||
import { BasicTree } from '/@/components/Tree';
|
||||
import { loadMesMaterialCategoryTreeData, hasMesMaterialCategoryTreeCache } from '/@/views/system/category/category.constants';
|
||||
import { list as mixerList, queryById as queryMixerById } from '/@/views/mes/material/MesMixerMaterial.api';
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签查询胶料信息(mes_material)------------->
|
||||
import { list as rubberList, queryById as queryRubberById } from '/@/views/mes/material/MesMaterial.api';
|
||||
import { loadTreeData } from '/@/api/common/api';
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签查询胶料信息(mes_material)------------->
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import MesXslMixingMaterialCategorySetting from './MesXslMixingMaterialCategorySetting.vue';
|
||||
import {
|
||||
applyMixingMaterialFromSelection,
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】引入胶料页签列与回填------------->
|
||||
applyMixingRubberFromSelection,
|
||||
mixingRubberPickerTableColumns,
|
||||
resolveMixingRubberKindForPicker,
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】引入胶料页签列与回填------------->
|
||||
EMPTY_MIXER_MATERIAL_KIND_LOOKUP,
|
||||
loadMixingMaterialKindLookup,
|
||||
loadMixingMaterialPickerHiddenCategoryIds,
|
||||
@@ -96,6 +129,34 @@
|
||||
import type { KeyType } from '/@/components/Tree/src/types/tree';
|
||||
|
||||
const TREE_ALL = 'ALL';
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗数据源类型与胶料类别树------------->
|
||||
const RUBBER_TREE_ALL = 'ALL';
|
||||
const RUBBER_CATEGORY_PCODE = 'XSLMES_RUBBER';
|
||||
const pickerType = ref<'mixer' | 'rubber'>('mixer');
|
||||
const rubberTreeLoading = ref(false);
|
||||
const rubberCategoryTree = ref<Recordable[]>([]);
|
||||
/** 胶料类别 id -> { code, title },用于按种类配置编码匹配 */
|
||||
const rubberCategoryMetaMap = ref<Map<string, { code?: string; title?: string }>>(new Map());
|
||||
const selectedRubberCategoryKeys = ref<KeyType[]>([RUBBER_TREE_ALL]);
|
||||
const expandedRubberCategoryKeys = ref<KeyType[]>([RUBBER_TREE_ALL]);
|
||||
|
||||
const visibleRubberTree = computed(() => [
|
||||
{
|
||||
key: RUBBER_TREE_ALL,
|
||||
title: '全部胶料类别',
|
||||
children: rubberCategoryTree.value || [],
|
||||
},
|
||||
]);
|
||||
|
||||
const selectedRubberCategoryFilter = computed(() => {
|
||||
const key = selectedRubberCategoryKeys.value[0];
|
||||
if (!key || key === RUBBER_TREE_ALL) {
|
||||
return {};
|
||||
}
|
||||
return { categoryId: String(key) };
|
||||
});
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】选料弹窗数据源类型与胶料类别树------------->
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
@@ -177,8 +238,13 @@
|
||||
return { minorCategoryId: keyStr };
|
||||
});
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, clearSelectedRowKeys }] = useTable({
|
||||
api: mixerList,
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】右侧列表按页签切换数据源------------->
|
||||
function pickerListApi(params: Recordable) {
|
||||
return pickerType.value === 'rubber' ? rubberList(params) : mixerList(params);
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, clearSelectedRowKeys, setColumns }] = useTable({
|
||||
api: pickerListApi,
|
||||
columns: mixingMaterialPickerTableColumns,
|
||||
rowKey: 'id',
|
||||
useSearchForm: false,
|
||||
@@ -187,13 +253,22 @@
|
||||
showIndexColumn: true,
|
||||
immediate: false,
|
||||
beforeFetch: (params) => {
|
||||
const next = { ...params, ...selectedCategoryFilter.value };
|
||||
const kw = keyword.value?.trim();
|
||||
if (pickerType.value === 'rubber') {
|
||||
const rubberParams = { ...params, ...selectedRubberCategoryFilter.value };
|
||||
if (kw) {
|
||||
rubberParams.materialName = `*${kw}*`;
|
||||
}
|
||||
return rubberParams;
|
||||
}
|
||||
const next = { ...params, ...selectedCategoryFilter.value };
|
||||
if (kw) {
|
||||
next.materialName = `*${kw}*`;
|
||||
}
|
||||
return next;
|
||||
},
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】右侧列表按页签切换数据源------------->
|
||||
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
@@ -218,11 +293,18 @@
|
||||
clearSelectedRowKeys?.();
|
||||
hiddenCategoryIds.value = loadMixingMaterialPickerHiddenCategoryIds();
|
||||
selectedCategoryKeys.value = [TREE_ALL];
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】每次打开默认密炼物料页签------------->
|
||||
pickerType.value = 'mixer';
|
||||
selectedRubberCategoryKeys.value = [RUBBER_TREE_ALL];
|
||||
setColumns(mixingMaterialPickerTableColumns);
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】每次打开默认密炼物料页签------------->
|
||||
setModalProps({ confirmLoading: false });
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A52】选料弹窗先加载左侧树再查右侧列表-----------
|
||||
try {
|
||||
await loadMaterialCategoryTree();
|
||||
kindLookup.value = await loadMixingMaterialKindLookup(false);
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】打开弹窗刷新种类配置避免缓存旧数据-----------
|
||||
kindLookup.value = await loadMixingMaterialKindLookup(true);
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】打开弹窗刷新种类配置避免缓存旧数据-----------
|
||||
reloadTable();
|
||||
} finally {
|
||||
pickerInitializing.value = false;
|
||||
@@ -231,6 +313,64 @@
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A50】选料弹窗打开时初始化(对齐其他SelectModal)-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】页签切换 + 胶料类别树加载/选择------------->
|
||||
async function handleSwitchPickerType() {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setColumns(pickerType.value === 'rubber' ? mixingRubberPickerTableColumns : mixingMaterialPickerTableColumns);
|
||||
if (pickerType.value === 'rubber' && !rubberCategoryTree.value.length) {
|
||||
await loadRubberCategoryTree();
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function flattenRubberCategoryTree(nodes: Recordable[], map: Map<string, { code?: string; title?: string }>) {
|
||||
for (const node of nodes || []) {
|
||||
const key = node?.key != null ? String(node.key) : '';
|
||||
if (key) {
|
||||
map.set(key, {
|
||||
code: node.code != null ? String(node.code) : undefined,
|
||||
title: node.title != null ? String(node.title) : undefined,
|
||||
});
|
||||
}
|
||||
if (node?.children?.length) {
|
||||
flattenRubberCategoryTree(node.children, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRubberCategoryTree() {
|
||||
rubberTreeLoading.value = true;
|
||||
try {
|
||||
const res: any = await loadTreeData({ pcode: RUBBER_CATEGORY_PCODE });
|
||||
const treeNodes = Array.isArray(res) ? res : res?.result || [];
|
||||
rubberCategoryTree.value = treeNodes;
|
||||
const metaMap = new Map<string, { code?: string; title?: string }>();
|
||||
flattenRubberCategoryTree(treeNodes, metaMap);
|
||||
rubberCategoryMetaMap.value = metaMap;
|
||||
} catch {
|
||||
rubberCategoryTree.value = [];
|
||||
rubberCategoryMetaMap.value = new Map();
|
||||
createMessage.warning('加载胶料类别失败,请检查分类根编码 XSLMES_RUBBER 是否存在。');
|
||||
} finally {
|
||||
rubberTreeLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onRubberCategorySelect(keys: KeyType[]) {
|
||||
selectedRubberCategoryKeys.value = keys?.length ? keys : [RUBBER_TREE_ALL];
|
||||
if (pickerInitializing.value) {
|
||||
return;
|
||||
}
|
||||
reloadTable();
|
||||
}
|
||||
|
||||
function onRubberExpandedKeysChange(keys: KeyType[]) {
|
||||
expandedRubberCategoryKeys.value = keys?.length ? keys : [RUBBER_TREE_ALL];
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】页签切换 + 胶料类别树加载/选择------------->
|
||||
|
||||
|
||||
async function loadMaterialCategoryTree(forceReload = false) {
|
||||
const hasCachedTree = !forceReload && (hasMesMaterialCategoryTreeCache() || rawCategoryTree.value.length > 0);
|
||||
if (forceReload || !hasCachedTree) {
|
||||
@@ -363,6 +503,15 @@
|
||||
}
|
||||
|
||||
function resolvePickerMaterialKind(material: Recordable) {
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签种类/自动人工称量解析------------->
|
||||
if (pickerType.value === 'rubber') {
|
||||
const weighMode = getPickerWeighMode(material?.id);
|
||||
const catId = material?.categoryId ? String(material.categoryId) : '';
|
||||
const catName = material?.categoryId_dictText || '';
|
||||
const catCode = rubberCategoryMetaMap.value.get(catId)?.code || '';
|
||||
return resolveMixingRubberKindForPicker(kindLookup.value, weighMode, catId, catName, catCode);
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签种类/自动人工称量解析------------->
|
||||
const weighMode = getPickerWeighMode(material?.id);
|
||||
const minorId = material?.minorCategoryId ? String(material.minorCategoryId) : '';
|
||||
const minorName = material?.minorCategoryId_dictText || '';
|
||||
@@ -380,12 +529,37 @@
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMixerById({ id: keys[0] });
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】按页签查询选中行详情------------->
|
||||
const queryById = pickerType.value === 'rubber' ? queryRubberById : queryMixerById;
|
||||
const raw = await queryById({ id: keys[0] });
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】按页签查询选中行详情------------->
|
||||
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签选中回填明细------------->
|
||||
if (pickerType.value === 'rubber') {
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条胶料');
|
||||
return;
|
||||
}
|
||||
const weighMode = getPickerWeighMode(row.id);
|
||||
const catId = row.categoryId ? String(row.categoryId) : '';
|
||||
const catName = row.categoryId_dictText || '';
|
||||
const catCode = rubberCategoryMetaMap.value.get(catId)?.code || '';
|
||||
const rubberKind = resolveMixingRubberKindForPicker(kindLookup.value, weighMode, catId, catName, catCode);
|
||||
if (!rubberKind) {
|
||||
createMessage.warning('未匹配到种类,请检查种类配置(胶料类别或「胶料」兜底种类)');
|
||||
return;
|
||||
}
|
||||
const rubberPayload: Recordable = { ...row, pickerWeighMode: weighMode };
|
||||
applyMixingRubberFromSelection(rubberPayload, row, rubberKind);
|
||||
emit('select', rubberPayload);
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】胶料页签选中回填明细------------->
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条密炼物料');
|
||||
return;
|
||||
@@ -439,6 +613,17 @@
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* 选料弹窗左侧密炼物料/胶料页签 */
|
||||
.mixing-material-picker-tabs {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mixing-material-picker-tabs :deep(.ant-radio-button-wrapper) {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mixing-material-picker-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
Reference in New Issue
Block a user