1510 lines
88 KiB
Java
1510 lines
88 KiB
Java
package com.awspaas.user.apps.integration.oauth;
|
||
|
||
import com.actionsoft.apps.coe.pal.pal.output.constant.OutputConst;
|
||
import com.actionsoft.apps.coe.pal.pal.output.dao.OutputTask;
|
||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppManager;
|
||
import com.actionsoft.apps.coe.pal.pal.output.extend.OutputAppProfile;
|
||
import com.actionsoft.apps.coe.pal.pal.output.model.OutputTaskModel;
|
||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
|
||
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
|
||
import com.actionsoft.apps.resource.plugin.profile.DCPluginProfile;
|
||
import com.actionsoft.bpms.bo.engine.BO;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.TaskInstance;
|
||
import com.actionsoft.bpms.client.form.UserTaskFormsWeb;
|
||
import com.actionsoft.bpms.commons.database.RowMap;
|
||
import com.actionsoft.bpms.commons.htmlframework.HtmlPageTemplate;
|
||
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
|
||
import com.actionsoft.bpms.org.model.DepartmentModel;
|
||
import com.actionsoft.bpms.org.model.UserModel;
|
||
import com.actionsoft.bpms.server.RequestParams;
|
||
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.Mapping;
|
||
import com.actionsoft.bpms.server.fs.DCContext;
|
||
import com.actionsoft.bpms.util.DBSql;
|
||
import com.actionsoft.bpms.util.UUIDGener;
|
||
import com.actionsoft.bpms.util.UtilString;
|
||
import com.actionsoft.exception.AWSException;
|
||
import com.actionsoft.exception.AWSQuotaException;
|
||
import com.actionsoft.sdk.local.SDK;
|
||
import com.actionsoft.sdk.local.api.*;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.awspaas.user.apps.integration.util.HttpClientUtils;
|
||
import com.awspaas.user.apps.integration.util.UtilUrl;
|
||
import org.apache.commons.httpclient.HttpClient;
|
||
import org.apache.commons.lang.StringUtils;
|
||
|
||
import java.io.IOException;
|
||
import java.io.UnsupportedEncodingException;
|
||
import java.math.BigDecimal;
|
||
import java.net.URLDecoder;
|
||
import java.nio.charset.StandardCharsets;
|
||
import java.sql.Connection;
|
||
import java.sql.SQLException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.time.LocalDate;
|
||
import java.util.*;
|
||
|
||
@SuppressWarnings("all")
|
||
@Controller
|
||
public class TaskController {
|
||
|
||
/**
|
||
* OA系统单点访问PAL系统
|
||
*
|
||
* @return
|
||
*/
|
||
@Mapping("com.yili_pal_portal_open")
|
||
public String openPALConsole(String code) throws Exception {
|
||
ResponseObject ro = ResponseObject.newOkResponse();
|
||
|
||
|
||
String userid = "";
|
||
|
||
App app = new App();
|
||
String tokens = app.getTokens("http://10.114.11.135:8088/portal/yili.html", code);
|
||
if (StringUtils.isEmpty(tokens)) {
|
||
//System.out.println("这个认证是失败的,code为空,请联系管理员");;
|
||
} else {
|
||
JSONObject jsonObjects = JSONObject.parseObject(tokens);
|
||
String access_token = jsonObjects.getString("access_token");
|
||
String userInfo = app.getUserInfo(access_token);
|
||
|
||
if (StringUtils.isNotEmpty(userInfo)) {
|
||
JSONObject json = JSONObject.parseObject(userInfo);
|
||
//System.out.println("json-=====>>>>"+json);
|
||
if (StringUtils.isNotEmpty(json.getString("employeenumber"))) {
|
||
//System.out.println("userid》》》》》》》》》》"+json.getString("employeenumber"));
|
||
userid = json.getString("employeenumber");
|
||
try {
|
||
setUserLog("", userid, "1");
|
||
} catch (Exception e) {
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
String sessionId = UserContext.fromUID(userid).getSessionId();
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
|
||
String url = portalUrl + "/r/w?sid=" + sessionId + "&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1";
|
||
// String palPortalUrl= portalUrl + "/r/w?sid="+sessionId+"&cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1";
|
||
|
||
String portal_url = "https://bpm.yili.com:8088" + "/portal/r/or?cmd=com.actionsoft.apps.skins.mportal3_home_page&id=5af46cd5-a1bc-4125-a144-86d1a199eec1&sid=" + sessionId + "&oauthName=oauthLogin&code=" + code;
|
||
|
||
//ro.put("new_url",url);
|
||
|
||
return portal_url;
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 用户登录日志
|
||
*
|
||
* @param userid
|
||
* @param logType
|
||
*/
|
||
public void setUserLog(String processInstId, String userid, String logType) {
|
||
System.err.println("用户登录记录存入日志========>" + userid + "_类型:" + logType);
|
||
if (UtilString.isNotEmpty(userid)) {
|
||
//待阅更新已读记录
|
||
if ("3".equals(logType)) {
|
||
String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
|
||
/*
|
||
* RowMap map = DBSql.getMap("SELECT * FROM BO_ACT_DATAID WHERE PROCESSID = '"
|
||
* +processInstId+"' AND USER_ID = '"+userid+"' AND READSTATE = '已读'");
|
||
* if(null!=map) { int readCount = map.getInt("READCOUNT")+1;
|
||
* DBSql.update("UPDATE BO_ACT_DATAID SET READSTATE = '已读',READTIMES = '"
|
||
* +dateTime+"',READCOUNT = "+readCount+" WHERE PROCESSID = '"
|
||
* +processInstId+"' AND USER_ID = '"+userid+"'"); }else { }
|
||
*/
|
||
DBSql.update("UPDATE BO_ACT_DATAID SET READSTATE = '已读',READTIMES = '" + dateTime + "',READCOUNT = 1 WHERE PROCESSID = '" + processInstId + "' AND USER_ID = '" + userid + "'");
|
||
|
||
|
||
//将已读数据插入至BO_ACT_ALREADY_DATAID ,并把BO_ACT_DATAID中此条已读数据删除
|
||
/*String sql = "INSERT INTO BO_ACT_ALREADY_DATAID (\"ID\",ORGID,BINDID,CREATEDATE,CREATEUSER,UPDATEDATE,UPDATEUSER,PROCESSDEFID,ISEND,PROCESSID,USER_ID,USERDEP,READTIMES,DATAID,\"RESULT\",TITLE,SENDTYPE,READSTATE,READCOUNT,\"TYPE\")\n" +
|
||
"\t\t\t\tSELECT \"ID\",ORGID,BINDID,CREATEDATE,CREATEUSER,UPDATEDATE,UPDATEUSER,PROCESSDEFID,ISEND,PROCESSID,USER_ID,USERDEP,READTIMES,DATAID,\"RESULT\",TITLE,SENDTYPE,READSTATE,READCOUNT,\"TYPE\"\n" +
|
||
"\t\t\t\tFROM BO_ACT_DATAID WHERE READSTATE='已读' AND PROCESSID = '" + processInstId + "' AND USER_ID = '" + userid + "'";
|
||
DBSql.update(sql);*/
|
||
|
||
|
||
String sqly = "SELECT PROCESSID,USER_ID,USERDEP,READTIMES,DATAID,TITLE,SENDTYPE,READSTATE,READCOUNT FROM BO_ACT_DATAID WHERE PROCESSID = '" + processInstId + "' AND USER_ID='"+userid+"' ";
|
||
RowMap mapsy = DBSql.getMap(sqly);
|
||
System.out.println("mapsy==========="+mapsy);
|
||
if (null != mapsy && !mapsy.isEmpty()) {
|
||
System.out.println("插入已阅数据===========");
|
||
String sql = "insert into BO_ACT_ALREADY_DATAID (ID,PROCESSID,USER_ID,READTIMES,DATAID,TITLE,READSTATE) values ('%s', '%s', '%s', '%s', '%s', '%s','%s')";
|
||
String id = UUIDGener.getUUID();
|
||
int update = DBSql.update(String.format(sql, id, mapsy.getString("PROCESSID"), mapsy.getString("USER_ID"), mapsy.get("READTIMES"), mapsy.getString("DATAID"),mapsy.getString("TITLE"),mapsy.getString("READSTATE")));
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
String sql1 = "DELETE FROM BO_ACT_DATAID WHERE READSTATE='已读' AND PROCESSID = '" + processInstId + "' AND USER_ID = '" + userid + "'";
|
||
DBSql.update(sql1);
|
||
|
||
|
||
}
|
||
String logTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||
BO bo = new BO();
|
||
ORGAPI orgapi = SDK.getORGAPI();
|
||
UserModel user = orgapi.getUser(userid);
|
||
DepartmentModel departmentByUser = orgapi.getDepartmentByUser(userid);
|
||
bo.set("LOGINUSERNAME", userid);
|
||
bo.set("USERBUNAME", user.getExt4());
|
||
bo.set("USERPOST", user.getPositionName());
|
||
bo.set("USERDEPTNAME", departmentByUser.getPathNameOfCache());
|
||
bo.set("LOGINTIME", logTime);
|
||
bo.set("LOGINCOUNTS", 1);
|
||
bo.set("LOGTYPE", Integer.valueOf(logType));
|
||
SDK.getBOAPI().createDataBO("BO_EU_USER_LOGIN_LOG", bo, UserContext.fromUID("admin"));
|
||
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* OA系统单点访问表单数据
|
||
*
|
||
* @param me
|
||
* @param params
|
||
* @return
|
||
*/
|
||
@Mapping("com.yili_form_page_open")
|
||
public String openFormPage(UserContext me, RequestParams params) {
|
||
//System.out.println("进入表单了===========");
|
||
//System.out.println("参数输出==========="+params.asMap());
|
||
//打开待办时记录日志
|
||
try {
|
||
setUserLog("", me.getUID(), "2");
|
||
} catch (Exception e) {
|
||
}
|
||
String sessionId = me.getSessionId();
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
if (!SDK.getPortalAPI().checkSession(sessionId)) {
|
||
SSOUtil ssoUtil = new SSOUtil();
|
||
sessionId = ssoUtil.registerClientSessionNoPassword(me.getUID(), "cn", portalUrl, me.getDeviceType());
|
||
}
|
||
UserContext uc = UserContext.fromSessionId(sessionId);
|
||
UserTaskFormsWeb web = new UserTaskFormsWeb(uc);
|
||
String processInstId = params.get("processInstId");
|
||
String taskInstId = params.get("taskInstId");
|
||
|
||
|
||
if (!UtilString.isEmpty(taskInstId) && taskInstId.equals("null")) {
|
||
taskInstId = "";
|
||
}
|
||
int openState = 0;
|
||
//根据流程实例去获取表单的 状态
|
||
if (!taskInstId.equals("")) {
|
||
TaskAPI taskAPI = SDK.getTaskAPI();
|
||
final TaskInstance taskInstance = taskAPI.getTaskInstance(taskInstId);
|
||
if (null == taskInstance) {
|
||
taskInstId = "";
|
||
} else {
|
||
if ("delete".equals(taskInstance.getControlState())) {
|
||
taskInstId = "";
|
||
} else {
|
||
openState = taskInstance.getState();
|
||
}
|
||
}
|
||
}
|
||
int currentPage = params.getInt("currentPage", 1);
|
||
String formDefId = params.get("formDefId", "");
|
||
String boId = params.get("boId", "");
|
||
String lang = params.get("lang");
|
||
if (!UtilString.isEmpty(lang)) {
|
||
me.setLanguages(lang);
|
||
}
|
||
String extParam = params.get("extParam");
|
||
JSONObject extParamJO = null;
|
||
if (!UtilString.isEmpty(extParam)) {
|
||
try {
|
||
extParamJO = JSONObject.parseObject(URLDecoder.decode(extParam, StandardCharsets.UTF_8.name()));
|
||
} catch (UnsupportedEncodingException var14) {
|
||
var14.printStackTrace();
|
||
}
|
||
}
|
||
boolean isDisplayToolbar = params.getBoolean("displayToolbar", true);
|
||
String formPage = web.getFormPage(processInstId, taskInstId, openState, currentPage, formDefId, boId, isDisplayToolbar, extParamJO);
|
||
//String formURL = SDK.getFormAPI().getFormURL("", sessionId, processInstId,taskInstId, 1, null, null, null);
|
||
//System.err.println("单点登录页面链接--->"+formURL);
|
||
//return portalUrl+"/r"+formURL.substring(1);
|
||
////System.out.println("输出表单==========="+formPage);
|
||
return formPage;
|
||
}
|
||
|
||
//pc端待阅
|
||
@Mapping("com.yili_process_page")
|
||
public String processTest(UserContext me, RequestParams params) throws IOException, SQLException {
|
||
// System.out.println("params>>>>>>>>>>>>"+params.toString());
|
||
// System.out.println("UserContext>>>>>>>>>>>>"+me.getUID());
|
||
String userMobile = me.getDeviceType();
|
||
String html = "index_web.html";
|
||
Connection conn = DBSql.open();
|
||
ArrayList<String> isNumberAscArray = new ArrayList<String>();
|
||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||
try {
|
||
JSONArray jsonArray = new JSONArray();
|
||
String sid = me.getSessionId();
|
||
String processInstId = params.get("processInstId");
|
||
String taskInstId = params.get("taskInstId");
|
||
ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId);
|
||
try {
|
||
// 记录门户待阅
|
||
setRecord(me.getUID(), processInstId, instanceById.getTitle());
|
||
|
||
|
||
} catch (Exception e) {
|
||
}
|
||
String usercode = "admin";
|
||
if (UtilString.isNotEmpty(params.get("usercode"))) {
|
||
usercode = params.get("usercode");
|
||
}
|
||
map.put("sid", sid);
|
||
|
||
List<BO> list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
List<BO> lists = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
List<BO> list_stop = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
int num = 1;
|
||
// 发布
|
||
if (list.size() > 0) {
|
||
// System.out.println("这个是更新的架构数据");
|
||
for (BO bo : list) {
|
||
// System.out.println("开始时间》》》》》》》" + System.currentTimeMillis());
|
||
JSONObject jsonObject = new JSONObject();
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='"
|
||
+ bo.get("PUBLISHFILEID") + "'";
|
||
RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql);
|
||
String id = bo.getString("TASKID");
|
||
jsonObject.put("title", bo.get("PUBLISHFILENAME"));
|
||
jsonObject.put("file_number", 0);
|
||
jsonObject.put("link",
|
||
SDK.getPortalAPI().getPortalUrl()
|
||
+ "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid="
|
||
+ Row_maps_is_not_publish.getString("id") + "&sid=" + sid);
|
||
jsonObject.put("size", "");
|
||
// jsonObject.put("id", num);
|
||
jsonObject.put("taskId", id);
|
||
jsonObject.put("id", bo.getString("PUBLISHFILEID"));
|
||
jsonArray.add(jsonObject);
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
// String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where
|
||
// palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID=
|
||
// '"+bo.getString("PUBLISHFILEID")+"') AND FILETYPE = 'f'";
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
// 文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
// 显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
// groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
// 文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
// 是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
// 原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
// 是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
// sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
// 文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
// 文档预览
|
||
String sourceAppId = instanceById.getAppId();
|
||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview";
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
String base_url = "https://bpm.yili.com:8088/portal/r";
|
||
if (row.getString("FILENAME").toString().contains(".xls")
|
||
|| row.getString("FILENAME").toString().contains(".xlsx")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link", base_url + ros.get("url").toString().substring(1));
|
||
}
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
}
|
||
num++;
|
||
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 当发布和变更为空时,显示作废的文件
|
||
*/
|
||
if (list.size() == 0 && lists.size() == 0) {
|
||
if (list_stop.size() > 0) {
|
||
// System.out.println("这个是作废的架构数据");
|
||
for (BO bo : list_stop) {
|
||
// System.out.println("开始时间》》》》》》》" + System.currentTimeMillis());
|
||
JSONObject jsonObject = new JSONObject();
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='"
|
||
+ bo.get("STOPFILEID") + "'";
|
||
RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql);
|
||
String id = bo.getString("TASKID");
|
||
jsonObject.put("title", bo.get("STOPFILENAME"));
|
||
jsonObject.put("file_number", 0);
|
||
jsonObject.put("link",
|
||
SDK.getPortalAPI().getPortalUrl()
|
||
+ "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid="
|
||
+ Row_maps_is_not_publish.getString("id") + "&sid=" + sid);
|
||
jsonObject.put("size", "");
|
||
jsonObject.put("id", bo.getString("STOPFILEID"));
|
||
jsonObject.put("taskId", id);
|
||
jsonArray.add(jsonObject);
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql
|
||
.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
// String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where
|
||
// palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID=
|
||
// '"+bo.getString("PUBLISHFILEID")+"') AND FILETYPE = 'f'";
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
// 文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
// 显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
// groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
// 文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
// 是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
// 原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
// 是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
// sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
// 文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
// 文档预览
|
||
String sourceAppId = instanceById.getAppId();
|
||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview";
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
String base_url = "https://bpm.yili.com:8088/portal/r";
|
||
if (row.getString("FILENAME").toString().contains(".xls")
|
||
|| row.getString("FILENAME").toString().contains(".xlsx")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link", base_url + ros.get("url").toString().substring(1));
|
||
}
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
}
|
||
num++;
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
// 变更
|
||
if (lists.size() > 0) {
|
||
for (BO bo : lists) {
|
||
// System.out.println("这个是更新文件的架构");
|
||
// System.out.println("开始时间》》》》》》》" + System.currentTimeMillis());
|
||
JSONObject jsonObject = new JSONObject();
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID ='"
|
||
+ bo.get("CHANGEDFILEIDNEW") + "'";
|
||
RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql);
|
||
String id = bo.getString("TASKID");
|
||
jsonObject.put("title", bo.get("CHANGEDFILENAMENEW"));
|
||
jsonObject.put("file_number", 0);
|
||
jsonObject.put("link",
|
||
SDK.getPortalAPI().getPortalUrl()
|
||
+ "/r/w?cmd=com.actionsoft.apps.coe.pal.publisher_publish_file_open&uuid="
|
||
+ Row_maps_is_not_publish.getString("id") + "&sid=" + sid);
|
||
jsonObject.put("size", "");
|
||
jsonObject.put("id", bo.get("CHANGEDFILEIDNEW"));
|
||
jsonObject.put("taskId", id);
|
||
jsonArray.add(jsonObject);
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.get("CHANGEDFILEIDNEW") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("CHANGEDFILEIDNEW") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.get("CHANGEDFILEIDNEW") + "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
// String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where
|
||
// palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID=
|
||
// '"+bo.getString("PUBLISHFILEID")+"') AND FILETYPE = 'f'";
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
// 文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
// 显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
// groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
// 文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
// 是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
// 原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
// 是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
// sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
// 文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
// 文档预览
|
||
String sourceAppId = instanceById.getAppId();
|
||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview";
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
String base_url = "https://bpm.yili.com:8088/portal/r";
|
||
if (row.getString("FILENAME").toString().contains(".xls")
|
||
|| row.getString("FILENAME").toString().contains(".xlsx")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link", base_url + ros.get("url").toString().substring(1));
|
||
}
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
}
|
||
|
||
num++;
|
||
|
||
}
|
||
}
|
||
|
||
String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
|
||
.addQuery("OPTIONTYPE IS NOT NULL", null).detail().getString("RELEASE_INSTRUCTIONS");
|
||
BO bo_act_coe_publishs = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
|
||
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
|
||
|
||
// }
|
||
map.put("subString", substring);
|
||
map.put("ProcessTile", bo_act_coe_publishs.getString("PROCESS_TITLE"));
|
||
map.put("processInstId", processInstId);
|
||
map.put("sid", sid);
|
||
// System.out.println("jsonArray=====>>>>>>>>>"+jsonArray);
|
||
boolean contains = isNumberAscArray.contains("false");
|
||
if (!contains) {
|
||
try {
|
||
jsonArray.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("file_number")));
|
||
} catch (Exception e) {
|
||
throw new AWSQuotaException("附件格式请以:《附件1:XXXXXX》格式命名");
|
||
}
|
||
}
|
||
map.put("jsonlist", jsonArray);
|
||
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
String url = portalUrl + "/r/or?cmd=com.yili_process_page&processInstId=" + processInstId + "&taskInstId="
|
||
+ taskInstId;
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
// String s =
|
||
// httpClientUtil.SendPreview("http://10.119.22.207:80/services/service_lcglpt?wsdl",
|
||
// jsonObject);
|
||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
|
||
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
|
||
List<BO> bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
|
||
.addQuery("USER_ID=", usercode).list();
|
||
if (bo_act_dataid.size() > 0) {
|
||
System.out.println("查询未读数据=============" + processInstId + "USER_ID=========" + usercode);
|
||
for (BO bo : bo_act_dataid) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("action", "read");
|
||
jsonObject.put("status", "1");
|
||
jsonObject.put("dataid", bo.getString("DATAID"));
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
|
||
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
|
||
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
|
||
HttpClient client = new HttpClient();
|
||
int timeout = 10000;
|
||
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
|
||
String s = UtilUrl.doPostSoap(readurl, xmlStr, "");
|
||
System.err.println(instanceById.getTitle() + "OA待阅PC端阅读返回=======>" + s);
|
||
String nums = DBSql.getString(
|
||
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
|
||
if (UtilString.isNotEmpty(nums)) {
|
||
Integer read_num = Integer.valueOf(nums);
|
||
read_num += 1;
|
||
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
|
||
+ processInstId + "'");
|
||
}
|
||
}
|
||
|
||
} else {
|
||
List<BO> actAlreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
|
||
.addQuery("USER_ID=", usercode).list();
|
||
if (actAlreadyDataid.size() > 0) {
|
||
System.out.println("查询已读数据=============" + processInstId + "USER_ID=========" + usercode);
|
||
for (BO bo : actAlreadyDataid) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("action", "read");
|
||
jsonObject.put("status", "1");
|
||
jsonObject.put("dataid", bo.getString("DATAID"));
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
|
||
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
|
||
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
|
||
HttpClient client = new HttpClient();
|
||
int timeout = 10000;
|
||
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
|
||
String s = UtilUrl.doPostSoap(readurl, xmlStr, "");
|
||
System.err.println(instanceById.getTitle() + "OA待阅PC端阅读返回=======>" + s);
|
||
String nums = DBSql.getString(
|
||
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
|
||
if (UtilString.isNotEmpty(nums)) {
|
||
Integer read_num = Integer.valueOf(nums);
|
||
read_num += 1;
|
||
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
|
||
+ processInstId + "'");
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
// 用户打开阅览界面日志
|
||
setUserLog(processInstId, me.getUID(), "3");
|
||
|
||
// }
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
} finally {
|
||
conn.close();
|
||
}
|
||
return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration", html, map);
|
||
}
|
||
|
||
//门户待阅同步更新
|
||
public String setRecord(String uid, String id, String fileName) {
|
||
String sql = "SELECT READFILECOUNT FROM BO_EU_PAL_RECORD WHERE FILEID = ? AND READFILENAME = ?";
|
||
RowMap map= DBSql.getMap(sql, new Object[]{id, uid});
|
||
int num = 0;
|
||
if (null != map) {
|
||
String readCount = map.getString("READFILECOUNT");
|
||
int count = Integer.parseInt(readCount) + 1;
|
||
String s = "UPDATE BO_EU_PAL_RECORD SET READFILECOUNT = ? WHERE FILEID = ? AND READFILENAME = ?";
|
||
num = DBSql.update(s, new Object[]{count, id, uid});
|
||
} else {
|
||
BO bo = new BO();
|
||
bo.set("FILEID", id);
|
||
bo.set("FILENAME", fileName);
|
||
bo.set("READFILENAME", uid);
|
||
bo.set("READFILETIME", LocalDate.now());
|
||
bo.set("READFILECOUNT", "1");
|
||
num = SDK.getBOAPI().createDataBO("BO_EU_PAL_RECORD", bo, UserContext.fromUID(uid));
|
||
}
|
||
|
||
return num + "";
|
||
}
|
||
|
||
|
||
@Mapping("com.yili_process_page_phone")
|
||
public String processPhone(UserContext me, RequestParams params) throws SQLException {
|
||
ArrayList<String> isNumberAscArray = new ArrayList<String>();
|
||
String userMobile = me.getDeviceType();
|
||
Connection conn = DBSql.open();
|
||
JSONArray jsonArray = new JSONArray();
|
||
|
||
String html = "index_phone.html";
|
||
Map<String, Object> map = new LinkedHashMap<String, Object>();
|
||
try {
|
||
// UserContext uc = UserContext.fromSessionId(sid);
|
||
String sid = me.getSessionId();
|
||
String processInstId = params.get("processInstId");
|
||
String taskInstId = params.get("taskInstId");
|
||
ProcessInstance instanceById = SDK.getProcessAPI().getInstanceById(processInstId);
|
||
try {
|
||
//记录门户待阅
|
||
setRecord(me.getUID(), processInstId, instanceById.getTitle());
|
||
|
||
|
||
} catch (Exception e) {
|
||
}
|
||
String usercode = "admin";
|
||
if (UtilString.isNotEmpty(me.getUID())) {
|
||
usercode = me.getUID();
|
||
}
|
||
StringBuffer sb = new StringBuffer();
|
||
|
||
String sourceAppId = instanceById.getAppId();
|
||
// aslp服务地址
|
||
String aslp = "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview";
|
||
String substring = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
|
||
.addQuery("OPTIONTYPE IS NOT NULL", null).detail().getString("RELEASE_INSTRUCTIONS");
|
||
BO bo_act_coe_publish = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH", true).addQuery("BINDID=", processInstId)
|
||
.addQuery("OPTIONTYPE IS NOT NULL", null).detail();
|
||
|
||
List<BO> list = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_N", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
List<BO> lists = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_C", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
List<BO> list_stop = SDK.getBOAPI().query("BO_ACT_COE_PUBLISH_S", true).addQuery("BINDID=", processInstId)
|
||
.orderByCreated().asc().list();
|
||
int num = 1;
|
||
|
||
if (list.size() > 0) {
|
||
for (BO bo : list) {
|
||
|
||
if (StringUtils.isNotEmpty(bo.getString("TASKID"))
|
||
&& !bo.getString("TASKID").equals("submit_create")) {
|
||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||
// System.out.println(",odel>>>>>>>>"+bo.getString("TASKID"));
|
||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||
if (appProfile == null) {
|
||
throw new AWSException(
|
||
"Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1");
|
||
}
|
||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(),
|
||
OutputConst.EXT_APP_DC_OUTPUT);
|
||
if (dcProfile == null)
|
||
throw new AWSException(
|
||
"Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"
|
||
+ bo.getString("PUBLISHFILEID") + "'";
|
||
String lever = DBSql.getString(conn, sql_lever);
|
||
// System.out.println("lever====>>>>>"+lever);
|
||
if (lever.length() != 5) {
|
||
lever = lever + ".0";
|
||
}
|
||
String name = bo.getString("PUBLISHFILENAME").replaceAll("/", "");
|
||
DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(),
|
||
model.getWsId(), bo.getString("TASKID"), name + "_" + lever + ".doc");
|
||
|
||
// 调用App
|
||
|
||
// 参数定义列表
|
||
Map params_preview = new HashMap<String, Object>();
|
||
//文档是否允许下载,必填
|
||
params_preview.put("isDownload", true);
|
||
//显示文件名,必填
|
||
params_preview.put("fileNameOriginal", name + "_" + lever + ".doc");
|
||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_preview.put("isPDFCovertPNG", 0);
|
||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_preview.put("extParams", "");
|
||
//文档是否允许打印,必填
|
||
params_preview.put("isPrint", true);
|
||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_preview.put("isShowBackbtn", false);
|
||
//原文件DC,必填
|
||
params_preview.put("sourceDc", dcContext);
|
||
//是否显示默认预览工具栏,必填
|
||
params_preview.put("isShowDefaultToolbar", true);
|
||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_preview.put("isCopy", true);
|
||
//sessionid,必填
|
||
params_preview.put("sid", sid);
|
||
//文档是否加密,必填
|
||
params_preview.put("isEncrypt", false);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//文档预览
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview);
|
||
|
||
// System.out.println("ro>>>>>>>>>>>>>>>>"+ro);
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"
|
||
+ bo.get("PUBLISHFILEID") + "'";
|
||
List<RowMap> Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql);
|
||
|
||
/*
|
||
* boolean havingStartProcessPermission
|
||
* =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId);
|
||
* if(havingStartProcessPermission) {
|
||
*/
|
||
BigDecimal big = new BigDecimal(Row_maps_is_not_publish.get(0).getString("PLVER"));
|
||
|
||
JSONObject jsonObjects = new JSONObject();
|
||
jsonObjects.put("title", bo.get("PUBLISHFILENAME"));
|
||
jsonObjects.put("file_number", 0);
|
||
jsonObjects.put("link",
|
||
"https://bpm.yili.com:8088/portal/r" + ro.get("url").toString().substring(1));
|
||
// jsonObjects.put("size","12k");
|
||
jsonArray.add(jsonObjects);
|
||
}
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("PUBLISHFILEID") + "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
// String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where
|
||
// palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID=
|
||
// '"+bo.getString("PUBLISHFILEID")+"') AND FILETYPE = 'f'";
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
//文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
//显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
//文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
//原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
//是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
//sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
//文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
//文档预览
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
String base_url = "https://bpm.yili.com:8088/portal/r";
|
||
if (row.getString("FILENAME").toString().contains(".xls")
|
||
|| row.getString("FILENAME").toString().contains(".xlsx")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link", base_url + ros.get("url").toString().substring(1));
|
||
}
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
num++;
|
||
}
|
||
num++;
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 当发布和变更为空时,显示作废的文件
|
||
*/
|
||
if (list.size() == 0 && lists.size() == 0) {
|
||
if (list_stop.size() > 0) {
|
||
for (BO bo : list_stop) {
|
||
|
||
if (StringUtils.isNotEmpty(bo.getString("TASKID"))
|
||
&& !bo.getString("TASKID").equals("submit_create")) {
|
||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||
// System.out.println(",odel>>>>>>>>"+bo.getString("TASKID"));
|
||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||
if (appProfile == null) {
|
||
throw new AWSException(
|
||
"Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1");
|
||
}
|
||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(),
|
||
OutputConst.EXT_APP_DC_OUTPUT);
|
||
if (dcProfile == null)
|
||
throw new AWSException(
|
||
"Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"
|
||
+ bo.getString("STOPFILEID") + "'";
|
||
String lever = DBSql.getString(conn, sql_lever);
|
||
// System.out.println("lever====>>>>>"+lever);
|
||
if (lever.length() != 5) {
|
||
lever = lever + ".0";
|
||
}
|
||
String name = bo.getString("STOPFILENAME").replaceAll("/", "");
|
||
DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(),
|
||
model.getWsId(), bo.getString("TASKID"), name + "_" + lever + ".doc");
|
||
|
||
// 调用App
|
||
|
||
// 参数定义列表
|
||
Map params_preview = new HashMap<String, Object>();
|
||
// 文档是否允许下载,必填
|
||
params_preview.put("isDownload", true);
|
||
// 显示文件名,必填
|
||
params_preview.put("fileNameOriginal", name + "_" + lever + ".doc");
|
||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_preview.put("isPDFCovertPNG", 0);
|
||
// groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_preview.put("extParams", "");
|
||
// 文档是否允许打印,必填
|
||
params_preview.put("isPrint", true);
|
||
// 是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_preview.put("isShowBackbtn", false);
|
||
// 原文件DC,必填
|
||
params_preview.put("sourceDc", dcContext);
|
||
// 是否显示默认预览工具栏,必填
|
||
params_preview.put("isShowDefaultToolbar", true);
|
||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_preview.put("isCopy", true);
|
||
// sessionid,必填
|
||
params_preview.put("sid", sid);
|
||
// 文档是否加密,必填
|
||
params_preview.put("isEncrypt", false);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
// 文档预览
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp,
|
||
params_preview);
|
||
|
||
// System.out.println("ro>>>>>>>>>>>>>>>>"+ro);
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"
|
||
+ bo.get("STOPFILEID") + "'";
|
||
List<RowMap> Row_maps_is_not_publish = DBSql.getMaps(conn, is_not_publish_sql);
|
||
|
||
/*
|
||
* boolean havingStartProcessPermission
|
||
* =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId);
|
||
* if(havingStartProcessPermission) {
|
||
*/
|
||
BigDecimal big = new BigDecimal(Row_maps_is_not_publish.get(0).getString("PLVER"));
|
||
|
||
JSONObject jsonObjects = new JSONObject();
|
||
jsonObjects.put("title", bo.get("STOPFILENAME"));
|
||
jsonObjects.put("file_number", 0);
|
||
jsonObjects.put("link",
|
||
"https://bpm.yili.com:8088/portal/r" + ro.get("url").toString().substring(1));
|
||
// jsonObjects.put("size","12k");
|
||
jsonArray.add(jsonObjects);
|
||
}
|
||
|
||
/*
|
||
* String sql_upfile =
|
||
* "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
* +bo.getString("STOPFILEID")+"'" + ")";
|
||
*/
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql
|
||
.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("STOPFILEID") + "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
// String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where
|
||
// palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID=
|
||
// '"+bo.getString("STOPFILEID")+"') AND FILETYPE = 'f'";
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
// 文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
// 显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
// PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
// groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
// 文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
// 是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
// 原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
// 是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
// 文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
// sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
// 文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
// 文档预览
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
String base_url = "https://bpm.yili.com:8088/portal/r";
|
||
if (row.getString("FILENAME").toString().contains(".xls")
|
||
|| row.getString("FILENAME").toString().contains(".xlsx")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link", base_url + ros.get("url").toString().substring(1));
|
||
}
|
||
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
num++;
|
||
}
|
||
num++;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
if (lists.size() > 0) {
|
||
for (BO bo : lists) {
|
||
|
||
if (StringUtils.isNotEmpty(bo.getString("TASKID"))
|
||
&& !bo.getString("TASKID").equals("submit_create")) {
|
||
OutputTaskModel model = new OutputTask().getTaskReportById(bo.getString("TASKID"));
|
||
// System.out.println(",odel>>>>>>>>"+bo.getString("TASKID"));
|
||
OutputAppProfile appProfile = OutputAppManager.getProfile(model.getProfileId());
|
||
if (appProfile == null) {
|
||
throw new AWSException(
|
||
"Not Find OutputAppProfile! profileId=" + "_900fde3255248317266cad1c72f157b1");
|
||
}
|
||
DCPluginProfile dcProfile = SDK.getDCAPI().getDCProfile(appProfile.getAppContext().getId(),
|
||
OutputConst.EXT_APP_DC_OUTPUT);
|
||
if (dcProfile == null)
|
||
throw new AWSException(
|
||
"Not Find DCProfile! repositoryName=" + OutputConst.EXT_APP_DC_OUTPUT);
|
||
String sql_lever = "SELECT PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE ID = '"
|
||
+ bo.getString("CHANGEDFILEIDNEW") + "'";
|
||
String lever = DBSql.getString(conn, sql_lever);
|
||
// System.out.println("lever====>>>>>"+lever);
|
||
if (lever.length() != 5) {
|
||
lever = lever + ".0";
|
||
}
|
||
String name = bo.getString("CHANGEDFILENAMENEW").replaceAll("/", "");
|
||
DCContext dcContext = new DCContext(me, dcProfile, appProfile.getAppContext().getId(),
|
||
model.getWsId(), bo.getString("TASKID"), name + "_" + lever + ".doc");
|
||
|
||
// 调用App
|
||
|
||
// 参数定义列表
|
||
Map params_preview = new HashMap<String, Object>();
|
||
//文档是否允许下载,必填
|
||
params_preview.put("isDownload", true);
|
||
//显示文件名,必填
|
||
params_preview.put("fileNameOriginal", name + "_" + lever + ".doc");
|
||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_preview.put("isPDFCovertPNG", 0);
|
||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_preview.put("extParams", "");
|
||
//文档是否允许打印,必填
|
||
params_preview.put("isPrint", true);
|
||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_preview.put("isShowBackbtn", false);
|
||
//原文件DC,必填
|
||
params_preview.put("sourceDc", dcContext);
|
||
//是否显示默认预览工具栏,必填
|
||
params_preview.put("isShowDefaultToolbar", true);
|
||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_preview.put("isCopy", true);
|
||
//sessionid,必填
|
||
params_preview.put("sid", sid);
|
||
//文档是否加密,必填
|
||
params_preview.put("isEncrypt", false);
|
||
AppAPI appAPI = SDK.getAppAPI();
|
||
//文档预览
|
||
ResponseObject ro = appAPI.callASLP(appAPI.getAppContext(sourceAppId), aslp, params_preview);
|
||
|
||
// System.out.println("ro>>>>>>>>>>>>>>>>"+ro);
|
||
String is_not_publish_sql = "SELECT id,PLVER FROM APP_ACT_COE_PAL_REPOSITORY WHERE id ='"
|
||
+ bo.get("CHANGEDFILEIDNEW") + "'";
|
||
RowMap Row_maps_is_not_publish = DBSql.getMap(conn, is_not_publish_sql);
|
||
|
||
/*
|
||
* boolean havingStartProcessPermission
|
||
* =SDK.getPermAPI().havingStartProcessPermission(uc.getUID(), processDefId);
|
||
* if(havingStartProcessPermission) {
|
||
*/
|
||
BigDecimal big = new BigDecimal(Row_maps_is_not_publish.getString("PLVER"));
|
||
|
||
JSONObject jsonObjects = new JSONObject();
|
||
jsonObjects.put("title", bo.get("CHANGEDFILENAMENEW"));
|
||
jsonObjects.put("file_number", 0);
|
||
jsonObjects.put("link",
|
||
"https://bpm.yili.com:8088/portal/r" + ro.get("url").toString().substring(1));
|
||
// jsonObjects.put("size","12k");
|
||
jsonArray.add(jsonObjects);
|
||
}
|
||
|
||
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("CHANGEDFILEIDNEW") + "'" + ") ORDER BY FILENAME ASC";
|
||
String methodId = DBSql.getString("select PLMETHODID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("CHANGEDFILEIDNEW") + "'");
|
||
if (UtilString.isNotEmpty(methodId)) {
|
||
if (methodId.equals("control.policy")) {
|
||
sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"
|
||
+ bo.getString("CHANGEDFILEIDNEW")
|
||
+ "') AND FILETYPE = 'f' ORDER BY FILENAME ASC";
|
||
}
|
||
}
|
||
|
||
List<RowMap> maps = DBSql.getMaps(conn, sql_upfile);
|
||
UserContext userContext = UserContext.fromSessionId(sid);
|
||
UpfileWeb upfileWeb = new UpfileWeb(userContext);
|
||
|
||
for (RowMap row : maps) {
|
||
UpfileModel upfileModel = new UpfileModel();
|
||
upfileModel.setType(row.getString("FILETYPE"));
|
||
upfileModel.setFileName(row.getString("FILENAME"));
|
||
upfileModel.setPl_uuid(row.getString("PALREPOSITORYID"));
|
||
upfileModel.setShape_uuid(row.getString("SHAPEID"));
|
||
DCContext dcContexts = upfileWeb.getDCContext(upfileModel);
|
||
Map params_previews = new HashMap<String, Object>();
|
||
//文档是否允许下载,必填
|
||
params_previews.put("isDownload", true);
|
||
//显示文件名,必填
|
||
params_previews.put("fileNameOriginal", row.getString("FILENAME"));
|
||
//PDF转图片处理选项。- 0代表只在需要时做转换;- 1代表打开即检查是否已转换成图片,如未处理,强制转换。默认0,非必填
|
||
params_previews.put("isPDFCovertPNG", 0);
|
||
//groupJson参数,用于表单附件OfficeOnline服务预览回传文件流,非必填
|
||
params_previews.put("extParams", "");
|
||
//文档是否允许打印,必填
|
||
params_previews.put("isPrint", true);
|
||
//是否显示顶部工具栏的返回按钮,默认显示,非必填
|
||
params_previews.put("isShowBackbtn", "");
|
||
//原文件DC,必填
|
||
params_previews.put("sourceDc", dcContexts);
|
||
//是否显示默认预览工具栏,必填
|
||
params_previews.put("isShowDefaultToolbar", true);
|
||
//文档是否允许复制。true为允许复制,转换结果为PDF格式文件;false为不可复制,转换结果为PNG格式文件(注意参数值为false时转换时间稍长),必填
|
||
params_previews.put("isCopy", true);
|
||
//sessionid,必填
|
||
params_previews.put("sid", sid);
|
||
//文档是否加密,必填
|
||
params_previews.put("isEncrypt", false);
|
||
AppAPI appAPIs = SDK.getAppAPI();
|
||
//文档预览
|
||
ResponseObject ros = appAPIs.callASLP(appAPIs.getAppContext(sourceAppId), aslp,
|
||
params_previews);
|
||
|
||
JSONObject jsonObject1 = new JSONObject();
|
||
//按照附件编号排序
|
||
String fileNamel = row.getString("FILENAME");
|
||
if (UtilString.isNotEmpty(fileNamel) && fileNamel.contains("附件") && fileNamel.length() > 2 && (fileNamel.contains(":") || fileNamel.contains(":"))) {
|
||
if (fileNamel.indexOf("附件") == 0) {
|
||
int indexOf2 = 3;
|
||
if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
} else if (fileNamel.contains(":")) {
|
||
indexOf2 = fileNamel.indexOf(":");
|
||
}
|
||
String numberStr = fileNamel.substring(2, indexOf2);
|
||
if (isNumeric(numberStr) && !"".equals(numberStr)) {
|
||
isNumberAscArray.add("true");
|
||
int fileNumber = Integer.parseInt(numberStr);
|
||
jsonObject1.put("file_number", fileNumber);
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
|
||
} else {
|
||
isNumberAscArray.add("false");
|
||
}
|
||
jsonObject1.put("title", row.getString("FILENAME"));
|
||
if (row.getString("FILENAME").contains(".xlsx") || row.getString("FILENAME").contains(".xls")) {
|
||
jsonObject1.put("link", ros.get("url").toString().substring(0));
|
||
} else {
|
||
jsonObject1.put("link",
|
||
"https://bpm.yili.com:8088/portal/r" + ros.get("url").toString().substring(1));
|
||
}
|
||
|
||
// jsonObject1.put("size","12k");
|
||
jsonArray.add(jsonObject1);
|
||
num++;
|
||
}
|
||
num++;
|
||
}
|
||
|
||
}
|
||
|
||
// }
|
||
// System.out.println("substring>>>>>>>>>>"+substring);
|
||
map.put("subString", substring);
|
||
map.put("ProcessTile", bo_act_coe_publish.getString("PROCESS_TITLE"));
|
||
map.put("processInstId", processInstId);
|
||
map.put("sid", sid);
|
||
boolean contains = isNumberAscArray.contains("false");
|
||
if (!contains) {
|
||
try {
|
||
jsonArray.sort(Comparator.comparing(obj -> ((JSONObject) obj).getInteger("file_number")));
|
||
} catch (Exception e) {
|
||
throw new AWSQuotaException("附件格式请以:《附件1:XXXXXX》格式命名");
|
||
}
|
||
}
|
||
///////////
|
||
// System.out.println("jsonArray=====>>>>>>>>>"+jsonArray);
|
||
map.put("jsonlist", jsonArray);
|
||
// DBSql.close(conn);
|
||
|
||
String portalUrl = SDK.getPortalAPI().getPortalUrl();
|
||
String url = portalUrl + "/r/or?cmd=com.yili_process_page&processInstId=" + processInstId + "&taskInstId="
|
||
+ taskInstId;
|
||
String mobileurl = portalUrl + "/r/or?cmd=com.yili_process_page_phone&processInstId=" + processInstId
|
||
+ "&taskInstId=" + taskInstId;
|
||
HttpClientUtils httpClientUtil = new HttpClientUtils();
|
||
List<BO> bo_act_dataid = SDK.getBOAPI().query("BO_ACT_DATAID").addQuery("PROCESSID=", processInstId)
|
||
.addQuery("USER_ID=", usercode).list();
|
||
if (bo_act_dataid.size() > 0) {
|
||
for (BO bo : bo_act_dataid) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("status", "1");
|
||
jsonObject.put("action", "read");
|
||
jsonObject.put("dataid", bo.getString("DATAID"));
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
|
||
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
|
||
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
|
||
int timeout = 10000;
|
||
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
|
||
String s = UtilUrl.doPostSoap(readurl, xmlStr, "");
|
||
//System.err.println(instanceById.getTitle()+"_OA待阅移动端阅读返回=======>"+s);
|
||
String nums = DBSql.getString(
|
||
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
|
||
if (UtilString.isNotEmpty(nums)) {
|
||
Integer read_num = Integer.valueOf(nums);
|
||
read_num += 1;
|
||
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
|
||
+ processInstId + "'");
|
||
}
|
||
}
|
||
|
||
} else {
|
||
List<BO> alreadyDataid = SDK.getBOAPI().query("BO_ACT_ALREADY_DATAID").addQuery("PROCESSID=", processInstId)
|
||
.addQuery("USER_ID=", usercode).list();
|
||
if (alreadyDataid.size() > 0) {
|
||
for (BO bo : alreadyDataid) {
|
||
JSONObject jsonObject = new JSONObject();
|
||
jsonObject.put("status", "1");
|
||
jsonObject.put("action", "read");
|
||
jsonObject.put("dataid", bo.getString("DATAID"));
|
||
String xmlStr = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||
+ " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>"
|
||
+ " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" + " </web:in0>"
|
||
+ " </web:service>" + " </soapenv:Body>" + "</soapenv:Envelope>";
|
||
int timeout = 10000;
|
||
String readurl = SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration", "readurl");
|
||
String s = UtilUrl.doPostSoap(readurl, xmlStr, "");
|
||
System.err.println(instanceById.getTitle() + "_OA待阅移动端阅读返回=======>" + s);
|
||
String nums = DBSql.getString(
|
||
"select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" + processInstId + "'");
|
||
if (UtilString.isNotEmpty(nums)) {
|
||
Integer read_num = Integer.valueOf(nums);
|
||
read_num += 1;
|
||
DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num + "' where PROCESSID = '"
|
||
+ processInstId + "'");
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
// 用户打开阅览界面日志
|
||
setUserLog(processInstId, me.getUID(), "3");
|
||
/*
|
||
* JSONObject jsonObject = new JSONObject(); SimpleDateFormat sdf = new
|
||
* SimpleDateFormat("yyyy-MM-dd"); String sql =
|
||
* "SELECT * FROM WFC_PROCESS WHERE ID ='" + processInstId + "'"; List<RowMap>
|
||
* rowMaps = DBSql.getMaps(conn, sql); if (rowMaps.size() == 1) {
|
||
*
|
||
* jsonObject.put("action", "read"); //
|
||
* jsonObject.put("dept",me.getDepartmentModel().getNo()); //
|
||
* jsonObject.put("user",me.getUID()); // jsonObject.put("remark","");
|
||
* jsonObject.put("status", "1"); // jsonObject.put("pcurl",url); //
|
||
* jsonObject.put("mobileurl",mobileurl); try { BO bo_act_dataid =
|
||
* SDK.getBOAPI().query("BO_ACT_DATAID", true).addQuery("PROCESSID=",
|
||
* processInstId) .addQuery("USER_ID=", usercode).detail(); if (bo_act_dataid !=
|
||
* null) { jsonObject.put("dataid", bo_act_dataid.getString("DATAID")); } }
|
||
* catch (Exception e) {
|
||
*
|
||
* }
|
||
*
|
||
* // jsonObject.put("userList","00345531"); HttpClientUtils httpClientUtil =
|
||
* new HttpClientUtils(); // String s = // httpClientUtil.SendPreview(
|
||
* "http://10.119.22.207:80/services/service_lcglpt?wsdl", // jsonObject);
|
||
*
|
||
* String xmlStr =
|
||
* "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"webservices.yili.weaver.com.cn\">\n"
|
||
* + " <soapenv:Header/>" + " <soapenv:Body>" + " <web:service>" +
|
||
* " <web:in0>" + "<![CDATA[" + jsonObject + "]]>" +
|
||
* " </web:in0>" + " </web:service>" + " </soapenv:Body>" +
|
||
* "</soapenv:Envelope>"; // HttpClientUtil httpClientUtil = new
|
||
* HttpClientUtil(); String readurl =
|
||
* SDK.getAppAPI().getProperty("com.awspaas.user.apps.yili.integration",
|
||
* "readurl");
|
||
*
|
||
* String s = UtilUrl.doPostSoap(readurl, xmlStr, ""); //
|
||
* System.out.println("s==============>>>>>>>>>>>"+s);
|
||
*
|
||
* } String nums = DBSql
|
||
* .getString("select READNUM from BO_EU_PAL_READ_LOG where PROCESSID = '" +
|
||
* processInstId + "'"); if (UtilString.isNotEmpty(nums)) {
|
||
*
|
||
* Integer read_num = Integer.valueOf(nums); read_num += 1;
|
||
* DBSql.update("update BO_EU_PAL_READ_LOG set READNUM = '" + read_num +
|
||
* "' where PROCESSID = '" + processInstId + "'"); }
|
||
*/
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
} finally {
|
||
conn.close();
|
||
}
|
||
return HtmlPageTemplate.merge("com.awspaas.user.apps.yili.integration", html, map);
|
||
}
|
||
|
||
|
||
/**
|
||
* 从 String 中提取数字
|
||
*
|
||
* @param string
|
||
* @return
|
||
*/
|
||
public static String getNumberFromString(String string) {
|
||
String str = string;
|
||
str = str.trim();
|
||
StringBuffer str2 = new StringBuffer();
|
||
if (str != null && !"".equals(str)) {
|
||
for (int i = 0; i < str.length(); i++) {
|
||
if (str.charAt(i) >= 48 && str.charAt(i) <= 57) {
|
||
String s = String.valueOf(str.charAt(i));
|
||
str2.append(s);
|
||
}
|
||
}
|
||
}
|
||
return str2.toString();
|
||
}
|
||
|
||
public static boolean isNumeric(String str) {
|
||
for (int i = str.length(); --i >= 0; ) {
|
||
int chr = str.charAt(i);
|
||
if (chr < 48 || chr > 57)
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
}
|