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
///
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