From 0554d14577373759b88b8be0f5134d3e89684362 Mon Sep 17 00:00:00 2001
From: zhaoy <137053305@qq.com>
Date: Wed, 28 Feb 2024 15:00:18 +0800
Subject: [PATCH] z
---
.../ProductFunction/ProductFunctionBaseDto.cs | 2 +-
.../Device/Services/DeviceVesionService.cs | 89 +++++++++++++++++--
.../Device/Services/ProductFunctionService.cs | 4 +-
.../Device/Services/ProductTopicsService.cs | 4 +-
BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs | 30 +++++++
BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs | 30 +++++++
.../Product/BPA_ProductFunction.cs | 2 +-
.../Product/BPA_ProductTopics.cs | 6 +-
8 files changed, 153 insertions(+), 14 deletions(-)
create mode 100644 BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs
create mode 100644 BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs
diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs
index d9a4d28..9eb68ff 100644
--- a/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs
+++ b/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs
@@ -20,7 +20,7 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction
///
/// 功能类型 0属性1服务2事件
///
- public int Type { get; set; }
+ public FunctionTypeEnum Type { get; set; }
///
/// 数据类型
///
diff --git a/BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs b/BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
index 70dd786..6ec7fd5 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
@@ -71,37 +71,74 @@ namespace BPA.SAAS.Manage.Application.Device.Services
Status = CommonStatus.ENABLE
}).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
var Product = _db.Queryable().Where(x => x.Id == inputDto.ProductId).First();
+ #region 添加默认功能和topics
List list = new();
var goodspushtopics = new BPA_ProductTopics()
{
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/goodspush",
- TopicsType = 2,
+ TopicsType = TopicsTypeEnum.SUBSCRIBE,
Description = "商品数据下发",
ProductId = inputDto.ProductId,
ProductVesionId = res.Id,
+ Name = "商品数据下发",
+ IsDefault = true
+ };
+ var goodspushtopics_reply = new BPA_ProductTopics()
+ {
+ Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/goodspush_reply",
+ TopicsType = TopicsTypeEnum.PUBLISH,
+ Description = "响应商品数据下发",
+ ProductId = inputDto.ProductId,
+ ProductVesionId = res.Id,
+ Name = "商品数据下发",
IsDefault = true
};
var batchingpushtopics = new BPA_ProductTopics()
{
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/batvhingpush",
- TopicsType = 2,
+ TopicsType = TopicsTypeEnum.PUBLISH,
Description = "物料数据下发",
ProductId = inputDto.ProductId,
ProductVesionId = res.Id,
+ Name = "物料数据下发",
+ IsDefault = true
+ };
+ var batchingpushtopics_reply = new BPA_ProductTopics()
+ {
+ Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/batvhingpush_reply",
+ TopicsType = TopicsTypeEnum.SUBSCRIBE,
+ Description = "响应物料数据下发",
+ ProductId = inputDto.ProductId,
+ ProductVesionId = res.Id,
+ Name = "物料数据下发",
IsDefault = true
};
var chnologypushtopics = new BPA_ProductTopics()
{
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/chnologypush",
- TopicsType = 2,
+ TopicsType = TopicsTypeEnum.PUBLISH,
Description = "工艺数据下发",
ProductId = inputDto.ProductId,
ProductVesionId = res.Id,
+ Name = "工艺数据下发",
+ IsDefault = true
+ };
+ var chnologypushtopics_reply = new BPA_ProductTopics()
+ {
+ Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/chnologypush_reply",
+ TopicsType = TopicsTypeEnum.SUBSCRIBE,
+ Description = "响应工艺数据下发",
+ ProductId = inputDto.ProductId,
+ Name = "工艺数据下发",
+ ProductVesionId = res.Id,
IsDefault = true
};
list.Add(goodspushtopics);
+ list.Add(goodspushtopics_reply);
list.Add(batchingpushtopics);
+ list.Add(batchingpushtopics_reply);
list.Add(chnologypushtopics);
+ list.Add(chnologypushtopics_reply);
await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
List ProductFunctionlist = new();
var goodsProductFunction = new BPA_ProductFunction()
@@ -109,40 +146,79 @@ namespace BPA.SAAS.Manage.Application.Device.Services
Id=Guid.NewGuid().ToString(),
CreateAt= DateTime.Now,
DataType = "",
- Type = 1,
+ Type = FunctionTypeEnum.SERVER,
Name = "商品数据下发",
Description = "商品数据下发",
ProductId = inputDto.ProductId,
DeviceVersionKey = res.Id,
IsDefault = true
};
+ var goodsProductFunction_reply = new BPA_ProductFunction()
+ {
+ Id = Guid.NewGuid().ToString(),
+ CreateAt = DateTime.Now,
+ DataType = "",
+ Type = FunctionTypeEnum.SERVER,
+ Name = "响应商品数据下发",
+ Description = "响应商品数据下发",
+ ProductId = inputDto.ProductId,
+ DeviceVersionKey = res.Id,
+ IsDefault = true
+ };
var batchingProductFunction = new BPA_ProductFunction()
{
Id = Guid.NewGuid().ToString(),
CreateAt = DateTime.Now,
DataType = "",
- Type = 1,
+ Type = FunctionTypeEnum.SERVER,
Name = "物料数据下发",
Description = "物料数据下发",
ProductId = inputDto.ProductId,
DeviceVersionKey = res.Id,
IsDefault = true
};
+ var batchingProductFunction_reply = new BPA_ProductFunction()
+ {
+ Id = Guid.NewGuid().ToString(),
+ CreateAt = DateTime.Now,
+ DataType = "",
+ Type = FunctionTypeEnum.SERVER,
+ Name = "响应物料数据下发",
+ Description = "响应物料数据下发",
+ ProductId = inputDto.ProductId,
+ DeviceVersionKey = res.Id,
+ IsDefault = true
+ };
var chnologyProductFunction = new BPA_ProductFunction()
{
Id = Guid.NewGuid().ToString(),
CreateAt = DateTime.Now,
DataType = "",
- Type = 1,
+ Type = FunctionTypeEnum.SERVER,
Name = "工艺数据下发",
Description = "工艺数据下发",
ProductId = inputDto.ProductId,
DeviceVersionKey = res.Id,
IsDefault = true
};
+ var chnologyProductFunction_reply = new BPA_ProductFunction()
+ {
+ Id = Guid.NewGuid().ToString(),
+ CreateAt = DateTime.Now,
+ DataType = "",
+ Type = FunctionTypeEnum.SERVER,
+ Name = "响应工艺数据下发",
+ Description = "响应工艺数据下发",
+ ProductId = inputDto.ProductId,
+ DeviceVersionKey = res.Id,
+ IsDefault = true
+ };
ProductFunctionlist.Add(goodsProductFunction);
+ ProductFunctionlist.Add(goodsProductFunction_reply);
ProductFunctionlist.Add(batchingProductFunction);
+ ProductFunctionlist.Add(batchingProductFunction_reply);
ProductFunctionlist.Add(chnologyProductFunction);
+ ProductFunctionlist.Add(chnologyProductFunction_reply);
await _db.Insertable(ProductFunctionlist).ExecuteCommandAsync();
List ProductFunctionActionlist = new();
var goodsProductFunctionActionlist = new BPA_ProductFunctionAction()
@@ -173,6 +249,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
ProductFunctionActionlist.Add(batchingProductFunctionActionlist);
ProductFunctionActionlist.Add(chnologyProductFunctionActionlist);
await _db.Insertable(ProductFunctionActionlist).CallEntityMethod(m => m.Create()).ExecuteCommandAsync();
+ #endregion
_db.Ado.CommitTran();
return res != null;
}
diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
index 4f7377b..7d59373 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
@@ -37,11 +37,11 @@ namespace BPA.SAAS.Manage.Application.Device.Services
var res = await _db.Queryable((x, b) => new JoinQueryInfos(JoinType.Left, b.Id == x.DeviceVersionKey))
.Where((x,b)=>x.ProductId == inputDto.ProductId && x.DeviceVersionKey== inputDto.ProductVesionId)
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Name), (x, b) => x.Name.Contains(inputDto.Name))
- .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Type), (x, b) => x.Type==Convert.ToInt32(inputDto.Type))
+ .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Type), (x, b) => x.Type==(FunctionTypeEnum)(Enum.Parse(typeof(FunctionTypeEnum), inputDto.Type)))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (x, b) => x.DeviceVersionKey == inputDto.Vesion)
//.WhereIF(inputDto.IsDefault!=null, (x, b) => x.IsDefault == inputDto.IsDefault)
.WhereIF(inputDto.Status != null, (x, b) => x.Status == inputDto.Status)
- .OrderBy((x, b) => x.CreateAt, OrderByType.Desc)
+ .OrderBy((x, b) => x.CreateAt, OrderByType.Desc).OrderBy((x, b) => x.Name, OrderByType.Desc)
.Select((x, b) => new
{
Name = x.Name,
diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs
index 2d43ded..126bba6 100644
--- a/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs
+++ b/BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs
@@ -30,9 +30,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
var total = new RefAsync();
var data = await _db.Queryable().Where(x=>x.ProductId== inputDto.ProductId && x.ProductVesionId== inputDto.ProductVesionId && x.IsDefault== inputDto.IsDefault)
- .WhereIF(inputDto.TopicsType!=null, x => x.TopicsType==Convert.ToInt32(inputDto.TopicsType))
+ .WhereIF(inputDto.TopicsType!=null, x => x.TopicsType== (TopicsTypeEnum)(Enum.Parse(typeof(TopicsTypeEnum), inputDto.TopicsType.ToString())))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Topics), x => x.Topics == inputDto.Topics)
- .OrderBy(x => x.CreateAt, OrderByType.Desc)
+ .OrderBy(x => x.CreateAt, OrderByType.Desc).OrderBy(x => x.Name, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);
return new PageUtil()
diff --git a/BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs b/BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs
new file mode 100644
index 0000000..3b491c3
--- /dev/null
+++ b/BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Comm.Enum
+{
+ public enum FunctionTypeEnum
+ {
+ ///
+ /// 属性
+ ///
+ [Description("属性")]
+ ATTRIBUTE = 0,
+
+ ///
+ /// 服务
+ ///
+ [Description("服务")]
+ SERVER = 1,
+
+ ///
+ /// 事件
+ ///
+ [Description("事件")]
+ EVENT= 2
+ }
+}
diff --git a/BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs b/BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs
new file mode 100644
index 0000000..3a88558
--- /dev/null
+++ b/BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.Manage.Comm.Enum
+{
+ public enum TopicsTypeEnum
+ {
+ ///
+ /// 发布
+ ///
+ [Description("发布")]
+ PUBLISH = 0,
+
+ ///
+ /// 订阅
+ ///
+ [Description("订阅")]
+ SUBSCRIBE = 1,
+
+ ///
+ /// 发布和订阅
+ ///
+ [Description("发布和订阅")]
+ PUBLISHANDSUBSCRIBE = 2
+ }
+}
diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs
index 52e5f29..16f2522 100644
--- a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs
+++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs
@@ -38,7 +38,7 @@ namespace BPA.SAAS.Manage.Core.Product
///
/// 功能类型 0属性1服务2事件
///
- public int Type { get; set; }
+ public FunctionTypeEnum Type { get; set; }
///
/// 数据类型
///
diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs
index 95d7bb6..f782457 100644
--- a/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs
+++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs
@@ -1,4 +1,5 @@
-using BPA.SAAS.Manage.Core.Base;
+using BPA.SAAS.Manage.Comm.Enum;
+using BPA.SAAS.Manage.Core.Base;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -18,7 +19,7 @@ namespace BPA.SAAS.Manage.Core.Product
///
/// TopicsType类型 0发布 1订阅 2发布和订阅
///
- public int TopicsType { get; set; }
+ public TopicsTypeEnum TopicsType { get; set; }
///
/// 描述
///
@@ -29,5 +30,6 @@ namespace BPA.SAAS.Manage.Core.Product
/// 是否默认Topics
///
public bool IsDefault { get; set; }
+ public string Name { get; set; }
}
}