using HslCommunication;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using WIDESEA_Common;
|
using WIDESEA_Common.Tools;
|
using WIDESEA_Core.EFDbContext;
|
using WIDESEA_Core.Utilities;
|
using WIDESEA_Entity.DomainModels;
|
using WIDESEA_Services;
|
using WIDESEA_Services.IRepositories;
|
using WIDESEA_Services.Repositories;
|
using WIDESEA_Services.Services;
|
using WIDESEA_WCS.WCSClient;
|
|
namespace WIDESEA_WCS.Jobs
|
{
|
public partial class EquipmentExecutor : SchedulerExecuteBase
|
{
|
private static int _readGMHKUPSignalso = 0;
|
public static void GMHKSB_UpTask()
|
{
|
if (Interlocked.Exchange(ref _readGMHKUPSignalso, 1) == 0)
|
{
|
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);
|
Ibill_group_stockRepository groupRepository = new bill_group_stockRepository(Context);
|
List<string> HKSBs = new List<string> { "正极1号烘烤机", "正极2号烘烤机", "负极1号烘烤机", "负极2号烘烤机" };
|
foreach (var hksb in HKSBs)
|
{
|
PLCClient plc = WCSService.Clients.Find(v => v.PLCName == hksb);
|
if (plc == null)
|
continue;
|
//启用工单
|
string IsBatchNo = plc.ReadValue(ConveyorLineInfoDBName.R_HKSB_IsWorkBatchNo.ToString(), plc.PLCDescroption).ToString();
|
if (IsBatchNo == "False") { continue; }
|
var task = new List<dt_agvtask>();
|
if (plc.PLCDescroption.Contains("ZJSL"))
|
{
|
task = agvRepository.Find(f => f.agv_toaddress.Contains("ZJSL-GMHX")).ToList();
|
}
|
else
|
{
|
task = agvRepository.Find(f => f.agv_toaddress.Contains("FJSL-GMHX")).ToList();
|
}
|
if (task.Count >= 1)
|
continue;
|
//获取隔膜烘箱上料请求
|
string isWork = plc.ReadValue(ConveyorLineInfoDBName.R_HKSB_UPrequest.ToString(), plc.PLCDescroption).ToString();
|
PLCClient hcxplc = WCSService.Clients.Find(v => v.PLCName == "正极提升机");
|
string isZGMWork = hcxplc.ReadValue(ConveyorLineInfoDBName.R_ZGMWork.ToString(), hcxplc.PLCDescroption).ToString();
|
string isFGMWork = hcxplc.ReadValue(ConveyorLineInfoDBName.R_FGMWork.ToString(), hcxplc.PLCDescroption).ToString();
|
string isZState = hcxplc.ReadValue(ConveyorLineInfoDBName.R_ZGMState.ToString(), hcxplc.PLCDescroption).ToString();
|
string isFState = hcxplc.ReadValue(ConveyorLineInfoDBName.R_FGMState.ToString(), hcxplc.PLCDescroption).ToString();
|
GetEquipmentInfo(plc.PLCDescroption, isWork, "隔膜缓存线的下料请求:Z:" + isZGMWork + ",F:" + isFGMWork, "隔膜缓存线的状态:Z:" + isZState + ",F:" + isFState, "");
|
if (isWork != "5")
|
continue;
|
var route = routingRepository.Find(f => f.route_end == plc.PLCDescroption);
|
foreach (var r in route)
|
{
|
if (bool.Parse(isZGMWork) && int.Parse(isZState) == 2)
|
{
|
dt_agvtask agvtask = new dt_agvtask
|
{
|
agv_materbarcode = "A"+DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")+"," + "B" + DateTime.Now.ToString("yyyy-MM-dd-HH-MM-SS"),
|
agv_barcode = "",
|
agv_code = "负极2号AGV",
|
agv_createtime = DateTime.Now,
|
agv_realesstime = DateTime.Now,
|
agv_fromaddress = r.route_began,
|
agv_grade = 1,
|
agv_materielid = "隔膜物料",
|
agv_qty = 1,
|
agv_tasknum = "KH-" + tasknumber.GetTaskNumber(tasknumberRep),
|
agv_taskstate = "Create",
|
agv_tasktype = "TaskType_Outbound",
|
agv_toaddress = plc.PLCDescroption,
|
agv_userid = "WCS",
|
agv_worktype = 1
|
};
|
agvRepository.Add(agvtask, true);
|
WriteLog.Info("GMHKSB_UpTask").Write("GMHKSB_UpTask" + agvtask.agv_tasknum + DateTime.Now, "GMHKSB_UpTask");
|
}
|
else if (bool.Parse(isFGMWork) && int.Parse(isFState) == 2)
|
{
|
dt_agvtask agvtask = new dt_agvtask
|
{
|
agv_materbarcode = "A" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ";" + "B" + DateTime.Now.ToString("yyyy-MM-dd-HH-MM-SS"),
|
agv_barcode = "",
|
agv_code = "负极2号AGV",
|
agv_createtime = DateTime.Now,
|
agv_realesstime = DateTime.Now,
|
agv_fromaddress = r.route_began,
|
agv_grade = 1,
|
agv_materielid = "隔膜物料",
|
agv_qty = 1,
|
agv_tasknum = "KH-" + tasknumber.GetTaskNumber(tasknumberRep),
|
agv_taskstate = "Create",
|
agv_tasktype = "TaskType_Outbound",
|
agv_toaddress = plc.PLCDescroption,
|
agv_userid = "WCS",
|
agv_worktype = 1
|
};
|
agvRepository.Add(agvtask, true);
|
WriteLog.Info("GMHKSB_UpTask").Write("GMHKSB_UpTask" + agvtask.agv_tasknum + DateTime.Now, "GMHKSB_UpTask");
|
}
|
}
|
break;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
}
|
finally
|
{
|
Interlocked.Exchange(ref _readGMHKUPSignalso, 0);
|
}
|
}
|
}
|
}
|
}
|