@@ -14,7 +14,8 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction | |||||
public string Name { get; set; } | public string Name { get; set; } | ||||
public string Type { get; set; } | public string Type { get; set; } | ||||
public string Vesion { get; set; } | public string Vesion { get; set; } | ||||
public string DeviceTypeKey { get; set; } | |||||
public string ProductVesionId { get; set; } | |||||
public string ProductId { get; set; } | |||||
public CommonStatus? Status { get; set; } | public CommonStatus? Status { get; set; } | ||||
} | } | ||||
} | } |
@@ -22,5 +22,6 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductTopics | |||||
/// </summary> | /// </summary> | ||||
public string Description { get; set; } | public string Description { get; set; } | ||||
public string ProductId { get; set; } | public string ProductId { get; set; } | ||||
public string ProductVesionId { get; set; } | |||||
} | } | ||||
} | } |
@@ -10,6 +10,9 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductTopics | |||||
public class ProductTopicsQueryInputDto : PageInputBase | public class ProductTopicsQueryInputDto : PageInputBase | ||||
{ | { | ||||
public int? TopicsType { get; set; } | public int? TopicsType { get; set; } | ||||
public string Topics { get; set; } | |||||
public string ProductId { get; set; } | public string ProductId { get; set; } | ||||
public string ProductVesionId { get; set; } | |||||
public bool IsDefault { get; set; } | |||||
} | } | ||||
} | } |
@@ -5,6 +5,7 @@ using BPA.SAAS.Manage.Comm.Enum; | |||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.Device; | using BPA.SAAS.Manage.Core.Device; | ||||
using BPA.SAAS.Manage.Core.Product; | using BPA.SAAS.Manage.Core.Product; | ||||
using Microsoft.AspNetCore.Server.IISIntegration; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -55,14 +56,57 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
public async Task<bool> AddDeviceVesionAsync(DeviceVesionBaseDto inputDto) | public async Task<bool> AddDeviceVesionAsync(DeviceVesionBaseDto inputDto) | ||||
{ | { | ||||
var res = await _db.Insertable(new BPA_ProductVesion | |||||
try | |||||
{ | { | ||||
Vesion = inputDto.Vesion, | |||||
ProductId = inputDto.ProductId, | |||||
TemplatePath = inputDto.TemplatePath, | |||||
Status = CommonStatus.ENABLE | |||||
}).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
_db.Ado.BeginTran(); | |||||
var res = await _db.Insertable(new BPA_ProductVesion | |||||
{ | |||||
Vesion = inputDto.Vesion, | |||||
ProductId = inputDto.ProductId, | |||||
TemplatePath = inputDto.TemplatePath, | |||||
Status = CommonStatus.ENABLE | |||||
}).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||||
var Product = _db.Queryable<BPA_Product>().Where(x => x.Id == inputDto.ProductId).First(); | |||||
List<BPA_ProductTopics> list = new(); | |||||
var goodspushtopics = new BPA_ProductTopics() | |||||
{ | |||||
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/goodspush", | |||||
TopicsType = 2, | |||||
Description = "商品数据下发", | |||||
ProductId = inputDto.ProductId, | |||||
ProductVesionId = res.Id, | |||||
IsDefault = true | |||||
}; | |||||
var batchingpushtopics = new BPA_ProductTopics() | |||||
{ | |||||
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/batvhingpush", | |||||
TopicsType = 2, | |||||
Description = "物料数据下发", | |||||
ProductId = inputDto.ProductId, | |||||
ProductVesionId = res.Id, | |||||
IsDefault = true | |||||
}; | |||||
var chnologypushtopics = new BPA_ProductTopics() | |||||
{ | |||||
Topics = " /" + Product.Key + "/" + inputDto.Vesion + "/${deviceKey}/defaul/chnologypush", | |||||
TopicsType = 2, | |||||
Description = "工艺数据下发", | |||||
ProductId = inputDto.ProductId, | |||||
ProductVesionId = res.Id, | |||||
IsDefault = true | |||||
}; | |||||
list.Add(goodspushtopics); | |||||
list.Add(batchingpushtopics); | |||||
list.Add(chnologypushtopics); | |||||
await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||||
_db.Ado.CommitTran(); | |||||
return res != null; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
_db.Ado.RollbackTran(); | |||||
throw Oops.Oh("添加失败,失败信息:"+e.Message); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 删除 | /// 删除 | ||||
@@ -71,16 +115,35 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> DelDeviceVesionAsync(List<string> inputList) | public async Task<bool> DelDeviceVesionAsync(List<string> inputList) | ||||
{ | { | ||||
var data = await _db.Queryable<BPA_DeviceInfo>().Where(x => inputList.Contains(x.ProductVersionId)).ToListAsync(); | |||||
if (data.Count > 0) | |||||
try | |||||
{ | { | ||||
throw Oops.Oh("当前设备类型已使用,无法删除"); | |||||
} | |||||
var datas = await _db.Queryable<BPA_ProductVesion>() | |||||
.Where(x => inputList.Contains(x.Id)) | |||||
_db.Ado.BeginTran(); | |||||
var data = await _db.Queryable<BPA_DeviceInfo>().Where(x => inputList.Contains(x.ProductVersionId)).ToListAsync(); | |||||
if (data.Count > 0) | |||||
{ | |||||
throw Oops.Oh("当前版本已有设备使用,无法删除"); | |||||
} | |||||
var datas = await _db.Queryable<BPA_ProductVesion>() | |||||
.Where(x => inputList.Contains(x.Id)) | |||||
.ToListAsync(); | |||||
var ProductFunctions = await _db.Queryable<BPA_ProductFunction>() | |||||
.Where(x => inputList.Contains(x.DeviceVersionKey)) | |||||
.ToListAsync(); | |||||
var ProductTopics = await _db.Queryable<BPA_ProductTopics>() | |||||
.Where(x => inputList.Contains(x.ProductVesionId)) | |||||
.ToListAsync(); | .ToListAsync(); | ||||
_db.Deleteable(datas).ExecuteCommand(); | |||||
return true; | |||||
_db.Deleteable(ProductTopics).ExecuteCommand();//删除相关topic | |||||
_db.Deleteable(ProductFunctions).ExecuteCommand();//删除相关服务和功能 | |||||
var res=await _db.Deleteable(datas).ExecuteCommandAsync(); | |||||
_db.Ado.CommitTran(); | |||||
return res>0; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
_db.Ado.RollbackTran(); | |||||
throw Oops.Oh("删除失败,失败信息:"+e.Message); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 修改 | /// 修改 | ||||
@@ -33,7 +33,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
{ | { | ||||
RefAsync<int> total = 0; | RefAsync<int> total = 0; | ||||
var res = await _db.Queryable<BPA_ProductFunction, BPA_ProductVesion>((x, b) => new JoinQueryInfos(JoinType.Left, b.Id == x.DeviceVersionKey)) | var res = await _db.Queryable<BPA_ProductFunction, BPA_ProductVesion>((x, b) => new JoinQueryInfos(JoinType.Left, b.Id == x.DeviceVersionKey)) | ||||
.Where((x,b)=>b.ProductId == inputDto.DeviceTypeKey) | |||||
.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.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==Convert.ToInt32(inputDto.Type)) | ||||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (x, b) => x.DeviceVersionKey == inputDto.Vesion) | .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (x, b) => x.DeviceVersionKey == inputDto.Vesion) | ||||
@@ -29,8 +29,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||||
public async Task<PageUtil> GetProductTopicsPage(ProductTopicsQueryInputDto inputDto) | public async Task<PageUtil> GetProductTopicsPage(ProductTopicsQueryInputDto inputDto) | ||||
{ | { | ||||
var total = new RefAsync<int>(); | var total = new RefAsync<int>(); | ||||
var data = await _db.Queryable<BPA_ProductTopics>().Where(x=>x.ProductId== inputDto.ProductId) | |||||
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==Convert.ToInt32(inputDto.TopicsType)) | ||||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Topics), x => x.Topics == inputDto.Topics) | |||||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | .OrderBy(x => x.CreateAt, OrderByType.Desc) | ||||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | ||||
@@ -24,6 +24,10 @@ namespace BPA.SAAS.Manage.Core.Product | |||||
/// </summary> | /// </summary> | ||||
public string Description { get; set; } | public string Description { get; set; } | ||||
public string ProductId { get; set; } | public string ProductId { get; set; } | ||||
//public string GroupId { get; set; } | |||||
public string ProductVesionId { get; set; } | |||||
/// <summary> | |||||
/// 是否默认Topics | |||||
/// </summary> | |||||
public bool IsDefault { get; set; } | |||||
} | } | ||||
} | } |