归档数据
|
|
|
|
|
|
|
|
|
|
|
|
智能归档
|
|
|
|
|
|
|
|
|
|
|
|
var filelist=JSON.parse(input.filelist?input.filelist:'[]'); //正则匹配文件名 var backgroundImageRegex=/(?<=attname=).+(?=&e)/; var arr=[]; var file_path=""; for( var key in filelist){ var ming={}; ming.url=filelist[key]; file_path=decodeURI(filelist[key].match(backgroundImageRegex)) ming.name=file_path.replace(/(.*\/)*([^.]+).*/ig,"$2"); arr.push(ming); } output={arr:arr}
var fetch=require('node-fetch'); var data= await fetch(input.imgurl).then(r => r.buffer()).then(buf => buf.toString('base64')); output={data:data}
const fetch = require('node-fetch'); // 智能归档信息 var rowId=input.rowId; var appKey="a711ac208151a185"; var sign="ZjlkMTM0NjIwZjM0ZDFlYzg4NDBiZWM2M2QwZTQ4YzVjMDdjMWFhYTUyNjU1YzAxMjI1MjAwYTE5ZDMwMmY0Mg=="; var worksheetId="zngd"; var url='https://api.mingdao.com/v2/open/worksheet/getRowByIdPost'; var data={ "appKey": appKey, "sign": sign, "worksheetId": worksheetId, "rowId": rowId }; var token={}; var wei=[]; var yi=[]; const res = await fetch(url,{ method:"post", headers:{ 'Content-Type':'application/json; charset=UTF-8', 'Authorization':token }, body:JSON.stringify(data) }).then(function(response){ if(response.ok){ return response.json(); }else{ return {"error":"无数据"}; } }).catch(function(err){ return {"error":"Fetch错误:"+err}; }); var result = await res; var fujian= JSON.parse(result.data["gdwj"]); // 法律文本数据 var url_hetong='https://api.mingdao.com/v2/open/worksheet/getFilterRows'; var result_hetong={}; var data_hetong={}; var token_hetong=''; // 更改数据链接 var url_hetong_edit="https://api.mingdao.com/v2/open/worksheet/editRow"; var data_hetong_edit={}; var fileBase64=""; for (let index = 0; index < fujian.length; index++) { const element = fujian[index]; //将附件 fileBase64= await fetch(element['DownloadUrl']).then(r => r.buffer()).then(buf => buf.toString('base64')); // 获取法律文本 data_hetong={ "appKey": appKey, "sign": sign, "worksheetId": "dgdsj", "pageSize": "100", "pageIndex": "1", "viewId":"", "filters":[ { "controlId": "zdbh", "dataType": 33, "spliceType": 2, "filterType": 2, "value": element['file_name'].replace(/(.*\/)*([^.]+).*/ig,"$2") } ] }; const res_hetong = await fetch(url_hetong,{ method:"post", headers:{ 'Content-Type':'application/json; charset=UTF-8', 'Authorization':token_hetong }, body:JSON.stringify(data_hetong) }).then(function(response){ if(response.ok){ return response.json(); }else{ return {"error":"无数据"}; } }).catch(function(err){ return {"error":"Fetch错误:"+err}; }); result_hetong = await res_hetong; if(result_hetong.data.total==0){ wei.push(element['file_name']); continue; } yi.push(element['file_name']); // 修改数据 data_hetong_edit={ "appKey": appKey, "sign": sign, "worksheetId": "dgdsj", "rowId": result_hetong["data"]["rows"][0]["rowid"], "controls": [ { "controlId": "fujian", "editType": "1", "valueType": "2", "controlFiles": [ { "baseFile": fileBase64, "fileName": element['file_name'] } ] } ], "triggerWorkflow": true }; const res_hetong_edit = await fetch(url_hetong_edit,{ method:"post", headers:{ 'Content-Type':'application/json; charset=UTF-8', 'Authorization':token_hetong }, body:JSON.stringify(data_hetong_edit) }).then(function(response){ if(response.ok){ return response.json(); }else{ return {"error":"无数据"}; } }).catch(function(err){ return {"error":"Fetch错误:"+err}; }); } var guidangString=""; if(wei.length>0){ guidangString="未匹配到归档文件:"+wei.toString(); } if(wei.length>0&&yi.length>0){ guidangString+=","; } if(yi.length>0){ guidangString+="已匹配到归档文件:"+yi.toString(); } output = {output:guidangString };