using HslCommunication;
|
using System;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using WIDESEA_Common;
|
using WIDESEA_Common.LoctionEnum;
|
using WIDESEA_Common.Tools;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Services.IRepositories;
|
using WIDESEA_Services.Repositories;
|
using WIDESEA_Services.Services;
|
using WIDESEA_WCS.WCSClient;
|
|
namespace WIDESEA_WCS
|
{
|
public partial class StackerExecutor
|
{
|
public static object requestZJTSJ = new object();//requestZJJK
|
private static int _readTSJDOWNSignalsoZTSJ = 0;//_readZTBUPSignalso
|
private static int lock_TSJ_Z = 1;
|
/// <summary>
|
/// 正极提升机下料工作逻辑
|
/// </summary>
|
/// <param name="client"></param>
|
public static void Z_TSJ_DownTask()
|
{
|
|
if (Interlocked.Exchange(ref _readTSJDOWNSignalsoZTSJ, 1) == 0)
|
{
|
Task.Run(() =>
|
{
|
try
|
{
|
VOLContext Context = new VOLContext();
|
WebResponseContent responseContent = new WebResponseContent();
|
Idt_task_numberRepository tasknumberRep = new dt_task_numberRepository(Context);
|
dt_task_numberService tasknumber = new dt_task_numberService(tasknumberRep);
|
Ibase_ware_locationRepository locRepository = new base_ware_locationRepository(Context);
|
Ibase_routing_tableRepository routingRepository = new base_routing_tableRepository(Context);
|
Ibill_pda_groupdiskRepository pdaRepository = new bill_pda_groupdiskRepository(Context);
|
Idt_agvtaskRepository agvRepository = new dt_agvtaskRepository(Context);
|
Idt_agvtask_htyRepository agvhtyRepository = new dt_agvtask_htyRepository(Context);
|
Ibill_group_stockRepository groupRepository = new bill_group_stockRepository(Context);
|
|
PLCClient plc = WCSService.Clients.Find(v => v.PLCName == "正极箔材提升机");
|
if (plc == null)
|
{
|
//WriteLog.GetLog("TSJ下料呼叫").Write($"设备:正极箔材提升机 内容:未连接PLC 时间记录:{DateTime.Now}", "TSJ下料呼叫");
|
return;
|
}
|
//当前设备有没有下料请求
|
//bool TSJ_CL = Convert.ToBoolean(plc.ReadValue("R_Feedingrequest".ToString(), plc.PLCDescroption));
|
OperateResult<bool> TSJ_CL = plc.SiemensPLCClient.SiemensS7NetClient.ReadBool("DB51.93");
|
if (TSJ_CL.Content)
|
{
|
//查看当前辊分机设备是否有AGV任务
|
var SBtask = agvRepository.FindFirst(f => f.agv_fromaddress == plc.PLCDescroption);
|
//有结束本次循环
|
if (SBtask != null) { return; }
|
|
|
base_ware_location ware_Locations = locRepository.FindFirst(d => d.upper_code == "ZJ-BCHCJ35" && d.location_state == LoctionStateEnum.LocationState_Empty.ToString() && d.tpgd == 0 && d.status == 1 && d.task == 2);
|
if (ware_Locations != null)
|
{
|
//生成提升机机下料任务
|
dt_agvtask agvtask = new dt_agvtask()
|
{
|
agv_id = Guid.NewGuid(),
|
agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
|
agv_fromaddress = plc.PLCDescroption,
|
agv_toaddress = ware_Locations.upper_code,
|
agv_code = "正极AGV调度",
|
agv_remark = "正极提升机下料",
|
agv_taskstate = AGVTaskStateEnum.Create.ToString(),
|
agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
|
agv_worktype = 1,//工作类型
|
agv_materielid = "",
|
agv_qty = 1,
|
agv_createtime = DateTime.Now,
|
agv_grade = 0,//任务优先级
|
agv_userid = "WCS",
|
agv_barcode = "",
|
};
|
|
ware_Locations.update_time = DateTime.Now;
|
ware_Locations.task = 1;
|
int a = locRepository.Update(ware_Locations, d => new { d.task, d.update_time }, true);
|
if (a == 1)
|
{
|
agvRepository.Add(agvtask, true);
|
//WriteDBLog.Info($"正极提升机下料任务生成").Write($"生成任务:{agvtask.agv_tasknum},终点货位【{ware_Locations.upper_code}】状态:托盘光电检测:{ware_Locations.tpgd},状态:{ware_Locations.location_state},更新时间:{ware_Locations.wireless_time}", $"正极提升机下料任务生成");
|
//WriteDBLog.Info($"正极提升机下料任务生成").Write($"----------------任务生成成功 {DateTime.Now} -------------- {Environment.NewLine}", $"正极提升机下料任务生成");
|
}
|
//WriteLog.GetLog("设备呼叫").Write($"设备{plc.PLCName}呼叫成功,任务{agvtask.agv_tasknum}生成", "设备呼叫");
|
}
|
|
|
}
|
|
|
}
|
catch (Exception ex)
|
{
|
WriteLog.GetLog().Write($"正极提升机下料:{DateTime.Now} --------------{ex}", $"正极提升机下料");
|
}
|
finally
|
{
|
|
Interlocked.Exchange(ref _readTSJDOWNSignalsoZTSJ, 0);
|
}
|
});
|
|
}
|
}
|
|
}
|
}
|