Browse Source

胖子天骄需求修改

master
747575620@qq.com 6 months ago
parent
commit
b6b68c0a27
11 changed files with 626 additions and 5 deletions
  1. +189
    -0
      backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
  2. +4
    -0
      backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs
  3. +26
    -0
      backend/BPA.MES.Base.Application/Entitys/App/WorkBatchEntity.cs
  4. +78
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs
  5. +13
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs
  6. +9
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs
  7. +43
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkBatchService.cs
  8. +6
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs
  9. +60
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs
  10. +197
    -4
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs
  11. +1
    -1
      backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj.user

+ 189
- 0
backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml View File

@@ -547,6 +547,11 @@
产量
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity.BatchId">
<summary>
批次号
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity.CreateTime">
<summary>
创建时间
@@ -598,6 +603,29 @@
备注
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.WorkBatchEntity">
<summary>
名 称 :
创 建 人 :yangxiao
创建时间 : 2023/8/9 18:22:42
描 述 :
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkBatchEntity.Name">
<summary>
批次名词
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkBatchEntity.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkBatchEntity.Status">
<summary>
状态
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity">
<summary>
名 称 :
@@ -2520,6 +2548,11 @@
计划重量
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.BucketMaterialsRecordOutput.PotNum">
<summary>
第几锅
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.BucketInfoService">
<summary>
名 称 :桶服务
@@ -7309,6 +7342,74 @@
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchDto">
<summary>
名 称 :
创 建 人 :yangxiao
创建时间 : 2024/4/8 15:46:52
描 述 :
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchDto.Name">
<summary>
批次名词
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchDto.CreateTime">
<summary>
创建时间
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchDto.Status">
<summary>
状态
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchAddInput">
<summary>
增加
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchUpdateInput">
<summary>
更新
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchUpdateInput.Id">
<summary>
主键
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchDelInput">
<summary>
删除
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchDelInput.Id">
<summary>
主键
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchQueryInput">
<summary>
不分页
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchQueryPageInput">
<summary>
分页
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchOutput">
<summary>
输出
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkBatchOutput.Id">
<summary>
主键
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoCraftstepRecordDto">
<summary>
名 称 :
@@ -7430,6 +7531,11 @@
产量
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoDto.BatchId">
<summary>
批次号
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoDto.DeviceId">
<summary>
设备id
@@ -7495,6 +7601,11 @@
结束时间
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoQueryInput.BatchId">
<summary>
批次计划Id
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoQueryPageInput">
<summary>
分页
@@ -7515,6 +7626,11 @@
工单状态
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoQueryPageInput.BatchId">
<summary>
批次计划Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoQueryPageInput.StartTime">
<summary>
起始时间
@@ -7839,6 +7955,11 @@
分页
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.BatchInput">
<summary>
批次下发
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.PublishInput">
<summary>
下发
@@ -7869,6 +7990,44 @@
状态名称
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.IWorkBatchService">
<summary>
名 称 :
创 建 人 :yangxiao
创建时间 : 2024/4/8 15:41:42
描 述 :
</summary>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkBatchService.Add(BPA.MES.Base.Application.Services.WorkBatchAddInput)">
<summary>
增加
</summary>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkBatchService.Del(BPA.MES.Base.Application.Services.WorkBatchDelInput)">
<summary>
移除
</summary>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkBatchService.Update(BPA.MES.Base.Application.Services.WorkBatchUpdateInput)">
<summary>
更新
</summary>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkBatchService.List(BPA.MES.Base.Application.Services.WorkBatchQueryInput)">
<summary>
不分页列表
</summary>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkBatchService.PagedList(BPA.MES.Base.Application.Services.WorkBatchQueryPageInput)">
<summary>
分页列表
</summary>
<returns></returns>
</member>
<member name="T:BPA.MES.Base.Application.Services.IWorkInfoService">
<summary>
名 称 :工单服务
@@ -7933,6 +8092,13 @@
<param name="input">工单Id</param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkInfoService.Publishs(BPA.MES.Base.Application.Services.BatchInput)">
<summary>
批次工单下发
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.IWorkInfoService.ForcedEnd(System.String)">
<summary>
强制结束
@@ -7969,6 +8135,14 @@
描 述 :
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkBatchService">
<summary>
名 称 :工单服务
创 建 人 :yangxiao
创建时间 :2023/7/20 14:39:41
描 述 :
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoService.Services.WorkInfoService">
<summary>
名 称 :工单服务
@@ -8014,6 +8188,21 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.WorkInfoService.Services.WorkInfoService.BatchPagedList(BPA.MES.Base.Application.Services.WorkInfoQueryPageInput)">
<summary>
分页
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.WorkInfoService.Services.WorkInfoService.Publishs(BPA.MES.Base.Application.Services.BatchInput)">
<summary>
工单下发
</summary>
<param name="input">工单id</param>
<returns></returns>
<exception cref="T:System.NotImplementedException"></exception>
</member>
<member name="M:BPA.MES.Base.Application.Services.WorkInfoService.Services.WorkInfoService.Publish(BPA.MES.Base.Application.Services.PublishInput)">
<summary>
工单下发


