集成伊利GPT代码提交
This commit is contained in:
parent
8e7cd7a639
commit
a348ccfc4c
@ -0,0 +1,25 @@
|
||||
package com.awspaas.user.apps.gpt_interface.controller;
|
||||
|
||||
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Mapping;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author:yujh
|
||||
* @Date: 2024/9/26 10:47
|
||||
*/
|
||||
@Controller
|
||||
public class GPTController {
|
||||
@Mapping(value = "com.awspaas.user.apps.gpt_interface.openRepositoryHome",
|
||||
session = false,
|
||||
noSessionEvaluate = "无安全隐患",
|
||||
noSessionReason = "用于打开相关文件地址")
|
||||
public String openRepositoryHome(String repositoryId){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("repositoryId", repositoryId);
|
||||
return HtmlPageTemplate.merge("com.awspaas.user.apps.gpt_interface", "repositoryHome.html", map);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,171 @@
|
||||
package com.awspaas.user.apps.gpt_interface.restful;
|
||||
|
||||
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.cache.PALRepositoryCache;
|
||||
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
|
||||
import com.actionsoft.bpms.commons.database.RowMap;
|
||||
import com.actionsoft.bpms.commons.login.constant.LoginConst;
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.bpms.commons.pagination.SQLPagination;
|
||||
import com.actionsoft.bpms.server.SSOUtil;
|
||||
import com.actionsoft.bpms.server.UserContext;
|
||||
import com.actionsoft.bpms.server.bind.annotation.Controller;
|
||||
import com.actionsoft.bpms.server.bind.annotation.HandlerType;
|
||||
import com.actionsoft.bpms.server.conf.portal.AWSPortalConf;
|
||||
import com.actionsoft.bpms.server.fs.DCContext;
|
||||
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
|
||||
import com.actionsoft.bpms.util.DBSql;
|
||||
import com.actionsoft.bpms.util.UtilFile;
|
||||
import com.actionsoft.bpms.util.UtilString;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.awspaas.user.apps.gpt_interface.utils.CallASLPUtil;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:yujh
|
||||
* @Date: 2024/9/23 11:56
|
||||
*/
|
||||
@Controller(type = HandlerType.RESTFUL, apiName = "GPTapi", desc = "与伊利集成的GPTapi")
|
||||
public class GPTRestFul {
|
||||
|
||||
@Path("getPalRepositoryList")
|
||||
@GET
|
||||
public String getPalRepositoryList(@QueryParam("page") Integer page,
|
||||
@QueryParam("pageSize") Integer pageSize,
|
||||
@QueryParam("repositoryId") String repositoryId){
|
||||
if(UtilString.isEmpty(page)){
|
||||
page = 1;
|
||||
}
|
||||
if(UtilString.isEmpty(pageSize)){
|
||||
pageSize = 20;
|
||||
}
|
||||
JSONObject result = new JSONObject();
|
||||
String sid = new SSOUtil().registerClientSessionNoPassword("admin", "cn", "", LoginConst.DEVICE_PC, null);
|
||||
UserContext uc = UserContext.fromSessionId(sid);
|
||||
JSONArray data =new JSONArray();
|
||||
String queryCountSql = " SELECT COUNT(ID) FROM APP_ACT_COE_PAL_REPOSITORY WHERE ISPUBLISH = '1' AND ISUSE = '1'";
|
||||
int sumNum = DBSql.getInt(queryCountSql,new Object[]{});//总数据量
|
||||
String queryListSql = "";
|
||||
List<RowMap> maps = null;
|
||||
if(UtilString.isNotEmpty(repositoryId)){//如果查询Id参数不为空
|
||||
queryListSql= " SELECT ID,PLNAME,PLORDERINDEX FROM APP_ACT_COE_PAL_REPOSITORY WHERE ISPUBLISH = '1' AND ISUSE = '1' AND ID = ?";
|
||||
maps = DBSql.getMaps(queryListSql, new Object[]{repositoryId});
|
||||
}else{
|
||||
queryListSql= " SELECT ID,PLNAME,PLORDERINDEX FROM APP_ACT_COE_PAL_REPOSITORY WHERE ISPUBLISH = '1' AND ISUSE = '1'";
|
||||
queryListSql = SQLPagination.getPaginitionSQL(queryListSql, (page - 1) * pageSize, pageSize);
|
||||
maps = DBSql.getMaps(queryListSql, new Object[]{});
|
||||
}
|
||||
for (RowMap map : maps) {
|
||||
JSONObject repositoryModel = new JSONObject();
|
||||
String thisRepositoryId = map.getString("ID");
|
||||
repositoryModel.put("id",thisRepositoryId);
|
||||
repositoryModel.put("palName",map.getString("PLNAME"));
|
||||
String taskId = getLastPublishTaskIdByModelId(thisRepositoryId);
|
||||
//String downloadUrlData= CallASLPUtil.callTranslateDocASLP(thisRepositoryId,taskId);
|
||||
repositoryModel.put("fileDownLoadUrl",outputReportDownload(uc,taskId,thisRepositoryId));
|
||||
repositoryModel.put("fileLinkText",map.getString("PLNAME"));
|
||||
repositoryModel.put("fileLinkUrl",getFileLinkUrl(thisRepositoryId,taskId));
|
||||
data.add(repositoryModel);
|
||||
}
|
||||
result.put("totalCount",sumNum);
|
||||
result.put("thisCount",maps.size());
|
||||
result.put("data",data);
|
||||
result.put("page",page);
|
||||
result.put("pageSize",pageSize);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件下载地址
|
||||
* @param sourceDc
|
||||
* @return
|
||||
*/
|
||||
public String getFileDownLoadUrl(DCContext sourceDc){
|
||||
String downloadURL = sourceDc.getDownloadURL();
|
||||
return AWSPortalConf.getUrl()+ "/r"+ downloadURL.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件链接地址
|
||||
* @param repositoryId
|
||||
* @return
|
||||
*/
|
||||
public String getFileLinkUrl(String repositoryId,String taskId){
|
||||
return AWSPortalConf.getUrl()+"/r/w?cmd=com.awspaas.user.apps.gpt_interface.openRepositoryHome&repositoryId="+repositoryId+"&taskId="+taskId;
|
||||
}
|
||||
|
||||
|
||||
public String getLastPublishTaskIdByModelId(String repositoryId) {
|
||||
String sql = "SELECT pl.TASKID FROM APP_ACT_COE_PAL_PUBLISH p, APP_ACT_COE_PAL_PUBLISH_LIST pl WHERE pl.pid = p.id AND pl.palrepositoryid = ? ORDER BY publishdate DESC";
|
||||
return DBSql.getString(sql,new Object[]{repositoryId});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 流程手册下载
|
||||
* @param _uc
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
public String outputReportDownload(UserContext _uc, String taskId, String ruuid) {
|
||||
System.out.println(">>>>>taskId = " + taskId);
|
||||
System.out.println(">>>>>ruuid = " + ruuid);
|
||||
OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
|
||||
ResponseObject result = ResponseObject.newOkResponse();
|
||||
if (model != null) {
|
||||
try {
|
||||
System.out.println(">>>>>model.getWsId() = " + model.getWsId());
|
||||
System.out.println(">>>>>model.getProfileId() = " + model.getProfileId());
|
||||
UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId());
|
||||
System.out.println(">>>>>>>file.exists"+file.exists());
|
||||
if (file.exists()) {
|
||||
File[] fileList = file.listFiles();
|
||||
if (fileList.length > 0) {
|
||||
File docFile = null;
|
||||
for (File file2 : fileList) {
|
||||
if (file2.isFile() && "doc".equals((file2.getName().substring(file2.getName().lastIndexOf(".") + 1)))) {
|
||||
docFile = file2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (docFile == null) {
|
||||
return ResponseObject.newErrResponse("没有找到文件").toString();
|
||||
}
|
||||
PALRepositoryModel plmodel = PALRepositoryCache.getCache().get(ruuid);
|
||||
if (plmodel != null) {
|
||||
String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr";
|
||||
String methodId = plmodel.getMethodId();
|
||||
if (methodId.contains("control")) {
|
||||
sourceAppId = "com.awspaas.user.apps.coe.pal.output.zd";
|
||||
} else if (methodId.contains("data")) {
|
||||
sourceAppId = "com.awspaas.user.apps.coe.pal.output.bd";
|
||||
}
|
||||
String filename = docFile.getName();
|
||||
DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, model.getWsId(), taskId, filename);
|
||||
String downUrl = SDK.getConfAPI().getPortalUrl() + "/r/" + sourceDc.getDownloadURL().replace("./", "");
|
||||
return downUrl;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = ResponseObject.newErrResponse("没有可预览文件");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResponseObject.newErrResponse().toString();
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package com.awspaas.user.apps.gpt_interface.utils;
|
||||
|
||||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||||
import com.actionsoft.sdk.local.SDK;
|
||||
import com.actionsoft.sdk.local.api.AppAPI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
public class CallASLPUtil {
|
||||
|
||||
/**
|
||||
* 获取文件下载地址
|
||||
* @return
|
||||
*/
|
||||
public static String callTranslateDocASLP(String repositoryId, String taskId){
|
||||
String sourceAppId= "com.awspaas.user.apps.gpt_interface";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("repositoryId",repositoryId);
|
||||
params.put("taskId",taskId);
|
||||
// aslp服务地址
|
||||
String aslp = "aslp://com.actionsoft.apps.coe.pal/getRepositoryDownLoadUrlAslp";
|
||||
// 参数定义列表
|
||||
AppAPI appAPI = SDK.getAppAPI();
|
||||
//开发者注册报告生成器扩展App
|
||||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params);
|
||||
System.out.println("ro = " + ro);
|
||||
return ro.get("data").toString();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user