pioneer
2 years ago
commit
18b215fff6
28 changed files with 3044 additions and 0 deletions
@ -0,0 +1,6 @@
|
||||
# open-JSD-10009 |
||||
|
||||
JSD-10009 单点登录和文档预览接口集成到帆软的按钮事件,实现对文档进行带水印的预览\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
@ -0,0 +1,6 @@
|
||||
EDOURL=http://xxxxxx |
||||
EDOKEY=xxxxx |
||||
DEFAULT_NAME=xxx |
||||
TOKEN_IP=xxxxx |
||||
BATCH_URL=http://xxxxx |
||||
SEARCH_URL=http://xxxxx |
@ -0,0 +1,108 @@
|
||||
"use strict"; |
||||
|
||||
var initHyJs = function initHyJs() { |
||||
var util = { |
||||
postJSON: function postJSON(url, data, callback, _error) { |
||||
url = FR.servletURL + url; |
||||
FR.ajax({ |
||||
type: "POST", |
||||
url: url, |
||||
contentType: "application/json; charset=utf-8", |
||||
data: JSON.stringify(data), |
||||
success: function success(resp) { |
||||
callback != undefined && callback(JSON.parse(resp)); |
||||
}, |
||||
error: function error(err) { |
||||
_error != undefined && _error(err); |
||||
} |
||||
}); |
||||
}, |
||||
get: function get(url, data, callback, _error2) { |
||||
url = FR.servletURL + url; |
||||
FR.ajax({ |
||||
type: "GET", |
||||
url: url, |
||||
data: data, |
||||
success: function success(resp) { |
||||
callback != undefined && callback(JSON.parse(resp)); |
||||
}, |
||||
error: function error(err) { |
||||
_error2 != undefined && _error2(err); |
||||
} |
||||
}); |
||||
} |
||||
}; |
||||
window["EDO"] = { |
||||
"downloadFile": function downloadFile(fileId, verId, userName) { |
||||
//下载
|
||||
var url = "/edo/download?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
console.log("下载返回结果:" + JSON.stringify(res)); |
||||
|
||||
if (!res.errorCode) { |
||||
window.open(res.data); |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
}, |
||||
"priviewFile": function priviewFile(fileId, userName) { |
||||
//预览
|
||||
var url = "/edo/priview?fileId=" + fileId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
console.log("预览返回结果:" + JSON.stringify(res)); |
||||
|
||||
if (!res.errorCode) { |
||||
window.open(res.data); |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
}, |
||||
"deleteFiles": function deleteFiles(fileIds, callback, userName) { |
||||
//删除
|
||||
var url = "/edo/remove" + "?edocName=" + userName; |
||||
util.postJSON(url, fileIds, function () { |
||||
callback && callback(); |
||||
}); |
||||
}, |
||||
"batchDownload": function batchDownload(fileIds, folders, userName) { |
||||
//批量下载
|
||||
var url = "/edo/batch/download" + "?edocName=" + userName; |
||||
util.postJSON(url, { |
||||
fileIds: fileIds, |
||||
folders: folders |
||||
}, function (res) { |
||||
console.log("批量下载返回结果:" + JSON.stringify(res)); |
||||
|
||||
if (!res.errorCode) { |
||||
window.open(res.data); |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
}, |
||||
"fileManager": function fileManager(folderId, userName, callback) { |
||||
var url = "/edo/file/manager?" + "folderId=" + folderId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
if (!res.errorCode) { |
||||
if ($.isFunction(callback)) { |
||||
callback(res); |
||||
} else { |
||||
window.open(res.data); |
||||
} |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
} |
||||
};
|
||||
|
||||
console.log("FR.EDO init complted"); |
||||
}; |
||||
|
||||
initHyJs(); |
||||
|
||||
var test = function test() { |
||||
alert("aaaaa"); |
||||
}; |
@ -0,0 +1,178 @@
|
||||
|
||||
var initHyJs = function () { |
||||
var util = { |
||||
isMobile: function () { |
||||
try { |
||||
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
}, |
||||
isAndroidMobile: function () { |
||||
try { |
||||
if (/Android/i.test(navigator.userAgent)) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
}, |
||||
postJSON: function (url, data, callback, error) { |
||||
url = FR.servletURL + url; |
||||
FR.ajax({ |
||||
type: "POST", |
||||
url: url, |
||||
contentType: "application/json; charset=utf-8", |
||||
data: JSON.stringify(data), |
||||
success: function (resp) { |
||||
callback != undefined && callback(JSON.parse(resp)); |
||||
}, |
||||
error: function (err) { |
||||
error != undefined && error(err); |
||||
} |
||||
}) |
||||
}, |
||||
get: function (url, data, callback, error) { |
||||
url = FR.servletURL + url; |
||||
FR.ajax({ |
||||
type: "GET", |
||||
url: url, |
||||
data: data, |
||||
success: function (resp) { |
||||
callback != undefined && callback(JSON.parse(resp)); |
||||
}, |
||||
error: function (err) { |
||||
error != undefined && error(err); |
||||
} |
||||
}) |
||||
} |
||||
}; |
||||
|
||||
window["EDO"] = { |
||||
"downloadFile":function (fileId, verId, userName) {//下载
|
||||
if (util.isAndroidMobile()) { |
||||
console.log("android platform") |
||||
var url = "/edo/getDownloadUrlFr?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
console.log("下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
||||
// alert("下载地址为:"+newUrl)
|
||||
window.open(newUrl) |
||||
// window.location.href = newUrl;
|
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
} |
||||
else { |
||||
console.log("not android platform") |
||||
var url = "/edo/download?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
// FR.Msg.toast(res.data)
|
||||
console.log("下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
//window.open(res.data)
|
||||
window.location.href = res.data; |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
} |
||||
}, |
||||
"priviewFile": function (fileId, userName) { //预览
|
||||
var url = "/edo/priview?fileId=" + fileId + "&edocName=" + userName; |
||||
|
||||
util.get(url, {}, function (res) { |
||||
|
||||
if (!res.errorCode) { |
||||
|
||||
window.location=res.data; |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
},function(err){ |
||||
|
||||
FR.Msg.toast("err:"+err); |
||||
}); |
||||
}, |
||||
"deleteFiles":function (fileIds, callback, userName) { //删除
|
||||
var url = "/edo/remove" + "?edocName=" + userName; |
||||
|
||||
util.postJSON(url, fileIds, function () { |
||||
callback && callback(); |
||||
}) |
||||
|
||||
}, |
||||
"batchDownload": function (fileIds, folders, userName) { //批量下载
|
||||
if (util.isAndroidMobile()) { |
||||
console.log("android platform") |
||||
var url = "/edo/batch/downloadFr" + "?edocName=" + userName; |
||||
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
||||
console.log("批量下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
||||
console.log("下载地址为:"+newUrl) |
||||
// window.open(newUrl)
|
||||
window.location=newUrl; |
||||
// window.open(res.data)
|
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}) |
||||
} |
||||
else{ |
||||
console.log("not android platform") |
||||
var url = "/edo/batch/download" + "?edocName=" + userName; |
||||
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
||||
console.log("批量下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
//window.open(res.data)
|
||||
window.location=res.data; |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
}, |
||||
|
||||
"fileManager":function (folderId, userName, callback) { |
||||
var url = "/edo/file/manager?" + "folderId=" + folderId + "&edocName=" + userName; |
||||
|
||||
util.get(url, {}, function (res) { |
||||
if (!res.errorCode) { |
||||
if ($.isFunction(callback)) { |
||||
callback(res); |
||||
} else { |
||||
window.open(res.data) |
||||
} |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
|
||||
}); |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("FR.EDO init complted") |
||||
|
||||
} |
||||
|
||||
initHyJs(); |
||||
|
||||
var test = function () { |
||||
alert("aaaaa") |
||||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.edo.file.manager</id> |
||||
<name><![CDATA[鸿翼文件管理]]></name> |
||||
<active>yes</active> |
||||
<version>1.3</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[文件管理]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2021-08-18 v1.0]第一个版本<br/> |
||||
[2021-08-18 v1.1]更新了提交的更新字段br/> |
||||
[2021-08-24 v1.2]修改了前端的js调用方式,支持传入用户和自定义默认用户,增加批量下载接口br/> |
||||
[2021-09-22 v1.3]增加了文件管理打开的直接单点接口br/> |
||||
]]></change-notes> |
||||
<extra-core> |
||||
<JavaScriptFileHandler class="com.fr.plugin.edo.web.EDOJavaScriptFileHandler"/> |
||||
</extra-core> |
||||
<extra-report> |
||||
</extra-report> |
||||
<extra-decision> |
||||
<ControllerRegisterProvider class="com.fr.plugin.edo.controller.EdoControllerProvider"/> |
||||
</extra-decision> |
||||
|
||||
<extra-designer> |
||||
<TableDataDefineProvider class="com.fr.plugin.edo.tabDataSource.HyTableDataDefineProvider"/> |
||||
</extra-designer> |
||||
|
||||
<function-recorder class="com.fr.plugin.edo.HyEdoPluginLifecycleMonitor"/> |
||||
<lifecycle-monitor class="com.fr.plugin.edo.HyEdoPluginLifecycleMonitor"/> |
||||
</plugin> |
@ -0,0 +1,174 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import EDoc2.IAppService.IDocAppService; |
||||
import EDoc2.IAppService.IOrgAppService; |
||||
import EDoc2.IAppService.Model.FileListAndFolderListDto; |
||||
import EDoc2.IAppService.Model.ReturnValueResult; |
||||
import EDoc2.IAppService.Model.UserLoginIntegrationByUserLoginNameDto; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.edoc2.model.ResultBean; |
||||
import com.edoc2.model.upload.UploadFileInfo; |
||||
import com.edoc2.model.upload.UploadFileResult; |
||||
import com.edoc2.model.upload.uploadenum.CalcMD5; |
||||
import com.edoc2.model.upload.uploadenum.UpgradeStrategy; |
||||
import com.edoc2.proxy.FacadeProxy; |
||||
import com.edoc2.sdkconfig.SdkBaseInfo; |
||||
import com.edoc2.utils.FileUtils; |
||||
import com.edoc2.utils.HttpUtils; |
||||
import com.edoc2.utils.UploaderUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author xx |
||||
* @version 10.0 |
||||
* @date 2021/6/28 |
||||
*/ |
||||
public class EDOTest { |
||||
private static int DEMO_FOLDER_ID = 35679; |
||||
private static String DEMO_USERNAME = "xx"; |
||||
private static String DEMO_KEY = "xxx"; |
||||
|
||||
public static void main(String[] args) { |
||||
SdkBaseInfo.baseUrl = "http://xxx:33333"; |
||||
IOrgAppService iOrgAppService = FacadeProxy.newProxyInstance(IOrgAppService.class); |
||||
UserLoginIntegrationByUserLoginNameDto params = new UserLoginIntegrationByUserLoginNameDto(); |
||||
params.setLoginName(DEMO_USERNAME); |
||||
params.setIntegrationKey(DEMO_KEY); |
||||
params.setIPAddress("192.168.2.23"); |
||||
ReturnValueResult<String> result = iOrgAppService.UserLoginIntegrationByUserLoginName(params); |
||||
String token = result.getData(); |
||||
System.out.println("token:" + token); |
||||
// ResultBean resultBean = uploadFile(token, "D:\\test.xlsx");
|
||||
// System.out.println(resultBean);
|
||||
// fileDownload(380050 ,390380 , token);
|
||||
// ReturnValueResult returnValueResult = removeFile(token, 379642);
|
||||
//System.out.println(returnValueResult);
|
||||
String[] fileIds = {"380050", "380066"}; |
||||
String[] folderIds = {}; |
||||
createBatchDownloadUrl(fileIds, folderIds, token); |
||||
} |
||||
|
||||
public static ResultBean uploadFile(String token, String filePath) { |
||||
File file = null; |
||||
FileInputStream fileInputStream = null; |
||||
try { |
||||
file = new File(filePath); |
||||
fileInputStream = new FileInputStream(file); |
||||
} catch (FileNotFoundException e) { |
||||
e.printStackTrace(); |
||||
return new ResultBean(); |
||||
} |
||||
//文件类型
|
||||
String mimeType = null; |
||||
try { |
||||
mimeType = FileUtils.getMimeType(file.getPath()); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
return new ResultBean(); |
||||
} |
||||
UploadFileInfo uploadFileInfo = new UploadFileInfo(); |
||||
uploadFileInfo.setName(file.getName()); |
||||
uploadFileInfo.setType(mimeType); |
||||
// 获取文件最后一次更新时间
|
||||
Date lastModifiedDate = FileUtils.getFileLastModifiedDate(file); |
||||
uploadFileInfo.setLastModifiedDate(lastModifiedDate); |
||||
//uploadFileInfo.setFileId(44);// 更新的时候需要传文件id ,策略需要设置 MajorUpgrade OverlayLatestVersion
|
||||
/* UploadFileResult uploadFileResult = UploaderUtils.uploadFileByInputStraemAsync(token, DEMO_FOLDER_ID, UpgradeStrategy.MinorUpgrade, |
||||
CalcMD5.Before.getValue(), "test.xlsx", fileInputStream, uploadFileInfo);*/ |
||||
ResultBean resultBean = null; |
||||
try { |
||||
resultBean = UploaderUtils.uploadFileByStream(token, DEMO_FOLDER_ID, UpgradeStrategy.MinorUpgrade, |
||||
CalcMD5.Before.getValue(), "", fileInputStream, uploadFileInfo); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
return new ResultBean(); |
||||
} |
||||
return resultBean; |
||||
} |
||||
|
||||
public static String createBatchDownloadUrl(String[] fileList, String[] folderList, String token) { |
||||
StringBuilder stringBuilder = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
stringBuilder.append("/DownLoad/DownLoadCheck?fileIds=").append(StringUtils.join(",", fileList)); |
||||
stringBuilder.append("&folderIds=").append(StringUtils.join(",", folderList)); |
||||
stringBuilder.append("&token="); |
||||
stringBuilder.append(token); |
||||
//1.2请求
|
||||
String result = null; |
||||
try { |
||||
result = HttpUtils.doGet(stringBuilder.toString(), null, null); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//1.3获取region hash
|
||||
JSONObject json = JSONObject.parseObject(result); |
||||
String regionHash = (String) json.get("RegionHash"); |
||||
System.out.println(json); |
||||
|
||||
//2.拼装下载URL
|
||||
StringBuilder url = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
url.append("/downLoad/index?regionHash="); |
||||
url.append(regionHash); |
||||
url.append("&async=true"); |
||||
url.append("&token="); |
||||
url.append(token); |
||||
|
||||
System.out.println(url); |
||||
return url.toString(); |
||||
} |
||||
|
||||
public static void fileDownload(int fileId, int verId, String token) { |
||||
//1.1组装下载请求URL
|
||||
StringBuilder stringBuilder = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
stringBuilder.append("/DownLoad/DownLoadCheck?fileIds="); |
||||
stringBuilder.append(fileId); |
||||
stringBuilder.append("&ver_id="); |
||||
stringBuilder.append(verId); |
||||
stringBuilder.append("&token="); |
||||
stringBuilder.append(token); |
||||
//1.2请求
|
||||
String result = null; |
||||
try { |
||||
result = HttpUtils.doGet(stringBuilder.toString(), null, null); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
//1.3获取region hash
|
||||
JSONObject json = JSONObject.parseObject(result); |
||||
String regionHash = (String) json.get("RegionHash"); |
||||
System.out.println(json); |
||||
|
||||
//2.拼装下载URL
|
||||
StringBuilder url = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
url.append("/downLoad/index?regionHash="); |
||||
url.append(regionHash); |
||||
url.append("&async=true"); |
||||
url.append("&token="); |
||||
url.append(token); |
||||
|
||||
System.out.println(url); |
||||
|
||||
} |
||||
|
||||
public static ReturnValueResult removeFile(String token, int fileId) { |
||||
IDocAppService service = FacadeProxy.newProxyInstance(IDocAppService.class); |
||||
FileListAndFolderListDto fileListAndFolderListDto = new FileListAndFolderListDto(); |
||||
ArrayList<Integer> fileList = new ArrayList<Integer>(); |
||||
fileList.add(fileId); |
||||
fileListAndFolderListDto.setFileIdList(fileList); |
||||
fileListAndFolderListDto.setFilePathList(new ArrayList<String>()); |
||||
fileListAndFolderListDto.setFolderIdList(new ArrayList<Integer>()); |
||||
fileListAndFolderListDto.setFolderPathList(new ArrayList<String>()); |
||||
fileListAndFolderListDto.setToken(token); |
||||
return service.RemoveFolderListAndFileList(fileListAndFolderListDto); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.edoc2.sdkconfig.SdkBaseInfo; |
||||
import com.fr.io.utils.ResourceIOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* @author xxx |
||||
* @version 10.0 |
||||
* @date 2021/8/24 |
||||
*/ |
||||
public class PluginContants { |
||||
private static Properties pro = new Properties(); |
||||
|
||||
static { |
||||
InputStream inputStream = ResourceIOUtils.read("/resources/edoConfig.properties"); |
||||
pro = new Properties(); |
||||
try { |
||||
pro.load(inputStream); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@
|
||||
package com.fr.plugin.edo; |
||||
|
||||
import com.fr.plugin.edo.controller.EdoController; |
||||
import com.fr.plugin.edo.tabDataSource.model.SearchResult; |
||||
import com.fr.plugin.edo.util.HttpUtil; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.edo.submit.EDOFileUtils; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.alibaba.druid.support.json.JSONUtils; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
import java.io.File; |
||||
import java.util.*; |
||||
|
||||
@EnableMetrics |
||||
@FunctionRecorder |
||||
public class HyEdoPluginLifecycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
@Override |
||||
@Focus(id = "com.fr.plugin.edo.file.manager", text = "filemanager", source = Original.PLUGIN) |
||||
public void afterRun(PluginContext pluginContext) { |
||||
FineLoggerFactory.getLogger().info("插件启动:"); |
||||
String envPath = WorkContext.getCurrent().getPath(); |
||||
FineLoggerFactory.getLogger().info("envPath:"+envPath); |
||||
String webReport = (new File(envPath)).getParent(); |
||||
File downfiles = new File(webReport+File.separator+"downfiles"); |
||||
if(!downfiles.exists()){ |
||||
downfiles.mkdir(); |
||||
} |
||||
EdoController.downFileDir = downfiles; |
||||
FineLoggerFactory.getLogger().info("downfiles:"+downfiles.getPath()); |
||||
FineLoggerFactory.getLogger().info("hongyi start..............."); |
||||
|
||||
Calendar startDate = Calendar.getInstance(); |
||||
//定时每天23点半执行一次
|
||||
startDate.set(startDate.get(Calendar.YEAR), startDate.get(Calendar.MONTH), startDate.get(Calendar.DATE), 23, 30, 0); |
||||
// 1小时的毫秒设定
|
||||
long timeInterval = 24* 60 * 60 * 1000; |
||||
Timer t = new Timer(); |
||||
t.schedule(new TimerTask() { |
||||
public void run() { |
||||
// 定时器主要执行的代码块
|
||||
FineLoggerFactory.getLogger().info("定时器主要执行的代码! 删除下载文件"); |
||||
try { |
||||
File files[] = downfiles.listFiles(); |
||||
for (File file : files) { |
||||
FineLoggerFactory.getLogger().info(" 删除下载文件:"+file.getAbsolutePath()); |
||||
file.delete(); |
||||
} |
||||
FineLoggerFactory.getLogger().info(" 删除下载文件成功"); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
FineLoggerFactory.getLogger().error(e.toString()); |
||||
} |
||||
} |
||||
// 设定的定时器在23:30分开始执行,每隔 24小时执行一次.
|
||||
}, startDate.getTime(), timeInterval ); //timeInterval 是一天的毫秒数,也是执行间隔
|
||||
|
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
FineLoggerFactory.getLogger().info("插件停止"); |
||||
} |
||||
} |
@ -0,0 +1,490 @@
|
||||
package com.fr.plugin.edo.controller; |
||||
import EDoc2.IAppService.Model.ReturnValueResult; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.edoc2.sdkconfig.SdkBaseInfo; |
||||
import com.edoc2.utils.HttpUtils; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.webservice.Response; |
||||
import com.fr.decision.webservice.annotation.LoginStatusChecker; |
||||
import com.fr.decision.webservice.utils.DecisionStatusService; |
||||
import com.fr.decision.webservice.v10.login.LoginService; |
||||
import com.fr.decision.webservice.v10.user.UserService; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.edo.controller.params.BatchDownParam; |
||||
import com.fr.plugin.edo.controller.params.DownLoadParam; |
||||
import com.fr.plugin.edo.submit.EDOFileUtils; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.store.StateHubManager; |
||||
import com.fr.third.springframework.stereotype.Controller; |
||||
import com.fr.third.springframework.web.bind.annotation.*; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.*; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.MalformedURLException; |
||||
import java.net.URL; |
||||
import java.net.URLDecoder; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @author xx |
||||
* @version 10.0 |
||||
* @date 2021/6/29 |
||||
*/ |
||||
@EnableMetrics |
||||
@Controller |
||||
@LoginStatusChecker( |
||||
required = false |
||||
) |
||||
@RequestMapping("edo") |
||||
public class EdoController { |
||||
|
||||
|
||||
public static File downFileDir; |
||||
|
||||
private String getCurrentUserName(HttpServletRequest req) { |
||||
String edocName = WebUtils.getHTTPRequestParameter(req, "edocName"); |
||||
return StringUtils.isBlank(edocName) ? EDOFileUtils.DEFAULT_NAME : edocName; |
||||
} |
||||
|
||||
|
||||
public String getCurrentLoginUser(HttpServletRequest req) { |
||||
//HomePageResource
|
||||
return LoginService.getInstance().getCurrentUserNameFromRequestCookie(req); |
||||
|
||||
} |
||||
|
||||
@RequestMapping( |
||||
value = {"/token"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public Response createToken(HttpServletRequest req, HttpServletResponse res) { |
||||
String userName = getCurrentUserName(req); |
||||
return Response.ok(EDOFileUtils.createToken(userName, req)); |
||||
} |
||||
|
||||
//三个参数:fileId,verId,edocName
|
||||
@RequestMapping( |
||||
value = {"/download"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public Response getDownLoadURL(HttpServletRequest req, HttpServletResponse res) throws IOException { |
||||
FineLoggerFactory.getLogger().debug("getDownLoadURL.................."); |
||||
int fileId = WebUtils.getHTTPRequestIntParameter(req, "fileId"); |
||||
int verId = WebUtils.getHTTPRequestIntParameter(req, "verId"); |
||||
String userName = EDOFileUtils.createToken(getCurrentUserName(req), req); |
||||
FineLoggerFactory.getLogger().debug("获取下载参数:fileId"+fileId+",verId:"+verId+",userName:"+userName); |
||||
String url = EDOFileUtils.createDownFileURL(fileId, verId, userName); |
||||
FineLoggerFactory.getLogger().debug("获取下载url:"+url); |
||||
// downFile(url);
|
||||
return Response.ok(url); |
||||
} |
||||
|
||||
|
||||
@RequestMapping( |
||||
value = {"/getDownloadUrlFr"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public Response getDownLoadURLFr(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
FineLoggerFactory.getLogger().debug("android getDownloadUrlFr .................."); |
||||
int fileId = WebUtils.getHTTPRequestIntParameter(req, "fileId"); |
||||
int verId = WebUtils.getHTTPRequestIntParameter(req, "verId"); |
||||
String userName = EDOFileUtils.createToken(getCurrentUserName(req), req); |
||||
FineLoggerFactory.getLogger().debug("获取下载参数:fileId"+fileId+",verId:"+verId+",userName:"+userName); |
||||
String url = EDOFileUtils.createDownFileURL(fileId, verId, userName); |
||||
FineLoggerFactory.getLogger().debug("获取下载url:"+url); |
||||
String newUrl = downFile(url); |
||||
FineLoggerFactory.getLogger().debug("获取fr下载url:"+newUrl); |
||||
return Response.ok(newUrl); |
||||
} |
||||
|
||||
@RequestMapping( |
||||
value = {"/downloadFileFr"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public void downloadFileFr(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
String downFileName = WebUtils.getHTTPRequestParameter(req,"downFileName"); |
||||
FineLoggerFactory.getLogger().debug("android downloadFileFr fileName:"+downFileName); |
||||
String downFilePath = downFileDir.getPath()+File.separator+downFileName; |
||||
FineLoggerFactory.getLogger().debug("downloadFileFr filePath:"+downFilePath); |
||||
File file = new File(downFilePath); |
||||
FineLoggerFactory.getLogger().debug("downloadFileFr file.exists():"+file.exists()); |
||||
if(file.exists()){ |
||||
String showName = DecisionStatusService.loginStatusService().get(downFileName); |
||||
// DecisionStatusService.loginStatusService().delete(downFileName);
|
||||
FineLoggerFactory.getLogger().debug("showName:"+showName); |
||||
res.reset(); // 响应重置
|
||||
res.setHeader("Content-Disposition", "attachment;filename=\""+ showName + "\""); |
||||
res.addHeader("Content-Length", ""+file.length()); |
||||
res.setContentType("application/octet-stream;charset=UTF-8"); |
||||
OutputStream out = res.getOutputStream(); |
||||
FileInputStream input = new FileInputStream(file); |
||||
int len = 0; |
||||
byte[] buffer = new byte[1024*8]; |
||||
while ((len = input.read(buffer)) != -1) { |
||||
out.write(buffer,0,len); |
||||
} |
||||
input.close(); |
||||
res.flushBuffer(); |
||||
} |
||||
} |
||||
|
||||
private String downFile(String urlPath) throws Exception { |
||||
URL url = new URL(urlPath); |
||||
HttpURLConnection http = (HttpURLConnection)url.openConnection(); |
||||
http.setConnectTimeout(3000); |
||||
// 设置 User-Agent 避免被拦截
|
||||
http.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"); |
||||
String contentType = http.getContentType(); |
||||
|
||||
String fieldValue = http.getHeaderField("Content-Disposition"); |
||||
FineLoggerFactory.getLogger().debug("获取fr下载fieldValue:"+fieldValue); |
||||
String filename = fieldValue.substring(fieldValue.indexOf("filename=\"") + 10, fieldValue.length() - 2); |
||||
//filename = URLDecoder.decode(filename,"utf-8");
|
||||
int indexPos = filename.indexOf("."); |
||||
String extension = filename.substring(indexPos,filename.length()); |
||||
String fileNameUuid = UUID.randomUUID().toString(); |
||||
fileNameUuid = fileNameUuid.replaceAll("-",""); |
||||
String oldFileName = filename; |
||||
filename = fileNameUuid+extension; |
||||
DecisionStatusService.loginStatusService().put(filename,oldFileName); |
||||
FineLoggerFactory.getLogger().debug("获取fr下载filename:"+filename); |
||||
|
||||
InputStream inputStream = http.getInputStream(); |
||||
byte[] buff = new byte[1024*10]; |
||||
File file = new File(downFileDir, filename); |
||||
FineLoggerFactory.getLogger().debug("file path:"+file.getAbsolutePath()); |
||||
if(file.exists()){ |
||||
FineLoggerFactory.getLogger().debug("file.delete.................."); |
||||
file.delete(); |
||||
} |
||||
FineLoggerFactory.getLogger().debug("file.exists():"+file.exists()); |
||||
if(!file.exists()){ |
||||
OutputStream out = new FileOutputStream(file); |
||||
int len ; |
||||
while((len = inputStream.read(buff)) != -1) { |
||||
out.write(buff, 0, len); |
||||
out.flush(); |
||||
} |
||||
// 关闭资源
|
||||
out.close(); |
||||
inputStream.close(); |
||||
FineLoggerFactory.getLogger().debug("文件写入完成"); |
||||
} |
||||
http.disconnect(); |
||||
// String newUrl = "webroot"+File.separator+"decision"+File.separator+"downfiles"+File.separator+filename;
|
||||
String newUrl = filename ; |
||||
FineLoggerFactory.getLogger().debug("newUrl:"+newUrl); |
||||
FineLoggerFactory.getLogger().debug("file.exists():"+file.exists()); |
||||
return newUrl; |
||||
} |
||||
|
||||
|
||||
private String downFile1(String urlPath) throws Exception { |
||||
URL url = new URL(urlPath); |
||||
HttpURLConnection http = (HttpURLConnection)url.openConnection(); |
||||
http.setConnectTimeout(3000); |
||||
// 设置 User-Agent 避免被拦截
|
||||
http.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"); |
||||
String contentType = http.getContentType(); |
||||
|
||||
String fieldValue = http.getHeaderField("Content-Disposition"); |
||||
FineLoggerFactory.getLogger().debug("获取fr下载fieldValue:"+fieldValue); |
||||
String filename = fieldValue.substring(fieldValue.indexOf("filename=\"") + 10, fieldValue.length()); |
||||
//filename = URLDecoder.decode(filename,"utf-8");
|
||||
int indexPos = filename.indexOf("."); |
||||
String extension = filename.substring(indexPos,filename.length()); |
||||
String fileNameUuid = UUID.randomUUID().toString(); |
||||
fileNameUuid = fileNameUuid.replaceAll("-",""); |
||||
String oldFileName = filename; |
||||
filename = fileNameUuid+extension; |
||||
DecisionStatusService.loginStatusService().put(filename,oldFileName); |
||||
FineLoggerFactory.getLogger().debug("获取fr下载filename:"+filename); |
||||
|
||||
InputStream inputStream = http.getInputStream(); |
||||
byte[] buff = new byte[1024*10]; |
||||
File file = new File(downFileDir, filename); |
||||
FineLoggerFactory.getLogger().debug("file path:"+file.getAbsolutePath()); |
||||
if(file.exists()){ |
||||
FineLoggerFactory.getLogger().debug("file.delete.................."); |
||||
file.delete(); |
||||
} |
||||
FineLoggerFactory.getLogger().debug("file.exists():"+file.exists()); |
||||
if(!file.exists()){ |
||||
OutputStream out = new FileOutputStream(file); |
||||
int len ; |
||||
while((len = inputStream.read(buff)) != -1) { |
||||
out.write(buff, 0, len); |
||||
out.flush(); |
||||
} |
||||
// 关闭资源
|
||||
out.close(); |
||||
inputStream.close(); |
||||
FineLoggerFactory.getLogger().debug("文件写入完成"); |
||||
} |
||||
http.disconnect(); |
||||
// String newUrl = "webroot"+File.separator+"decision"+File.separator+"downfiles"+File.separator+filename;
|
||||
String newUrl = filename ; |
||||
FineLoggerFactory.getLogger().debug("newUrl:"+newUrl); |
||||
FineLoggerFactory.getLogger().debug("file.exists():"+file.exists()); |
||||
return newUrl; |
||||
} |
||||
|
||||
|
||||
//两个参数edocName,fileIds 多个文件id
|
||||
@RequestMapping( |
||||
value = {"/batch/download"}, |
||||
method = {RequestMethod.POST} |
||||
) |
||||
@ResponseBody |
||||
public Response getBatchDownloadURL(HttpServletRequest req, HttpServletResponse res, @RequestBody BatchDownParam param) { |
||||
String token = EDOFileUtils.createToken(getCurrentUserName(req), req); |
||||
String result = ""; |
||||
try { |
||||
String url = EDOFileUtils.batchDownload(param.getFileIds(),param.getFolders(), token); |
||||
FineLoggerFactory.getLogger().info("获取批量下载url:"+url); |
||||
result = HttpUtils.doGet(url, null, null); |
||||
FineLoggerFactory.getLogger().info("获取批量下载url结果:"+result); |
||||
|
||||
JSONObject json = JSONObject.parseObject(result); |
||||
String regionHash = (String) json.get("RegionHash"); |
||||
// System.out.println(json);
|
||||
|
||||
//2.拼装下载URL
|
||||
StringBuilder downUrl = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
downUrl.append("/downLoad/index?regionHash="); |
||||
downUrl.append(regionHash); |
||||
// downUrl.append("&async=true");
|
||||
// downUrl.append("&token=");
|
||||
// downUrl.append(token);
|
||||
|
||||
JSONObject jsonParam = new JSONObject(); |
||||
jsonParam.put("async",true); |
||||
jsonParam.put("token",token); |
||||
String fileString = org.apache.commons.lang.StringUtils.join(param.getFileIds().toArray(), ','); |
||||
jsonParam.put("fileIds",fileString.split(",")); |
||||
|
||||
// downUrl.append("&filesId="+fileString);
|
||||
fileString = org.apache.commons.lang.StringUtils.join(param.getFolders().toArray(), ','); |
||||
jsonParam.put("folderIds",fileString.split(",")); |
||||
// downUrl.append("&folderIds="+fileString);
|
||||
|
||||
FineLoggerFactory.getLogger().info("第2步 获取批量下载url:"+downUrl.toString()); |
||||
|
||||
result = HttpUtils.doPostObjectParam(downUrl.toString(),jsonParam,null); |
||||
FineLoggerFactory.getLogger().info("第2步 获取批量下载url结果:"+result); |
||||
json = JSONObject.parseObject(result); |
||||
String pTaskId = (String) json.get("pTaskId"); |
||||
String zipUrl = SdkBaseInfo.baseUrl+"/WebCore"; |
||||
System.out.println("第3步 压缩url:"+zipUrl); |
||||
jsonParam = new JSONObject(); |
||||
jsonParam.put("module","WebClient"); |
||||
jsonParam.put("fun","GetZipProgress"); |
||||
jsonParam.put("pTaskId",pTaskId); |
||||
jsonParam.put("token",token); |
||||
jsonParam.put("r",Math.random()*1000); |
||||
|
||||
String status = "Ziping"; |
||||
String zipName = ""; |
||||
while(status.equals("Complete") == false){ |
||||
result = HttpUtils.doPostObjectParam(zipUrl.toString(),jsonParam,null); |
||||
FineLoggerFactory.getLogger().info("第3步 压缩结果:"+result); |
||||
json = JSONObject.parseObject(result); |
||||
status = (String) json.get("status"); |
||||
zipName = (String) json.get("zipName"); |
||||
String errorMsg = (String) json.get("errorMsg"); |
||||
if(StringUtils.isNotEmpty(errorMsg)){ |
||||
return Response.error("10000","压缩失败:"+errorMsg); |
||||
} |
||||
} |
||||
|
||||
String lastdownUrl = SdkBaseInfo.baseUrl+"/downLoad/GetFile?fileName="+zipName; |
||||
FineLoggerFactory.getLogger().info("最后的下载url:"+lastdownUrl); |
||||
|
||||
|
||||
return Response.ok(lastdownUrl); |
||||
} catch (Exception e) { |
||||
return Response.error("404", e.getMessage()); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
@RequestMapping( |
||||
value = {"/batch/downloadFr"}, |
||||
method = {RequestMethod.POST} |
||||
) |
||||
@ResponseBody |
||||
public Response getBatchDownloadFrURL(HttpServletRequest req, HttpServletResponse res, @RequestBody BatchDownParam param) { |
||||
String token = EDOFileUtils.createToken(getCurrentUserName(req), req); |
||||
String result = ""; |
||||
try { |
||||
String url = EDOFileUtils.batchDownload(param.getFileIds(),param.getFolders(), token); |
||||
FineLoggerFactory.getLogger().info("android 获取批量下载url:"+url); |
||||
result = HttpUtils.doGet(url, null, null); |
||||
FineLoggerFactory.getLogger().info("android 获取批量下载url结果:"+result); |
||||
|
||||
JSONObject json = JSONObject.parseObject(result); |
||||
String regionHash = (String) json.get("RegionHash"); |
||||
// System.out.println(json);
|
||||
|
||||
//2.拼装下载URL
|
||||
StringBuilder downUrl = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
downUrl.append("/downLoad/index?regionHash="); |
||||
downUrl.append(regionHash); |
||||
// downUrl.append("&async=true");
|
||||
// downUrl.append("&token=");
|
||||
// downUrl.append(token);
|
||||
|
||||
JSONObject jsonParam = new JSONObject(); |
||||
jsonParam.put("async",true); |
||||
jsonParam.put("token",token); |
||||
String fileString = org.apache.commons.lang.StringUtils.join(param.getFileIds().toArray(), ','); |
||||
jsonParam.put("fileIds",fileString.split(",")); |
||||
|
||||
// downUrl.append("&filesId="+fileString);
|
||||
fileString = org.apache.commons.lang.StringUtils.join(param.getFolders().toArray(), ','); |
||||
jsonParam.put("folderIds",fileString.split(",")); |
||||
// downUrl.append("&folderIds="+fileString);
|
||||
|
||||
FineLoggerFactory.getLogger().info("第2步 获取批量下载url:"+downUrl.toString()); |
||||
|
||||
result = HttpUtils.doPostObjectParam(downUrl.toString(),jsonParam,null); |
||||
FineLoggerFactory.getLogger().info("第2步 获取批量下载url结果:"+result); |
||||
json = JSONObject.parseObject(result); |
||||
String pTaskId = (String) json.get("pTaskId"); |
||||
String zipUrl = SdkBaseInfo.baseUrl+"/WebCore"; |
||||
System.out.println("第3步 压缩url:"+zipUrl); |
||||
jsonParam = new JSONObject(); |
||||
jsonParam.put("module","WebClient"); |
||||
jsonParam.put("fun","GetZipProgress"); |
||||
jsonParam.put("pTaskId",pTaskId); |
||||
jsonParam.put("token",token); |
||||
jsonParam.put("r",Math.random()*1000); |
||||
|
||||
String status = "Ziping"; |
||||
String zipName = ""; |
||||
while(status.equals("Complete") == false){ |
||||
result = HttpUtils.doPostObjectParam(zipUrl.toString(),jsonParam,null); |
||||
FineLoggerFactory.getLogger().info("第3步 压缩结果:"+result); |
||||
json = JSONObject.parseObject(result); |
||||
status = (String) json.get("status"); |
||||
zipName = (String) json.get("zipName"); |
||||
String errorMsg = (String) json.get("errorMsg"); |
||||
if(StringUtils.isNotEmpty(errorMsg)){ |
||||
return Response.error("10000","压缩失败:"+errorMsg); |
||||
} |
||||
} |
||||
|
||||
String lastdownUrl = SdkBaseInfo.baseUrl+"/downLoad/GetFile?fileName="+zipName; |
||||
FineLoggerFactory.getLogger().info("android 最后的下载url:"+lastdownUrl); |
||||
lastdownUrl = downFile1(lastdownUrl); |
||||
FineLoggerFactory.getLogger().info("android 最后的下载 fr url:"+lastdownUrl); |
||||
return Response.ok(lastdownUrl); |
||||
} catch (Exception e) { |
||||
return Response.error("404", e.getMessage()); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
@RequestMapping( |
||||
value = {"/priview"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public Response getPriviewURL(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
FineLoggerFactory.getLogger().info("yulan.................."); |
||||
FineLoggerFactory.getLogger().info("preview coming=================================================================="); |
||||
int fileId = WebUtils.getHTTPRequestIntParameter(req, "fileId"); |
||||
String userName = getCurrentUserName(req); |
||||
String ip = EDOFileUtils.getIpAddr(req); |
||||
String loginUserName = getCurrentLoginUser(req); |
||||
DecisionStatusService.loginStatusService().put(loginUserName,ip); |
||||
FineLoggerFactory.getLogger().info("======================== 预览时,存储用户名与IP:userName="+loginUserName+",ip="+ip); |
||||
String token = EDOFileUtils.createToken(userName, req); |
||||
StringBuilder url = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
url.append("/jump.html?token="); |
||||
url.append(token).append("&returnUrl=/preview.html?userName="+loginUserName+"&fileid=").append(fileId); |
||||
// String url = EDOFileUtils.createDownFileURL(fileId, verId, EDOFileUtils.createToken(getCurrentUserName(req), req));
|
||||
String result = url.toString(); |
||||
FineLoggerFactory.getLogger().info("预览地址:"+result); |
||||
return Response.ok(result); |
||||
} |
||||
|
||||
@RequestMapping( |
||||
value = {"/remove"}, |
||||
method = {RequestMethod.POST} |
||||
) |
||||
@ResponseBody |
||||
public Response deleteFiles(HttpServletRequest req, HttpServletResponse res, @RequestBody ArrayList<Integer> fileIds) { |
||||
if (fileIds == null || fileIds.size() == 0) { |
||||
return Response.success(); |
||||
} |
||||
ReturnValueResult result = EDOFileUtils.deleteFile(EDOFileUtils.createToken(getCurrentUserName(req), req), fileIds, new ArrayList<Integer>()); |
||||
if (result != null) { |
||||
if (result.getResult() == 0) { |
||||
return Response.success(); |
||||
} else { |
||||
return Response.error(String.valueOf(result.getResult()), result.getMessage()); |
||||
} |
||||
} |
||||
return Response.error("500", "位置错误"); |
||||
} |
||||
// http://120.27.145.41:8080/webroot/decision/edo/getWatermarkContent
|
||||
|
||||
@RequestMapping( |
||||
value = {"/getWatermarkContent"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
// public Response getWatermarkContent(HttpServletRequest req, HttpServletResponse res,@RequestParam String userName) throws Exception {
|
||||
public String getWatermarkContent(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
|
||||
String userName = req.getParameter("username"); |
||||
if(userName == null){ |
||||
userName = "default"; |
||||
} |
||||
|
||||
|
||||
FineLoggerFactory.getLogger().info("=============================== 获取水印内容 userName:"+userName); |
||||
String ip = DecisionStatusService.loginStatusService().get(userName); |
||||
if(StringUtils.isEmpty(ip)){ |
||||
ip = EDOFileUtils.TOKEN_IP; |
||||
} |
||||
Date date = new Date(); |
||||
// 定义格式化时间输出格式
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
String currentSimpleDate= simpleDateFormat.format(date); |
||||
String result = userName +" "+ ip + " "+currentSimpleDate; |
||||
return result; |
||||
} |
||||
|
||||
|
||||
@RequestMapping( |
||||
value = {"/file/manager"}, |
||||
method = {RequestMethod.GET} |
||||
) |
||||
@ResponseBody |
||||
public Response getFileManagerURL(HttpServletRequest req, HttpServletResponse res) throws Exception { |
||||
int folderId = WebUtils.getHTTPRequestIntParameter(req, "folderId"); |
||||
String currentUserName = getCurrentUserName(req); |
||||
String token = EDOFileUtils.createToken(currentUserName, req); |
||||
if (StringUtils.isBlank(token)) { |
||||
return Response.error("500", "获取token失败"); |
||||
} |
||||
StringBuilder url = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
url.append("/jump.html?token=").append(token); |
||||
url.append("&returnUrl=/index.html#doc/enterprise/").append(folderId); |
||||
return Response.ok(url.toString()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.edo.controller; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider; |
||||
|
||||
public class EdoControllerProvider extends AbstractControllerRegisterProvider { |
||||
|
||||
@Override |
||||
public Class<?>[] getControllers() { |
||||
return new Class[]{ |
||||
EdoController.class |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.plugin.edo.controller.params; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
public class BatchDownParam { |
||||
private ArrayList<Integer> fileIds; |
||||
private ArrayList<Integer> folders; |
||||
|
||||
public ArrayList<Integer> getFileIds() { |
||||
return fileIds; |
||||
} |
||||
|
||||
public void setFileIds(ArrayList<Integer> fileIds) { |
||||
this.fileIds = fileIds; |
||||
} |
||||
|
||||
public ArrayList<Integer> getFolders() { |
||||
return folders; |
||||
} |
||||
|
||||
public void setFolders(ArrayList<Integer> folders) { |
||||
this.folders = folders; |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.plugin.edo.controller.params; |
||||
|
||||
public class DownLoadParam { |
||||
|
||||
private String downFileName; |
||||
|
||||
|
||||
public String getDownFileName() { |
||||
return downFileName; |
||||
} |
||||
|
||||
public void setDownFileName(String downFileName) { |
||||
this.downFileName = downFileName; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,168 @@
|
||||
package com.fr.plugin.edo.submit; |
||||
|
||||
import com.edoc2.model.ResultBean; |
||||
import com.edoc2.model.upload.CheckRegionData; |
||||
import com.edoc2.model.upload.UploadFileResult; |
||||
import com.fr.cache.Attachment; |
||||
import com.fr.data.JobValue; |
||||
import com.fr.data.TotalSubmitJob; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FArray; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.io.TemplateWorkBookIO; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.main.TemplateWorkBook; |
||||
import com.fr.main.workbook.WriteWorkBook; |
||||
import com.fr.report.write.SubmitHelper; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.WriteActor; |
||||
import com.fr.web.core.ReportWebUtils; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.edoc2.entity.FileUploadConfig; |
||||
import com.edoc2.entity.FileUploadCreateInfoInput; |
||||
import com.edoc2.entity.UpdateStrategy; |
||||
import com.edoc2.entity.ResultFile; |
||||
import com.edoc2.UploadFileServices; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
public class EDOFileSubmit extends TotalSubmitJob { |
||||
@Override |
||||
protected void doTotalJob(Data data, Calculator calculator) throws Exception { |
||||
|
||||
data.getColumnCount(); |
||||
for (int i = 0; i < data.getColumnCount(); i++) { |
||||
System.out.println(data.getColumnName(i)); |
||||
} |
||||
for (int i = 0; i < data.getRowCount(); i++) { |
||||
String submitId = ""; |
||||
String updateCpt = ""; |
||||
Attachment attachment = null; |
||||
int fileId = -1; |
||||
int verId = -1; |
||||
String userName = ""; |
||||
String fileName = ""; |
||||
int folderId = -1; |
||||
for (int j = 0; j < data.getColumnCount(); j++) { |
||||
JobValue jobValue = (JobValue)data.getValueAt(i, j); |
||||
String colName = data.getColumnName(j); |
||||
if (ComparatorUtils.equals(colName, "submitId")) { |
||||
submitId = GeneralUtils.objectToString(jobValue.getValue()); |
||||
} |
||||
if (ComparatorUtils.equals(colName, "updateCpt")) { |
||||
updateCpt = GeneralUtils.objectToString(jobValue.getValue()); |
||||
} |
||||
if (ComparatorUtils.equals(colName, "fileId")) { |
||||
String s = GeneralUtils.objectToString(jobValue.getValue()); |
||||
if (StringUtils.isNotBlank(s)) { |
||||
fileId = Integer.valueOf(s).intValue(); |
||||
} |
||||
} |
||||
if (ComparatorUtils.equals(colName, "folderId")) { |
||||
String s = GeneralUtils.objectToString(jobValue.getValue()); |
||||
if (StringUtils.isNotBlank(s)) { |
||||
folderId = Integer.valueOf(s).intValue(); |
||||
} |
||||
} |
||||
if (ComparatorUtils.equals(colName, "verId")) { |
||||
String s = GeneralUtils.objectToString(jobValue.getValue()); |
||||
if (StringUtils.isNotBlank(s)) { |
||||
verId = Integer.valueOf(s).intValue(); |
||||
} |
||||
} |
||||
if (ComparatorUtils.equals("fileName", colName)) { |
||||
fileName = GeneralUtils.objectToString(jobValue.getValue()); |
||||
} |
||||
if (ComparatorUtils.equals("userName", colName)) { |
||||
userName = GeneralUtils.objectToString(jobValue.getValue()); |
||||
} |
||||
if (ComparatorUtils.equals(data.getColumnName(j), "file")) { |
||||
Object value = jobValue.getValue(); |
||||
if ((!(value instanceof FArray)) || (((FArray)value).length() <= 0)) |
||||
continue; |
||||
attachment = (Attachment)((FArray)value).elementAt(0); |
||||
|
||||
} |
||||
} |
||||
|
||||
String filePath = WorkContext.getCurrent().getPath()+ File.separator+attachment.getPath(); |
||||
FineLoggerFactory.getLogger().info("filePath:"+filePath); |
||||
FineLoggerFactory.getLogger().info("文件自定义提交参数:submitId="+submitId+",updateCpt="+updateCpt+",fileId="+fileId+",folderId="+folderId+",verId="+verId+",fileName="+fileName+",userName="+userName+",filepath:"+filePath); |
||||
|
||||
ResultFile resultBean = upload(attachment, folderId, fileId, fileName, userName,filePath); |
||||
// FineLoggerFactory.getLogger().info("上传文件的结果:code="+resultBean.getCode()+",content="+resultBean.getContent()+",isSuccess="+resultBean.isSuccess());
|
||||
if ((StringUtils.isNotBlank(submitId)) && (StringUtils.isNotBlank(updateCpt)) && (resultBean != null)) { |
||||
// int code = resultBean.getCode();
|
||||
// if (code == 1) {
|
||||
// UploadFileResult result = (UploadFileResult)resultBean.getObj();
|
||||
// CheckRegionData fileInfo = result.getFileInfo();
|
||||
int newLileId = resultBean.getFileId(); |
||||
int fileVerId = resultBean.getFileVerId(); |
||||
|
||||
Map paramater = new HashMap(); |
||||
paramater.put("submitId", submitId); |
||||
paramater.put("userName", userName); |
||||
paramater.put("folderId", Integer.valueOf(folderId)); |
||||
paramater.put("fileId", Integer.valueOf(newLileId)); |
||||
paramater.put("verId", Integer.valueOf(fileVerId)); |
||||
paramater.put("fileName", fileName); |
||||
FineLoggerFactory.getLogger().info("入库参数:submitId="+submitId+",userName="+userName+",folderId="+folderId+",fileId="+newLileId+",verId="+fileVerId+",fileName="+fileName); |
||||
TemplateWorkBook baseTemplate = TemplateWorkBookIO.readTemplateWorkBook(updateCpt); |
||||
WriteWorkBook writeworkbook = (WriteWorkBook)baseTemplate.execute(paramater, new WriteActor()); |
||||
SubmitHelper.submit(writeworkbook, baseTemplate, ReportWebUtils.dealWithReportParameters(baseTemplate, paramater)); |
||||
FineLoggerFactory.getLogger().info("入库成功"); |
||||
// } else {
|
||||
// throw new Exception(resultBean.getContent());
|
||||
// }
|
||||
} |
||||
} |
||||
} |
||||
|
||||
protected ResultFile upload(Attachment attachment, int folderId, int fileId, String filename, String userName,String filePath) |
||||
{ |
||||
if (attachment == null) { |
||||
return null; |
||||
} |
||||
if (StringUtils.isBlank(filename)); |
||||
filename = attachment.getFilename(); |
||||
FileInputStream inputStream = (FileInputStream)attachment.getInputStream(); |
||||
|
||||
String type = attachment.getType(); |
||||
|
||||
FileUploadConfig config = new FileUploadConfig(); |
||||
config.set_host("http://xxxx"); |
||||
config.set_token(EDOFileUtils.createToken(userName, null)); |
||||
UploadFileServices updaloadFile = new UploadFileServices(config); |
||||
FileUploadCreateInfoInput createInfoInput = new FileUploadCreateInfoInput(); |
||||
createInfoInput.set_fileName(filename); |
||||
createInfoInput.set_FolderId(folderId); |
||||
createInfoInput.set_FileRmark("测试文件"); |
||||
createInfoInput.set_size(attachment.getBytes().length); |
||||
createInfoInput.set_updateStrategy(UpdateStrategy.UpdateVersion); |
||||
|
||||
createInfoInput.setFilePath(filePath); |
||||
ResultFile result = null; |
||||
try { |
||||
result = updaloadFile.CreateFileInfo(createInfoInput); |
||||
if (result.getResult() == 0) { |
||||
FineLoggerFactory.getLogger().info("上传成功:fileId:"+result.getFileId()+"|verId:"+result.getFileVerId()); |
||||
} else { |
||||
FineLoggerFactory.getLogger().info("上传失败-错误编号:"+result.getResult()); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
//ResultBean resultBean = EDOFileUtils.uploadFile(EDOFileUtils.createToken(userName, null), inputStream, folderId, type, filename, fileId);
|
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,244 @@
|
||||
package com.fr.plugin.edo.submit; |
||||
|
||||
import EDoc2.IAppService.IDocAppService; |
||||
import EDoc2.IAppService.IOrgAppService; |
||||
import EDoc2.IAppService.Model.FileListAndFolderListDto; |
||||
import EDoc2.IAppService.Model.ReturnValueResult; |
||||
import EDoc2.IAppService.Model.UserLoginIntegrationByUserLoginNameDto; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.edoc2.model.ResultBean; |
||||
import com.edoc2.model.upload.UploadFileInfo; |
||||
import com.edoc2.model.upload.uploadenum.CalcMD5; |
||||
import com.edoc2.model.upload.uploadenum.UpgradeStrategy; |
||||
import com.edoc2.proxy.FacadeProxy; |
||||
import com.edoc2.sdkconfig.SdkBaseInfo; |
||||
import com.edoc2.utils.HttpUtils; |
||||
import com.edoc2.utils.UploaderUtils; |
||||
import com.fr.decision.webservice.Response; |
||||
import com.fr.io.utils.ResourceIOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.jodd.util.StringUtil; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* edo的文件处理工具类 |
||||
* |
||||
* @author xx |
||||
* @version 10.0 |
||||
* @date 2021/6/29 |
||||
*/ |
||||
public class EDOFileUtils { |
||||
private static String EDO_KEY = ""; |
||||
|
||||
public static String DEFAULT_NAME = ""; |
||||
|
||||
public static String BATCH_URL = ""; |
||||
|
||||
public static String SEARCH_URL = ""; |
||||
|
||||
public static String TOKEN_IP = ""; |
||||
|
||||
static { |
||||
InputStream inputStream = ResourceIOUtils.read("/resources/edoConfig.properties"); |
||||
Properties pro = new Properties(); |
||||
try { |
||||
pro.load(inputStream); |
||||
SdkBaseInfo.baseUrl = pro.getProperty("EDOURL"); |
||||
EDO_KEY = pro.getProperty("EDOKEY"); |
||||
DEFAULT_NAME = pro.getProperty("DEFAULT_NAME"); |
||||
BATCH_URL = pro.getProperty("BATCH_URL"); |
||||
SEARCH_URL = pro.getProperty("SEARCH_URL"); |
||||
TOKEN_IP = pro.getProperty("TOKEN_IP"); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 根据用户名获取token |
||||
* |
||||
* @param userName |
||||
* @param req |
||||
* @return |
||||
*/ |
||||
public static String createToken(String userName, HttpServletRequest req) { |
||||
String ip = getIpAddr(req); |
||||
return createToken1(userName,ip); |
||||
} |
||||
|
||||
public static String createToken1(String userName, String ip) { |
||||
IOrgAppService iOrgAppService = FacadeProxy.newProxyInstance(IOrgAppService.class); |
||||
UserLoginIntegrationByUserLoginNameDto params = new UserLoginIntegrationByUserLoginNameDto(); |
||||
params.setLoginName(userName); |
||||
params.setIntegrationKey(EDO_KEY); |
||||
|
||||
params.setIPAddress(ip); |
||||
ReturnValueResult<String> result = iOrgAppService.UserLoginIntegrationByUserLoginName(params); |
||||
if (result == null) { |
||||
FineLoggerFactory.getLogger().error("userName {} getToken failed", userName); |
||||
return StringUtils.EMPTY; |
||||
} |
||||
if (result.getResult() != 0) { |
||||
FineLoggerFactory.getLogger().error("userName {} getToken failed:{}", userName, result.getMessage()); |
||||
return StringUtils.EMPTY; |
||||
} |
||||
return result.getData(); |
||||
} |
||||
|
||||
public static String getIpAddr(HttpServletRequest request) { |
||||
if(request == null){ |
||||
return EDOFileUtils.TOKEN_IP; |
||||
} |
||||
String remoteAddr = request.getHeader("X-Forwarded-For"); |
||||
if (StringUtil.isBlank(remoteAddr)) { |
||||
remoteAddr = request.getHeader("Proxy-Client-IP"); |
||||
} |
||||
if (StringUtil.isBlank(remoteAddr)) { |
||||
remoteAddr = request.getHeader("WL-Proxy-Client-IP"); |
||||
} |
||||
return remoteAddr != null ? remoteAddr : request.getRemoteAddr(); |
||||
} |
||||
|
||||
/** |
||||
* 上传文件 |
||||
* |
||||
* @param token token |
||||
* @param inputStream 文件流 |
||||
* @param folderId 父文件夹id |
||||
* @param mimeType 文件类型 |
||||
* @param fileName 文件名称 |
||||
* @param newFileName 新文件名 |
||||
* @param lastModifiedDate 上次修改时间 |
||||
* @param strategy 文件相同时候的策略 |
||||
* @param calcMD5 是否提前计算MD5值 |
||||
*/ |
||||
public static ResultBean uploadFile(String token, FileInputStream inputStream, int folderId, String mimeType, String fileName, String newFileName, Date lastModifiedDate, UpgradeStrategy strategy, CalcMD5 calcMD5, int fileId) { |
||||
UploadFileInfo uploadFileInfo = new UploadFileInfo(); |
||||
uploadFileInfo.setName(fileName); |
||||
uploadFileInfo.setType(mimeType); |
||||
uploadFileInfo.setLastModifiedDate(lastModifiedDate); |
||||
|
||||
if (fileId > 0) { |
||||
uploadFileInfo.setFileId(fileId); |
||||
} |
||||
ResultBean resultBean = null; |
||||
try { |
||||
|
||||
resultBean = UploaderUtils.uploadFileByStream(token, folderId, strategy, |
||||
calcMD5.getValue(), newFileName, inputStream, uploadFileInfo); |
||||
} catch (IOException e) { |
||||
e.printStackTrace(); |
||||
return new ResultBean(); |
||||
} |
||||
return resultBean; |
||||
} |
||||
|
||||
/** |
||||
* 上传文件 |
||||
* |
||||
* @param token token |
||||
* @param inputStream 文件流 |
||||
* @param folderId 父文件夹id |
||||
* @param mimeType 文件类型 |
||||
* @param fileName 文件名称 |
||||
* @return |
||||
*/ |
||||
public static ResultBean uploadFile(String token, FileInputStream inputStream, int folderId, String mimeType, String fileName, int fileId) { |
||||
String newFileName = fileName; |
||||
CalcMD5 calcMD5 = CalcMD5.Before; |
||||
Date lastModifiedDate = new Date(); |
||||
UpgradeStrategy strategy = UpgradeStrategy.MinorUpgrade; |
||||
return uploadFile(token, inputStream, folderId, mimeType, fileName, newFileName, lastModifiedDate, strategy, calcMD5, fileId); |
||||
} |
||||
|
||||
/** |
||||
* 获取文件下载的地址 |
||||
* |
||||
* @param fileId 文件id |
||||
* @param verId 文件版本id |
||||
* @param token token |
||||
* @return |
||||
*/ |
||||
|
||||
public static String createDownFileURL(int fileId, int verId, String token) { |
||||
|
||||
|
||||
//2.拼装下载URL
|
||||
StringBuilder url = new StringBuilder(SdkBaseInfo.baseUrl); |
||||
|
||||
url.append("/downLoad/index?token="); |
||||
url.append(token); |
||||
url.append("&fileIds="); |
||||
url.append(fileId); |
||||
return url.toString(); |
||||
} |
||||
|
||||
public static String batchDownload(List<Integer> fileIds, List<Integer> folders,String token) throws Exception { |
||||
if(fileIds == null){ |
||||
fileIds = new ArrayList<>(); |
||||
} |
||||
if(folders == null){ |
||||
folders = new ArrayList() ; |
||||
} |
||||
if (fileIds.isEmpty() && folders.isEmpty()) { |
||||
throw new Exception("文件id与文件夹id不能同时为空"); |
||||
} |
||||
String fileString = "";//
|
||||
StringBuilder stringBuilder = new StringBuilder(BATCH_URL); |
||||
stringBuilder.append("/Download/DownLoadCheck?token="); |
||||
stringBuilder.append(token); |
||||
if(fileIds.size() > 0){ |
||||
fileString = org.apache.commons.lang.StringUtils.join(fileIds.toArray(), ','); |
||||
stringBuilder.append("&fileIds=").append(fileString); |
||||
} |
||||
else{ |
||||
stringBuilder.append("&fileIds=").append(""); |
||||
} |
||||
if(folders.size() > 0){ |
||||
fileString = org.apache.commons.lang.StringUtils.join(folders.toArray(), ','); |
||||
stringBuilder.append("&folderIds=").append(fileString); |
||||
} |
||||
else{ |
||||
stringBuilder.append("&folderIds=").append(""); |
||||
} |
||||
return stringBuilder.toString(); |
||||
} |
||||
|
||||
/** |
||||
* 删除文件 |
||||
* |
||||
* @param token token |
||||
* @param fileIDList 文件ids |
||||
* @param folderIDList 文件夹ids |
||||
* @return |
||||
*/ |
||||
public static ReturnValueResult deleteFile(String token, ArrayList<Integer> fileIDList, ArrayList<Integer> folderIDList) { |
||||
IDocAppService service = FacadeProxy.newProxyInstance(IDocAppService.class); |
||||
FileListAndFolderListDto fileListAndFolderListDto = new FileListAndFolderListDto(); |
||||
fileListAndFolderListDto.setFileIdList(fileIDList); |
||||
fileListAndFolderListDto.setFilePathList(new ArrayList<String>()); |
||||
fileListAndFolderListDto.setFolderIdList(folderIDList); |
||||
fileListAndFolderListDto.setFolderPathList(new ArrayList<String>()); |
||||
fileListAndFolderListDto.setToken(token); |
||||
return service.RemoveFolderListAndFileList(fileListAndFolderListDto); |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
List<Integer> filesId = new ArrayList<Integer>(); |
||||
filesId.add(1); |
||||
filesId.add(2); |
||||
filesId.add(4); |
||||
// System.out.println(batchDownload(filesId, ""));
|
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.plugin.edo.tabDataSource; |
||||
|
||||
import com.fr.data.AbstractDataModel; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.edo.tabDataSource.model.SearchResult; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
public class HyDataModel extends AbstractDataModel { |
||||
private String[] columnNames = SearchResult.columnNames; |
||||
public ArrayList<SearchResult> results = new ArrayList<SearchResult>(); |
||||
|
||||
public HyDataModel(ArrayList results){ |
||||
this.results = results; |
||||
} |
||||
|
||||
@Override |
||||
public int getColumnCount() throws TableDataException { |
||||
return columnNames.length; |
||||
} |
||||
|
||||
@Override |
||||
public String getColumnName(int i) throws TableDataException { |
||||
return columnNames[i]; |
||||
} |
||||
|
||||
@Override |
||||
public int getRowCount() throws TableDataException { |
||||
return results.size(); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int rowIdx, int colIdx) throws TableDataException { |
||||
String columnName = columnNames[colIdx]; |
||||
SearchResult res = results.get(rowIdx); |
||||
Object value = res.getColumnValue(columnName); |
||||
FineLoggerFactory.getLogger().info("列:"+columnName+",值:"+value); |
||||
return value; |
||||
} |
||||
} |
@ -0,0 +1,123 @@
|
||||
package com.fr.plugin.edo.tabDataSource; |
||||
|
||||
import com.fr.data.AbstractParameterTableData; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.edo.submit.EDOFileUtils; |
||||
import com.fr.plugin.edo.tabDataSource.model.SearchResult; |
||||
import com.fr.plugin.edo.util.HttpUtil; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.alibaba.druid.support.json.JSONUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedHashMap; |
||||
|
||||
public class HyTableData extends AbstractParameterTableData { |
||||
@Override |
||||
public DataModel createDataModel(Calculator calculator) { |
||||
ParameterProvider[] parameters = Calculator.processParameters(calculator,super.getParameters(calculator)); |
||||
String folderId = ""; // 搜索的文件夹Id 1代表全库
|
||||
String filename = ""; |
||||
String filecontent = ""; |
||||
for(ParameterProvider pp : parameters){ |
||||
Object value = pp.getValue(); |
||||
if(pp.getName().equals("folderId")){ |
||||
if(value != null){ |
||||
folderId = value.toString(); |
||||
} |
||||
} |
||||
if(pp.getName().equals("fileName")){ |
||||
if(value != null){ |
||||
filename = value.toString(); |
||||
} |
||||
} |
||||
if(pp.getName().equals("fileContent")){ |
||||
if(value != null){ |
||||
filecontent = value.toString(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if(folderId.equals("$folderId")){ |
||||
folderId = "1"; |
||||
} |
||||
if(filecontent.equals("$fileContent")){ |
||||
filecontent = ""; |
||||
} |
||||
if(filename.equals("$fileName")){ |
||||
filename = ""; |
||||
} |
||||
|
||||
FineLoggerFactory.getLogger().info("参数folderId:"+folderId+",filename:"+filename+",filecontent:"+filecontent); |
||||
String queryStr = "filepath:("+folderId+")"; |
||||
boolean isMask = true; //是否模糊搜索
|
||||
if(StringUtils.isNotEmpty(filename) && StringUtils.isNotEmpty(filecontent)){ |
||||
if(isMask == true){ |
||||
filename = filename; |
||||
filecontent = filecontent; |
||||
} |
||||
else{ |
||||
filename = "\""+filename+"\\\""; |
||||
filecontent ="\""+filecontent+"\\\""; |
||||
} |
||||
queryStr+= (" AND (filename:"+filename +" OR filecontent:"+filecontent+")"); |
||||
} |
||||
if(StringUtils.isNotEmpty(filename) && StringUtils.isEmpty(filecontent)){ |
||||
if(isMask == true){ |
||||
filename = filename; |
||||
} |
||||
else{ |
||||
filename = "\""+filename+"\""; |
||||
} |
||||
queryStr+= (" AND (filename: "+filename+")"); |
||||
// queryStr+= (" AND (filename: “+filename+”)");
|
||||
} |
||||
if(StringUtils.isNotEmpty(filecontent ) && StringUtils.isEmpty(filename)){ |
||||
if(isMask == true){ |
||||
filecontent = filecontent; |
||||
} |
||||
else{ |
||||
filecontent ="\""+filecontent+"\\\""; |
||||
} |
||||
queryStr+= (" AND (filecontent:"+filecontent+")"); |
||||
} |
||||
|
||||
|
||||
FineLoggerFactory.getLogger().info("参数queryStr:"+queryStr); |
||||
JSONObject jsonObj = new JSONObject(); |
||||
jsonObj.put("ArgsXml", "<GetListArgs><PageNum>0</PageNum><PageSize>10</PageSize></GetListArgs>"); |
||||
jsonObj.put("Lang", "zh-cn"); |
||||
jsonObj.put("metaDataSearch", false); |
||||
jsonObj.put("searchType", "MixFile"); |
||||
jsonObj.put("SearchXml", "{\"from\":0,\"size\":10,\"_source\":{\"excludes\":[\"filecontent\"]},\"sort\":[{\"_score\":{\"order\":\"desc\"}}],\"query\":{\"query_string\":{\"query\":\"(" + queryStr+ ")\",\"default_operator\":\"AND\"}},\"highlight\":{\"fields\":{\"filename\":{},\"filecontent\":{\"type\":\"fvh\"}},\"pre_tags\":\"<span class='Highlighter'>\",\"post_tags\":\"</span>\",\"number_of_fragments\":3,\"no_match_size\":250}}"); |
||||
jsonObj.put("StartNum",0); |
||||
jsonObj.put("Token", EDOFileUtils.createToken1("gb", EDOFileUtils.TOKEN_IP)); |
||||
String jsonData = jsonObj.toString(); |
||||
FineLoggerFactory.getLogger().info("参数jsonData:"+jsonData); |
||||
String reqResult = HttpUtil.doPost(EDOFileUtils.SEARCH_URL,jsonData); |
||||
FineLoggerFactory.getLogger().info("结果:"+reqResult); |
||||
Object obj = JSONUtils.parse(reqResult); |
||||
ArrayList<SearchResult> results = new ArrayList<SearchResult>(); |
||||
|
||||
if (obj instanceof LinkedHashMap) { |
||||
LinkedHashMap lhm = (LinkedHashMap) obj; |
||||
if((int)lhm.get("result") == 0){ |
||||
LinkedHashMap data = (LinkedHashMap)lhm.get("data"); |
||||
LinkedHashMap docListInfo = (LinkedHashMap)data.get("DocListInfo"); |
||||
if(docListInfo.containsKey("FilesInfo")){ |
||||
ArrayList<LinkedHashMap> filesInfo = (ArrayList<LinkedHashMap>)docListInfo.get("FilesInfo"); |
||||
for (LinkedHashMap lhm1 : filesInfo){ |
||||
SearchResult sr = new SearchResult(); |
||||
sr.parseMap(lhm1); |
||||
results.add(sr); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return new HyDataModel(results); |
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
package com.fr.plugin.edo.tabDataSource; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||
|
||||
public class HyTableDataDefineProvider extends AbstractTableDataDefineProvider { |
||||
@Override |
||||
public Class<? extends TableData> classForTableData() { |
||||
return HyTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForInitTableData() { |
||||
return HyTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||
return HyTableDataPane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForTableData() { |
||||
return "hy datas"; |
||||
} |
||||
|
||||
@Override |
||||
public String prefixForTableData() { |
||||
return "hy"; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForTableData() { |
||||
return "com/fr/plugin/web/js/icon.png"; |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.plugin.edo.tabDataSource; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Parameter; |
||||
import com.fr.design.data.datapane.preview.PreviewTablePane; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||
import com.fr.design.gui.itableeditorpane.UITableModelAdapter; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.script.Calculator; |
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class HyTableDataPane extends AbstractTableDataPane<HyTableData> { |
||||
|
||||
private UITableEditorPane<ParameterProvider> parameterTableEditorPane; |
||||
|
||||
public HyTableDataPane(){ |
||||
setLayout(new BorderLayout()); |
||||
UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
||||
preview.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
SwingUtilities.invokeLater(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
PreviewTablePane.previewTableData(HyTableDataPane.this.updateBean()); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
add(TableLayoutHelper.createTableLayoutPane( |
||||
new Component[][] {{ |
||||
new UILabel("配置"),preview |
||||
}}, |
||||
new double[] { TableLayout.PREFERRED }, |
||||
new double[] { TableLayout.FILL,TableLayout.PREFERRED } |
||||
),BorderLayout.NORTH); |
||||
|
||||
UITableModelAdapter<ParameterProvider> model = new ParameterTableModel(); |
||||
parameterTableEditorPane = new UITableEditorPane<ParameterProvider>(model); |
||||
|
||||
add(parameterTableEditorPane,BorderLayout.SOUTH); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(HyTableData data) { |
||||
Calculator c = Calculator.createCalculator(); |
||||
ParameterProvider[] parameters = data.getParameters(c); |
||||
parameterTableEditorPane.populate(parameters); |
||||
} |
||||
|
||||
@Override |
||||
public HyTableData updateBean() { |
||||
HyTableData data = new HyTableData(); |
||||
// data.setConfig( config.getText() );
|
||||
java.util.List<ParameterProvider> parameterProviderList = parameterTableEditorPane.update(); |
||||
Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]); |
||||
data.setParameters(parameters); |
||||
return data; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "xx文件搜索"; |
||||
} |
||||
} |
@ -0,0 +1,565 @@
|
||||
package com.fr.plugin.edo.tabDataSource.model; |
||||
|
||||
import java.util.LinkedHashMap; |
||||
|
||||
public class SearchResult { |
||||
public static final String[] columnNames = new String[]{ |
||||
"id", |
||||
"name", |
||||
"code", |
||||
"path", |
||||
"parentFolderId", |
||||
"tagContent", |
||||
"extName", |
||||
"size", |
||||
"createTime", |
||||
"modifyTime", |
||||
"creatorId", |
||||
"creatorName", |
||||
"state", |
||||
"remark", |
||||
|
||||
"highlightname", |
||||
"fileTags", |
||||
"editorId", |
||||
"editorName", |
||||
"fileType", |
||||
"currentOperatorId", |
||||
"currentOperator", |
||||
"lastVerId", |
||||
"lastVerNumStr", |
||||
"securityLevelId", |
||||
"securityLevelName", |
||||
"secLevelDegree", |
||||
"isAttachment", |
||||
"masterFileId", |
||||
"masterFilePath", |
||||
"FileCipherText", |
||||
"archiveOperator", |
||||
"archiveTime", |
||||
"content", |
||||
"relativePath", |
||||
"permission", |
||||
"favoriteId", |
||||
"favoriteType", |
||||
"isfavorite" |
||||
}; |
||||
|
||||
public void parseMap(LinkedHashMap map) { |
||||
this.id = map.get("id").toString(); |
||||
this.name = map.get("name").toString(); |
||||
this.code = map.get("code").toString(); |
||||
this.path = map.get("path").toString(); |
||||
this.parentFolderId = map.get("parentFolderId").toString(); |
||||
this.tagContent = map.get("tagContent").toString(); |
||||
this.extName = map.get("extName").toString(); |
||||
this.size = (int) map.get("size"); |
||||
this.createTime = map.get("createTime").toString(); |
||||
this.modifyTime = map.get("modifyTime").toString(); |
||||
this.creatorId = map.get("creatorId").toString(); |
||||
this.creatorName = map.get("creatorName").toString(); |
||||
this.state = (int) map.get("state"); |
||||
this.remark = map.get("remark").toString(); |
||||
|
||||
|
||||
this.highlightname = map.get("highlightname").toString(); |
||||
this.fileTags = map.get("fileTags").toString(); |
||||
this.editorId = (int) map.get("editorId"); |
||||
this.editorName = map.get("editorName").toString(); |
||||
this.fileType = (int) map.get("fileType"); |
||||
this.currentOperatorId = (int) map.get("currentOperatorId"); |
||||
this.currentOperator = map.get("currentOperator").toString(); |
||||
this.lastVerId = (int) map.get("lastVerId"); |
||||
this.lastVerNumStr = map.get("lastVerNumStr").toString(); |
||||
this.securityLevelId = (int) map.get("securityLevelId"); |
||||
this.securityLevelName = map.get("securityLevelName").toString(); |
||||
this.secLevelDegree = (int) map.get("secLevelDegree"); |
||||
this.isAttachment = (boolean) map.get("isAttachment"); |
||||
this.masterFileId = (int) map.get("masterFileId"); |
||||
if(map.get("masterFilePath") != null){ |
||||
this.masterFilePath = map.get("masterFilePath").toString(); |
||||
} |
||||
else{ |
||||
this.masterFilePath = ""; |
||||
} |
||||
this.FileCipherText = (boolean) map.get("FileCipherText"); |
||||
this.archiveOperator = map.get("archiveOperator").toString(); |
||||
this.archiveTime = map.get("archiveTime").toString(); |
||||
this.content = map.get("content").toString(); |
||||
this.relativePath = map.get("relativePath").toString(); |
||||
this.permission = (int) map.get("permission"); |
||||
this.favoriteId = map.get("favoriteId").toString(); |
||||
this.favoriteType = map.get("favoriteType").toString(); |
||||
this.isfavorite = (boolean) map.get("isfavorite"); |
||||
|
||||
} |
||||
|
||||
public Object getColumnValue(String columnName) { |
||||
if ("id".equals(columnName)) { |
||||
return this.getId(); |
||||
} |
||||
if ("name".equals(columnName)) { |
||||
return this.getName(); |
||||
} |
||||
if ("code".equals(columnName)) { |
||||
return this.getCode(); |
||||
} |
||||
if ("path".equals(columnName)) { |
||||
return this.getPath(); |
||||
} |
||||
if ("parentFolderId".equals(columnName)) { |
||||
return this.getParentFolderId(); |
||||
} |
||||
if ("tagContent".equals(columnName)) { |
||||
return this.getTagContent(); |
||||
} |
||||
if ("extName".equals(columnName)) { |
||||
return this.getExtName(); |
||||
} |
||||
if ("size".equals(columnName)) { |
||||
return this.getSize(); |
||||
} |
||||
if ("createTime".equals(columnName)) { |
||||
return this.getCreateTime(); |
||||
} |
||||
if ("modifyTime".equals(columnName)) { |
||||
return this.getModifyTime(); |
||||
} |
||||
if ("creatorId".equals(columnName)) { |
||||
return this.getCreatorId(); |
||||
} |
||||
if ("creatorName".equals(columnName)) { |
||||
return this.getCreatorName(); |
||||
} |
||||
if ("state".equals(columnName)) { |
||||
return this.getState(); |
||||
} |
||||
if ("remark".equals(columnName)) { |
||||
return this.getRemark(); |
||||
} |
||||
if ("highlightname".equals(columnName)) { |
||||
return this.highlightname; |
||||
} |
||||
if ("fileTags".equals(columnName)) { |
||||
return this.fileTags; |
||||
} |
||||
if ("editorId".equals(columnName)) { |
||||
return this.editorId; |
||||
} |
||||
if ("editorName".equals(columnName)) { |
||||
return this.editorName; |
||||
} |
||||
if ("fileType".equals(columnName)) { |
||||
return this.fileType; |
||||
} |
||||
if ("currentOperatorId".equals(columnName)) { |
||||
return this.currentOperatorId; |
||||
} |
||||
if ("currentOperator".equals(columnName)) { |
||||
return this.currentOperator; |
||||
} |
||||
if ("lastVerId".equals(columnName)) { |
||||
return this.lastVerId; |
||||
} |
||||
if ("lastVerNumStr".equals(columnName)) { |
||||
return this.lastVerNumStr; |
||||
} |
||||
if ("securityLevelId".equals(columnName)) { |
||||
return this.securityLevelId; |
||||
} |
||||
if ("securityLevelName".equals(columnName)) { |
||||
return this.securityLevelName; |
||||
} |
||||
if ("secLevelDegree".equals(columnName)) { |
||||
return this.secLevelDegree; |
||||
} |
||||
if ("isAttachment".equals(columnName)) { |
||||
return this.isAttachment; |
||||
} |
||||
if ("masterFileId".equals(columnName)) { |
||||
return this.masterFileId; |
||||
} |
||||
if ("masterFilePath".equals(columnName)) { |
||||
return this.masterFilePath; |
||||
} |
||||
if ("FileCipherText".equals(columnName)) { |
||||
return this.FileCipherText; |
||||
} |
||||
if ("archiveOperator".equals(columnName)) { |
||||
return this.archiveOperator; |
||||
} |
||||
if ("archiveTime".equals(columnName)) { |
||||
return this.archiveTime; |
||||
} |
||||
if ("content".equals(columnName)) { |
||||
return this.content; |
||||
} |
||||
if ("relativePath".equals(columnName)) { |
||||
return this.relativePath; |
||||
} |
||||
if ("permission".equals(columnName)) { |
||||
return this.permission; |
||||
} |
||||
if ("favoriteId".equals(columnName)) { |
||||
return this.favoriteId; |
||||
} |
||||
if ("favoriteType".equals(columnName)) { |
||||
return this.favoriteType; |
||||
} |
||||
if ("isfavorite".equals(columnName)) { |
||||
return this.isfavorite; |
||||
} |
||||
|
||||
|
||||
return ""; |
||||
} |
||||
|
||||
private String id; |
||||
private String name; |
||||
private String code; |
||||
private String path; |
||||
private String parentFolderId; |
||||
private String tagContent; |
||||
private String extName; |
||||
private int size; |
||||
private String createTime; |
||||
private String modifyTime; |
||||
private String creatorId; |
||||
private String creatorName; |
||||
private int state; |
||||
private String remark; |
||||
|
||||
private String highlightname; |
||||
private String fileTags; |
||||
private int editorId; |
||||
private String editorName; |
||||
private int fileType; |
||||
private int currentOperatorId; |
||||
private String currentOperator; |
||||
private int lastVerId; |
||||
private String lastVerNumStr; |
||||
private int securityLevelId; |
||||
private String securityLevelName; |
||||
private int secLevelDegree; |
||||
private boolean isAttachment; |
||||
private int masterFileId; |
||||
private String masterFilePath; |
||||
private boolean FileCipherText; |
||||
private String archiveOperator; |
||||
private String archiveTime; |
||||
private String content; |
||||
private String relativePath; |
||||
private int permission; |
||||
private String favoriteId; |
||||
private String favoriteType; |
||||
private boolean isfavorite; |
||||
|
||||
|
||||
public String getHighlightname() { |
||||
return highlightname; |
||||
} |
||||
|
||||
public void setHighlightname(String highlightname) { |
||||
this.highlightname = highlightname; |
||||
} |
||||
|
||||
public String getFileTags() { |
||||
return fileTags; |
||||
} |
||||
|
||||
public void setFileTags(String fileTags) { |
||||
this.fileTags = fileTags; |
||||
} |
||||
|
||||
public int getEditorId() { |
||||
return editorId; |
||||
} |
||||
|
||||
public void setEditorId(int editorId) { |
||||
this.editorId = editorId; |
||||
} |
||||
|
||||
public String getEditorName() { |
||||
return editorName; |
||||
} |
||||
|
||||
public void setEditorName(String editorName) { |
||||
this.editorName = editorName; |
||||
} |
||||
|
||||
public int getFileType() { |
||||
return fileType; |
||||
} |
||||
|
||||
public void setFileType(int fileType) { |
||||
this.fileType = fileType; |
||||
} |
||||
|
||||
public int getCurrentOperatorId() { |
||||
return currentOperatorId; |
||||
} |
||||
|
||||
public void setCurrentOperatorId(int currentOperatorId) { |
||||
this.currentOperatorId = currentOperatorId; |
||||
} |
||||
|
||||
public String getCurrentOperator() { |
||||
return currentOperator; |
||||
} |
||||
|
||||
public void setCurrentOperator(String currentOperator) { |
||||
this.currentOperator = currentOperator; |
||||
} |
||||
|
||||
public int getLastVerId() { |
||||
return lastVerId; |
||||
} |
||||
|
||||
public void setLastVerId(int lastVerId) { |
||||
this.lastVerId = lastVerId; |
||||
} |
||||
|
||||
public String getLastVerNumStr() { |
||||
return lastVerNumStr; |
||||
} |
||||
|
||||
public void setLastVerNumStr(String lastVerNumStr) { |
||||
this.lastVerNumStr = lastVerNumStr; |
||||
} |
||||
|
||||
public int getSecurityLevelId() { |
||||
return securityLevelId; |
||||
} |
||||
|
||||
public void setSecurityLevelId(int securityLevelId) { |
||||
this.securityLevelId = securityLevelId; |
||||
} |
||||
|
||||
public String getSecurityLevelName() { |
||||
return securityLevelName; |
||||
} |
||||
|
||||
public void setSecurityLevelName(String securityLevelName) { |
||||
this.securityLevelName = securityLevelName; |
||||
} |
||||
|
||||
public int getSecLevelDegree() { |
||||
return secLevelDegree; |
||||
} |
||||
|
||||
public void setSecLevelDegree(int secLevelDegree) { |
||||
this.secLevelDegree = secLevelDegree; |
||||
} |
||||
|
||||
public boolean isAttachment() { |
||||
return isAttachment; |
||||
} |
||||
|
||||
public void setAttachment(boolean attachment) { |
||||
isAttachment = attachment; |
||||
} |
||||
|
||||
public int getMasterFileId() { |
||||
return masterFileId; |
||||
} |
||||
|
||||
public void setMasterFileId(int masterFileId) { |
||||
this.masterFileId = masterFileId; |
||||
} |
||||
|
||||
public String getMasterFilePath() { |
||||
return masterFilePath; |
||||
} |
||||
|
||||
public void setMasterFilePath(String masterFilePath) { |
||||
this.masterFilePath = masterFilePath; |
||||
} |
||||
|
||||
public boolean isFileCipherText() { |
||||
return FileCipherText; |
||||
} |
||||
|
||||
public void setFileCipherText(boolean fileCipherText) { |
||||
FileCipherText = fileCipherText; |
||||
} |
||||
|
||||
public String getArchiveOperator() { |
||||
return archiveOperator; |
||||
} |
||||
|
||||
public void setArchiveOperator(String archiveOperator) { |
||||
this.archiveOperator = archiveOperator; |
||||
} |
||||
|
||||
public String getArchiveTime() { |
||||
return archiveTime; |
||||
} |
||||
|
||||
public void setArchiveTime(String archiveTime) { |
||||
this.archiveTime = archiveTime; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public String getRelativePath() { |
||||
return relativePath; |
||||
} |
||||
|
||||
public void setRelativePath(String relativePath) { |
||||
this.relativePath = relativePath; |
||||
} |
||||
|
||||
public int getPermission() { |
||||
return permission; |
||||
} |
||||
|
||||
public void setPermission(int permission) { |
||||
this.permission = permission; |
||||
} |
||||
|
||||
public String getFavoriteId() { |
||||
return favoriteId; |
||||
} |
||||
|
||||
public void setFavoriteId(String favoriteId) { |
||||
this.favoriteId = favoriteId; |
||||
} |
||||
|
||||
public String getFavoriteType() { |
||||
return favoriteType; |
||||
} |
||||
|
||||
public void setFavoriteType(String favoriteType) { |
||||
this.favoriteType = favoriteType; |
||||
} |
||||
|
||||
public boolean isIsfavorite() { |
||||
return isfavorite; |
||||
} |
||||
|
||||
public void setIsfavorite(boolean isfavorite) { |
||||
this.isfavorite = isfavorite; |
||||
} |
||||
|
||||
public static String[] getColumnNames() { |
||||
return columnNames; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(String id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return path; |
||||
} |
||||
|
||||
public void setPath(String path) { |
||||
this.path = path; |
||||
} |
||||
|
||||
public String getParentFolderId() { |
||||
return parentFolderId; |
||||
} |
||||
|
||||
public void setParentFolderId(String parentFolderId) { |
||||
this.parentFolderId = parentFolderId; |
||||
} |
||||
|
||||
public String getTagContent() { |
||||
return tagContent; |
||||
} |
||||
|
||||
public void setTagContent(String tagContent) { |
||||
this.tagContent = tagContent; |
||||
} |
||||
|
||||
public String getExtName() { |
||||
return extName; |
||||
} |
||||
|
||||
public void setExtName(String extName) { |
||||
this.extName = extName; |
||||
} |
||||
|
||||
public int getSize() { |
||||
return size; |
||||
} |
||||
|
||||
public void setSize(int size) { |
||||
this.size = size; |
||||
} |
||||
|
||||
public String getCreateTime() { |
||||
return createTime; |
||||
} |
||||
|
||||
public void setCreateTime(String createTime) { |
||||
this.createTime = createTime; |
||||
} |
||||
|
||||
public String getModifyTime() { |
||||
return modifyTime; |
||||
} |
||||
|
||||
public void setModifyTime(String modifyTime) { |
||||
this.modifyTime = modifyTime; |
||||
} |
||||
|
||||
public String getCreatorId() { |
||||
return creatorId; |
||||
} |
||||
|
||||
public void setCreatorId(String creatorId) { |
||||
this.creatorId = creatorId; |
||||
} |
||||
|
||||
public String getCreatorName() { |
||||
return creatorName; |
||||
} |
||||
|
||||
public void setCreatorName(String creatorName) { |
||||
this.creatorName = creatorName; |
||||
} |
||||
|
||||
public int getState() { |
||||
return state; |
||||
} |
||||
|
||||
public void setState(int state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public String getRemark() { |
||||
return remark; |
||||
} |
||||
|
||||
public void setRemark(String remark) { |
||||
this.remark = remark; |
||||
} |
||||
} |
@ -0,0 +1,241 @@
|
||||
package com.fr.plugin.edo.util; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
|
||||
import javax.net.ssl.*; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.*; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.security.cert.CertificateException; |
||||
|
||||
public class HttpUtil { |
||||
|
||||
private static String parseStringHttpsReq(HttpURLConnection conn) throws IOException { |
||||
InputStream inputStream = conn.getInputStream(); |
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
||||
byte[] buf = new byte[1024]; |
||||
int len = 0; |
||||
while ((len = inputStream.read(buf)) != -1) { |
||||
baos.write(buf, 0, len); |
||||
} |
||||
baos.flush(); |
||||
String result = baos.toString(); |
||||
inputStream.close(); |
||||
baos.close(); |
||||
return result; |
||||
} |
||||
|
||||
private static HttpURLConnection getConnection(URL url) throws IOException { |
||||
HttpUtil.trustAllHosts(); |
||||
HttpURLConnection conn = null; |
||||
HttpsURLConnection https = (HttpsURLConnection) url.openConnection(); |
||||
https.setHostnameVerifier(HttpUtil.DO_NOT_VERIFY); |
||||
conn = https; |
||||
conn.setRequestMethod("GET");//设置请求方式
|
||||
conn.setConnectTimeout(6000); |
||||
conn.setReadTimeout(6000); |
||||
conn.setDoInput(true); |
||||
conn.setDoOutput(true); |
||||
conn.setRequestProperty("Content-Type", "application/json;charset=utf-8"); |
||||
|
||||
return conn; |
||||
} |
||||
|
||||
public static String doGet(String reqUrl) throws IOException { |
||||
FineLoggerFactory.getLogger().info("get req url:"+reqUrl); |
||||
URL url = new URL(reqUrl); |
||||
HttpURLConnection conn = getConnection(url); |
||||
int statusCode = conn.getResponseCode(); |
||||
FineLoggerFactory.getLogger().info("get req statusCode:"+statusCode); |
||||
String result = ""; |
||||
if (statusCode == 200) { |
||||
result = parseStringHttpsReq(conn); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public static String doGetStream(String reqUrl, HttpServletResponse res) throws IOException { |
||||
FineLoggerFactory.getLogger().info("get req url:"+reqUrl); |
||||
URL url = new URL(reqUrl); |
||||
HttpURLConnection conn = getConnection(url); |
||||
int statusCode = conn.getResponseCode(); |
||||
FineLoggerFactory.getLogger().info("get req statusCode:"+statusCode); |
||||
String result = ""; |
||||
if (statusCode == 200) { |
||||
InputStream inputStream = conn.getInputStream(); |
||||
int len; |
||||
byte[] b = new byte[1024]; |
||||
|
||||
try { |
||||
while ((len = inputStream.read(b, 0, 1024)) != -1) { |
||||
res.getOutputStream().write(b, 0, len); |
||||
} |
||||
|
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} finally { |
||||
if (inputStream != null) { |
||||
inputStream.close(); |
||||
} |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public static String doPost(String reqUrl,String jsonData){ |
||||
FineLoggerFactory.getLogger().info("post req url:" + reqUrl+",jsonData:"+jsonData); |
||||
if(reqUrl.indexOf("https") != -1){ |
||||
return doPostHttpsReq(jsonData,reqUrl); |
||||
} |
||||
else{ |
||||
return doPostHttpReq(jsonData,reqUrl); |
||||
} |
||||
} |
||||
|
||||
public static String doPostHttpsReq(String jsonData, String reqUrl) { |
||||
HttpUtil.trustAllHosts(); |
||||
// HttpURLConnection con = null;
|
||||
HttpsURLConnection con = null; |
||||
BufferedReader buffer = null; |
||||
StringBuffer resultBuffer = null; |
||||
String result = ""; |
||||
try { |
||||
URL url = new URL(reqUrl); |
||||
// 得到连接对象
|
||||
// con = (HttpURLConnection) url.openConnection();
|
||||
con = (HttpsURLConnection) url.openConnection(); |
||||
con.setHostnameVerifier(HttpUtil.DO_NOT_VERIFY); |
||||
// 设置请求类型
|
||||
con.setRequestMethod("POST"); |
||||
con.setRequestProperty("Content-Type", "application/json;charset=utf-8"); |
||||
|
||||
con.setDoOutput(true); |
||||
con.setDoInput(true); |
||||
con.setUseCaches(false); |
||||
con.setConnectTimeout(6000); |
||||
con.setReadTimeout(6000); |
||||
con.connect(); |
||||
String body = jsonData; |
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), "UTF-8")); |
||||
writer.write(body); |
||||
writer.close(); |
||||
|
||||
|
||||
int responseCode = con.getResponseCode(); |
||||
FineLoggerFactory.getLogger().info("sendRedirect responseCode:" + responseCode); |
||||
if (responseCode == HttpURLConnection.HTTP_OK) { |
||||
InputStream inputStream = con.getInputStream(); |
||||
resultBuffer = new StringBuffer(); |
||||
String line; |
||||
buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
||||
while ((line = buffer.readLine()) != null) { |
||||
resultBuffer.append(line); |
||||
} |
||||
result = resultBuffer.toString(); |
||||
FineLoggerFactory.getLogger().info("result:" + result); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
FineLoggerFactory.getLogger().info("失败.................................:"+e.toString()); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
public static String doPostHttpReq(String jsonData, String reqUrl) { |
||||
HttpURLConnection con = null; |
||||
BufferedReader buffer = null; |
||||
StringBuffer resultBuffer = null; |
||||
String result = ""; |
||||
try { |
||||
URL url = new URL(reqUrl); |
||||
// 得到连接对象
|
||||
con = (HttpURLConnection) url.openConnection(); |
||||
// 设置请求类型
|
||||
con.setRequestMethod("POST"); |
||||
con.setRequestProperty("Content-Type", "application/json;charset=utf-8"); |
||||
|
||||
con.setDoOutput(true); |
||||
con.setDoInput(true); |
||||
con.setUseCaches(false); |
||||
con.setConnectTimeout(6000); |
||||
con.setReadTimeout(6000); |
||||
con.connect(); |
||||
String body = jsonData; |
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(con.getOutputStream(), "UTF-8")); |
||||
writer.write(body); |
||||
writer.close(); |
||||
|
||||
|
||||
int responseCode = con.getResponseCode(); |
||||
FineLoggerFactory.getLogger().info("sendRedirect responseCode:" + responseCode); |
||||
if (responseCode == HttpURLConnection.HTTP_OK) { |
||||
InputStream inputStream = con.getInputStream(); |
||||
resultBuffer = new StringBuffer(); |
||||
String line; |
||||
buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
||||
while ((line = buffer.readLine()) != null) { |
||||
resultBuffer.append(line); |
||||
} |
||||
result = resultBuffer.toString(); |
||||
FineLoggerFactory.getLogger().info("result:" + result); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
FineLoggerFactory.getLogger().info("失败.................................:"+e.toString()); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
public static String doPostCommonReq(String reqUrl, String jsonData) { |
||||
FineLoggerFactory.getLogger().info("post req url:" + reqUrl+",jsonData:"+jsonData); |
||||
if(reqUrl.indexOf("https") != -1){ |
||||
return doPostHttpsReq(reqUrl,jsonData); |
||||
} |
||||
else{ |
||||
return doPostHttpReq(reqUrl,jsonData); |
||||
} |
||||
} |
||||
|
||||
|
||||
private static void trustAllHosts() { |
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { |
||||
@Override |
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) |
||||
throws CertificateException { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) |
||||
throws CertificateException { |
||||
|
||||
} |
||||
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
||||
return new java.security.cert.X509Certificate[] {}; |
||||
} |
||||
|
||||
} }; |
||||
// Install the all-trusting trust manager
|
||||
try { |
||||
SSLContext sc = SSLContext.getInstance("TLS"); |
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom()); |
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
FineLoggerFactory.getLogger().info("error trustAllHosts----- HTTPS" + e.toString()); |
||||
} |
||||
} |
||||
|
||||
private final static HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() { |
||||
public boolean verify(String hostname, SSLSession session) { |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.edo.web; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
/** |
||||
* @author xx |
||||
* @version 10.0 |
||||
* @date 2021/6/29 |
||||
*/ |
||||
public class EDOJavaScriptFileHandler extends AbstractJavaScriptFileHandler { |
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{"/com/fr/plugin/web/js/utils/EDOJSUtils.js"}; |
||||
} |
||||
} |
@ -0,0 +1 @@
|
||||
<GetListArgs><PageNum>0</PageNum><PageSize>10</PageSize></GetListArgs> |
After Width: | Height: | Size: 382 B |
@ -0,0 +1,162 @@
|
||||
{ |
||||
"data": { |
||||
"DocListInfo": { |
||||
"InfoItems": [ |
||||
{ |
||||
"Name": "basic:name", |
||||
"Title": "name", |
||||
"Width": 400, |
||||
"Remark": null, |
||||
"DataType": "docName" |
||||
}, |
||||
{ |
||||
"Name": "basic:size", |
||||
"Title": "size", |
||||
"Width": 150, |
||||
"Remark": null, |
||||
"DataType": "fileSize" |
||||
}, |
||||
{ |
||||
"Name": "basic:creator", |
||||
"Title": "creator", |
||||
"Width": 150, |
||||
"Remark": null, |
||||
"DataType": "string" |
||||
}, |
||||
{ |
||||
"Name": "basic:editor", |
||||
"Title": "editor", |
||||
"Width": 150, |
||||
"Remark": null, |
||||
"DataType": "string" |
||||
}, |
||||
{ |
||||
"Name": "basic:modifyTime", |
||||
"Title": "modifyTime", |
||||
"Width": 170, |
||||
"Remark": null, |
||||
"DataType": "datetime" |
||||
}, |
||||
{ |
||||
"Name": "basic:version", |
||||
"Title": "version", |
||||
"Width": 100, |
||||
"Remark": null, |
||||
"DataType": "version" |
||||
}, |
||||
{ |
||||
"Name": "basic:content", |
||||
"Title": "content", |
||||
"Width": 0, |
||||
"Remark": null, |
||||
"DataType": null |
||||
}, |
||||
{ |
||||
"Name": "basic:highlightname", |
||||
"Title": "highlightname", |
||||
"Width": 0, |
||||
"Remark": null, |
||||
"DataType": null |
||||
}, |
||||
{ |
||||
"Name": "basic:relativePath", |
||||
"Title": "relativePath", |
||||
"Width": 0, |
||||
"Remark": null, |
||||
"DataType": null |
||||
} |
||||
], |
||||
"FoldersInfo": [], |
||||
"FilesInfo": [ |
||||
{ |
||||
"id": 26, |
||||
"highlightname": "<span class='Highlighter'>1630817226</span>.png", |
||||
"name": "1630817226.png", |
||||
"code": "", |
||||
"path": "1\\16\\", |
||||
"parentFolderId": 16, |
||||
"tagContent": "", |
||||
"fileTags": [], |
||||
"extName": ".png", |
||||
"size": 88479, |
||||
"createTime": "2022-05-17 15:20:49", |
||||
"modifyTime": "2022-05-17 17:31:01", |
||||
"creatorId": 14, |
||||
"creatorName": "gongbin", |
||||
"editorId": 2, |
||||
"editorName": "Administrator", |
||||
"state": 0, |
||||
"remark": "", |
||||
"fileType": 2, |
||||
"currentOperatorId": 0, |
||||
"currentOperator": "", |
||||
"lastVerId": 25, |
||||
"lastVerNumStr": "1.0", |
||||
"securityLevelId": 0, |
||||
"securityLevelName": "", |
||||
"secLevelDegree": -1, |
||||
"isAttachment": false, |
||||
"masterFileId": 0, |
||||
"masterFilePath": null, |
||||
"FileCipherText": false, |
||||
"archiveOperator": 0, |
||||
"archiveTime": "2022-05-17 15:20:50", |
||||
"content": "", |
||||
"relativePath": "企业内容库\\我的文件1", |
||||
"permission": 1088391993, |
||||
"favoriteId": "", |
||||
"favoriteType": "", |
||||
"isfavorite": false |
||||
} |
||||
], |
||||
"Settings": { |
||||
"searchTotalCount": 1, |
||||
"endNum": 1 |
||||
}, |
||||
"MustOnline": false, |
||||
"EnabledOutSend": false, |
||||
"SecurityEnable": false, |
||||
"ProcessStrategy": [], |
||||
"ArchiveStrategy": {}, |
||||
"IsArchive": false, |
||||
"CiphertextOutwardPolicy": 0 |
||||
}, |
||||
"DocViewInfoList": [ |
||||
{ |
||||
"ViewId": 1, |
||||
"EntryType": 0, |
||||
"EntryId": 0, |
||||
"UserId": 0, |
||||
"ViewType": "standard", |
||||
"ViewName": "List", |
||||
"ConfigString": "<InfoNames><Info><Name>basic:name</Name><Width>400</Width></Info><Info><Name>basic:size</Name><Width>150</Width></Info><Info><Name>basic:creator</Name><Width>150</Width></Info><Info><Name>basic:editor</Name><Width>150</Width></Info><Info><Name>basic:modifyTime</Name><Width>170</Width></Info><Info><Name>basic:version</Name><Width>100</Width></Info></InfoNames><SortInfoName>basic:name</SortInfoName><SortDesc>false</SortDesc><PageSize>20</PageSize><ViewMode>List</ViewMode>", |
||||
"IsDefault": true |
||||
}, |
||||
{ |
||||
"ViewId": -2, |
||||
"EntryType": 0, |
||||
"EntryId": 0, |
||||
"UserId": 0, |
||||
"ViewType": "standard", |
||||
"ViewName": "Summary", |
||||
"ConfigString": "", |
||||
"IsDefault": false |
||||
}, |
||||
{ |
||||
"ViewId": -3, |
||||
"EntryType": 0, |
||||
"EntryId": 0, |
||||
"UserId": 0, |
||||
"ViewType": "standard", |
||||
"ViewName": "Thumbnail", |
||||
"ConfigString": "<InfoNames><Info><Name>basic:name</Name><Width>400</Width></Info></InfoNames><SortInfoName>basic:name</SortInfoName><SortDesc>false</SortDesc><PageSize>20</PageSize><ViewMode>Thumbnail</ViewMode>", |
||||
"IsDefault": false |
||||
} |
||||
], |
||||
"StartNum": 0, |
||||
"EndNum": 1 |
||||
}, |
||||
"dataDescription": "", |
||||
"result": 0, |
||||
"message": "" |
||||
} |
@ -0,0 +1,36 @@
|
||||
{ |
||||
"from": 0,//从多少条开始 |
||||
"size": 20,//每页显示记录条数 |
||||
"_source": { |
||||
"excludes": [ |
||||
"filecontent" |
||||
] |
||||
}, |
||||
"sort": [ |
||||
{ |
||||
"_score": { |
||||
"order": "desc" |
||||
} |
||||
} |
||||
], |
||||
"query": { |
||||
"query_string": { |
||||
"query": " filepath:(1) AND (filename:\"aa\" OR filecontent:\"aa\")", |
||||
//filepath:搜索的文件夹Id 1代表全库;//如 aa 没有双引号是模糊搜索,如果有双引号 "aa" 则是精确搜索在传参的时候由于是字符串所以参数是 keyWord:"\"aa\"" 形式 |
||||
//搜索范围:filename --文件名 filecontent--文件内容 |
||||
"default_operator": "AND" |
||||
} |
||||
}, |
||||
"highlight": { |
||||
"fields": { |
||||
"filename": {}, |
||||
"filecontent": { |
||||
"type": "fvh" |
||||
} |
||||
}, |
||||
"pre_tags": "<span class=\\'Highlighter\\'>", |
||||
"post_tags": "</span>", |
||||
"number_of_fragments": 3, |
||||
"no_match_size": 250 |
||||
} |
||||
} |
@ -0,0 +1,186 @@
|
||||
/** |
||||
* @author xx |
||||
* @date 2021/6/29 |
||||
* @version 10.0 |
||||
*/ |
||||
; !(function () { |
||||
console.log("加载文件管理JS。。。。。。。。。。。。。。。。。。") |
||||
var util = { |
||||
isMobile: function () { |
||||
try { |
||||
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
}, |
||||
|
||||
isAndroidMobile: function () { |
||||
try { |
||||
if (/Android/i.test(navigator.userAgent)) { |
||||
return true; |
||||
} else { |
||||
return false; |
||||
} |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
}, |
||||
postJSON: function (url, data, callback, error) { |
||||
url = FR.fineServletURL + url; |
||||
FR.ajax({ |
||||
type: "POST", |
||||
url: url, |
||||
contentType: "application/json; charset=utf-8", |
||||
data: JSON.stringify(data), |
||||
success: function (resp) { |
||||
$.isFunction(callback) && callback(resp); |
||||
}, |
||||
error: function (err) { |
||||
$.isFunction(error) && error(err); |
||||
} |
||||
}) |
||||
}, |
||||
get: function (url, data, callback, error) { |
||||
url = FR.fineServletURL + url; |
||||
FR.ajax({ |
||||
type: "GET", |
||||
url: url, |
||||
data: data, |
||||
success: function (resp) { |
||||
$.isFunction(callback) && callback(resp); |
||||
}, |
||||
error: function (err) { |
||||
$.isFunction(error) && error(err); |
||||
} |
||||
}) |
||||
} |
||||
}; |
||||
|
||||
|
||||
|
||||
|
||||
window["EDO"] = { |
||||
"downloadFile": function (fileId, verId, userName) {//下载
|
||||
if (util.isAndroidMobile()) { |
||||
console.log("android platform") |
||||
var url = "/edo/getDownloadUrlFr?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
console.log("下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
||||
console.log("下载地址为:"+newUrl) |
||||
|
||||
// window.open(newUrl)
|
||||
// window.location.href = newUrl;
|
||||
FR.doHyperlinkByGet({"url":newUrl}) |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
} |
||||
else { |
||||
console.log("not android platform") |
||||
var url = "/edo/download?fileId=" + fileId + "&verId=" + verId + "&edocName=" + userName; |
||||
util.get(url, {}, function (res) { |
||||
// FR.Msg.toast(res.data)
|
||||
console.log("下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
// window.open(res.data)
|
||||
//window.location.href = res.data;
|
||||
FR.doHyperlinkByGet({"url":res.data}) |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
}, |
||||
"priviewFile": function (fileId, userName) { //预览
|
||||
var url = "/edo/priview?fileId=" + fileId + "&edocName=" + userName; |
||||
|
||||
util.get(url, {}, function (res) { |
||||
// console.log("预览返回结果:" + JSON.stringify(res))
|
||||
// var isIphone = util.isIphoneMobile();
|
||||
// FR.Msg.toast("isIphone:"+isIphone);
|
||||
if (!res.errorCode) { |
||||
// window.location.href = res.data;
|
||||
FR.doHyperlinkByGet({"url":res.data}) |
||||
// var a = document.createElement("a");
|
||||
// a.href = res.data;
|
||||
// a.click();
|
||||
|
||||
// window.location=res.data;
|
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}); |
||||
}, |
||||
"deleteFiles": function (fileIds, callback, userName) { //删除
|
||||
var url = "/edo/remove" + "?edocName=" + userName; |
||||
|
||||
util.postJSON(url, fileIds, function () { |
||||
callback && callback(); |
||||
}) |
||||
|
||||
}, |
||||
"batchDownload": function (fileIds, folders, userName) { //批量下载
|
||||
if (util.isAndroidMobile()) { |
||||
console.log("android platform") |
||||
var url = "/edo/batch/downloadFr" + "?edocName=" + userName; |
||||
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
||||
console.log("批量下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
var newUrl = location.protocol+"//"+ location.host+"/webroot/decision/edo/downloadFileFr?downFileName="+res.data; |
||||
console.log("下载地址为:"+newUrl) |
||||
// window.open(newUrl)
|
||||
//window.location.href = newUrl;
|
||||
// window.open(res.data)
|
||||
FR.doHyperlinkByGet({"url":newUrl}) |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}) |
||||
} |
||||
else{ |
||||
console.log("not android platform") |
||||
var url = "/edo/batch/download" + "?edocName=" + userName; |
||||
util.postJSON(url, { fileIds: fileIds, folders: folders }, function (res) { |
||||
console.log("批量下载返回结果:" + JSON.stringify(res)) |
||||
if (!res.errorCode) { |
||||
//window.open(res.data)
|
||||
FR.doHyperlinkByGet({"url":res.data}) |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
}) |
||||
} |
||||
|
||||
}, |
||||
|
||||
"fileManager": function (folderId, userName, callback) { |
||||
var url = "/edo/file/manager?" + "folderId=" + folderId + "&edocName=" + userName; |
||||
|
||||
util.get(url, {}, function (res) { |
||||
if (!res.errorCode) { |
||||
if ($.isFunction(callback)) { |
||||
callback(res); |
||||
} else { |
||||
window.open(res.data) |
||||
} |
||||
} else { |
||||
FR.Msg.toast(res.errorMsg); |
||||
} |
||||
|
||||
}); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
})(); |
Loading…
Reference in new issue