feat: integrate native BPM task processing and strict Excel test rules
This commit is contained in:
commit
8cb6a32876
444 files changed
+17045
-3182
No files matched your search
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
const crypto=require('node:crypto');
|
||||
const {loadPlaywright,browserOptions}=require('./runtime.cjs');
|
||||
const {isLoginRedirect}=require('./modules/bpm/auth-redirect.cjs');
|
||||
const ORIGIN='https://bpm.skyworthdigital.com';
|
||||
const MAX_BYTES=12_000_000;
|
||||
const fail=(message,status=409)=>{throw Object.assign(new Error(message),{status});};
|
||||
@@ -23,11 +24,11 @@ async function loadForm(request,entry,{timeout=20000}={}){
|
||||
let response;try{response=await request.get(current.url.href,{maxRedirects:0,timeout});}catch{fail('BPM 只读表单连接失败。',502);}
|
||||
const status=response.status();
|
||||
if([301,302,303,307,308].includes(status)){
|
||||
const location=response.headers().location;if(!location)fail('BPM 表单跳转缺少目标。',403);let next;try{next=new URL(location,current.url);}catch{fail('BPM 表单跳转目标无效。',403);}
|
||||
const location=response.headers().location;if(isLoginRedirect(location||'',current.url.href))fail('BPM 表单会话需要续登。',401);if(!location)fail('BPM 表单跳转缺少目标。',403);let next;try{next=new URL(location,current.url);}catch{fail('BPM 表单跳转目标无效。',403);}
|
||||
if(current.kind==='sso')current=processURL(next.href);else if(current.kind==='process')current=finalURL(next.href);else fail('BPM 最终表单不允许再次跳转。',403);
|
||||
if(current.tid!==start.tid||current.pid!==start.pid)fail('BPM 表单跳转的 tid/pid 与原始任务冲突。',403);continue;
|
||||
}
|
||||
if(status!==200)fail([401,403].includes(status)?'BPM 表单会话已失效。':'BPM 只读表单查询失败。',[401,403].includes(status)?401:502);
|
||||
if(status!==200)fail(status===401?'BPM 表单会话已失效。':status===403?'BPM 表单没有读取权限。':'BPM 只读表单查询失败。',[401,403].includes(status)?status:502);
|
||||
if(current.kind!=='form')fail('BPM 未到达已核验的最终表单。',403);
|
||||
const bytes=await response.body();if(bytes.length>MAX_BYTES)fail('BPM 表单响应超过采集上限。');
|
||||
return {url:current.url,bytes,identity:{tid:current.tid,pid:current.pid,processName:current.processName,processVersion:current.processVersion}};
|
||||
@@ -38,7 +39,7 @@ async function loadData(request,value,{timeout=20000}={}){
|
||||
const identity=finalURL(value instanceof URL?value.href:value);
|
||||
const xml='<?xml version="1.0"?><Requests><Params><Method>GetFormProcessData</Method><PID>'+identity.pid+'</PID></Params></Requests>';
|
||||
let response;try{response=await request.post(ORIGIN+'/YZSoft/BPM/XMLService/DataProvider.ashx',{data:xml,headers:{'Content-Type':'text/xml'},maxRedirects:0,timeout});}catch{fail('BPM 表单字段只读请求失败。',502);}
|
||||
const status=response.status();if([301,302,303,307,308,401,403].includes(status))fail('BPM 表单数据会话失效,需要重新核验连接。',401);if(status!==200)fail('BPM 表单字段读取失败。',502);
|
||||
const status=response.status();if(status===401||[301,302,303,307,308].includes(status)&&isLoginRedirect(response.headers().location||'',ORIGIN))fail('BPM 表单数据会话失效,需要重新核验连接。',401);if(status===403)fail('BPM 表单字段没有读取权限。',403);if(status!==200)fail('BPM 表单字段读取失败。',502);
|
||||
const bytes=await response.body();if(bytes.length>MAX_BYTES)fail('BPM 表单字段响应超过采集上限。');let data;try{data=JSON.parse(bytes.toString('utf8'));}catch{fail('BPM 表单字段响应不是有效数据。',502);}
|
||||
if(data?.success!==true||!Array.isArray(data.Tables)||data.Tables.length>200||data.Tables.some(table=>!table||typeof table.TableName!=='string'||!table.TableName||table.TableName.length>200||!Array.isArray(table.Rows)||table.Rows.length>4000||table.Rows.some(row=>!row||typeof row!=='object'||Array.isArray(row))))fail('BPM 表单字段数据不完整或未通过权限检查。',502);
|
||||
return data.Tables.filter(table=>table.FormTable===true);
|
||||
|
||||
Reference in new issue
Block a user