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 036d2e72..38c9d1e7 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 @@ -40,6 +40,8 @@ public class ToolServiceImpl implements ToolService { @Value("${ifs-api.api-url}") private String apiUrl; + @Value("${ifs-control.control-flag}") + private Boolean controlFlag; @Override public List getToolInfoList(IfsTool inData) { @@ -122,27 +124,28 @@ public class ToolServiceImpl implements ToolService { //属性拷贝 BeanUtils.copyProperties(inData, ifsToolData); //2.校验存在调用接口 - String toolURL = apiUrl + "/tool/ifs/syncToolDataToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsToolData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool新增异常:" + toolResponse.getMsg()); + 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()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); + //删除工具信息默认的工具实例信息 + IfsToolInstanceData toolInstance = new IfsToolInstanceData(); + //属性拷贝 + 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()); + } } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); - //删除工具信息默认的工具实例信息 - IfsToolInstanceData toolInstance = new IfsToolInstanceData(); - //属性拷贝 - 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()); - } - //2.调用方法保存当前的数据 toolDao.insertToolInfo(inData); } @@ -193,17 +196,19 @@ public class ToolServiceImpl implements ToolService { //属性拷贝 BeanUtils.copyProperties(inData, ifsToolData); - //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()); + 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()); + } + // 更新 ifs_row_id ifs_row_version + String objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); //2.调用方法保存当前的数据 toolDao.updateToolInfo(inData); } @@ -253,12 +258,14 @@ public class ToolServiceImpl implements ToolService { IfsToolData ifsToolData = new IfsToolData(); //属性拷贝 BeanUtils.copyProperties(inData, ifsToolData); - //2.校验存在调用接口 - //判断是否存在替代的 - String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsToolData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS Tool删除异常:" + toolResponse.getMsg()); + if (controlFlag) { + //2.校验存在调用接口 + //判断是否存在替代的 + String toolURL = apiUrl + "/tool/ifs/removeToolDataToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, ifsToolData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS Tool删除异常:" + toolResponse.getMsg()); + } } //3.调用方法保存当前的数据 toolDao.deleteToolInfo(inData); @@ -307,30 +314,32 @@ public class ToolServiceImpl implements ToolService { String resultMsg = String.valueOf(resultMap.get("result_msg")); throw new RuntimeException(resultMsg); } - //2.校验存在调用接口 - toolInstanceData = new IfsToolInstanceDateData(); - inData.setCreateDate(new Date()); - inData.setState("Active"); - //拷贝属性 设置参数 - BeanUtils.copyProperties(inData, toolInstanceData); - String lastCalibrationTime = ""; - if(lastCalibrationDate != null){ - lastCalibrationTime = DateUtils.getStringDate(lastCalibrationDate, "yyyy-MM-dd"); - inData.setNextCalibrationDate(lastCalibrationDate); - } - 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()); + if (controlFlag) { + //2.校验存在调用接口 + toolInstanceData = new IfsToolInstanceDateData(); + inData.setCreateDate(new Date()); + inData.setState("Active"); + //拷贝属性 设置参数 + BeanUtils.copyProperties(inData, toolInstanceData); + String lastCalibrationTime = ""; + if (lastCalibrationDate != null) { + lastCalibrationTime = DateUtils.getStringDate(lastCalibrationDate, "yyyy-MM-dd"); + inData.setNextCalibrationDate(lastCalibrationDate); + } + 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 objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + //设置版本号 + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); - //设置版本号 - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); //2.调用方法保存当前的数据 toolDao.insertToolInstance(inData); } @@ -394,17 +403,19 @@ public class ToolServiceImpl implements ToolService { toolInstanceData.setLastCalibrationDate(lastCalibrationTime); inData.setCreateDate(new Date()); inData.setState("Active"); - //2.校验存在调用接口 - String toolURL = apiUrl + "/tool/ifs/modifyToolInstanceToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance修改异常:" + toolResponse.getMsg()); + if (controlFlag) { + //2.校验存在调用接口 + 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 objStr = String.valueOf(toolResponse.getObj()); + IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); + //设置版本号 + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolData ifsTool = JSON.parseObject(objStr, IfsToolData.class); - //设置版本号 - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); //2.调用方法保存当前的数据 toolDao.updateToolInstance(inData); } @@ -450,11 +461,13 @@ public class ToolServiceImpl implements ToolService { //拷贝属性 设置参数 BeanUtils.copyProperties(inData, toolInstanceData); - //2.校验存在调用接口 - String toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; - ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); - if (!"200".equals(toolResponse.getCode())) { - throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); + if (controlFlag) { + //2.校验存在调用接口 + String toolURL = apiUrl + "/tool/ifs/removeToolInstanceToIfs"; + ResponseData toolResponse = HttpClientUtil.doPostByRawWithPLM(toolURL, toolInstanceData); + if (!"200".equals(toolResponse.getCode())) { + throw new RuntimeException("IFS ToolInstance删除异常:" + toolResponse.getMsg()); + } } //2.调用方法保存当前的数据 toolDao.deleteToolInstance(inData); @@ -494,17 +507,19 @@ public class ToolServiceImpl implements ToolService { //设置时间的信息 instanceDateData.setBeginDate(beginTime); instanceDateData.setEndDate(endTime); - //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()); + 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()); + IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); //保存新增的数据 toolDao.insertToolInstanceDate(inData); } @@ -563,17 +578,19 @@ public class ToolServiceImpl implements ToolService { //设置时间的信息 instanceDateData.setBeginDate(beginTime); instanceDateData.setEndDate(endTime); - //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()); + 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()); + IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); + inData.setIfsRowId(ifsTool.getIfsRowId()); + inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); } - // 更新 ifs_row_id ifs_row_version - String objStr = String.valueOf(toolResponse.getObj()); - IfsToolInstanceDateData ifsTool = JSON.parseObject(objStr, IfsToolInstanceDateData.class); - inData.setIfsRowId(ifsTool.getIfsRowId()); - inData.setIfsRowVersion(ifsTool.getIfsRowVersion()); //保存新增的数据 toolDao.updateToolInstanceDate(inData); } @@ -612,11 +629,13 @@ public class ToolServiceImpl implements ToolService { IfsToolInstanceDateData instanceDateData = new IfsToolInstanceDateData(); //属性拷贝 BeanUtils.copyProperties(inData, instanceDateData); - //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()); + 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()); + } } //保存新增的数据 toolDao.deleteToolInstanceDate(inData);