生产工单分配员工

This commit is contained in:
2024-06-18 16:54:30 +08:00
parent a30bcf213d
commit 8957dd9628
6 changed files with 64 additions and 17 deletions

View File

@@ -19,5 +19,10 @@ namespace Tnb.BasicData
/// 域名
/// </summary>
public const string DOMAIN = "domain";
/// <summary>
/// 空载具出库数量
/// </summary>
public const string EmptyCarryOutNum = "EmptyCarryOutNum";
}
}

View File

@@ -206,5 +206,9 @@ public partial class PrdMoTask : BaseEntity<string>
/// 暂停原因
/// </summary>
public string? pause_reason { get; set; }
/// <summary>
/// 分配员工id
/// </summary>
public string worker_id { get; set; }
}

View File

@@ -233,7 +233,7 @@ namespace Tnb.ProductionMgr
{
if (!inputMaterials.Contains(item["material_id"]))
{
throw new Exception("该物料不是生产bom投入物料不能签收");
throw new Exception("该物料不是生产bom投入物料不能投料");
}
PrdMaterialReceiptD? detail = await db.Queryable<PrdMaterialReceiptD>()

View File

@@ -1098,6 +1098,18 @@ namespace Tnb.ProductionMgr
string status = SetTaskStatus(behavior);
List<PrdMoTask>? list = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
if (behavior == PrdTaskBehavior.Release)
{
foreach(PrdMoTask item in list)
{
if (string.IsNullOrEmpty(item.worker_id))
{
throw Oops.Bah("请先分配员工");
}
}
}
if (behavior == PrdTaskBehavior.Compled)
{
// if (list?.Count > 0)
@@ -3315,6 +3327,23 @@ namespace Tnb.ProductionMgr
Log.Information($"视觉设备判定参数:{JsonConvert.SerializeObject(input)}");
return $"接收到参数:{JsonConvert.SerializeObject(input)}";
}
/// <summary>
/// 分配员工
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task<string> BindUser(Dictionary<String,String> input)
{
string id = input.GetOrDefault("id");
string workerId = input.GetOrDefault("worker_id");
int row = await _db.Updateable<PrdMoTask>()
.SetColumns(x => x.worker_id == workerId)
.Where(x => x.id == id)
.ExecuteCommandAsync();
return row>0 ? "分配成功" : "分配失败";
}
}

View File

@@ -1,4 +1,5 @@
using JNPF.Common.Enums;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Filter;
using JNPF.Common.Security;
@@ -34,10 +35,14 @@ namespace Tnb.ProductionMgr
{
private readonly ISqlSugarClient _db;
private readonly IDictionaryDataService _dictionaryDataService;
private readonly IUserManager _userManager;
private static Dictionary<string, Tuple<string, string>> _dicWorkLine = new();
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository, IDictionaryDataService dictionaryDataService)
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository,
IUserManager userManager,
IDictionaryDataService dictionaryDataService)
{
_db = repository.AsSugarClient();
_userManager = userManager;
_dictionaryDataService = dictionaryDataService;
}
/// <summary>
@@ -363,20 +368,20 @@ namespace Tnb.ProductionMgr
}
/// <summary>
/// pda端根据工位获取任务单列表
/// PAD,pda端根据工位获取任务单列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetPadPrdMoTaskList(PrdMoTaskListOutput input)
{
if (string.IsNullOrEmpty(input.stationId))
{
return new
{
pagination = new PageResult(),
list = Array.Empty<string>()
};
}
// if (string.IsNullOrEmpty(input.stationId))
// {
// return new
// {
// pagination = new PageResult(),
// list = Array.Empty<string>()
// };
// }
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
string? mo_task_code = queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
@@ -408,7 +413,7 @@ namespace Tnb.ProductionMgr
input.sidx = "create_time";
input.sort = "desc";
}
SqlSugarPagedList<PADPackageTaskPageOutput> result = await _db.Queryable<PrdMoTask>()
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
.LeftJoin<BasProcess>((a, b, c) => a.process_id == c.id)
@@ -421,7 +426,8 @@ namespace Tnb.ProductionMgr
.LeftJoin<PrdMo>((a, b, c, d, e, f, g, h, i, j) => a.mo_id == j.id)
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg")
.LeftJoin<EqpDaq>((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求
.Where((a, b) => a.workstation_id == input.stationId)
// .Where((a, b) => a.workstation_id == input.stationId)
.Where((a, b) => a.worker_id == _userManager.UserId)
.WhereIF(!string.IsNullOrEmpty(mo_task_code), a => a.mo_task_code.Contains(mo_task_code))
//.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status)
.WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status))

View File

@@ -139,12 +139,13 @@ namespace Tnb.ProductionMgr
public async Task<string> EmptyCarryOutStkCtu1()
{
string msg = "";
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.EmptyCarryOutNum);
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "SSX-021-001";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
input.qty = 1;
input.qty = int.Parse(config?.value ?? "5");
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】ctu1空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
@@ -167,12 +168,13 @@ namespace Tnb.ProductionMgr
public async Task<string> EmptyCarryOutStkCtu3()
{
string msg = "";
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.EmptyCarryOutNum);
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "SSX-021-003";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
input.qty = 1;
input.qty = int.Parse(config?.value ?? "5");
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】ctu3空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);
@@ -195,12 +197,13 @@ namespace Tnb.ProductionMgr
public async Task<string> EmptyCarryOutStkCtu6()
{
string msg = "";
BasFactoryConfig config = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.EmptyCarryOutNum);
MESEmptyCarryOutStkInput input = new MESEmptyCarryOutStkInput();
input.org_id = WmsWareHouseConst.AdministratorOrgId;
input.location_code = "SSX-011-006";
input.warehouse_id = WmsWareHouseConst.WAREHOUSE_ZC_ID;
input.carrystd_id = WmsWareHouseConst.LIAOXIANGID;
input.qty = 1;
input.qty = int.Parse(config?.value ?? "5");
input.create_id = WmsWareHouseConst.AdministratorUserId;
Log.Information($"【EmptyCarryOutStk】ctu6空箱入呼叫开始,参数:{JsonConvert.SerializeObject(input)}");
Result result = await _wmsEmptyOutstockService.MESEmptyCarryOutStk(input);