Browse Source

Merge branch 'master' into groupmealmanage

groupmealmanage
zhaoy 10 months ago
parent
commit
48bf7ec8cf
7 changed files with 92 additions and 19 deletions
  1. +2
    -1
      BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionPageBase.cs
  2. +1
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/ProductTopics/ProductTopicsBaseDto.cs
  3. +3
    -0
      BPA.SAAS.Manage.Application/Device/Dtos/ProductTopics/ProductTopicsQueryInputDto.cs
  4. +78
    -15
      BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs
  5. +1
    -1
      BPA.SAAS.Manage.Application/Device/Services/ProductFunctionService.cs
  6. +2
    -1
      BPA.SAAS.Manage.Application/Device/Services/ProductTopicsService.cs
  7. +5
    -1
      BPA.SAAS.Manage.Core/Product/BPA_ProductTopics.cs

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

@@ -14,7 +14,8 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction
public string Name { get; set; }
public string Type { 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; }
}
}

+ 1
- 0
BPA.SAAS.Manage.Application/Device/Dtos/ProductTopics/ProductTopicsBaseDto.cs View File

@@ -22,5 +22,6 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductTopics
/// </summary>
public string Description { get; set; }
public string ProductId { get; set; }
public string ProductVesionId { get; set; }
}
}

+ 3
- 0
BPA.SAAS.Manage.Application/Device/Dtos/ProductTopics/ProductTopicsQueryInputDto.cs View File

@@ -10,6 +10,9 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductTopics
public class ProductTopicsQueryInputDto : PageInputBase
{
public int? TopicsType { get; set; }
public string Topics { get; set; }
public string ProductId { get; set; }
public string ProductVesionId { get; set; }
public bool IsDefault { get; set; }
}
}

+ 78
- 15
BPA.SAAS.Manage.Application/Device/Services/DeviceVesionService.cs View File

@@ -5,6 +5,7 @@ using BPA.SAAS.Manage.Comm.Enum;
using BPA.SAAS.Manage.Core.Base;
using BPA.SAAS.Manage.Core.Device;
using BPA.SAAS.Manage.Core.Product;
using Microsoft.AspNetCore.Server.IISIntegration;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -55,14 +56,57 @@ namespace BPA.SAAS.Manage.Application.Device.Services
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>
/// 删除
@@ -71,16 +115,35 @@ namespace BPA.SAAS.Manage.Application.Device.Services
/// <returns></returns>
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();
_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>
/// 修改


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

@@ -33,7 +33,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services
{
RefAsync<int> total = 0;
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.Type), (x, b) => x.Type==Convert.ToInt32(inputDto.Type))
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.Vesion), (x, b) => x.DeviceVersionKey == inputDto.Vesion)


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

@@ -29,8 +29,9 @@ namespace BPA.SAAS.Manage.Application.Device.Services
public async Task<PageUtil> GetProductTopicsPage(ProductTopicsQueryInputDto inputDto)
{
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(!string.IsNullOrWhiteSpace(inputDto.Topics), x => x.Topics == inputDto.Topics)
.OrderBy(x => x.CreateAt, OrderByType.Desc)
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total);



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

@@ -24,6 +24,10 @@ namespace BPA.SAAS.Manage.Core.Product
/// </summary>
public string Description { 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; }
}
}

Loading…
Cancel
Save