业务流程.工具.将所有流程数据还原到当前表

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

业务流程.工具.将所有流程数据还原到当前表

【逻辑】 (0)获取业务流程归档文件记录表的文件记录,还原 (1)还原完文件表的还原归档表 (2)还原完归档表的还原历史表 【代码】 ```python import clr clr.AddReference("mscorlib") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.ServiceHelper") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.App") clr.AddReference("Kingdee.BOS.App.Core") clr.AddReference("System.Data") clr.AddReference("System.Core") clr.AddReference("Kingdee.BOS.DataEntity") from Kingdee.BOS import * from Kingdee.BOS.KDThread import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.App.Core import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import * from Kingdee.BOS.Util import * from System import * from System.Collections.Generic import * from System.Data import * from Kingdee.BOS.DataEntity import * from System.Reflection import * def BarItemClick(e): if (e.BarItemKey.Equals("tbMoveFileToBackup", StringComparison.OrdinalIgnoreCase)): MainWorker.QuequeTask(this.View.Context, InnerExecute,None); if (e.BarItemKey.Equals("tbMoveFileToBackupTest", StringComparison.OrdinalIgnoreCase)): MoveAllToCurCustom202112(); def InnerExecute(): for idx in range(5000): MoveAllToCurCustom202112(); def MoveFileToBackCustom(): ##文件回到归档表 新版本 fileIds = HashSet[Int64](); sql = 'select top 50 FFileId from t_BF_ArchiveFiles'; ans = DBUtils.ExecuteDynamicObject(this.View.Context, sql); for idx in range(ans.Count): item = ans[idx]; fileIds.Add(Convert.ToInt64(item[0])); bfServiceType = TypesContainer.GetOrRegister("Kingdee.BOS.App.Core.BusinessFlow.Repositories.BFHisDataRepository,Kingdee.BOS.App.Core"); bfService = Activator.CreateInstance(bfServiceType,this.Context); flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; method = bfService.GetType().GetMethod("MoveArchiveFileToBack",flags); paramArray = Array.CreateInstance(object, 3); paramArray[0] = ''; paramArray[1] = None; paramArray[2] = fileIds; method.Invoke(bfService, paramArray); def MoveFileToBackCustom202112(): ##文件回到归档表 202112 fileIds = List[Int64](); sql = 'select top 50 td.ftablenumber,filelog.ftid from t_bf_instarchivelog filelog left join t_Bf_tabledefine td on filelog.fttableid = td.fseq order by filelog.fttableid'; ans = DBUtils.ExecuteDynamicObject(this.View.Context, sql); if(ans.Count <=0): return False; tableName = Convert.ToString(ans[0]['ftablenumber']); curTableName = ''; for idx in range(ans.Count): item = ans[idx]; curTableName = item['ftablenumber']; if(curTableName != tableName): break; fileIds.Add(Convert.ToInt64(item['ftid'])); if(fileIds.Count <= 0): return False; bfServiceType = TypesContainer.GetOrRegister("Kingdee.BOS.App.Core.BusinessFlow.Repositories.BFHisDataRepository,Kingdee.BOS.App.Core"); bfService = Activator.CreateInstance(bfServiceType,this.Context); flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; method = bfService.GetType().GetMethod("MoveArchiveFileToBack",flags); paramArray = Array.CreateInstance(object, 2); paramArray[0] = tableName; paramArray[1] = fileIds; method.Invoke(bfService, paramArray); return True; def MoveAllToCurCustom202112(): ##所有回到当前表 202112 if(MoveFileToCurCustom202112()): return; if(MoveBackUpToCurCustom202112()): return; if(MoveHisToCurCustom202112()): return; def MoveFileToCurCustom202112(): ##所有文件到当前表 202112 sql = 'select top 50 td.ftablenumber,filelog.ftid from t_bf_instarchivelog filelog left join t_Bf_tabledefine td on filelog.fttableid = td.fseq order by filelog.fttableid'; return MoveSqlToCurCustom202112(sql); def MoveBackUpToCurCustom202112(): ##所有归档表到当前表 202112 sql = 'select top 50 td.ftablenumber,node.ftid from t_bf_instentrybackup node left join t_Bf_tabledefine td on node.fttableid = td.fseq order by node.fttableid'; return MoveSqlToCurCustom202112(sql); def MoveHisToCurCustom202112(): ##所有归档表到当前表 202112 sql = 'select top 50 td.ftablenumber,node.ftid from t_bf_instanceentryhis node left join t_Bf_tabledefine td on node.fttableid = td.fseq order by node.fttableid'; return MoveSqlToCurCustom202112(sql); def MoveSqlToCurCustom202112(sql): ##sql 中关联 ftablenumber 和 ftid ,其中自行实现按照tableid 排序 ans = DBUtils.ExecuteDynamicObject(this.View.Context, sql); if(ans.Count <=0): return False; tableName = Convert.ToString(ans[0]['ftablenumber']); curTableName = ''; entityIds = List[Int64](); for idx in range(ans.Count): item = ans[idx]; curTableName = item['ftablenumber']; if(curTableName != tableName): break; entityIds.Add(Convert.ToInt64(item['ftid'])); if(entityIds.Count <= 0): return False; bfServiceType = TypesContainer.GetOrRegister("Kingdee.BOS.App.Core.BusinessFlow.Repositories.BFHisDataRepository,Kingdee.BOS.App.Core"); bfService = Activator.CreateInstance(bfServiceType,this.Context); flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public; method = bfService.GetType().GetMethod("MoveInstToCurrTable",flags); paramArray = Array.CreateInstance(object, 2); paramArray[0] = tableName; paramArray[1] = entityIds; method.Invoke(bfService, paramArray); return True; ``` 【效果】 ```sql select 't_bf_instanceentry' tablename, count(1) as cnt from t_bf_instanceentry union select 't_bf_instanceentryhis' tablename, count(1) as cnt from t_bf_instanceentryhis union select 't_bf_instentrybackup' tablename, count(1) as cnt from t_bf_instentrybackup union select 't_BF_ArchiveFiles' tablename, count(1) as cnt from t_BF_ArchiveFiles ``` 处理前 ![image.webp](/download/0100df86e4b38952427d9be8b3f1c8bc1df9.webp) 处理后 ![image.webp](/download/01009e4ca227797142e1a52a408d729f9758.webp)

业务流程.工具.将所有流程数据还原到当前表

【逻辑】(0)获取业务流程归档文件记录表的文件记录,还原(1)还原完文件表的还原归档表(2)还原完归档表的还原历史表【代码】```pythonimport...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息