Browse Source

工具和工具实例属性维护

master
DouDou 4 months ago
parent
commit
f2c6248f30
  1. 54
      src/main/java/com/spring/ifs/api/TechnicalClassApi.java
  2. 47
      src/main/java/com/spring/ifs/bean/TechnicalClassBean.java
  3. 98
      src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java

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

@ -1,11 +1,14 @@
package com.spring.ifs.api; package com.spring.ifs.api;
import com.spring.common.utils.DateUtils;
import com.spring.ifs.utils.IfsConverterToMap; import com.spring.ifs.utils.IfsConverterToMap;
import com.spring.ifs.utils.IfsPlsqlUtils; import com.spring.ifs.utils.IfsPlsqlUtils;
import com.spring.modules.part.entity.APIEntity.PartIfsCatalogModel; import com.spring.modules.part.entity.APIEntity.PartIfsCatalogModel;
import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty; import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty;
import com.spring.modules.part.entity.APIEntity.PartIfsInventory;
import ifs.fnd.ap.*; import ifs.fnd.ap.*;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -239,6 +242,57 @@ public class TechnicalClassApi {
} }
} }
/**
* @description: 插叙技术等级属性值的集合
* @author DouDou
* @date 2025/9/10 13:25
* @version 1.0
*/
public static List<PartIfsCatalogProperty> getTechnicalAttributeList(Server srv, String technicalSpecNo, String technicalClass) throws APException {
StringBuilder searchSql = new StringBuilder();
searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, TECHNICAL_SPEC_NO, TECHNICAL_CLASS, ATTRIB_NUMBER, ATTRIBUTE,");
searchSql.append(" VALUE_NO, VALUE_TEXT, LOWER_LIMIT, UPPER_LIMIT, INFO, ALT_VALUE_NO, ALT_UNIT,");
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 new ArrayList<>();
} else {
List<PartIfsCatalogProperty> returnlList = new ArrayList<>();
//处理结果集
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
//获取数据转bean
for (int i = 0; i < resultList.size(); i++) {
Map<String, String> tempMap = resultList.get(i);
PartIfsCatalogProperty tempItem = new PartIfsCatalogProperty();
//设置参数
tempItem.setIfsRowId(tempMap.get("IFSROWID"));
tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
tempItem.setTechnicalSpecNo(tempMap.get("TECHNICAL_SPEC_NO"));
tempItem.setTechnicalClass(tempMap.get("TECHNICAL_CLASS"));
tempItem.setAttributeType(tempMap.get("ATTRIBUTETYPE"));
tempItem.setAttribute(tempMap.get("ATTRIBUTE"));
tempItem.setValueNo(tempMap.get("VALUE_NO"));
tempItem.setValueText(tempMap.get("VALUE_TEXT"));
tempItem.setInfo(tempMap.get("INFO"));
tempItem.setLowerLimit(tempMap.get("LOWER_LIMIT"));
tempItem.setUpperLimit(tempMap.get("UPPER_LIMIT"));
//添加对象
returnlList.add(tempItem);
}
return returnlList;
}
}
/** /**
* @description: 插入技术等级的属性 * @description: 插入技术等级的属性
* @author LR * @author LR

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

@ -7,6 +7,7 @@ import com.spring.modules.part.entity.APIEntity.PartIfsCatalogModel;
import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty; import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty;
import ifs.fnd.ap.APException; import ifs.fnd.ap.APException;
import ifs.fnd.ap.Server; import ifs.fnd.ap.Server;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -351,6 +352,52 @@ public class TechnicalClassBean {
return returnMap; return returnMap;
} }
/**
* @description: 批量删除技术等级的集合数据
* @author DouDou
* @date 2025/9/10 13:28
* @version 1.0
*/
public Map<String, String> removeTechnicalClassAttributesByTechnicalClass(Server srv, PartIfsCatalogModel inData) {
logger.info("Technical Class Attributes 批量删除开始:"+JSON.toJSONString(inData));
Map<String, String> returnMap = new HashMap<>();
// 公共参数
String luName = inData.getLuName(); //
String keyRef = inData.getKeyRef(); //
try{
//查询技术等级
Map<String, String> technicalMap = TechnicalClassApi.getTechnicalClass(srv, luName, keyRef);
//判断查询导数据
if(technicalMap == null || technicalMap.isEmpty()) {
throw new APException("不存在此技术等级的信息!");
}
//设置唯一键和版本
String technicalSpecNo = technicalMap.get("TECHNICAL_SPEC_NO");
String technicalClass = technicalMap.get("TECHNICAL_CLASS");
logger.info("技术等级模版信息:"+JSON.toJSONString(technicalMap));
//查询属性集合批量删除
List<PartIfsCatalogProperty> resultList = TechnicalClassApi.getTechnicalAttributeList(srv, technicalSpecNo, technicalClass);
logger.info("技术等级属性集合信息:"+JSON.toJSONString(resultList));
//循环删除 只删除有数据的对象 ---没有对象的数据 不处理
for(PartIfsCatalogProperty tempData : resultList) {
logger.info("技术等级属性删除开始:"+JSON.toJSONString(tempData));
//api修改参数
TechnicalClassApi.removeTechnicalAttribute(srv, tempData);
logger.info("技术等级属性删除结束:"+JSON.toJSONString(tempData));
}
returnMap.put("resultCode", "200");
returnMap.put("obj", JSON.toJSONString(resultList));
} catch(APException e){
returnMap.put("resultCode", "400");
returnMap.put("resultMsg", e.getMessage());
logger.info("异常信息:"+e.getMessage());
}
//插入查询的记录数据
logger.info("Technical Class Attributes 批量删除结束:"+JSON.toJSONString(inData));
//返回结果集
return returnMap;
}

