生产任务排产,新增 任务 下发、开始、关闭、完成 接口
This commit is contained in:
@@ -40,6 +40,18 @@ public static class DictConst
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ToBeStartedEnCode = "ToBeStarted";
|
public const string ToBeStartedEnCode = "ToBeStarted";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 任务单状态-进行中
|
||||||
|
/// </summary>
|
||||||
|
public const string InProgressEnCode = "InProgress";
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单状态-关闭编码
|
||||||
|
/// </summary>
|
||||||
|
public const string ClosedEnCode = "Closed";
|
||||||
|
/// <summary>
|
||||||
|
/// 任务单状态-完工编码
|
||||||
|
/// </summary>
|
||||||
|
public const string ComplatedEnCode = "Complated";
|
||||||
|
/// <summary>
|
||||||
/// 任务单状态-待排产
|
/// 任务单状态-待排产
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ToBeScheduledEncode = "ToBeScheduled";
|
public const string ToBeScheduledEncode = "ToBeScheduled";
|
||||||
|
|||||||
@@ -15,5 +15,14 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
|||||||
/// 生产任务ID列表
|
/// 生产任务ID列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> TaskIds { get; set; }
|
public List<string> TaskIds { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 行为:
|
||||||
|
///<br/> Release(任务下发),
|
||||||
|
///<br/> Start(任务开始),
|
||||||
|
///<br/> Closed(任务关闭),
|
||||||
|
///<br/> Compled(任务完成)
|
||||||
|
/// </summary>
|
||||||
|
public string Behavior { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
ProductionMgr/Tnb.ProductionMgr.Entitys/Enums/Behavior.cs
Normal file
23
ProductionMgr/Tnb.ProductionMgr.Entitys/Enums/Behavior.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
namespace Tnb.ProductionMgr.Entities.Enums
|
||||||
|
{
|
||||||
|
public enum Behavior
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 任务下发
|
||||||
|
/// </summary>
|
||||||
|
Release = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务开始
|
||||||
|
/// </summary>
|
||||||
|
Start = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务关闭
|
||||||
|
/// </summary>
|
||||||
|
Closed = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// 任务完成
|
||||||
|
/// </summary>
|
||||||
|
Compled = 8,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
using Aop.Api.Domain;
|
||||||
using JNPF.Common.Core.Manager;
|
using JNPF.Common.Core.Manager;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
using JNPF.DynamicApiController;
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.Extensitions.EventBus;
|
||||||
using JNPF.FriendlyException;
|
using JNPF.FriendlyException;
|
||||||
using JNPF.Logging;
|
using JNPF.Logging;
|
||||||
using JNPF.Systems.Interfaces.System;
|
using JNPF.Systems.Interfaces.System;
|
||||||
@@ -19,6 +21,7 @@ using Tnb.BasicData.Entitys.Entity;
|
|||||||
using Tnb.EquipMgr.Entities;
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.ProductionMgr.Entities;
|
using Tnb.ProductionMgr.Entities;
|
||||||
using Tnb.ProductionMgr.Entities.Dto;
|
using Tnb.ProductionMgr.Entities.Dto;
|
||||||
|
using Tnb.ProductionMgr.Entities.Enums;
|
||||||
using Tnb.ProductionMgr.Interfaces;
|
using Tnb.ProductionMgr.Interfaces;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
@@ -164,7 +167,7 @@ namespace Tnb.ProductionMgr
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查看工单操作记录
|
/// 查看生产任务操作记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="taskId">任务ID</param>
|
/// <param name="taskId">任务ID</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -383,7 +386,7 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
if (row > 0)
|
if (row > 0)
|
||||||
{
|
{
|
||||||
if (icmoEntities?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null)
|
if (icmoEntities?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null)
|
||||||
{
|
{
|
||||||
var moList = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
var moList = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||||
var combinePlanQty = icmoEntities?.Sum(x => x.plan_qty); //合并工单后的计划数量
|
var combinePlanQty = icmoEntities?.Sum(x => x.plan_qty); //合并工单后的计划数量
|
||||||
@@ -458,23 +461,59 @@ namespace Tnb.ProductionMgr
|
|||||||
return row > 0;
|
return row > 0;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生产任务下发
|
/// 生产任务下发,开始 、结束、完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="input">输入参数</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<dynamic> PrdTaskRelease(PrdTaskReleaseUpInput input)
|
public async Task<dynamic> PrdTaskRelease(PrdTaskReleaseUpInput input)
|
||||||
{
|
{
|
||||||
|
var row = -1;
|
||||||
if (input is null)
|
if (input is null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(input));
|
throw new ArgumentNullException(nameof(input));
|
||||||
}
|
}
|
||||||
|
if (input.TaskIds is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(input.TaskIds));
|
||||||
|
}
|
||||||
|
if (input.Behavior.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
|
||||||
|
}
|
||||||
|
string SetTaskStatus(Behavior behavior) => behavior switch
|
||||||
|
{
|
||||||
|
Behavior.Release => DictConst.ToBeStartedEnCode,
|
||||||
|
Behavior.Start => DictConst.InProgressEnCode,
|
||||||
|
Behavior.Closed => DictConst.ClosedEnCode,
|
||||||
|
Behavior.Compled => DictConst.ComplatedEnCode,
|
||||||
|
_ => throw new NotImplementedException(),
|
||||||
|
};
|
||||||
|
Behavior behavior = input.Behavior.ToEnum<Behavior>();
|
||||||
|
var status = SetTaskStatus(behavior);
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
var row = await db.Updateable<PrdTask>()
|
if (behavior == Behavior.Compled)
|
||||||
.SetColumns(it => new PrdTask { status = DictConst.ToBeStartedEnCode })
|
{
|
||||||
.Where(it => input.TaskIds.Contains(it.id))
|
var list = await db.Queryable<PrdTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
|
||||||
.ExecuteCommandAsync();
|
if (list?.Count > 0)
|
||||||
|
{
|
||||||
|
var schedQtySum = list.Sum(x => x.scheduled_qty);
|
||||||
|
var planQtySum = list.Sum(x => x.plan_qty);
|
||||||
|
if (schedQtySum < planQtySum)
|
||||||
|
{
|
||||||
|
throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
row = await db.Updateable<PrdTask>()
|
||||||
|
.SetColumns(it => new PrdTask { status = status })
|
||||||
|
.Where(it => input.TaskIds.Contains(it.id))
|
||||||
|
.ExecuteCommandAsync();
|
||||||
return (row > 0);
|
return (row > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生产任务单修改
|
/// 生产任务单修改
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -486,7 +525,7 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
var row = -1;
|
var row = -1;
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
if(input.icmo_id.IsNullOrWhiteSpace())
|
if (input.icmo_id.IsNullOrWhiteSpace())
|
||||||
throw new ArgumentNullException(nameof(input.icmo_id));
|
throw new ArgumentNullException(nameof(input.icmo_id));
|
||||||
var icmoItem = await db.Queryable<PrdTask>().FirstAsync(it => it.id == input.icmo_id);
|
var icmoItem = await db.Queryable<PrdTask>().FirstAsync(it => it.id == input.icmo_id);
|
||||||
switch (input.category)
|
switch (input.category)
|
||||||
@@ -533,7 +572,7 @@ namespace Tnb.ProductionMgr
|
|||||||
if (row > 0)
|
if (row > 0)
|
||||||
{
|
{
|
||||||
var prdMo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == prdTask.mo_id);
|
var prdMo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == prdTask.mo_id);
|
||||||
if (prdMo is not null)
|
if (prdMo is not null)
|
||||||
{
|
{
|
||||||
prdMo.input_qty += prdTask.scheduled_qty;
|
prdMo.input_qty += prdTask.scheduled_qty;
|
||||||
prdMo.icmo_status = DictConst.ToBeScheduledEncode;
|
prdMo.icmo_status = DictConst.ToBeScheduledEncode;
|
||||||
@@ -546,4 +585,5 @@ namespace Tnb.ProductionMgr
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -938,5 +938,16 @@ public static class StringExtensions
|
|||||||
return kq * q / ((kq * q) + (kr * r) + (ks * s));
|
return kq * q / ((kq * q) + (kr * r) + (ks * s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串转枚举
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">枚举类型</typeparam>
|
||||||
|
/// <param name="value">字符串值</param>
|
||||||
|
/// <returns>枚举值</returns>
|
||||||
|
public static T ToEnum<T>(this string value)
|
||||||
|
{
|
||||||
|
return (T)System.Enum.Parse(typeof(T), value, true);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user