|
|
|
@ -1,6 +1,9 @@ |
|
|
|
package com.spring.modules.Tooling.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.spring.ifs.api.IfsServer; |
|
|
|
import com.spring.ifs.bean.ToolServiceBean; |
|
|
|
import com.spring.modules.Tooling.dao.BaseConfigDao; |
|
|
|
import com.spring.modules.Tooling.data.*; |
|
|
|
import com.spring.modules.Tooling.dao.ToolDao; |
|
|
|
@ -12,6 +15,10 @@ import com.spring.modules.base.utils.DateUtils; |
|
|
|
import com.spring.modules.base.utils.HttpClientUtil; |
|
|
|
import com.spring.modules.base.utils.ResponseData; |
|
|
|
import com.spring.modules.report.dao.ProcedureDao; |
|
|
|
import com.spring.modules.sys.dao.SysUserDao; |
|
|
|
import com.spring.modules.sys.entity.SysUserEntity; |
|
|
|
import ifs.fnd.ap.Server; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
@ -38,11 +45,17 @@ public class ToolServiceImpl implements ToolService { |
|
|
|
private ProcedureDao procedureDao; |
|
|
|
@Autowired |
|
|
|
private BaseConfigDao baseConfigDao; |
|
|
|
@Autowired |
|
|
|
private ToolServiceBean toolServiceBean; |
|
|
|
@Autowired |
|
|
|
private SysUserDao sysUserDao; |
|
|
|
|
|
|
|
@Value("${ifs-api.api-url}") |
|
|
|
private String apiUrl; |
|
|
|
@Value("${ifs-control.control-flag}") |
|
|
|
private Boolean controlFlag; |
|
|
|
@Autowired |
|
|
|
private IfsServer ifsServer; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ToolInfo> getToolInfoList(IfsTool inData) { |
|
|
|
@ -135,13 +148,25 @@ public class ToolServiceImpl implements ToolService { |
|
|
|
BeanUtils.copyProperties(inData, ifsToolData); |
|
|
|
//2.校验存在调用接口 |
|
|
|
if (controlFlag) { |
|
|
|
String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs"; |
|
|
|
/*String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs"; |
|
|
|
ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsToolData); |
|
|
|
if (!"200".equals(toolResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); |
|
|
|
}*/ |
|
|
|
//获取当前操作的账号 |
|
|
|
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); |
|
|
|
SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper<SysUserEntity>().eq("username", username)); |
|
|
|
if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { |
|
|
|
throw new RuntimeException("获取用户的IFS账号密码为空值!"); |
|
|
|
} |
|
|
|
String ifsUsername = ifsUser.getIfsUsername(); |
|
|
|
String ifsPassword = ifsUser.getIfsPassword(); |
|
|
|
//获取链接 |
|
|
|
Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); |
|
|
|
//调用新的api方法 |
|
|
|
Map<String, String> returnMap = toolServiceBean.syncToolHeader(srv, ifsToolData); |
|
|
|
// 更新 ifs_row_id ifs_row_version |
|
|
|
String objStr = String.valueOf(toolResponse.getObj()); |
|
|
|
String objStr = returnMap.get("objStr"); |
|
|
|
ToolInfo ifsTool = JSON.parseObject(objStr, ToolInfo.class); |
|
|
|
inData.setIfsRowId(ifsTool.getIfsRowId()); |
|
|
|
inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); |
|
|
|
@ -150,10 +175,11 @@ public class ToolServiceImpl implements ToolService { |
|
|
|
//属性拷贝 |
|
|
|
BeanUtils.copyProperties(inData, toolInstance); |
|
|
|
toolInstance.setToolInstance(toolId); |
|
|
|
toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; |
|
|
|
toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstance); |
|
|
|
if (!"200".equals(toolResponse.getCode())) { |
|
|
|
throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); |
|
|
|
//调用api 删除已经产生的默认工具实例 |
|
|
|
//调用新的api方法 |
|
|
|
Map<String, String> removeMap = toolServiceBean.removeToolInstance(srv, toolInstance); |
|
|
|
if (!"200".equals(removeMap.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS ToolInstance新增异常:" + removeMap.get("resultMsg")); |
|
|
|
} |
|
|
|
|
|
|
|
//2.调用api处理属性部分的api数据 |
|
|
|
|