质检任务
This commit is contained in:
@@ -25,62 +25,74 @@ namespace Tnb.ProductionMgr
|
||||
//获取注塑装箱状态
|
||||
private void GetZSPackStatus(object state)
|
||||
{
|
||||
string[] strs = new string[1] { "TY4C-ZHUSU1" };
|
||||
string sign = "agvMode";
|
||||
foreach (string s in strs)
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
string[] strs = new string[1] { "TY4C-ZHUSU1" };
|
||||
string sign = "agvMode";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) and not ((int)Eagvmode.收到请求))
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
continue;
|
||||
}
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (int.Parse(res["Value"]!.ToString()) is not ((int)Eagvmode.无请求) and not ((int)Eagvmode.收到请求))
|
||||
{
|
||||
equip_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_ = _prdInstockService.InstockTypeOne(instockInput);
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["DevName"]!.ToString(),
|
||||
label_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_prdInstockService.InstockTypeOne(instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
//获取挤出装箱状态
|
||||
private void GetJCPackStatus(object state)
|
||||
{
|
||||
string[] strs = new string[1] { "TY4C-SHUSONG-JC" };
|
||||
string sign = "AGVFullCall";
|
||||
foreach (string s in strs)
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
string[] strs = new string[1] { "TY4C-SHUSONG-JC" };
|
||||
string sign = "AGVFullCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
InstockInput instockInput = new()
|
||||
continue;
|
||||
}
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
{
|
||||
equip_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_ = _prdInstockService.InstockTypeOne(instockInput);
|
||||
InstockInput instockInput = new()
|
||||
{
|
||||
equip_code = res["DevName"]!.ToString(),
|
||||
label_code = res["TagName"]!.ToString()
|
||||
};
|
||||
_prdInstockService.InstockTypeOne(instockInput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
//获取限位状态
|
||||
private void GetLimitStatus(object state)
|
||||
@@ -90,29 +102,33 @@ namespace Tnb.ProductionMgr
|
||||
Console.WriteLine($"获取挤出装箱状态");
|
||||
string data = _redisData.GetHash("TY4C-SHUSONG-JC", "AGVFullCall").Result;
|
||||
Console.WriteLine(data);*/
|
||||
/*
|
||||
string[] strs = new string[1] { "TY4C-WAIBAO" };
|
||||
string sign = "AGVCall";
|
||||
foreach (string s in strs)
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
string[] strs = new string[1] { "TY4C-WAIBAO" };
|
||||
string sign = "AGVCall";
|
||||
foreach (string s in strs)
|
||||
{
|
||||
if (!kv.Key.Contains(sign))
|
||||
Dictionary<string, string> dic = _redisData.HGetAll(s).Result;
|
||||
foreach (KeyValuePair<string, string> kv in dic)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
if (!kv.Key.Contains(sign))
|
||||
{
|
||||
//
|
||||
continue;
|
||||
}
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(kv.Value);
|
||||
if (res != null && res["Value"] != null)
|
||||
{
|
||||
if (res.Value<bool>("Value"))
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -122,9 +138,9 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// ZSpacktimer = new Timer(GetZSPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// JCpacktimer = new Timer(GetJCPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
// limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(2));
|
||||
ZSpacktimer = new Timer(GetZSPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
|
||||
JCpacktimer = new Timer(GetJCPackStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
|
||||
limittimer = new Timer(GetLimitStatus, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
|
||||
@@ -45,4 +45,26 @@ namespace Tnb.QcMgr.Entities
|
||||
/// </summary>
|
||||
public int? pronum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class CreateTaskEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料方案编号
|
||||
/// </summary>
|
||||
public List<string> materialids { get; set; }
|
||||
/// <summary>
|
||||
/// 触发条件
|
||||
/// </summary>
|
||||
public EnumTriggerEvent? triggerevent { get; set; }
|
||||
|
||||
public string maintableid { get; set; }
|
||||
}
|
||||
public class TaskEntity
|
||||
{
|
||||
public List<string> materialids { get; set; }
|
||||
public QcCheckPlanH qcCheckPlanH { get; set; }
|
||||
public string maintableid { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,6 +286,105 @@ namespace Tnb.QcMgr
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task CreateWmsTask(CreateTaskEntity entity)
|
||||
{
|
||||
ISugarQueryable<QcCheckPlanH, QcCheckPlanAdd> Query = _repository.AsSugarClient().Queryable<QcCheckPlanH, QcCheckPlanAdd>
|
||||
((a, b) => new object[] {
|
||||
JoinType.Inner,a.id== b.mainid,
|
||||
});
|
||||
GetQuery(Query, entity);
|
||||
List<QcCheckPlanH> list = await Query.ToListAsync();
|
||||
List<TaskEntity> taskEntities = new List<TaskEntity>();
|
||||
foreach (QcCheckPlanH data in list)
|
||||
{
|
||||
if (entity.materialids.Count>0)
|
||||
{
|
||||
if (_repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Any())
|
||||
{
|
||||
var Materials= _repository.AsSugarClient().Queryable<QcCheckPlanMaterial>().Where(p => p.planid == data.id).Select(p=>p.materialid).ToList();
|
||||
var Intersect = entity.materialids.Intersect(Materials).ToList();
|
||||
if (Intersect.Count > 0)
|
||||
{
|
||||
taskEntities.Add(new TaskEntity { maintableid=entity.maintableid, materialids = Intersect!, qcCheckPlanH = data });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (taskEntities.Count > 0)
|
||||
{
|
||||
await SaveTask(taskEntities);
|
||||
}
|
||||
}
|
||||
|
||||
private void GetQuery(ISugarQueryable<QcCheckPlanH, QcCheckPlanAdd> Query, CreateTaskEntity entity)
|
||||
{
|
||||
List<DictionaryDataEntity> DictionaryData = _repository.AsSugarClient().Queryable<DictionaryDataEntity, DictionaryTypeEntity>
|
||||
((a, b) => new object[] { JoinType.Left, a.DictionaryTypeId == b.Id, })
|
||||
.Where((a, b) => b.FullName == "质检类型选择").ToList();
|
||||
QcTriggerEvent TriggerEvent = new();
|
||||
EnumTriggerEvent? enumTriggerEvent = entity.triggerevent;
|
||||
RemarkAttribute remark = RemarkAttribute.GetRemark(enumTriggerEvent);
|
||||
string type = DictionaryData.Where(p => p.FullName == remark.CheckType).First().Id;
|
||||
TriggerEvent = _repository.AsSugarClient().Queryable<QcTriggerEvent>().Where(p => p.type == type && p.name == remark.CheckContent).First();
|
||||
Query = Query.Where((a, b) => b.triggertype == "3" && b.content!.Contains(TriggerEvent.id));
|
||||
}
|
||||
|
||||
private async Task SaveTask(List<TaskEntity> taskEntities)
|
||||
{
|
||||
DictionaryDataEntity DictionaryData = _repository.AsSugarClient().Queryable<DictionaryDataEntity, DictionaryTypeEntity>
|
||||
((a, b) => new object[] { JoinType.Left, a.DictionaryTypeId == b.Id, })
|
||||
.Where((a, b) => b.FullName == "质检状态" && a.FullName == "待执行").First();
|
||||
foreach (var entity in taskEntities)
|
||||
{
|
||||
List<QcCheckPlanD> plands = await _repository.AsSugarClient().Queryable<QcCheckPlanD>().Where(p =>p.mainid== entity.qcCheckPlanH.id).ToListAsync();
|
||||
|
||||
foreach (string s in entity.materialids)
|
||||
{
|
||||
DateTime time = DateTime.Now;
|
||||
QcCheckExecH qcCheckExecH = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
checktype = entity.qcCheckPlanH.checktype,
|
||||
status = DictionaryData.Id,
|
||||
tasktime = time.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
materialid = s,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = time,
|
||||
extras= entity.maintableid
|
||||
};
|
||||
List<QcCheckExecD> ExecDs = new();
|
||||
foreach (var pland in plands)
|
||||
{
|
||||
QcCheckExecD QcCheckExecD = new()
|
||||
{
|
||||
mainid = qcCheckExecH.id,
|
||||
extype = pland.extype,
|
||||
excontent = pland.excontent,
|
||||
check = pland.check,
|
||||
errorcause = pland.errorcause,
|
||||
errorlevel = pland.errorlevel,
|
||||
remark = pland.remark,
|
||||
attachment = pland.attachment,
|
||||
isexec = pland.isexec,
|
||||
custom = pland.custom,
|
||||
typeid = pland.typeid,
|
||||
itemid = pland.itemid,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = time
|
||||
};
|
||||
ExecDs.Add(QcCheckExecD);
|
||||
}
|
||||
_ = await _repository.AsSugarClient().Insertable(qcCheckExecH).ExecuteCommandAsync();
|
||||
_ = await _repository.AsSugarClient().Insertable(ExecDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划生成任务
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user