+ 4
- 0
backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs View File

@@ -32,6 +32,10 @@
/// </summary>
public string Number { get;set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }


+ 26
- 0
backend/BPA.MES.Base.Application/Entitys/App/WorkBatchEntity.cs View File

@@ -0,0 +1,26 @@
namespace BPA.MES.Base.Application.Entitys
{
/// <summary>
/// 名 称 :
/// 创 建 人 :yangxiao
/// 创建时间 : 2023/8/9 18:22:42
/// 描 述 :
/// </summary>
[SugarTable("work_batch")]
public class WorkBatchEntity : DEntityBase
{
/// <summary>
/// 批次名词
/// </summary>
public string Name { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 状态
/// </summary>
public WorkOrderStatusEnum? Status { get; set; }

}
}

+ 78
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkBatchDto.cs View File

@@ -0,0 +1,78 @@
namespace BPA.MES.Base.Application.Services
{
/// <summary>
/// 名 称 :
/// 创 建 人 :yangxiao
/// 创建时间 : 2024/4/8 15:46:52
/// 描 述 :
/// </summary>
public class WorkBatchDto
{
/// <summary>
/// 批次名词
/// </summary>
public string Name { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 状态
/// </summary>
public WorkOrderStatusEnum? Status { get; set; }

}

/// <summary>
/// 增加
/// </summary>
public class WorkBatchAddInput : WorkBatchDto
{

}
/// <summary>
/// 更新
/// </summary>
public class WorkBatchUpdateInput : WorkBatchDto
{
/// <summary>
/// 主键
/// </summary>
public string Id { get; set; }
}
/// <summary>
/// 删除
/// </summary>
public class WorkBatchDelInput
{
/// <summary>
/// 主键
/// </summary>
public string Id { get; set; }
}
/// <summary>
/// 不分页
/// </summary>
public class WorkBatchQueryInput
{

}
/// <summary>
/// 分页
/// </summary>
public class WorkBatchQueryPageInput : RequestPage
{
}
/// <summary>
/// 输出
/// </summary>
public class WorkBatchOutput : WorkBatchDto
{
/// <summary>
/// 主键
/// </summary>
public string Id { get; set; }

}
}

+ 13
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs View File

@@ -25,6 +25,10 @@
/// </summary>
public string Number { get; set; }
/// <summary>
/// 批次号
/// </summary>
public string BatchId { get; set; }
/// <summary>
/// 设备id
/// </summary>
public string DeviceId { get; set; }
@@ -89,6 +93,10 @@
/// 结束时间
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// 批次计划Id
/// </summary>
public string BatchId { get; set; }
}
/// <summary>
/// 分页
@@ -108,6 +116,11 @@
/// </summary>
public WorkOrderStatusEnum?[] Status { get; set; }
/// <summary>
/// 批次计划Id
/// </summary>

public string BatchId { get; set; }
/// <summary>
/// 起始时间
/// </summary>
public DateTime? StartTime { get; set; }


+ 9
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs View File

@@ -69,6 +69,15 @@
{
}

/// <summary>
/// 批次下发
/// </summary>
public class BatchInput
{
public string BatchId { get; set; }
}

/// <summary>
/// 下发
/// </summary>


+ 43
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkBatchService.cs View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.MES.Base.Application.Services
{
/// <summary>
/// 名 称 :
/// 创 建 人 :yangxiao
/// 创建时间 : 2024/4/8 15:41:42
/// 描 述 :
/// </summary>
public interface IWorkBatchService
{
/// <summary>
/// 增加
/// </summary>
/// <returns></returns>
Task<bool> Add(WorkBatchAddInput input);
/// <summary>
/// 移除
/// </summary>
/// <returns></returns>
Task<bool> Del(WorkBatchDelInput input);
/// <summary>
/// 更新
/// </summary>
/// <returns></returns>
Task<bool> Update(WorkBatchUpdateInput input);
/// <summary>
/// 不分页列表
/// </summary>
/// <returns></returns>
Task<List<WorkBatchOutput>> List(WorkBatchQueryInput input);
/// <summary>
/// 分页列表
/// </summary>
/// <returns></returns>
Task<SqlSugarPagedList<WorkBatchOutput>> PagedList(WorkBatchQueryPageInput input);
}
}

+ 6
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs View File

@@ -57,6 +57,12 @@
/// <returns></returns>
Task<bool> Publish(PublishInput input);
/// <summary>
/// 批次工单下发
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task<bool> Publishs(BatchInput input);
/// <summary>
/// 强制结束
/// </summary>
/// <param name="workId">工单Id</param>


+ 60
- 0
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkBatchService.cs View File

@@ -0,0 +1,60 @@
namespace BPA.MES.Base.Application.Services
{
/// <summary>
/// 名 称 :工单服务
/// 创 建 人 :yangxiao
/// 创建时间 :2023/7/20 14:39:41
/// 描 述 :
/// </summary>
[ApiDescriptionSettings("工单批次服务", Order = 0, Tag = "工单服务", Name = "WorkBatch", KeepName = true, SplitCamelCase = true, KeepVerb = true)]
public class WorkBatchService : IWorkBatchService, ITransient, IDynamicApiController
{
private readonly ISqlSugarClient _dbContext;
private readonly IMQTTService _MQTTService;
public WorkBatchService(ISqlSugarClient db, IMQTTService MQTTService)
{
_dbContext = db;
_MQTTService = MQTTService;
}
public async Task<bool> Add(WorkBatchAddInput input)
{
WorkBatchEntity entity = input.Adapt<WorkBatchEntity>();
entity.Status = WorkOrderStatusEnum.Draft;
return await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandIdentityIntoEntityAsync();
}

public async Task<bool> Del(WorkBatchDelInput input)
{
var res = await _dbContext.Deleteable<WorkBatchEntity>().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync();
return res;
}

public async Task<List<WorkBatchOutput>> List(WorkBatchQueryInput input)
{
var entity = await _dbContext.Queryable<WorkBatchEntity>().ToListAsync();
List<WorkBatchOutput> output = entity.Adapt<List<WorkBatchOutput>>();
return output;
}

public async Task<SqlSugarPagedList<WorkBatchOutput>> PagedList(WorkBatchQueryPageInput input)
{
var entity = await _dbContext.Queryable<WorkBatchEntity>()
.OrderByDescending(x => x.CreateTime)
.ToPagedListAsync(input.PageIndex, input.PageSize);
//foreach (var item in entity.Items)
//{
// item.Status = WorkOrderStatusEnum.Started
//}
SqlSugarPagedList<WorkBatchOutput> output = entity.Adapt<SqlSugarPagedList<WorkBatchOutput>>();
return output;
}

public async Task<bool> Update(WorkBatchUpdateInput input)
{
var entity = await _dbContext.Queryable<WorkBatchEntity>().Where(x => x.Id == input.Id).FirstAsync();
entity = input.Adapt<WorkBatchEntity>();
var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync();
return res;
}
}
}

+ 197
- 4
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs View File

@@ -155,16 +155,21 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
.LeftJoin<Pztj_FinalsInfoEntity>((a, b) => a.FinalId == b.Id)
.LeftJoin<ProductLineEntity>((a, b, c) => a.LineId == c.Id)
.LeftJoin<Pztj_WorkInfoStatusEntity>((a, b, c, d) => d.Id == SqlFunc.Subqueryable<Pztj_WorkInfoStatusEntity>().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id))
.LeftJoin<Pztj_DevicesInfoEntity>((a,b,c,d,e)=>a.DeviceId==e.Id)
.WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name))
.WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id))
.WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status))
.WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= a.CreateTime)
.WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= a.CreateTime)
.Select((a, b, c, d) => new WorkInfoOutput
.WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c, d) => a.BatchId == input.BatchId)
.WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status))
.WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= Convert.ToDateTime(a.CreateTime))
.WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime))
.OrderByDescending((a, b, c, d) => a.CreateTime)
.Select((a, b, c, d,e) => new WorkInfoOutput
{
Id = a.Id.SelectAll(),
FinalName = b.Name,
LineName = c.Name,
DeviceId = a.DeviceId == null ? "" : a.DeviceId,
DeviceName = e.Name,
Status = d.Status == null ? WorkOrderStatusEnum.Draft : d.Status
}).ToListAsync();
return entity;
@@ -176,6 +181,36 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
/// <returns></returns>
[HttpPost]
public async Task<SqlSugarPagedList<WorkInfoOutput>> PagedList(WorkInfoQueryPageInput input)
{
var entity = await _dbContext.Queryable<Pztj_WorkInfoEntity>()
.LeftJoin<Pztj_FinalsInfoEntity>((a, b) => a.FinalId == b.Id)
.LeftJoin<ProductLineEntity>((a, b, c) => a.LineId == c.Id)
.LeftJoin<Pztj_WorkInfoStatusEntity>((a, b, c, d) => d.Id == SqlFunc.Subqueryable<Pztj_WorkInfoStatusEntity>().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id))
.WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name))
.WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id))
.WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c, d) => a.BatchId==input.BatchId)
.WhereIF(input.Status != null, (a, b, c, d) => input.Status.Contains(d.Status))
.WhereIF(input.StartTime != null, (a, b, c, d) => input.StartTime <= Convert.ToDateTime(a.CreateTime))
.WhereIF(input.EndTime != null, (a, b, c, d) => input.EndTime.Value.AddHours(23).AddMinutes(59).AddSeconds(59) >= Convert.ToDateTime(a.CreateTime))
.OrderByDescending((a, b, c, d) => a.CreateTime)
.Select((a, b, c, d) => new WorkInfoOutput
{
Id = a.Id.SelectAll(),
FinalName = b.Name,
LineName = c.Name,
DeviceId = a.DeviceId == null?"": a.DeviceId,
Status = d.Status == null ? WorkOrderStatusEnum.Draft : d.Status
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
return entity;
}
/// <summary>
/// 分页
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task<SqlSugarPagedList<WorkInfoOutput>> BatchPagedList(WorkInfoQueryPageInput input)
{
var entity = await _dbContext.Queryable<Pztj_WorkInfoEntity>()
.LeftJoin<Pztj_FinalsInfoEntity>((a, b) => a.FinalId == b.Id)
@@ -197,6 +232,146 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
.ToPagedListAsync(input.PageIndex, input.PageSize);
return entity;
}

/// <summary>
/// 工单下发
/// </summary>
/// <param name="input">工单id</param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[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 _dbContext.Updateable<WorkBatchEntity>().SetColumns(x => x.Status == WorkOrderStatusEnum.Issued).Where(x => x.Id == input.BatchId).ExecuteCommandAsync();
return true;
}

