Browse Source

ss

master
Yanko 2 months ago
parent
commit
a109b5191a
7 changed files with 291 additions and 28 deletions
  1. +98
    -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. +4
    -0
      backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs
  4. +26
    -0
      backend/BPA.MES.Base.Application/Entitys/Base/WorkDeviceRecordEntity.cs
  5. +54
    -5
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs
  6. +2
    -0
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs
  7. +103
    -23
      backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs

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

@@ -572,6 +572,11 @@
创建时间
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoEntity.PlanId">
<summary>
生产计划Id
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.Pztj_WorkInfoItemEntity">
<summary>
名 称 :工单拆分
@@ -654,6 +659,11 @@
工单Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity.DeviceId">
<summary>
设备Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.WorkInfoCraftstepRecordEntity.CraftId">
<summary>
工艺Id
@@ -1145,6 +1155,31 @@
描 述 :
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.Base.WorkDeviceRecordEntity">
<summary>
工单所属设备保存
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Base.WorkDeviceRecordEntity.WorkId">
<summary>
工单Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Base.WorkDeviceRecordEntity.LineId">
<summary>
产线Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Base.WorkDeviceRecordEntity.ProcessId">
<summary>
产线工序Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Entitys.Base.WorkDeviceRecordEntity.DeviceId">
<summary>
设备Id
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Entitys.ProcessEntity">
<summary>
工艺流程库
@@ -9050,6 +9085,11 @@
工单名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoDto.PlanId">
<summary>
生产计划Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoDto.LineId">
<summary>
产线Id
@@ -9085,6 +9125,21 @@
增加
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoAddInput.WorkDevices">
<summary>
产线工序Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkDeviceAddInput.ProcessId">
<summary>
产线工序Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkDeviceAddInput.DeviceId">
<summary>
设备
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoUpdateInput">
<summary>
更新
@@ -9095,6 +9150,11 @@
主键
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoUpdateInput.WorkDevices">
<summary>
产线工序Id
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoDelInput">
<summary>
删除
@@ -9240,6 +9300,37 @@
物料信息
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput">
<summary>
编辑页面
</summary>
<returns></returns>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput.PlanId">
<summary>
生产计划Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput.FinalName">
<summary>
成品名称
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput.Quantity">
<summary>
数量
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput.LineId">
<summary>
产线Id
</summary>
</member>
<member name="P:BPA.MES.Base.Application.Services.WorkInfoEditDetailOutput.WorkDevices">
<summary>
产线工序Id
</summary>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoItemDto">
<summary>
名 称 :工单产量
@@ -9916,6 +10007,13 @@
<param name="workId"></param>
<returns></returns>
</member>
<member name="M:BPA.MES.Base.Application.Services.WorkInfoService.Services.WorkInfoService.EditDetail(System.String)">
<summary>
获取编辑详情
</summary>
<param name="Id"></param>
<returns></returns>
</member>
<member name="T:BPA.MES.Base.Application.Services.WorkInfoStatusService">
<summary>
名 称 :


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

@@ -44,5 +44,9 @@
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 生产计划Id
/// </summary>
public string PlanId { get; set; }
}
}

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

@@ -14,6 +14,10 @@
/// </summary>
public string WorkId { get; set; }
/// <summary>
/// 设备Id
/// </summary>
public string DeviceId { get; set; }
/// <summary>
/// 工艺Id
/// </summary>
public string CraftId { get; set; }


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

@@ -0,0 +1,26 @@
namespace BPA.MES.Base.Application.Entitys.Base
{
/// <summary>
/// 工单所属设备保存
/// </summary>
[SugarTable("work_device_record")]
public class WorkDeviceRecordEntity : DEntityBase
{
/// <summary>
/// 工单Id
/// </summary>
public string WorkId { get; set; }
/// <summary>
/// 产线Id
/// </summary>
public string LineId { get; set; }
/// <summary>
/// 产线工序Id
/// </summary>
public string ProcessId { get; set; }
/// <summary>
/// 设备Id
/// </summary>
public string DeviceId { get; set; }
}
}

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

@@ -13,6 +13,10 @@
/// </summary>
public string Name { get; set; }
/// <summary>
/// 生产计划Id
/// </summary>
public string PlanId { get; set; }
/// <summary>
/// 产线Id
/// </summary>
public string LineId { get; set; }
@@ -45,8 +49,24 @@
/// </summary>
public class WorkInfoAddInput : WorkInfoDto
{
/// <summary>
/// 产线工序Id
/// </summary>
public List<WorkDeviceAddInput> WorkDevices { get; set; } = new();

}

