|
@@ -12,19 +12,68 @@ namespace DataTransmission.Joint
|
|
|
{
|
|
|
private readonly CommonTool tool = new CommonTool();
|
|
|
|
|
|
- public DataTable GetWorkflow(string OldOrderId) {
|
|
|
+ public DataTable GetWorkflow(string OldOrderId,string StoreCode) {
|
|
|
var conn = tool.GetConSqlServer();
|
|
|
- var orderSql = $"SELECT * FROM Flow_Transfer01_RunBackups WHERE FTRB_FlowID ='{OldOrderId}' ORDER BY FTRB_MoveDate ";
|
|
|
+ var orderSql = $@"SELECT * FROM Flow_Transfer01_RunBackups FTR
|
|
|
+ LEFT JOIN Flow_Set01_Store FSS ON FTR.FTRB_StoreID = FSS.FSL_StoreID
|
|
|
+ LEFT JOIN Flow03_Search FS ON FTR.FTRB_FlowID = FS.FSH_FlowID
|
|
|
+ WHERE FTRB_FlowID ='{OldOrderId}' AND FSS.FSL_Code ='{StoreCode}' ORDER BY FTRB_MoveDate ";
|
|
|
return tool.GetDataTable(orderSql, conn);
|
|
|
}
|
|
|
|
|
|
- public string GetWorkflowSql(DataTable data, DataTable org, DataTable user)
|
|
|
+ public string GetWorkflowSql(DataTable data, DataRow row, string orderId, DataTable org, DataTable user, DataRow module)
|
|
|
{
|
|
|
var pgSql = string.Empty;
|
|
|
|
|
|
var workflow = new Entity.Workflow();
|
|
|
-
|
|
|
workflow.InitId();
|
|
|
+ workflow.DefinitionId = module["DefinitionId"].ToString();
|
|
|
+ workflow.ModuleId = module["Id"].ToString();
|
|
|
+ workflow.ModuleCode = module["Code"].ToString();
|
|
|
+ workflow.ModuleName = module["Name"].ToString();
|
|
|
+ workflow.Title = row["FSH_Title_ys"].ToString();
|
|
|
+ var stStep = data.AsEnumerable().OrderBy(x => x.Field<int?>("FTRB_RunID")).FirstOrDefault();
|
|
|
+ var endStep = data.AsEnumerable().OrderByDescending(x=>x.Field<int?>("FTRB_RunID")).FirstOrDefault(x=> x.Field<string>("FTRB_ItemName").ToString() == "结束");
|
|
|
+ var actualStep = data.AsEnumerable().FirstOrDefault(x => x.Field<int?>("FSH_AcceptBMID").ToString() == x.Field<int?>("FTRB_APBMID").ToString());
|
|
|
+ if (row["FSH_AcceptBMID"].ToString() == Form1.CenterId)
|
|
|
+ {
|
|
|
+ actualStep = data.AsEnumerable().FirstOrDefault(x => x.Field<DateTime>("FSH_AcceptDate").ToString() == x.Field<DateTime>("FTRB_APDate").ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //Creator
|
|
|
+ var creator = user.AsEnumerable().FirstOrDefault(x => x.Field<int?>("oldUserId").ToString() == stStep["FTRB_MoveUserID"].ToString());
|
|
|
+ var creatorOrg = org.AsEnumerable().FirstOrDefault(x => x.Field<int?>("oldBmid").ToString() == creator["OrgId"].ToString());
|
|
|
+
|
|
|
+ workflow.EndTime = DateTime.Parse(endStep["FTRB_DisposeDate"].ToString());
|
|
|
+ workflow.ActualHandleStepCode = "";
|
|
|
+ workflow.ActualHandleStepName = "";
|
|
|
+ workflow.ActualHandleStepId = actualStep["FSH_RunID"].ToString();
|
|
|
+ workflow.ActualOpinion = actualStep["FTRB_RRemark"].ToString();
|
|
|
+ workflow.ExternalId = row["FSH_FlowID"].ToString();
|
|
|
+ workflow.CreationTime = DateTime.Parse(stStep["FSH_AddDate"].ToString());
|
|
|
+ if (creator != null)
|
|
|
+ {
|
|
|
+ workflow.CreatorId = creator["Id"].ToString();
|
|
|
+ workflow.CreatorName = creator["Name"].ToString();
|
|
|
+ }
|
|
|
+ if (creatorOrg != null)
|
|
|
+ {
|
|
|
+ workflow.CreatorOrgId = creatorOrg["Id"].ToString();
|
|
|
+ workflow.CreatorOrgName = creatorOrg["Name"].ToString();
|
|
|
+ workflow.CreatorOrgLevel = int.Parse(creatorOrg["Level"].ToString());
|
|
|
+ workflow.AreaId = creatorOrg["AreaId"].ToString();
|
|
|
+ //workflow.AssignerOrgIsCenter = bool.Parse(creatorOrg["IsCenter"].ToString());
|
|
|
+ }
|
|
|
+ if (workflow.ModuleCode == "OrderHandle")
|
|
|
+ {
|
|
|
+ workflow.FlowType = EFlowType.Handle;
|
|
|
+ workflow.ReviewResult = EReviewResult.Unknown;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ workflow.FlowType = EFlowType.Handle;
|
|
|
+ workflow.ReviewResult = EReviewResult.Approval;
|
|
|
+ }
|
|
|
+
|
|
|
var order = 1;
|
|
|
foreach (DataRow item in data.Rows) {
|
|
|
|
|
@@ -35,20 +84,28 @@ namespace DataTransmission.Joint
|
|
|
order++;
|
|
|
}
|
|
|
|
|
|
- var sql = $@"INSERT INTO ""public"".""workflow"" (""Id"", ""DefinitionId"", ""ModuleId"", ""ModuleName"", ""ModuleCode"", ""Title"", ""EndTime"", ""Status"", ""ActualHandleStepCode"",
|
|
|
- ""ActualHandleStepName"", ""ActualHandleStepId"", ""ActualHandleStepCreateTime"", ""ActualHandleStepAcceptTime"", ""ActualHandleTime"", ""ActualHandlerId"", ""ActualHandlerName"", ""ActualHandleOrgName"",
|
|
|
- ""ActualHandleOrgCode"", ""ActualHandleOrgAreaCode"", ""ActualHandleOrgAreaName"", ""ActualOpinion"", ""CounterSignType"", ""TopCountersignStepId"", ""IsInCountersign"", ""AllDuration"", ""ExternalId"",
|
|
|
- ""HandlerUsers"", ""HandlerOrgs"", ""FlowedOrgIds"", ""FlowedUserIds"", ""OrgLevelOneCode"", ""OrgLevelOneName"", ""AcceptorId"", ""AcceptorName"", ""AcceptorStaffNo"", ""AcceptorOrgId"", ""AcceptorOrgName"",
|
|
|
- ""AcceptorOrgAreaCode"", ""AcceptorOrgAreaName"", ""CreationTime"", ""CreatorId"", ""CreatorName"", ""CreatorOrgId"", ""CreatorOrgName"", ""CreatorOrgLevel"", ""AreaId"", ""FlowType"", ""ReviewResult"",
|
|
|
- ""CsActualHandleOrgIds"", ""CsActualHandleUserIds"", ""CurrentStepId"", ""CurrentStepCode"", ""CurrentStepName"", ""CurrentStepCreateTime"", ""CurrentStepAcceptTime"", ""CurrentHandleTime"", ""CurrentHandlerId"",
|
|
|
- ""CurrentHandlerName"", ""CurrentHandleOrgName"", ""CurrentHandleOrgId"", ""CurrentHandleOrgLevel"", ""CurrentHandleOrgAreaCode"", ""CurrentHandleOrgAreaName"", ""ActualHandleOrgLevel"")
|
|
|
- VALUES ('08dc3f2e-dfa2-4595-8925-c44b46a12f53', '08dc3db4-6ae4-475a-82a7-07243b2810a9', '08db8db3-eea4-4737-88dd-6c7b990c7705', '工单办理', 'OrderHandle', '0308业务汇聚测试工单1', NULL, 0, 'e64f6d91-fd6b-4301-90d1-7c0919945a3b', '一级部门', '08dc3f2e-f972-4f1a-826b-1749dc4796d6', '2024-03-08 13:16:56.5873', '2024-03-08 13:19:16.447054', '2024-03-08 13:19:40.065188', '08dbe4d7-3b8b-439f-87bc-5be05210a26e', '一级部门测试1', '测试一级部门', '001092', '511500', '四川省宜宾市', '办理中...', NULL, NULL, 'f', '0', '08dc3f2e-df85-418a-8a40-41f496056f58', '[]', '[{{""GroupId"":""08aa711f-4377-4e22-86a6-25dd50a07703"",""Key"":""001092001"",""Value"":""测试二级部门1""}}]', '[""001"",""001092"",""001092001""]', '[""08dc0121-5960-4267-817c-b6dc6c068fa4"",""08dc05b4-1aa6-4b50-84f2-472609d44314""]', '001092', '测试一级部门', '08dc0121-5960-4267-817c-b6dc6c068fa4', '坐席5', '', '001', '市民热线服务系统', NULL, NULL, '2024-03-08 13:16:13.277208', '08dc0121-5960-4267-817c-b6dc6c068fa4', '坐席5', '001', '市民热线服务系统', 1, '001', 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
|
|
|
+ var sql = $@"INSERT INTO ""public"".""workflow"" (""Id"", ""DefinitionId"", ""ModuleId"", ""ModuleName"", ""ModuleCode"", ""Title"", ""Status"",
|
|
|
+ ""ActualOpinion"", ""IsInCountersign"", ""AllDuration"", ""ExternalId"", ""HandlerUsers"", ""HandlerOrgs"", ""FlowedOrgIds"", ""FlowedUserIds"", ""CreationTime"",
|
|
|
+ ""CreatorId"", ""CreatorName"", ""CreatorOrgId"", ""CreatorOrgName"", ""CreatorOrgLevel"", ""AreaId"", ""FlowType"", ""ReviewResult"")
|
|
|
+ VALUES ('{workflow.Id}', '{workflow.DefinitionId}', '{workflow.ModuleId}', '{workflow.ModuleName}', '{workflow.ModuleCode}', '{workflow.Title}', 20,
|
|
|
+ '{workflow.ActualOpinion}', 'f', '0', '{workflow.ExternalId}', '[]', '[]', '[]', '[]', '{workflow.CreationTime.ToString()}',
|
|
|
+ '{workflow.CreatorId}', '{workflow.CreatorName}', '{workflow.CreatorOrgId}', '{workflow.CreatorOrgName}', {workflow.CreatorOrgLevel}, '{workflow.AreaId}', {(int)workflow.FlowType}, {(int)workflow.ReviewResult});";
|
|
|
|
|
|
|
|
|
return pgSql;
|
|
|
}
|
|
|
|
|
|
- public string GetWorkflowStepSql(DataRow item, DataTable org, DataTable user,bool start,bool end, ref Entity.Workflow workflow) {
|
|
|
+ /// <summary>
|
|
|
+ /// 生成流程
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="item"></param>
|
|
|
+ /// <param name="org"></param>
|
|
|
+ /// <param name="user"></param>
|
|
|
+ /// <param name="start"></param>
|
|
|
+ /// <param name="end"></param>
|
|
|
+ /// <param name="workflow"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private string GetWorkflowStepSql(DataRow item, DataTable org, DataTable user,bool start,bool end, ref Entity.Workflow workflow) {
|
|
|
|
|
|
//Acceptor
|
|
|
var acceptor = user.AsEnumerable().FirstOrDefault(x => x.Field<int?>("oldUserId").ToString() == item["FTRB_APUserID"].ToString());
|
|
@@ -106,8 +163,8 @@ namespace DataTransmission.Joint
|
|
|
step.CreatorId = item["FTRB_MoveUserID"].ToString();
|
|
|
if (creator != null )
|
|
|
{
|
|
|
- step.CreatorId = acceptor["Id"].ToString();
|
|
|
- step.CreatorName = acceptor["Name"].ToString();
|
|
|
+ step.CreatorId = creator["Id"].ToString();
|
|
|
+ step.CreatorName = creator["Name"].ToString();
|
|
|
}
|
|
|
if (creatorOrg != null)
|
|
|
{
|
|
@@ -118,7 +175,7 @@ namespace DataTransmission.Joint
|
|
|
step.AssignerOrgIsCenter = bool.Parse(creatorOrg["IsCenter"].ToString());
|
|
|
}
|
|
|
|
|
|
- step.ExternalId = item["FTRB_FlowID"].ToString();
|
|
|
+ step.ExternalId = workflow.ExternalId;
|
|
|
|
|
|
var stepSql = $@"INSERT INTO ""public"".""workflow_step"" (
|
|
|
""Id"", ""NextSteps"", ""PrevStepId"", ""PrevStepCode"", ""IsMain"", ""Status"", ""IsOrigin"", ""CountersignId"",""CountersignPosition"",
|
|
@@ -140,7 +197,18 @@ namespace DataTransmission.Joint
|
|
|
return stepSql + traceSql;
|
|
|
}
|
|
|
|
|
|
- public string GetWorkflowTraceSql(DataRow item, Entity.WorkflowStep step , DataTable org, DataTable user, bool start, bool end, ref Entity.Workflow workflow)
|
|
|
+ /// <summary>
|
|
|
+ /// 生成快照
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="item"></param>
|
|
|
+ /// <param name="step"></param>
|
|
|
+ /// <param name="org"></param>
|
|
|
+ /// <param name="user"></param>
|
|
|
+ /// <param name="start"></param>
|
|
|
+ /// <param name="end"></param>
|
|
|
+ /// <param name="workflow"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private string GetWorkflowTraceSql(DataRow item, Entity.WorkflowStep step , DataTable org, DataTable user, bool start, bool end, ref Entity.Workflow workflow)
|
|
|
{
|
|
|
var trace = new Entity.WorkflowTrace();
|
|
|
trace.InitId();
|