重构原材料卡片剩余数量计算逻辑,替换配置属性为服务调用以增强灵活性。新增匹配仓库配置的接口和视图,优化库区管理功能,确保数据展示的准确性和一致性。同时,更新相关文档以反映配置变更。
This commit is contained in:
@@ -4,17 +4,15 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.modules.xslmes.capacity.WarehouseAreaActualCapacityContribution;
|
||||
import org.jeecg.modules.xslmes.config.XslMesWarehouseAreaCapacityProperties;
|
||||
import org.jeecg.modules.xslmes.dto.MesXslAreaRemainQtySumDTO;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouseArea;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslRawMaterialCardMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaCapacityCfgService;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -23,6 +21,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用「原材料卡片」按库区(trim)汇总 remaining_quantity,回填展示字段 actual_capacity(不写库)。
|
||||
* 匹配哪些仓库分类由 {@link IMesXslWarehouseAreaCapacityCfgService}(页面配置 / YAML 兜底)决定。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -30,21 +29,20 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class RawMaterialCardRemainQtyCapacityContribution implements WarehouseAreaActualCapacityContribution {
|
||||
|
||||
private final XslMesWarehouseAreaCapacityProperties properties;
|
||||
private final IMesXslWarehouseAreaCapacityCfgService capacityCfgService;
|
||||
private final MesXslRawMaterialCardMapper mesXslRawMaterialCardMapper;
|
||||
private final ISysCategoryService sysCategoryService;
|
||||
|
||||
@Override
|
||||
public void contribute(List<MesXslWarehouseArea> areas) {
|
||||
if (areas == null || areas.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!properties.isEnabled()) {
|
||||
if (!capacityCfgService.isActualCapacityBackfillEnabled()) {
|
||||
return;
|
||||
}
|
||||
Set<String> allowedCategories = resolveAllowedWarehouseCategoryIds();
|
||||
Set<String> allowedCategories = capacityCfgService.resolveRawMaterialWarehouseCategoryIds();
|
||||
if (allowedCategories.isEmpty()) {
|
||||
log.debug("[WarehouseAreaActualCapacity] 原材料库分类编码/ID 均未解析到有效 warehouse_category,跳过 RawMaterialCard 策略");
|
||||
log.debug("[WarehouseAreaActualCapacity] 原材料库分类未配置或解析为空,跳过 RawMaterialCard 策略");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,33 +100,4 @@ public class RawMaterialCardRemainQtyCapacityContribution implements WarehouseAr
|
||||
private static String normId(String id) {
|
||||
return StringUtils.trimToEmpty(id);
|
||||
}
|
||||
|
||||
private static Set<String> normalizeIdSet(Collection<String> raw) {
|
||||
if (raw == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return raw.stream().filter(StringUtils::isNotBlank).map(String::trim).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/** 配置的 id + 配置的 code 解析出的 id 合并 */
|
||||
private Set<String> resolveAllowedWarehouseCategoryIds() {
|
||||
Set<String> set = new HashSet<>(normalizeIdSet(properties.getRawMaterialWarehouseCategoryIds()));
|
||||
Collection<String> codes = properties.getRawMaterialWarehouseCategoryCodes();
|
||||
if (codes != null) {
|
||||
for (String c : codes) {
|
||||
if (StringUtils.isBlank(c)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
String id = sysCategoryService.queryIdByCode(c.trim());
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
set.add(id.trim());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.warn("[WarehouseAreaActualCapacity] 解析原材料库分类编码失败 code={}: {}", c, ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,45 @@
|
||||
package org.jeecg.modules.xslmes.config;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.jeecg.modules.xslmes.constant.MesXslWarehouseCategory;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 库区列表「实际存放量」展示口径配置(不写库)
|
||||
|
||||
* <p>
|
||||
|
||||
* 推荐使用 {@link #rawMaterialWarehouseCategoryCodes},启动时解析为 sys_category.id,
|
||||
|
||||
* 避免在配置里维护易变的雪花 id;也可用 {@link #rawMaterialWarehouseCategoryIds} 直接指定 id。
|
||||
|
||||
*/
|
||||
|
||||
@Data
|
||||
|
||||
@Component
|
||||
|
||||
@ConfigurationProperties(prefix = "xslmes.warehouse-area.display-actual-capacity")
|
||||
|
||||
public class XslMesWarehouseAreaCapacityProperties {
|
||||
|
||||
|
||||
|
||||
package org.jeecg.modules.xslmes.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.xslmes.constant.MesXslWarehouseCategory;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 库区列表「实际存放量」展示兜底配置(不写库)
|
||||
* <p>
|
||||
* 当某租户在 {@code mes_xsl_warehouse_area_capacity_cfg} 中<strong>尚无已保存记录</strong>时,
|
||||
* 启用状态与分类 codes/ids 仍从本配置读取;一旦有库内记录,则仅以页面「匹配仓库」配置为准。
|
||||
* <p>
|
||||
* 推荐使用 codes 配置,由运行时解析为 sys_category.id;亦可直接配置 ids。
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "xslmes.warehouse-area.display-actual-capacity")
|
||||
public class XslMesWarehouseAreaCapacityProperties {
|
||||
|
||||
/**
|
||||
* 是否启用展示层回填「实际存放量」
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* 原材料库分类编码列表(resolve 成 id 后与 warehouse_category 匹配)。
|
||||
* 默认兼容 {@link MesXslWarehouseCategory#RAW_MATERIAL_CATEGORY_CODES}。
|
||||
*/
|
||||
private List<String> rawMaterialWarehouseCategoryCodes = defaultRawCodes();
|
||||
|
||||
/**
|
||||
* 直接指定 warehouse_category=sys_category.id(与 codes 解析结果<strong>合并</strong>)。
|
||||
* 可为空。
|
||||
*/
|
||||
private List<String> rawMaterialWarehouseCategoryIds = new ArrayList<>();
|
||||
|
||||
private static List<String> defaultRawCodes() {
|
||||
return new ArrayList<>(MesXslWarehouseCategory.RAW_MATERIAL_CATEGORY_CODES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.JeecgBaseConfig;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouseArea;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaService;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaCapacityCfgService;
|
||||
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslWarehouseAreaCapacityMatchVO;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
@@ -50,6 +52,9 @@ public class MesXslWarehouseAreaController extends JeecgController<MesXslWarehou
|
||||
@Autowired
|
||||
private MesXslStompNotifyService stompNotify;
|
||||
|
||||
@Autowired
|
||||
private IMesXslWarehouseAreaCapacityCfgService mesXslWarehouseAreaCapacityCfgService;
|
||||
|
||||
@Operation(summary = "MES库区管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MesXslWarehouseArea>> queryPageList(
|
||||
@@ -182,6 +187,22 @@ public class MesXslWarehouseAreaController extends JeecgController<MesXslWarehou
|
||||
return Result.OK(entity);
|
||||
}
|
||||
|
||||
@Operation(summary = "MES库区管理-匹配仓库配置(实际存放量按原材料卡片汇总的分类)")
|
||||
@RequiresPermissions("xslmes:mes_xsl_warehouse_area:capacityMatch")
|
||||
@GetMapping(value = "/capacityMatchConfig")
|
||||
public Result<MesXslWarehouseAreaCapacityMatchVO> capacityMatchConfig() {
|
||||
return Result.OK(mesXslWarehouseAreaCapacityCfgService.getCapacityMatchForEdit());
|
||||
}
|
||||
|
||||
@AutoLog(value = "MES库区管理-保存匹配仓库配置")
|
||||
@Operation(summary = "MES库区管理-保存匹配仓库配置")
|
||||
@RequiresPermissions("xslmes:mes_xsl_warehouse_area:capacityMatch")
|
||||
@PostMapping(value = "/capacityMatchConfig")
|
||||
public Result<String> saveCapacityMatchConfig(@RequestBody MesXslWarehouseAreaCapacityMatchVO vo) {
|
||||
mesXslWarehouseAreaCapacityCfgService.saveCapacityMatch(vo);
|
||||
return Result.OK("保存成功");
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_warehouse_area:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MesXslWarehouseArea mesXslWarehouseArea) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.common.system.base.entity.JeecgEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 库区「实际存放量」展示回填规则(按租户;匹配哪些仓库分类走原材料卡片汇总)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("mes_xsl_warehouse_area_capacity_cfg")
|
||||
@Schema(description = "MES库区实际存放量回填配置")
|
||||
public class MesXslWarehouseAreaCapacityCfg extends JeecgEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "是否启用回填 0否 1是")
|
||||
private Integer enabled;
|
||||
|
||||
@Schema(description = "仓库分类 sys_category.id,逗号分隔")
|
||||
private String warehouseCategoryIds;
|
||||
|
||||
@Schema(description = "仓库分类编码,逗号分隔")
|
||||
private String warehouseCategoryCodes;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private Integer tenantId;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouseAreaCapacityCfg;
|
||||
|
||||
/**
|
||||
* MES 库区实际存放量回填规则
|
||||
*/
|
||||
public interface MesXslWarehouseAreaCapacityCfgMapper extends BaseMapper<MesXslWarehouseAreaCapacityCfg> {}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import org.jeecg.modules.xslmes.vo.MesXslWarehouseAreaCapacityMatchVO;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 库区「实际存放量」回填:页面配置存储 + 运行时解析
|
||||
*/
|
||||
public interface IMesXslWarehouseAreaCapacityCfgService {
|
||||
|
||||
/**
|
||||
* 弹窗回显:库内有配置读库;否则回显 YAML / 默认编码(configSource 区分)
|
||||
*/
|
||||
MesXslWarehouseAreaCapacityMatchVO getCapacityMatchForEdit();
|
||||
|
||||
/** 保存或更新当前租户配置 */
|
||||
void saveCapacityMatch(MesXslWarehouseAreaCapacityMatchVO vo);
|
||||
|
||||
/** 是否启用回填(库内 saved=0 则关闭,不回落 YAML) */
|
||||
boolean isActualCapacityBackfillEnabled();
|
||||
|
||||
/**
|
||||
* 参与「原材料卡片 remaining 汇总」的仓库分类 sys_category.id 集合。
|
||||
* 无库内记录时等同原 YAML + 编码解析逻辑。
|
||||
*/
|
||||
Set<String> resolveRawMaterialWarehouseCategoryIds();
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
import org.jeecg.modules.xslmes.config.XslMesWarehouseAreaCapacityProperties;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslWarehouseAreaCapacityCfg;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslWarehouseAreaCapacityCfgMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslWarehouseAreaCapacityCfgService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslWarehouseAreaCapacityMatchVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 库区实际存放量回填规则(租户级页面配置)
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MesXslWarehouseAreaCapacityCfgServiceImpl extends ServiceImpl<MesXslWarehouseAreaCapacityCfgMapper, MesXslWarehouseAreaCapacityCfg>
|
||||
implements IMesXslWarehouseAreaCapacityCfgService {
|
||||
|
||||
private final XslMesWarehouseAreaCapacityProperties yamlProperties;
|
||||
private final ISysCategoryService sysCategoryService;
|
||||
|
||||
/** 当前租户下已保存的配置(无记录则返回 null,走 YAML 兜底) */
|
||||
private MesXslWarehouseAreaCapacityCfg findTenantRowStrict() {
|
||||
int tid = resolveTenantIdBestEffort();
|
||||
if (tid <= 0) {
|
||||
return null;
|
||||
}
|
||||
return this.lambdaQuery().eq(MesXslWarehouseAreaCapacityCfg::getTenantId, tid).last("LIMIT 1").one();
|
||||
}
|
||||
|
||||
private int resolveTenantIdBestEffort() {
|
||||
String t = TenantContext.getTenant();
|
||||
if (oConvertUtils.isEmpty(t)) {
|
||||
try {
|
||||
t = TokenUtils.getTenantIdByRequest(SpringContextUtils.getHttpServletRequest());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return oConvertUtils.getInt(t, 0);
|
||||
}
|
||||
|
||||
/** 页面保存必须用有效租户 */
|
||||
private int requireTenantIdForSave() {
|
||||
int tid = resolveTenantIdBestEffort();
|
||||
if (tid <= 0) {
|
||||
throw new JeecgBootException("未获取到租户信息,无法保存匹配仓库配置");
|
||||
}
|
||||
return tid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MesXslWarehouseAreaCapacityMatchVO getCapacityMatchForEdit() {
|
||||
MesXslWarehouseAreaCapacityCfg row = findTenantRowStrict();
|
||||
MesXslWarehouseAreaCapacityMatchVO vo = new MesXslWarehouseAreaCapacityMatchVO();
|
||||
if (row != null) {
|
||||
vo.setEnabled(Integer.valueOf(1).equals(row.getEnabled()));
|
||||
vo.setWarehouseCategoryIds(StringUtils.trimToEmpty(row.getWarehouseCategoryIds()));
|
||||
vo.setWarehouseCategoryCodes(StringUtils.trimToEmpty(row.getWarehouseCategoryCodes()));
|
||||
vo.setRemark(row.getRemark());
|
||||
vo.setConfigSource("db");
|
||||
vo.setBootstrapHint(null);
|
||||
return vo;
|
||||
}
|
||||
vo.setEnabled(yamlProperties.isEnabled());
|
||||
vo.setWarehouseCategoryIds("");
|
||||
List<String> codes = yamlProperties.getRawMaterialWarehouseCategoryCodes();
|
||||
if (codes != null && !codes.isEmpty()) {
|
||||
vo.setWarehouseCategoryCodes(codes.stream().filter(StringUtils::isNotBlank).map(String::trim).collect(Collectors.joining(",")));
|
||||
} else {
|
||||
vo.setWarehouseCategoryCodes("");
|
||||
}
|
||||
vo.setRemark(null);
|
||||
vo.setBootstrapHint("尚未保存页面配置:当前展示为服务端 YAML 兜底,保存后以库内配置为准。");
|
||||
vo.setConfigSource("yaml");
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveCapacityMatch(MesXslWarehouseAreaCapacityMatchVO vo) {
|
||||
if (vo == null) {
|
||||
return;
|
||||
}
|
||||
boolean en = Boolean.TRUE.equals(vo.getEnabled());
|
||||
String ids = normalizeCsv(vo.getWarehouseCategoryIds());
|
||||
String codes = normalizeCsv(vo.getWarehouseCategoryCodes());
|
||||
String remark = StringUtils.trimToNull(vo.getRemark());
|
||||
|
||||
int tenantId = requireTenantIdForSave();
|
||||
MesXslWarehouseAreaCapacityCfg row = findTenantRowStrict();
|
||||
LoginUser user = SecurityUtils.getSubject() != null && SecurityUtils.getSubject().getPrincipal() instanceof LoginUser
|
||||
? (LoginUser) SecurityUtils.getSubject().getPrincipal()
|
||||
: null;
|
||||
String username = user != null ? user.getUsername() : null;
|
||||
java.util.Date now = new java.util.Date();
|
||||
|
||||
if (row == null) {
|
||||
row = new MesXslWarehouseAreaCapacityCfg();
|
||||
row.setTenantId(tenantId);
|
||||
row.setEnabled(en ? 1 : 0);
|
||||
row.setWarehouseCategoryIds(StringUtils.isBlank(ids) ? null : ids);
|
||||
row.setWarehouseCategoryCodes(StringUtils.isBlank(codes) ? null : codes);
|
||||
row.setRemark(remark);
|
||||
row.setCreateBy(username);
|
||||
row.setCreateTime(now);
|
||||
row.setUpdateBy(username);
|
||||
row.setUpdateTime(now);
|
||||
this.save(row);
|
||||
} else {
|
||||
row.setEnabled(en ? 1 : 0);
|
||||
row.setWarehouseCategoryIds(StringUtils.isBlank(ids) ? null : ids);
|
||||
row.setWarehouseCategoryCodes(StringUtils.isBlank(codes) ? null : codes);
|
||||
row.setRemark(remark);
|
||||
row.setUpdateBy(username);
|
||||
row.setUpdateTime(now);
|
||||
this.updateById(row);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActualCapacityBackfillEnabled() {
|
||||
MesXslWarehouseAreaCapacityCfg row = findTenantRowStrict();
|
||||
if (row != null) {
|
||||
return Integer.valueOf(1).equals(row.getEnabled());
|
||||
}
|
||||
return yamlProperties.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> resolveRawMaterialWarehouseCategoryIds() {
|
||||
MesXslWarehouseAreaCapacityCfg row = findTenantRowStrict();
|
||||
if (row != null) {
|
||||
if (!Integer.valueOf(1).equals(row.getEnabled())) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return mergeCategoryIds(row.getWarehouseCategoryIds(), row.getWarehouseCategoryCodes());
|
||||
}
|
||||
if (!yamlProperties.isEnabled()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return mergeYamlCategoryIds();
|
||||
}
|
||||
|
||||
/** 逗号拆分并 trim */
|
||||
private static List<String> splitComma(String csv) {
|
||||
if (StringUtils.isBlank(csv)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(csv.split(",")).map(String::trim).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static String normalizeCsv(String raw) {
|
||||
if (StringUtils.isBlank(raw)) {
|
||||
return "";
|
||||
}
|
||||
return splitComma(raw).stream().distinct().collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
private Set<String> mergeCategoryIds(String idsCsv, String codesCsv) {
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String id : splitComma(idsCsv)) {
|
||||
set.add(id);
|
||||
}
|
||||
for (String code : splitComma(codesCsv)) {
|
||||
resolveCode(code).ifPresent(set::add);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
private Optional<String> resolveCode(String code) {
|
||||
try {
|
||||
String id = sysCategoryService.queryIdByCode(code);
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
return Optional.of(id.trim());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.warn("[WarehouseAreaCapacityCfg] 分类编码解析失败 code={}: {}", code, ex.getMessage());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private Set<String> mergeYamlCategoryIds() {
|
||||
Set<String> set = new HashSet<>();
|
||||
Collection<String> yamlIds = yamlProperties.getRawMaterialWarehouseCategoryIds();
|
||||
if (yamlIds != null) {
|
||||
for (String id : yamlIds) {
|
||||
if (StringUtils.isNotBlank(id)) {
|
||||
set.add(id.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
Collection<String> yamlCodes = yamlProperties.getRawMaterialWarehouseCategoryCodes();
|
||||
if (yamlCodes != null) {
|
||||
for (String c : yamlCodes) {
|
||||
if (StringUtils.isBlank(c)) {
|
||||
continue;
|
||||
}
|
||||
resolveCode(c.trim()).ifPresent(set::add);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 库区管理「匹配仓库」配置(读写)
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "库区实际存放量回填-匹配仓库配置")
|
||||
public class MesXslWarehouseAreaCapacityMatchVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "是否启用回填")
|
||||
private Boolean enabled;
|
||||
|
||||
/** 与前端 JCategorySelect 多选一致:sys_category.id 逗号分隔 */
|
||||
@Schema(description = "MES仓库分类ID,逗号分隔")
|
||||
private String warehouseCategoryIds;
|
||||
|
||||
@Schema(description = "MES仓库分类编码,逗号分隔(可选补充,与 YAML 兜底逻辑一致)")
|
||||
private String warehouseCategoryCodes;
|
||||
|
||||
@Schema(description = "配置来源 db=库内已保存 yaml=暂无库内配置使用文件兜底 preview")
|
||||
private String configSource;
|
||||
|
||||
@Schema(description = "首次打开且无库内配置时给出的提示(不落库)")
|
||||
private String bootstrapHint;
|
||||
|
||||
@Schema(description = "备注(落库)")
|
||||
private String remark;
|
||||
}
|
||||
Reference in New Issue
Block a user