You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
6.0 KiB
166 lines
6.0 KiB
package com.spring.ifs.bean;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.spring.ifs.api.IfsServer;
|
|
import com.spring.ifs.api.MasterPartApi;
|
|
import com.spring.modules.part.entity.APIEntity.PartIfsCatalog;
|
|
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.Map;
|
|
|
|
/**
|
|
* @description: 物料件的实现类
|
|
* @author LR
|
|
* @date 2024/12/9 11:49
|
|
* @version 1.0
|
|
*/
|
|
@Component
|
|
public class MasterServiceBean {
|
|
|
|
@Autowired
|
|
private IfsServer ifsServer;
|
|
private static final Logger logger = LoggerFactory.getLogger(MasterServiceBean.class);
|
|
|
|
/**
|
|
* @description: 查询物料件的信息
|
|
* @author LR
|
|
* @date 2024/12/9 13:28
|
|
* @version 1.0
|
|
*/
|
|
public Map<String, String> getMasterPart(Server srv, PartIfsCatalog inData) {
|
|
//公共参数
|
|
Map<String, String> returnMap = new HashMap<>();
|
|
String partNo = inData.getPartNo();
|
|
try {
|
|
//获取参数
|
|
Map<String, String> resultMap = MasterPartApi.getMasterPart(srv, partNo);
|
|
//判断是否存在
|
|
if (null == resultMap) {
|
|
throw new RuntimeException("当前物料件不存在!");
|
|
} else {
|
|
//设置IFS信息
|
|
//设置ifs 信息
|
|
inData.setIfsRowId(resultMap.get("OBJID"));
|
|
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());
|
|
}
|
|
return returnMap;
|
|
}
|
|
|
|
/**
|
|
* @description: master part 新增
|
|
* @author LR
|
|
* @date 2024/12/12 15:33
|
|
* @version 1.0
|
|
*/
|
|
public Map<String, String> syncPartCatalog(Server srv, PartIfsCatalog inData) {
|
|
logger.info("Part Catalog 新增开始:"+ JSON.toJSONString(inData));
|
|
//公共参数
|
|
Map<String, String> returnMap = new HashMap<>();
|
|
String partNo = inData.getPartNo();
|
|
try{
|
|
Map<String, String> partMap = MasterPartApi.getMasterPart(srv, partNo);
|
|
//判断是否需要插入到ifs
|
|
if(partMap == null || partMap.size() == 0) {
|
|
Map<String, String> resultMap = MasterPartApi.insertMasterPart(srv, inData);
|
|
//设置ifs 信息
|
|
inData.setIfsRowId(resultMap.get("OBJID"));
|
|
inData.setIfsRowVersion(resultMap.get("OBJVERSION"));
|
|
}else {
|
|
throw new RuntimeException("物料件已存在!");
|
|
}
|
|
returnMap.put("resultCode", "200");
|
|
returnMap.put("obj", JSON.toJSONString(inData));
|
|
} catch(APException e){
|
|
returnMap.put("resultCode", "400");
|
|
returnMap.put("resultMsg", e.getMessage());
|
|
}
|
|
//打印日志
|
|
logger.info("Part Catalog 新增结束:"+JSON.toJSONString(inData));
|
|
//返回结果集
|
|
return returnMap;
|
|
}
|
|
|
|
/**
|
|
* @description: 调用修改的方法
|
|
* @author LR
|
|
* @date 2024/12/12 15:40
|
|
* @version 1.0
|
|
*/
|
|
public Map<String, String> modifyPartCatalog(Server srv, PartIfsCatalog inData) {
|
|
logger.info("Part Catalog 修改开始:"+JSON.toJSONString(inData));
|
|
//公共参数
|
|
Map<String, String> returnMap = new HashMap<>();
|
|
String partNo = inData.getPartNo();
|
|
try {
|
|
//查询数据
|
|
Map<String, String> partMap = MasterPartApi.getMasterPart(srv, partNo);
|
|
//判断是否需要插入到ifs
|
|
if (partMap == null && partMap.size() == 0) {
|
|
throw new RuntimeException("物料件不存在!");
|
|
} else {
|
|
//设置ifs 信息
|
|
inData.setIfsRowId(partMap.get("IFSROWID"));
|
|
inData.setIfsRowVersion(partMap.get("IFSROWVERSION"));
|
|
Map<String, String> resultMap = MasterPartApi.modifyMasterPart(srv, inData);
|
|
//设置ifs 信息
|
|
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("Part Catalog 修改结束:"+JSON.toJSONString(inData));
|
|
//返回结果集
|
|
return returnMap;
|
|
}
|
|
|
|
/**
|
|
* @description: 调用删除的方法
|
|
* @author LR
|
|
* @date 2024/12/12 15:40
|
|
* @version 1.0
|
|
*/
|
|
public Map<String, String> removePartCatalog(Server srv, PartIfsCatalog inData) {
|
|
logger.info("Part Catalog 删除开始:"+JSON.toJSONString(inData));
|
|
//公共参数
|
|
Map<String, String> returnMap = new HashMap<>();
|
|
String partNo = inData.getPartNo();
|
|
//查询数据
|
|
try{
|
|
Map<String, String> partMap = MasterPartApi.getMasterPart(srv, partNo);
|
|
//判断是否需要插入到ifs
|
|
if(partMap == null && partMap.size() == 0) {
|
|
throw new RuntimeException("物料件不存在!");
|
|
}else {
|
|
//设置ifs 信息
|
|
inData.setIfsRowId(partMap.get("IFSROWID"));
|
|
inData.setIfsRowVersion(partMap.get("IFSROWVERSION"));
|
|
MasterPartApi.removeMasterPart(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("Part Catalog 删除结束:"+JSON.toJSONString(inData));
|
|
//返回结果集
|
|
return returnMap;
|
|
}
|
|
|
|
|
|
}
|