/// <summary>
/// 工单下发
/// </summary>
@@ -358,6 +533,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
public async Task<bool> Update(WorkInfoUpdateInput input)
{
Pztj_WorkInfoEntity entity = input.Adapt<Pztj_WorkInfoEntity>();
entity.CreateTime = DateTime.Now;
var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync();
return res;
}
@@ -372,6 +548,23 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
{
Pztj_WorkInfoStatusEntity entity = input.Adapt<Pztj_WorkInfoStatusEntity>();
var res = await _dbContext.Insertable(entity).IgnoreColumns(true).ExecuteCommandIdentityIntoEntityAsync();
var entitys = await _dbContext.Queryable<Pztj_WorkInfoEntity>().Where(x => x.Id == input.WorkId)
.FirstAsync();
var workItems = await _dbContext.Queryable<Pztj_WorkInfoEntity>().LeftJoin<Pztj_WorkInfoStatusEntity>((a, b) => a.Id == b.WorkId).Where(a => a.BatchId == entitys.BatchId)
.Select((a, b) => new WorkInfoOutput
{
Id = a.Id.SelectAll(),
Status = b.Status,
})
.ToListAsync();
if (workItems.Max(x => x.Status) == WorkOrderStatusEnum.Completed && workItems.Min(x => x.Status) == WorkOrderStatusEnum.Completed)
{
await _dbContext.Updateable<WorkBatchEntity>().SetColumns(x => x.Status == WorkOrderStatusEnum.Completed).Where(x => x.Id == entitys.BatchId).ExecuteCommandAsync();
}
else
{
await _dbContext.Updateable<WorkBatchEntity>().SetColumns(x => x.Status == workItems.Max(x => x.Status)).Where(x => x.Id == entitys.BatchId).ExecuteCommandAsync();
}
return res;
}
/// <summary>


+ 1
- 1
backend/BPA.MES.Base.Web.Entry/BPA.MES.Base.Web.Entry.csproj.user View File

@@ -5,6 +5,6 @@
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>BPA.MES.Base.Web.Entry</ActiveDebugProfile>
<NameOfLastUsedPublishProfile>D:\Work\WFZ.MES\backend\BPA.MES.Base.Web.Entry\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<NameOfLastUsedPublishProfile>E:\PZTJ.MES\backend\BPA.MES.Base.Web.Entry\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>

Loading…
Cancel
Save