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 b299bba0..01d52fa6 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 @@ -3,6 +3,7 @@ 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.TechnicalClassBean; import com.spring.ifs.bean.ToolServiceBean; import com.spring.modules.Tooling.dao.BaseConfigDao; import com.spring.modules.Tooling.data.*; @@ -14,6 +15,7 @@ import com.spring.modules.Tooling.service.ToolService; 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.part.entity.APIEntity.PartIfsCatalogModel; import com.spring.modules.report.dao.ProcedureDao; import com.spring.modules.sys.dao.SysUserDao; import com.spring.modules.sys.entity.SysUserEntity; @@ -48,6 +50,8 @@ public class ToolServiceImpl implements ToolService { @Autowired private ToolServiceBean toolServiceBean; @Autowired + private TechnicalClassBean technicalClassBean; + @Autowired private SysUserDao sysUserDao; @Value("${ifs-api.api-url}") @@ -148,11 +152,6 @@ public class ToolServiceImpl implements ToolService { BeanUtils.copyProperties(inData, ifsToolData); //2.校验存在调用接口 if (controlFlag) { - /*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().eq("username", username)); @@ -163,89 +162,32 @@ public class ToolServiceImpl implements ToolService { String ifsPassword = ifsUser.getIfsPassword(); //获取链接 Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); - //调用新的api方法 - Map returnMap = toolServiceBean.syncToolHeader(srv, ifsToolData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Tool新增异常:" + returnMap.get("resultMsg")); - } - // 更新 ifs_row_id ifs_row_version - String objStr = returnMap.get("objStr"); - ToolInfo ifsTool = JSON.parseObject(objStr, ToolInfo.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + //调用api方法 处理工具新增 + this.syncIfsToolInfo(srv, ifsToolData); + //删除工具信息默认的工具实例信息 ToolInstance toolInstance = new ToolInstance(); //属性拷贝 BeanUtils.copyProperties(inData, toolInstance); toolInstance.setToolInstance(toolId); //调用api 删除已经产生的默认工具实例 - //调用新的api方法 - Map removeMap = toolServiceBean.removeToolInstance(srv, toolInstance); - if (!"200".equals(removeMap.get("resultCode"))) { - throw new RuntimeException("IFS ToolInstance删除异常:" + removeMap.get("resultMsg")); - } + this.removeIfsToolInstance(srv, toolInstance); //2.调用api处理属性部分的api数据 if(propertyNo != null && !propertyNo.equals("")){ //调用方法 传工具的属性 try { - this.syncIfsToolInfoPropertyTemplate(site, toolId, propertyNo); + //调用api方法执行技术等级的新增 + this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); } catch(Exception e){ - //1.调用删除的api - this.removeIfsToolInfo(ifsToolData); + //调用删除的api 删除传过去的ifs 工具信息 + this.removeIfsToolInfo(srv, ifsToolData); throw new RuntimeException("IFS Tool新增异常:" + e.getMessage()); } } } } - /** - * @description: 删除IFS的工具信息 - * @author LR - * @date 2024/10/29 14:17 - * @version 1.0 - */ - public void removeIfsToolInfo(ToolInfo ifsTool){ - //调用api删除上面方法传过去的工具信息 - String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsTool); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool删除异常:" + toolResponse.getMsg()); - } - } - - /** - * @description: 调用新增工具的属性模版 - * @author LR - * @date 2024/10/28 13:59 - * @version 1.0 - */ - public void syncIfsToolInfoPropertyTemplate(String site, String toolId, String propertyNo) { - //查询ifs的使用的账号 - BaseConfigData baseConfig = baseConfigDao.getBaseConfigBySiteAndType("ALL", "tool", "default_ifs_account"); - String okSign = baseConfig.getBaseData(); - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; - String dtOk = DateUtils.getStringDate(new Date(), "yyyy-MM-dd"); - technicalClass.setLuName("ManufTool"); - technicalClass.setKeyRef(keyRef); - technicalClass.setTechnicalSpecNo("0"); - technicalClass.setTechnicalClass(propertyNo); - technicalClass.setOkYesNo("Not Approved"); - technicalClass.setOkSign(okSign); - technicalClass.setDtOk(dtOk); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/syncTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - TechnicalClass ifsTool = JSON.parseObject(objStr, TechnicalClass.class); - } - /** * @description: 调用存储过程 校验工具新增 * @author LR @@ -301,15 +243,9 @@ public class ToolServiceImpl implements ToolService { ToolInfo ifsToolData = new ToolInfo(); //属性拷贝 BeanUtils.copyProperties(inData, ifsToolData); - + //只有需要传数据才获取连接 + Server srv = null; if (controlFlag) { - //2.校验存在调用接口 - /* String toolURL = apiUrl + "/tool/ifs/modifyToolDataToIfs"; - 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().eq("username", username)); @@ -319,19 +255,12 @@ public class ToolServiceImpl implements ToolService { String ifsUsername = ifsUser.getIfsUsername(); String ifsPassword = ifsUser.getIfsPassword(); //获取链接 - Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); - //调用新的api方法 - Map returnMap = toolServiceBean.modifyToolHeader(srv, ifsToolData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Tool修改异常:" + returnMap.get("resultMsg")); - } - + srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); + //调用新的api方法 处理工具的修改 + ToolInfo returnTool = this.modifyIfsToolInfo(srv, ifsToolData); // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(returnMap.get("obj")); - ToolInfo ifsTool = JSON.parseObject(objStr, ToolInfo.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + inData.setIfsRowId(returnTool.getIfsRowId()); + inData.setIfsRowVersion(returnTool.getIfsRowVersion()); } //查询数据 ToolInfo checkData = toolDao.getToolInfoByToolId(site, toolId); @@ -345,15 +274,15 @@ public class ToolServiceImpl implements ToolService { //判断各种类型 //1.原值不存在 新值存在 if("".equals(rawPropertyNo) && !rawPropertyNo.equals(propertyNo)){ - this.syncIfsToolInfoPropertyTemplate(site, toolId, propertyNo); + this.syncIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); }else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){ //无需新增或者修改 }else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){ //需要调用修改的接口即可 - this.modifyIfsToolInfoPropertyTemplate(site, toolId, propertyNo); + this.modifyIfsToolInfoPropertyTemplate(srv, site, toolId, propertyNo); }else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){ //需要调用删除的接口即可 - this.removeIfsToolInfoPropertyTemplate(site, toolId); + this.removeIfsToolInfoPropertyTemplate(srv, site, toolId); } } //3.调用存储过程处理 工具的属性模版数据 @@ -362,50 +291,6 @@ public class ToolServiceImpl implements ToolService { toolDao.updateToolInfo(inData); } - /** - * @description: 调用api的接口删除属性的模版 - * @author LR - * @date 2024/10/28 14:44 - * @version 1.0 - */ - public void removeIfsToolInfoPropertyTemplate(String site, String toolId) { - //查询ifs的使用的账号 - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; - technicalClass.setLuName("ManufTool"); - technicalClass.setKeyRef(keyRef); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/removeTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - } - - /** - * @description: 调用api的接口 - * @author LR - * @date 2024/10/28 14:42 - * @version 1.0 - */ - public void modifyIfsToolInfoPropertyTemplate(String site, String toolId, String propertyNo) { - //查询ifs的使用的账号 - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; - technicalClass.setLuName("ManufTool"); - technicalClass.setKeyRef(keyRef); - technicalClass.setTechnicalClass(propertyNo); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/modifyTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - TechnicalClass ifsTool = JSON.parseObject(objStr, TechnicalClass.class); - } - /** * @description: 调用存储过程处理 工具的属性模版数据 * @author LR @@ -471,8 +356,6 @@ public class ToolServiceImpl implements ToolService { //属性拷贝 BeanUtils.copyProperties(inData, ifsToolData); if (controlFlag) { - //1.校验删除调用接口 - //this.removeIfsToolInfo(ifsToolData); //获取当前操作的账号 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -483,12 +366,8 @@ public class ToolServiceImpl implements ToolService { String ifsPassword = ifsUser.getIfsPassword(); //获取链接 Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); - //调用新的api方法 - Map returnMap = toolServiceBean.removeToolHeader(srv, ifsToolData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Tool删除异常:" + returnMap.get("resultMsg")); - } + //校验删除调用接口 + this.removeIfsToolInfo(srv, ifsToolData); } //3.调用方法保存当前的数据 toolDao.deleteToolInfo(inData); @@ -560,12 +439,6 @@ public class ToolServiceImpl implements ToolService { } toolInstanceData.setLastCalibrationDate(lastCalibrationTime); - //2.校验存在调用接口 - /* String toolURL = apiUrl + "/tool/ifs/syncToolInstanceToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance新增异常:" + toolResponse.getMsg()); - }*/ //获取当前操作的账号 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -576,58 +449,26 @@ public class ToolServiceImpl implements ToolService { String ifsPassword = ifsUser.getIfsPassword(); //获取链接 Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); - //调用新的api方法 - Map returnMap = toolServiceBean.syncToolInstance(srv, toolInstanceData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Instance新增异常:" + returnMap.get("resultMsg")); - } - String objStr = String.valueOf(returnMap.get("obj")); - ToolInstance ifsTool = JSON.parseObject(objStr, ToolInstance.class); + //调用新的api方法 执行新增的方法 + ToolInfo returnTool = this.syncIfsToolInstance(srv, toolInstanceData); //设置版本号 - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + inData.setIfsRowId(returnTool.getIfsRowId()); + inData.setIfsRowVersion(returnTool.getIfsRowVersion()); //2.调用api处理工具实例部分的属性数据 if(propertyNo != null && !propertyNo.equals("")){ try { - this.syncIfsToolInstancePropertyTemplate(site, toolId, toolInstance, propertyNo); + this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo); } catch (Exception e){ //2.调用IFS API接口 - this.removeIfsToolInstance(toolInstanceData); + this.removeIfsToolInstance(srv, toolInstanceData); throw new RuntimeException(e.getMessage()); } } } } - /** - * @description: 同步库工具实例的属性 - * @author LR - * @date 2024/10/29 16:32 - * @version 1.0 - */ - public void syncIfsToolInstancePropertyTemplate(String site, String toolId, String toolInstance, String propertyNo) { - //查询ifs的使用的账号 - BaseConfigData baseConfig = baseConfigDao.getBaseConfigBySiteAndType("ALL", "tool_instance", "default_ifs_account"); - String okSign = baseConfig.getBaseData(); - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; - String dtOk = DateUtils.getStringDate(new Date(), "yyyy-MM-dd"); - technicalClass.setLuName("ManufToolDetail"); - technicalClass.setKeyRef(keyRef); - technicalClass.setTechnicalSpecNo("0"); - technicalClass.setTechnicalClass(propertyNo); - technicalClass.setOkYesNo("Not Approved"); - technicalClass.setOkSign(okSign); - technicalClass.setDtOk(dtOk); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/syncTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - } + /** * @description: 调用存储过程 处理工具实例的模版属性参数 @@ -709,13 +550,10 @@ public class ToolServiceImpl implements ToolService { toolInstanceData.setLastCalibrationDate(lastCalibrationTime); inData.setUpdatedDate(new Date()); inData.setState("Active"); + //初始化连接声明 + Server srv = null; //2.校验存在调用接口 if (controlFlag) { - /* String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance修改异常:" + toolResponse.getMsg()); - }*/ //查询当前用户 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -725,18 +563,12 @@ public class ToolServiceImpl implements ToolService { String ifsUsername = ifsUser.getIfsUsername(); String ifsPassword = ifsUser.getIfsPassword(); //获取链接 - Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); + srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); //调用新的api方法 - Map returnMap = toolServiceBean.modifyToolInstance(srv, toolInstanceData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Instance修改异常:" + returnMap.get("resultMsg")); - } - String objStr = String.valueOf(returnMap.get("obj")); - ToolInstance ifsTool = JSON.parseObject(objStr, ToolInstance.class); + ToolInfo returnTool = this.modifyIfsToolInstance(srv, toolInstanceData); //设置版本号 - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + inData.setIfsRowId(returnTool.getIfsRowId()); + inData.setIfsRowVersion(returnTool.getIfsRowVersion()); } //查询数据 ToolInstance checkData = toolDao.getToolInstanceByToolInstance(site, toolId, toolInstance); @@ -753,15 +585,15 @@ public class ToolServiceImpl implements ToolService { //判断各种类型 //1.原值不存在 新值存在 if("".equals(rawPropertyNo) && !rawPropertyNo.equals(propertyNo)){ - this.syncIfsToolInstancePropertyTemplate(site, toolId, toolInstance, propertyNo); + this.syncIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo); }else if ("".equals(rawPropertyNo) && rawPropertyNo.equals(propertyNo)){ //无需新增或者修改 }else if(!"".equals(rawPropertyNo) && !"".equals(propertyNo) && !rawPropertyNo.equals(propertyNo)){ //需要调用修改的接口即可 - this.modifyIfsToolInstancePropertyTemplate(site, toolId, toolInstance, propertyNo); + this.modifyIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance, propertyNo); }else if(!"".equals(rawPropertyNo) && "".equals(propertyNo)){ //需要调用删除的接口即可 - this.removeIfsToolInstancePropertyTemplate(site, toolId, toolInstance); + this.removeIfsToolInstancePropertyTemplate(srv, site, toolId, toolInstance); } } //3.调用存储过程处理 工具的属性模版数据 @@ -770,50 +602,6 @@ public class ToolServiceImpl implements ToolService { toolDao.updateToolInstance(inData); } - /** - * @description: 删除工具实例下的属性模版 - * @author LR - * @date 2024/10/29 17:38 - * @version 1.0 - */ - public void removeIfsToolInstancePropertyTemplate(String site, String toolId, String toolInstance) { - //查询ifs的使用的账号 - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; - technicalClass.setLuName("ManufToolDetail"); - technicalClass.setKeyRef(keyRef); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/removeTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - } - - /** - * @description: 修改工具实例的属性模版 - * @author LR - * @date 2024/10/29 17:29 - * @version 1.0 - */ - public void modifyIfsToolInstancePropertyTemplate(String site, String toolId, String toolInstance, String propertyNo) { - //查询ifs的使用的账号 - TechnicalClass technicalClass = new TechnicalClass(); - String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; - technicalClass.setLuName("ManufToolDetail"); - technicalClass.setKeyRef(keyRef); - technicalClass.setTechnicalClass(propertyNo); - //调用ifs的api - String toolURL = apiUrl + "/technical/class/modifyTechnicalClass"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, technicalClass); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); - } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - TechnicalClass ifsTool = JSON.parseObject(objStr, TechnicalClass.class); - } - /** * @description: 调用存储过程修改工具实例 * @author LR @@ -856,8 +644,6 @@ public class ToolServiceImpl implements ToolService { BeanUtils.copyProperties(inData, toolInstanceData); if (controlFlag) { - //2.调用IFS API接口 - //this.removeIfsToolInstance(toolInstanceData); //查询当前用户 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -869,31 +655,12 @@ public class ToolServiceImpl implements ToolService { //获取链接 Server srv = ifsServer.getIfsServer(ifsUsername, ifsPassword); //调用新的api方法 - Map returnMap = toolServiceBean.removeToolInstance(srv, toolInstanceData); - // 判断调用是否成功 - if (!"200".equals(returnMap.get("resultCode"))) { - throw new RuntimeException("ifs Instance删除异常:" + returnMap.get("resultMsg")); - } + this.removeIfsToolInstance(srv, toolInstanceData); } //2.调用方法保存当前的数据 toolDao.deleteToolInstance(inData); } - /** - * @description: 删除IFS的工具信息 - * @author LR - * @date 2024/10/29 14:17 - * @version 1.0 - */ - public void removeIfsToolInstance(ToolInstance ifsTool){ - String toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsTool); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); - } - } - - @Override @Transactional public void insertToolInstanceDate(IfsToolInstanceDate inData) { @@ -932,18 +699,6 @@ public class ToolServiceImpl implements ToolService { inData.setCreatedDate(new Date()); int id = toolDao.insertToolInstanceDate(inData); if (controlFlag) { - //2.校验存在调用接口 - /* String toolURL = apiUrl + "/tool/ifs/syncToolInstanceDateToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); - } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - ToolInstanceDate ifsTool = JSON.parseObject(objStr, ToolInstanceDate.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion());*/ - //查询当前用户 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -1028,18 +783,6 @@ public class ToolServiceImpl implements ToolService { instanceDateData.setEndDate(endTime); inData.setUpdatedDate(new Date()); if (controlFlag) { - //2.校验存在调用接口 - /* String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceDateToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); - } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - ToolInstanceDate ifsTool = JSON.parseObject(objStr, ToolInstanceDate.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion());*/ - //查询当前用户 String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); @@ -1102,11 +845,6 @@ public class ToolServiceImpl implements ToolService { BeanUtils.copyProperties(inData, instanceDateData); if (controlFlag) { //2.校验存在调用接口 - /* String toolURL = apiUrl + "/tool/ifs/removeToolInstanceDateToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, instanceDateData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstanceDate删除异常:" + toolResponse.getMsg()); - }*/ String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); SysUserEntity ifsUser = sysUserDao.selectOne(new QueryWrapper().eq("username", username)); if (ifsUser == null || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsUsername()) || !org.apache.commons.lang3.StringUtils.isNotBlank(ifsUser.getIfsPassword())) { @@ -1156,4 +894,260 @@ public class ToolServiceImpl implements ToolService { //处理返回的结果 return resultList.get(0); } + + /** + * @description: 新增Tool Header + * @author LR + * @date 2024/12/24 17:28 + * @version 1.0 + */ + public ToolInfo syncIfsToolInfo(Server srv, ToolInfo ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.syncToolHeader(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("ifs Tool新增异常:" + returnMap.get("resultMsg")); + } + // 更新 ifs_row_id ifs_row_version + String objStr = returnMap.get("objStr"); + ToolInfo returnTool = JSON.parseObject(objStr, ToolInfo.class); + ifsTool.setIfsRowId(returnTool.getIfsRowId()); + ifsTool.setIfsRowVersion(returnTool.getIfsRowVersion()); + return ifsTool; + } + + /** + * @description: Tool Header 修改 + * @author LR + * @date 2024/12/24 17:29 + * @version 1.0 + */ + public ToolInfo modifyIfsToolInfo(Server srv, ToolInfo ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.modifyToolHeader(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("ifs Tool修改异常:" + returnMap.get("resultMsg")); + } + // 更新 ifs_row_id ifs_row_version + String objStr = returnMap.get("objStr"); + ToolInfo returnTool = JSON.parseObject(objStr, ToolInfo.class); + ifsTool.setIfsRowId(returnTool.getIfsRowId()); + ifsTool.setIfsRowVersion(returnTool.getIfsRowVersion()); + return ifsTool; + } + + /** + * @description: 删除IFS的工具信息 + * @author LR + * @date 2024/10/29 14:17 + * @version 1.0 + */ + public void removeIfsToolInfo(Server srv, ToolInfo ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.removeToolHeader(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool Header 新增异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 新增Tool Instance + * @author LR + * @date 2024/12/24 17:28 + * @version 1.0 + */ + public ToolInfo syncIfsToolInstance(Server srv, ToolInstance ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.syncToolInstance(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("ifs Tool Instance新增异常:" + returnMap.get("resultMsg")); + } + // 更新 ifs_row_id ifs_row_version + String objStr = returnMap.get("objStr"); + ToolInfo returnTool = JSON.parseObject(objStr, ToolInfo.class); + ifsTool.setIfsRowId(returnTool.getIfsRowId()); + ifsTool.setIfsRowVersion(returnTool.getIfsRowVersion()); + return ifsTool; + } + + /** + * @description: Tool Instance 修改 + * @author LR + * @date 2024/12/24 17:29 + * @version 1.0 + */ + public ToolInfo modifyIfsToolInstance(Server srv, ToolInstance ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.modifyToolInstance(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("ifs Tool Instance修改异常:" + returnMap.get("resultMsg")); + } + // 更新 ifs_row_id ifs_row_version + String objStr = returnMap.get("objStr"); + ToolInfo returnTool = JSON.parseObject(objStr, ToolInfo.class); + ifsTool.setIfsRowId(returnTool.getIfsRowId()); + ifsTool.setIfsRowVersion(returnTool.getIfsRowVersion()); + return ifsTool; + } + + /** + * @description: 删除Tool Instance + * @author LR + * @date 2024/10/29 14:17 + * @version 1.0 + */ + public void removeIfsToolInstance(Server srv, ToolInstance ifsTool){ + //调用新的api方法 + Map returnMap = toolServiceBean.removeToolInstance(srv, ifsTool); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("ifs Tool Instance 删除异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 调用新增工具的属性模版 + * @author LR + * @date 2024/10/28 13:59 + * @version 1.0 + */ + public void syncIfsToolInfoPropertyTemplate(Server srv, String site, String toolId, String propertyNo) { + //查询ifs的使用的账号 + BaseConfigData baseConfig = baseConfigDao.getBaseConfigBySiteAndType("ALL", "tool", "default_ifs_account"); + String okSign = baseConfig.getBaseData(); + PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); + String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; + String dtOk = DateUtils.getStringDate(new Date(), "yyyy-MM-dd"); + technicalClass.setLuName("ManufTool"); + technicalClass.setKeyRef(keyRef); + technicalClass.setTechnicalSpecNo("0"); + technicalClass.setTechnicalClass(propertyNo); + technicalClass.setOkYesNo("Not Approved"); + technicalClass.setOkSign(okSign); + technicalClass.setDtOk(dtOk); + + //调用新的api方法 + Map returnMap = technicalClassBean.syncTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool 技术等级 新增异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 调用api的接口 + * @author LR + * @date 2024/10/28 14:42 + * @version 1.0 + */ + public void modifyIfsToolInfoPropertyTemplate(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); + technicalClass.setTechnicalClass(propertyNo); + + //调用新的api方法 + Map returnMap = technicalClassBean.modifyTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool 技术等级 修改异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 调用api的接口删除属性的模版 + * @author LR + * @date 2024/10/28 14:44 + * @version 1.0 + */ + public void removeIfsToolInfoPropertyTemplate(Server srv, String site, String toolId) { + //查询ifs的使用的账号 + PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); + String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^"; + technicalClass.setLuName("ManufTool"); + technicalClass.setKeyRef(keyRef); + //调用ifs的api + Map returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool 技术等级 删除异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 同步库工具实例的属性 + * @author LR + * @date 2024/10/29 16:32 + * @version 1.0 + */ + public void syncIfsToolInstancePropertyTemplate(Server srv, String site, String toolId, String toolInstance, String propertyNo) { + //查询ifs的使用的账号 + BaseConfigData baseConfig = baseConfigDao.getBaseConfigBySiteAndType("ALL", "tool_instance", "default_ifs_account"); + String okSign = baseConfig.getBaseData(); + PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); + String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; + String dtOk = DateUtils.getStringDate(new Date(), "yyyy-MM-dd"); + technicalClass.setLuName("ManufToolDetail"); + technicalClass.setKeyRef(keyRef); + technicalClass.setTechnicalSpecNo("0"); + technicalClass.setTechnicalClass(propertyNo); + technicalClass.setOkYesNo("Not Approved"); + technicalClass.setOkSign(okSign); + technicalClass.setDtOk(dtOk); + + //调用新的api方法 + Map returnMap = technicalClassBean.syncTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool Instance技术等级 新增异常:" + returnMap.get("resultMsg")); + } + } + + + /** + * @description: 修改工具实例的属性模版 + * @author LR + * @date 2024/10/29 17:29 + * @version 1.0 + */ + public void modifyIfsToolInstancePropertyTemplate(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); + //调用新的api方法 + Map returnMap = technicalClassBean.modifyTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool Instance技术等级 修改异常:" + returnMap.get("resultMsg")); + } + } + + /** + * @description: 删除工具实例下的属性模版 + * @author LR + * @date 2024/10/29 17:38 + * @version 1.0 + */ + public void removeIfsToolInstancePropertyTemplate(Server srv, String site, String toolId, String toolInstance) { + //查询ifs的使用的账号 + PartIfsCatalogModel technicalClass = new PartIfsCatalogModel(); + String keyRef = "CONTRACT="+site+"^TOOL_ID="+toolId+"^TOOL_INSTANCE="+toolInstance+"^"; + technicalClass.setLuName("ManufToolDetail"); + technicalClass.setKeyRef(keyRef); + //调用新的api方法 + Map returnMap = technicalClassBean.removeTechnicalClass(srv, technicalClass); + // 判断调用是否成功 + if (!"200".equals(returnMap.get("resultCode"))) { + throw new RuntimeException("Tool Instance技术等级 删除异常:" + returnMap.get("resultMsg")); + } + } }