流程发布推送OA、EHSQ、KMS代码调整

This commit is contained in:
lihongyu 2022-11-06 06:18:35 +08:00
parent 60b612b751
commit 84a27d589a
13 changed files with 3375 additions and 17 deletions

View File

@ -35,10 +35,8 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis
if("00000000-0000-0000-0000-000000000000".equals(ctx.getTaskInstance().getParentTaskInstId())) {
BO boData = (BO) ctx.getParameter(ListenerConst.FORM_EVENT_PARAM_BODATA);
Object variable = SDK.getProcessAPI().getVariable(ctx.getProcessInstance(), "createType");
System.err.println("=====boData1=====>"+boData);
System.err.println("====variable1======>"+variable);
if(boData==null&&variable==null) {
System.err.println("===任务创建后创建====>");
System.err.println("任务创建后执行====>");
saveData(ctx);
}
}
@ -106,7 +104,7 @@ public class ApplyTaskAfterCreated extends ExecuteListener implements ExecuteLis
bo.set("DEPARTMENT_PROOFREADER", data.getString("DEAPRTMNUM"));
bo.set("PROCESS_MANAGER", data.getString("PROCESSMNUMBER"));
bo.set("WSID", "7d3ca852-a0bd-42e6-80b1-3dcea6f55083");
bo.set("RELEASE_INSTRUCTIONS", "<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:center\"><strong><span style=\";font-family:宋体;font-size:24px\">关于发布《XXXXXXXXXXXX》的通知</span></strong><br></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:center\"><strong><span style=\";font-family:宋体;font-size:14px\">&nbsp;</span></strong></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">各事业部、分(子)公司、总部各部(室):</span></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-indent:43px;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">为</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">,现下发《</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">》,请各单位遵照执行。</span></p><p style=\"margin-top:5px;margin-right:0;margin-bottom:5px;margin-left:0;text-indent:43px;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">特此通知。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right;\"><span style=\"text-indent: 299px; font-family: 仿宋_GB2312; font-size: 21px;\">xxxxxxxxx单位名称</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right;\"><span style=\"font-family: 仿宋_GB2312; font-size: 21px;\">2022年7月27日</span></p>");//流程实例状态
bo.set("RELEASE_INSTRUCTIONS", "<div id=\"RELEASE_INSTRUCTIONS_htmlRead\" class=\"readonly-html-div\" style=\"width: 100%;\"><style style=\"display: none;\">#RELEASE_INSTRUCTIONS_htmlRead img{vertical-align:bottom}li{list-style: inherit;}</style><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:24px\"><br></span></strong></p><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:24px\">关于发布《XXXXXXXXXXXX》的通知</span></strong><br></p><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:14px\">&nbsp;</span></strong></p><p style=\"margin: 0px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">各事业部、分(子)公司、总部各部(室):</span></p><p style=\"margin: 0px; text-indent: 43px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">为</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">,现下发《</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">》,请各单位遵照执行。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">特此通知。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right; line-height: 1.5em; display: block;\"><span style=\"text-indent: 299px; font-family: 仿宋_GB2312; font-size: 21px;\">xxxxxxxxx单位名称</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right; line-height: 1.5em; display: block;\"><span style=\"font-family: 仿宋_GB2312; font-size: 21px;\">2022年7月27日</span></p></div>");//流程实例状态
SDK.getBOAPI().create(PublisherConstant.BOTABLENAME, bo, ctx.getProcessInstance(), userContext);
//如果需要展示在表单上需要调用如下代码注意此操作不会更新数据库中的数据
ctx.setParameter(ListenerConst.FORM_EVENT_PARAM_BODATA, bo);

View File

