李勇

1.文档模块增加新接口 getDocFullAddress(_param) 之前获取图片好pdf的接口将废弃

此 diff 太大无法显示。
... ... @@ -26,7 +26,7 @@ import ArrayBufferUtil from 'libs/ArrayBufferUtil';
import UTF8 from 'utf-8';
let loger = Loger.getLoger('MessageEntrance');
let _sdkInfo = {"version": "v.1.8.22.20170411", "author": "www.3mang.com"};
let _sdkInfo = {"version": "v.1.9.0.20170411", "author": "www.3mang.com"};
//APE
let _sass;
... ... @@ -173,9 +173,10 @@ export default class MessageEntrance extends Emiter {
this.getDocImageFullPath = this._getDocImageFullPath.bind(this);
//获取文档图片的完整路径
this.getDocPDFFullPath = this._getDocPDFFullPath.bind(this);//获取文档的完整路径
this.getDocFullAddress=this._getDocFullAddress.bind(this);//获取文档资源地址
this.setDebuger = this._setDebuger.bind(this);//debug
this.setDebuger = this._setDebuger.bind(this);//debug
this.setMessageDelay=this._setMessageDelay.bind(this);//设置是否延迟消息
}
... ... @@ -928,16 +929,25 @@ export default class MessageEntrance extends Emiter {
//DocApe
//获取文档的所有资源地址
_getDocFullAddress(_param) {
if (_doc_ape) {
return _doc_ape.getDocFullAddress(_param);
} else {
loger.error("文档模块还没有创建无法获取");
return {"code":ApeConsts.RETURN_FAILED, "data": "文档模块还没有创建无法获取"};
}
}
//获取文档完整路径
_getDocImageFullPath(_param) {
if (_doc_ape) {
return _doc_ape.getDocImageFullPath(_param);
} else {
loger.error("文档模块还没有创建,无法获取");
loger.error("文档模块还没有创建无法获取");
return [];
}
}
_getDocPDFFullPath(_param) {
if (_doc_ape) {
return _doc_ape.getDocPDFFullPath(_param);
... ...
... ... @@ -32,35 +32,31 @@ class DocApe extends Ape {
ApeConsts.DOCSHARING_SESSION_TAG
);
this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据
//this.activeDocItemIdx =0;//当前激活的文档itemIdx
//this.activeDocCurPage=1;//当前激活的文档的当前页
// Ape Models
this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer);
this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID, ApeConsts.DOCSHARING_OBJ_TABLE_NAME, ApeConsts.DOCSHARING_OBJ_TABLE_TAG, 0, new ArrayBuffer);
//this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5, ApeConsts.DOCSHARING_OBJ_TABLE_NAME_H5, ApeConsts.DOCSHARING_OBJ_TABLE_TAG_H5, 0, new ArrayBuffer);
}
}
/////////////发送数据操作//////////////////////////////////////////////////////
//上传文档
documentUpload(paramInfo) {
if (paramInfo == null || EngineUtils.isEmptyObject(paramInfo)) {
loger.log('documentUpload失败,参数错误');
loger.warn('上传文档->失败->参数错误->',paramInfo);
this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return;
}
//判断文档是否已经存在,每个文档都有唯一的docId,如果已经同步的文档中存在相同的docId就不需要再同步
if (this.checkDocId(paramInfo.docId)) {
//文档已经存在相同的docId,不需要同步上传
loger.warn('documentUpload->档的docId无效或已经存在相同的docId,不需要上传');
loger.warn('上传文档->失败->文档档的docId无效或已经存在相同的docId不需要上传');
return;
}
itemIdx = EngineUtils.creatSoleNumberFromTimestamp();//
let docDataModelPdu = this.packPdu(paramInfo, itemIdx);
if (docDataModelPdu == null) {
loger.log('documentUpload失败,参数错误');
loger.log('上传文档->失败->数据无效');
this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
return;
}
... ... @@ -93,7 +89,7 @@ class DocApe extends Ape {
adapterPdu.type = pdu.RCPDU_REG_ADAPTER;
adapterPdu.item.push(adapterItemPdu);
loger.log("文档upload tableItemPdu.itemIdx=" + tableItemPdu.itemIdx);
loger.log("上传文档->发送->itemIdx=" + tableItemPdu.itemIdx);
this.sendUniform(adapterPdu, true);
}
... ... @@ -137,6 +133,92 @@ class DocApe extends Ape {
loger.log("发送更新文档.itemIdx=" + tableItemPdu.itemIdx);
this.sendUniform(adapterPdu, true);
}
//获取文档的完整地址和所有图片
getDocFullAddress(_param){
if (_param == null || _param.url == null || _param.itemIdx ==null) {
loger.warn('获取文档完整地址->传递的参数不正确->', _param);
return {"code":ApeConsts.RETURN_FAILED, "data": "获取文档时传递的参数不对"};
}
let fullPath='';//文档路径地址
let pageNum=1;//总页数
let docType="";//文档地址的后缀类型
let fileType="";//文档的原始类型
let docItem=this.docList[_param.itemIdx];
if(docItem){
fullPath=docItem.url||"";
pageNum=docItem.pageNum||1;
fileType=docItem.fileType||""
}else {
fullPath =_param.url;
}
//获取当前文档的后缀名
docType=this._getDocType(fullPath);
let substrFullPath=this._getDocPath(fullPath);//获取去掉后缀和文件名的地址,需要获取同目录下其他文件
let imagesArr=[];
let htmlPath="";
let pdfPath="";
//根据文件后缀名,生成对应的访问地址
if(docType=="jpg"||docType=="png"||docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){
//页数从1开始
for (let i = 1; i <=pageNum; i++) {
imagesArr.push(substrFullPath + "/" + i + ".jpg");
}
}
if(docType=="swf"||docType=="pdf"||docType=="doc"||docType=="pptx"){
pdfPath=fullPath.replace(/\.swf/g, ".pdf")||"";
}
//动态PPT
if(docType=="html"){
htmlPath=fullPath;
}
//返回文档第所有地址
return {'code':ApeConsts.RETURN_SUCCESS, 'data': '','docFullAddress':{
'images':imagesArr,
'pdf':pdfPath,
' html':htmlPath
}};
}
_getDocType(_fullPath){
if(!_fullPath){
return "";
}
if(_fullPath.lastIndexOf(".jpg")>=0){
return "jpg";
}
if(_fullPath.lastIndexOf(".png")>=0){
return "png";
}
if(_fullPath.lastIndexOf(".swf")>=0){
return "swf";
}
if(_fullPath.lastIndexOf(".pdf")>=0){
return "pdf";
}
if(_fullPath.lastIndexOf(".doc")>=0){
return "doc";
}
if(_fullPath.lastIndexOf(".html")>=0){
return "html";
}
if(_fullPath.lastIndexOf(".pptx")>=0){
return "pptx";
}
return "";
}
//获取去掉文件名和后缀名的地址 http://www.xxx.xxx/image/aa.jpg -->http://www.xxx.xxx/image/
_getDocPath(_fullPath){
if(!_fullPath){
return "";
}
var lastIndex = _fullPath.lastIndexOf("/");
if (lastIndex > 0) {
return _fullPath.substr(0, lastIndex);
}
return _fullPath;
}
//获取文档的图片完整地址
getDocImageFullPath(_param) {
... ... @@ -540,7 +622,7 @@ class DocApe extends Ape {
///////数据的封包和解包/////////////////////////////////////////
packPdu(_param, _itemIdx) {
loger.log("文档===>packPdu ");
loger.log("文档===>packPdu");
//验证坐标点集合数组是否合法
if (_param == null || _itemIdx == null) {
this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG);
... ... @@ -555,7 +637,7 @@ class DocApe extends Ape {
docModelPdu.pageNum = _param.pageNum || 1;
docModelPdu.fileType = _param.fileType || "";
docModelPdu.creatUserId = _param.creatUserId || "0";
docModelPdu.url = "";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu.url = _param.url||"";//这个地址没用到,数据太长占用资源 暂停使用//"http://101.200.150.192/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu.relativeUrl = _param.relativeUrl || "";//"/DocSharing/data/h5test/20170206-171100025/7e9c4178cac1133e0dd9d5b583439122.jpg";
docModelPdu.curV = _param.curV || 0;
docModelPdu.curH = _param.curH || 0;
... ...