From 3d32e542b45a14decdbe32bc556eb7df2b1de350 Mon Sep 17 00:00:00 2001 From: qiyh Date: Wed, 19 Jun 2024 10:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=99=BB=E5=BD=95=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E6=AF=8F=E6=AC=A1=E8=BF=9B=E8=A1=8C=E7=99=BB?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pjb/springbootjjwt/api/IgtcoaApi.java | 136 +++++++----------- 1 file changed, 54 insertions(+), 82 deletions(-) diff --git a/src/main/java/com/pjb/springbootjjwt/api/IgtcoaApi.java b/src/main/java/com/pjb/springbootjjwt/api/IgtcoaApi.java index cef2526..0144e6c 100644 --- a/src/main/java/com/pjb/springbootjjwt/api/IgtcoaApi.java +++ b/src/main/java/com/pjb/springbootjjwt/api/IgtcoaApi.java @@ -12,6 +12,7 @@ import com.teamcenter.clientx.Utils; import com.teamcenter.services.strong.administration.PreferenceManagementRestBindingStub; import com.teamcenter.services.strong.administration.PreferenceManagementService; import com.teamcenter.services.strong.administration._2012_09.PreferenceManagement; +import com.teamcenter.soa.client.Connection; import com.teamcenter.soa.client.model.ServiceData; import com.teamcenter.soa.client.model.strong.User; import org.springframework.beans.factory.annotation.Autowired; @@ -100,10 +101,12 @@ public class IgtcoaApi { // 获取必要的属性 String task_Uid = propertyMap.containsKey("task_uid") ? propertyMap.get("task_uid").toString() : ""; -// String taskWorkFlowUID = -// propertyMap.containsKey("TaskWorkFlowUID") ? propertyMap.get("TaskWorkFlowUID").toString() : ""; -// String taskPackageUID = -// propertyMap.containsKey("TaskPackageUID") ? propertyMap.get("TaskPackageUID").toString() : ""; + // String taskWorkFlowUID = + // propertyMap.containsKey("TaskWorkFlowUID") ? + // propertyMap.get("TaskWorkFlowUID").toString() : ""; + // String taskPackageUID = + // propertyMap.containsKey("TaskPackageUID") ? + // propertyMap.get("TaskPackageUID").toString() : ""; String task_name = propertyMap.containsKey("task_name") ? propertyMap.get("task_name").toString() : ""; String task_CustomerNameBilingUnit = @@ -197,8 +200,7 @@ public class IgtcoaApi { productApplicationFieldOrIndustry, productApplicationPart, productType); - if(productValue.length() > 256) - { + if (productValue.length() > 256) { return JsonResult.error("产品属性值超长"); } productList.add(productValue); @@ -223,9 +225,9 @@ public class IgtcoaApi { : "项目名称"); System.out.println(taskInstruction); if (taskInstruction.length() > 128) { - taskInstruction = taskInstruction.substring(0,124) + "..."; - //Utils.setLog(logFileName, "oaCreateWorkFlow", "流程名称过长"); - //return JsonResult.error("流程名称过长"); + taskInstruction = taskInstruction.substring(0, 124) + "..."; + // Utils.setLog(logFileName, "oaCreateWorkFlow", "流程名称过长"); + // return JsonResult.error("流程名称过长"); } // 获取附件 List fileList = new ArrayList(); @@ -245,8 +247,7 @@ public class IgtcoaApi { String fileUrl = key; byte[] buffer = Utils.getFile(fileUrl); Date date = new Date(); - String filePath = - System.getProperty("java.io.tmpdir") + dateFormat.format(date) + "\\"; + String filePath = System.getProperty("java.io.tmpdir") + dateFormat.format(date) + "\\"; File file = new File(filePath); if (!file.exists()) { file.mkdir(); @@ -336,13 +337,9 @@ public class IgtcoaApi { // String try { - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); } catch (Exception ex) { Utils.setLog(logFileName, "oaCreateWorkFlow", "TC服务器出错" + ex.getMessage()); ex.printStackTrace(); @@ -385,16 +382,11 @@ public class IgtcoaApi { // @UserLoginToken @PostMapping(value = "/oaGetDeliveryInfo") public Object getDeliveryInfo(@RequestBody List itemIdList) { - //String deliveryId = request.getParameter("deliveryId"); - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } + // String deliveryId = request.getParameter("deliveryId"); + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); try { - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } - + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); } catch (Exception ex) { ex.printStackTrace(); } @@ -402,26 +394,22 @@ public class IgtcoaApi { Object object = TcsoaService.osGetDeliveryInfo(itemIdList); return object; } + // @UserLoginToken @PostMapping(value = "/oaGetHistoryDelivery") public Object getHistoryDelivery(HttpServletRequest request) { String deliveryId = request.getParameter("deliveryId"); - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); try { - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } - + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); } catch (Exception ex) { ex.printStackTrace(); } - Object Object = TcsoaService.oaGetHistoryDelivery(deliveryId); return Object; } + // @UserLoginToken @GetMapping(value = "/oaGetDeliveryFile") public void getGetDeliveryFile(HttpServletRequest request, HttpServletResponse response) { @@ -430,14 +418,10 @@ public class IgtcoaApi { System.out.println("oaGetDeliveryFile" + deliveryId); - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); try { - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); } catch (Exception ex) { ex.printStackTrace(); @@ -517,14 +501,10 @@ public class IgtcoaApi { propertyMap, logFileName); - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); try { - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); } catch (Exception ex) { Utils.setLog(logFileName, "oaCreateOrUpdateProject", "TC服务器登录出错" + ex.getMessage()); @@ -532,7 +512,8 @@ public class IgtcoaApi { } // 获取必须的属性 - String userId = propertyMap.containsKey("designTeam") ? propertyMap.get("designTeam").toString() : "admin"; + String userId = + propertyMap.containsKey("designTeam") ? propertyMap.get("designTeam").toString() : "admin"; String objectName = propertyMap.containsKey("objectName") ? propertyMap.get("objectName").toString() : ""; String projectUID = @@ -629,44 +610,35 @@ public class IgtcoaApi { @PostMapping(value = "/getItemProperty") public JsonResult getItemProperty(@RequestBody List itemIdList) { String logFileName = dateFormatLog.format(new Date()); - try { - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } - } catch (Exception ex) { - Utils.setLog(logFileName, "getItemProperty", "TC服务器出错" + ex.getMessage()); - ex.printStackTrace(); - return JsonResult.error("TC服务器登录出错" + ex.getMessage()); - } + try { + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); + } catch (Exception ex) { + Utils.setLog(logFileName, "getItemProperty", "TC服务器出错" + ex.getMessage()); + ex.printStackTrace(); + return JsonResult.error("TC服务器登录出错" + ex.getMessage()); + } - JsonResult jsonResult = TcsoaService.getItemPropertys(logFileName,itemIdList); - Utils.setLog(logFileName, "getItemPropertys", "jsonResult:"+jsonResult.toString()); + JsonResult jsonResult = TcsoaService.getItemPropertys(logFileName, itemIdList); + Utils.setLog(logFileName, "getItemPropertys", "jsonResult:" + jsonResult.toString()); return jsonResult; } - @GetMapping(value = "/getProjectItemProperty") public JsonResult getProjectItemProperty(@RequestParam("uid") String uid) { String logFileName = dateFormatLog.format(new Date()); - try { - if (tcSession == null) { - tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); - } - if (tcUser == null) { - tcUser = - tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); - } - } catch (Exception ex) { - Utils.setLog(logFileName, "getProjectItemProperty", "TC服务器出错" + ex.getMessage()); - ex.printStackTrace(); - return JsonResult.error("TC服务器登录出错" + ex.getMessage()); - } - JsonResult jsonResult = TcsoaService.getProjectItemPropertys(logFileName,uid); - Utils.setLog(logFileName, "getProjectItemProperty", "jsonResult:"+jsonResult.toString()); + try { + tcSession = new AppXSession(SpringbootJjwtApplication.TC_URL); + tcUser = + tcSession.login(SpringbootJjwtApplication.TC_USER, SpringbootJjwtApplication.TC_PWD); + } catch (Exception ex) { + Utils.setLog(logFileName, "getProjectItemProperty", "TC服务器出错" + ex.getMessage()); + ex.printStackTrace(); + return JsonResult.error("TC服务器登录出错" + ex.getMessage()); + } + JsonResult jsonResult = TcsoaService.getProjectItemPropertys(logFileName, uid); + Utils.setLog(logFileName, "getProjectItemProperty", "jsonResult:" + jsonResult.toString()); return jsonResult; } }