Browse Source

技术等级 BUG 修尬

master
Rui_Li 9 months ago
parent
commit
c4aed4b1f8
  1. 33
      src/main/java/com/spring/ifs/api/TechnicalClassApi.java
  2. 74
      src/main/java/com/spring/ifs/bean/TechnicalClassBean.java

33
src/main/java/com/spring/ifs/api/TechnicalClassApi.java

@ -175,6 +175,39 @@ public class TechnicalClassApi {
} }
} }
/**
* @description: 查询技术等级下的所有属性
* @author LR
* @date 2025/4/28 09:24
* @version 1.0
*/
public static List<Map<String, String>> getTechnicalAttributesMap(Server srv, String technicalSpecNo, String technicalClass) throws APException {
StringBuilder searchSql = new StringBuilder();
searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, ATTRIBUTE,");
searchSql.append(" VALUE_NO, LOWER_LIMIT, UPPER_LIMIT, INFO,");
searchSql.append(" CASE WHEN objtype = 'TechnicalSpecNumeric' THEN 'Numeric'");
searchSql.append(" WHEN objtype = 'TechnicalSpecAlphanum' THEN 'Alpha' ELSE '' END attributeType");
searchSql.append(" FROM ifsapp.TECHNICAL_SPECIFICATION_BOTH");
searchSql.append(" WHERE TECHNICAL_SPEC_NO = :technicalSpecNo AND TECHNICAL_CLASS = :technicalClass");
//设置查询的入参
Map<String, String> inParam = new HashMap<>();
inParam.put("technicalSpecNo", technicalSpecNo);
inParam.put("technicalClass", technicalClass);
//调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
//判断能否返回
if (recordCollection == null) {
return null;
} else {
// 集合转List
Record recordData = recordCollection.get(0);
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
//返回结果数据
return resultList;
}
}
/** /**
* @description: 查询技术等级的属性集合 * @description: 查询技术等级的属性集合
* @author LR * @author LR

74
src/main/java/com/spring/ifs/bean/TechnicalClassBean.java

@ -204,17 +204,17 @@ public class TechnicalClassBean {
//设置唯一键和版本 //设置唯一键和版本
String technicalSpecNo = technicalMap.get("TECHNICAL_SPEC_NO"); String technicalSpecNo = technicalMap.get("TECHNICAL_SPEC_NO");
String technicalClass = inData.getTechnicalClass(); String technicalClass = inData.getTechnicalClass();
//打印日志
//查询当前技术等级下的所有属性的数据
List<Map<String, String>> resultList = TechnicalClassApi.getTechnicalAttributesMap(srv, technicalSpecNo, technicalClass);
//打印日志
logger.info("Technical Class Attributes 最终批量修改:"+JSON.toJSONString(resultList));
logger.info("Technical Class Attributes 最终批量数量:"+JSON.toJSONString(resultList.size()));
//调用方法 获取需要修改的数据
List<PartIfsCatalogProperty> paramList = this.getAndCheckNeedUpdateList(resultList, inDatas);
//循环设置参数 //循环设置参数
for(PartIfsCatalogProperty tempData : inDatas) {
String attribute = tempData.getAttribute();
//查询属性信息
Map<String, String> attributeMap = TechnicalClassApi.getTechnicalAttribute(srv, technicalSpecNo, technicalClass, attribute);
if(attributeMap == null || attributeMap.isEmpty()) {
throw new APException("不存在此技术等级的属性信息!");
}
for(PartIfsCatalogProperty tempData : paramList) {
//设置替代的ifs的key //设置替代的ifs的key
tempData.setIfsRowId(attributeMap.get("IFSROWID"));
tempData.setIfsRowVersion(attributeMap.get("IFSROWVERSION"));
tempData.setTechnicalSpecNo(technicalSpecNo); tempData.setTechnicalSpecNo(technicalSpecNo);
//api修改参数 //api修改参数
Map<String, String> resultMap = TechnicalClassApi.modifyTechnicalAttribute(srv, tempData); Map<String, String> resultMap = TechnicalClassApi.modifyTechnicalAttribute(srv, tempData);
@ -234,6 +234,62 @@ public class TechnicalClassBean {
return returnMap; return returnMap;
} }
/**
* @description: 获取需要修改的数据 不需要修改的数据不再放入循环操作中
* @author LR
* @date 2025/4/28 09:45
* @version 1.0
*/
public List<PartIfsCatalogProperty> getAndCheckNeedUpdateList(List<Map<String, String>> resultList, List<PartIfsCatalogProperty> inDatas) {
//数据转Map 键为属性名称
Map<String, PartIfsCatalogProperty> newMap = new HashMap<>();
List<PartIfsCatalogProperty> updateList = new ArrayList<>();
//循环转换
for(PartIfsCatalogProperty bean : inDatas) {
newMap.put(bean.getAttribute(), bean);
}
//循环比较数据是否一直
for (Map<String, String> resultMap : resultList){
String attribute = resultMap.get("ATTRIBUTE"); // 属性编码
String attributeType = resultMap.get("ATTRIBUTETYPE"); // 属性类型
String valueText = resultMap.get("VALUE_TEXT"); // 文本值
String valueNo = resultMap.get("VALUE_NO"); // 数字值
//接口路传过来的新值
if (!newMap.containsKey(attribute)){
continue;
}
PartIfsCatalogProperty tempBean = newMap.get(attribute);
//针对文本和数据使用不同的比较方式
if(attributeType.equals("Alpha")) {
String newValueText = tempBean.getValueText();
//如果都是空字符串 或者都是null 跳过修改
if ((null == newValueText || "NULL".equalsIgnoreCase(newValueText) || newValueText.trim().isEmpty())
&& (null == valueText || "NULL".equalsIgnoreCase(valueText) || valueText.trim().isEmpty())){
continue;
}else if (newValueText.equals(valueText)){
continue;
}
} else if (attributeType.equals("Numeric")) {
String newValueNo = tempBean.getValueNo();
//如果都是空字符串 或者都是null 跳过修改
if ((null == newValueNo || "NULL".equalsIgnoreCase(newValueNo) || newValueNo.trim().isEmpty())
&& (null == valueNo || "NULL".equalsIgnoreCase(valueNo) || valueNo.trim().isEmpty())){
continue;
}else if (newValueNo.equals(valueNo)){
continue;
}
}
//添加ifsRowId ifsRowVersion
String ifsRowId = resultMap.get("IFSROWID");
String ifsRowVersion = resultMap.get("IFSROWVERSION");
tempBean.setIfsRowId(ifsRowId);
tempBean.setIfsRowVersion(ifsRowVersion);
updateList.add(tempBean);
}
//返回需要处理的数据
return updateList;
}
/** /**
* @description: 批量删除技术等级属性数据 * @description: 批量删除技术等级属性数据
* @author LR * @author LR

Loading…
Cancel
Save