From f2c6248f300d8795083a9e74e3c606ccc76c5fe8 Mon Sep 17 00:00:00 2001 From: DouDou <877258667@qq.com> Date: Wed, 10 Sep 2025 15:24:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=92=8C=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=B1=9E=E6=80=A7=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/spring/ifs/api/TechnicalClassApi.java | 54 +++++++++ .../spring/ifs/bean/TechnicalClassBean.java | 47 ++++++++ .../Tooling/service/impl/ToolServiceImpl.java | 104 +++++++++++++++--- 3 files changed, 188 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/spring/ifs/api/TechnicalClassApi.java b/src/main/java/com/spring/ifs/api/TechnicalClassApi.java index bfb49633..f7e28a51 100644 --- a/src/main/java/com/spring/ifs/api/TechnicalClassApi.java +++ b/src/main/java/com/spring/ifs/api/TechnicalClassApi.java @@ -1,11 +1,14 @@ package com.spring.ifs.api; +import com.spring.common.utils.DateUtils; import com.spring.ifs.utils.IfsConverterToMap; import com.spring.ifs.utils.IfsPlsqlUtils; import com.spring.modules.part.entity.APIEntity.PartIfsCatalogModel; import com.spring.modules.part.entity.APIEntity.PartIfsCatalogProperty; +import com.spring.modules.part.entity.APIEntity.PartIfsInventory; import ifs.fnd.ap.*; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; 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 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 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 returnlList = new ArrayList<>(); + //处理结果集 + List> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); + //获取数据转bean + for (int i = 0; i < resultList.size(); i++) { + Map 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: 插入技术等级的属性 * @author LR diff --git a/src/main/java/com/spring/ifs/bean/TechnicalClassBean.java b/src/main/java/com/spring/ifs/bean/TechnicalClassBean.java index a85546c5..cc4f34b5 100644 --- a/src/main/java/com/spring/ifs/bean/TechnicalClassBean.java +++ b/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 ifs.fnd.ap.APException; import ifs.fnd.ap.Server; +import org.apache.poi.ss.formula.functions.T; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -351,6 +352,52 @@ public class TechnicalClassBean { return returnMap; } + /** + * @description: 批量删除技术等级的集合数据 + * @author DouDou + * @date 2025/9/10 13:28 + * @version 1.0 + */ + public Map removeTechnicalClassAttributesByTechnicalClass(Server srv, PartIfsCatalogModel inData) { + logger.info("Technical Class Attributes 批量删除开始:"+JSON.toJSONString(inData)); + Map returnMap = new HashMap<>(); + // 公共参数 + String luName = inData.getLuName(); // + String keyRef = inData.getKeyRef(); // + try{ + //查询技术等级 + Map 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 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; + } + diff --git a/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java b/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java index 76675d94..2547aa12 100644 --- a/src/main/java/com/spring/modules/Tooling/service/impl/ToolServiceImpl.java +++ b/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("")){ //调用方法 传工具的属性 try { - //调用api方法执行技术等级的新增 - this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); + String luName = "ManufTool"; + String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; + int countFlag = this.checkIfsToolPropertyTemplate(srv, luName, keyRef); + //如果不存在 则调用新增 否则则调用修改 + if (countFlag == 0){ + //调用api方法执行技术等级的新增 + this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); + }else{ + //先删除再新增 + this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); + this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); + } } catch(Exception e){ //调用删除的api 删除传过去的ifs 工具信息 this.removeIfsToolInfo(srv, ifsToolData); @@ -281,11 +291,12 @@ public class ToolServiceImpl implements ToolService { }else if ("".equals(rawPropertyNo) && 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)){ //需要调用删除的接口即可 - this.removeIfsToolInfoPropertyTemplate(srv, site, toolId); + this.removeIfsToolInfoPropertyTemplate(srv, site, toolId, rawPropertyNo); } } //3.调用存储过程处理 工具的属性模版数据 @@ -369,6 +380,13 @@ public class ToolServiceImpl implements ToolService { String ifsPassword = ifsUser.getIfsPassword(); //获取链接 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); } @@ -378,6 +396,7 @@ public class ToolServiceImpl implements ToolService { toolDao.deleteToolInstanceDateByTool(inData); } + /** * @description: 调用存储过程删除工具的信息 * @author LR @@ -460,7 +479,18 @@ public class ToolServiceImpl implements ToolService { //2.调用api处理工具实例部分的属性数据 if(propertyNo != null && !propertyNo.equals("")){ - this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo); + //首选查询当前工具是否存在技术等级模版 如果存在则调用修改的方法 + //组装数据 + 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); + } } } catch (Exception e){ //2.调用IFS API接口 @@ -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 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) && !"".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)){ //需要调用删除的接口即可 - this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance); + this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, rawPropertyNo); } } //3.调用存储过程处理 工具的属性模版数据 @@ -656,6 +707,12 @@ public class ToolServiceImpl implements ToolService { String ifsPassword = ifsUser.getIfsPassword(); //获取链接 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方法 this.removeIfsToolInstance(srv, toolInstanceData); } @@ -950,7 +1007,7 @@ public class ToolServiceImpl implements ToolService { Map returnMap = toolServiceBean.removeToolHeader(srv, ifsTool); // 判断调用是否成功 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 * @version 1.0 */ - public void removeIfsToolInfoPropertyTemplate(Server srv, String site, String toolId) { + public void removeIfsToolInfoPropertyTemplate(Server srv, String site, String toolId, String propertyNo) { //查询ifs的使用的账号 PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; technicalClass.setLuName("ManufTool"); technicalClass.setKeyRef(keyRef); + //先删除技术等级的属性数据 + Map returnMap1 = technicalClassBean.removeTechnicalClassAttributesByTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap1.get("resultCode"))) { + throw new RuntimeException("Tool 技术等级属性 删除异常:" + returnMap1.get("resultMsg")); + } //调用ifs的api - Map returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass); + Map 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 * @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的使用的账号 PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; technicalClass.setLuName("ManufToolDetail"); technicalClass.setKeyRef(keyRef); + technicalClass.setTechnicalClass(propertyNo); + //先删除技术等级的属性数据 + Map returnMap1 = technicalClassBean.removeTechnicalClassAttributesByTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap1.get("resultCode"))) { + throw new RuntimeException("Tool 技术等级属性 删除异常:" + returnMap1.get("resultMsg")); + } //调用新的api方法 - Map returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass); + Map 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")); } } }