@ -2,7 +2,14 @@ package com.actionsoft.apps.coe.pal.publisher.event;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -36,20 +43,16 @@ import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilDate;
import com.actionsoft.bpms.util.UtilString;
import com.actionsoft.exception.AWSAPIException;
import com.actionsoft.exception.AWSDataAccessException;
import com.actionsoft.exception.AWSException;
import com.actionsoft.exception.BPMNError;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.awspaas.yili.publishevent.event.ProcessEndAfterEvent;
public class PublishExecuteListenerInterfaceImpl extends ExecuteListener implements ExecuteListenerInterface {
@ -189,8 +192,8 @@ public class PublishExecuteListenerInterfaceImpl extends ExecuteListener impleme
updateEffectiveDateProperty(processInstId, bo, nowTime, bolistN, bolistC);
// 流程发布范围权限单独存储
savePublishScope(bo, bolistN, bolistC, bolistS);
//发布待阅推送知识库推送EHSQ
new ProcessEndAfterEvent().ProcessData(param);
//发布待阅推送知识库推送EHSQ 改为确认发布节点任务完成后执行
//new ProcessEndAfterEvent().ProcessData(param);
}

View File

@ -36,8 +36,6 @@ public class PublishLoadBefore extends ExecuteListener {
// BO表记录注意该记录的数据如果被修改将会体现到表单上修改后不会直接持久化到数据库中
BO boData = (BO) ctx.getParameter(ListenerConst.FORM_EVENT_PARAM_BODATA);
Object variable = SDK.getProcessAPI().getVariable(ctx.getProcessInstance(), "createType");
System.err.println("====boData2====>"+boData);
System.err.println("====variable2====>"+variable);
if (null == boData) {
} else {
// 如果有值就不再去计算了
@ -47,7 +45,7 @@ public class PublishLoadBefore extends ExecuteListener {
}
//如果是1是从oa创建就不用再获取
if ("pal".equals(variable)) {
System.err.println("===表单加载前创建====>");
System.err.println("表单加载前执行pal====>");
// 根据部门名称 和单位 计算出 内部校对人 和流程经理
UserContext me = ctx.getUserContext();
String departmentId = me.getUserModel().getDepartmentId();
@ -75,7 +73,7 @@ public class PublishLoadBefore extends ExecuteListener {
boData.set("DEPARTMENT_PROOFREADER", data.getString("DEAPRTMNUM"));
boData.set("PROCESS_MANAGER", data.getString("PROCESSMNUMBER"));
boData.set("RELEASE_INSTRUCTIONS",
"<p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:center\"><strong><span style=\";font-family:宋体;font-size:24px\">关于发布《XXXXXXXXXXXX》的通知</span></strong><br></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:center\"><strong><span style=\";font-family:宋体;font-size:14px\">&nbsp;</span></strong></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">各事业部、分(子)公司、总部各部(室):</span></p><p style=\"margin-top:0;margin-right:0;margin-bottom:0;margin-left:0;text-indent:43px;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">为</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">,现下发《</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">》,请各单位遵照执行。</span></p><p style=\"margin-top:5px;margin-right:0;margin-bottom:5px;margin-left:0;text-indent:43px;text-align:justify;text-justify:inter-ideograph\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">特此通知。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right;\"><span style=\"text-indent: 299px; font-family: 仿宋_GB2312; font-size: 21px;\">xxxxxxxxx单位名称</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right;\"><span style=\"font-family: 仿宋_GB2312; font-size: 21px;\">2022年7月27日</span></p>");// 流程实例状态
"<div id=\"RELEASE_INSTRUCTIONS_htmlRead\" class=\"readonly-html-div\" style=\"width: 100%;\"><style style=\"display: none;\">#RELEASE_INSTRUCTIONS_htmlRead img{vertical-align:bottom}li{list-style: inherit;}</style><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:24px\"><br></span></strong></p><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:24px\">关于发布《XXXXXXXXXXXX》的通知</span></strong><br></p><p style=\"margin: 0px; text-align: center; line-height: 1.5em; display: block;\"><strong><span style=\";font-family:宋体;font-size:14px\">&nbsp;</span></strong></p><p style=\"margin: 0px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">各事业部、分(子)公司、总部各部(室):</span></p><p style=\"margin: 0px; text-indent: 43px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">为</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">,现下发《</span><span style=\";font-family:宋体;font-size:21px\">xxxxxxxxxxxxxxx</span><span style=\";font-family:仿宋_GB2312;font-size:21px\">》,请各单位遵照执行。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: justify; line-height: 1.5em; display: block;\"><span style=\";font-family:仿宋_GB2312;font-size:21px\">特此通知。</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right; line-height: 1.5em; display: block;\"><span style=\"text-indent: 299px; font-family: 仿宋_GB2312; font-size: 21px;\">xxxxxxxxx单位名称</span></p><p style=\"margin: 5px 0px; text-indent: 43px; text-align: right; line-height: 1.5em; display: block;\"><span style=\"font-family: 仿宋_GB2312; font-size: 21px;\">2022年7月27日</span></p></div>");// 流程实例状态
// 如果需要展示在表单上需要调用如下代码注意此操作不会更新数据库中的数据
ctx.setParameter(ListenerConst.FORM_EVENT_PARAM_BODATA, boData);
}

View File

@ -146,7 +146,7 @@ public class CreateProcessController {
}
//批量导入权限
@Mapping("com.awspaas.user.apps.xitongfankui.createPrem")
public JSONObject createPrem(String sid,String processDefId) {
JSONObject result = new JSONObject();

View File

@ -0,0 +1,52 @@
package com.actionsoft.apps.coe.pal.publisher.extend;
import java.sql.Connection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
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.util.DBSql;
import com.actionsoft.sdk.local.SDK;
/**
* 表单加载前获取内部校对人和流程经理
* @author lihongyu
*
*/
@Controller
public class PublisherGetManagerController {
private static Logger logger = LoggerFactory.getLogger(PublisherGetManagerController.class);
// 修改文件发布状态
@Mapping("com.actionsoft.apps.coe.pal.publisher.PublisherGetManagerController")
public ResponseObject checkIsSend(String sid) {
ResponseObject ro = ResponseObject.newOkResponse();
//根据部门名称 和单位 计算出 内部校对人 和流程经理
UserContext me = UserContext.fromSessionId(sid);
String departmentId = me.getUserModel().getDepartmentId();
String allpath = SDK.getORGAPI().getDepartmentById(departmentId).getPathNameOfCache();
String[] patharr = allpath.split("/");
StringBuffer sb = new StringBuffer();
for (String str : patharr) {
sb.append("'").append(str).append("'").append(",");
}
String substring = sb.substring(0, sb.length()-1);
// 可以为boData中的字段进行赋值
Connection open = DBSql.open();
RowMap data = DBSql.getMap(open,"select DEAPRTMNUM,PROCESSMNUMBER from BO_ACT_PROCESSMANAGER where ORGDEPART in ("+substring+")");
if(null==data) {
ro.put("result","error");
}else {
ro.put("result","ok");
ro.put("DEAPRTMNUM",data.getString("DEAPRTMNUM"));
ro.put("PROCESSMNUMBER",data.getString("PROCESSMNUMBER"));
}
return ro;
}
}

View File

@ -36,8 +36,13 @@ public class UpateFileStateController {
count += DBSql.update(updataSql);
String sqlt = "UPDATE BO_EU_PAL_FILE1 SET FILESTATE = '" + state + "' WHERE FILEID = '" + plId + "'";
DBSql.update(sqlt);
PALRepositoryModel model = PALRepositoryCache.getCache().get(plId);
String taskId = createOutputReport(model, "7d3ca852-a0bd-42e6-80b1-3dcea6f55083", "admin", "", plId);
//刷新预览加载的表
String sqlr = "UPDATE BO_EU_PAL_OUTPUTREPORT SET TASKID = '" + taskId + "' WHERE PLID = '" + plId + "'";
DBSql.update(sqlr);
System.err.println("重新生成手册:" + model.getName() + "--->taskId" + taskId);
DBSql.update(
"UPDATE BO_ACT_COE_PUBLISH_N SET TASKID='" + taskId + "'WHERE PUBLISHFILEID ='" + plId + "'");

View File

@ -0,0 +1,90 @@
package com.actionsoft.apps.coe.pal.publisher.pubEvent;
import java.net.URLEncoder;
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* AES加密解密工具类
*
* @author M-Y
*/
public class AesUtil {
public static String DES = "AES"; // optional value AES/DES/DESede
public static String CIPHER_ALGORITHM = "AES"; // optional value
// AES/DES/DESede
public Key getKey(String strKey) {
try {
if (strKey == null) {
strKey = "";
}
KeyGenerator _generator = KeyGenerator.getInstance("AES");
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.setSeed(strKey.getBytes());
_generator.init(128, secureRandom);
return _generator.generateKey();
} catch (Exception e) {
throw new RuntimeException(" 初始化密钥出现异常 ");
}
}
public String encrypt(String data, String key) throws Exception {
SecureRandom sr = new SecureRandom();
Key secureKey = getKey(key);
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, secureKey, sr);
byte[] bt = cipher.doFinal(data.getBytes());
String strS = new BASE64Encoder().encode(bt);
return strS;
}
public String decrypt(String message, String key) {
try {
SecureRandom sr = new SecureRandom();
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
Key secureKey = getKey(key);
cipher.init(Cipher.DECRYPT_MODE, secureKey, sr);
byte[] res = new BASE64Decoder().decodeBuffer(message);
res = cipher.doFinal(res);
return new String(res);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String DecryptedMsg(String message, String key) throws Exception, Exception {
String Msg1 = encrypt(message, key);
System.out.println("message is :" + Msg1);
String encryptMsg1 = URLEncoder.encode(encrypt(message, key), "UTF-8");
System.out.println("encrypted message is :" + encryptMsg1);
return encryptMsg1;
}
public static void main(String[] args) throws Exception {
String data = "AUDIT##202210181611";
String key = "auditY809kUih23";
String url = "http://10.60.143.183:8088/portal/r/df?groupValue=7d3ca852-a0bd-42e6-80b1-3dcea6f55083&fileValue=d1135309-e376-4ec6-bd27-51947abe26ea&sid=null&repositoryName=output&appId=com.actionsoft.apps.coe.pal.output.pr&attachment=true&fileName=%E5%B9%BF%E5%91%8A%E5%88%9B%E6%84%8F%E7%94%9F%E6%88%90%E6%B5%81%E7%A8%8B_1.0.doc&lastModified=1666352134000";
String str1 = url.substring(0, url.indexOf("/df"));
System.out.println("str1>"+str1);
//String encryptMsg1 = AesUtil.encrypt(data, key);
//System.out.println("加密后:" + encryptMsg1);
/*message = "YPS5F%2F%2BVmdbVj0iuxrSINw%3D%3D";
System.out.println("解密后:" + AesUtil.decrypt(URLDecoder.decode(message), key));*/
}
}

View File

@ -0,0 +1,135 @@
package com.actionsoft.apps.coe.pal.publisher.pubEvent;
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.apps.coe.pal.pal.repository.upfile.model.UpfileModel;
import com.actionsoft.apps.coe.pal.pal.repository.upfile.web.UpfileWeb;
import com.actionsoft.bpms.commons.database.RowMap;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
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.UUIDGener;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONObject;
import com.awspaas.yili.publishevent.event.OutputDCFileProcessor;
import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
public class DownloadUtil {
/**
* 流程手册下载
* @param _uc
* @param taskId
* @return
*/
public LinkedHashMap<String,String> outputReportDownload(UserContext _uc, String taskId, String ruuid) {
System.out.println("usercontext>>>>>>>>>>>"+_uc.getUID());
System.out.println("sid>>>>>>>>>>>"+_uc.getSessionId());
LinkedHashMap<String,String> map = new LinkedHashMap<>();
OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
ResponseObject result = ResponseObject.newOkResponse();
if (model != null) {
try {
UtilFile file = OutputAPIManager.getInstance().getFilePath(model.getWsId(), taskId, model.getProfileId());
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("./", "");
// result.put("url",downUrl);
map.put(filename,downUrl);
}
String sql_upfile = "select * from APP_ACT_COE_PAL_UPFILE where palrepositoryid in (select ID from APP_ACT_COE_PAL_REPOSITORY where ID= '"+ruuid+"'" +
")";
List<RowMap> maps = DBSql.getMaps(sql_upfile);
UpfileWeb upfileWeb = new UpfileWeb(_uc);
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);
String downUrl= SDK.getConfAPI().getPortalUrl() + "/r/" + dcContexts.getDownloadURL().replace("./", "");
map.put(row.getString("FILENAME"),downUrl);
}
}
}else{
result = ResponseObject.newErrResponse("没有可预览文件");
}
} catch (Exception e) {
e.printStackTrace();
// return ResponseObject.newErrResponse().toString();
}
}
return map;
}
public String getzipURL(String sid,String taskId,String title){
System.out.println("taskid》》》》》》》》》》"+taskId);
System.out.println("fileName》》》》》》》》》》"+title);
String reportDownloadURL = "";
UserContext me = UserContext.fromSessionId(sid);
OutputTaskModel model = new OutputTask().getTaskReportById(taskId);
JSONObject result = new JSONObject();
if (model != null) {
//三员管理步骤横表下载重新生成手册
String taskName = model.getTaskName();
if ("步骤横表".equals(taskName)){
// 重新设置生成id与用户id
String uuid = UUIDGener.getUUID();
model.setUserId(me.getUID());
// 重新生成手册文件
OutputAPIManager.getInstance().reGennerReport(me,model,uuid);
// 重新构建手册下载URL
taskId = uuid;
}
try {
reportDownloadURL = OutputDCFileProcessor.getReportDownloadURL(model.getWsId(), taskId, model.getProfileId(), me, title+model.getTaskName());
} catch (Exception e) {
e.printStackTrace();
}
}
return reportDownloadURL;
}
}

