zhaoy 8 months ago
parent
commit
0554d14577
8 changed files with 153 additions and 14 deletions
  1. +1
    -1
      BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs
  2. +83
    -6
      BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
  3. +2
    -2
      BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
  4. +2
    -2
      BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs
  5. +30
    -0
      BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs
  6. +30
    -0
      BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs
  7. +1
    -1
      BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs
  8. +4
    -2
      BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs

+ 1
- 1
BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs View File

@@ -20,7 +20,7 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction
/// <summary>
/// 功能类型 0属性1服务2事件
/// </summary>
public int Type { get; set; }
public FunctionTypeEnum Type { get; set; }
/// <summary>
/// 数据类型
/// </summary>


+ 83
- 6
BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs View File

@@ -71,37 +71,74 @@ namespace BPA.SAAS.Manage.Application.Device.Services
Status = CommonStatus.ENABLE
}).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync();
var Product = _db.Queryable<BPA_Product>().Where(x => x.Id == inputDto.ProductId).First();
#region 添加默认功能和topics
List<BPA_ProductTopics> 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<BPA_ProductFunction> 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<BPA_ProductFunctionAction> 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;
}


+ 2
- 2
BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs View File

@@ -37,11 +37,11 @@ namespace BPA.SAAS.Manage.Application.Device.Services
var res = await _db.Queryable<BPA_ProductFunction, BPA_ProductVesion>((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,


+ 2
- 2
BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs View File

@@ -30,9 +30,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
var total = new RefAsync<int>();
var data = await _db.Queryable<BPA_ProductTopics>().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()


+ 30
- 0
BPA.SAAS.Manage.Comm/Enum/FunctionTypeEnum.cs View File

@@ -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
{
/// <summary>
/// 属性
/// </summary>
[Description("属性")]
ATTRIBUTE = 0,

/// <summary>
/// 服务
/// </summary>
[Description("服务")]
SERVER = 1,

/// <summary>
/// 事件
/// </summary>
[Description("事件")]
EVENT= 2
}
}

+ 30
- 0
BPA.SAAS.Manage.Comm/Enum/TopicsTypeEnum.cs View File

@@ -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
{
/// <summary>
/// 发布
/// </summary>
[Description("发布")]
PUBLISH = 0,

/// <summary>
/// 订阅
/// </summary>
[Description("订阅")]
SUBSCRIBE = 1,

/// <summary>
/// 发布和订阅
/// </summary>
[Description("发布和订阅")]
PUBLISHANDSUBSCRIBE = 2
}
}

+ 1
- 1
BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs View File

@@ -38,7 +38,7 @@ namespace BPA.SAAS.Manage.Core.Product
/// <summary>
/// 功能类型 0属性1服务2事件
/// </summary>
public int Type { get; set; }
public FunctionTypeEnum Type { get; set; }
/// <summary>
/// 数据类型
/// </summary>


+ 4
- 2
BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs View File

@@ -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
/// <summary>
/// TopicsType类型 0发布 1订阅 2发布和订阅
/// </summary>
public int TopicsType { get; set; }
public TopicsTypeEnum TopicsType { get; set; }
/// <summary>
/// 描述
/// </summary>
@@ -29,5 +30,6 @@ namespace BPA.SAAS.Manage.Core.Product
/// 是否默认Topics
/// </summary>
public bool IsDefault { get; set; }
public string Name { get; set; }
}
}

Loading…
Cancel
Save