下面是我生成流程的代码
---------------------------------------------------------------------------------------------------------
static procedure TTZTX.saveGZTX(Context :TContext; Const dw,zt,nr,cbnbid,cmnbid :String);
var
FQuery: Business.Data.TQuery;
busiDataID, displayNUM :String;
tpf : TTaskPubFunc;
AFuncURL, ATaskTypeName, ATaskTypeID, ASubject, ABizField, ABizFieldValue,
ADept, APosition, APerson : string;
j :Integer;
lBizUrl: TBizUrl;
tjr,tjjs : string;
olist:Business.Model.Org.TOrgURLs;
begin
if (length(dw) = 0) OR (length(zt) = 0) OR (length(nr) = 0) then
begin
exit;
end;
FQuery := Business.Data.TQuery.Create(nil);
FQuery.ConnectionString := Format('DataBaseURL=%s', ['Biz:\CBCM\CBCMSJK.Database']);
tpf := TTaskPubFunc.Create(Context);
olist:= Business.Model.Org.TOrgURLs.Create;
orgSys.OrgSystem.GetOrgURLsByOrgExpr('OrgChildren(OrgKey(''' + dw + ''', ''YWY'', ''''), '''', True, False)',olist);
try
for j := 0 to olist.Count - 1 do
begin
lBizURL := olist[j].BizURL;
tjr := TPerson(OrgSys.OrgSystem.FindUnit(lBizURL)).ID;
tjjs := TPerson(OrgSys.OrgSystem.FindUnit(lBizURL)).Parent.ID;
with FQuery do
begin
Close;
CommandText := 'INSERT INTO TBUSINESSDATA (FID,FHURRY,FIMPORTANCE,FTOPIC,FPOSTDETAIL,FPOSTDEPT,FPOSTPTM,FPOSTER,FPOSTDEPTNAME,FPOSTPTMNAME,FPOSTERNAME,FDEALDEPT,FDEALPTM,FDEALMAN,FDEALDEPTNAME,FDEALPTMNAME,FDEALMANNAME,FPOSTDATE,FDEALSTATE,FRELATIONNUM,FDISPLAYNUM,CBNBID,CMNBID) VALUES (:FID,:FHURRY,:FIMPORTANCE,:FTOPIC,:FPOSTDETAIL,:FPOSTDEPT,:FPOSTPTM,:FPOSTER,:FPOSTDEPTNAME,:FPOSTPTMNAME,:FPOSTERNAME,:FDEALDEPT,:FDEALPTM,:FDEALMAN,:FDEALDEPTNAME,:FDEALPTMNAME,:FDEALMANNAME,:FPOSTDATE,:FDEALSTATE,:FRELATIONNUM,:FDISPLAYNUM,:CBNBID,:CMNBID)';
busiDataID := TCommonEnv.getGUID;
Params.ParamByName('FID').AsString := busiDataID ;
Params.ParamByName('FHURRY').AsString := '01' ;
Params.ParamByName('FIMPORTANCE').AsString := '02';
Params.ParamByName('FTOPIC').AsString := zt;
Params.ParamByName('FPOSTDETAIL').AsBlob := nr;
Params.ParamByName('FPOSTDEPT').AsString := TCommonEnv.getYHSSDW;
Params.ParamByName('FPOSTPTM').AsString := TCommonEnv.getYHJSID;
Params.ParamByName('FPOSTER').AsString := TCommonEnv.getYHID;
Params.ParamByName('FPOSTDEPTNAME').AsString := TCommonEnv.getYHSSDWMC;
Params.ParamByName('FPOSTPTMNAME').AsString := TCommonEnv.getYHJSMC;
Params.ParamByName('FPOSTERNAME').AsString := TCommonEnv.getYHXM;
Params.ParamByName('FDealDept').AsString := dw;
Params.ParamByName('FDealPtm').AsString := tjjs;
Params.ParamByName('FDealMan').AsString := tjr;
Params.ParamByName('FDealDEPTNAME').AsString := TCommonEnv.getDeptName(dw);
Params.ParamByName('FDealPTMNAME').AsString := TCommonEnv.getPositionName(tjjs);
Params.ParamByName('FDealManNAME').AsString := TCommonEnv.getPersonName(tjr);
Params.ParamByName('FPOSTDATE').AsDateTime := SysSrv.SysService.Time;
Params.ParamByName('FDEALSTATE').AsString := '01';
Params.ParamByName('FRELATIONNUM').AsString := '-1';
displayNUM := TCommonUtils.GetAutoIncreaseID(Context,'Code', '编号');
displayNUM := TCommonUtils.StrToRightLenStr(Variants.VarToStr(displayNUM), '0', 10);
Params.ParamByName('FDISPLAYNUM').AsString := displayNUM;
Params.ParamByName('CBNBID').AsString := cbnbid;
Params.ParamByName('CMNBID').AsString := cmnbid;
Execute;
end;
AFuncURL := 'Biz:\CBCM\CBCMGZTXCL.FUNC'; // 自定义任务关联功能
ATaskTypeName := '船舶船民工作提醒'; // 自定义任务关联的任务名称
ATaskTypeID := 'CBCMTX'; // 自定义任务关联的任务ID
ABizField := 'Biz:\CBCM\CBCMSJK.DATABASE\TBUSINESSDATA.TABLE\FID.Field'; // 关联字段
ASubject := zt; // 主题
ABizFieldValue := busiDataID ; // 关联字段主键
ADept := dw; // 接收部门
APosition := tjjs; // 接收岗位
APerson := tjr; // 接收人
tpf.UserStartTask(AFuncURL, ATaskTypeName, ATaskTypeID, ASubject, ABizField,
ABizFieldValue, ADept, APosition, APerson);
jsDialogs.ShowMsg('启动 ' + ASubject + ' 成功', '启动无流程任务');
end;
finally
tpf.Free;
FQuery.Free;
end;
end; |