提交 4650c4dd 编写于 作者: W wq1234wq

设备活动日期格式化,移除部分脚本选项,修正保存执行历史指定导航属性报错的问题

上级 07a4d3c6
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Migrations
{
public partial class modyfyflowoperation : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "BaseEventEventId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "FlowRuleRuleId",
table: "FlowOperations");
migrationBuilder.AlterColumn<Guid>(
name: "FlowId",
table: "FlowOperations",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AddColumn<Guid>(
name: "BaseEventId",
table: "FlowOperations",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "FlowRuleId",
table: "FlowOperations",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_BaseEventId",
table: "FlowOperations",
column: "BaseEventId");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_FlowRuleId",
table: "FlowOperations",
column: "FlowRuleId");
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventId",
table: "FlowOperations",
column: "BaseEventId",
principalTable: "BaseEvents",
principalColumn: "EventId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleId",
table: "FlowOperations",
column: "FlowRuleId",
principalTable: "FlowRules",
principalColumn: "RuleId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations",
column: "FlowId",
principalTable: "Flows",
principalColumn: "FlowId",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleId",
table: "FlowOperations");
migrationBuilder.DropForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_BaseEventId",
table: "FlowOperations");
migrationBuilder.DropIndex(
name: "IX_FlowOperations_FlowRuleId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "BaseEventId",
table: "FlowOperations");
migrationBuilder.DropColumn(
name: "FlowRuleId",
table: "FlowOperations");
migrationBuilder.AlterColumn<Guid>(
name: "FlowId",
table: "FlowOperations",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn<Guid>(
name: "BaseEventEventId",
table: "FlowOperations",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "FlowRuleRuleId",
table: "FlowOperations",
type: "uuid",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_BaseEventEventId",
table: "FlowOperations",
column: "BaseEventEventId");
migrationBuilder.CreateIndex(
name: "IX_FlowOperations_FlowRuleRuleId",
table: "FlowOperations",
column: "FlowRuleRuleId");
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_BaseEvents_BaseEventEventId",
table: "FlowOperations",
column: "BaseEventEventId",
principalTable: "BaseEvents",
principalColumn: "EventId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_FlowRules_FlowRuleRuleId",
table: "FlowOperations",
column: "FlowRuleRuleId",
principalTable: "FlowRules",
principalColumn: "RuleId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_FlowOperations_Flows_FlowId",
table: "FlowOperations",
column: "FlowId",
principalTable: "Flows",
principalColumn: "FlowId",
onDelete: ReferentialAction.Restrict);
}
}
}
...@@ -1050,7 +1050,7 @@ namespace IoTSharp.Migrations ...@@ -1050,7 +1050,7 @@ namespace IoTSharp.Migrations
b.Property<DateTime?>("AddDate") b.Property<DateTime?>("AddDate")
.HasColumnType("timestamp without time zone"); .HasColumnType("timestamp without time zone");
b.Property<Guid?>("BaseEventEventId") b.Property<Guid>("BaseEventId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<string>("BizId") b.Property<string>("BizId")
...@@ -1059,10 +1059,10 @@ namespace IoTSharp.Migrations ...@@ -1059,10 +1059,10 @@ namespace IoTSharp.Migrations
b.Property<string>("Data") b.Property<string>("Data")
.HasColumnType("text"); .HasColumnType("text");
b.Property<Guid?>("FlowId") b.Property<Guid>("FlowId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid?>("FlowRuleRuleId") b.Property<Guid>("FlowRuleId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<int?>("NodeStatus") b.Property<int?>("NodeStatus")
...@@ -1082,11 +1082,11 @@ namespace IoTSharp.Migrations ...@@ -1082,11 +1082,11 @@ namespace IoTSharp.Migrations
b.HasKey("OperationId"); b.HasKey("OperationId");
b.HasIndex("BaseEventEventId"); b.HasIndex("BaseEventId");
b.HasIndex("FlowId"); b.HasIndex("FlowId");
b.HasIndex("FlowRuleRuleId"); b.HasIndex("FlowRuleId");
b.ToTable("FlowOperations"); b.ToTable("FlowOperations");
}); });
...@@ -1724,15 +1724,21 @@ namespace IoTSharp.Migrations ...@@ -1724,15 +1724,21 @@ namespace IoTSharp.Migrations
{ {
b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent")
.WithMany() .WithMany()
.HasForeignKey("BaseEventEventId"); .HasForeignKey("BaseEventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IoTSharp.Data.Flow", "Flow") b.HasOne("IoTSharp.Data.Flow", "Flow")
.WithMany() .WithMany()
.HasForeignKey("FlowId"); .HasForeignKey("FlowId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
.WithMany() .WithMany()
.HasForeignKey("FlowRuleRuleId"); .HasForeignKey("FlowRuleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BaseEvent"); b.Navigation("BaseEvent");
......
...@@ -23,11 +23,11 @@ namespace IoTSharp.Data ...@@ -23,11 +23,11 @@ namespace IoTSharp.Data
public string BizId { get; set; } public string BizId { get; set; }
public string bpmnid { get; set; } public string bpmnid { get; set; }
public Flow Flow { get; set; } public Flow Flow { get; set; }
public Guid FlowId { get; set; }
public FlowRule FlowRule { get; set; } public FlowRule FlowRule { get; set; }
public Guid FlowRuleId { get; set; }
public BaseEvent BaseEvent { get; set; } public BaseEvent BaseEvent { get; set; }
public Guid BaseEventId { get; set; }
public int Step { get; set; } public int Step { get; set; }
public string Tag { get; set; } public string Tag { get; set; }
} }
......
...@@ -97,7 +97,7 @@ export class DevicelistComponent implements OnInit, OnDestroy { ...@@ -97,7 +97,7 @@ export class DevicelistComponent implements OnInit, OnDestroy {
{ title: '名称', index: 'name', render: 'name' }, { title: '名称', index: 'name', render: 'name' },
{ title: '设备类型', index: 'deviceType', type: 'tag', tag: this.DeviceTAG }, { title: '设备类型', index: 'deviceType', type: 'tag', tag: this.DeviceTAG },
{ title: '在线状态', index: 'online', type: 'badge', badge: this.BADGE }, { title: '在线状态', index: 'online', type: 'badge', badge: this.BADGE },
{ title: '最后活动时间', index: 'lastActive' }, { title: '最后活动时间', index: 'lastActive',type:'date' },
{ title: '认证方式', index: 'identityType', type: 'tag', tag: this.TAG }, { title: '认证方式', index: 'identityType', type: 'tag', tag: this.TAG },
{ {
title: '操作', title: '操作',
......
...@@ -80,10 +80,7 @@ ...@@ -80,10 +80,7 @@
<nz-option nzValue="sql" nzLabel="sql"></nz-option> <nz-option nzValue="sql" nzLabel="sql"></nz-option>
<nz-option nzValue="lua" nzLabel="lua"></nz-option> <nz-option nzValue="lua" nzLabel="lua"></nz-option>
<nz-option nzValue="csharp" nzLabel="csharp"></nz-option> <nz-option nzValue="csharp" nzLabel="csharp"></nz-option>
<nz-option nzValue="json" nzLabel="json"[nzDisabled]="true"></nz-option>
<nz-option nzValue="bat" nzLabel="bat" [nzDisabled]="true"></nz-option>
<nz-option nzValue="xml" nzLabel="xml" [nzDisabled]="true"></nz-option>
</nz-select> </nz-select>
</se> </se>
<se label="执行器" error="请选择执行器" *ngIf="form.nodeProcessClassVisable"> <se label="执行器" error="请选择执行器" *ngIf="form.nodeProcessClassVisable">
......
...@@ -36,7 +36,7 @@ export class FloweventviewComponent implements OnInit, OnDestroy { ...@@ -36,7 +36,7 @@ export class FloweventviewComponent implements OnInit, OnDestroy {
this.flowview.diagramdata = x.data; this.flowview.diagramdata = x.data;
this.flowview.loadXml(); this.flowview.loadXml();
}), }),
), this.http.get('api/rules/getFlowOperstions?eventId=' + this.event.eventId).pipe( ), this.http.get('api/rules/GetFlowOperations?eventId=' + this.event.eventId).pipe(
map((x) => { map((x) => {
if(x.data.length>0){ if(x.data.length>0){
......
...@@ -1069,22 +1069,30 @@ namespace IoTSharp.Controllers ...@@ -1069,22 +1069,30 @@ namespace IoTSharp.Controllers
var d = formdata.Value<JToken>().ToObject(typeof(ExpandoObject)); var d = formdata.Value<JToken>().ToObject(typeof(ExpandoObject));
var testabizId = Guid.NewGuid().ToString(); //根据业务保存起来,用来查询执行事件和步骤 var testabizId = Guid.NewGuid().ToString(); //根据业务保存起来,用来查询执行事件和步骤
var result = await _flowRuleProcessor.RunFlowRules(ruleid, d, Guid.Empty, EventType.TestPurpose, testabizId); var result = await _flowRuleProcessor.RunFlowRules(ruleid, d, Guid.Empty, EventType.TestPurpose, testabizId);
if (result.Count > 0)
{
result.ForEach(c =>
{
_context.FlowOperations.Add(new FlowOperation()
{
AddDate = c.AddDate,
BaseEventId = c.BaseEventId,
BizId = c.BizId,
Data = c.Data,
FlowId = c.FlowId,
FlowRuleId = c.FlowRuleId,
NodeStatus = c.NodeStatus,
OperationDesc = c.OperationDesc,
OperationId = new Guid(),
Step = c.Step,
Tag = c.Tag,
bpmnid = c.bpmnid
});
_context.SaveChanges();
});
//result.ForEach(c => }
//{
// _context.FlowOperations.Add(new FlowOperation()
// {
// AddDate = c.AddDate, BaseEvent = c.BaseEvent, BizId = c.BizId, Data = c.Data, Flow = c.Flow, FlowRule = c.FlowRule, NodeStatus = c.NodeStatus, OperationDesc = c.OperationDesc, OperationId = c.OperationId, Step = c.Step, Tag = c.Tag, bpmnid = c.bpmnid
// });
// _context.SaveChanges();
//});
return new ApiResult<dynamic>(ApiCode.Success, "test complete", result.OrderBy(c => c.Step). return new ApiResult<dynamic>(ApiCode.Success, "test complete", result.OrderBy(c => c.Step).
Where(c => c.BaseEvent.Bizid == testabizId).ToList() Where(c => c.BaseEvent.Bizid == testabizId).ToList()
.GroupBy(c => c.Step).Select(c => new .GroupBy(c => c.Step).Select(c => new
...@@ -1174,9 +1182,9 @@ namespace IoTSharp.Controllers ...@@ -1174,9 +1182,9 @@ namespace IoTSharp.Controllers
[HttpGet("[action]")] [HttpGet("[action]")]
public ApiResult<dynamic> GetFlowOperstions(Guid eventId) public ApiResult<dynamic> GetFlowOperations(Guid eventId)
{ {
return new ApiResult<dynamic>(ApiCode.Success, "OK", _context.FlowOperations.Where(c => c.BaseEvent.EventId == eventId).ToList().OrderBy(c => c.Step). return new ApiResult<dynamic>(ApiCode.Success, "OK", _context.FlowOperations.Where(c => c.BaseEventId == eventId).ToList().OrderBy(c => c.Step).
ToList() ToList()
.GroupBy(c => c.Step).Select(c => new .GroupBy(c => c.Step).Select(c => new
{ {
...@@ -1321,10 +1329,6 @@ namespace IoTSharp.Controllers ...@@ -1321,10 +1329,6 @@ namespace IoTSharp.Controllers
var data = JsonConvert.DeserializeObject(m.Data) as JObject; var data = JsonConvert.DeserializeObject(m.Data) as JObject;
var d = data.ToObject(typeof(ExpandoObject)); var d = data.ToObject(typeof(ExpandoObject));
var result = await this._flowRuleProcessor.TestCondition(m.ruleId, m.flowId, d); var result = await this._flowRuleProcessor.TestCondition(m.ruleId, m.flowId, d);
return new ApiResult<ConditionTestResult>(ApiCode.Success, "Ok", result); return new ApiResult<ConditionTestResult>(ApiCode.Success, "Ok", result);
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace IoTSharp.Dtos
{
public class FlowOperationDto
{
public Guid OperationId { get; set; }
public DateTime? AddDate { get; set; }
/// <summary>
/// 节点处理状态,0 创建完
/// </summary>
public int? NodeStatus { get; set; }
public string OperationDesc { get; set; }
public string Data { get; set; }
public string BizId { get; set; }
public string bpmnid { get; set; }
public Guid ruleid { get; set; }
public Guid flowid { get; set; }
public Guid eventid { get; set; }
public int Step { get; set; }
}
}
...@@ -117,7 +117,11 @@ namespace IoTSharp.FlowRuleEngine ...@@ -117,7 +117,11 @@ namespace IoTSharp.FlowRuleEngine
bpmnid = "", bpmnid = "",
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = rule, FlowRule = rule,
FlowRuleId = rule.RuleId,
BaseEventId = @event.EventId,
FlowId = start.FlowId,
Flow = start, Flow = start,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "未能找到启动节点", OperationDesc = "未能找到启动节点",
...@@ -137,6 +141,9 @@ namespace IoTSharp.FlowRuleEngine ...@@ -137,6 +141,9 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = rule, FlowRule = rule,
Flow = start, Flow = start,
FlowRuleId = rule.RuleId,
BaseEventId = @event.EventId,
FlowId = start.FlowId,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "进入开始节点", OperationDesc = "进入开始节点",
...@@ -157,6 +164,12 @@ namespace IoTSharp.FlowRuleEngine ...@@ -157,6 +164,12 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = @event.FlowRule, FlowRule = @event.FlowRule,
Flow = item, Flow = item,
FlowRuleId = rule.RuleId,
BaseEventId = @event.EventId,
FlowId = start.FlowId,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "Condition(" + (string.IsNullOrEmpty(item.Conditionexpression) OperationDesc = "Condition(" + (string.IsNullOrEmpty(item.Conditionexpression)
...@@ -204,6 +217,11 @@ namespace IoTSharp.FlowRuleEngine ...@@ -204,6 +217,11 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = peroperation.BaseEvent.FlowRule, FlowRule = peroperation.BaseEvent.FlowRule,
Flow = flow, Flow = flow,
FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId,
BaseEventId = peroperation.BaseEvent.EventId,
FlowId = flow.FlowId,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "Condition(" + (string.IsNullOrEmpty(flow.Conditionexpression) OperationDesc = "Condition(" + (string.IsNullOrEmpty(flow.Conditionexpression)
...@@ -227,6 +245,9 @@ namespace IoTSharp.FlowRuleEngine ...@@ -227,6 +245,9 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = peroperation.BaseEvent.FlowRule, FlowRule = peroperation.BaseEvent.FlowRule,
Flow = flow, Flow = flow,
FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId,
BaseEventId = peroperation.BaseEvent.EventId,
FlowId = flow.FlowId,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "Run" + flow.NodeProcessScriptType + "Task:" + flow.Flowname, OperationDesc = "Run" + flow.NodeProcessScriptType + "Task:" + flow.Flowname,
...@@ -355,6 +376,9 @@ namespace IoTSharp.FlowRuleEngine ...@@ -355,6 +376,9 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = peroperation.BaseEvent.FlowRule, FlowRule = peroperation.BaseEvent.FlowRule,
Flow = item, Flow = item,
FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId,
BaseEventId = peroperation.BaseEvent.EventId,
FlowId = item.FlowId,
Data = JsonConvert.SerializeObject(obj), Data = JsonConvert.SerializeObject(obj),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "Execute(" + OperationDesc = "Execute(" +
...@@ -387,6 +411,9 @@ namespace IoTSharp.FlowRuleEngine ...@@ -387,6 +411,9 @@ namespace IoTSharp.FlowRuleEngine
AddDate = DateTime.Now, AddDate = DateTime.Now,
FlowRule = peroperation.BaseEvent.FlowRule, FlowRule = peroperation.BaseEvent.FlowRule,
Flow = item, Flow = item,
FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId,
BaseEventId = peroperation.BaseEvent.EventId,
FlowId = item.FlowId,
Data = JsonConvert.SerializeObject(data), Data = JsonConvert.SerializeObject(data),
NodeStatus = 1, NodeStatus = 1,
OperationDesc = "执行条件(" + (string.IsNullOrEmpty(item.Conditionexpression) OperationDesc = "执行条件(" + (string.IsNullOrEmpty(item.Conditionexpression)
...@@ -411,10 +438,16 @@ namespace IoTSharp.FlowRuleEngine ...@@ -411,10 +438,16 @@ namespace IoTSharp.FlowRuleEngine
if (end != null) if (end != null)
{ {
end.FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId;
end.BaseEventId = peroperation.BaseEvent.EventId;
end.FlowId = flow.FlowId;
end.bpmnid = flow.bpmnid; end.bpmnid = flow.bpmnid;
end.AddDate = DateTime.Now; end.AddDate = DateTime.Now;
end.FlowRule = peroperation.BaseEvent.FlowRule; end.FlowRule = peroperation.BaseEvent.FlowRule;
end.Flow = flow; end.Flow = flow;
end.Data = JsonConvert.SerializeObject(data); end.Data = JsonConvert.SerializeObject(data);
end.NodeStatus = 1; end.NodeStatus = 1;
end.OperationDesc = "处理完成"; end.OperationDesc = "处理完成";
...@@ -424,6 +457,10 @@ namespace IoTSharp.FlowRuleEngine ...@@ -424,6 +457,10 @@ namespace IoTSharp.FlowRuleEngine
else else
{ {
end = new FlowOperation(); end = new FlowOperation();
end.FlowRuleId = peroperation.BaseEvent.FlowRule.RuleId;
end.BaseEventId = peroperation.BaseEvent.EventId;
end.FlowId = flow.FlowId;
end.OperationId = Guid.NewGuid(); end.OperationId = Guid.NewGuid();
end.bpmnid = flow.bpmnid; end.bpmnid = flow.bpmnid;
end.AddDate = DateTime.Now; end.AddDate = DateTime.Now;
......
...@@ -579,6 +579,11 @@ ...@@ -579,6 +579,11 @@
客户 客户
</summary> </summary>
</member> </member>
<member name="P:IoTSharp.Dtos.FlowOperationDto.NodeStatus">
<summary>
节点处理状态,0 创建完
</summary>
</member>
<member name="P:IoTSharp.Dtos.InstallDto.Email"> <member name="P:IoTSharp.Dtos.InstallDto.Email">
<summary> <summary>
系统管理员用户名 系统管理员用户名
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册