7 changed files with 526 additions and 119 deletions
-
24src/main/java/com/spring/ifs/api/TechnicalClassApi.java
-
10src/main/java/com/spring/ifs/api/TechnicalClassApiTest.java
-
239src/main/java/com/spring/ifs/bean/TechnicalClassBean.java
-
259src/main/java/com/spring/ifs/bean/TechnicalClassBeanTest.java
-
106src/main/java/com/spring/ifs/controller/TestIfsController.java
-
3src/main/java/com/spring/modules/part/entity/APIEntity/PartIfsCatalogModel.java
-
4src/main/java/com/spring/modules/part/entity/APIEntity/PartIfsCatalogProperty.java
@ -0,0 +1,259 @@ |
|||
package com.spring.ifs.bean; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.spring.ifs.api.IfsServer; |
|||
import com.spring.ifs.api.TechnicalClassApi; |
|||
import com.spring.ifs.api.TechnicalClassApiTest; |
|||
import com.spring.ifs.data.TechnicalAttribute; |
|||
import com.spring.ifs.data.TechnicalClass; |
|||
import ifs.fnd.ap.APException; |
|||
import ifs.fnd.ap.Server; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @description: 技术等级实现类 |
|||
* @author LR |
|||
* @date 2024/12/9 11:49 |
|||
* @version 1.0 |
|||
*/ |
|||
@Component |
|||
public class TechnicalClassBeanTest { |
|||
|
|||
@Autowired |
|||
private IfsServer ifsServer; |
|||
|
|||
private static final Logger logger = LoggerFactory.getLogger(TechnicalClassBeanTest.class); |
|||
|
|||
/** |
|||
* @description: 查询技术等级 |
|||
* @author LR |
|||
* @date 2024/12/16 13:15 |
|||
* @version 1.0 |
|||
*/ |
|||
public Map<String, String> getTechnicalClass(TechnicalClass inData) throws APException { |
|||
logger.info("Technical Class 查询开始:"+ JSON.toJSONString(inData)); |
|||
//公共参数 |
|||
Map<String, String> returnMap = new HashMap<>(); |
|||
String username = inData.getIfsUsername(); |
|||
String password = inData.getIfsPassword(); |
|||
String luName = inData.getLuName(); // |
|||
String keyRef = inData.getKeyRef(); // |
|||
try{ |
|||
//获取连接 |
|||
Server srv = ifsServer.getIfsServer(username, password); |
|||
//查询对象 |
|||
Map<String, String> resultMap = TechnicalClassApi.getTechnicalClass(srv, luName, keyRef); |
|||
//判断查询导数据 |
|||
if(resultMap == null) { |
|||
throw new RuntimeException("查无此技术等级的信息!"); |
|||
} |
|||
//设置ifs 信息 |
|||
inData.setIfsRowId(resultMap.get("IFSROWID")); |
|||
inData.setIfsRowVersion(resultMap.get("IFSROWVERSION")); |
|||
returnMap.put("resultCode", "200"); |
|||
returnMap.put("obj", JSON.toJSONString(inData)); |
|||
} catch(APException e){ |
|||
returnMap.put("resultCode", "400"); |
|||
returnMap.put("resultMsg", e.getMessage()); |
|||
} |
|||
//打印日志 |
|||
logger.info("Technical Class 查询结束:"+JSON.toJSONString(inData)); |
|||
//返回结果集 |
|||
return returnMap; |
|||
} |
|||
|
|||
/** |
|||
* @description: 新增 |
|||
* @author LR |
|||
* @date 2024/12/16 13:37 |
|||
* @version 1.0 |
|||
*/ |
|||
public Map<String, String> syncTechnicalClass(TechnicalClass inData) throws APException { |
|||
logger.info("Technical Class 新增开始:"+JSON.toJSONString(inData)); |
|||
//公共参数 |
|||
Map<String, String> returnMap = new HashMap<>(); |
|||
String username = inData.getIfsUsername(); |
|||
String password = inData.getIfsPassword(); |
|||
String luName = inData.getLuName(); // |
|||
String keyRef = inData.getKeyRef(); // |
|||
try{ |
|||
//获取连接 |
|||
Server srv = ifsServer.getIfsServer(username, password); |
|||
//查询对象 |
|||
Map<String, String> technicalMap = TechnicalClassApi.getTechnicalClass(srv, luName, keyRef); |
|||
//判断查询导数据 |
|||
if(technicalMap != null && technicalMap.size() > 0) { |
|||
throw new RuntimeException("已存在此技术等级的信息!"); |
|||
} |
|||
|
|||
//调用api同步信息 |
|||
Map<String, String> resultMap = TechnicalClassApiTest.insertTechnicalClass(srv, inData); |
|||
//设置唯一键和版本 |
|||
inData.setIfsRowVersion(resultMap.get("OBJVERSION")); |
|||
returnMap.put("resultCode", "200"); |
|||
returnMap.put("obj", JSON.toJSONString(inData)); |
|||
} catch(APException e){ |
|||
returnMap.put("resultCode", "400"); |
|||
returnMap.put("resultMsg", e.getMessage()); |
|||
} |
|||
//插入查询的记录数据 |
|||
logger.info("Technical Class 新增结束:"+JSON.toJSONString(inData)); |
|||
//返回结果集 |
|||
return returnMap; |
|||
} |
|||
|
|||
/** |
|||
* @description: 修改技术等级的数据 |
|||
* @author LR |
|||
* @date 2024/12/16 13:45 |
|||
* @version 1.0 |
|||
*/ |
|||
public Map<String, String> modifyTechnicalClass(TechnicalClass inData) throws APException { |
|||
logger.info("Technical Class 修改开始:"+JSON.toJSONString(inData)); |
|||
//公共参数 |
|||
Map<String, String> returnMap = new HashMap<>(); |
|||
String username = inData.getIfsUsername(); |
|||
String password = inData.getIfsPassword(); |
|||
String luName = inData.getLuName(); // |
|||
String keyRef = inData.getKeyRef(); |
|||
try{ |
|||
//获取连接 |
|||
Server srv = ifsServer.getIfsServer(username, password); |
|||
//查询对象 |
|||
Map<String, String> technicalMap = TechnicalClassApiTest.getTechnicalClass(srv, luName, keyRef); |
|||
//判断查询导数据 |
|||
if(technicalMap == null || technicalMap.size() == 0) { |
|||
throw new RuntimeException("不存在此技术等级的信息!"); |
|||
} |
|||
//设置IFS的信息 |
|||
inData.setIfsRowId(technicalMap.get("IFSROWID")); |
|||
inData.setIfsRowVersion(technicalMap.get("IFSROWVERSION")); |
|||
|
|||
//调用api同步信息 |
|||
Map<String, String> resultMap = TechnicalClassApiTest.modifyTechnicalClass(srv, inData); |
|||
//设置唯一键和版本 |
|||
inData.setIfsRowVersion(resultMap.get("OBJVERSION")); |
|||
returnMap.put("resultCode", "200"); |
|||
returnMap.put("obj", JSON.toJSONString(inData)); |
|||
} catch(APException e){ |
|||
returnMap.put("resultCode", "400"); |
|||
returnMap.put("resultMsg", e.getMessage()); |
|||
} |
|||
//插入查询的记录数据 |
|||
logger.info("Technical Class 修改结束:"+JSON.toJSONString(inData)); |
|||
//返回结果集 |
|||
return returnMap; |
|||
} |
|||
|
|||
/** |
|||
* @description: 刪除技术等级的信息 |
|||
* @author LR |
|||
* @date 2024/12/16 13:46 |
|||
* @version 1.0 |
|||
*/ |
|||
public Map<String, String> removeTechnicalClass(TechnicalClass inData) throws APException { |
|||
logger.info("Technical Class 删除开始:"+JSON.toJSONString(inData)); |
|||
//公共参数 |
|||
Map<String, String> returnMap = new HashMap<>(); |
|||
String username = inData.getIfsUsername(); |
|||
String password = inData.getIfsPassword(); |
|||
String luName = inData.getLuName(); // |
|||
String keyRef = inData.getKeyRef(); // |
|||
try{ |
|||
//获取连接 |
|||
Server srv = ifsServer.getIfsServer(username, password); |
|||
//查询对象 |
|||
Map<String, String> technicalMap = TechnicalClassApiTest.getTechnicalClass(srv, luName, keyRef); |
|||
//判断查询导数据 |
|||
if(technicalMap == null || technicalMap.size() == 0) { |
|||
throw new RuntimeException("不存在此技术等级的信息!"); |
|||
} |
|||
//设置IFS的信息 |
|||
inData.setIfsRowId(technicalMap.get("IFSROWID")); |
|||
inData.setIfsRowVersion(technicalMap.get("IFSROWVERSION")); |
|||
//调用api同步信息 |
|||
TechnicalClassApiTest.removeTechnicalClass(srv, inData); |
|||
returnMap.put("resultCode", "200"); |
|||
returnMap.put("obj", JSON.toJSONString(inData)); |
|||
} catch(APException e){ |
|||
returnMap.put("resultCode", "400"); |
|||
returnMap.put("resultMsg", e.getMessage()); |
|||
} |
|||
//插入查询的记录数据 |
|||
logger.info("Technical Class 删除结束:"+JSON.toJSONString(inData)); |
|||
//返回结果集 |
|||
return returnMap; |
|||
} |
|||
|
|||
/** |
|||
* @description: 批量同步技术等级属性数据 |
|||
* @author LR |
|||
* @date 2024/12/19 15:02 |
|||
* @version 1.0 |
|||
*/ |
|||
public Map<String, String> modifyTechnicalClassAttributes(List<TechnicalAttribute> inDatas) throws APException { |
|||
logger.info("Technical Class Attributes 批量修改开始:"+JSON.toJSONString(inDatas)); |
|||
Map<String, String> returnMap = new HashMap<>(); |
|||
TechnicalAttribute inData = inDatas.get(0); |
|||
// 公共参数 |
|||
String username = inData.getIfsUsername(); |
|||
String password = inData.getIfsPassword(); |
|||
String luName = inData.getLuName(); // |
|||
String keyRef = inData.getKeyRef(); // |
|||
try{ |
|||
//获取连接 |
|||
Server srv = ifsServer.getIfsServer(username, password); |
|||
//查询技术等级 |
|||
Map<String, String> technicalMap = TechnicalClassApiTest.getTechnicalClass(srv, luName, keyRef); |
|||
//判断查询导数据 |
|||
//判断查询导数据 |
|||
if(technicalMap == null || technicalMap.size() == 0) { |
|||
throw new RuntimeException("不存在此技术等级的信息!"); |
|||
} |
|||
//设置唯一键和版本 |
|||
String technicalSpecNo = technicalMap.get("TECHNICAL_SPEC_NO"); |
|||
String technicalClass = inData.getTechnicalClass(); |
|||
//循环设置参数 |
|||
for(TechnicalAttribute tempData : inDatas) { |
|||
String attribute = tempData.getAttribute(); |
|||
//查询属性信息 |
|||
Map<String, String> attributeMap = TechnicalClassApiTest.getTechnicalAttribute(srv, technicalSpecNo, technicalClass, attribute); |
|||
if(attributeMap == null || attributeMap.size() == 0) { |
|||
throw new RuntimeException("不存在此技术等级的属性信息!"); |
|||
} |
|||
//设置替代的ifs的key |
|||
inData.setIfsRowId(attributeMap.get("IFSROWID")); |
|||
inData.setIfsRowVersion(attributeMap.get("IFSROWVERSION")); |
|||
inData.setTechnicalSpecNo(technicalSpecNo); |
|||
//api修改参数 |
|||
Map<String, String> resultMap = TechnicalClassApiTest.modifyTechnicalAttribute(srv, tempData); |
|||
//设置记录的版本 |
|||
inData.setIfsRowVersion(resultMap.get("OBJVERSION")); |
|||
} |
|||
returnMap.put("resultCode", "200"); |
|||
returnMap.put("obj", JSON.toJSONString(inDatas)); |
|||
} catch(APException e){ |
|||
returnMap.put("resultCode", "400"); |
|||
returnMap.put("resultMsg", e.getMessage()); |
|||
} |
|||
//插入查询的记录数据 |
|||
logger.info("Technical Class Attributes 批量修改结束:"+JSON.toJSONString(inDatas)); |
|||
//返回结果集 |
|||
return returnMap; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue