Yanko 1 месяц назад
Родитель
Сommit
a4688cf7fb
18 измененных файлов: 156 добавлений и 218 удалений
  1. +36
    -21
      backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
  2. +2
    -2
      backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs
  3. +4
    -0
      backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs
  4. +4
    -0
      backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs
  5. +3
    -3
      backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs
  6. +1
    -1
      backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs
  7. +2
    -3
      backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs
  8. +6
    -5
      backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs
  9. +1
    -1
      backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs
  10. +14
    -1
      backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs
  11. +5
    -0
      backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs
  12. +3
    -3
      backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs
  13. +3
    -3
      backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs
  14. +1
    -1
      backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs
  15. +12
    -3
      backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs
  16. +11
    -1
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs
  17. +0
    -4
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs
  18. +48
    -166
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs

+ 36
- 21
backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml Просмотреть файл

@@ -514,7 +514,7 @@
料仓名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.MaterialId">
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.MaterialCode">
<summary>
物料Id
</summary>
@@ -522,7 +522,7 @@
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_StockInfoEntity.Volume">
<summary>
料仓容积
</summary>
</summary>i
</member>
<member name="T:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity">
<summary>
@@ -669,6 +669,11 @@
工艺Id
</summary>
</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">
<summary>
工艺名称
@@ -737,6 +742,11 @@
物料id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoMaterialsRecordEntity.MaterialCode">
<summary>
物料编码
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoMaterialsRecordEntity.WorkId">
<summary>
工单id
@@ -841,17 +851,17 @@
描 述 :
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.DeviceProductId">
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.FunctionId">
<summary>
设备产品Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Name">
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Code">
<summary>
名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Code">
<member name="P:BPA.MES.Base.Application.Entitys.DeviceProductParmEntity.Souce">
<summary>
编码
</summary>
@@ -1008,7 +1018,7 @@
成品配方
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.FinalMaterialEntity.MaterialId">
<member name="P:BPA.MES.Base.Application.Entitys.FinalMaterialEntity.MaterialCode">
<summary>
物料Id
</summary>
@@ -5141,7 +5151,12 @@
</member>
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.MaterialId">
<summary>
物料Id
物料编码
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.MaterialCode">
<summary>
物料编码
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialDto.FinalId">
@@ -5229,11 +5244,6 @@
物料名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.FinalMaterialOutput.MaterialCode">
<summary>
物料编码
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.FinalsInfoDto">
<summary>
名 称 :成品管理
@@ -7786,9 +7796,9 @@
产线Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockQueryInput.MaterialId">
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockQueryInput.MaterialCode">
<summary>
物料Id
物料编码
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.ProductLineStockQueryPageInput">
@@ -7842,7 +7852,7 @@
编码
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockOutput.MaterialId">
<member name="P:BPA.MES.Base.Application.Services.ProductLineStockOutput.MaterialCode">
<summary>
物料信息
</summary>
@@ -8744,7 +8754,7 @@
料仓名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.StockInfoDto.MaterialId">
<member name="P:BPA.MES.Base.Application.Services.StockInfoDto.MaterialCode">
<summary>
物料Id
</summary>
@@ -9546,6 +9556,16 @@
每升重量
</summary>
</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">
<summary>
名 称 :工单状态
@@ -9629,11 +9649,6 @@
工单ID
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.PublishInput.DeviceId">
<summary>
设备ID
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusOutput">
<summary>
输出


+ 2
- 2
backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs Просмотреть файл

@@ -20,10 +20,10 @@
/// <summary>
/// 物料Id
/// </summary>
public string MaterialId { get; set; }
public string MaterialCode { get; set; }
/// <summary>
/// 料仓容积
/// </summary>
/// </summary>i
public string Volume { get; set; }

}


+ 4
- 0
backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs Просмотреть файл

@@ -22,6 +22,10 @@
/// </summary>
public string CraftId { get; set; }
/// <summary>
/// 成品Id
/// </summary>
public string FinalId { get; set; }
/// <summary>
/// 工艺名称
/// </summary>
public string CraftName { get; set; }


+ 4
- 0
backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs Просмотреть файл

@@ -20,6 +20,10 @@
[SugarColumn(IsNullable = true)]
public string MaterialId { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialCode { get; set; }
/// <summary>
/// 工单id
/// </summary>
[SugarColumn(IsNullable = true)]


+ 3
- 3
backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs Просмотреть файл

@@ -12,15 +12,15 @@
/// <summary>
/// 设备产品Id
/// </summary>
public string DeviceProductId { get; set; }
public string FunctionId { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
public string Code { get; set; }
/// <summary>
/// 编码
/// </summary>
public string Code { get; set; }
public string Souce { get; set; }
/// <summary>
/// 描述
/// </summary>


+ 1
- 1
backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs Просмотреть файл

@@ -16,7 +16,7 @@ namespace BPA.MES.Base.Application.Entitys
/// <summary>
/// 物料Id
/// </summary>
public string MaterialId { get; set; }
public string MaterialCode { get; set; }
/// <summary>
/// 操作方式
/// </summary>


+ 2
- 3
backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs Просмотреть файл

@@ -22,7 +22,7 @@
[HttpPost]
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)
{
throw Oops.Bah("名称已存在!");
@@ -76,7 +76,6 @@
public async Task<SqlSugarPagedList<DeviceProductParmOutput>> PagedList(DeviceProductParmQueryPageInput input)
{
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))
.ToPagedListAsync(input.PageIndex, input.PageSize);
SqlSugarPagedList<DeviceProductParmOutput> output = entity.Adapt<SqlSugarPagedList<DeviceProductParmOutput>>();
@@ -93,7 +92,7 @@
var entity = await _dbContext.Queryable<DeviceProductParmEntity>().Select(x => new
{
key = x.Id,
value = x.Name
value = x.Code
}).ToListAsync();
return entity;
}


+ 6
- 5
backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs Просмотреть файл

@@ -11,10 +11,14 @@ namespace BPA.MES.Base.Application.Services
public class FinalMaterialDto
{
/// <summary>
/// 物料Id
/// 物料编码
/// </summary>
public string MaterialId { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialCode { get; set; }
/// <summary>
/// 成品Id
/// </summary>
public string FinalId { get; set; }
@@ -96,9 +100,6 @@ namespace BPA.MES.Base.Application.Services
/// 物料名称
/// </summary>
public string MaterialName { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialCode { get; set; }
}
}

+ 1
- 1
backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs Просмотреть файл

@@ -85,7 +85,7 @@
public async Task<List<FinalMaterialOutput>> List(FinalMaterialQueryInput input)
{
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)
.Select((a,b)=>new FinalMaterialOutput
{


+ 14
- 1
backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs Просмотреть файл

@@ -41,7 +41,20 @@ namespace BPA.MES.Base.Application.Services
[HttpPost]
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;
}
/// <summary>


+ 5
- 0
backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs Просмотреть файл

@@ -124,6 +124,11 @@
[HttpPost]
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();
entity = input.Adapt<Pztj_MaterialsInfoEntity>();
var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync();


+ 3
- 3
backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs Просмотреть файл

@@ -36,9 +36,9 @@
/// </summary>
public string LineId { get; set; }
/// <summary>
/// 物料Id
/// 物料编码
/// </summary>
public string MaterialId { get; set; }
public string MaterialCode { get; set; }
}
/// <summary>
/// 产线设备分页
@@ -89,7 +89,7 @@
/// <summary>
/// 物料信息
/// </summary>
public string MaterialId { get; set; }
public string MaterialCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>


+ 3
- 3
backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs Просмотреть файл

@@ -263,8 +263,8 @@ namespace BPA.MES.Base.Application.Services
{
var entity = await _dbContext.Queryable<Pztj_LineStocksEntity>()
.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)
.Select((a, b,c) => new ProductLineStockOutput
{
@@ -273,7 +273,7 @@ namespace BPA.MES.Base.Application.Services
StockCode = b.Code,
StockId = b.Id,
StockName = b.Name,
MaterialId = b.MaterialId,
MaterialCode = b.MaterialCode,
MateriaName = c.Name
})
.ToListAsync();


+ 1
- 1
backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs Просмотреть файл

@@ -19,7 +19,7 @@
/// <summary>
/// 物料Id
/// </summary>
public string MaterialId { get; set; }
public string MaterialCode { get; set; }
/// <summary>
/// 料仓容积
/// </summary>


+ 12
- 3
backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs Просмотреть файл

@@ -1,4 +1,6 @@
namespace BPA.MES.Base.Application.Services
using SqlSugar;

namespace BPA.MES.Base.Application.Services
{
/// <summary>
/// 名 称 :料仓服务
@@ -63,7 +65,14 @@
[HttpGet]
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>>();
return output;
}
@@ -76,7 +85,7 @@
public async Task<SqlSugarPagedList<StockInfoOutput>> PagedList(StockInfoQueryPageInput input)
{
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.Code), (a, b) => a.Code.Contains(input.Code))
.Select((a,b)=>new StockInfoOutput


+ 11
- 1
backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs Просмотреть файл

@@ -1,4 +1,6 @@
namespace BPA.MES.Base.Application.Services
using BPA.MES.Base.Application.Const;

namespace BPA.MES.Base.Application.Services
{
/// <summary>
/// 名 称 :
@@ -108,5 +110,13 @@
/// 每升重量
/// </summary>
public string WeightPerLiter { get; set; }
/// <summary>
/// 物料编码
/// </summary>
public string MaterialCode { get; set; }
/// <summary>
/// 物料配料方式
/// </summary>
public ModeEnum MaterialMode { get; set; }
}
}

