巡检
This commit is contained in:
@@ -241,4 +241,8 @@ public partial class PrdMoTask : BaseEntity<string>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string nightshiftafter_worker_id { get; set; }
|
public string nightshiftafter_worker_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 定时任务key
|
||||||
|
/// </summary>
|
||||||
|
public string timer_key { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Tnb.ProductionMgr.Helpers
|
|||||||
// 初始化代码,如果有必要的话
|
// 初始化代码,如果有必要的话
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartTimer(TimerCallback timerCallback,object data,TimeSpan dueTime, TimeSpan period)
|
public void StartTimer(TimerCallback timerCallback,object data,TimeSpan dueTime, TimeSpan period,bool autoClode = true)
|
||||||
{
|
{
|
||||||
Timer timer;
|
Timer timer;
|
||||||
lock (_lockObject)
|
lock (_lockObject)
|
||||||
@@ -36,16 +36,19 @@ namespace Tnb.ProductionMgr.Helpers
|
|||||||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||||||
dic.Add("key",timestamp);
|
dic.Add("key",timestamp);
|
||||||
dic.Add("value",data);
|
dic.Add("value",data);
|
||||||
timerCallback += DisposeTimer;
|
if (autoClode)
|
||||||
|
{
|
||||||
|
timerCallback += DisposeTimer;
|
||||||
|
}
|
||||||
timer = new Timer(timerCallback, dic, dueTime, period);
|
timer = new Timer(timerCallback, dic, dueTime, period);
|
||||||
_timers.Add(timestamp,timer);
|
_timers.Add(timestamp,timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisposeTimer(object args)
|
public void DisposeTimer(object args)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> dic = (Dictionary<string, object>)args;
|
Dictionary<string, object> dic = (Dictionary<string, object>)args;
|
||||||
string key = dic["key"].ToString();
|
string key = dic["key"]!=null ? dic["key"].ToString() : "";
|
||||||
if (_timers.ContainsKey(key))
|
if (_timers.ContainsKey(key))
|
||||||
{
|
{
|
||||||
_timers[dic["key"].ToString()].Dispose();
|
_timers[dic["key"].ToString()].Dispose();
|
||||||
@@ -53,5 +56,6 @@ namespace Tnb.ProductionMgr.Helpers
|
|||||||
_timers.Remove(dic["key"].ToString());
|
_timers.Remove(dic["key"].ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1247,6 +1247,23 @@ namespace Tnb.ProductionMgr
|
|||||||
await _qcCheckPlanService.CreateTask(entity);
|
await _qcCheckPlanService.CreateTask(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (behavior == PrdTaskBehavior.Start)
|
||||||
|
{
|
||||||
|
TimerPoolHelper.GetInstance().StartTimer(TimeCallback2,prdTaskList.Where(p => p.mo_task_status == "Pause" || p.mo_task_status == "ToBeStarted").ToList(),TimeSpan.FromHours(2),Timeout.InfiniteTimeSpan,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (behavior == PrdTaskBehavior.Pause)
|
||||||
|
{
|
||||||
|
foreach (PrdMoTask? task in prdTaskList.Where(p => p.mo_task_status == "ToBeStarted").ToList())
|
||||||
|
{
|
||||||
|
TimerPoolHelper.GetInstance().DisposeTimer(new Dictionary<string,string>()
|
||||||
|
{
|
||||||
|
["key"] = task.timer_key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
foreach (PrdMoTask item in prdTaskList)
|
foreach (PrdMoTask item in prdTaskList)
|
||||||
@@ -1589,8 +1606,14 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
Dictionary<string, object> dic = (Dictionary<string, object>)args;
|
Dictionary<string, object> dic = (Dictionary<string, object>)args;
|
||||||
List<PrdMoTask> prdTaskList = (List<PrdMoTask>)(dic["value"]);
|
List<PrdMoTask> prdTaskList = (List<PrdMoTask>)(dic["value"]);
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
foreach (PrdMoTask? task in prdTaskList)
|
foreach (PrdMoTask? task in prdTaskList)
|
||||||
{
|
{
|
||||||
|
ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x=>x.id==task.mold_id);
|
||||||
|
await _db.Updateable<PrdMoTask>()
|
||||||
|
.SetColumns(x => x.timer_key == dic["key"])
|
||||||
|
.Where(x => x.id == task.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
TriggerPlanEntity entity = new()
|
TriggerPlanEntity entity = new()
|
||||||
{
|
{
|
||||||
materialid = task.material_id,
|
materialid = task.material_id,
|
||||||
@@ -1598,7 +1621,44 @@ namespace Tnb.ProductionMgr
|
|||||||
workid = task.workstation_id,
|
workid = task.workstation_id,
|
||||||
triggerevent = EnumTriggerEvent.开工首件检,
|
triggerevent = EnumTriggerEvent.开工首件检,
|
||||||
mo_task_code = task.mo_task_code,
|
mo_task_code = task.mo_task_code,
|
||||||
check_type = WmsWareHouseConst.FULLREVIEW_CODE
|
newpronum = toolMolds?.mold_cavity
|
||||||
|
// check_type = WmsWareHouseConst.FULLREVIEW_CODE
|
||||||
|
};
|
||||||
|
await _qcCheckPlanService.CreateTask(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
Console.WriteLine("质检任务生成成功");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
Log.Error("质检任务生成失败:"+e.Message,e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void TimeCallback2(object args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dic = (Dictionary<string, object>)args;
|
||||||
|
List<PrdMoTask> prdTaskList = (List<PrdMoTask>)(dic["value"]);
|
||||||
|
foreach (PrdMoTask? task in prdTaskList)
|
||||||
|
{
|
||||||
|
ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x=>x.id==task.mold_id);
|
||||||
|
await _db.Updateable<PrdMoTask>()
|
||||||
|
.SetColumns(x => x.timer_key == dic["key"])
|
||||||
|
.Where(x => x.id == task.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
TriggerPlanEntity entity = new()
|
||||||
|
{
|
||||||
|
materialid = task.material_id,
|
||||||
|
processid = task.process_id,
|
||||||
|
workid = task.workstation_id,
|
||||||
|
triggerevent = EnumTriggerEvent.巡检,
|
||||||
|
mo_task_code = task.mo_task_code,
|
||||||
|
newpronum = toolMolds?.mold_cavity
|
||||||
|
// check_type = WmsWareHouseConst.FULLREVIEW_CODE
|
||||||
};
|
};
|
||||||
await _qcCheckPlanService.CreateTask(entity);
|
await _qcCheckPlanService.CreateTask(entity);
|
||||||
}
|
}
|
||||||
@@ -1860,6 +1920,11 @@ namespace Tnb.ProductionMgr
|
|||||||
.Where(x => x.id == prdMoTask.id)
|
.Where(x => x.id == prdMoTask.id)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
TimerPoolHelper.GetInstance().DisposeTimer(new Dictionary<string,string>()
|
||||||
|
{
|
||||||
|
["key"] = prdMoTask.timer_key
|
||||||
|
});
|
||||||
|
ToolMolds toolMolds = await db.Queryable<ToolMolds>().SingleAsync(x=>x.id==prdMoTask.mold_id);
|
||||||
TriggerPlanEntity entity = new()
|
TriggerPlanEntity entity = new()
|
||||||
{
|
{
|
||||||
materialid = prdMoTask.material_id,
|
materialid = prdMoTask.material_id,
|
||||||
@@ -1871,6 +1936,7 @@ namespace Tnb.ProductionMgr
|
|||||||
report_id = report.id,
|
report_id = report.id,
|
||||||
batch = report.batch,
|
batch = report.batch,
|
||||||
plan_check_type = WmsWareHouseConst.MOJIAN_ID,
|
plan_check_type = WmsWareHouseConst.MOJIAN_ID,
|
||||||
|
newpronum = toolMolds?.mold_cavity,
|
||||||
};
|
};
|
||||||
await _qcCheckPlanService.CreateTask(entity);
|
await _qcCheckPlanService.CreateTask(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,15 @@
|
|||||||
public int? qty { get; set; }
|
public int? qty { get; set; }
|
||||||
public string bill_code { get; set; }
|
public string bill_code { get; set; }
|
||||||
public string equip_name { get; set; }
|
public string equip_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料规格
|
||||||
|
/// </summary>
|
||||||
|
public string? material_specification { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料型号
|
||||||
|
/// </summary>
|
||||||
|
public string? material_standard { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
public class CheckTaskOut
|
public class CheckTaskOut
|
||||||
@@ -168,6 +177,7 @@
|
|||||||
public string? result { get; set; }
|
public string? result { get; set; }
|
||||||
|
|
||||||
public List<List<Checktype>>? checktypes { get; set; }
|
public List<List<Checktype>>? checktypes { get; set; }
|
||||||
|
public CheckCarry carryInfo { get; set; }
|
||||||
}
|
}
|
||||||
public class Checktype
|
public class Checktype
|
||||||
{
|
{
|
||||||
@@ -187,4 +197,14 @@
|
|||||||
public string? result { get; set; }
|
public string? result { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CheckCarry
|
||||||
|
{
|
||||||
|
public string carry_name { get; set; }
|
||||||
|
public string location_id { get; set; }
|
||||||
|
public string location_code { get; set; }
|
||||||
|
public string is_check { get; set; }
|
||||||
|
public string material_name { get; set; }
|
||||||
|
public decimal qty { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ namespace Tnb.QcMgr.Entities.Enums
|
|||||||
[Remark("首检", "开工检")]
|
[Remark("首检", "开工检")]
|
||||||
开工首件检 = 15,
|
开工首件检 = 15,
|
||||||
[Remark("末检", "末检触发事件")]
|
[Remark("末检", "末检触发事件")]
|
||||||
末检质检方案 = 16
|
末检质检方案 = 16,
|
||||||
|
[Remark("巡检", "巡检")]
|
||||||
|
巡检 = 17,
|
||||||
|
[Remark("巡检", "巡检")]
|
||||||
|
注塑特殊产品工序检 = 18,
|
||||||
}
|
}
|
||||||
public class RemarkAttribute : Attribute
|
public class RemarkAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities;
|
||||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||||
using Tnb.QcMgr.Entities;
|
using Tnb.QcMgr.Entities;
|
||||||
using Tnb.QcMgr.Interfaces;
|
using Tnb.QcMgr.Interfaces;
|
||||||
@@ -83,11 +84,13 @@ namespace Tnb.QcMgr
|
|||||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workid == d.Id)
|
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workid == d.Id)
|
||||||
.LeftJoin<UserEntity>((a, b, c, d, e) => a.execuser == e.Id)
|
.LeftJoin<UserEntity>((a, b, c, d, e) => a.execuser == e.Id)
|
||||||
.LeftJoin<PrdReport>((a,b,c,d,e,f)=>a.report_id==f.id)
|
.LeftJoin<PrdReport>((a,b,c,d,e,f)=>a.report_id==f.id)
|
||||||
|
.LeftJoin<PrdMoTask>((a,b,c,d,e,f,g)=>a.mo_task_code==g.mo_task_code)
|
||||||
|
.LeftJoin<EqpEquipment>((a,b,c,d,e,f,g,h)=>g.eqp_id==h.id)
|
||||||
.WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d,e) => b.name.Contains(materialid))
|
.WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d,e) => b.name.Contains(materialid))
|
||||||
.WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype)
|
.WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype)
|
||||||
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status)
|
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status)
|
||||||
.Where((a, b, c, d, e) => a.status == list.Where(p => p.FullName == "待执行").First().Id)
|
.Where((a, b, c, d, e) => a.status == list.Where(p => p.FullName == "待执行").First().Id)
|
||||||
.Select((a, b, c, d, e,f) => new QcCheckExecHOut
|
.Select((a, b, c, d, e,f,g,h) => new QcCheckExecHOut
|
||||||
{
|
{
|
||||||
id = a.id,
|
id = a.id,
|
||||||
materialid = b.name,
|
materialid = b.name,
|
||||||
@@ -103,7 +106,10 @@ namespace Tnb.QcMgr
|
|||||||
execuser = e.RealName ?? "",
|
execuser = e.RealName ?? "",
|
||||||
mo_task_code = a.mo_task_code,
|
mo_task_code = a.mo_task_code,
|
||||||
batch = a.batch,
|
batch = a.batch,
|
||||||
qty = a.qty
|
qty = a.qty,
|
||||||
|
material_standard = b.material_standard,
|
||||||
|
material_specification = b.material_specification,
|
||||||
|
equip_name = h.name,
|
||||||
}).OrderByDescending(a => DateTime.Parse(a.tasktime)).ToPagedListAsync(input.currentPage, input.pageSize);
|
}).OrderByDescending(a => DateTime.Parse(a.tasktime)).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
foreach (QcCheckExecHOut? item in result.list)
|
foreach (QcCheckExecHOut? item in result.list)
|
||||||
{
|
{
|
||||||
@@ -408,6 +414,21 @@ namespace Tnb.QcMgr
|
|||||||
checktypes = new List<List<Checktype>>(),
|
checktypes = new List<List<Checktype>>(),
|
||||||
result = QcCheckExecH.result
|
result = QcCheckExecH.result
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrEmpty(QcCheckExecH.carry_code))
|
||||||
|
{
|
||||||
|
WmsCarryH carryH = await db.Queryable<WmsCarryH>().FirstAsync(x => x.carry_code == QcCheckExecH.carry_code);
|
||||||
|
WmsCarryCode carryCode = await db.Queryable<WmsCarryCode>().FirstAsync(x => x.carry_id == carryH.id);
|
||||||
|
string materialId = carryCode?.id ?? "";
|
||||||
|
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x=>x.id==materialId);
|
||||||
|
Result.carryInfo = new CheckCarry()
|
||||||
|
{
|
||||||
|
carry_name = carryH.carry_name,
|
||||||
|
location_id = carryH.location_id,
|
||||||
|
location_code = carryH.location_code,
|
||||||
|
material_name = basMaterial?.name,
|
||||||
|
qty = carryCode?.codeqty ?? 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
List<string?> groupkeys = QcCheckExecDs.Select(p => p.checkindex).Distinct().ToList();
|
List<string?> groupkeys = QcCheckExecDs.Select(p => p.checkindex).Distinct().ToList();
|
||||||
foreach (string? key in groupkeys)
|
foreach (string? key in groupkeys)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user