|
|
@@ -1,5 +1,6 @@
|
|
|
using System.Diagnostics;
|
|
|
using System.Text.Json;
|
|
|
+using Admin.NET.Plugin.AiDOP.Entity;
|
|
|
using Admin.NET.Plugin.AiDOP.MaterialWarehouse;
|
|
|
using Admin.NET.Plugin.ApprovalFlow;
|
|
|
using Admin.NET.Plugin.ApprovalFlow.Service;
|
|
|
@@ -25,6 +26,8 @@ public static class IqcInspBillFlowSeed
|
|
|
typeof(ApprovalBizType),
|
|
|
typeof(ApprovalFlowEntity),
|
|
|
typeof(ApprovalFlowVersion));
|
|
|
+ // D' SQE 处置表(CodeFirst 建表,无 SQL)
|
|
|
+ db.CodeFirst.InitTables(typeof(AdoS5IqcSqeDisposition));
|
|
|
EnsureRoles(db);
|
|
|
EnsureUatMembers(db);
|
|
|
EnsureBizType(db);
|
|
|
@@ -40,6 +43,7 @@ public static class IqcInspBillFlowSeed
|
|
|
{
|
|
|
EnsureRole(db, IqcInspBillFlowConst.RoleInspectorId, IqcInspBillFlowConst.RoleInspectorCode, "来料检验员", 810);
|
|
|
EnsureRole(db, IqcInspBillFlowConst.RoleSupervisorId, IqcInspBillFlowConst.RoleSupervisorCode, "来料检验主管", 811);
|
|
|
+ EnsureRole(db, IqcInspBillFlowConst.RoleSqeId, IqcInspBillFlowConst.RoleSqeCode, "来料检验SQE", 812);
|
|
|
}
|
|
|
|
|
|
private static void EnsureRole(ISqlSugarClient db, long id, string code, string name, int orderNo)
|
|
|
@@ -72,6 +76,7 @@ public static class IqcInspBillFlowSeed
|
|
|
}
|
|
|
EnsureUserRole(db, user.Id, IqcInspBillFlowConst.RoleInspectorId);
|
|
|
EnsureUserRole(db, user.Id, IqcInspBillFlowConst.RoleSupervisorId);
|
|
|
+ EnsureUserRole(db, user.Id, IqcInspBillFlowConst.RoleSqeId);
|
|
|
}
|
|
|
|
|
|
private static void EnsureUserRole(ISqlSugarClient db, long userId, long roleId)
|
|
|
@@ -120,8 +125,22 @@ public static class IqcInspBillFlowSeed
|
|
|
.Where(x => x.BizType == IqcInspBillFlowConst.BizType && x.OrgId == orgId && x.IsPublished && !x.IsDelete)
|
|
|
.OrderByDescending(x => x.Version)
|
|
|
.First();
|
|
|
- if (existing != null) continue;
|
|
|
|
|
|
+ // v1→v2 幂等升级:已发布定义若已含 N3_SQE(v2)则跳过;若仍为 v1(无 N3)则下架旧版、发布 v2。
|
|
|
+ // 历史 Running/Approved 实例使用各自 FlowJsonSnapshot,不受本次 republish 影响。
|
|
|
+ if (existing != null)
|
|
|
+ {
|
|
|
+ var isV2 = (existing.FlowJson ?? "").Contains(IqcInspBillFlowConst.NodeSqe)
|
|
|
+ && (existing.FlowJson ?? "").Contains(IqcInspBillFlowConst.GatewayPd);
|
|
|
+ if (isV2) continue;
|
|
|
+ db.Updateable<ApprovalFlowEntity>()
|
|
|
+ .SetColumns(x => x.IsPublished == false)
|
|
|
+ .SetColumns(x => x.UpdateTime == now)
|
|
|
+ .Where(x => x.Id == existing.Id)
|
|
|
+ .ExecuteCommand();
|
|
|
+ }
|
|
|
+
|
|
|
+ var nextVersion = (existing?.Version ?? 0) + 1;
|
|
|
var flow = new ApprovalFlowEntity
|
|
|
{
|
|
|
Id = YitIdHelper.NextId(),
|
|
|
@@ -131,8 +150,8 @@ public static class IqcInspBillFlowSeed
|
|
|
FormJson = "{}",
|
|
|
FlowJson = flowJson,
|
|
|
Status = 1,
|
|
|
- Remark = "系统默认流程:开始-检验员检验-检验主管审核-结束",
|
|
|
- Version = 1,
|
|
|
+ Remark = "系统默认流程 v2:开始-检验员检验-检验主管审核-网关(pd)-SQE处置-结束",
|
|
|
+ Version = nextVersion,
|
|
|
IsPublished = true,
|
|
|
OrgId = orgId,
|
|
|
CreateTime = now,
|
|
|
@@ -202,20 +221,67 @@ public static class IqcInspBillFlowSeed
|
|
|
Text = new FlowTextItem { X = 500, Y = 154, Value = "检验主管审核" },
|
|
|
},
|
|
|
new()
|
|
|
+ {
|
|
|
+ Id = IqcInspBillFlowConst.GatewayPd,
|
|
|
+ Type = "bpmn:exclusiveGateway",
|
|
|
+ X = 660,
|
|
|
+ Y = 120,
|
|
|
+ Properties = new FlowProperties
|
|
|
+ {
|
|
|
+ NodeName = "判定分流",
|
|
|
+ Conditions = new List<GatewayCondition>
|
|
|
+ {
|
|
|
+ new()
|
|
|
+ {
|
|
|
+ Expression = "pd == 1",
|
|
|
+ TargetNodeId = IqcInspBillFlowConst.NodeSqe,
|
|
|
+ IsDefault = false,
|
|
|
+ Label = "不合格转SQE",
|
|
|
+ },
|
|
|
+ new()
|
|
|
+ {
|
|
|
+ TargetNodeId = "end",
|
|
|
+ IsDefault = true,
|
|
|
+ Label = "合格完成",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Text = new FlowTextItem { X = 660, Y = 154, Value = "判定分流" },
|
|
|
+ },
|
|
|
+ new()
|
|
|
+ {
|
|
|
+ Id = IqcInspBillFlowConst.NodeSqe,
|
|
|
+ Type = "bpmn:userTask",
|
|
|
+ X = 820,
|
|
|
+ Y = 120,
|
|
|
+ Properties = new FlowProperties
|
|
|
+ {
|
|
|
+ NodeName = "SQE处置",
|
|
|
+ ApproverType = nameof(ApproverTypeEnum.Role),
|
|
|
+ ApproverIds = IqcInspBillFlowConst.RoleSqeId.ToString(),
|
|
|
+ ApproverNames = "来料检验SQE",
|
|
|
+ MultiApproveMode = "Any",
|
|
|
+ },
|
|
|
+ Text = new FlowTextItem { X = 820, Y = 154, Value = "SQE处置" },
|
|
|
+ },
|
|
|
+ new()
|
|
|
{
|
|
|
Id = "end",
|
|
|
Type = "bpmn:endEvent",
|
|
|
- X = 700,
|
|
|
+ X = 980,
|
|
|
Y = 120,
|
|
|
Properties = new FlowProperties { NodeName = "结束" },
|
|
|
- Text = new FlowTextItem { X = 700, Y = 154, Value = "结束" },
|
|
|
+ Text = new FlowTextItem { X = 980, Y = 154, Value = "结束" },
|
|
|
},
|
|
|
},
|
|
|
Edges = new List<ApprovalFlowEdgeItem>
|
|
|
{
|
|
|
BuildEdge("edge-start-n1", "start", IqcInspBillFlowConst.NodeInspect, 140, 120, 260, 120),
|
|
|
BuildEdge("edge-n1-n2", IqcInspBillFlowConst.NodeInspect, IqcInspBillFlowConst.NodeSupervisor, 340, 120, 460, 120),
|
|
|
- BuildEdge("edge-n2-end", IqcInspBillFlowConst.NodeSupervisor, "end", 540, 120, 660, 120),
|
|
|
+ BuildEdge("edge-n2-gw", IqcInspBillFlowConst.NodeSupervisor, IqcInspBillFlowConst.GatewayPd, 540, 120, 640, 120),
|
|
|
+ BuildEdge("edge-gw-n3", IqcInspBillFlowConst.GatewayPd, IqcInspBillFlowConst.NodeSqe, 680, 120, 780, 120),
|
|
|
+ BuildEdge("edge-gw-end", IqcInspBillFlowConst.GatewayPd, "end", 680, 120, 960, 120),
|
|
|
+ BuildEdge("edge-n3-end", IqcInspBillFlowConst.NodeSqe, "end", 860, 120, 960, 120),
|
|
|
}
|
|
|
};
|
|
|
return JsonSerializer.Serialize(item);
|