Compare commits
3 Commits
38f22ef8bd
...
a65ae7be60
| Author | SHA1 | Date | |
|---|---|---|---|
| a65ae7be60 | |||
| 69a60ca07b | |||
| 29efd6694f |
64
jeecg-boot/db/mes-fix-rubber-category-visible.sql
Normal file
64
jeecg-boot/db/mes-fix-rubber-category-visible.sql
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
-- 修复:胶料分类字典(XSLMES_RUBBER)数据库有数据但页面不展示
|
||||||
|
-- 场景:开启多租户后,sys_category 的 tenant_id 与当前登录租户不一致/为空
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
-- 1) 目标租户:默认取 admin 用户租户;若为空则回退到 0
|
||||||
|
SET @target_tenant_id = (
|
||||||
|
SELECT COALESCE(tenant_id, 0)
|
||||||
|
FROM sys_user
|
||||||
|
WHERE username = 'admin'
|
||||||
|
ORDER BY create_time ASC
|
||||||
|
LIMIT 1
|
||||||
|
);
|
||||||
|
SET @target_tenant_id = IFNULL(@target_tenant_id, 0);
|
||||||
|
|
||||||
|
-- 2) 定位根分类编码
|
||||||
|
SET @rubber_code = 'XSLMES_RUBBER';
|
||||||
|
|
||||||
|
-- 若根节点不存在则补一个最小根节点(避免前端 pcode 查询直接失败)
|
||||||
|
INSERT INTO sys_category (id, pid, name, code, has_child, tenant_id, create_by, create_time, update_by, update_time)
|
||||||
|
SELECT '1994000000000000001', '0', 'MES胶料分类', @rubber_code, '1', @target_tenant_id, 'admin', NOW(), 'admin', NOW()
|
||||||
|
FROM dual
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM sys_category WHERE code = @rubber_code
|
||||||
|
);
|
||||||
|
|
||||||
|
SET @rubber_root_id = (
|
||||||
|
SELECT id
|
||||||
|
FROM sys_category
|
||||||
|
WHERE code = @rubber_code
|
||||||
|
ORDER BY create_time ASC
|
||||||
|
LIMIT 1
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 3) 若根节点存在,统一修复租户与父子标记
|
||||||
|
UPDATE sys_category
|
||||||
|
SET tenant_id = @target_tenant_id
|
||||||
|
WHERE id = @rubber_root_id;
|
||||||
|
|
||||||
|
UPDATE sys_category
|
||||||
|
SET tenant_id = @target_tenant_id
|
||||||
|
WHERE pid = @rubber_root_id;
|
||||||
|
|
||||||
|
-- 根节点是否有子节点,按真实数据回写
|
||||||
|
UPDATE sys_category
|
||||||
|
SET has_child = CASE
|
||||||
|
WHEN EXISTS (SELECT 1 FROM (SELECT id FROM sys_category WHERE pid = @rubber_root_id LIMIT 1) t) THEN '1'
|
||||||
|
ELSE '0'
|
||||||
|
END
|
||||||
|
WHERE id = @rubber_root_id;
|
||||||
|
|
||||||
|
-- 子节点统一标记为无子(当前这批分类通常为叶子)
|
||||||
|
UPDATE sys_category
|
||||||
|
SET has_child = '0'
|
||||||
|
WHERE pid = @rubber_root_id;
|
||||||
|
|
||||||
|
-- 4) 结果检查(执行后看返回)
|
||||||
|
SELECT 'ROOT' AS level_tag, id, pid, code, name, tenant_id, has_child
|
||||||
|
FROM sys_category
|
||||||
|
WHERE id = @rubber_root_id
|
||||||
|
UNION ALL
|
||||||
|
SELECT 'CHILD' AS level_tag, id, pid, code, name, tenant_id, has_child
|
||||||
|
FROM sys_category
|
||||||
|
WHERE pid = @rubber_root_id
|
||||||
|
ORDER BY level_tag, code;
|
||||||
@@ -785,71 +785,65 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
}
|
}
|
||||||
String specCode = row.getSpecCode().trim();
|
String specCode = row.getSpecCode().trim();
|
||||||
boolean isFinalStage = "Q".equalsIgnoreCase(resolveMixingMaterialStep(row));
|
boolean isFinalStage = "Q".equalsIgnoreCase(resolveMixingMaterialStep(row));
|
||||||
|
String materialPhase = resolveGeneratedMaterialPhase(row);
|
||||||
MesMaterial sourceRubber = resolveSourceRubberMaterial(formula);
|
MesMaterial sourceRubber = resolveSourceRubberMaterial(formula);
|
||||||
MesMaterial existing = findRubberMaterialByCodeOrName(specCode);
|
String categoryId = sourceRubber != null ? sourceRubber.getCategoryId() : null;
|
||||||
|
String rubberName = resolveRubberName(formula);
|
||||||
|
String generatedName = buildGeneratedRubberMaterialName(row, rubberName);
|
||||||
|
MesMaterial existing = findGeneratedRubberMaterialByCodeOrName(specCode, materialPhase);
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】更新已生成胶料时按原胶料复制字段-----------
|
copyGeneratedMaterialFieldsFromSource(existing, sourceRubber);
|
||||||
if (sourceRubber != null) {
|
if (StringUtils.isNotBlank(categoryId)) {
|
||||||
fillGeneratedRubberFromSource(existing, sourceRubber, specCode, now, true);
|
existing.setCategoryId(categoryId);
|
||||||
} else {
|
|
||||||
applyGeneratedRubberFallback(existing, formula, specCode, now);
|
|
||||||
}
|
}
|
||||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】更新已生成胶料时按原胶料复制字段-----------
|
if (StringUtils.isBlank(existing.getMaterialCode())) {
|
||||||
|
existing.setMaterialCode(specCode);
|
||||||
|
}
|
||||||
|
existing.setMaterialName(generatedName);
|
||||||
|
if (StringUtils.isBlank(existing.getAliasName()) && StringUtils.isNotBlank(rubberName)) {
|
||||||
|
existing.setAliasName(rubberName);
|
||||||
|
}
|
||||||
|
existing.setMaterialPhase(materialPhase);
|
||||||
|
existing.setEnableFlag(existing.getEnableFlag() == null ? 1 : existing.getEnableFlag());
|
||||||
|
existing.setUpdateTime(now);
|
||||||
mesMaterialService.updateById(existing);
|
mesMaterialService.updateById(existing);
|
||||||
log.info(
|
log.info(
|
||||||
"[混炼示方生成] 更新胶料信息 id={}, code={}, sourceId={}, isFinal={}",
|
"[混炼示方生成] 更新胶料信息 id={}, code={}, phase={}, categoryId={}, isFinal={}",
|
||||||
existing.getId(),
|
existing.getId(),
|
||||||
specCode,
|
specCode,
|
||||||
sourceRubber != null ? sourceRubber.getId() : null,
|
materialPhase,
|
||||||
|
categoryId,
|
||||||
isFinalStage);
|
isFinalStage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MesMaterial material = new MesMaterial();
|
MesMaterial material = new MesMaterial();
|
||||||
//update-begin---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】新增B/F段胶料按原胶料复制字段-----------
|
copyGeneratedMaterialFieldsFromSource(material, sourceRubber);
|
||||||
if (sourceRubber != null) {
|
material.setMaterialCode(specCode);
|
||||||
fillGeneratedRubberFromSource(material, sourceRubber, specCode, now, false);
|
material.setMaterialName(generatedName);
|
||||||
} else {
|
material.setAliasName(StringUtils.isNotBlank(rubberName) ? rubberName : null);
|
||||||
applyGeneratedRubberFallback(material, formula, specCode, now);
|
material.setCategoryId(categoryId);
|
||||||
}
|
material.setMaterialPhase(materialPhase);
|
||||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】新增B/F段胶料按原胶料复制字段-----------
|
material.setEnableFlag(1);
|
||||||
|
material.setIsSpecialRubber(0);
|
||||||
|
material.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||||
|
material.setCreateTime(now);
|
||||||
|
material.setUpdateTime(now);
|
||||||
mesMaterialService.save(material);
|
mesMaterialService.save(material);
|
||||||
log.info(
|
log.info(
|
||||||
"[混炼示方生成] 新增胶料信息 id={}, code={}, sourceId={}, isFinal={}",
|
"[混炼示方生成] 新增胶料信息 id={}, code={}, phase={}, categoryId={}, isFinal={}",
|
||||||
material.getId(),
|
material.getId(),
|
||||||
specCode,
|
specCode,
|
||||||
sourceRubber != null ? sourceRubber.getId() : null,
|
materialPhase,
|
||||||
|
categoryId,
|
||||||
isFinalStage);
|
isFinalStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 配合示方所选「胶料代号」对应的原胶料信息 */
|
private void copyGeneratedMaterialFieldsFromSource(MesMaterial target, MesMaterial source) {
|
||||||
private MesMaterial resolveSourceRubberMaterial(MesXslFormulaSpec formula) {
|
if (target == null || source == null) {
|
||||||
if (formula == null || StringUtils.isBlank(formula.getRubberMaterialId())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
MesMaterial rubber = mesMaterialService.getById(formula.getRubberMaterialId());
|
|
||||||
if (rubber == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (rubber.getDelFlag() != null && rubber.getDelFlag().equals(CommonConstant.DEL_FLAG_1)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return rubber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将原胶料字段复制到生成的 B/F 段胶料:编码/名称=示方编号,ERP 编号留空,不复制主键与审计字段。
|
|
||||||
*/
|
|
||||||
private void fillGeneratedRubberFromSource(
|
|
||||||
MesMaterial target, MesMaterial source, String specCode, Date now, boolean isUpdate) {
|
|
||||||
if (target == null || source == null || StringUtils.isBlank(specCode)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String code = specCode.trim();
|
|
||||||
target.setMaterialCode(code);
|
|
||||||
target.setMaterialName(code);
|
|
||||||
target.setAliasName(source.getAliasName());
|
|
||||||
target.setShortName(source.getShortName());
|
target.setShortName(source.getShortName());
|
||||||
target.setCategoryId(source.getCategoryId());
|
target.setCategoryId(source.getCategoryId());
|
||||||
target.setMaterialGrade(source.getMaterialGrade());
|
target.setMaterialGrade(source.getMaterialGrade());
|
||||||
@@ -859,7 +853,7 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
target.setBaseUnitId(source.getBaseUnitId());
|
target.setBaseUnitId(source.getBaseUnitId());
|
||||||
target.setStatUnitId(source.getStatUnitId());
|
target.setStatUnitId(source.getStatUnitId());
|
||||||
target.setUnitConvertRate(source.getUnitConvertRate());
|
target.setUnitConvertRate(source.getUnitConvertRate());
|
||||||
target.setErpCode(null);
|
target.setErpCode(source.getErpCode());
|
||||||
target.setFinalShelfLifeDays(source.getFinalShelfLifeDays());
|
target.setFinalShelfLifeDays(source.getFinalShelfLifeDays());
|
||||||
target.setMasterShelfLifeDays(source.getMasterShelfLifeDays());
|
target.setMasterShelfLifeDays(source.getMasterShelfLifeDays());
|
||||||
target.setMinStandingHours(source.getMinStandingHours());
|
target.setMinStandingHours(source.getMinStandingHours());
|
||||||
@@ -867,41 +861,18 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
target.setOriginPlace(source.getOriginPlace());
|
target.setOriginPlace(source.getOriginPlace());
|
||||||
target.setSupplierId(source.getSupplierId());
|
target.setSupplierId(source.getSupplierId());
|
||||||
target.setCustomerId(source.getCustomerId());
|
target.setCustomerId(source.getCustomerId());
|
||||||
target.setEnableFlag(source.getEnableFlag() != null ? source.getEnableFlag() : 1);
|
target.setEnableFlag(source.getEnableFlag());
|
||||||
target.setIsSpecialRubber(source.getIsSpecialRubber() != null ? source.getIsSpecialRubber() : 0);
|
target.setIsSpecialRubber(source.getIsSpecialRubber());
|
||||||
target.setSyncFromErpFlag(0);
|
target.setSyncFromErpFlag(source.getSyncFromErpFlag());
|
||||||
target.setLastErpSyncTime(null);
|
target.setLastErpSyncTime(source.getLastErpSyncTime());
|
||||||
target.setRemark(source.getRemark());
|
target.setRemark(source.getRemark());
|
||||||
target.setTenantId(source.getTenantId());
|
|
||||||
target.setSysOrgCode(source.getSysOrgCode());
|
|
||||||
target.setUpdateTime(now);
|
|
||||||
if (!isUpdate) {
|
|
||||||
target.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
||||||
target.setCreateTime(now);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 未选择原胶料时的最小兜底(仅类别/状态) */
|
private MesMaterial resolveSourceRubberMaterial(MesXslFormulaSpec formula) {
|
||||||
private void applyGeneratedRubberFallback(MesMaterial target, MesXslFormulaSpec formula, String specCode, Date now) {
|
if (formula == null || StringUtils.isBlank(formula.getRubberMaterialId())) {
|
||||||
if (target == null || StringUtils.isBlank(specCode)) {
|
return null;
|
||||||
return;
|
|
||||||
}
|
|
||||||
String code = specCode.trim();
|
|
||||||
target.setMaterialCode(code);
|
|
||||||
target.setMaterialName(code);
|
|
||||||
target.setCategoryId(resolveGeneratedRubberCategoryId(formula));
|
|
||||||
String rubberName = resolveRubberName(formula);
|
|
||||||
if (StringUtils.isNotBlank(rubberName)) {
|
|
||||||
target.setAliasName(rubberName);
|
|
||||||
}
|
|
||||||
target.setErpCode(null);
|
|
||||||
target.setEnableFlag(target.getEnableFlag() != null ? target.getEnableFlag() : 1);
|
|
||||||
target.setIsSpecialRubber(target.getIsSpecialRubber() != null ? target.getIsSpecialRubber() : 0);
|
|
||||||
target.setDelFlag(target.getDelFlag() != null ? target.getDelFlag() : CommonConstant.DEL_FLAG_0);
|
|
||||||
target.setUpdateTime(now);
|
|
||||||
if (target.getCreateTime() == null) {
|
|
||||||
target.setCreateTime(now);
|
|
||||||
}
|
}
|
||||||
|
return mesMaterialService.getById(formula.getRubberMaterialId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 生成的 B/F 段胶料类别:取配合示方所选「胶料代号」对应胶料(mes_material)的类别 */
|
/** 生成的 B/F 段胶料类别:取配合示方所选「胶料代号」对应胶料(mes_material)的类别 */
|
||||||
@@ -911,22 +882,67 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MesMaterial findRubberMaterialByCodeOrName(String specCode) {
|
private MesMaterial findRubberMaterialByCodeOrName(String specCode) {
|
||||||
|
return findGeneratedRubberMaterialByCodeOrName(specCode, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private MesMaterial findGeneratedRubberMaterialByCodeOrName(String specCode, String materialPhase) {
|
||||||
if (StringUtils.isBlank(specCode)) {
|
if (StringUtils.isBlank(specCode)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
LambdaQueryWrapper<MesMaterial> byCodeWrapper = new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(MesMaterial::getMaterialCode, specCode)
|
||||||
|
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag));
|
||||||
|
appendPhaseMatch(byCodeWrapper, materialPhase);
|
||||||
MesMaterial byCode = mesMaterialService.getOne(
|
MesMaterial byCode = mesMaterialService.getOne(
|
||||||
new LambdaQueryWrapper<MesMaterial>()
|
byCodeWrapper.last("limit 1"));
|
||||||
.eq(MesMaterial::getMaterialCode, specCode)
|
|
||||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
|
||||||
.last("limit 1"));
|
|
||||||
if (byCode != null) {
|
if (byCode != null) {
|
||||||
return byCode;
|
return byCode;
|
||||||
}
|
}
|
||||||
|
LambdaQueryWrapper<MesMaterial> byNameWrapper = new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(MesMaterial::getMaterialName, specCode)
|
||||||
|
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag));
|
||||||
|
appendPhaseMatch(byNameWrapper, materialPhase);
|
||||||
return mesMaterialService.getOne(
|
return mesMaterialService.getOne(
|
||||||
new LambdaQueryWrapper<MesMaterial>()
|
byNameWrapper.last("limit 1"));
|
||||||
.eq(MesMaterial::getMaterialName, specCode)
|
}
|
||||||
.and(w -> w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0).or().isNull(MesMaterial::getDelFlag))
|
|
||||||
.last("limit 1"));
|
private void appendPhaseMatch(LambdaQueryWrapper<MesMaterial> wrapper, String materialPhase) {
|
||||||
|
if (wrapper == null || StringUtils.isBlank(materialPhase)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wrapper.and(w -> w.eq(MesMaterial::getMaterialPhase, materialPhase)
|
||||||
|
.or()
|
||||||
|
.isNull(MesMaterial::getMaterialPhase)
|
||||||
|
.or()
|
||||||
|
.eq(MesMaterial::getMaterialPhase, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveGeneratedMaterialPhase(MesXslFormulaMixingGenerateRowVO row) {
|
||||||
|
if (row == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ("Q".equalsIgnoreCase(resolveMixingMaterialStep(row))) {
|
||||||
|
return "F";
|
||||||
|
}
|
||||||
|
if (row.getASegmentIndex() != null && row.getASegmentIndex() > 0) {
|
||||||
|
return "B" + row.getASegmentIndex();
|
||||||
|
}
|
||||||
|
if (row.getStageIndex() != null && row.getStageIndex() > 0) {
|
||||||
|
return "B" + row.getStageIndex();
|
||||||
|
}
|
||||||
|
return "B1";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildGeneratedRubberMaterialName(MesXslFormulaMixingGenerateRowVO row, String rubberName) {
|
||||||
|
String baseName = StringUtils.defaultString(rubberName).trim();
|
||||||
|
if (StringUtils.isBlank(baseName) && row != null && StringUtils.isNotBlank(row.getSpecCode())) {
|
||||||
|
baseName = row.getSpecCode().trim();
|
||||||
|
}
|
||||||
|
String phase = resolveGeneratedMaterialPhase(row);
|
||||||
|
if (StringUtils.isBlank(phase)) {
|
||||||
|
return baseName;
|
||||||
|
}
|
||||||
|
return phase + baseName;
|
||||||
}
|
}
|
||||||
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】生成混炼示方改为同步B/F段胶至胶料信息-----------
|
//update-end---author:cursor ---date:20260601 for:【XSLMES-20260601-A62】生成混炼示方改为同步B/F段胶至胶料信息-----------
|
||||||
|
|
||||||
@@ -1015,9 +1031,9 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
if (row != null && row.getStageIndex() != null && row.getStageIndex() > 0) {
|
if (row != null && row.getStageIndex() != null && row.getStageIndex() > 0) {
|
||||||
return Math.min(row.getStageIndex(), 7);
|
return Math.min(row.getStageIndex(), 7);
|
||||||
}
|
}
|
||||||
String specCode = row != null ? row.getSpecCode() : null;
|
String normalizedSpecCode = row == null ? "" : StringUtils.trimToEmpty(row.getSpecCode());
|
||||||
if (StringUtils.isNotBlank(specCode)) {
|
if (StringUtils.isNotEmpty(normalizedSpecCode)) {
|
||||||
Matcher matcher = Pattern.compile("(?i)B(\\d+)").matcher(specCode.trim());
|
Matcher matcher = Pattern.compile("(?i)B(\\d+)").matcher(normalizedSpecCode);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
return Math.min(Integer.parseInt(matcher.group(1)), 7);
|
return Math.min(Integer.parseInt(matcher.group(1)), 7);
|
||||||
}
|
}
|
||||||
@@ -1033,8 +1049,8 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
if (row != null && StringUtils.isNotBlank(row.getStepType())) {
|
if (row != null && StringUtils.isNotBlank(row.getStepType())) {
|
||||||
return row.getStepType().trim().toUpperCase();
|
return row.getStepType().trim().toUpperCase();
|
||||||
}
|
}
|
||||||
String specCode = row != null ? row.getSpecCode() : null;
|
String normalizedSpecCode = row == null ? "" : StringUtils.trimToEmpty(row.getSpecCode()).toUpperCase();
|
||||||
if (StringUtils.isNotBlank(specCode) && specCode.trim().toUpperCase().startsWith("F")) {
|
if (StringUtils.isNotEmpty(normalizedSpecCode) && normalizedSpecCode.startsWith("F")) {
|
||||||
return "Q";
|
return "Q";
|
||||||
}
|
}
|
||||||
return "A";
|
return "A";
|
||||||
@@ -1052,7 +1068,6 @@ public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecM
|
|||||||
Map<String, String> categoryIdCache) {
|
Map<String, String> categoryIdCache) {
|
||||||
String stepFilter = StringUtils.isNotBlank(materialStep) ? materialStep.trim().toUpperCase() : "A";
|
String stepFilter = StringUtils.isNotBlank(materialStep) ? materialStep.trim().toUpperCase() : "A";
|
||||||
List<MesXslMixingSpecMaterial> materials = new ArrayList<>();
|
List<MesXslMixingSpecMaterial> materials = new ArrayList<>();
|
||||||
int sort = 0;
|
|
||||||
if ("Q".equals(stepFilter)) {
|
if ("Q".equals(stepFilter)) {
|
||||||
//update-begin---author:cursor ---date:20260522 for:【XSLMES-20260522-A38】F段加入最后一段B炼好胶料一条再加Q配合剂-----------
|
//update-begin---author:cursor ---date:20260522 for:【XSLMES-20260522-A38】F段加入最后一段B炼好胶料一条再加Q配合剂-----------
|
||||||
String rubberName = resolveRubberName(formula);
|
String rubberName = resolveRubberName(formula);
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ public class MesXslRawMaterialInspectRecordServiceImpl
|
|||||||
if (lineList == null || lineList.isEmpty()) {
|
if (lineList == null || lineList.isEmpty()) {
|
||||||
throw new JeecgBootException("请至少录入一条检验结果");
|
throw new JeecgBootException("请至少录入一条检验结果");
|
||||||
}
|
}
|
||||||
|
boolean hasAnyDetailUpdated = false;
|
||||||
boolean allPass = true;
|
|
||||||
for (MesXslRawMaterialInspectRecordLine line : lineList) {
|
for (MesXslRawMaterialInspectRecordLine line : lineList) {
|
||||||
if (StringUtils.isBlank(line.getId())) {
|
if (StringUtils.isBlank(line.getId())) {
|
||||||
throw new JeecgBootException("明细ID不能为空,请刷新后重试");
|
throw new JeecgBootException("明细ID不能为空,请刷新后重试");
|
||||||
@@ -158,6 +157,15 @@ public class MesXslRawMaterialInspectRecordServiceImpl
|
|||||||
if (dbLine == null || !recordId.equals(dbLine.getRecordId())) {
|
if (dbLine == null || !recordId.equals(dbLine.getRecordId())) {
|
||||||
throw new JeecgBootException("明细不存在或不属于当前送检记录");
|
throw new JeecgBootException("明细不存在或不属于当前送检记录");
|
||||||
}
|
}
|
||||||
|
// 已录入(非待检)明细不允许再次录入,防止重复覆盖。
|
||||||
|
String dbPassFlag = normalize(dbLine.getPassFlag());
|
||||||
|
if (!STATUS_PENDING.equals(dbPassFlag)) {
|
||||||
|
throw new JeecgBootException("检验项目【" + dbLine.getInspectItemName() + "】已录入,不能重复录入");
|
||||||
|
}
|
||||||
|
// 允许分次录入:本次未填检验值的明细跳过,不改该行状态。
|
||||||
|
if (line.getInspectValue() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String passFlag =
|
String passFlag =
|
||||||
evaluatePassFlag(
|
evaluatePassFlag(
|
||||||
line.getInspectValue(),
|
line.getInspectValue(),
|
||||||
@@ -168,20 +176,37 @@ public class MesXslRawMaterialInspectRecordServiceImpl
|
|||||||
dbLine.setInspectValue(line.getInspectValue());
|
dbLine.setInspectValue(line.getInspectValue());
|
||||||
dbLine.setPassFlag(passFlag);
|
dbLine.setPassFlag(passFlag);
|
||||||
recordLineMapper.updateById(dbLine);
|
recordLineMapper.updateById(dbLine);
|
||||||
|
hasAnyDetailUpdated = true;
|
||||||
|
}
|
||||||
|
if (!hasAnyDetailUpdated) {
|
||||||
|
throw new JeecgBootException("请至少录入一条检验值后再保存");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MesXslRawMaterialInspectRecordLine> allDbLines = selectLinesByRecordId(recordId);
|
||||||
|
boolean allCompleted = true;
|
||||||
|
boolean allPass = true;
|
||||||
|
for (MesXslRawMaterialInspectRecordLine dbLine : allDbLines) {
|
||||||
|
String passFlag = normalize(dbLine.getPassFlag());
|
||||||
|
if (STATUS_PENDING.equals(passFlag) || StringUtils.isBlank(passFlag)) {
|
||||||
|
allCompleted = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!STATUS_PASS.equals(passFlag)) {
|
if (!STATUS_PASS.equals(passFlag)) {
|
||||||
allPass = false;
|
allPass = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record.setInspectStatus(allPass ? STATUS_PASS : STATUS_FAIL);
|
// 仅当全部明细已完成录入时,才回写主表/卡片检验状态。
|
||||||
record.setResultTime(new Date());
|
if (allCompleted) {
|
||||||
this.updateById(record);
|
record.setInspectStatus(allPass ? STATUS_PASS : STATUS_FAIL);
|
||||||
// 判定完成后回写原材料卡片检测结果
|
record.setResultTime(new Date());
|
||||||
if (StringUtils.isNotBlank(record.getRawMaterialCardId())) {
|
this.updateById(record);
|
||||||
MesXslRawMaterialCard card = new MesXslRawMaterialCard();
|
if (StringUtils.isNotBlank(record.getRawMaterialCardId())) {
|
||||||
card.setId(record.getRawMaterialCardId());
|
MesXslRawMaterialCard card = new MesXslRawMaterialCard();
|
||||||
card.setTestResult(allPass ? CARD_TEST_RESULT_PASS : CARD_TEST_RESULT_FAIL);
|
card.setId(record.getRawMaterialCardId());
|
||||||
rawMaterialCardService.updateById(card);
|
card.setTestResult(allPass ? CARD_TEST_RESULT_PASS : CARD_TEST_RESULT_FAIL);
|
||||||
|
rawMaterialCardService.updateById(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ public class MesMaterialController extends JeecgController<MesMaterial, IMesMate
|
|||||||
MesMaterial model,
|
MesMaterial model,
|
||||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
|
@RequestParam(name = "onlySales", required = false) Integer onlySales,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
QueryWrapper<MesMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
QueryWrapper<MesMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||||
|
if (onlySales != null && onlySales == 1) {
|
||||||
|
queryWrapper.and(w -> w.isNull("material_phase").or().eq("material_phase", ""));
|
||||||
|
}
|
||||||
IPage<MesMaterial> pageList = mesMaterialService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
IPage<MesMaterial> pageList = mesMaterialService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public class MesMaterial implements Serializable {
|
|||||||
@Excel(name = "胶料客户", width = 15, dictTable = "mes_xsl_customer", dicText = "customer_name", dicCode = "id")
|
@Excel(name = "胶料客户", width = 15, dictTable = "mes_xsl_customer", dicText = "customer_name", dicCode = "id")
|
||||||
@Dict(dictTable = "mes_xsl_customer", dicText = "customer_name", dicCode = "id")
|
@Dict(dictTable = "mes_xsl_customer", dicText = "customer_name", dicCode = "id")
|
||||||
private String customerId;
|
private String customerId;
|
||||||
|
@Excel(name = "物料阶段", width = 12)
|
||||||
|
private String materialPhase;
|
||||||
@Excel(name = "使用状态", width = 10, replace = {"使用中_1", "停用_0"})
|
@Excel(name = "使用状态", width = 10, replace = {"使用中_1", "停用_0"})
|
||||||
private Integer enableFlag;
|
private Integer enableFlag;
|
||||||
@Excel(name = "是否为特种胶", width = 12, replace = {"是_1", "否_0"})
|
@Excel(name = "是否为特种胶", width = 12, replace = {"是_1", "否_0"})
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
-- mes_material 新增物料阶段字段(销售物料为空,生产自动生成为 Bn/F)
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
SET @db = DATABASE();
|
||||||
|
|
||||||
|
SET @sql = IF(
|
||||||
|
(SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'mes_material' AND COLUMN_NAME = 'material_phase') = 0,
|
||||||
|
'ALTER TABLE `mes_material` ADD COLUMN `material_phase` varchar(16) DEFAULT NULL COMMENT ''物料阶段(销售为空,生产为B1/B2.../F)'' AFTER `customer_id`',
|
||||||
|
'SELECT 1'
|
||||||
|
);
|
||||||
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
|
|
||||||
const selectedRow = ref<Recordable | null>(null);
|
const selectedRow = ref<Recordable | null>(null);
|
||||||
|
const onlySales = ref(false);
|
||||||
|
|
||||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||||
api: materialList,
|
api: materialList,
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
beforeFetch: (params) => ({
|
beforeFetch: (params) => ({
|
||||||
...params,
|
...params,
|
||||||
enableFlag: params.enableFlag ?? 1,
|
enableFlag: params.enableFlag ?? 1,
|
||||||
|
onlySales: onlySales.value ? 1 : undefined,
|
||||||
}),
|
}),
|
||||||
rowSelection: {
|
rowSelection: {
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
@@ -46,6 +48,7 @@
|
|||||||
|
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
selectedRow.value = null;
|
selectedRow.value = null;
|
||||||
|
onlySales.value = !!data?.onlySales;
|
||||||
clearSelectedRowKeys?.();
|
clearSelectedRowKeys?.();
|
||||||
setModalProps({ confirmLoading: false });
|
setModalProps({ confirmLoading: false });
|
||||||
const materialId = data?.materialId as string | undefined;
|
const materialId = data?.materialId as string | undefined;
|
||||||
|
|||||||
@@ -831,7 +831,7 @@
|
|||||||
if (!showFooterFlag.value) {
|
if (!showFooterFlag.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openRubberMaterialModalInner(true, { materialId: rubberMaterialPickerId.value || '' });
|
openRubberMaterialModalInner(true, { materialId: rubberMaterialPickerId.value || '', onlySales: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function openIssueNumberPicker() {
|
function openIssueNumberPicker() {
|
||||||
|
|||||||
@@ -68,7 +68,12 @@ export const lineJVxeColumns: JVxeColumn[] = [
|
|||||||
key: 'inspectValue',
|
key: 'inspectValue',
|
||||||
type: JVxeTypes.inputNumber,
|
type: JVxeTypes.inputNumber,
|
||||||
width: 120,
|
width: 120,
|
||||||
validateRules: [{ required: true, message: '${title}必填' }],
|
props: {
|
||||||
|
isDisabledCell: ({ row }) => {
|
||||||
|
const passFlag = String(row?.passFlag ?? '');
|
||||||
|
return passFlag !== '' && passFlag !== '0';
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '判定',
|
title: '判定',
|
||||||
|
|||||||
@@ -114,15 +114,14 @@
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const lineRef = lineTableRef.value as any;
|
const lineRef = lineTableRef.value as any;
|
||||||
if (lineRef?.validateTable) {
|
|
||||||
const err = await lineRef.validateTable();
|
|
||||||
if (err) {
|
|
||||||
createMessage.warning('请完善检验值');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
|
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
|
||||||
const lineList = tableData.map((item) => ({
|
const editableRows = tableData.filter((item) => String(item?.passFlag ?? '0') === '0');
|
||||||
|
const hasInput = editableRows.some((item) => item.inspectValue !== null && item.inspectValue !== undefined && item.inspectValue !== '');
|
||||||
|
if (!hasInput) {
|
||||||
|
createMessage.warning('请至少录入一条检验值');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const lineList = editableRows.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
inspectValue: item.inspectValue,
|
inspectValue: item.inspectValue,
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user