Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-mes-ext-v1.1
jun 9 months ago
commit f8d371a3e2

@ -18,6 +18,9 @@ public interface IMesConfigService {
@ApiOperation(value = "获取配置表模板代码") @ApiOperation(value = "获取配置表模板代码")
MesConfig getCfgValueByCode(String key); MesConfig getCfgValueByCode(String key);
@ApiOperation(value = "获取系统配置集合")
List<MesConfig> getConfigList(String organizeCode, String cfgCode, String cfgKey, String cfgType);
@ApiOperation(value = "根据分隔符验证是否存在元素的配置") @ApiOperation(value = "根据分隔符验证是否存在元素的配置")
Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item); Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item);

@ -51,31 +51,38 @@ public class MesConfigService implements IMesConfigService {
} }
@Override @Override
public Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item) { public List<MesConfig> getConfigList(String organizeCode, String cfgCode, String cfgKey, String cfgType) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(cfgCode, MesExtConstWords.CFG_CODE, packBean); DdlPreparedPack.getStringEqualPack(cfgCode, MesExtConstWords.CFG_CODE, packBean);
DdlPreparedPack.getStringEqualPack(cfgKey, MesExtConstWords.CFG_KEY, packBean); DdlPreparedPack.getStringEqualPack(cfgKey, MesExtConstWords.CFG_KEY, packBean);
DdlPreparedPack.getStringEqualPack(cfgType, MesExtConstWords.CFG_TYPE, packBean); DdlPreparedPack.getStringEqualPack(cfgType, MesExtConstWords.CFG_TYPE, packBean);
MesConfig config = configRepository.getByProperty(packBean); return configRepository.findByHqlWhere(packBean);
if (null == config || StringUtils.isEmpty(config.getCfgValue())) return false; }
List<String> cfgValueList = Arrays.asList(config.getCfgValue().split(splitStr));
@Override
public Boolean checkCfgValueIsContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, String item) {
String cfgValue = getAndMergeCfgValue(organizeCode, cfgCode, cfgKey, cfgType, splitStr);
if (StringUtils.isEmpty(cfgValue)) return false;
List<String> cfgValueList = Arrays.asList(cfgValue.split(splitStr));
return (!CollectionUtils.isEmpty(cfgValueList) && cfgValueList.contains(item)) ? true : false; return (!CollectionUtils.isEmpty(cfgValueList) && cfgValueList.contains(item)) ? true : false;
} }
private String getAndMergeCfgValue(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr) {
List<MesConfig> configList = getConfigList(organizeCode, cfgCode, cfgKey, cfgType);
if (CollectionUtils.isEmpty(configList)) return null;
return configList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCfgValue()))).map(MesConfig::getCfgValue).collect(Collectors.joining(splitStr));
}
@Override @Override
public Boolean checkShardingTablesObjectCfg(String organizeCode, String cfgKey, String item) { public Boolean checkShardingTablesObjectCfg(String organizeCode, String cfgKey, String item) {
return checkCfgValueIsContainItem(organizeCode, MesExtConstWords.MES_SHARDING_TABLES_OBJECT_CFG, cfgKey, CommonEnumUtil.SOFT_TYPE.MES.name(), MesExtConstWords.SEMICOLON, item); return checkCfgValueIsContainItem(organizeCode, MesExtConstWords.MES_SHARDING_TABLES_OBJECT_CFG, cfgKey, CommonEnumUtil.SOFT_TYPE.MES.name(), MesExtConstWords.COMMA, item);
} }
@Override @Override
public List<String> findCfgValueContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, List<String> itemList) { public List<String> findCfgValueContainItem(String organizeCode, String cfgCode, String cfgKey, String cfgType, String splitStr, List<String> itemList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); String cfgValue = getAndMergeCfgValue(organizeCode, cfgCode, cfgKey, cfgType, splitStr);
DdlPreparedPack.getStringEqualPack(cfgCode, MesExtConstWords.CFG_CODE, packBean); if (StringUtils.isEmpty(cfgValue)) return null;
DdlPreparedPack.getStringEqualPack(cfgKey, MesExtConstWords.CFG_KEY, packBean); List<String> cfgValueList = Arrays.asList(cfgValue.split(splitStr));
DdlPreparedPack.getStringEqualPack(cfgType, MesExtConstWords.CFG_TYPE, packBean);
MesConfig config = configRepository.getByProperty(packBean);
if (null == config || StringUtils.isEmpty(config.getCfgValue())) return null;
List<String> cfgValueList = Arrays.asList(config.getCfgValue().split(splitStr));
if (CollectionUtils.isEmpty(cfgValueList)) return null; if (CollectionUtils.isEmpty(cfgValueList)) return null;
return itemList.stream().filter(cfgValueList::contains).collect(Collectors.toList()); return itemList.stream().filter(cfgValueList::contains).collect(Collectors.toList());
} }
@ -83,7 +90,7 @@ public class MesConfigService implements IMesConfigService {
@Override @Override
public List<String> findShardingTablesObjectCfg(String organizeCode, String cfgKey, List<String> itemList) { public List<String> findShardingTablesObjectCfg(String organizeCode, String cfgKey, List<String> itemList) {
if(CollectionUtils.isEmpty(itemList)) return null; if(CollectionUtils.isEmpty(itemList)) return null;
return findCfgValueContainItem(organizeCode, MesExtConstWords.MES_SHARDING_TABLES_OBJECT_CFG, cfgKey, CommonEnumUtil.SOFT_TYPE.MES.name(), MesExtConstWords.SEMICOLON, itemList); return findCfgValueContainItem(organizeCode, MesExtConstWords.MES_SHARDING_TABLES_OBJECT_CFG, cfgKey, CommonEnumUtil.SOFT_TYPE.MES.name(), MesExtConstWords.COMMA, itemList);
} }
} }

Loading…
Cancel
Save