diff --git a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md index 164d4dc1..a9f3008c 100644 --- a/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md +++ b/SanPinPLM/相关操作/4.0-other/999.Delphi脚本记录.md @@ -896,3 +896,42 @@ begin end. ``` +## 执行流程归档文件 + +将过程设置为普通过程,在提交后的事件里写入归档文件脚本,实现该过程提交后,文件归档的操作 + +```delphi +uses + Classes, SHostIntf, ThreadContextMan, IntfKernel, EntClas, CommonFunc, DataConst, DBIntf, + Data.Win.ADODB, Data.DB, SysUtils; + +var + strSql: string; // 声明SQL命令字符串变量 + iWFId: integer; // 声明工作流ID整型变量 + CurBizObj: TEntClas; // 声明当前业务对象变量 +begin + // 获取当前线程的业务对象实例 + CurBizObj := shiCurBizObj; + + // 如果当前业务对象不存在则退出程序 + if CurBizObj = nil then + exit; + + // 从业务对象中获取WFId字段的整数值 + iWFId := CurBizObj.I['WFId']; + + // 构建SQL更新语句: + // 1. 将cfdoc表中符合条件记录的stat字段更新为4(归档状态) + // 2. 同时更新archivedtime字段为当前时间 + // 3. 通过关联cfwfobj表确定需要更新的记录(要求wfid匹配且objtypeid=10) + strSql := Format( + 'update cfdoc set stat = 4, archivedtime = ''%s'' ' + + 'from cfwfobj a, cfdoc b ' + + 'where a.wfid = %d and a.objtypeid = 10 and a.objid = b.docid', + [GetCurTimeStr, iWFId] // 参数1:当前时间字符串,参数2:工作流ID + ); + + // 执行生成的SQL语句 + shiExeSql(strSql); +end. +``` \ No newline at end of file