public class WorkDeviceAddInput
{
/// <summary>
/// 产线工序Id
/// </summary>
public string ProcessId { get; set; }
/// <summary>
/// 设备
/// </summary>
public string DeviceId { get; set; }
}
/// <summary>
/// 更新
/// </summary>
@@ -56,6 +76,10 @@
/// 主键
/// </summary>
public string Id { get; set; }
/// <summary>
/// 产线工序Id
/// </summary>
public List<WorkDeviceAddInput> WorkDevices { get; set; } = new();
}
/// <summary>
/// 删除
@@ -166,7 +190,7 @@
/// </summary>
public WorkOrderStatusEnum? Status { get; set; }


}
/// <summary>
@@ -191,13 +215,38 @@
/// <summary>
/// 工艺步骤
/// </summary>
public List<WorkInfoCraftstepRecordEntity> CraftList { get; set; }
public List<WorkInfoCraftstepRecordEntity> CraftList { get; set; }
/// <summary>
/// 物料信息
/// </summary>
public List<WorkInfoMaterialsRecordOutput> MaterialList { get; set; }
public List<WorkInfoMaterialsRecordOutput> MaterialList { get; set; }
}


/// <summary>
/// 编辑页面
/// </summary>
/// <returns></returns>
public class WorkInfoEditDetailOutput
{
/// <summary>
/// 生产计划Id
/// </summary>
public string PlanId { get; set; }
/// <summary>
/// 成品名称
/// </summary>
public string FinalName { get; set; }
/// <summary>
/// 数量
/// </summary>
public string Quantity { get; set; }
/// <summary>
/// 产线Id
/// </summary>
public string LineId { get; set; }
/// <summary>
/// 产线工序Id
/// </summary>
public List<WorkDeviceAddInput> WorkDevices { get; set; } = new();
}
}

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

@@ -23,6 +23,8 @@
/// </summary>
/// <returns></returns>
Task<bool> Update(WorkInfoUpdateInput input);

Task<WorkInfoEditDetailOutput> EditDetail(string Id);
/// <summary>
/// 不分页列表
/// </summary>


+ 103
- 23
backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs View File

@@ -1,4 +1,6 @@
using Furion.EventBus;
using BPA.MES.Base.Application.Entitys.Base;
using Furion.EventBus;
using System.Security.Cryptography;
using Yitter.IdGenerator;

namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
@@ -29,20 +31,36 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
{
bool result = false;
Pztj_WorkInfoEntity entity = input.Adapt<Pztj_WorkInfoEntity>();
List<WorkDeviceRecordEntity> workDeviceRecordEntities = new();
foreach (var item in input.WorkDevices)
{
WorkDeviceRecordEntity workDeviceRecordEntity = new()
{
DeviceId = item.DeviceId,
WorkId = entity.Id,
ProcessId = item.ProcessId,
LineId = input.LineId,
};
workDeviceRecordEntities.Add(workDeviceRecordEntity);
}
Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
{
Status = WorkOrderStatusEnum.Draft,
WorkId = entity.Id
};
try
{
_dbContext.Ado.BeginTran();
await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
if (workDeviceRecordEntities.Count>1)
{
Status = WorkOrderStatusEnum.Draft,
WorkId = entity.Id
};
await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync();
}
await _dbContext.Insertable(pztj_WorkInfoStatusEntity).IgnoreColumns(true).ExecuteCommandAsync();
_dbContext.Ado.CommitTran();
result = true;
}
catch
catch (Exception ex)
{
_dbContext.Ado.RollbackTran();
throw Oops.Bah("添加失败!");
@@ -74,7 +92,7 @@ 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)
.LeftJoin<Pztj_DevicesInfoEntity>((a, b, c, d, e) => a.DeviceId==e.Id)
.Where((a, b, c, d) => a.Id == Id)
.Select((a, b, c, d, e) => new WorkInfoDetailOutput
{
@@ -100,10 +118,10 @@ 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<Pztj_MaterialsInfoEntity>((a, b) => a.MaterialId==b.Id)
.LeftJoin<DictDataEntity>((a, b, c) => b.Type == c.Id)
.Where((a, b) => a.WorkId == Id)
.Select((a, b,c) =>
.Select((a, b, c) =>
new WorkInfoMaterialsRecordOutput
{
Id = a.Id.SelectAll(),
@@ -154,7 +172,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
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_DevicesInfoEntity>((a, b, c, d) =>a.DeviceId==d.Id)
.LeftJoin<Pztj_DevicesInfoEntity>((a, b, c, d) => a.DeviceId==d.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)
@@ -247,7 +265,7 @@ 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;
var workentitys = await _dbContext.Queryable<Pztj_WorkInfoEntity>().Where(x => x.BatchId == input.BatchId).ToListAsync();
foreach (var item in workentitys)
{
var res = await UpdateStatus(
@@ -283,7 +301,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
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)
//.Where((a, b, c) => a.RecipesId == finainfo.RecipeId)
.Select((a, b, c) => new WorkInfoMaterialsRecordEntity
{
MaterialId = a.MaterialId,
@@ -397,9 +415,9 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
Remark = $"[{userId}]{userName}"
});
var workentity = await _dbContext.Queryable<Pztj_WorkInfoEntity>()
.LeftJoin<Pztj_DevicesInfoEntity>((a,b)=>a.DeviceId==b.Id)
.LeftJoin<Pztj_DevicesInfoEntity>((a, b) => a.DeviceId==b.Id)
.Where((a, b) => a.Id == input.WorkId)
.Select((a,b)=>new WorkInfoOutput
.Select((a, b) => new WorkInfoOutput
{
Id=a.Id.SelectAll(),
DeviceCode = b.Code,
@@ -421,8 +439,8 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services

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)
.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,
@@ -498,7 +516,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
_dbContext.Ado.BeginTran();
await _dbContext.Deleteable<WorkInfoCraftstepRecordEntity>().Where(x => x.WorkId == input.WorkId).ExecuteCommandAsync();
await _dbContext.Deleteable<WorkInfoMaterialsRecordEntity>().Where(x => x.WorkId == input.WorkId).ExecuteCommandAsync();
await _dbContext.Insertable(newcraftslist).ExecuteCommandAsync();
await _dbContext.Insertable(newmateriallist).ExecuteCommandAsync();
_dbContext.Ado.CommitTran();
@@ -536,10 +554,43 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpPost]
public async Task<bool> Update(WorkInfoUpdateInput input)
{
bool result = false;
Pztj_WorkInfoEntity entity = input.Adapt<Pztj_WorkInfoEntity>();
entity.CreateTime = DateTime.Now;
var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync();
return res;
List<WorkDeviceRecordEntity> workDeviceRecordEntities = new();
foreach (var item in input.WorkDevices)
{
WorkDeviceRecordEntity workDeviceRecordEntity = new()
{
DeviceId = item.DeviceId,
WorkId = entity.Id,
ProcessId = item.ProcessId,
LineId = input.LineId,
};
workDeviceRecordEntities.Add(workDeviceRecordEntity);
}
Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
{
Status = WorkOrderStatusEnum.Draft,
WorkId = entity.Id
};
try
{
_dbContext.Ado.BeginTran();
await _dbContext.Updateable(entity).Where(x=>x.Id==input.Id).IgnoreColumns(true).ExecuteCommandAsync();
await _dbContext.Deleteable<WorkDeviceRecordEntity>().Where(x => x.WorkId==input.Id).ExecuteCommandAsync();
if (workDeviceRecordEntities.Count>1)
{
await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync();
}
_dbContext.Ado.CommitTran();
result = true;
}
catch (Exception ex)
{
_dbContext.Ado.RollbackTran();
throw Oops.Bah("添加失败!");
}
return result;
}
/// <summary>
/// 修改工单状态
@@ -661,10 +712,39 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpGet]
public async Task<List<WorkInfoStatusOutput>> StatusList(string workId)
{
var entitys = await _dbContext.Queryable<Pztj_WorkInfoStatusEntity>().Where(x => x.WorkId == workId).OrderByDescending(x=>x.CreateTime).ToListAsync();
var entitys = await _dbContext.Queryable<Pztj_WorkInfoStatusEntity>().Where(x => x.WorkId == workId).OrderByDescending(x => x.CreateTime).ToListAsync();
List<WorkInfoStatusOutput> list = entitys.Adapt<List<WorkInfoStatusOutput>>();
return list;
}
/// <summary>
/// 获取编辑详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
public async Task<WorkInfoEditDetailOutput> EditDetail(string Id)
{
var entity = await _dbContext.Queryable<Pztj_WorkInfoEntity>()
.LeftJoin<WorkPlanEntity>((a, b) => a.PlanId == b.Id)
.LeftJoin<Pztj_FinalsInfoEntity>((a, b, c) => a.FinalId == c.Id)
.Where((a, b, c) => a.Id == Id)
.Select((a, b, c) => new WorkInfoEditDetailOutput
{
PlanId = a.PlanId,
FinalName = c.Name,
LineId = a.LineId,
Quantity = b.Quantity
}).FirstAsync();
var devicelist = await _dbContext.Queryable<WorkDeviceRecordEntity>().Where(x => x.WorkId==Id)
.Select(x => new WorkDeviceAddInput
{
DeviceId = x.DeviceId,
ProcessId = x.ProcessId,
})
.ToListAsync();
entity.WorkDevices = devicelist;
return entity;
}
}
}

Loading…
Cancel
Save