|  |  |  | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Microsoft.IdentityModel.Tokens; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Quartz; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | 
|---|
|  |  |  | ConveyorLineSignal conveyorLineSignalWrite = conveyorLineInfoWrite.Signal.ByteToBoolObject<ConveyorLineSignal>(); | 
|---|
|  |  |  | if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //å¹²èå
¥åºç«å°äº¤äº | 
|---|
|  |  |  | if (conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && !conveyorLineSignalWrite.ACK) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!string.IsNullOrEmpty(conveyorLineInfoRead.Barcode)) | 
|---|
|  |  |  | string boxcode = device.GetValue<R_ConveyorLineDB, string>(R_ConveyorLineDB.Boxcode, item.StationCode); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!string.IsNullOrEmpty(boxcode)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sc = device.Communicator.Read<string>("DB900.478.0"); | 
|---|
|  |  |  | WriteError(device.DeviceName, $"读åå¼ï¼{boxcode},对æ¯{sc}"); | 
|---|
|  |  |  | string boxEndCode = ""; | 
|---|
|  |  |  | if (boxcode.LastIndexOf(",PO:") >=0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | boxEndCode = "M"+ boxcode.Substring(0,boxcode.LastIndexOf(",PO:")) + sc.Substring(sc.IndexOf(",PO:")).Replace("\0", ""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //å
¥åºç³è¯·ä»»å¡ | 
|---|
|  |  |  | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode); | 
|---|
|  |  |  | WebResponseContent content = _taskService.RequestWMSTask(conveyorLineInfoRead.Barcode, item.StationCode, boxEndCode); | 
|---|
|  |  |  | if (content.Status) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.ACK, true, item.StationCode); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (!conveyorLineSignalRead.STB && conveyorLineStatus.Online && conveyorLineStatus.Goods && !conveyorLineStatus.Alarm && conveyorLineSignalWrite.ACK) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.PalletCode == conveyorLineInfoRead.Barcode && x.DeviceCode == item.StationDeviceCode && x.TaskState == TaskStatusEnum.New.ObjToInt()); | 
|---|
|  |  |  | string boxcode = device.GetValue<R_ConveyorLineDB, string>(R_ConveyorLineDB.Boxcode, item.StationCode); | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && boxcode.Contains(x.PalletCode) && x.TaskState == TaskStatusEnum.New.ObjToInt()); | 
|---|
|  |  |  | if (task != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: item.StackerCraneStationCode, deviceCode: task.Roadway, nextAddress: task.TargetAddress); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //å¹²èåºåºç«å°äº¤äº | 
|---|
|  |  |  | if (!conveyorLineSignalWrite.STB && !conveyorLineSignalRead.ACK && conveyorLineStatus.Goods) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && x.TaskState == TaskStatusEnum.Line_Execute.ObjToInt() && x.DeviceCode == item.StationDeviceCode); | 
|---|
|  |  |  | 
|---|
|  |  |  | WriteError(item.StationName, $"æªæ¾å°è·¯ç±é
置信æ¯,设å¤ç¼å·:{item.StationCode},ä»»å¡å·:{task.TaskNum}"); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.TaskNum, task.TaskNum, item.StationCode); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.EndPos, task.NextAddress, item.StationCode); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.EndPos, router.NextPosi, item.StationCode); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.StartPos, task.CurrentAddress, item.StationCode); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.Spare1, ConveyorWorkTypeEnum.Outbound.ObjToInt(), item.StationCode); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.STB, true, item.StationCode); | 
|---|
|  |  |  | _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (conveyorLineSignalWrite.STB && conveyorLineSignalRead.ACK && conveyorLineStatus.Goods) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //宿干èåºåºä»»å¡ | 
|---|
|  |  |  | _taskService.TaskCompleted(conveyorLineInfoWrite.TaskNum); | 
|---|
|  |  |  | device.SetValue(W_ConveyorLineDB.STB, false, item.StationCode); | 
|---|
|  |  |  | } | 
|---|