+ 0
- 4
backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs Просмотреть файл

@@ -87,10 +87,6 @@
/// 工单ID
/// </summary>
public string WorkId { get; set; }
/// <summary>
/// 设备ID
/// </summary>
public string? DeviceId { get; set; }
}
/// <summary>
/// 输出


+ 48
- 166
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs Просмотреть файл

@@ -55,7 +55,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
{
_dbContext.Ado.BeginTran();
await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
if (workDeviceRecordEntities.Count>1)
if (workDeviceRecordEntities.Count>0)
{
await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync();
}
@@ -79,6 +79,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpPost]
public async Task<bool> Del(WorkInfoDelInput input)
{

var res = await _dbContext.Deleteable<Pztj_WorkInfoEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync();
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 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)
.Select((a, b, c) =>
.Select((a, b, c,d) =>
new WorkInfoMaterialsRecordOutput
{
Id = a.Id.SelectAll(),
MaterialType = c.Id,
MaterialTypeName = c.Value,
WeightPerLiter = b.WeightPerLiter
MaterialTypeName = d.Value,
MaterialCode = c.Code,
MaterialMode = b.Mode,
WeightPerLiter = c.WeightPerLiter
})
.ToListAsync();
entity.CraftList = craftlist;
@@ -266,131 +270,10 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpPost]
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();

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();
return true;
@@ -407,10 +290,11 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
{
string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.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(
new WorkInfoStatusUpdateInput
{
@@ -430,53 +314,50 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
.FirstAsync();
if (res)
{
WorkInfoMaterialsRecordEntity workInfoMaterialsRecordEntity = new()
{
MaterialId = input.WorkId,
};
//获取成品信息
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)
//获取物料信息
var materiallist = await _dbContext.Queryable<FinalMaterialEntity>()
.LeftJoin<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialCode == b.Code)
//.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,
MaterialStatus = EBatchingStatus.等待配料,
WorkId = input.WorkId,
Weight = a.Weight,
RecipeId = a.RecipesId,
RecipeName = c.Name,
ErrorWeight = a.ErrorWeight,
})
.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<WorkInfoCraftstepRecordEntity> newcraftslist = new();
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(),
MaterialId = item.MaterialId,
MaterialCode = item.MaterialCode,
MaterialName = item.MaterialName,
MaterialStatus = item.MaterialStatus,
WorkId = item.WorkId,
@@ -497,11 +379,11 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
};
newmateriallist.Add(itementity);
}
foreach (var item in craftsteplist)
foreach (var item in ccc)
{
WorkInfoCraftstepRecordEntity itementity = new()
{
CraftId = item.CraftId,
FinalId = item.FinalId,
CraftName = item.CraftName,
CraftstepId = item.CraftstepId,
DeviceProductFunctionId = item.DeviceProductFunctionId,


Загрузка…
Отмена
Сохранить