OA附件读取定时任务优化
This commit is contained in:
parent
6e1dfc930f
commit
ada1632e4d
|
@ -1,5 +1,6 @@
|
|||
package shkd.repc.task;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
|
@ -65,13 +66,14 @@ public class DobeContractAttachmentTask extends AbstractTask implements Plugin {
|
|||
String requrl;
|
||||
String nasPath = null;
|
||||
JSONObject resultjsonObject;
|
||||
JSONArray filenames;
|
||||
for (int i = 0; i < cons.length; i++) {
|
||||
contractinfo = cons[i];
|
||||
//根据合同中的编号、附件oa id、正文oa id三个字段调用OA附件接口,记录日志
|
||||
contractid = contractinfo.getLong("id");
|
||||
contractno = contractinfo.getString("billno");
|
||||
fj_oaid = contractinfo.getString("qeug_fjoaid");
|
||||
fj_zwid = contractinfo.getString("qeug_fjzwid");
|
||||
fj_oaid = contractinfo.getString("qeug_fjoaid");//流程ID(Excel导入模板中的附件字段) 必填
|
||||
fj_zwid = contractinfo.getString("qeug_fjzwid");//正文ID(Excel导入模板中的合同正文字段) 非必填
|
||||
|
||||
//拿到OA附件接口返回的NAS文件存放路径
|
||||
requrl = oaUrl+oa_menthod+contractno+"?summaryId="+fj_oaid+"&subReference="+fj_zwid;
|
||||
|
@ -103,22 +105,27 @@ public class DobeContractAttachmentTask extends AbstractTask implements Plugin {
|
|||
if(!DobeDWUtils.isEmpty(nasPath)){
|
||||
//处理表单附件目录
|
||||
nasPath = nasPath.substring(2).replace("\\","/");
|
||||
// resultjsonObject.getJSONArray("");
|
||||
try {
|
||||
boolean upresult = false;
|
||||
//nasPath+fj_oaid;
|
||||
logger.info(contractno+" OA附件接口返回nasPath\n{}", nasPath+"/"+fj_oaid);
|
||||
boolean upresult = AttachmentFileUtil.saveDirFile2Attchment(appId,entityName,contractid,nasPath+"/"+fj_oaid,attachKey,null);
|
||||
filenames = resultjsonObject.getJSONArray("att_fileNames");//流程附件文件名称清单
|
||||
if(filenames != null && !filenames.isEmpty()){
|
||||
upresult = AttachmentFileUtil.saveDirFile2Attchment(appId,entityName,contractid,nasPath+"/"+fj_oaid,attachKey,filenames);
|
||||
}
|
||||
//处理合同正文附件目录
|
||||
if(!DobeDWUtils.isEmpty(fj_zwid)){
|
||||
//nasPath+fj_zwid;
|
||||
// AttachmentFileUtil.saveDirFile2Attchment(appId,entityName,contractid,nasPath+"/"+fj_zwid,zwattKey);
|
||||
filenames = resultjsonObject.getJSONArray("contract_fileNames");//合同正文文件名称清单
|
||||
if(filenames != null && !filenames.isEmpty()){
|
||||
AttachmentFileUtil.saveDirFile2Attchment(appId,entityName,contractid,nasPath+"/"+fj_zwid,zwattKey,filenames);
|
||||
}
|
||||
}
|
||||
//上传成功后更新合同未上传附件的标记为false
|
||||
if(upresult){
|
||||
DB.update(DBRoute.of("scm"), updatesql, new Object[]{contractid});
|
||||
//记录成功日志
|
||||
DobeDWUtils.saveLog(contractno,"NAS附件",nasPath,null,true,"NAS上传文件至星瀚");
|
||||
DobeDWUtils.saveLog(contractno,"NAS附件",null,null,true,"NAS上传文件至星瀚");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
//记录附件上传异常信息
|
||||
logger.info(contractno+" 从NAS上传文件至星瀚异常"+e.getMessage());
|
||||
|
|
|
@ -124,13 +124,6 @@ public class AttachmentFileUtil {
|
|||
*/
|
||||
public static boolean saveDirFile2Attchment(String appId, String entity, Object pk, String dirpath, String attachKey, JSONArray filenames) throws IOException {
|
||||
logger.info("传入的文件夹路径"+dirpath);
|
||||
filenames = new JSONArray();
|
||||
JSONObject f1 = new JSONObject();
|
||||
f1.put("filename","1.docx");
|
||||
filenames.add(f1);
|
||||
JSONObject f2 = new JSONObject();
|
||||
f2.put("filename","2.docx");
|
||||
filenames.add(f2);
|
||||
logger.info("传入的文件名称集合"+filenames);
|
||||
List<Map<String, Object>> attachments = new ArrayList<>(filenames.size());
|
||||
Map<String, Object> attachItem;
|
||||
|
@ -144,7 +137,7 @@ public class AttachmentFileUtil {
|
|||
//遍历目标目录,得到所有文件
|
||||
for (int i = 0; i < filenames.size(); i++) {
|
||||
destFile = filenames.getJSONObject(i);
|
||||
fileName = destFile.getString("filename");//TODO 文件名称可能涉及字符集转义,需要注意
|
||||
fileName = destFile.getString("fileName");//文件名称可能涉及字符集转义,需要注意
|
||||
attachItem = new HashMap<>();
|
||||
//文件名称
|
||||
attachItem.put("name", fileName);
|
||||
|
|
Loading…
Reference in New Issue