diff --git a/projects/IoTNode/Data/IoTNodeDbContext.cs b/projects/IoTNode/Data/IoTNodeDbContext.cs index 8c234e17..ca9fc3a1 100644 --- a/projects/IoTNode/Data/IoTNodeDbContext.cs +++ b/projects/IoTNode/Data/IoTNodeDbContext.cs @@ -29,6 +29,7 @@ namespace IoTNode.Data //Setting modelBuilder.Entity().HasIndex(o => o.Name).IsUnique(); //ignore + modelBuilder.Ignore(); modelBuilder.Ignore(); modelBuilder.Ignore(); modelBuilder.Ignore(); @@ -50,12 +51,8 @@ namespace IoTNode.Data modelBuilder.Ignore(); modelBuilder.Ignore(); modelBuilder.Entity().Ignore(o => o.Order); - modelBuilder.Entity().Ignore(o => o.IoTCommands); modelBuilder.Entity().Ignore(o => o.Building); modelBuilder.Entity().Ignore(o => o.IoTCommands); - modelBuilder.Ignore(); - modelBuilder.Ignore(); - modelBuilder.Ignore(); // modelBuilder.Ignore(); modelBuilder.Ignore(); diff --git a/projects/IoTNode/DeviceServices/FBee/Controllers/IrController.cs b/projects/IoTNode/DeviceServices/FBee/Controllers/IrController.cs index bf868f6b..d31df13c 100644 --- a/projects/IoTNode/DeviceServices/FBee/Controllers/IrController.cs +++ b/projects/IoTNode/DeviceServices/FBee/Controllers/IrController.cs @@ -48,7 +48,7 @@ namespace IoTNode.Controllers } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("空调匹配")] - public ApiResponse MathAir1([SwaggerParameter("设备编号"), Required] string number) + public ApiResponse Match1([SwaggerParameter("设备编号"), Required] string number) { return this.AsyncAction(() => { @@ -57,7 +57,7 @@ namespace IoTNode.Controllers } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("电视匹配")] - public ApiResponse MathAir2([SwaggerParameter("设备编号"), Required] string number) + public ApiResponse Match2([SwaggerParameter("设备编号"), Required] string number) { return this.AsyncAction(() => { @@ -66,7 +66,7 @@ namespace IoTNode.Controllers } [HttpGet, Route("/[controller]/[action]"), SwaggerOperation("机顶盒匹配")] - public ApiResponse MathAir3([SwaggerParameter("设备编号"), Required] string number) + public ApiResponse Match3([SwaggerParameter("设备编号"), Required] string number) { return this.AsyncAction(() => { diff --git a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs index bc41f0c8..e6f65101 100644 --- a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs +++ b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs @@ -196,6 +196,7 @@ namespace IoTNode.DeviceServices.FBee this.Connect(client); } this.X9d(gateway.Number); + this.X81(gateway.Number); } catch (Exception ex) { diff --git a/projects/IoTNode/appsettings.Development.json b/projects/IoTNode/appsettings.Development.json index 4b4f5614..9eef32a0 100644 --- a/projects/IoTNode/appsettings.Development.json +++ b/projects/IoTNode/appsettings.Development.json @@ -1,7 +1,7 @@ { "Logging": { "LogLevel": { - "Default": "Debug", + "Default": "Trace", "System": "Information", "Microsoft": "Warning" } diff --git a/projects/IoTNode/appsettings.json b/projects/IoTNode/appsettings.json index e6d194cc..71df620f 100644 --- a/projects/IoTNode/appsettings.json +++ b/projects/IoTNode/appsettings.json @@ -12,7 +12,7 @@ "AppSettings": { "SecretKey": "111111111111111111111111", "JWT": "key=111111111111111111111111;issuer=111111111111111111111111;audience=111111111111111111111111;cookie=jwt", - "OpenApi": "name=name;title=title;version=1.0", + "OpenApi": "name=v1;title=title;version=1.0", "TablePrefix": "", "Database": "SQLite" } diff --git a/projects/IoTNode/db.sql b/projects/IoTNode/db.sql index ace06722..ba71e143 100644 --- a/projects/IoTNode/db.sql +++ b/projects/IoTNode/db.sql @@ -1,27 +1,4 @@ -CREATE TABLE "AppModule" ( - -- 模块 - - -- Id - "Id" TEXT NOT NULL CONSTRAINT "PK_AppModule" PRIMARY KEY, - - -- Name - "Name" TEXT NOT NULL, - - -- Number - "Number" TEXT NULL, - - -- Url - "Url" TEXT NULL, - - -- Order - "Order" INTEGER NOT NULL, - - -- IsDeleted - "IsDeleted" TEXT NULL -); - - -CREATE TABLE "IoTGateway" ( +CREATE TABLE "IoTGateway" ( -- 网关 -- Id @@ -111,33 +88,6 @@ CREATE TABLE "Setting" ( ); -CREATE TABLE "IoTApi" ( - -- 接口 - - -- Id - "Id" TEXT NOT NULL CONSTRAINT "PK_IoTApi" PRIMARY KEY, - - -- Name - "Name" TEXT NULL, - - -- Path - "Path" TEXT NULL, - - -- Command - "Command" TEXT NULL, - - -- Method - "Method" TEXT NULL, - - -- IoTProductId - "IoTProductId" TEXT NOT NULL, - - -- IsDeleted - "IsDeleted" TEXT NULL, - CONSTRAINT "FK_IoTApi_IoTProduct_IoTProductId" FOREIGN KEY ("IoTProductId") REFERENCES "IoTProduct" ("Id") ON DELETE CASCADE -); - - CREATE TABLE "IoTDevice" ( -- 设备 @@ -253,9 +203,6 @@ CREATE TABLE "IoTData" ( ); -CREATE INDEX "IX_IoTApi_IoTProductId" ON "IoTApi" ("IoTProductId"); - - CREATE INDEX "IX_IoTData_IoTDeviceId" ON "IoTData" ("IoTDeviceId"); diff --git a/projects/Platform/Api/Api/ApiController.cs b/projects/Platform/Api/Api/ApiController.cs index b5d450a5..1a7d2c0e 100644 --- a/projects/Platform/Api/Api/ApiController.cs +++ b/projects/Platform/Api/Api/ApiController.cs @@ -36,6 +36,7 @@ namespace Platform.Api.Api this._publisher = publisher; } + [HttpPost] public IActionResult ExecApi([FromBody] ExecApiModel model) { try diff --git a/projects/Platform/Api/Api/SiteController.cs b/projects/Platform/Api/Api/SiteController.cs index eedb6341..9d44f385 100644 --- a/projects/Platform/Api/Api/SiteController.cs +++ b/projects/Platform/Api/Api/SiteController.cs @@ -30,6 +30,7 @@ namespace Platform.Api this._organUserRepo = organUserRepo; } + [HttpPost] public IActionResult Layout(string user = null) { try diff --git a/projects/Platform/appsettings.json b/projects/Platform/appsettings.json index e4b20b08..4ff2d9ce 100644 --- a/projects/Platform/appsettings.json +++ b/projects/Platform/appsettings.json @@ -10,7 +10,7 @@ "AppSettings": { "SecretKey": "111111111111111111111111", "JWT": "key=111111111111111111111111;issuer=111111111111111111111111;audience=111111111111111111111111;cookie=token", - "OpenApi": "name=name;title=title;version=1.0", + "OpenApi": "name=v1;title=title;version=1.0", "BasePath": "/platform", "TablePrefix": "", "Database": "MySQL", diff --git a/projects/WebMVC/wwwroot/components/devices/control.html b/projects/WebMVC/wwwroot/components/devices/control.html index f72557d7..5e158f2d 100644 --- a/projects/WebMVC/wwwroot/components/devices/control.html +++ b/projects/WebMVC/wwwroot/components/devices/control.html @@ -345,9 +345,9 @@
- - - + + +
@@ -356,20 +356,51 @@ # 名称 - 按键 序号 + 按键 删除 {{index+1}} + {{button.Order}} {{button.Name}} {{button.Value}} - {{button.Order}}
+
+
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ + + +
+
+
+
+
@@ -386,6 +417,67 @@ code: this.value || 0 }; }, + computed: { + pattern: function () { + var code = parseInt(getIoTDataValue(this.device, "空调按键")); + var pattern = { name: '制冷', value: 0 }; + if (code > 480 + 2) { + pattern = { name: '通风', value: 480 }; + } + else if (code > 360 + 2) { + pattern = { name: '抽湿', value: 360 }; + } + else if (code > 240 + 2) { + pattern = { name: '制热', value: 240 }; + } + else if (code > 120 + 2) { + pattern = { name: '自动', value: 120 }; + } + return pattern; + }, + direction: function () { + var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); + var code = code1 - this.pattern.value; + var direction = { name: '自动', value: 0 };; + if (code > 60 + 2) { + direction = { name: '手动', value: 60 }; + } + return direction; + }, + wind: function () { + var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); + var code = code1 - this.pattern.value - this.direction.value; + var wind = { name: '自动', value: 0 }; + if (code > 45 + 2) { + wind = { name: '低', value: 45 }; + } + else if (code > 30 + 2) { + wind = { name: '中', value: 30 }; + } + else if (code > 15 + 2) { + wind = { name: '高', value: 15 }; + } + return wind; + }, + power: function () { + var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); + var code = code1 - this.pattern.value - this.direction.value - this.wind.value; + var power = { name: '关', value: 1 }; + if (code > 1) { + power = { name: '开', value: 2 }; + } + return power; + }, + temperature: function () { + var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); + var code = code1 - this.pattern.value - this.direction.value - this.wind.value - this.power.value; + var temperature = { name: '16℃', value: 1 }; + if (code > 1) { + temperature = { name: parseInt(code + 15) + '℃', value: code }; + } + return temperature; + } + }, watch: { code(val) { this.$emit('update:value', val); @@ -433,6 +525,9 @@ var newCode = code - oldValue + newValue; this.send(newCode, 1); }, + send: function (value, type) { + execApi(this.device.number, '/Ir/Send', 'type=' + type + '&code=' + value); + }, change: function (v, min, max, step) { var oldValue = parseInt(v); var newValue = oldValue + step; @@ -443,69 +538,35 @@ var newCode = code - oldValue + newValue; this.send(newCode, 1); }, - send: function (value, type) { - execApi(this.device.number, '/Ir/Send', 'type=' + type + '&code=' + value); + add: function () { + var array = $(event.target).parents('form').serializeArray(); + var button = {}; + $.map(array, function (n, i) { + button[n['name']] = n['value']; + }); + var list = this.getCustomButtons(); + list.push(button); + var value = JSON.stringify(list); + execApi(this.device.number, '/Ir/Buttons', 'buttons=' + value); }, - }, - computed: { - pattern: function () { - var code = parseInt(getIoTDataValue(this.device, "空调按键")); - var pattern = { name: '制冷', value: 0 }; - if (code > 480 + 2) { - pattern = { name: '通风', value: 480 }; + remove: function (name) { + var buttons = this.getCustomButtons(); + for (var i = buttons.length - 1; i >= 0; i--) { + if (buttons[i].name === name) { + buttons.splice(i, 1); + break; + } } - else if (code > 360 + 2) { - pattern = { name: '抽湿', value: 360 }; - } - else if (code > 240 + 2) { - pattern = { name: '制热', value: 240 }; - } - else if (code > 120 + 2) { - pattern = { name: '自动', value: 120 }; - } - return pattern; + var value = JSON.stringify(buttons); + execApi(this.device.number, '/Ir/Buttons', 'buttons=' + value); }, - direction: function () { - var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); - var code = code1 - this.pattern.value; - var direction = { name: '自动', value: 0 };; - if (code > 60 + 2) { - direction = { name: '手动', value: 60 }; - } - return direction; + test: function (event) { + var code = $(event.target).parents('form').find("input[name='Value']").val(); + execApi(this.device.number, '/Ir/Send', 'type=5&code=' + code); }, - wind: function () { - var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); - var code = code1 - this.pattern.value - this.direction.value; - var wind = { name: '自动', value: 0 }; - if (code > 45 + 2) { - wind = { name: '低', value: 45 }; - } - else if (code > 30 + 2) { - wind = { name: '中', value: 30 }; - } - else if (code > 15 + 2) { - wind = { name: '高', value: 15 }; - } - return wind; - }, - power: function () { - var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); - var code = code1 - this.pattern.value - this.direction.value - this.wind.value; - var power = { name: '关', value: 1 }; - if (code > 1) { - power = { name: '开', value: 2 }; - } - return power; - }, - temperature: function () { - var code1 = parseInt(getIoTDataValue(this.device, "空调按键")); - var code = code1 - this.pattern.value - this.direction.value - this.wind.value - this.power.value; - var temperature = { name: '16℃', value: 1 }; - if (code > 1) { - temperature = { name: parseInt(code + 15) + '℃', value: code }; - } - return temperature; + study: function (event) { + var code = $(event.target).parents('form').find("input[name='Value']").val(); + execApi(this.device.number, '/Ir/Study', 'type=' + 5 + '&code=' + code); } } }; diff --git a/projects/WebMVC/wwwroot/components/views/areas/default/index.html b/projects/WebMVC/wwwroot/components/views/areas/default/index.html index 2fc5e99e..bd8a7089 100644 --- a/projects/WebMVC/wwwroot/components/views/areas/default/index.html +++ b/projects/WebMVC/wwwroot/components/views/areas/default/index.html @@ -271,7 +271,7 @@ } else { var url = config.service('platform/Home/GetBuilding/' + id); - axios.get(url).then(function (response) { + axios.post(url).then(function (response) { parent.model.building = response.data; }); }