箱变物料推送增加物料分类过滤

This commit is contained in:
lihao 2025-11-13 10:10:15 +08:00
parent 3605f9ceb1
commit 4f9024fe8b
3 changed files with 75 additions and 2 deletions

View File

@ -39,6 +39,7 @@ public class MaterialPushToQmsAction implements ICommonAction {
private Map<String, String> configParams;
private BaseDAO dao;
public BaseDAO getDao() {
if (dao == null) {
dao = new BaseDAO();
@ -93,7 +94,10 @@ public class MaterialPushToQmsAction implements ICommonAction {
String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE,
"pk_marbasclass = '" + pk_marbasclass + "'");
// 计量单位
// 过滤物料分类
if(checkMrlType(mrlTypeName,configParams)){
continue;
}
Map unitMap = getGoodsInfo(pkMaterial);
// 1=未启用;2=已启用;3=已停用;
@ -157,6 +161,25 @@ public class MaterialPushToQmsAction implements ICommonAction {
Object map = (Object) getDao().executeQuery(sql, new ColumnProcessor());
return map;
}
private boolean checkMrlType(String mrlTypeName, Map<String, String> configParams) throws BusinessException {
// 从配置中获取目标类型字符串
String targetCode = configParams.get("mrlType");
// 配置为空则直接返回false
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
return false;
}
// 按逗号拆分多个类型
String[] typeItems = targetCode.split(",");
// 遍历每个类型检查是否以mrlTypeName为前缀
for (String typeCode : typeItems) {
// 跳过空字符串且判断当前类型是否以目标名称为前缀
if (!typeCode.isEmpty() && typeCode.startsWith(mrlTypeName)) {
return true;
}
}
// 无匹配则返回false
return false;
}
/**

View File

@ -118,7 +118,10 @@ public class MaterialToQmsPlugin implements IBackgroundWorkPlugin {
String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE,
"pk_marbasclass = '" + pk_marbasclass + "'");
// 计量单位
// 过滤物料分类
if(checkMrlType(mrlTypeName,configParams)){
continue;
}
Map unitMap = getGoodsInfo(pkMaterial);
// 1=未启用;2=已启用;3=已停用;
@ -181,6 +184,25 @@ public class MaterialToQmsPlugin implements IBackgroundWorkPlugin {
Object map = (Object) new BaseDAO().executeQuery(sql, new ColumnProcessor());
return map;
}
private boolean checkMrlType(String mrlTypeName, Map<String, String> configParams) throws BusinessException {
// 从配置中获取目标类型字符串
String targetCode = configParams.get("mrlType");
// 配置为空则直接返回false
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
return false;
}
// 按逗号拆分多个类型
String[] typeItems = targetCode.split(",");
// 遍历每个类型检查是否以mrlTypeName为前缀
for (String typeCode : typeItems) {
// 跳过空字符串且判断当前类型是否以目标名称为前缀
if (!typeCode.isEmpty() && typeCode.startsWith(mrlTypeName)) {
return true;
}
}
// 无匹配则返回false
return false;
}
/**
* 推送同步数据

View File

@ -98,6 +98,13 @@ public class MaterialToQmsListener implements IBusinessListener {
String pk_marbasclass = vo.getPk_marbasclass();
String mrlTypeName = MyHelper.getStrValByCondition(MarBasClassVO.getDefaultTableName(), MarBasClassVO.CODE,
"pk_marbasclass = '" + pk_marbasclass + "'");
// 过滤物料分类
if(checkMrlType(mrlTypeName,configParams)){
continue;
}
// ¼ÆÁ¿µ¥Î»
Map unitMap = getGoodsInfo(pkMaterial);
@ -149,6 +156,27 @@ public class MaterialToQmsListener implements IBusinessListener {
updateBs(pkMaterial);
}
}
private boolean checkMrlType(String mrlTypeName, Map<String, String> configParams) throws BusinessException {
// 从配置中获取目标类型字符串
String targetCode = configParams.get("mrlType");
// 配置为空则直接返回false
if (targetCode == null || nc.vo.am.common.util.StringUtils.isEmpty(targetCode)) {
return false;
}
// 按逗号拆分多个类型
String[] typeItems = targetCode.split(",");
// 遍历每个类型检查是否以mrlTypeName为前缀
for (String typeCode : typeItems) {
// 跳过空字符串且判断当前类型是否以目标名称为前缀
if (!typeCode.isEmpty() && typeCode.startsWith(mrlTypeName)) {
return true;
}
}
// 无匹配则返回false
return false;
}
private void updateBs(String pkMaterial) throws DAOException {
BaseDAO dao = new BaseDAO();
String sql = "update BD_MATERIAL set def36='Y' where pk_material='"