@@ -0,0 +1,14 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos | |||||
{ | |||||
public class GoodsEnergyConfigQuDto | |||||
{ | |||||
public string GoodsId { get; set; } | |||||
public string Name { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,23 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos | |||||
{ | |||||
public class GoodsEnergyConfigVuewDto | |||||
{ | |||||
public string Id { get; set; } | |||||
public string GoodsId { get; set; } | |||||
public string Name { get; set; } | |||||
//public string Uint { get; set; } | |||||
public List<GoodsEnergyConfigDetailsView> Details { get; set; } | |||||
} | |||||
public class GoodsEnergyConfigDetailsView | |||||
{ | |||||
public string Id { get; set; } | |||||
public string Key { get; set; } | |||||
public string Value { get; set; } | |||||
} | |||||
} |
@@ -2,6 +2,7 @@ | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Services; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig; | |||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using Microsoft.AspNetCore.Components.Forms; | using Microsoft.AspNetCore.Components.Forms; | ||||
using Org.BouncyCastle.Crypto; | using Org.BouncyCastle.Crypto; | ||||
@@ -181,5 +182,15 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods | |||||
{ | { | ||||
return await _goodsService.DelGoodsUint(dto); | return await _goodsService.DelGoodsUint(dto); | ||||
} | } | ||||
/// <summary> | |||||
/// 查询商品能量配置 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
[HttpPost("/api/ExternalPlatform/Goods/GetGoodsEnergyConfig")] | |||||
public async Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto) | |||||
{ | |||||
return await _goodsService.GetGoodsEnergyConfigPage(dto); | |||||
} | |||||
} | } | ||||
} | } |
@@ -6,6 +6,7 @@ using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos; | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Dtos; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.ThirdpartyPush.Services; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods; | using BPA.SAAS.Manage.Application.DataBase.Dtos.Goods; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig; | |||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology; | using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsType; | using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsType; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
@@ -561,6 +562,36 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services | |||||
} | } | ||||
} | } | ||||
/// <summary> | |||||
/// 查询商品能量配置 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
public async Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto) | |||||
{ | |||||
List<IConditionalModel> conModels = new List<IConditionalModel>(); | |||||
//string groupId = App.User.FindFirst(ClaimConst.GroupId)?.Value; | |||||
if (!string.IsNullOrEmpty(dto.Name)) | |||||
{ | |||||
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name }); | |||||
} | |||||
if (!string.IsNullOrEmpty(dto.GoodsId)) | |||||
{ | |||||
conModels.Add(new ConditionalModel() { FieldName = "GoodsId", ConditionalType = ConditionalType.Like, FieldValue = dto.GoodsId }); | |||||
} | |||||
int total = new RefAsync<int>(); | |||||
var res = await SqlSugarDb.Db.Queryable<BPA_GoodsEnergyConfig>() | |||||
.Where(conModels) | |||||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | |||||
.Select(x=>new GoodsEnergyConfigVuewDto() { Id=x.Id,Name=x.Name, GoodsId =x.GoodsId}) | |||||
.Mapper(x => | |||||
{ | |||||
var data=SqlSugarDb.Db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == x.Id).Select(it=>new GoodsEnergyConfigDetailsView() { Id=it.Id.SelectAll()}).ToList(); | |||||
x.Details = data; | |||||
}) | |||||
.ToListAsync(); | |||||
return res; | |||||
} | |||||
private string GetNumber2(int Length = 10) | private string GetNumber2(int Length = 10) | ||||
{ | { | ||||
byte[] buffer = Guid.NewGuid().ToByteArray(); | byte[] buffer = Guid.NewGuid().ToByteArray(); | ||||
@@ -1,5 +1,6 @@ | |||||
using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto; | ||||
using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Dtos; | ||||
using BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig; | |||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -61,5 +62,11 @@ namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.Goods.Services | |||||
Task<bool> AddGoodsUint(List<GoodsUintInsertDto> dto); | Task<bool> AddGoodsUint(List<GoodsUintInsertDto> dto); | ||||
Task<bool> UpdateGoodsUint(GoodsUintUpdateDto dto); | Task<bool> UpdateGoodsUint(GoodsUintUpdateDto dto); | ||||
Task<bool> DelGoodsUint(GoodsUintDelDto dto); | Task<bool> DelGoodsUint(GoodsUintDelDto dto); | ||||
/// <summary> | |||||
/// 查询商品能量配置 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
Task<List<GoodsEnergyConfigVuewDto>> GetGoodsEnergyConfigPage(GoodsEnergyConfigQuDto dto); | |||||
} | } | ||||
} | } |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig | |||||
{ | |||||
public class GoodsEnergyConfigDetailsViewDto | |||||
{ | |||||
public string Id { get; set; } | |||||
public string Key { get; set; } | |||||
public string Value { get; set; } | |||||
} | |||||
} |
@@ -12,5 +12,12 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig | |||||
public string GoodsId { get; set; } | public string GoodsId { get; set; } | ||||
public string Name { get; set; } | public string Name { get; set; } | ||||
public string Uint { get; set; } | public string Uint { get; set; } | ||||
public List<GoodsEnergyConfigDetails> Details { get; set; } | |||||
} | |||||
public class GoodsEnergyConfigDetails | |||||
{ | |||||
public string Key { get; set; } | |||||
public string Value { get; set; } | |||||
} | } | ||||
} | } |
@@ -9,6 +9,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsEnergyConfig | |||||
{ | { | ||||
public class GoodsEnergyConfigQueryDto: PageInputBase | public class GoodsEnergyConfigQueryDto: PageInputBase | ||||
{ | { | ||||
public string GoodsId { get; set; } | |||||
public string Name { get; set; } | public string Name { get; set; } | ||||
} | } | ||||
} | } |
@@ -57,15 +57,16 @@ namespace BPA.SAAS.Manage.Application.DataBase | |||||
{ | { | ||||
return await _energyConfigService.DelGoodsEnergyConfig(Id); | return await _energyConfigService.DelGoodsEnergyConfig(Id); | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 分页查询 | |||||
/// 查询详情 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="dto"></param> | |||||
/// <param name="goodsenergyconfigId"></param> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpPost("/api/goodsenergyconfig/getgoodsenergyconfigdetailspage")] | |||||
public async Task<PageUtil> GetGoodsEnergyConfigDetailsPage(GoodsEnergyConfigDetailsQueryDto dto) | |||||
[HttpGet("/api/goodsenergyconfig/getgoodsenergyconfigdetailslist")] | |||||
public async Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId) | |||||
{ | { | ||||
return await _energyConfigService.GetGoodsEnergyConfigDetailsPage(dto); | |||||
return await _energyConfigService.GetGoodsEnergyConfigDetailsList(goodsenergyconfigId); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 添加 | /// 添加 | ||||
@@ -36,11 +36,11 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface | |||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<bool> DelGoodsEnergyConfig(string Id); | Task<bool> DelGoodsEnergyConfig(string Id); | ||||
/// <summary> | /// <summary> | ||||
/// 分页查询 | |||||
/// 查询详情 | |||||
/// </summary> | /// </summary> | ||||
/// <param name="dto"></param> | |||||
/// <param name="goodsenergyconfigId"></param> | |||||
/// <returns></returns> | /// <returns></returns> | ||||
Task<PageUtil> GetGoodsEnergyConfigDetailsPage(GoodsEnergyConfigDetailsQueryDto dto); | |||||
Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId); | |||||
/// <summary> | /// <summary> | ||||
/// 添加 | /// 添加 | ||||
/// </summary> | /// </summary> | ||||
@@ -5,6 +5,7 @@ using BPA.SAAS.Manage.Comm.Const; | |||||
using BPA.SAAS.Manage.Comm.Enum; | using BPA.SAAS.Manage.Comm.Enum; | ||||
using BPA.SAAS.Manage.Core.Base; | using BPA.SAAS.Manage.Core.Base; | ||||
using BPA.SAAS.Manage.Core.DataBase; | using BPA.SAAS.Manage.Core.DataBase; | ||||
using NPOI.POIFS.Storage; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -33,6 +34,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
{ | { | ||||
conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name }); | conModels.Add(new ConditionalModel() { FieldName = "Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name }); | ||||
} | } | ||||
if (!string.IsNullOrEmpty(dto.GoodsId)) | |||||
{ | |||||
conModels.Add(new ConditionalModel() { FieldName = "GoodsId", ConditionalType = ConditionalType.Like, FieldValue = dto.GoodsId }); | |||||
} | |||||
int total = new RefAsync<int>(); | int total = new RefAsync<int>(); | ||||
var res = await _db.Queryable<BPA_GoodsEnergyConfig>() | var res = await _db.Queryable<BPA_GoodsEnergyConfig>() | ||||
.Where(conModels) | .Where(conModels) | ||||
@@ -53,16 +58,39 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> AddGoodsEnergyConfig(GoodsEnergyConfigDto dto) | public async Task<bool> AddGoodsEnergyConfig(GoodsEnergyConfigDto dto) | ||||
{ | { | ||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name); | |||||
if (resEntity != null) throw Oops.Oh("配置名称已存在"); | |||||
var newType = new BPA_GoodsEnergyConfig | |||||
try | |||||
{ | { | ||||
GoodsId = dto.GoodsId, | |||||
Name = dto.Name, | |||||
Uint = dto.Uint, | |||||
}; | |||||
var res = await _db.Insertable(newType).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
_db.Ado.BeginTran(); | |||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name); | |||||
if (resEntity != null) throw Oops.Oh("配置名称已存在"); | |||||
var newType = new BPA_GoodsEnergyConfig | |||||
{ | |||||
GoodsId = dto.GoodsId, | |||||
Name = dto.Name, | |||||
Uint = dto.Uint, | |||||
}; | |||||
var model = await _db.Insertable(newType).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||||
List<BPA_GoodsEnergyConfigDetails> list = new(); | |||||
for (int i = 0; i < dto.Details.Count; i++) | |||||
{ | |||||
var model1 = new BPA_GoodsEnergyConfigDetails | |||||
{ | |||||
GoodsenergyconfigId = model.Id, | |||||
Key = dto.Details[i].Key, | |||||
Value = dto.Details[i].Value, | |||||
}; | |||||
list.Add(model1); | |||||
} | |||||
var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||||
_db.Ado.CommitTran(); | |||||
return res > 0; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
_db.Ado.RollbackTran(); | |||||
throw Oops.Oh("系统异常,异常信息:"+ e.Message); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 更新 | /// 更新 | ||||
@@ -71,15 +99,40 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> UpdateGoodsEnergyConfig(GoodsEnergyConfigDto dto) | public async Task<bool> UpdateGoodsEnergyConfig(GoodsEnergyConfigDto dto) | ||||
{ | { | ||||
// 查询数据库中是否存在未删除的商品类型 | |||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == dto.Id); | |||||
if (null == resEntity) throw Oops.Oh("配置不存在"); | |||||
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.Id!= dto.Id); | |||||
if (resEntity1 != null) throw Oops.Oh("配置名称已存在"); | |||||
resEntity.Name = dto.Name; | |||||
resEntity.Uint = dto.Uint; | |||||
var res = await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
try | |||||
{ | |||||
_db.Ado.BeginTran(); | |||||
// 查询数据库中是否存在未删除的商品类型 | |||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == dto.Id); | |||||
if (null == resEntity) throw Oops.Oh("配置不存在"); | |||||
var resEntity1 = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Name == dto.Name && it.Id != dto.Id); | |||||
if (resEntity1 != null) throw Oops.Oh("配置名称已存在"); | |||||
resEntity.Name = dto.Name; | |||||
resEntity.Uint = dto.Uint; | |||||
await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); | |||||
var model = _db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == dto.Id).ToList(); | |||||
if (model.Count > 0) await _db.Deleteable(model).ExecuteCommandAsync(); | |||||
List<BPA_GoodsEnergyConfigDetails> list = new(); | |||||
for (int i = 0; i < dto.Details.Count; i++) | |||||
{ | |||||
var model1 = new BPA_GoodsEnergyConfigDetails | |||||
{ | |||||
GoodsenergyconfigId = dto.Id, | |||||
Key = dto.Details[i].Key, | |||||
Value = dto.Details[i].Value, | |||||
}; | |||||
list.Add(model1); | |||||
} | |||||
var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); | |||||
_db.Ado.CommitTran(); | |||||
return res > 0; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
_db.Ado.RollbackTran(); | |||||
throw Oops.Oh("系统异常,异常信息:" + e.Message); | |||||
} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 删除 | /// 删除 | ||||
@@ -88,34 +141,40 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||||
/// <returns></returns> | /// <returns></returns> | ||||
public async Task<bool> DelGoodsEnergyConfig(string Id) | public async Task<bool> DelGoodsEnergyConfig(string Id) | ||||
{ | { | ||||
// 查询数据库中是否存在未删除的商品类型 | |||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == Id); | |||||
if (resEntity==null) | |||||
try | |||||
{ | { | ||||
throw Oops.Oh("配置不存在"); | |||||
_db.Ado.BeginTran(); | |||||
// 查询数据库中是否存在未删除的商品类型 | |||||
var resEntity = _db.Queryable<BPA_GoodsEnergyConfig>().First(it => it.Id == Id); | |||||
if (resEntity == null) | |||||
{ | |||||
throw Oops.Oh("配置不存在"); | |||||
} | |||||
var model = _db.Queryable<BPA_GoodsEnergyConfigDetails>().Where(it => it.GoodsenergyconfigId == Id).ToList(); | |||||
if (model.Count > 0) await _db.Deleteable(model).ExecuteCommandAsync(); | |||||
var res = await _db.Deleteable(resEntity).ExecuteCommandAsync(); | |||||
_db.Ado.CommitTran(); | |||||
return res > 0; | |||||
} | } | ||||
var res = await _db.Deleteable(resEntity).ExecuteCommandAsync(); | |||||
return res > 0; | |||||
catch (Exception e) | |||||
{ | |||||
_db.Ado.RollbackTran(); | |||||
throw Oops.Oh("系统异常,异常信息:" + e.Message); | |||||
} | |||||
} | } | ||||
/// <summary> | |||||
/// 分页查询 | |||||
/// </summary> | |||||
/// <param name="dto"></param> | |||||
/// <returns></returns> | |||||
public async Task<PageUtil> GetGoodsEnergyConfigDetailsPage(GoodsEnergyConfigDetailsQueryDto dto) | |||||
public async Task<List<GoodsEnergyConfigDetailsViewDto>> GetGoodsEnergyConfigDetailsList(string goodsenergyconfigId) | |||||
{ | { | ||||
int total = new RefAsync<int>(); | int total = new RefAsync<int>(); | ||||
var res = await _db.Queryable<BPA_GoodsEnergyConfigDetails>() | var res = await _db.Queryable<BPA_GoodsEnergyConfigDetails>() | ||||
.Where(x=>x.GoodsenergyconfigId== goodsenergyconfigId) | |||||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | .OrderBy(a => a.CreateAt, OrderByType.Desc) | ||||
.ToPageListAsync(dto.Current, dto.PageSize, total); | |||||
PageUtil util = new PageUtil() | |||||
{ | |||||
Total = total, | |||||
Data = res | |||||
}; | |||||
return util; | |||||
.Select(x => new GoodsEnergyConfigDetailsViewDto() { Id=x.Id,Key=x.Key,Value=x.Value}) | |||||
.ToListAsync(); | |||||
return res; | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 添加 | /// 添加 | ||||