98
src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java

@ -180,8 +180,18 @@ public class ToolServiceImpl implements ToolService {
if(propertyNo != null && !propertyNo.equals("")){ if(propertyNo != null && !propertyNo.equals("")){
//调用方法 传工具的属性 //调用方法 传工具的属性
try { try {
String luName = "ManufTool";
String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^";
int countFlag = this.checkIfsToolPropertyTemplate(srv, luName, keyRef);
//如果不存在 则调用新增 否则则调用修改
if (countFlag == 0){
//调用api方法执行技术等级的新增 //调用api方法执行技术等级的新增
this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
}else{
//先删除再新增
this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
}
} catch(Exception e){ } catch(Exception e){
//调用删除的api 删除传过去的ifs 工具信息 //调用删除的api 删除传过去的ifs 工具信息
this.removeIfsToolInfo(srv, ifsToolData); this.removeIfsToolInfo(srv, ifsToolData);
@ -281,11 +291,12 @@ public class ToolServiceImpl implements ToolService {
}else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){ }else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){
//无需新增或者修改 //无需新增或者修改
}else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){ }else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){
//需要调用修改的接口即可
this.modifyIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
//需要调用先删除 后修改
this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, rawPropertyNo);
this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
}else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){ }else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){
//需要调用删除的接口即可 //需要调用删除的接口即可
this.removeIfsToolInfoPropertyTemplate(srv, site, toolId);
this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, rawPropertyNo);
} }
} }
//3.调用存储过程处理 工具的属性模版数据 //3.调用存储过程处理 工具的属性模版数据
@ -369,6 +380,13 @@ public class ToolServiceImpl implements ToolService {
String ifsPassword = ifsUser.getIfsPassword(); String ifsPassword = ifsUser.getIfsPassword();
//获取链接 //获取链接
Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword);
//存在则调用删除的方法
// 调用删除工具属性模版的方法 2025-09-10 LR 新增
String propertyNo = tool.getPropertyNo();
if (!(null == propertyNo || "".equals(propertyNo.trim()))){
//1.首先删掉属性值
this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo);
}
//校验删除调用接口 //校验删除调用接口
this.removeIfsToolInfo(srv, ifsToolData); this.removeIfsToolInfo(srv, ifsToolData);
} }
@ -378,6 +396,7 @@ public class ToolServiceImpl implements ToolService {
toolDao.deleteToolInstanceDateByTool(inData); toolDao.deleteToolInstanceDateByTool(inData);
} }
/** /**
* @description: 调用存储过程删除工具的信息 * @description: 调用存储过程删除工具的信息
* @author LR * @author LR
@ -460,8 +479,19 @@ public class ToolServiceImpl implements ToolService {
//2.调用api处理工具实例部分的属性数据 //2.调用api处理工具实例部分的属性数据
if(propertyNo != null && !propertyNo.equals("")){ if(propertyNo != null && !propertyNo.equals("")){
//首选查询当前工具是否存在技术等级模版 如果存在则调用修改的方法
//组装数据
String luName = "ManufToolDetail";
String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^";
int countFlag = this.checkIfsToolPropertyTemplate(srv, luName, keyRef);
//如果不存在 则调用新增 否则则调用修改
if (countFlag == 0){
this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
}else{
this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo); this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
} }
}
} catch (Exception e){ } catch (Exception e){
//2.调用IFS API接口 //2.调用IFS API接口
this.removeIfsToolInstance(srv, toolInstanceData); this.removeIfsToolInstance(srv, toolInstanceData);
@ -470,6 +500,25 @@ public class ToolServiceImpl implements ToolService {
} }
} }
/**
* @description: 查询技术等级是否存在
* @author DouDou
* @date 2025/9/10 10:54
* @version 1.0
*/
public int checkIfsToolPropertyTemplate(Server srv, String luName, String keyRef) {
PartIfsCatalogModel checkData = new PartIfsCatalogModel();
//设置参数
checkData.setLuName(luName);
checkData.setKeyRef(keyRef);
Map<String, String> returnMap = technicalClassBean.getTechnicalClass(srv, checkData);
// 判断调用是否成功
if (!"200".equals(returnMap.get("resultCode"))) {
return 0;
}else {
return 1;
}
}
/** /**
@ -591,11 +640,13 @@ public class ToolServiceImpl implements ToolService {
}else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){ }else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){
//无需新增或者修改 //无需新增或者修改
}else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){ }else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){
//需要调用删除的接口即可
this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, rawPropertyNo);
//需要调用修改的接口即可 //需要调用修改的接口即可
this.modifyIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
}else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){ }else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){
//需要调用删除的接口即可 //需要调用删除的接口即可
this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance);
this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, rawPropertyNo);
} }
} }
//3.调用存储过程处理 工具的属性模版数据 //3.调用存储过程处理 工具的属性模版数据
@ -656,6 +707,12 @@ public class ToolServiceImpl implements ToolService {
String ifsPassword = ifsUser.getIfsPassword(); String ifsPassword = ifsUser.getIfsPassword();
//获取链接 //获取链接
Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword);
//调用删除工具属性模版的方法 2025-09-10 LR 新增
String propertyNo = toolInstanceData.getPropertyNo();
if (!(null == propertyNo || "".equals(propertyNo.trim()))){
//1.先删除属性
this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo);
}
//调用新的api方法 //调用新的api方法
this.removeIfsToolInstance(srv, toolInstanceData); this.removeIfsToolInstance(srv, toolInstanceData);
} }
@ -950,7 +1007,7 @@ public class ToolServiceImpl implements ToolService {
Map<String, String> returnMap = toolServiceBean.removeToolHeader(srv, ifsTool); Map<String, String> returnMap = toolServiceBean.removeToolHeader(srv, ifsTool);
// 判断调用是否成功 // 判断调用是否成功
if (!"200".equals(returnMap.get("resultCode"))) { if (!"200".equals(returnMap.get("resultCode"))) {
throw new RuntimeException("Tool Header 新增异常:" + returnMap.get("resultMsg"));
throw new RuntimeException("Tool Header 删除异常:" + returnMap.get("resultMsg"));
} }
} }
@ -1068,17 +1125,23 @@ public class ToolServiceImpl implements ToolService {
* @date 2024/10/28 14:44 * @date 2024/10/28 14:44
* @version 1.0 * @version 1.0
*/ */
public void removeIfsToolInfoPropertyTemplate(Server srv, String site, String toolId) {
public void removeIfsToolInfoPropertyTemplate(Server srv, String site, String toolId, String propertyNo) {
//查询ifs的使用的账号 //查询ifs的使用的账号
PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); PartIfsCatalogModel technicalClass = new PartIfsCatalogModel();
String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^";
technicalClass.setLuName("ManufTool"); technicalClass.setLuName("ManufTool");
technicalClass.setKeyRef(keyRef); technicalClass.setKeyRef(keyRef);
//先删除技术等级的属性数据
Map<String, String> returnMap1 = technicalClassBean.removeTechnicalClassAttributesByTechnicalClass(srv, technicalClass);
// 判断调用是否成功
if (!"200".equals(returnMap1.get("resultCode"))) {
throw new RuntimeException("Tool 技术等级属性 删除异常:" + returnMap1.get("resultMsg"));
}
//调用ifs的api //调用ifs的api
Map<String, String> returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass);
Map<String, String> returnMap2 = technicalClassBean.removeTechnicalClass(srv, technicalClass);
// 判断调用是否成功 // 判断调用是否成功
if (!"200".equals(returnMap.get("resultCode"))) {
throw new RuntimeException("Tool 技术等级 删除异常:" + returnMap.get("resultMsg"));
if (!"200".equals(returnMap2.get("resultCode"))) {
throw new RuntimeException("Tool 技术等级模版 删除异常:" + returnMap2.get("resultMsg"));
} }
} }
@ -1139,17 +1202,24 @@ public class ToolServiceImpl implements ToolService {
* @date 2024/10/29 17:38 * @date 2024/10/29 17:38
* @version 1.0 * @version 1.0
*/ */
public void removeIfsToolInstancePropertyTemplate(Server srv, String site, String toolId, String toolInstance) {
public void removeIfsToolInstancePropertyTemplate(Server srv, String site, String toolId, String toolInstance, String propertyNo) {
//查询ifs的使用的账号 //查询ifs的使用的账号
PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); PartIfsCatalogModel technicalClass = new PartIfsCatalogModel();
String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^";
technicalClass.setLuName("ManufToolDetail"); technicalClass.setLuName("ManufToolDetail");
technicalClass.setKeyRef(keyRef); technicalClass.setKeyRef(keyRef);
technicalClass.setTechnicalClass(propertyNo);
//先删除技术等级的属性数据
Map<String, String> returnMap1 = technicalClassBean.removeTechnicalClassAttributesByTechnicalClass(srv, technicalClass);
// 判断调用是否成功
if (!"200".equals(returnMap1.get("resultCode"))) {
throw new RuntimeException("Tool 技术等级属性 删除异常:" + returnMap1.get("resultMsg"));
}
//调用新的api方法 //调用新的api方法
Map<String, String> returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass);
Map<String, String> returnMap2 = technicalClassBean.removeTechnicalClass(srv, technicalClass);
// 判断调用是否成功 // 判断调用是否成功
if (!"200".equals(returnMap.get("resultCode"))) {
throw new RuntimeException("Tool Instance技术等级 删除异常:" + returnMap.get("resultMsg"));
if (!"200".equals(returnMap2.get("resultCode"))) {
throw new RuntimeException("Tool Instance技术等级 删除异常:" + returnMap2.get("resultMsg"));
} }
} }
} }
Loading…
Cancel
Save