View File

@ -0,0 +1,65 @@
package com.actionsoft.apps.coe.pal.publisher.pubEvent;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* http请求
* @Author wangcy
*/
public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
/**
* 发送post请求
* @param json
* @param URL
* @return
*/
public String sendPost(JSONObject json,String URL) {
CloseableHttpClient client = HttpClients.createDefault();
HttpPost post = new HttpPost(URL);
post.setHeader("Content-Type", "application/json");
//post.addHeader("Authorization", "Basic YWRtaW46");
String result;
try {
StringEntity s = new StringEntity(json.toString(), "utf-8");
s.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
post.setEntity(s);
// 发送请求
HttpResponse httpResponse = client.execute(post);
// 获取响应输
InputStream inStream = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(
inStream, "utf-8"));
StringBuilder strber = new StringBuilder();
String line;
while ((line = reader.readLine()) != null)
strber.append(line + "\n");
inStream.close();
result = strber.toString();
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
System.out.println("请求服务器成功,做相应处理");
} else {
System.out.println("请求服务端失败");
}
} catch (Exception e) {
logger.error("请求异常:"+e.getMessage());
throw new RuntimeException(e);
}
return result;
}
}

View File

@ -0,0 +1,123 @@
package com.actionsoft.apps.coe.pal.publisher.pubEvent;
import com.actionsoft.apps.coe.pal.log.CoEOpLogAPI;
import com.actionsoft.apps.coe.pal.pal.output.OutputAPIManager;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.server.fs.AbstFileProcessor;
import com.actionsoft.bpms.server.fs.DCContext;
import com.actionsoft.bpms.server.fs.FileProcessorListener;
import com.actionsoft.bpms.server.fs.dc.DCProfileManager;
import com.actionsoft.bpms.server.fs.dc.DCUtil;
import com.actionsoft.bpms.util.UtilFile;
import com.actionsoft.sdk.local.SDK;
import com.actionsoft.sdk.local.api.AppAPI;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class OutputDCFileProcessor extends AbstFileProcessor implements FileProcessorListener {
public OutputDCFileProcessor() {
}
public static String getReportDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
if (file.exists()) {
DCContext dcContext = null;
DCUtil.getInstance();
dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
dcContext.setFileName(taskName + ".zip");
File ff = new File(dcContext.getFilePath());
UtilFile.zipCompressExcludeName(file.getPath(), ff, "log,**/config.txt");
dcContext.setSession(_uc);
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档");
}
return dcContext.getDownloadURL();
} else {
return "";
}
}
public static String doPreviewReport(String wsId, String id, String profileId, UserContext _uc) throws Exception {
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
ResponseObject result = ResponseObject.newOkResponse();
if (file.exists()) {
File[] fileList = file.listFiles();
if (fileList.length > 0) {
File docFile = null;
File[] var8 = fileList;
int var9 = fileList.length;
for(int var10 = 0; var10 < var9; ++var10) {
File file2 = var8[var10];
if (file2.isFile() && "doc".equals(file2.getName().substring(file2.getName().lastIndexOf(".") + 1))) {
docFile = file2;
break;
}
}
if (docFile == null) {
return ResponseObject.newErrResponse("没有找到文件").toString();
}
if (SDK.getAppAPI().isActive("com.actionsoft.apps.addons.onlinedoc")) {
String sourceAppId = "com.actionsoft.apps.coe.pal.output.pr";
String filename = docFile.getName();
DCContext sourceDc = new DCContext(_uc, DCProfileManager.getDCProfile(sourceAppId, "output"), sourceAppId, wsId, id, filename);
Map<String, Object> aslpParams = new HashMap();
aslpParams.put("sid", _uc.getSessionId());
aslpParams.put("fileNameOriginal", filename);
aslpParams.put("sourceDc", sourceDc);
aslpParams.put("isShowDefaultToolbar", "false");
aslpParams.put("isEncrypt", true);
aslpParams.put("isCopy", "true");
aslpParams.put("isPrint", "false");
aslpParams.put("isDownload", "false");
AppAPI appAPI = SDK.getAppAPI();
ResponseObject responseObject = appAPI.callASLP(appAPI.getAppContext(sourceAppId), "aslp://com.actionsoft.apps.addons.onlinedoc/filePreview", aslpParams);
if (responseObject != null) {
if (responseObject.isOk()) {
String url = responseObject.get("url").toString();
result.put("url", url);
result.put("filename", filename);
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "access", "访问报告手册文档");
}
} else {
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
}
}
} else {
result = ResponseObject.newErrResponse("文档转换服务不可用,请联系管理员");
}
}
} else {
result = ResponseObject.newErrResponse("没有可预览文件");
}
return result.toString();
}
public static String getReportLogDownloadURL(String wsId, String id, String profileId, UserContext _uc, String taskName) throws Exception {
UtilFile file = OutputAPIManager.getInstance().getFilePath(wsId, id, profileId);
if (file.exists()) {
DCContext dcContext = null;
DCUtil.getInstance();
dcContext = DCUtil.createTempFileContext("com.actionsoft.apps.coe.pal.output.pr", "output", id, "zip");
dcContext.setFileName("log.zip");
File ff = new File(dcContext.getFilePath());
UtilFile.zipCompress(file.getPath(), ff, "log");
dcContext.setSession(_uc);
if (SDK.getAppAPI().getPropertyBooleanValue("com.actionsoft.apps.coe.pal", "IS_RECORD_OP_LOG", false)) {
CoEOpLogAPI.auditOkOp(_uc, "PAL应用中心", "download", "下载报告手册文档日志");
}
return dcContext.getDownloadURL();
} else {
return "";
}
}
}

View File

@ -0,0 +1,51 @@
package com.actionsoft.apps.coe.pal.publisher.pubEvent;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.nio.charset.Charset;
/**
* @PackageName: com.awspaas.user.apps.yili.integration.util
* @ClassName: UtilUrl
* @author: yujh
* @date: 2022/5/18 21:41
*/
public class UtilUrl {
//使用SOAP1.1发送消息
public static String doPostSoap(String postUrl, String soapXml, String soapAction) {
String retStr = "";
// 创建HttpClientBuilder
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// HttpClient
CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
HttpPost httpPost = new HttpPost(postUrl);
// 设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(600000)
.setConnectTimeout(600000).build();
httpPost.setConfig(requestConfig);
try {
httpPost.setHeader("Content-Type", "text/xml;charset=UTF-8");
httpPost.setHeader("SOAPAction", soapAction);
StringEntity data = new StringEntity(soapXml, Charset.forName("UTF-8"));
httpPost.setEntity(data);
CloseableHttpResponse response = closeableHttpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
if (httpEntity != null) {
// 打印响应内容
retStr = EntityUtils.toString(httpEntity, "UTF-8");
}
// 释放资源
closeableHttpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
return retStr;
}
}