@@ -1,6 +1,9 @@ | |||
using BPA.SAAS.Manage.Application.DataBase.Dtos.Bom; | |||
using BPA.SAAS.Manage.Application.DataBase.Interface; | |||
using BPA.SAAS.Manage.Comm.Enum; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.DataBase; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -107,5 +110,27 @@ namespace BPA.SAAS.Manage.Application.DataBase | |||
{ | |||
return await _bomService.BomPage(inputDto); | |||
} | |||
/// <summary> | |||
/// 添加配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/bom/AddBom")] | |||
public async Task<bool> AddBom(BomCreateInputDto dto) | |||
{ | |||
return await _bomService.AddBom(dto); | |||
} | |||
/// <summary> | |||
/// 删除配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/bom/DelBom")] | |||
public async Task<bool> DelBom(string id) | |||
{ | |||
return await _bomService.DelBom(id); | |||
} | |||
} | |||
} |
@@ -9,6 +9,21 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Bom | |||
{ | |||
public class BomPageInputDto: PageInputBase | |||
{ | |||
public string Name { get; set; } | |||
public string bomTypeList { get; set; } | |||
public List<string> Pertains { get; set; } | |||
} | |||
public class BomCreateInputDto | |||
{ | |||
public string BomName { get; set; } | |||
public string BomType { get; set; } | |||
public string[] BomtypeList { get; set; } | |||
public List<Mateinfo> Mate { get; set; } | |||
} | |||
public class Mateinfo | |||
{ | |||
public string batchingId { get; set; } | |||
public int dosage { get; set; } | |||
} | |||
} |
@@ -26,13 +26,13 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddBom(BomInputDto dto); | |||
Task<bool> AddBom(BomInputDto dto); | |||
/// <summary> | |||
/// 更新 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateBom(BomInputDto dto); | |||
Task<bool> UpdateBom(BomInputDto dto); | |||
/// 更新配方详情 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
@@ -49,7 +49,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddBomType(AddBomTypeInputDto dto); | |||
Task<bool> AddBomType(AddBomTypeInputDto dto); | |||
/// <summary> | |||
/// 配方分类列表 | |||
/// </summary> | |||
@@ -62,5 +62,19 @@ namespace BPA.SAAS.Manage.Application.DataBase.Interface | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> BomPage(BomPageInputDto inputDto); | |||
/// <summary> | |||
/// 添加配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
Task<bool> AddBom(BomCreateInputDto dto); | |||
/// <summary> | |||
/// 删除配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
Task<bool> DelBom(string id); | |||
} | |||
} |
@@ -117,6 +117,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
} | |||
} | |||
/// <summary> | |||
/// 更新配方详情 | |||
/// </summary> | |||
@@ -229,16 +231,130 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services | |||
/// <returns></returns> | |||
public async Task<PageUtil> BomPage(BomPageInputDto inputDto) | |||
{ | |||
var pertainList = _db.Queryable<BPA_BomTypeInfo, BPA_BomType>((a, b) => | |||
new JoinQueryInfos(JoinType.Left, a.BomTypeId == b.Id)) | |||
.Where((a, b) => a.IsDeleted == 0 && b.IsDeleted == 0) | |||
.WhereIF(inputDto.Pertains != null && inputDto.Pertains.Count > 0, (a, b) => inputDto.Pertains.Contains(b.Pertain)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), (a, b) => b.Id == inputDto.bomTypeList) | |||
.Select((a, b) => a.BomId) | |||
.ToList(); | |||
int total = new RefAsync<int>(); | |||
var res = await _db.Queryable<BPA_Bom>() | |||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | |||
var res = _db.Queryable<BPA_Bom>() | |||
.Where(it => it.IsDeleted == 0) | |||
.WhereIF(!string.IsNullOrEmpty(inputDto.Name),x=>x.Name.Contains(inputDto.Name)) | |||
.WhereIF(!string.IsNullOrWhiteSpace(inputDto.bomTypeList), x => pertainList.Contains(x.Id)) | |||
.OrderBy(i => i.CreateAt, OrderByType.Desc) | |||
.ToPageList(inputDto.Current, inputDto.PageSize, ref total); | |||
var listtype = _db.Queryable<BPA_BomTypeInfo>() | |||
.Where(a => res.Select(x => x.Id).Contains(a.BomId) && a.IsDeleted == 0).ToList(); | |||
return new PageUtil() | |||
var data = new List<object>(); | |||
foreach (var item in res) | |||
{ | |||
Data = res, | |||
Total= total, | |||
var obj = listtype.Where(x => x.BomId == item.Id).Select(x => x.BomTypeId).ToList(); | |||
data.Add(new | |||
{ | |||
BomTypeList = obj, | |||
Name = item.Name, | |||
Code = item.Code, | |||
item.IsMain, | |||
item.BOMInfo, | |||
item.Status, | |||
item.Id, | |||
item.Sort, | |||
}); | |||
} | |||
PageUtil util = new PageUtil() | |||
{ | |||
Total = total, | |||
Data = data | |||
}; | |||
return util; | |||
} | |||
/// <summary> | |||
/// 添加配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> AddBom(BomCreateInputDto dto) | |||
{ | |||
_db.Ado.BeginTran(); | |||
try | |||
{ | |||
var sortMax = _db.Queryable<BPA_Bom>().Max(x => x.Sort); | |||
BPA_Bom newbPA_BOM = new BPA_Bom | |||
{ | |||
Name = dto.BomName, | |||
Code = GetNumber2(), | |||
IsMain = true, | |||
Sort = sortMax + 1, | |||
Id = Guid.NewGuid().ToString(), | |||
CreateAt = DateTime.Now, | |||
Status = CommonStatus.ENABLE, | |||
}; | |||
//添加配方 | |||
var res = _db.Insertable(newbPA_BOM).CallEntityMethod(m => m.Create()).ExecuteCommand(); | |||
//添加配方分类 | |||
var list = dto.BomtypeList.Select(item => new BPA_BomTypeInfo() { BomId = newbPA_BOM.Id, BomTypeId = item }).ToList(); | |||
_db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommand(); | |||
List<BPA_BomEntry> BOMEntryList = new(); | |||
if (dto.Mate.Count > 0) | |||
{ | |||
for (int i = 0; i < dto.Mate.Count; i++) | |||
{ | |||
BPA_BomEntry newbPA_BOMEnty = new BPA_BomEntry | |||
{ | |||
BatchingId = dto.Mate[i].batchingId, | |||
//BatchingKey = dto.Mate[i].AutoKey, | |||
BomQty = dto.Mate[i].dosage, | |||
BomId = newbPA_BOM.Id, | |||
Status = CommonStatus.ENABLE, | |||
IsReplace = false, | |||
}; | |||
BOMEntryList.Add(newbPA_BOMEnty); | |||
} | |||
} | |||
//添加配方物料关系 | |||
_db.Insertable(BOMEntryList).CallEntityMethod(m => m.Create()).ExecuteCommand(); | |||
_db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception e) | |||
{ | |||
_db.Ado.RollbackTran(); | |||
throw Oops.Oh("添加失败,失败信息:" + e.Message); | |||
} | |||
} | |||
/// <summary> | |||
/// 删除配方 | |||
/// </summary> | |||
/// <param name="dto"></param> | |||
/// <returns></returns> | |||
public async Task<bool> DelBom(string id) | |||
{ | |||
try | |||
{ | |||
_db.Ado.BeginTran(); | |||
await _db.Deleteable<BPA_Bom>().Where(x => x.Id == id).ExecuteCommandAsync(); | |||
await _db.Deleteable<BPA_BomEntry>().Where(x => x.BomId == id).ExecuteCommandAsync(); | |||
_db.Ado.CommitTran(); | |||
return true; | |||
} | |||
catch (Exception e) | |||
{ | |||
_db.Ado.RollbackTran(); | |||
throw Oops.Oh("删除失败" + e.Message); | |||
} | |||
} | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion; | |||
using BPA.SAAS.Manage.Application.Device.Interface; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using BPA.SAAS.Manage.Core.Product; | |||
using Microsoft.AspNetCore.Components.Forms; | |||
using System; | |||
using System.Collections.Generic; | |||
@@ -0,0 +1,13 @@ | |||
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.Device | |||
{ | |||
public class TechnologyQueryInputDto: PageInputBase | |||
{ | |||
} | |||
} |
@@ -1,6 +1,6 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.DeviceVesion; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using BPA.SAAS.Manage.Core.Product; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -0,0 +1,15 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||
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 ITechnologyService | |||
{ | |||
Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto); | |||
} | |||
} |
@@ -3,7 +3,6 @@ using BPA.SAAS.Manage.Application.Device.Interface; | |||
using BPA.SAAS.Manage.Comm.Const; | |||
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.POIFS.Crypt.Dsig; | |||
using NPOI.Util; | |||
@@ -0,0 +1,50 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||
using BPA.SAAS.Manage.Application.Device.Interface; | |||
using BPA.SAAS.Manage.Core.Base; | |||
using BPA.SAAS.Manage.Core.Device; | |||
using BPA.SAAS.Manage.Core.Product; | |||
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 TechnologyService : ITechnologyService, ITransient | |||
{ | |||
private readonly ISqlSugarClient _db; | |||
public TechnologyService(ISqlSugarClient db) | |||
{ | |||
_db=db; | |||
} | |||
/// <summary> | |||
/// 分页查询 | |||
/// </summary> | |||
/// <param name="inputDto"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto) | |||
{ | |||
var total = new RefAsync<int>(); | |||
var data = await _db.Queryable<BPA_ProductVesion,BPA_Technology, BPA_Product>((a, b,c) => new JoinQueryInfos( | |||
JoinType.Left, a.Id == b.DeviceVersionId, | |||
JoinType.Left, a.ProductId == c.Id | |||
)).Select((a, b, c) => new | |||
{ | |||
Id=b.Id, | |||
Vesion=a.Vesion, | |||
ProductName=c.Name, | |||
CreateAt=b.CreateAt, | |||
}) | |||
.OrderBy(x => x.CreateAt, OrderByType.Desc) | |||
.ToPageListAsync(inputDto.Current, inputDto.PageSize, total); | |||
return new PageUtil() | |||
{ | |||
Data = data, | |||
Total = total | |||
}; | |||
} | |||
} | |||
} |
@@ -0,0 +1,26 @@ | |||
using BPA.SAAS.Manage.Application.Device.Dtos.Device; | |||
using BPA.SAAS.Manage.Application.Device.Interface; | |||
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 | |||
{ | |||
[ApiDescriptionSettings("Technology", Tag = "设备工艺")] | |||
public class TechnologyServices: IDynamicApiController, ITransient | |||
{ | |||
ITechnologyService _technologyService; | |||
public TechnologyServices(ITechnologyService technologyService) | |||
{ | |||
_technologyService= technologyService; | |||
} | |||
[HttpPost("/api/technology/page")] | |||
public async Task<PageUtil> GetTechnologyPage(TechnologyQueryInputDto inputDto) | |||
{ | |||
return await _technologyService.GetTechnologyPage(inputDto); | |||
} | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
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_technology")] | |||
public class BPA_Technology | |||
{ | |||
/// <summary> | |||
/// 主键 Guid | |||
/// </summary> | |||
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Id { get; set; } | |||
public string Name { get; set; } | |||
public string DeviceVersionId { get; set; } | |||
public string ForeignKeyRe { get; set; } | |||
public DateTime CreateAt { get; set; } | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
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_technologyaction")] | |||
public class BPA_TechnologyAction | |||
{ | |||
/// <summary> | |||
/// 主键 Guid | |||
/// </summary> | |||
[SugarColumn(IsPrimaryKey = true, ColumnDataType = "Nvarchar(64)", IsNullable = false)] | |||
public string Id { get; set; } | |||
public string TechnologyId { get; set; } | |||
public string ActionName { get; set; } | |||
public string ActionValue { get; set; } | |||
public string ActionType { get; set; } | |||
public string Unit { get; set; } | |||
public bool IsBatch { get; set; } | |||
public DateTime CreateAt { get; set; } | |||
public int Sort { get; set; } | |||
} | |||
} |
@@ -7,7 +7,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPA.SAAS.Manage.Core.Device | |||
namespace BPA.SAAS.Manage.Core.Product | |||
{ | |||
[SugarTable("bpa_productvesion")] | |||
public class BPA_ProductVesion : IBaseEntity |