@@ -514,7 +514,7 @@ | |||||
料仓名称 | 料仓名称 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.MaterialId"> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.MaterialCode"> | |||||
<summary> | <summary> | ||||
物料Id | 物料Id | ||||
</summary> | </summary> | ||||
@@ -522,7 +522,7 @@ | |||||
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.Volume"> | <member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.Volume"> | ||||
<summary> | <summary> | ||||
料仓容积 | 料仓容积 | ||||
</summary> | |||||
</summary>i | |||||
</member> | </member> | ||||
<member name="T:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity"> | <member name="T:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity"> | ||||
<summary> | <summary> | ||||
@@ -669,6 +669,11 @@ | |||||
工艺Id | 工艺Id | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity.FinalId"> | |||||
<summary> | |||||
成品Id | |||||
</summary> | |||||
</member> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity.CraftName"> | <member name="P:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity.CraftName"> | ||||
<summary> | <summary> | ||||
工艺名称 | 工艺名称 | ||||
@@ -737,6 +742,11 @@ | |||||
物料id | 物料id | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoMaterialsRecordEntity.MaterialCode"> | |||||
<summary> | |||||
物料编码 | |||||
</summary> | |||||
</member> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoMaterialsRecordEntity.WorkId"> | <member name="P:BPA.MES.Base.Application.Entitys.WorkInfoMaterialsRecordEntity.WorkId"> | ||||
<summary> | <summary> | ||||
工单id | 工单id | ||||
@@ -841,17 +851,17 @@ | |||||
描 述 : | 描 述 : | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.DeviceProductId"> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.FunctionId"> | |||||
<summary> | <summary> | ||||
设备产品Id | 设备产品Id | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Name"> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Code"> | |||||
<summary> | <summary> | ||||
名称 | 名称 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Code"> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Souce"> | |||||
<summary> | <summary> | ||||
编码 | 编码 | ||||
</summary> | </summary> | ||||
@@ -1008,7 +1018,7 @@ | |||||
成品配方 | 成品配方 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Entitys.FinalMaterialEntity.MaterialId"> | |||||
<member name="P:BPA.MES.Base.Application.Entitys.FinalMaterialEntity.MaterialCode"> | |||||
<summary> | <summary> | ||||
物料Id | 物料Id | ||||
</summary> | </summary> | ||||
@@ -5141,7 +5151,12 @@ | |||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.MaterialId"> | <member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.MaterialId"> | ||||
<summary> | <summary> | ||||
物料Id | |||||
物料编码 | |||||
</summary> | |||||
</member> | |||||
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.MaterialCode"> | |||||
<summary> | |||||
物料编码 | |||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.FinalId"> | <member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.FinalId"> | ||||
@@ -5229,11 +5244,6 @@ | |||||
物料名称 | 物料名称 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialOutput.MaterialCode"> | |||||
<summary> | |||||
物料编码 | |||||
</summary> | |||||
</member> | |||||
<member name="T:BPA.MES.Base.Application.Services.FinalsInfoDto"> | <member name="T:BPA.MES.Base.Application.Services.FinalsInfoDto"> | ||||
<summary> | <summary> | ||||
名 称 :成品管理 | 名 称 :成品管理 | ||||
@@ -7786,9 +7796,9 @@ | |||||
产线Id | 产线Id | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockQueryInput.MaterialId"> | |||||
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockQueryInput.MaterialCode"> | |||||
<summary> | <summary> | ||||
物料Id | |||||
物料编码 | |||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="T:BPA.MES.Base.Application.Services.ProductLineStockQueryPageInput"> | <member name="T:BPA.MES.Base.Application.Services.ProductLineStockQueryPageInput"> | ||||
@@ -7842,7 +7852,7 @@ | |||||
编码 | 编码 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockOutput.MaterialId"> | |||||
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockOutput.MaterialCode"> | |||||
<summary> | <summary> | ||||
物料信息 | 物料信息 | ||||
</summary> | </summary> | ||||
@@ -8744,7 +8754,7 @@ | |||||
料仓名称 | 料仓名称 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.StockInfoDto.MaterialId"> | |||||
<member name="P:BPA.MES.Base.Application.Services.StockInfoDto.MaterialCode"> | |||||
<summary> | <summary> | ||||
物料Id | 物料Id | ||||
</summary> | </summary> | ||||
@@ -9546,6 +9556,16 @@ | |||||
每升重量 | 每升重量 | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.WorkInfoMaterialsRecordOutput.MaterialCode"> | |||||
<summary> | |||||
物料编码 | |||||
</summary> | |||||
</member> | |||||
<member name="P:BPA.MES.Base.Application.Services.WorkInfoMaterialsRecordOutput.MaterialMode"> | |||||
<summary> | |||||
物料配料方式 | |||||
</summary> | |||||
</member> | |||||
<member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusDto"> | <member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusDto"> | ||||
<summary> | <summary> | ||||
名 称 :工单状态 | 名 称 :工单状态 | ||||
@@ -9629,11 +9649,6 @@ | |||||
工单ID | 工单ID | ||||
</summary> | </summary> | ||||
</member> | </member> | ||||
<member name="P:BPA.MES.Base.Application.Services.PublishInput.DeviceId"> | |||||
<summary> | |||||
设备ID | |||||
</summary> | |||||
</member> | |||||
<member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusOutput"> | <member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusOutput"> | ||||
<summary> | <summary> | ||||
输出 | 输出 | ||||
@@ -20,10 +20,10 @@ | |||||
/// <summary> | /// <summary> | ||||
/// 物料Id | /// 物料Id | ||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 料仓容积 | /// 料仓容积 | ||||
/// </summary> | |||||
/// </summary>i | |||||
public string Volume { get; set; } | public string Volume { get; set; } | ||||
} | } | ||||
@@ -22,6 +22,10 @@ | |||||
/// </summary> | /// </summary> | ||||
public string CraftId { get; set; } | public string CraftId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 成品Id | |||||
/// </summary> | |||||
public string FinalId { get; set; } | |||||
/// <summary> | |||||
/// 工艺名称 | /// 工艺名称 | ||||
/// </summary> | /// </summary> | ||||
public string CraftName { get; set; } | public string CraftName { get; set; } | ||||
@@ -20,6 +20,10 @@ | |||||
[SugarColumn(IsNullable = true)] | [SugarColumn(IsNullable = true)] | ||||
public string MaterialId { get; set; } | public string MaterialId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 物料编码 | |||||
/// </summary> | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | |||||
/// 工单id | /// 工单id | ||||
/// </summary> | /// </summary> | ||||
[SugarColumn(IsNullable = true)] | [SugarColumn(IsNullable = true)] | ||||
@@ -12,15 +12,15 @@ | |||||
/// <summary> | /// <summary> | ||||
/// 设备产品Id | /// 设备产品Id | ||||
/// </summary> | /// </summary> | ||||
public string DeviceProductId { get; set; } | |||||
public string FunctionId { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 名称 | /// 名称 | ||||
/// </summary> | /// </summary> | ||||
public string Name { get; set; } | |||||
public string Code { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 编码 | /// 编码 | ||||
/// </summary> | /// </summary> | ||||
public string Code { get; set; } | |||||
public string Souce { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 描述 | /// 描述 | ||||
/// </summary> | /// </summary> | ||||
@@ -16,7 +16,7 @@ namespace BPA.MES.Base.Application.Entitys | |||||
/// <summary> | /// <summary> | ||||
/// 物料Id | /// 物料Id | ||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 操作方式 | /// 操作方式 | ||||
/// </summary> | /// </summary> | ||||
@@ -22,7 +22,7 @@ | |||||
[HttpPost] | [HttpPost] | ||||
public async Task<bool> Add(DeviceProductParmAddInput input) | public async Task<bool> Add(DeviceProductParmAddInput input) | ||||
{ | { | ||||
var r_entity = await _dbContext.Queryable<DeviceProductParmEntity>().FirstAsync(x => x.Name == input.Name); | |||||
var r_entity = await _dbContext.Queryable<DeviceProductParmEntity>().FirstAsync(x => x.Code == input.Name); | |||||
if (r_entity != null) | if (r_entity != null) | ||||
{ | { | ||||
throw Oops.Bah("名称已存在!"); | throw Oops.Bah("名称已存在!"); | ||||
@@ -76,7 +76,6 @@ | |||||
public async Task<SqlSugarPagedList<DeviceProductParmOutput>> PagedList(DeviceProductParmQueryPageInput input) | public async Task<SqlSugarPagedList<DeviceProductParmOutput>> PagedList(DeviceProductParmQueryPageInput input) | ||||
{ | { | ||||
var entity = await _dbContext.Queryable<DeviceProductParmEntity>() | var entity = await _dbContext.Queryable<DeviceProductParmEntity>() | ||||
.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name)) | |||||
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code)) | .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code)) | ||||
.ToPagedListAsync(input.PageIndex, input.PageSize); | .ToPagedListAsync(input.PageIndex, input.PageSize); | ||||
SqlSugarPagedList<DeviceProductParmOutput> output = entity.Adapt<SqlSugarPagedList<DeviceProductParmOutput>>(); | SqlSugarPagedList<DeviceProductParmOutput> output = entity.Adapt<SqlSugarPagedList<DeviceProductParmOutput>>(); | ||||
@@ -93,7 +92,7 @@ | |||||
var entity = await _dbContext.Queryable<DeviceProductParmEntity>().Select(x => new | var entity = await _dbContext.Queryable<DeviceProductParmEntity>().Select(x => new | ||||
{ | { | ||||
key = x.Id, | key = x.Id, | ||||
value = x.Name | |||||
value = x.Code | |||||
}).ToListAsync(); | }).ToListAsync(); | ||||
return entity; | return entity; | ||||
} | } | ||||
@@ -11,10 +11,14 @@ namespace BPA.MES.Base.Application.Services | |||||
public class FinalMaterialDto | public class FinalMaterialDto | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 物料Id | |||||
/// 物料编码 | |||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | public string MaterialId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 物料编码 | |||||
/// </summary> | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | |||||
/// 成品Id | /// 成品Id | ||||
/// </summary> | /// </summary> | ||||
public string FinalId { get; set; } | public string FinalId { get; set; } | ||||
@@ -96,9 +100,6 @@ namespace BPA.MES.Base.Application.Services | |||||
/// 物料名称 | /// 物料名称 | ||||
/// </summary> | /// </summary> | ||||
public string MaterialName { get; set; } | public string MaterialName { get; set; } | ||||
/// <summary> | |||||
/// 物料编码 | |||||
/// </summary> | |||||
public string MaterialCode { get; set; } | |||||
} | } | ||||
} | } |
@@ -85,7 +85,7 @@ | |||||
public async Task<List<FinalMaterialOutput>> List(FinalMaterialQueryInput input) | public async Task<List<FinalMaterialOutput>> List(FinalMaterialQueryInput input) | ||||
{ | { | ||||
var output = await _dbContext.Queryable<FinalMaterialEntity>() | var output = await _dbContext.Queryable<FinalMaterialEntity>() | ||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a,b)=>a.MaterialId==b.Id) | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a,b)=>a.MaterialCode==b.Code) | |||||
.WhereIF(!string.IsNullOrEmpty(input.FinalId),(a,b)=>a.FinalId==input.FinalId) | .WhereIF(!string.IsNullOrEmpty(input.FinalId),(a,b)=>a.FinalId==input.FinalId) | ||||
.Select((a,b)=>new FinalMaterialOutput | .Select((a,b)=>new FinalMaterialOutput | ||||
{ | { | ||||
@@ -41,7 +41,20 @@ namespace BPA.MES.Base.Application.Services | |||||
[HttpPost] | [HttpPost] | ||||
public async Task<bool> Del(FinalsInfoDelInput input) | public async Task<bool> Del(FinalsInfoDelInput input) | ||||
{ | { | ||||
var res = await _dbContext.Deleteable<Pztj_FinalsInfoEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); | |||||
bool res =false; | |||||
try | |||||
{ | |||||
_dbContext.Ado.BeginTran(); | |||||
await _dbContext.Deleteable<Pztj_FinalsInfoEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); | |||||
await _dbContext.Deleteable<FinalMaterialEntity>().Where(x => x.FinalId == input.Id).ExecuteCommandAsync(); | |||||
_dbContext.Ado.CommitTran(); | |||||
res = true; | |||||
} | |||||
catch (Exception) | |||||
{ | |||||
_dbContext.Ado.RollbackTran(); | |||||
} | |||||
return res; | return res; | ||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -124,6 +124,11 @@ | |||||
[HttpPost] | [HttpPost] | ||||
public async Task<bool> Update(MaterialsInfoUpdateInput input) | public async Task<bool> Update(MaterialsInfoUpdateInput input) | ||||
{ | { | ||||
var currentity = await _dbContext.Queryable<Pztj_MaterialsInfoEntity>().FirstAsync(x => x.Id != input.Id && (x.Name == input.Name || x.Code==input.Code)); | |||||
if (currentity != null) | |||||
{ | |||||
throw Oops.Bah("名称已存在!"); | |||||
} | |||||
var entity = await _dbContext.Queryable<Pztj_MaterialsInfoEntity>().Where(x => x.Id == input.Id).FirstAsync(); | var entity = await _dbContext.Queryable<Pztj_MaterialsInfoEntity>().Where(x => x.Id == input.Id).FirstAsync(); | ||||
entity = input.Adapt<Pztj_MaterialsInfoEntity>(); | entity = input.Adapt<Pztj_MaterialsInfoEntity>(); | ||||
var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync(); | var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync(); | ||||
@@ -36,9 +36,9 @@ | |||||
/// </summary> | /// </summary> | ||||
public string LineId { get; set; } | public string LineId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 物料Id | |||||
/// 物料编码 | |||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | |||||
public string MaterialCode { get; set; } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 产线设备分页 | /// 产线设备分页 | ||||
@@ -89,7 +89,7 @@ | |||||
/// <summary> | /// <summary> | ||||
/// 物料信息 | /// 物料信息 | ||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 物料名称 | /// 物料名称 | ||||
/// </summary> | /// </summary> | ||||
@@ -263,8 +263,8 @@ namespace BPA.MES.Base.Application.Services | |||||
{ | { | ||||
var entity = await _dbContext.Queryable<Pztj_LineStocksEntity>() | var entity = await _dbContext.Queryable<Pztj_LineStocksEntity>() | ||||
.LeftJoin<Pztj_StockInfoEntity>((a, b) => a.StockId == b.Id) | .LeftJoin<Pztj_StockInfoEntity>((a, b) => a.StockId == b.Id) | ||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b,c) => b.MaterialId == c.Id) | |||||
.WhereIF(!string.IsNullOrEmpty(input.MaterialId), (a, b) => b.MaterialId == input.MaterialId) | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b,c) => b.MaterialCode == c.Code) | |||||
.WhereIF(!string.IsNullOrEmpty(input.MaterialCode), (a, b) => b.MaterialCode == input.MaterialCode) | |||||
.WhereIF(!string.IsNullOrEmpty(input.LineId), (a, b) => a.LineId == input.LineId) | .WhereIF(!string.IsNullOrEmpty(input.LineId), (a, b) => a.LineId == input.LineId) | ||||
.Select((a, b,c) => new ProductLineStockOutput | .Select((a, b,c) => new ProductLineStockOutput | ||||
{ | { | ||||
@@ -273,7 +273,7 @@ namespace BPA.MES.Base.Application.Services | |||||
StockCode = b.Code, | StockCode = b.Code, | ||||
StockId = b.Id, | StockId = b.Id, | ||||
StockName = b.Name, | StockName = b.Name, | ||||
MaterialId = b.MaterialId, | |||||
MaterialCode = b.MaterialCode, | |||||
MateriaName = c.Name | MateriaName = c.Name | ||||
}) | }) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
@@ -19,7 +19,7 @@ | |||||
/// <summary> | /// <summary> | ||||
/// 物料Id | /// 物料Id | ||||
/// </summary> | /// </summary> | ||||
public string MaterialId { get; set; } | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 料仓容积 | /// 料仓容积 | ||||
/// </summary> | /// </summary> | ||||
@@ -1,4 +1,6 @@ | |||||
namespace BPA.MES.Base.Application.Services | |||||
using SqlSugar; | |||||
namespace BPA.MES.Base.Application.Services | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 名 称 :料仓服务 | /// 名 称 :料仓服务 | ||||
@@ -63,7 +65,14 @@ | |||||
[HttpGet] | [HttpGet] | ||||
public async Task<List<StockInfoOutput>> List() | public async Task<List<StockInfoOutput>> List() | ||||
{ | { | ||||
var entity = await _dbContext.Queryable<Pztj_StockInfoEntity>().ToListAsync(); | |||||
var entity = await _dbContext.Queryable<Pztj_StockInfoEntity>() | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a,b)=>a.MaterialCode==b.Code) | |||||
.Select((a, b) =>new StockInfoOutput | |||||
{ | |||||
Id = a.Id.SelectAll(), | |||||
MaterialName = b.Name, | |||||
}) | |||||
.ToListAsync(); | |||||
List<StockInfoOutput> output = entity.Adapt<List<StockInfoOutput>>(); | List<StockInfoOutput> output = entity.Adapt<List<StockInfoOutput>>(); | ||||
return output; | return output; | ||||
} | } | ||||
@@ -76,7 +85,7 @@ | |||||
public async Task<SqlSugarPagedList<StockInfoOutput>> PagedList(StockInfoQueryPageInput input) | public async Task<SqlSugarPagedList<StockInfoOutput>> PagedList(StockInfoQueryPageInput input) | ||||
{ | { | ||||
var entity = await _dbContext.Queryable<Pztj_StockInfoEntity>() | var entity = await _dbContext.Queryable<Pztj_StockInfoEntity>() | ||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a,b)=>a.MaterialId==b.Id) | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a,b)=>a.MaterialCode==b.Code) | |||||
.WhereIF(!string.IsNullOrEmpty(input.Name),(a,b)=>a.Name.Contains(input.Name)) | .WhereIF(!string.IsNullOrEmpty(input.Name),(a,b)=>a.Name.Contains(input.Name)) | ||||
.WhereIF(!string.IsNullOrEmpty(input.Code), (a, b) => a.Code.Contains(input.Code)) | .WhereIF(!string.IsNullOrEmpty(input.Code), (a, b) => a.Code.Contains(input.Code)) | ||||
.Select((a,b)=>new StockInfoOutput | .Select((a,b)=>new StockInfoOutput | ||||
@@ -1,4 +1,6 @@ | |||||
namespace BPA.MES.Base.Application.Services | |||||
using BPA.MES.Base.Application.Const; | |||||
namespace BPA.MES.Base.Application.Services | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 名 称 : | /// 名 称 : | ||||
@@ -108,5 +110,13 @@ | |||||
/// 每升重量 | /// 每升重量 | ||||
/// </summary> | /// </summary> | ||||
public string WeightPerLiter { get; set; } | public string WeightPerLiter { get; set; } | ||||
/// <summary> | |||||
/// 物料编码 | |||||
/// </summary> | |||||
public string MaterialCode { get; set; } | |||||
/// <summary> | |||||
/// 物料配料方式 | |||||
/// </summary> | |||||
public ModeEnum MaterialMode { get; set; } | |||||
} | } | ||||
} | } |
@@ -87,10 +87,6 @@ | |||||
/// 工单ID | /// 工单ID | ||||
/// </summary> | /// </summary> | ||||
public string WorkId { get; set; } | public string WorkId { get; set; } | ||||
/// <summary> | |||||
/// 设备ID | |||||
/// </summary> | |||||
public string? DeviceId { get; set; } | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 输出 | /// 输出 | ||||
@@ -55,7 +55,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
{ | { | ||||
_dbContext.Ado.BeginTran(); | _dbContext.Ado.BeginTran(); | ||||
await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | ||||
if (workDeviceRecordEntities.Count>1) | |||||
if (workDeviceRecordEntities.Count>0) | |||||
{ | { | ||||
await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync(); | await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync(); | ||||
} | } | ||||
@@ -79,6 +79,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
[HttpPost] | [HttpPost] | ||||
public async Task<bool> Del(WorkInfoDelInput input) | public async Task<bool> Del(WorkInfoDelInput input) | ||||
{ | { | ||||
var res = await _dbContext.Deleteable<Pztj_WorkInfoEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); | var res = await _dbContext.Deleteable<Pztj_WorkInfoEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); | ||||
return res; | return res; | ||||
} | } | ||||
@@ -121,16 +122,19 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
var craftlist = await _dbContext.Queryable<WorkInfoCraftstepRecordEntity>().Where(x => x.WorkId == Id).ToListAsync(); | var craftlist = await _dbContext.Queryable<WorkInfoCraftstepRecordEntity>().Where(x => x.WorkId == Id).ToListAsync(); | ||||
//获取物料信息 | //获取物料信息 | ||||
var materiallist = await _dbContext.Queryable<WorkInfoMaterialsRecordEntity>() | var materiallist = await _dbContext.Queryable<WorkInfoMaterialsRecordEntity>() | ||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialId==b.Id) | |||||
.LeftJoin<DictDataEntity>((a, b, c) => b.Type == c.Id) | |||||
.LeftJoin<FinalMaterialEntity>((a,b) => a.MaterialCode==b.MaterialCode) | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b,c) => a.MaterialCode==c.Code) | |||||
.LeftJoin<DictDataEntity>((a, b, c,d) => c.Type == d.Id) | |||||
.Where((a, b) => a.WorkId == Id) | .Where((a, b) => a.WorkId == Id) | ||||
.Select((a, b, c) => | |||||
.Select((a, b, c,d) => | |||||
new WorkInfoMaterialsRecordOutput | new WorkInfoMaterialsRecordOutput | ||||
{ | { | ||||
Id = a.Id.SelectAll(), | Id = a.Id.SelectAll(), | ||||
MaterialType = c.Id, | MaterialType = c.Id, | ||||
MaterialTypeName = c.Value, | |||||
WeightPerLiter = b.WeightPerLiter | |||||
MaterialTypeName = d.Value, | |||||
MaterialCode = c.Code, | |||||
MaterialMode = b.Mode, | |||||
WeightPerLiter = c.WeightPerLiter | |||||
}) | }) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
entity.CraftList = craftlist; | entity.CraftList = craftlist; | ||||
@@ -266,131 +270,10 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
[HttpPost] | [HttpPost] | ||||
public async Task<bool> Publishs(BatchInput input) | public async Task<bool> Publishs(BatchInput input) | ||||
{ | { | ||||
string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | |||||
string userName = App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value; | |||||
var workentitys = await _dbContext.Queryable<Pztj_WorkInfoEntity>().Where(x => x.BatchId == input.BatchId).ToListAsync(); | var workentitys = await _dbContext.Queryable<Pztj_WorkInfoEntity>().Where(x => x.BatchId == input.BatchId).ToListAsync(); | ||||
foreach (var item in workentitys) | foreach (var item in workentitys) | ||||
{ | { | ||||
var res = await UpdateStatus( | |||||
new WorkInfoStatusUpdateInput | |||||
{ | |||||
WorkId = item.Id, | |||||
Status = WorkOrderStatusEnum.Issued, | |||||
Remark = $"[{userId}]{userName}" | |||||
}); | |||||
var workentity = await _dbContext.Queryable<Pztj_WorkInfoEntity>() | |||||
.LeftJoin<Pztj_DevicesInfoEntity>((a, b) => a.DeviceId == b.Id) | |||||
.Where((a, b) => a.Id == item.Id) | |||||
.Select((a, b) => new WorkInfoOutput | |||||
{ | |||||
Id = a.Id.SelectAll(), | |||||
DeviceCode = b.Code, | |||||
DeviceName = b.Name | |||||
}) | |||||
.FirstAsync(); | |||||
if (res) | |||||
{ | |||||
WorkInfoMaterialsRecordEntity workInfoMaterialsRecordEntity = new() | |||||
{ | |||||
MaterialId = item.Id, | |||||
}; | |||||
//获取成品信息 | |||||
var finainfo = await _dbContext.Queryable<Pztj_FinalsInfoEntity>().FirstAsync(x => x.Id == workentity.FinalId); | |||||
if (finainfo == null) | |||||
{ | |||||
throw Oops.Bah("没有找到成品信息!"); | |||||
} | |||||
var materiallist = await _dbContext.Queryable<RecipeMaterialEntity>() | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialId == b.Id) | |||||
.LeftJoin<RecipesInfoEntity>((a, b, c) => a.RecipesId == c.Id) | |||||
//.Where((a, b, c) => a.RecipesId == finainfo.RecipeId) | |||||
.Select((a, b, c) => new WorkInfoMaterialsRecordEntity | |||||
{ | |||||
MaterialId = a.MaterialId, | |||||
MaterialName = b.Name, | |||||
MaterialStatus = EBatchingStatus.等待配料, | |||||
WorkId = item.Id, | |||||
Weight = a.Weight, | |||||
RecipeId = a.RecipesId, | |||||
RecipeName = c.Name | |||||
}) | |||||
.ToListAsync(); | |||||
//获取物料信息 | |||||
var craftsteplist = await _dbContext.Queryable<Pztj_CraftStepsEntity>() | |||||
.LeftJoin<Pztj_CraftsInfoEntity>((a, b) => a.CraftId == b.Id) | |||||
.LeftJoin<DeviceProductFunctionEntity>((a, b, c) => a.DeviceProductFunctionId == c.Id) | |||||
//.Where((a, b) => a.CraftId == finainfo.CraftId) | |||||
.Select((a, b, c) => new WorkInfoCraftstepRecordEntity | |||||
{ | |||||
CraftId = a.CraftId, | |||||
CraftName = b.Name, | |||||
CraftstepId = a.Id, | |||||
DeviceProductFunctionId = c.Id, | |||||
DeviceProductFunctionName = c.Name, | |||||
CraftstepParms = a.Params, | |||||
Status = RecipeStatus.等待执行, | |||||
Step = a.Step, | |||||
WorkId = item.Id | |||||
}) | |||||
.ToListAsync(); | |||||
List<WorkInfoMaterialsRecordEntity> newmateriallist = new(); | |||||
List<WorkInfoCraftstepRecordEntity> newcraftslist = new(); | |||||
for (int i = 1; i <= Convert.ToInt32(workentity.Number); i++) | |||||
{ | |||||
foreach (var materiaItem in materiallist) | |||||
{ | |||||
WorkInfoMaterialsRecordEntity itementity = new() | |||||
{ | |||||
PotNum = i.ToString(), | |||||
MaterialId = materiaItem.MaterialId, | |||||
MaterialName = materiaItem.MaterialName, | |||||
MaterialStatus = materiaItem.MaterialStatus, | |||||
WorkId = materiaItem.WorkId, | |||||
Weight = materiaItem.Weight, | |||||
RecipeId = materiaItem.RecipeId, | |||||
RecipeName = materiaItem.RecipeName, | |||||
}; | |||||
newmateriallist.Add(itementity); | |||||
} | |||||
foreach (var craftstepitem in craftsteplist) | |||||
{ | |||||
WorkInfoCraftstepRecordEntity itementity = new() | |||||
{ | |||||
CraftId = craftstepitem.CraftId, | |||||
CraftName = craftstepitem.CraftName, | |||||
CraftstepId = craftstepitem.CraftstepId, | |||||
DeviceProductFunctionId = craftstepitem.DeviceProductFunctionId, | |||||
DeviceProductFunctionName = craftstepitem.DeviceProductFunctionName, | |||||
CraftstepParms = craftstepitem.CraftstepParms, | |||||
Status = craftstepitem.Status, | |||||
Step = craftstepitem.Step, | |||||
WorkId = craftstepitem.WorkId, | |||||
PotNum = i.ToString(), | |||||
}; | |||||
newcraftslist.Add(itementity); | |||||
} | |||||
} | |||||
try | |||||
{ | |||||
_dbContext.Ado.BeginTran(); | |||||
await _dbContext.Deleteable<WorkInfoCraftstepRecordEntity>().Where(x => x.WorkId == item.Id).ExecuteCommandAsync(); | |||||
await _dbContext.Deleteable<WorkInfoMaterialsRecordEntity>().Where(x => x.WorkId == item.Id).ExecuteCommandAsync(); | |||||
await _dbContext.Insertable(newcraftslist).ExecuteCommandAsync(); | |||||
await _dbContext.Insertable(newmateriallist).ExecuteCommandAsync(); | |||||
_dbContext.Ado.CommitTran(); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
_dbContext.Ado.RollbackTran(); | |||||
throw Oops.Oh("下发失败!"); | |||||
} | |||||
await _MQTTService.MqttPublish(new MqttPublishDto() { Payload = workentity, Topic = Topics.WorkOrderPush, MessageId = MessageID.WorkOrderIssued }); | |||||
} | |||||
await Publish(new PublishInput { WorkId = item.Id }); | |||||
} | } | ||||
await _dbContext.Updateable<WorkBatchEntity>().SetColumns(x => x.Status == WorkOrderStatusEnum.Issued).Where(x => x.Id == input.BatchId).ExecuteCommandAsync(); | await _dbContext.Updateable<WorkBatchEntity>().SetColumns(x => x.Status == WorkOrderStatusEnum.Issued).Where(x => x.Id == input.BatchId).ExecuteCommandAsync(); | ||||
return true; | return true; | ||||
@@ -407,10 +290,11 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
{ | { | ||||
string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value; | ||||
string userName = App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value; | string userName = App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value; | ||||
if (!string.IsNullOrEmpty(input.DeviceId)) | |||||
{ | |||||
await _dbContext.Updateable<Pztj_WorkInfoEntity>().SetColumns(x => x.DeviceId == input.DeviceId).Where(x => x.Id == input.WorkId).ExecuteCommandAsync(); | |||||
} | |||||
//查询有多少个步骤 | |||||
var deviceList = await _dbContext.Queryable<WorkDeviceRecordEntity>().Where(x => x.WorkId==input.WorkId).ToListAsync(); | |||||
var res = await UpdateStatus( | var res = await UpdateStatus( | ||||
new WorkInfoStatusUpdateInput | new WorkInfoStatusUpdateInput | ||||
{ | { | ||||
@@ -430,53 +314,50 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
.FirstAsync(); | .FirstAsync(); | ||||
if (res) | if (res) | ||||
{ | { | ||||
WorkInfoMaterialsRecordEntity workInfoMaterialsRecordEntity = new() | |||||
{ | |||||
MaterialId = input.WorkId, | |||||
}; | |||||
//获取成品信息 | //获取成品信息 | ||||
var finainfo = await _dbContext.Queryable<Pztj_FinalsInfoEntity>().FirstAsync(x => x.Id == workentity.FinalId); | var finainfo = await _dbContext.Queryable<Pztj_FinalsInfoEntity>().FirstAsync(x => x.Id == workentity.FinalId); | ||||
if (finainfo == null) | if (finainfo == null) | ||||
{ | { | ||||
throw Oops.Bah("没有找到成品信息!"); | throw Oops.Bah("没有找到成品信息!"); | ||||
} | } | ||||
var materiallist = await _dbContext.Queryable<RecipeMaterialEntity>() | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialId == b.Id) | |||||
.LeftJoin<RecipesInfoEntity>((a, b, c) => a.RecipesId==c.Id) | |||||
//获取物料信息 | |||||
var materiallist = await _dbContext.Queryable<FinalMaterialEntity>() | |||||
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialCode == b.Code) | |||||
//.Where((a, b, c) => a.RecipesId == finainfo.RecipeId) | //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId) | ||||
.Select((a, b, c) => new WorkInfoMaterialsRecordEntity | |||||
.Select((a, b) => new WorkInfoMaterialsRecordEntity | |||||
{ | { | ||||
MaterialId = a.MaterialId, | |||||
MaterialCode = a.MaterialCode, | |||||
MaterialName = b.Name, | MaterialName = b.Name, | ||||
MaterialStatus = EBatchingStatus.等待配料, | MaterialStatus = EBatchingStatus.等待配料, | ||||
WorkId = input.WorkId, | WorkId = input.WorkId, | ||||
Weight = a.Weight, | Weight = a.Weight, | ||||
RecipeId = a.RecipesId, | |||||
RecipeName = c.Name, | |||||
ErrorWeight = a.ErrorWeight, | ErrorWeight = a.ErrorWeight, | ||||
}) | }) | ||||
.ToListAsync(); | .ToListAsync(); | ||||
//获取物料信息 | |||||
var craftsteplist = await _dbContext.Queryable<Pztj_CraftStepsEntity>() | |||||
.LeftJoin<Pztj_CraftsInfoEntity>((a, b) => a.CraftId == b.Id) | |||||
.LeftJoin<DeviceProductFunctionEntity>((a, b, c) => a.DeviceProductFunctionId == c.Id) | |||||
//.Where((a, b) => a.CraftId == finainfo.CraftId) | |||||
.Select((a, b, c) => new WorkInfoCraftstepRecordEntity | |||||
{ | |||||
CraftId = a.CraftId, | |||||
CraftName = b.Name, | |||||
CraftstepId = a.Id, | |||||
DeviceProductFunctionId = c.Id, | |||||
DeviceProductFunctionName = c.Name, | |||||
CraftstepParms = a.Params, | |||||
Status = RecipeStatus.等待执行, | |||||
Step = a.Step, | |||||
WorkId = input.WorkId | |||||
}) | |||||
.ToListAsync(); | |||||
List<WorkInfoCraftstepRecordEntity> ccc = new(); | |||||
foreach (var item in deviceList) | |||||
{ | |||||
var craftsteplist = await _dbContext.Queryable<FinalCraftStepsEntity>() | |||||
.LeftJoin<DeviceProductFunctionEntity>((a, b) => a.DeviceProductFunctionId == b.Id) | |||||
.Where((a, b) => a.FinalId == finainfo.Id) | |||||
.Where((a, b) => a.DeviceId == item.DeviceId) | |||||
.Select((a, b) => new WorkInfoCraftstepRecordEntity | |||||
{ | |||||
FinalId = a.FinalId, | |||||
CraftName = b.Name, | |||||
CraftstepId = a.Id, | |||||
DeviceProductFunctionId = b.Id, | |||||
DeviceProductFunctionName = b.Name, | |||||
CraftstepParms = a.Params, | |||||
Status = RecipeStatus.等待执行, | |||||
Step = a.Step, | |||||
WorkId = input.WorkId | |||||
}) | |||||
.ToListAsync(); | |||||
ccc.AddRange(craftsteplist); | |||||
} | |||||
List<WorkInfoMaterialsRecordEntity> newmateriallist = new(); | List<WorkInfoMaterialsRecordEntity> newmateriallist = new(); | ||||
List<WorkInfoCraftstepRecordEntity> newcraftslist = new(); | List<WorkInfoCraftstepRecordEntity> newcraftslist = new(); | ||||
for (int i = 1; i <= Convert.ToInt32(workentity.Number); i++) | for (int i = 1; i <= Convert.ToInt32(workentity.Number); i++) | ||||
@@ -487,6 +368,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
{ | { | ||||
PotNum = i.ToString(), | PotNum = i.ToString(), | ||||
MaterialId = item.MaterialId, | MaterialId = item.MaterialId, | ||||
MaterialCode = item.MaterialCode, | |||||
MaterialName = item.MaterialName, | MaterialName = item.MaterialName, | ||||
MaterialStatus = item.MaterialStatus, | MaterialStatus = item.MaterialStatus, | ||||
WorkId = item.WorkId, | WorkId = item.WorkId, | ||||
@@ -497,11 +379,11 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services | |||||
}; | }; | ||||
newmateriallist.Add(itementity); | newmateriallist.Add(itementity); | ||||
} | } | ||||
foreach (var item in craftsteplist) | |||||
foreach (var item in ccc) | |||||
{ | { | ||||
WorkInfoCraftstepRecordEntity itementity = new() | WorkInfoCraftstepRecordEntity itementity = new() | ||||
{ | { | ||||
CraftId = item.CraftId, | |||||
FinalId = item.FinalId, | |||||
CraftName = item.CraftName, | CraftName = item.CraftName, | ||||
CraftstepId = item.CraftstepId, | CraftstepId = item.CraftstepId, | ||||
DeviceProductFunctionId = item.DeviceProductFunctionId, | DeviceProductFunctionId = item.DeviceProductFunctionId, | ||||