From fb851cf25657e1cbed2396ce2f9a6e9ab1a3d647 Mon Sep 17 00:00:00 2001 From: anerx <512464164@qq.com> Date: Tue, 30 Jul 2024 08:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=8A=E4=BC=A0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Bodk.Customer/Entities/Customer.cs | 25 +++++-- Admin.Bodk.Device/Services/DeviceService.cs | 34 +++++++-- Admin.NET.Application/Configuration/Swagger.json | 23 ++++-- Admin.NET.Bodk.Core/Admin.NET.Bodk.Core.csproj | 13 ++++ Admin.NET.Bodk.Core/Devices/DeviceType.cs | 10 +++ Admin.NET.Bodk.Core/Devices/IDevice.cs | 19 +++++ Admin.NET.Bodk.Core/IRuntime.cs | 10 +++ .../Admin.NET.Bodk.Customer.csproj | 13 ++++ Admin.NET.Bodk.Customer/CustomerService.cs | 15 ++++ Admin.NET.Bodk.Customer/Entities/CustomerEntity.cs | 19 +++++ Admin.NET.Bodk.Device/Admin.NET.Bodk.Device.csproj | 13 ++++ .../Controllers/DeviceController.cs | 54 ++++++++++++++ Admin.NET.Bodk.Device/Controllers/Dto/DeviceDto.cs | 18 +++++ Admin.NET.Bodk.Device/Devices/DeviceType.cs | 10 +++ Admin.NET.Bodk.Device/Devices/IDevice.cs | 18 +++++ Admin.NET.Bodk.Device/Devices/Summary/M9Summary.cs | 22 ++++++ .../Admin.NET.Bodk.Genetic.csproj | 13 ++++ .../Entities/GeneticTestAgencyEntity.cs | 10 +++ .../Entities/GeneticTestResultEntity.cs | 10 +++ .../Admin.NET.Bodk.Project.csproj | 17 +++++ .../Controllers/ProjectController.cs | 87 ++++++++++++++++++++++ Admin.NET.Bodk.Project/Entities/ProjectEntity.cs | 21 ++++++ Admin.NET.Bodk.Project/Models/Project.cs | 50 +++++++++++++ Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj | 2 + Admin.NET.sln | 30 ++++++++ Bodk.Device.Storage/IStorage.cs | 8 +- Bodk.Device.Storage/M9Storage.cs | 31 +++++++- Bodk.Device.Storage/Modules/GantryY.cs | 2 +- Bodk.Device.Storage/Modules/Valves.cs | 58 +++++++++++++++ 29 files changed, 628 insertions(+), 27 deletions(-) create mode 100644 Admin.NET.Bodk.Core/Admin.NET.Bodk.Core.csproj create mode 100644 Admin.NET.Bodk.Core/Devices/DeviceType.cs create mode 100644 Admin.NET.Bodk.Core/Devices/IDevice.cs create mode 100644 Admin.NET.Bodk.Core/IRuntime.cs create mode 100644 Admin.NET.Bodk.Customer/Admin.NET.Bodk.Customer.csproj create mode 100644 Admin.NET.Bodk.Customer/CustomerService.cs create mode 100644 Admin.NET.Bodk.Customer/Entities/CustomerEntity.cs create mode 100644 Admin.NET.Bodk.Device/Admin.NET.Bodk.Device.csproj create mode 100644 Admin.NET.Bodk.Device/Controllers/DeviceController.cs create mode 100644 Admin.NET.Bodk.Device/Controllers/Dto/DeviceDto.cs create mode 100644 Admin.NET.Bodk.Device/Devices/DeviceType.cs create mode 100644 Admin.NET.Bodk.Device/Devices/IDevice.cs create mode 100644 Admin.NET.Bodk.Device/Devices/Summary/M9Summary.cs create mode 100644 Admin.NET.Bodk.Genetic/Admin.NET.Bodk.Genetic.csproj create mode 100644 Admin.NET.Bodk.Genetic/Entities/GeneticTestAgencyEntity.cs create mode 100644 Admin.NET.Bodk.Genetic/Entities/GeneticTestResultEntity.cs create mode 100644 Admin.NET.Bodk.Project/Admin.NET.Bodk.Project.csproj create mode 100644 Admin.NET.Bodk.Project/Controllers/ProjectController.cs create mode 100644 Admin.NET.Bodk.Project/Entities/ProjectEntity.cs create mode 100644 Admin.NET.Bodk.Project/Models/Project.cs create mode 100644 Bodk.Device.Storage/Modules/Valves.cs diff --git a/Admin.Bodk.Customer/Entities/Customer.cs b/Admin.Bodk.Customer/Entities/Customer.cs index 2e2f438..69b1098 100644 --- a/Admin.Bodk.Customer/Entities/Customer.cs +++ b/Admin.Bodk.Customer/Entities/Customer.cs @@ -1,4 +1,3 @@ - using System.ComponentModel.DataAnnotations; using Admin.NET.Core; using Nest; @@ -6,12 +5,13 @@ using SqlSugar; using Yitter.IdGenerator; namespace Admin.Bodk.Customer.Entities; + /// /// 客户表 /// -[SugarTable(null, "客户表")] +[SugarTable("bodk_customer", "客户表")] [SysTable] -public class Customer: EntityTenant, IRepositorySettings +public class Customer : EntityTenant, IRepositorySettings { [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = false)] public long Id { get; set; } = YitIdHelper.NextId(); @@ -19,20 +19,29 @@ public class Customer: EntityTenant, IRepositorySettings [SugarColumn(ColumnDescription = "客户名称", Length = 32)] [Required, MaxLength(32)] public virtual string? Name { get; set; } - + [SugarColumn(ColumnDescription = "性别")] [Required] public virtual Sex Sex { get; set; } - - [SugarColumn(ColumnDescription = "身份证号码", Length = 32,IsNullable = true)] + + [SugarColumn(ColumnDescription = "身份证号码", Length = 32, IsNullable = true)] public virtual string IdNo { get; set; } - - [SugarColumn(ColumnDescription = "手机号码", Length = 32,IsNullable = true)] + + [SugarColumn(ColumnDescription = "手机号码", Length = 32, IsNullable = true)] public virtual string PhoneNo { get; set; } + + [SugarColumn(ColumnDescription = "数据来源")] + public virtual DataSource Source { get; set; } } public enum Sex { Man = 1, Woman = 0 +} + +public enum DataSource +{ + App = 1, + Input = 2 } \ No newline at end of file diff --git a/Admin.Bodk.Device/Services/DeviceService.cs b/Admin.Bodk.Device/Services/DeviceService.cs index bf2ca74..db6488e 100644 --- a/Admin.Bodk.Device/Services/DeviceService.cs +++ b/Admin.Bodk.Device/Services/DeviceService.cs @@ -8,6 +8,7 @@ using Furion.DynamicApiController; using Furion.FriendlyException; using Mapster; using Microsoft.AspNetCore.Mvc; +using NewLife.Caching; using SqlSugar; namespace Admin.Bodk.Device.Services; @@ -19,13 +20,18 @@ namespace Admin.Bodk.Device.Services; public class DeviceService : IDynamicApiController, ITransient { private readonly SqlSugarRepository _repository; - + private readonly SqlSugarRepository _taskChainRepository; - public DeviceService(SqlSugarRepository repository, SqlSugarRepository taskChainRepository) + private readonly ICache _cache; + + public DeviceService(SqlSugarRepository repository, + SqlSugarRepository taskChainRepository, + ICache cache) { _repository = repository; _taskChainRepository = taskChainRepository; + _cache = cache; } /// @@ -41,23 +47,35 @@ public class DeviceService : IDynamicApiController, ITransient .WhereIF(!string.IsNullOrWhiteSpace(input.Name), m => m.Name != null && m.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type == input.Type) - .Select((u) => new EquipmentDto + .Select((u) => new EquipmentDto() { Id = u.Id, Name = u.Name, Type = u.Type, BaseName = u.BaseName, PicUrl = u.PicUrl, - LiquidNitrogenHeight = u.LiquidNitrogenHeight, - Temperature = u.Temperature, - Humidity = u.Humidity, Address = u.Address, Remark = u.Remark, Code = u.Code, Ip = u.Ip, Status = u.Status, CreateTime = u.CreateTime, - //TaskChainList =SqlFunc.Subqueryable().Where(tc => tc.EquipmentId == u.Id).ToList() + }) + .Mapper(d => + { + var cache = _cache.Get($"bodk:device:{d.Code}:summary"); + if (cache is not null) + { + d.Temperature = cache?.TankTopTemperature; + d.LiquidNitrogenHeight = cache?.LiquidHeight; + d.Humidity = cache?.CavityHumidity; + } + else + { + d.Temperature = -192.5f; + d.LiquidNitrogenHeight = 182; + d.Humidity = 0.5f; + } }) .ToPagedListAsync(input.Page, input.PageSize); } @@ -72,7 +90,7 @@ public class DeviceService : IDynamicApiController, ITransient [DisplayName("增加设备")] public async Task AddEquipment(EquipmentDto input) { - if(input is null) throw Oops.Oh("参数不能为空"); + if (input is null) throw Oops.Oh("参数不能为空"); var equipment = input.Adapt(); // if( a is double b) // { diff --git a/Admin.NET.Application/Configuration/Swagger.json b/Admin.NET.Application/Configuration/Swagger.json index 4d15b23..0da2657 100644 --- a/Admin.NET.Application/Configuration/Swagger.json +++ b/Admin.NET.Application/Configuration/Swagger.json @@ -1,12 +1,17 @@ { "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", - "SpecificationDocumentSettings": { - "DocumentTitle": "Admin.NET 通用权限开发平台", + "DocumentTitle": "Bodk Swagger", "GroupOpenApiInfos": [ { + "Group": "Bodk Groups", + "Title": "博工业务接口中心", + "Description": "Bodk Business API Center,提供博工业务相关的接口服务。", + "Version": "1.0.0" + }, + { "Group": "Default", - "Title": "Admin.NET 通用权限开发平台", + "Title": "Admin.NET", "Description": "让 .NET 开发更简单、更通用、更流行。前后端分离架构(.NET6/Vue3),开箱即用紧随前沿技术。
https://gitee.com/zuohuaijun/Admin.NET", "Version": "1.0.0" //"TermsOfService": "https://dotnetchina.gitee.io/furion/", @@ -29,14 +34,18 @@ //} } ], - "DefaultGroupName": "Default", // 默认分组名 - "DocExpansionState": "List", // List、Full、None + "DefaultGroupName": "Default", + // 默认分组名 + "DocExpansionState": "List", + // List、Full、None "EnableAllGroups": true, "LoginInfo": { - "Enabled": true, // 是否开启Swagger登录 + "Enabled": true, + // 是否开启Swagger登录 "CheckUrl": "/api/swagger/checkUrl", "SubmitUrl": "/api/swagger/submitUrl" }, - "EnumToNumber": true // 枚举类型生成值类型 + "EnumToNumber": true + // 枚举类型生成值类型 } } \ No newline at end of file diff --git a/Admin.NET.Bodk.Core/Admin.NET.Bodk.Core.csproj b/Admin.NET.Bodk.Core/Admin.NET.Bodk.Core.csproj new file mode 100644 index 0000000..619669c --- /dev/null +++ b/Admin.NET.Bodk.Core/Admin.NET.Bodk.Core.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/Admin.NET.Bodk.Core/Devices/DeviceType.cs b/Admin.NET.Bodk.Core/Devices/DeviceType.cs new file mode 100644 index 0000000..5fb61c7 --- /dev/null +++ b/Admin.NET.Bodk.Core/Devices/DeviceType.cs @@ -0,0 +1,10 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Core.Devices; + +public enum DeviceType +{ + M9 = 1, +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Core/Devices/IDevice.cs b/Admin.NET.Bodk.Core/Devices/IDevice.cs new file mode 100644 index 0000000..d039a28 --- /dev/null +++ b/Admin.NET.Bodk.Core/Devices/IDevice.cs @@ -0,0 +1,19 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Core.Devices; + +public interface IDevice +{ + long? Id { get; } + DeviceType Type { get; } + + string SerialNumber { get; } + + object Summary { get; } + + public long? ProjectId { get; } + + string Name { get; } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Core/IRuntime.cs b/Admin.NET.Bodk.Core/IRuntime.cs new file mode 100644 index 0000000..0c4c15e --- /dev/null +++ b/Admin.NET.Bodk.Core/IRuntime.cs @@ -0,0 +1,10 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Core; + +public interface IRuntime +{ + +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Customer/Admin.NET.Bodk.Customer.csproj b/Admin.NET.Bodk.Customer/Admin.NET.Bodk.Customer.csproj new file mode 100644 index 0000000..619669c --- /dev/null +++ b/Admin.NET.Bodk.Customer/Admin.NET.Bodk.Customer.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/Admin.NET.Bodk.Customer/CustomerService.cs b/Admin.NET.Bodk.Customer/CustomerService.cs new file mode 100644 index 0000000..0fbab2a --- /dev/null +++ b/Admin.NET.Bodk.Customer/CustomerService.cs @@ -0,0 +1,15 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; + +namespace Admin.NET.Bodk.Customer; + +[ApiDescriptionSettings(GroupName = "Bodk Groups",Description = "客户接口服务")] +public class CustomerService: IDynamicApiController, ITransient +{ + +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Customer/Entities/CustomerEntity.cs b/Admin.NET.Bodk.Customer/Entities/CustomerEntity.cs new file mode 100644 index 0000000..11b2513 --- /dev/null +++ b/Admin.NET.Bodk.Customer/Entities/CustomerEntity.cs @@ -0,0 +1,19 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Admin.NET.Core; +using Nest; + +namespace Admin.NET.Bodk.Customer.Entities; + +public class CustomerEntity : EntityBase, IRepositorySettings +{ + public string Name { get; set; } + + public string IdCard { get; set; } + + public string Phone { get; set; } + + public bool IsMale { get; set; } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Device/Admin.NET.Bodk.Device.csproj b/Admin.NET.Bodk.Device/Admin.NET.Bodk.Device.csproj new file mode 100644 index 0000000..b2772ff --- /dev/null +++ b/Admin.NET.Bodk.Device/Admin.NET.Bodk.Device.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/Admin.NET.Bodk.Device/Controllers/DeviceController.cs b/Admin.NET.Bodk.Device/Controllers/DeviceController.cs new file mode 100644 index 0000000..a5f3881 --- /dev/null +++ b/Admin.NET.Bodk.Device/Controllers/DeviceController.cs @@ -0,0 +1,54 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using System.ComponentModel; +using Admin.NET.Bodk.Device.Controllers.Dto; +using Admin.NET.Core; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using NewLife.Caching; + +namespace Admin.NET.Bodk.Device.Controllers; + +[ApiDescriptionSettings(Groups = new[] { "Bodk Groups" },Name = "DeviceController",Description = "设备接口服务")] +public class DeviceController : IDynamicApiController, ITransient +{ + private readonly ICache _cache; + + public DeviceController(ICache cache) + { + _cache = cache; + } + + /// + /// 上传设备摘要 + /// + /// + /// + [DisplayName("上传设备摘要")] + [Authorize(AuthenticationSchemes = + JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] + public Task UploadDeviceSummary(DeviceInput input) + { + _cache.Set($"bodk:device:{input.SerialNumber}:summary", input.Summary); + + return Task.CompletedTask; + } + + /// + /// 获取设备摘要 + /// + /// + /// + [DisplayName("获取设备摘要")] + [Authorize(AuthenticationSchemes = + JwtBearerDefaults.AuthenticationScheme + "," + SignatureAuthenticationDefaults.AuthenticationScheme)] + public Task GetDeviceSummary(string serialNumber) + { + return Task.Run(() => _cache.Get($"bodk:device:{serialNumber}:summary")); + } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Device/Controllers/Dto/DeviceDto.cs b/Admin.NET.Bodk.Device/Controllers/Dto/DeviceDto.cs new file mode 100644 index 0000000..9a45ded --- /dev/null +++ b/Admin.NET.Bodk.Device/Controllers/Dto/DeviceDto.cs @@ -0,0 +1,18 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Admin.NET.Bodk.Device.Devices; +using Admin.NET.Bodk.Device.Devices.Summary; + +namespace Admin.NET.Bodk.Device.Controllers.Dto; + +public class DeviceInput +{ + public string SerialNumber { get; set; } + + public string Name { get; set; } + + public DeviceType DeviceType { get; set; } + public object? Summary { get; set; } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Device/Devices/DeviceType.cs b/Admin.NET.Bodk.Device/Devices/DeviceType.cs new file mode 100644 index 0000000..8bed4bb --- /dev/null +++ b/Admin.NET.Bodk.Device/Devices/DeviceType.cs @@ -0,0 +1,10 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Device.Devices; + +public enum DeviceType +{ + M9 = 1 +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Device/Devices/IDevice.cs b/Admin.NET.Bodk.Device/Devices/IDevice.cs new file mode 100644 index 0000000..1387b79 --- /dev/null +++ b/Admin.NET.Bodk.Device/Devices/IDevice.cs @@ -0,0 +1,18 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Admin.NET.Bodk.Device.Devices.Summary; + +namespace Admin.NET.Bodk.Device.Devices; + +public interface IDevice +{ + object Summary { get; } + + string SerialNumber { get; } + + long? Id { get; } + + +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Device/Devices/Summary/M9Summary.cs b/Admin.NET.Bodk.Device/Devices/Summary/M9Summary.cs new file mode 100644 index 0000000..78c6229 --- /dev/null +++ b/Admin.NET.Bodk.Device/Devices/Summary/M9Summary.cs @@ -0,0 +1,22 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Device.Devices.Summary; + +public class M9Summary +{ + public bool Online { get; set; } + + public float CavityHumidity { get; set; } + + public float CavityTemperature { get; set; } + + public float LiquidHeight { get; set; } + + public float LiquidFillingPortTemperature { get; set; } + + public float ExhaustPortTemperature { get; set; } + + public float TankTopTemperature { get; set; } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Genetic/Admin.NET.Bodk.Genetic.csproj b/Admin.NET.Bodk.Genetic/Admin.NET.Bodk.Genetic.csproj new file mode 100644 index 0000000..619669c --- /dev/null +++ b/Admin.NET.Bodk.Genetic/Admin.NET.Bodk.Genetic.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/Admin.NET.Bodk.Genetic/Entities/GeneticTestAgencyEntity.cs b/Admin.NET.Bodk.Genetic/Entities/GeneticTestAgencyEntity.cs new file mode 100644 index 0000000..578d262 --- /dev/null +++ b/Admin.NET.Bodk.Genetic/Entities/GeneticTestAgencyEntity.cs @@ -0,0 +1,10 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Genetic.Entities; + +public class GeneticTestAgencyEntity +{ + +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Genetic/Entities/GeneticTestResultEntity.cs b/Admin.NET.Bodk.Genetic/Entities/GeneticTestResultEntity.cs new file mode 100644 index 0000000..e7d14ae --- /dev/null +++ b/Admin.NET.Bodk.Genetic/Entities/GeneticTestResultEntity.cs @@ -0,0 +1,10 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +namespace Admin.NET.Bodk.Genetic.Entities; + +public class GeneticTestResultEntity +{ + +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Project/Admin.NET.Bodk.Project.csproj b/Admin.NET.Bodk.Project/Admin.NET.Bodk.Project.csproj new file mode 100644 index 0000000..2967119 --- /dev/null +++ b/Admin.NET.Bodk.Project/Admin.NET.Bodk.Project.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/Admin.NET.Bodk.Project/Controllers/ProjectController.cs b/Admin.NET.Bodk.Project/Controllers/ProjectController.cs new file mode 100644 index 0000000..7c703f6 --- /dev/null +++ b/Admin.NET.Bodk.Project/Controllers/ProjectController.cs @@ -0,0 +1,87 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using System.ComponentModel; +using Admin.NET.Bodk.Project.Entities; +using Admin.NET.Bodk.Project.Models; +using Admin.NET.Core; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; + +namespace Admin.NET.Bodk.Project.Controllers; + +[ApiDescriptionSettings(GroupName = "Bodk Groups", Description = "项目接口服务")] +public class ProjectController : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _repository; + + public ProjectController(SqlSugarRepository repository) + { + _repository = repository; + } + + [ApiDescriptionSettings(Name = "GetList"), HttpPost] + [DisplayName("获取项目列表")] + public async Task> GetList(ProjectQueryInput input) + { + return await _repository.AsQueryable() + .WhereIF(!string.IsNullOrWhiteSpace(input.Name), + m => input.Name != null && m.Name.Contains(input.Name)) + .WhereIF(input.Id is not null, m => m.Id == input.Id) + .WhereIF(!string.IsNullOrWhiteSpace(input.Manager), + m => input.Manager != null && m.Manager.Contains(input.Manager)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Phone), + m => input.Phone != null && m.Phone.Contains(input.Phone)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Position), + m => input.Position != null && m.Position.Contains(input.Position)) + .WhereIF(input.IsDeleted is not null, + m => m.IsDelete == input.IsDeleted) + .Select((u) => new Models.Project() + { + Id = u.Id, + Name = u.Name, + Manager = u.Manager, + Position = u.Position, + Phone = u.Phone, + IsDeleted = u.IsDelete, + CreateTime = u.CreateTime, + }) + .ToPagedListAsync(input.Page, input.PageSize); + } + + [ApiDescriptionSettings(Name = "Add"), HttpPost] + [DisplayName("新增项目")] + public async Task AddProject(ProjectInput project) + { + await _repository.InsertAsync(new ProjectEntity() + { + Name = project.Name, + Position = project.Position, + Manager = project.Manager, + Phone = project.Phone + }); + } + + [ApiDescriptionSettings(Name = "Delete"), HttpPost] + [DisplayName("删除项目")] + public async Task DeleteProject(long id) + { + var project = await _repository.GetSingleAsync(d => d.Id == id); + project.IsDelete = true; + await _repository.UpdateAsync(project); + } + + [ApiDescriptionSettings(Name = "Update"), HttpPost] + [DisplayName("修改项目")] + public async Task UpdateProject(ProjectInput projectInput) + { + var project = await _repository.GetSingleAsync(d => d.Id == projectInput.Id); + project.Manager = projectInput.Manager; + project.Name = projectInput.Name; + project.Phone = projectInput.Phone; + project.Position = projectInput.Position; + await _repository.UpdateAsync(project); + } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Project/Entities/ProjectEntity.cs b/Admin.NET.Bodk.Project/Entities/ProjectEntity.cs new file mode 100644 index 0000000..865c781 --- /dev/null +++ b/Admin.NET.Bodk.Project/Entities/ProjectEntity.cs @@ -0,0 +1,21 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Admin.NET.Core; +using Nest; +using SqlSugar; + +namespace Admin.NET.Bodk.Project.Entities; + +[SugarTable("bodk_project", "项目表")] +public class ProjectEntity : EntityTenant, IRepositorySettings +{ + public string Name { get; set; } + + public string Position { get; set; } + + public string Manager { get; set; } + + public string Phone { get; set; } +} \ No newline at end of file diff --git a/Admin.NET.Bodk.Project/Models/Project.cs b/Admin.NET.Bodk.Project/Models/Project.cs new file mode 100644 index 0000000..08c7974 --- /dev/null +++ b/Admin.NET.Bodk.Project/Models/Project.cs @@ -0,0 +1,50 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Admin.NET.Core; + +namespace Admin.NET.Bodk.Project.Models; + +public class Project +{ + public long? Id { get; set; } + + public string Name { get; set; } + + public string Position { get; set; } + + public string Manager { get; set; } + + public string Phone { get; set; } + + public bool IsDeleted { get; set; } + + public DateTime CreateTime { get; set; } +} + +public class ProjectQueryInput : BasePageInput +{ + public long? Id { get; set; } + + public string? Name { get; set; } + + public string? Position { get; set; } + + public string? Manager { get; set; } + + public string? Phone { get; set; } + + public bool? IsDeleted { get; set; } +} + +public class ProjectInput : BaseIdInput +{ + public string Name { get; set; } + + public string Position { get; set; } + + public string Manager { get; set; } + + public string Phone { get; set; } +} \ No newline at end of file diff --git a/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj b/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj index 44e0318..618be92 100644 --- a/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj +++ b/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj @@ -42,6 +42,8 @@ + + diff --git a/Admin.NET.sln b/Admin.NET.sln index cfe547d..3cdd97d 100644 --- a/Admin.NET.sln +++ b/Admin.NET.sln @@ -30,6 +30,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bodk.Extensions.Modbus", "B EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.Bodk.Customer", "Admin.Bodk.Customer\Admin.Bodk.Customer.csproj", "{6A073364-6552-4CDB-861A-4BD8B51E0FF6}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Core", "Admin.NET.Bodk.Core\Admin.NET.Bodk.Core.csproj", "{C7CEFE53-6599-4249-B107-2912415660BD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Genetic", "Admin.NET.Bodk.Genetic\Admin.NET.Bodk.Genetic.csproj", "{BA340773-EEAA-430C-A0FC-AB6C3B35BA6D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Device", "Admin.NET.Bodk.Device\Admin.NET.Bodk.Device.csproj", "{35FB5A4D-4C35-4AF4-9719-1392707F9FF5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Customer", "Admin.NET.Bodk.Customer\Admin.NET.Bodk.Customer.csproj", "{75A96380-AA7E-46A6-892A-D66557B4565B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Admin.NET.Bodk.Project", "Admin.NET.Bodk.Project\Admin.NET.Bodk.Project.csproj", "{51EDA0FA-0D80-4631-9A2E-9315E99BA3CC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -76,6 +86,26 @@ Global {6A073364-6552-4CDB-861A-4BD8B51E0FF6}.Debug|Any CPU.Build.0 = Debug|Any CPU {6A073364-6552-4CDB-861A-4BD8B51E0FF6}.Release|Any CPU.ActiveCfg = Release|Any CPU {6A073364-6552-4CDB-861A-4BD8B51E0FF6}.Release|Any CPU.Build.0 = Release|Any CPU + {C7CEFE53-6599-4249-B107-2912415660BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7CEFE53-6599-4249-B107-2912415660BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7CEFE53-6599-4249-B107-2912415660BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7CEFE53-6599-4249-B107-2912415660BD}.Release|Any CPU.Build.0 = Release|Any CPU + {BA340773-EEAA-430C-A0FC-AB6C3B35BA6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA340773-EEAA-430C-A0FC-AB6C3B35BA6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA340773-EEAA-430C-A0FC-AB6C3B35BA6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA340773-EEAA-430C-A0FC-AB6C3B35BA6D}.Release|Any CPU.Build.0 = Release|Any CPU + {35FB5A4D-4C35-4AF4-9719-1392707F9FF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35FB5A4D-4C35-4AF4-9719-1392707F9FF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35FB5A4D-4C35-4AF4-9719-1392707F9FF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35FB5A4D-4C35-4AF4-9719-1392707F9FF5}.Release|Any CPU.Build.0 = Release|Any CPU + {75A96380-AA7E-46A6-892A-D66557B4565B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75A96380-AA7E-46A6-892A-D66557B4565B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75A96380-AA7E-46A6-892A-D66557B4565B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75A96380-AA7E-46A6-892A-D66557B4565B}.Release|Any CPU.Build.0 = Release|Any CPU + {51EDA0FA-0D80-4631-9A2E-9315E99BA3CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51EDA0FA-0D80-4631-9A2E-9315E99BA3CC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51EDA0FA-0D80-4631-9A2E-9315E99BA3CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51EDA0FA-0D80-4631-9A2E-9315E99BA3CC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Bodk.Device.Storage/IStorage.cs b/Bodk.Device.Storage/IStorage.cs index 32187a5..682168a 100644 --- a/Bodk.Device.Storage/IStorage.cs +++ b/Bodk.Device.Storage/IStorage.cs @@ -88,4 +88,10 @@ public interface IStorage /// /// Task Ready(); -} \ No newline at end of file + + /// + /// 一键回原 + /// + /// + Task GotoOrigin(); +} \ No newline at end of file diff --git a/Bodk.Device.Storage/M9Storage.cs b/Bodk.Device.Storage/M9Storage.cs index bc91b67..e5da2ae 100644 --- a/Bodk.Device.Storage/M9Storage.cs +++ b/Bodk.Device.Storage/M9Storage.cs @@ -39,6 +39,10 @@ public class M9Storage : IStorage _modbusWrapper.WriteCoilsAsync, _modbusWrapper.ReadCoilsAsync, _modbusWrapper.ReadHoldingRegistersAsync, _modbusWrapper.WriteHoldingRegistersAsync)); + _modules.Add(new Valves(alarmEventHandler, motionTimeoutAlarmEventHandler, + _modbusWrapper.WriteCoilsAsync, + _modbusWrapper.ReadCoilsAsync, _modbusWrapper.ReadHoldingRegistersAsync, + _modbusWrapper.WriteHoldingRegistersAsync)); } public async Task Start() @@ -152,7 +156,7 @@ public class M9Storage : IStorage var module = _modules.FirstOrDefault(m => m.Id == moduleId); if (module is null) throw new Exception("module not found"); - var method = module.GetType().GetMethod("methodName"); + var method = module.GetType().GetMethod(methodName); if (method is null) throw new Exception("method not found"); await Task.Run(() => (Task)method.Invoke(module, parameters)); @@ -199,7 +203,22 @@ public class M9Storage : IStorage } } - public Task Ready() + public async Task Ready() + { + await _modbusWrapper.WriteCoilsAsync(ReadyAddress, new[] { true }); + while (!(await _modbusWrapper.ReadCoilsAsync(ReadyFlagAddress, 1))[0]) + { + var modules = _modules.Where(d => d.Alarm || d.MotionTimeoutAlarm).ToList(); + if (modules.Count > 0) + { + throw new Exception($"module has error"); + } + + await Task.Delay(100); + } + } + + public Task GotoOrigin() { throw new NotImplementedException(); } @@ -215,6 +234,14 @@ public class M9Storage : IStorage private const ushort EnabledAddress = 330; + private const ushort ReadyAddress = 13; + + private const ushort ReadyFlagAddress = 14; + + private const ushort GotoOriginAddress = 90; + + private const ushort OriginFlagAddress = 11; + private void Process() { Task.Run(async () => diff --git a/Bodk.Device.Storage/Modules/GantryY.cs b/Bodk.Device.Storage/Modules/GantryY.cs index 739a4de..1f53012 100644 --- a/Bodk.Device.Storage/Modules/GantryY.cs +++ b/Bodk.Device.Storage/Modules/GantryY.cs @@ -105,7 +105,7 @@ public class GantryY( await AbsoluteMoveAsync(await ReadFloat(PlaceFoamLidAddress)); } - /// + /// /// 移动到双极模组A位 /// public async Task MoveToBipolarModuleAPositionAsync() diff --git a/Bodk.Device.Storage/Modules/Valves.cs b/Bodk.Device.Storage/Modules/Valves.cs new file mode 100644 index 0000000..ac3d022 --- /dev/null +++ b/Bodk.Device.Storage/Modules/Valves.cs @@ -0,0 +1,58 @@ +// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995 +// +// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证 + +using Bodk.Device.Storage.EventArgs; + +namespace Bodk.Device.Storage.Modules; + +public class Valves( + Action alarmEventHandler, + Action motionTimeoutAlarmEventHandler, + Func writeCoilRegisterFunc, + Func> readCoilRegisterFunc, + Func> readHoldingRegistersFunc, + Func writeHoldingRegistersFunc) + : ModuleBase(alarmEventHandler, motionTimeoutAlarmEventHandler, writeCoilRegisterFunc, readCoilRegisterFunc, + readHoldingRegistersFunc, writeHoldingRegistersFunc) +{ + public override string Name => "Valves"; + public override string Descirption => "阀门控制"; + public override int Id => 1001; + + private static ushort MainValve => 490; + + private static ushort InletValve => 491; + + private static ushort ExhaustValve => 492; + + /// + /// 总阀控制 + /// + /// + /// + public Task MainValveSwitch(bool open) + { + return writeCoilRegisterFunc(MainValve, new[] { open }); + } + + /// + /// 进液阀控制 + /// + /// + /// + public Task InletValveSwitch(bool open) + { + return writeCoilRegisterFunc(InletValve, new[] { open }); + } + + /// + /// 排气阀控制 + /// + /// + /// + public Task ExhaustValveSwitch(bool open) + { + return writeCoilRegisterFunc(ExhaustValve, new[] { open }); + } +} \ No newline at end of file