@@ -26,5 +26,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology | |||
public bool IsBatch { get; set; } = false; | |||
public string GoodsId { get; set; } | |||
public string DeviceId { get; set; } | |||
public string WarehousrTemplateId { get; set; } | |||
} | |||
} |
@@ -9,6 +9,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology | |||
public class GoodsTechnologyActionListView | |||
{ | |||
public string DeviceId { get; set; } | |||
public string WarehousrTemplateId { get; set; } | |||
public string DeviceName { get; set; } | |||
public List<GoodsTechnologyActionView> Data { get; set; } | |||
} | |||
@@ -41,5 +42,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsTechnology | |||
public int Sort { get; set; } | |||
public string GoodsId { get; set; } | |||
public string DeviceId { get; set; } | |||
public string WarehousrTemplateId { get; set; } | |||
} | |||
} |
@@ -48,6 +48,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
StepName = inputDto[i].StepName, | |||
ChnologyId = inputDto[i].ChnologyId, | |||
CreateAt = DateTime.Now, | |||
WarehousrTemplateId = inputDto[i].WarehousrTemplateId, | |||
IsDeleted = 0, | |||
GoodsAttributeId = inputDto[i].GoodsAttributeId, | |||
Sort = string.IsNullOrWhiteSpace(inputDto[i].Sort.ToString()) ? maxsort + (i + 1) : Convert.ToInt32(inputDto[i].Sort.ToString()), | |||
@@ -91,6 +92,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
ChnologyId = inputDto[i].ChnologyId, | |||
CreateAt = DateTime.Now, | |||
IsDeleted = 0, | |||
WarehousrTemplateId = inputDto[i].WarehousrTemplateId, | |||
GoodsAttributeId = inputDto[i].GoodsAttributeId, | |||
Sort = string.IsNullOrWhiteSpace(inputDto[i].Sort.ToString()) ? maxsort + (i + 1) : Convert.ToInt32(inputDto[i].Sort.ToString()), | |||
IsBatch = inputDto[i].IsBatch, | |||
@@ -124,6 +126,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
var Devicelist = await _db.Queryable<BPA_DeviceInfo>().ToListAsync(); | |||
var GoodsAttributeValue = await _db.Queryable<BPA_GoodsAttributeValue>().ToListAsync(); | |||
var sf = list.GroupBy(x => x.GoodsAttributeId).ToList(); | |||
var sf1 = list.GroupBy(x => x.WarehousrTemplateId).ToList(); | |||
for (int i = 0; i < sf.Count; i++) | |||
{ | |||
var sd = GoodsAttributeValue?.Where(x => sf[i].Key.Contains(x.Id)).Select(x => x.AttributeValue).ToArray(); | |||
@@ -134,30 +137,14 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
GoodsTechnologyActionListView item = new() | |||
{ | |||
DeviceId = s[t].Key, | |||
WarehousrTemplateId = sf1[t].Key, | |||
DeviceName = Devicelist?.FirstOrDefault(x => x.Id == s[t].Key).DeviceName+ "【"+ nane+"】", | |||
Data = s[t].AsQueryable().ToList(), | |||
}; | |||
goodsTechnologyActionListViews.Add(item); | |||
} | |||
//GoodsTechnologyActionListView item = new() | |||
//{ | |||
// DeviceId = sf[i].Key, | |||
// DeviceName = Devicelist?.FirstOrDefault(x => x.Id == sf[i].Key).DeviceName, | |||
// Data = sf[i].AsQueryable().ToList(), | |||
//}; | |||
//goodsTechnologyActionListViews.Add(item); | |||
} | |||
//var s = list.GroupBy(x => x.DeviceId).ToList(); | |||
//for (int i = 0; i < s.Count; i++) | |||
//{ | |||
// GoodsTechnologyActionListView item = new() | |||
// { | |||
// DeviceId = s[i].Key, | |||
// DeviceName = Devicelist?.FirstOrDefault(x => x.Id == s[i].Key).DeviceName, | |||
// Data = s[i].AsQueryable().ToList(), | |||
// }; | |||
// goodsTechnologyActionListViews.Add(item); | |||
//} | |||
return goodsTechnologyActionListViews; | |||
} | |||
public async Task<bool> DeleteGoodsTechnologyAction(string id) | |||
@@ -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.Device.Dtos.WarehouseTemplate | |||
{ | |||
public class WarehouseTemplatDto | |||
{ | |||
public string Id { get; set; } | |||
public string DeviceId { get; set; } | |||
public string TemplateName { get; set; } | |||
public List<WarehousePostion> WarehousePostionData { get; set; } | |||
} | |||
public class WarehousePostion | |||
{ | |||
public string Id { get; set; } | |||
public string TemplateId { get; set; } | |||
public string Code { get; set; } | |||
public string BatchingId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using BPA.SAAS.Manage.Core.Base; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate | |||
{ | |||
public class WarehouseTemplateQueryInputDto: PageInputBase | |||
{ | |||
public string DeviceName { get; set; } | |||
public string TemplateName { get; set; } | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
using BPA.SAAS.Manage.Core.Device; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate | |||
{ | |||
public class WarehouseTemplateView | |||
{ | |||
public string Id { get; set; } | |||
public string DeviceId { get; set; } | |||
public string DeviceName{ get; set; } | |||
public string TemplateName { get; set; } | |||
public DateTime CreateAt { get; set; } | |||
public int ProductNumber{ get; set; } | |||
public string ProductUrl { get; set; } | |||
public List<BPA_WarehousePostion> WarehousePostion { get; set; } | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.Device.Interface | |||
{ | |||
public interface IWarehouseTemplateService | |||
{ | |||
Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryInputDto inputDto); | |||
Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(string deviceId); | |||
Task<bool> AddWarehouseTemplate(WarehouseTemplatDto inputDto); | |||
Task<bool> DeWarehouseTemplate(List<string> inputList); | |||
Task<bool> UpdateWarehouseTemplate(WarehouseTemplatDto inputDto); | |||
} | |||
} |
@@ -77,6 +77,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||
data.ForEach(x => | |||
{ | |||
x.Vesion = _db.Queryable<BPA_ProductVesion>().Where(s => s.Id == x.ProductVersionId).First()?.Vesion; | |||
x.ProductNumber = _db.Queryable<BPA_ProductVesion>().Where(s => s.Id == x.ProductVersionId).First()?.ProductNumber; | |||
x.PrductKey = _db.Queryable<BPA_Product>().Where(s => s.Id == x.ProductId).First()?.Key; | |||
}); | |||
return data; | |||
@@ -73,6 +73,7 @@ namespace BPA.SAAS.Manage.Application.Device.Services | |||
public async Task<List<TechnologyView>> GetTechnologyList(string deviceId) | |||
{ | |||
var device= _db.Queryable<BPA_DeviceInfo>().Where(x=>x.Id== deviceId).First(); | |||
if (device == null) return new List<TechnologyView>(); | |||
var data = await _db.Queryable<BPA_Technology>().Where(x=>x.DeviceVersionId== device.ProductVersionId).Select(a => new TechnologyView | |||
{ | |||
Id = a.Id, | |||
@@ -0,0 +1,183 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||
using BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate; | |||
using BPA.SAAS.Manage.Application.Device.Interface; | |||
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 NPOI.XSSF.UserModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.Device.Services | |||
{ | |||
public class WarehouseTemplateService : IWarehouseTemplateService, ITransient | |||
{ | |||
ISqlSugarClient _db; | |||
public WarehouseTemplateService(ISqlSugarClient db) | |||
{ | |||
_db = db; | |||
} | |||
public async Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryInputDto inputDto) | |||
{ | |||
var total = new RefAsync<int>(); | |||
var data = await _db.Queryable<BPA_WarehouseTemplate,BPA_DeviceInfo,BPA_ProductVesion>((a,b,c) => new JoinQueryInfos(JoinType.Left,a.DeviceId==b.Id, JoinType.Left, b.ProductVersionId == c.Id)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.TemplateName), (a, b, c) => a.TemplateName.Contains(inputDto.TemplateName)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.DeviceName), (a, b, c) => a.DeviceId.Contains(inputDto.DeviceName)) | |||
.Select((a,b,c)=>new WarehouseTemplateView | |||
{ | |||
Id=a.Id, | |||
DeviceId=a.DeviceId, | |||
DeviceName=b.DeviceName, | |||
TemplateName =a.TemplateName, | |||
CreateAt =a.CreateAt, | |||
ProductNumber=c.ProductNumber, | |||
ProductUrl=c.ProductUrl | |||
}) | |||
.Mapper(x => | |||
{ | |||
x.WarehousePostion= _db.Queryable <BPA_WarehousePostion>().Where(t=>t.TemplateId==x.Id).ToList(); | |||
}) | |||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | |||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | |||
return new PageUtil() | |||
{ | |||
Data = data, | |||
Total = total | |||
}; | |||
} | |||
public async Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(string deviceId) | |||
{ | |||
var total = new RefAsync<int>(); | |||
var data = await _db.Queryable<BPA_WarehouseTemplate, BPA_DeviceInfo, BPA_ProductVesion>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.DeviceId == b.Id, JoinType.Left, b.ProductVersionId == c.Id)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(deviceId), (a, b, c) => a.DeviceId.Contains(deviceId)) | |||
.Select((a, b, c) => new WarehouseTemplateView | |||
{ | |||
Id = a.Id, | |||
DeviceId = a.DeviceId, | |||
DeviceName = b.DeviceName, | |||
TemplateName = a.TemplateName, | |||
CreateAt = a.CreateAt, | |||
ProductNumber = c.ProductNumber, | |||
ProductUrl = c.ProductUrl | |||
}) | |||
.Mapper(x => | |||
{ | |||
x.WarehousePostion = _db.Queryable<BPA_WarehousePostion>().Where(t => t.TemplateId == x.Id).ToList(); | |||
}) | |||
.OrderBy(a => a.CreateAt, OrderByType.Desc) | |||
.ToListAsync(); | |||
return data; | |||
} | |||
/// <summary> | |||
/// 新增 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<bool> AddWarehouseTemplate(WarehouseTemplatDto inputDto) | |||
{ | |||
try | |||
{ | |||
_db.Ado.BeginTran(); | |||
var check = _db.Queryable<BPA_WarehouseTemplate>().Where(x => x.TemplateName == inputDto.TemplateName).Any(); | |||
if (check) throw Oops.Oh("模板名称不能重复"); | |||
var res = await _db.Insertable(new BPA_WarehouseTemplate | |||
{ | |||
DeviceId = inputDto.DeviceId, | |||
TemplateName = inputDto.TemplateName, | |||
}).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
List<BPA_WarehousePostion> list = new(); | |||
for (int i = 0; i < inputDto.WarehousePostionData.Count; i++) | |||
{ | |||
var tem = new BPA_WarehousePostion | |||
{ | |||
TemplateId = res.Id, | |||
Code = inputDto.WarehousePostionData[i].Code, | |||
BatchingId = inputDto.WarehousePostionData[i].BatchingId, | |||
}; | |||
list.Add(tem); | |||
} | |||
var res1 = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
_db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception e) | |||
{ | |||
_db.Ado.RollbackTran(); | |||
throw Oops.Oh("添加失败"); | |||
} | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <param name="inputList"></param> | |||
/// <returns></returns> | |||
public async Task<bool> DeWarehouseTemplate(List<string> inputList) | |||
{ | |||
try | |||
{ | |||
_db.Ado.BeginTran(); | |||
var datas = await _db.Queryable<BPA_WarehouseTemplate>() | |||
.Where(x => inputList.Contains(x.Id)) | |||
.ToListAsync(); | |||
var datas1 = await _db.Queryable<BPA_WarehousePostion>() | |||
.Where(x => inputList.Contains(x.TemplateId)) | |||
.ToListAsync(); | |||
_db.Deleteable(datas).ExecuteCommand(); | |||
_db.Deleteable(datas1).ExecuteCommand(); | |||
_db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception) | |||
{ | |||
_db.Ado.RollbackTran(); | |||
throw Oops.Oh("删除失败"); | |||
} | |||
} | |||
/// <summary> | |||
/// 修改 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateWarehouseTemplate(WarehouseTemplatDto inputDto) | |||
{ | |||
try | |||
{ | |||
_db.Ado.BeginTran(); | |||
var model = _db.Queryable<BPA_WarehouseTemplate>().Where(x => x.Id == inputDto.Id).First(); | |||
model.DeviceId= inputDto.DeviceId; | |||
model.TemplateName= inputDto.TemplateName; | |||
var res = await _db.Updateable(model).ExecuteCommandAsync(); | |||
var warehousePostion = _db.Queryable<BPA_WarehousePostion>().Where(x => x.TemplateId == inputDto.Id).ToList(); | |||
await _db.Deleteable(warehousePostion).ExecuteCommandAsync(); | |||
List<BPA_WarehousePostion> list = new(); | |||
for (int i = 0; i < inputDto.WarehousePostionData.Count; i++) | |||
{ | |||
var tem = new BPA_WarehousePostion | |||
{ | |||
TemplateId = inputDto.Id, | |||
Code = inputDto.WarehousePostionData[i].Code, | |||
BatchingId = inputDto.WarehousePostionData[i].BatchingId, | |||
}; | |||
list.Add(tem); | |||
} | |||
var res1 = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); | |||
_db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception) | |||
{ | |||
_db.Ado.RollbackTran(); | |||
return false; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.WarehouseTemplate; | |||
using BPA.SAAS.Manage.Application.Device.Interface; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Application.Device | |||
{ | |||
[ApiDescriptionSettings("Device", Tag = "设备仓位模板")] | |||
public class WarehouseTemplateServices : IDynamicApiController, ITransient | |||
{ | |||
IWarehouseTemplateService _warehouseTemplateService; | |||
public WarehouseTemplateServices(IWarehouseTemplateService warehouseTemplateService) | |||
{ | |||
_warehouseTemplateService=warehouseTemplateService; | |||
} | |||
/// <summary> | |||
/// 分页查询 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/warehousetemplate/page")] | |||
public async Task<PageUtil> GetWarehouseTemplatePage(WarehouseTemplateQueryInputDto inputDto) | |||
{ | |||
return await _warehouseTemplateService.GetWarehouseTemplatePage(inputDto); | |||
} | |||
[HttpGet("/api/warehousetemplate/list")] | |||
public async Task<List<WarehouseTemplateView>> GetWarehouseTemplateList(string deviceId) | |||
{ | |||
return await _warehouseTemplateService.GetWarehouseTemplateList(deviceId); | |||
} | |||
/// <summary> | |||
/// 添加 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/warehousetemplate/add")] | |||
public async Task<bool> AddWarehouseTemplate(WarehouseTemplatDto inputDto) | |||
{ | |||
return await _warehouseTemplateService.AddWarehouseTemplate(inputDto); | |||
} | |||
/// <summary> | |||
/// 删除 | |||
/// </summary> | |||
/// <param name="inputList"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/warehousetemplate/del")] | |||
public async Task<bool> DeWarehouseTemplate(List<string> inputList) | |||
{ | |||
return await _warehouseTemplateService.DeWarehouseTemplate(inputList); | |||
} | |||
/// <summary> | |||
/// 更新 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/warehousetemplate/update")] | |||
public async Task<bool> UpdateWarehouseTemplate(WarehouseTemplatDto inputDto) | |||
{ | |||
return await _warehouseTemplateService.UpdateWarehouseTemplate(inputDto); | |||
} | |||
} | |||
} |
@@ -21,5 +21,6 @@ namespace BPA.SAAS.Manage.Comm.Model | |||
public string ProductId { get; set; } | |||
public string Vesion { get; set; } | |||
public string PrductKey { get; set; } | |||
public int? ProductNumber { get; set; } | |||
} | |||
} |
@@ -35,5 +35,9 @@ namespace BPA.SAAS.Manage.Core.DataBase | |||
public int Sort { get; set; } | |||
public string GoodsId { get; set; } | |||
public string DeviceId { get; set; } | |||
/// <summary> | |||
/// 仓位模板 | |||
/// </summary> | |||
public string WarehousrTemplateId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using BPA.SAAS.Manage.Core.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Core.Device | |||
{ | |||
[SugarTable("bpa_warehousepostion")] | |||
public class BPA_WarehousePostion : IBaseEntity, IGroupId | |||
{ | |||
public string TemplateId { get; set; } | |||
public string Code { get; set; } | |||
public string BatchingId { get; set; } | |||
public string GroupId { get; set; } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using BPA.SAAS.Manage.Core.Base; | |||
using SqlSugar; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Core.Device | |||
{ | |||
[SugarTable("bpa_warehousetemplate")] | |||
public class BPA_WarehouseTemplate : IBaseEntity, IGroupId | |||
{ | |||
public string DeviceId { get; set; } | |||
public string TemplateName { get; set; } | |||
public string GroupId { get; set; } | |||
} | |||
} |