推送EHSQ文件定时任务
This commit is contained in:
parent
28849309cb
commit
44fe4e5146
@ -0,0 +1,89 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.Key;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* 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));*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.actionsoft.apps.coe.pal.datamigration;
|
||||
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,6 @@ 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.publisher.pubEvent.AesUtil;
|
||||
import com.actionsoft.apps.coe.pal.publisher.pubEvent.DownloadUtil;
|
||||
import com.actionsoft.apps.coe.pal.publisher.pubEvent.HttpUtil;
|
||||
import com.actionsoft.bpms.bo.engine.BO;
|
||||
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
|
||||
import com.actionsoft.bpms.bpmn.engine.model.run.delegate.ProcessInstance;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user