更换员工
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class ChangeWorkerInput
|
||||||
|
{
|
||||||
|
public string mo_task_id { get; set; }
|
||||||
|
public string worker_id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
public int? complete_qty { get; set; }
|
public int? complete_qty { get; set; }
|
||||||
public int? scheduled_qty { get; set; }
|
public int? scheduled_qty { get; set; }
|
||||||
public string workline_id { get; set; }
|
public string workline_id { get; set; }
|
||||||
|
public string worker_id { get; set; }
|
||||||
public string workline_id_id { get; set; }
|
public string workline_id_id { get; set; }
|
||||||
public string estimated_start_date { get; set; }
|
public string estimated_start_date { get; set; }
|
||||||
public string estimated_end_date { get; set; }
|
public string estimated_end_date { get; set; }
|
||||||
|
|||||||
@@ -2568,13 +2568,14 @@ namespace Tnb.ProductionMgr
|
|||||||
.LeftJoin<PrdMo>((a, b, c, d, e, f) => a.mo_id == f.id)
|
.LeftJoin<PrdMo>((a, b, c, d, e, f) => a.mo_id == f.id)
|
||||||
.LeftJoin<OrganizeEntity>((a, b, c, d, e, f, g) => a.workline_id == g.Id)
|
.LeftJoin<OrganizeEntity>((a, b, c, d, e, f, g) => a.workline_id == g.Id)
|
||||||
.LeftJoin<EqpEquipment>((a, b, c, d, e, f, g, h) => a.eqp_id == h.id)
|
.LeftJoin<EqpEquipment>((a, b, c, d, e, f, g, h) => a.eqp_id == h.id)
|
||||||
|
.LeftJoin<UserEntity>((a, b, c, d, e, f, g, h,i)=>a.worker_id==i.Id)
|
||||||
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
|
.WhereIF(!string.IsNullOrEmpty(moTaskCode), (a, b, c, d) => a.mo_task_code.Contains(moTaskCode))
|
||||||
.WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count <= 0 && worklineIds.Count <= 0,
|
.WhereIF(!string.IsNullOrEmpty(eqpId) && equipIds.Count <= 0 && worklineIds.Count <= 0,
|
||||||
(a, b, c, d) => a.workline_id == eqpId || a.eqp_id == eqpId)
|
(a, b, c, d) => a.workline_id == eqpId || a.eqp_id == eqpId)
|
||||||
.WhereIF(worklineIds.Count > 0, (a, b, c, d) => worklineIds.Contains(a.workline_id))
|
.WhereIF(worklineIds.Count > 0, (a, b, c, d) => worklineIds.Contains(a.workline_id))
|
||||||
.WhereIF(equipIds.Count > 0, (a, b, c, d) => equipIds.Contains(a.eqp_id))
|
.WhereIF(equipIds.Count > 0, (a, b, c, d) => equipIds.Contains(a.eqp_id))
|
||||||
.Where((a) => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_code == DictConst.ToBeScheduledEncode || a.mo_task_code == DictConst.MoStatusPauseCode)
|
.Where((a) => a.mo_task_status == DictConst.ToBeStartedEnCode || a.mo_task_code == DictConst.ToBeScheduledEncode || a.mo_task_code == DictConst.MoStatusPauseCode)
|
||||||
.Select((a, b, c, d, e, f, g, h) => new WorkOrderAdjustmentListOutput
|
.Select((a, b, c, d, e, f, g, h,i) => new WorkOrderAdjustmentListOutput
|
||||||
{
|
{
|
||||||
id = a.id,
|
id = a.id,
|
||||||
mo_task_code = a.mo_task_code,
|
mo_task_code = a.mo_task_code,
|
||||||
@@ -2594,6 +2595,7 @@ namespace Tnb.ProductionMgr
|
|||||||
eqp_id_id = a.eqp_id,
|
eqp_id_id = a.eqp_id,
|
||||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||||
schedule_type = a.schedule_type,
|
schedule_type = a.schedule_type,
|
||||||
|
worker_id = i.RealName
|
||||||
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
|
}).OrderByDescending(a => a.create_time).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
return PageResult<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
|
return PageResult<WorkOrderAdjustmentListOutput>.SqlSugarPageResult(result);
|
||||||
}
|
}
|
||||||
@@ -2845,6 +2847,53 @@ namespace Tnb.ProductionMgr
|
|||||||
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
|
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更换员工
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> ChangeWorker(ChangeWorkerInput input)
|
||||||
|
{
|
||||||
|
ISqlSugarClient db = _repository.AsSugarClient();
|
||||||
|
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||||
|
{
|
||||||
|
PrdMoTask moTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||||
|
if (moTask.worker_id == input.worker_id)
|
||||||
|
{
|
||||||
|
throw new Exception("与原员工相同");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_ = await db.Updateable<PrdMoTask>().SetColumns(x => x.worker_id == input.worker_id)
|
||||||
|
.Where(x => x.id == input.mo_task_id).ExecuteCommandAsync();
|
||||||
|
|
||||||
|
PrdMo mo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == moTask.mo_id);
|
||||||
|
BasMaterial? material = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.material_id);
|
||||||
|
BasMaterial process = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == moTask.process_id);
|
||||||
|
PrdTaskLog taskLog = new()
|
||||||
|
{
|
||||||
|
id = SnowflakeIdHelper.NextId(),
|
||||||
|
mo_code = mo?.mo_code!,
|
||||||
|
eqp_code = "",
|
||||||
|
mold_code = "",
|
||||||
|
item_code = material?.code!,
|
||||||
|
item_standard = material?.material_specification!,
|
||||||
|
status = "更换员工",
|
||||||
|
operator_name = _userManager.RealName,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now,
|
||||||
|
mo_task_id = moTask.id,
|
||||||
|
mo_task_code = moTask.mo_task_code,
|
||||||
|
station_code = "",
|
||||||
|
process_code = process?.code
|
||||||
|
};
|
||||||
|
|
||||||
|
_ = await db.Insertable<PrdTaskLog>(taskLog).ExecuteCommandAsync();
|
||||||
|
});
|
||||||
|
|
||||||
|
return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "更换成功" : result.ErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据id获取任务单相关信息
|
/// 根据id获取任务单相关信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user