提报数量限制

This commit is contained in:
2023-07-28 09:55:13 +08:00
parent ec0697d5f8
commit ae80a0a971
4 changed files with 130 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
namespace Tnb.BasicData
{
/// <summary>
/// 工厂基础数据
/// </summary>
public static class FactoryConfigConst
{
/// <summary>
/// 报工是否允许超过工单计划数 是1 否 0
/// </summary>
public const string IS_SURPASS = "is_surpass";
/// <summary>
/// 报工允许超过工单计划数百分比 例填写10就是10%
/// </summary>
public const string IS_SURPASS_PERCENTAGE = "is_surpass_percentage";
}
}

View File

@@ -0,0 +1,87 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.BasicData.Entities;
/// <summary>
/// 工厂基础数据
/// </summary>
[SugarTable("bas_factory_config")]
public partial class BasFactoryConfig : BaseEntity<string>
{
public BasFactoryConfig()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 名称
/// </summary>
public string name { get; set; } = string.Empty;
/// <summary>
/// key
/// </summary>
public string key { get; set; } = string.Empty;
/// <summary>
/// 值
/// </summary>
public string value { get; set; } = string.Empty;
/// <summary>
/// 是否启用
/// </summary>
public int enabled { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? remark { get; set; }
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
/// <summary>
/// 所属组织
/// </summary>
public string? org_id { get; set; }
/// <summary>
/// 排序
/// </summary>
public long? ordinal { get; set; }
/// <summary>
/// 是否系统
/// </summary>
public int? is_system { get; set; }
/// <summary>
/// 流程任务Id
/// </summary>
public string? f_flowtaskid { get; set; }
/// <summary>
/// 流程引擎Id
/// </summary>
public string? f_flowid { get; set; }
}

View File

@@ -53,5 +53,10 @@ public partial class PrdInstockD : BaseEntity<string>
/// 生产提报id
/// </summary>
public string report_id { get; set; } = string.Empty;
/// <summary>
/// 生产任务单号
/// </summary>
public string mo_task_code { get; set; } = string.Empty;
}

View File

@@ -1361,6 +1361,26 @@ namespace Tnb.ProductionMgr
throw Oops.Bah("暂停的任务单无法提报");
}
if ((prdMoTask.reported_work_qty ?? 0) + input.reported_qty > prdMoTask.scheduled_qty)
{
var config1 = await db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.IS_SURPASS);
if (config1?.value == "1")
{
var config2 = await db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.IS_SURPASS_PERCENTAGE);
if (!string.IsNullOrEmpty(config2?.value))
{
if ((prdMoTask.reported_work_qty ?? 0) + input.reported_qty > prdMoTask.scheduled_qty*(100+Convert.ToDecimal(config2?.value ?? "1"))/100)
{
throw Oops.Bah($"提报数量不能大于{100+Convert.ToDecimal(config2?.value ?? "0")}%排产数量");
}
}
}
else
{
throw Oops.Bah("提报数量不能大于排产数量");
}
}
// bool flag = (prdMoTask.reported_work_qty ?? 0) + (prdMoTask.scrap_qty ?? 0) + input.reported_qty == prdMoTask.scheduled_qty;
// if ((prdMoTask.reported_work_qty ?? 0) + (prdMoTask.scrap_qty ?? 0) + input.reported_qty > prdMoTask.scheduled_qty)