From c9bbdcff22773ecb59498d58aa13996f5e98ab87 Mon Sep 17 00:00:00 2001 From: yujh_java Date: Wed, 18 Jun 2025 15:50:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B5=81=E7=A8=8B=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E5=90=8E=EF=BC=8C=E5=90=8C=E6=AD=A5GPT=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8A=A0=E8=BD=BD=E9=99=84=E4=BB=B6=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coe/pal/publisher/alsp/SendGPTAlsp.java | 4 +-- .../pubEvent/ProcessEndAfterEvent_new.java | 4 +-- .../publisher/utils/UploadGptFileUtils.java | 28 ++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendGPTAlsp.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendGPTAlsp.java index 7a190c1f..63c32213 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendGPTAlsp.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/alsp/SendGPTAlsp.java @@ -90,7 +90,7 @@ public class SendGPTAlsp implements ASLP { String finalFilePath = filepath.replace("bin\\..\\", ""); JSONObject result = null; - result = JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl, appkey, requestCode, dcContext.getFilePath())); + result = JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl, appkey, requestCode, dcContext.getFilePath(),dcContext.getFileName(),fileId)); if (result.getString("msg").equals("success")) { String data = result.getString("data"); //插入模型ID与DOCID对应表中 @@ -153,7 +153,7 @@ public class SendGPTAlsp implements ASLP { String filepath = dcContext.getFilePath(); String finalFilePath = filepath.replace("bin\\..\\", ""); - JSONObject result = JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl, appkey, requestCode, dcContext.getFilePath())); + JSONObject result = JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl, appkey, requestCode, dcContext.getFilePath(),dcContext.getFileName(),changefileIdNew)); if (result.getString("msg").equals("success")) { String data = result.getString("data"); diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java index 1b11b8ba..b3423753 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/pubEvent/ProcessEndAfterEvent_new.java @@ -581,7 +581,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String finalFilePath = filepath.replace("bin\\..\\", ""); - JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath())); + JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath(),dcContext.getFileName(),fileId)); if(result.getString("msg").equals("success")){ String data=result.getString("data"); @@ -708,7 +708,7 @@ public class ProcessEndAfterEvent_new extends ExecuteListener implements Execute String filepath = dcContext.getFilePath(); String finalFilePath = filepath.replace("bin\\..\\", ""); - JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath())); + JSONObject result=JSONObject.parseObject(UploadGptFileUtils.uploadGptFile(uploadGptUrl,appkey,requestCode,dcContext.getFilePath(),dcContext.getFileName(),changefileIdNew)); if(result.getString("msg").equals("success")){ String data=result.getString("data"); diff --git a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/utils/UploadGptFileUtils.java b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/utils/UploadGptFileUtils.java index 44855a65..f6869b3d 100644 --- a/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/utils/UploadGptFileUtils.java +++ b/com.actionsoft.apps.coe.pal.publisher/src/com/actionsoft/apps/coe/pal/publisher/utils/UploadGptFileUtils.java @@ -1,5 +1,6 @@ package com.actionsoft.apps.coe.pal.publisher.utils; +import com.actionsoft.bpms.server.conf.portal.AWSPortalConf; import com.actionsoft.sdk.local.SDK; import java.io.*; @@ -13,7 +14,7 @@ public class UploadGptFileUtils { - public static String uploadGptFile(String targetUrl,String appkey,String requestCode,String filePath) throws Exception { + public static String uploadGptFile(String targetUrl,String appkey,String requestCode,String filePath,String fileLinkName,String fileId) throws Exception { String result = null; HttpURLConnection connection=null; OutputStream output=null; @@ -57,6 +58,20 @@ public class UploadGptFileUtils { writer.append("\r\n"); writer.append(requestCode).append("\r\n"); + // Send requestCode part + writer.append("--").append(boundary).append("\r\n"); + writer.append("Content-Disposition: form-data; name=\"extensionName\"\r\n"); + writer.append("Content-Type: text/plain; charset=UTF-8\r\n"); + writer.append("\r\n"); + writer.append(fileLinkName).append("\r\n"); + + // Send requestCode part + writer.append("--").append(boundary).append("\r\n"); + writer.append("Content-Disposition: form-data; name=\"extensionValue\"\r\n"); + writer.append("Content-Type: text/plain; charset=UTF-8\r\n"); + writer.append("\r\n"); + writer.append(getFileLinkUrl(fileId)).append("\r\n"); + // End of multipart/form-data writer.append("--").append(boundary).append("--\r\n"); writer.flush(); @@ -81,4 +96,15 @@ public class UploadGptFileUtils { return result; } + + /** + * 获取文件链接地址 + * @param fileId + * @return + */ + public static String getFileLinkUrl(String fileId){ + String fileLinkUrl = AWSPortalConf.getUrl() + "/r/w?cmd=com.awspaas.user.apps.gpt_interface.openRepositoryHome&repositoryId="; + fileLinkUrl+=fileId; + return fileLinkUrl; + } }