| | |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks; |
| | | using WIDESEAWCS_Tasks.DBNames; |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | Thread.Sleep(500); |
| | | CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device; |
| | | string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim(); |
| | | |
| | | if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"ä¼ å
¥æç®±ç {containerFlowDTO.ContainerCode}ï¼è¾éæç®±ç {PickBarCode}æ°æ®é误"); |
| | | if (containerFlowDTO.Direction == "100") |
| | | int W_PickToHode = commonConveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.W_PickToHode, stationManger.StationDeviceCode); |
| | | if (containerFlowDTO.Direction == "100" && W_PickToHode == 300) |
| | | { |
| | | WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode, stationManger.PickStationCode); |
| | | if (!responseContent.Status) throw new Exception(responseContent.Message); |
| | | } |
| | | WriteLog.Write_Log($"容卿µå¨{stationManger.StationCode}", $"è¾é线信æ¯", "å¼å§å
¥åº", $"ç¶æ{containerFlowDTO.Direction}ï¼æç®±ç {containerFlowDTO.ContainerCode}"); |
| | | commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode); |
| | | } |
| | | content.OK(); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 2026/1/27 11:36:07.534 |
| | | å¼å§å
¥åº |
| | | "æçå·string" |
| | | ------------------------------- |
| | | |
| | |
| | | /// <summary> |
| | | /// AGVç¶ææ¥è¯¢è°ç¨åWMSæ
é䏿¥ |
| | | /// </summary> |
| | | public void AgvSearchStatus() // 1忥å2æ´æ°ä»»å¡ |
| | | public void AgvSearchStatus() |
| | | { |
| | | try |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | WriteLog.Write_Log("容å¨å
¥åºå建任å¡", $"è¾é线信æ¯", "å¼å§å
¥åº", $"æçå·{containerFlowDTO.ContainerCode}ï¼è®¾å¤{deviceCode}"); |
| | | List<Dt_LocationInfo> locationInfos = _locationInfoRepository.QueryData(); |
| | | Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.PalletCode == containerFlowDTO.ContainerCode); |
| | | if (locationInfo != null) throw new Exception($"åºä½æç®±å·{containerFlowDTO.ContainerCode}å·²åå¨"); |
| | |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(new List<int>() { taskOld.TaskNum }, $"{oldSlotCode}æ¢è³{containerFlowDTO.SlotCode}å
¥åº"); |
| | | return content.OK(); |
| | | } |
| | | else if(taskOld != null) |
| | | else if (taskOld != null) |
| | | { |
| | | throw new Exception($"æç®±å·{containerFlowDTO.ContainerCode}" + (taskOld.TaskType == TaskTypeEnum.Inbound.ObjToInt() ? "å
¥åºAGVæ§è¡ä¸": "åºåºAGVæ§è¡ä¸")); |
| | | throw new Exception($"æç®±å·{containerFlowDTO.ContainerCode}" + (taskOld.TaskType == TaskTypeEnum.Inbound.ObjToInt() ? "å
¥åºAGVæ§è¡ä¸" : "åºåºAGVæ§è¡ä¸")); |
| | | } |
| | | Dt_LocationInfo? noInLocation = locationInfos.FirstOrDefault(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()); |
| | | if (noInLocation == null) throw new Exception($"å¯ç¨è´§ä½ä¸è¶³!"); |
| | | Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt() && x.StationDeviceCode == deviceCode); |
| | | WriteLog.Write_Log("容å¨å
¥åºå建任å¡", $"ç«å°ä¿¡æ¯", "æ¥è¯¢ç«å°", $"ç«å°å·{stationManger.StationCode}ï¼è®¾å¤{stationManger.StationDeviceCode}"); |
| | | //åå»ºä»»å¡ |
| | | Dt_Task task = new Dt_Task(); |
| | | task.PalletCode = containerFlowDTO.ContainerCode; |
| | |
| | | task.TaskState = TaskStatusEnum.CL_Executing.ObjToInt(); |
| | | |
| | | //æ·»å ä»»å¡ |
| | | BaseDal.AddData(task); |
| | | int taskId = BaseDal.AddData(task); |
| | | WriteLog.Write_Log("容å¨å
¥åºå建任å¡", $"ä»»å¡ä¿¡æ¯", "å建å
¥åº", $"ä»»å¡å·ï¼{taskId},æçç¼å·ï¼{task.PalletCode}"); |
| | | if (type > 0) |
| | | { |
| | | _taskExecuteDetailService.AddTaskExecuteDetail(new List<int>() { task.TaskNum }, "æå¨æé®å
¥åº"); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | WriteLog.Write_Log("容å¨å
¥åºå建任å¡", $"ä»»å¡", "å建å
¥åº", $"失败ï¼{ex.Message}"); |
| | | content.Error($"é误信æ¯:{ex.Message}"); |
| | | } |
| | | return content; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace WIDESEAWCS_TaskInfoService |
| | | { |
| | | public class WriteLog |
| | | { |
| | | private int fileSize; |
| | | private string logFileName; |
| | | public static WriteLog log; |
| | | static string EquipName; |
| | | public static WriteLog GetLog(string equipName) |
| | | { |
| | | EquipName = equipName; |
| | | //if (log == null) |
| | | log = new WriteLog(equipName); |
| | | log.FileLogPath = AppContext.BaseDirectory + "\\log\\" + DateTime.Now.ToString("yyyyMMdd") /*+ "\\" + EquipName + "_" + DateTime.Now.ToString("yyyyMMdd")*/ + "\\"; |
| | | return log; |
| | | } |
| | | |
| | | public static WriteLog Info(string equipName) |
| | | { |
| | | EquipName = equipName; |
| | | //if (log == null) |
| | | log = new WriteLog("Info" + equipName); |
| | | log.FileLogPath = AppContext.BaseDirectory + "\\log\\Info\\" + DateTime.Now.ToString("yyyyMMdd") /*+ "\\" + EquipName + "_" + DateTime.Now.ToString("yyyyMMdd")*/ + "\\"; |
| | | return log; |
| | | } |
| | | |
| | | public static WriteLog Error(string equipName) |
| | | { |
| | | EquipName = equipName; |
| | | //if (log == null) |
| | | log = new WriteLog("Error" + equipName); |
| | | log.FileLogPath = AppContext.BaseDirectory + "\\log\\Error\\" + DateTime.Now.ToString("yyyyMMdd") /*+ "\\" + EquipName + "_" + DateTime.Now.ToString("yyyyMMdd")*/ + "\\"; |
| | | return log; |
| | | } |
| | | |
| | | private WriteLog(string equipName) |
| | | { |
| | | //åå§å大äº399Mæ¥å¿æä»¶å°èªå¨å é¤; |
| | | |
| | | this.fileSize = 2048 * 1024 * 200;//50M 2048 * 1024 * 200= 419430000åè(b)=399.9996185å
åè(mb) |
| | | |
| | | //é»è®¤è·¯å¾ |
| | | |
| | | //this.FileLogPath = AppContext.BaseDirectory + "\\log\\" + EquipName + "\\"; |
| | | EquipName = equipName; |
| | | if (!string.IsNullOrEmpty(equipName)) |
| | | this.logFileName = equipName + "_log" + DateTime.Now.ToString("yyyyMMdd") + ".log"; |
| | | else |
| | | this.logFileName = "log" + DateTime.Now.ToString("yyyyMMdd") + ".log"; |
| | | //this.logFileName = EquipName + "_log" + DateTime.Now.ToString("yyyyMMdd") + ".log"; |
| | | } |
| | | |
| | | public int FileSize |
| | | { |
| | | set |
| | | { |
| | | fileSize = value; |
| | | } |
| | | get |
| | | { |
| | | return fileSize; |
| | | } |
| | | } |
| | | |
| | | public string FileLogPath { set; get; } //= AppContext.BaseDirectory + "\\log\\" + EquipName + "\\"; |
| | | |
| | | public string LogFileName |
| | | { |
| | | set |
| | | { |
| | | this.logFileName = value; |
| | | } |
| | | get |
| | | { |
| | | return this.logFileName; |
| | | } |
| | | } |
| | | |
| | | object flag = new object(); |
| | | |
| | | public void Write(string Message, string equipName) |
| | | { |
| | | lock (flag) |
| | | { |
| | | if (!string.IsNullOrEmpty(equipName)) |
| | | this.logFileName = equipName + "_log" + DateTime.Now.ToString("yyyyMMdd") + ".log"; |
| | | else |
| | | this.logFileName = "log" + DateTime.Now.ToString("yyyyMMdd") + ".log"; |
| | | this.Write(this.logFileName, Message, equipName); |
| | | } |
| | | } |
| | | |
| | | public void Write(string LogFileName, string Message, string equipName) |
| | | { |
| | | |
| | | //DirectoryInfo path=new DirectoryInfo(LogFileName); |
| | | //妿æ¥å¿æä»¶ç®å½ä¸åå¨,åå建 |
| | | if (!Directory.Exists(this.FileLogPath)) |
| | | { |
| | | Directory.CreateDirectory(this.FileLogPath); |
| | | } |
| | | |
| | | FileInfo finfo = new FileInfo(this.FileLogPath + LogFileName); |
| | | if (finfo.Exists && finfo.Length > fileSize) |
| | | { |
| | | finfo.Delete(); |
| | | } |
| | | try |
| | | { |
| | | FileStream fs = new FileStream(this.FileLogPath + LogFileName, FileMode.Append); |
| | | StreamWriter strwriter = new StreamWriter(fs); |
| | | try |
| | | { |
| | | |
| | | DateTime d = DateTime.Now; |
| | | strwriter.WriteLine("æ¶é´:" + d.ToString()); |
| | | strwriter.WriteLine(Message); |
| | | //strwriter.WriteLine(); |
| | | strwriter.Flush(); |
| | | } |
| | | catch (Exception ee) |
| | | { |
| | | //Console.WriteLine("æ¥å¿æä»¶åå
¥å¤±è´¥ä¿¡æ¯:" + ee.ToString()); |
| | | } |
| | | finally |
| | | { |
| | | strwriter.Close(); |
| | | strwriter = null; |
| | | fs.Close(); |
| | | fs = null; |
| | | } |
| | | } |
| | | catch (Exception ee) |
| | | { |
| | | //Console.WriteLine("æ¥å¿æä»¶æ²¡ææå¼,详ç»ä¿¡æ¯å¦ä¸:"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// åå
¥æ¥å¿(ä¸è¦å¤çº¿ç¨æä½å䏿件ï¼ä¸ä¸ªè®¾å¤ä¸ä¸ªæä»¶å¤¹) |
| | | /// </summary> |
| | | /// <param name="groupName">æ¥å¿ç»</param> |
| | | /// <param name="logName">æ¥å¿åç§°</param> |
| | | /// <param name="content">å
容</param> |
| | | /// <param name="data">æ°æ®</param> |
| | | public static void Write_Log(string groupName, string logName, string content, object data = null) |
| | | { |
| | | DateTime nowTime = DateTime.Now; |
| | | string basePath = System.Environment.CurrentDirectory + "/Log/" + $"/{groupName}/{nowTime.ToString("yyyy-MM-dd")}"; |
| | | //妿æ¥å¿æä»¶ç®å½ä¸åå¨,åå建 |
| | | if (!Directory.Exists(basePath)) |
| | | { |
| | | Directory.CreateDirectory(basePath); |
| | | } |
| | | try |
| | | { |
| | | FileStream fs = new FileStream(basePath + "/" + logName + $"{nowTime.ToString("yyMMdd")}.txt", FileMode.Append); |
| | | StreamWriter strwriter = new StreamWriter(fs); |
| | | try |
| | | { |
| | | strwriter.WriteLine(nowTime.ToString() + "." + nowTime.Millisecond); |
| | | strwriter.WriteLine(content); |
| | | if (data != null) |
| | | { |
| | | strwriter.WriteLine(JsonConvert.SerializeObject(data)); |
| | | } |
| | | strwriter.WriteLine("-------------------------------"); |
| | | strwriter.WriteLine(); |
| | | strwriter.Flush(); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | strwriter.Close(); |
| | | fs.Close(); |
| | | } |
| | | } |
| | | catch { } |
| | | } |
| | | } |
| | | } |
| | |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DTO; |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | |
| | | WriteError(conveyorLine.DeviceCode, $"{station.PickStationCode}æ£éç³è¯·ä¸æ¥WMSé误{PickBarCode}ï¼ä¿¡æ¯{content.Message}"); |
| | | } |
| | | //åå
¥æ£é确认 |
| | | WriteLog.Write_Log("äºæè¾é线æ£éåå
¥", $"{station.StationCode}", "äºæè¾é线æ£éåå
¥", $"W_PickToHodeåå
¥PLCä¿¡å·:300"); |
| | | conveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)300, station.StationCode); |
| | | } |
| | | else |
| | |
| | | } |
| | | //æé®ç³è¯· |
| | | bool DownRequest = conveyorLine.GetValue<ConveyorLineDBName, bool>(ConveyorLineDBName.R_DownRequest, station.StationCode); |
| | | if (DownRequest) |
| | | int W_PickToHode = conveyorLine.GetValue<ConveyorLineDBName, short>(ConveyorLineDBName.W_PickToHode, station.StationCode); |
| | | if (DownRequest && W_PickToHode == 300) |
| | | { |
| | | string PickBarCode = conveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, station.StationCode).Trim(); |
| | | WriteInfo(conveyorLine.DeviceCode, $"ç³è¯·å
¥åº{PickBarCode}ï¼ç«å°ï¼{station.StationCode}"); |
| | | //䏿¥WMSæç®±å°è¾¾ |
| | | if (PickBarCode.IsNotEmptyOrNull()) |
| | | { |
| | |
| | | ContainerCode = PickBarCode, |
| | | Direction="100" |
| | | }; |
| | | WriteInfo(conveyorLine.DeviceCode, $"ä»»å¡æå»ºå®æSlotCode: {containerFlowDTO.SlotCode}, ContainerCode: {containerFlowDTO.ContainerCode}"); |
| | | WebResponseContent responseContent = _taskService.ContainerFlow(containerFlowDTO, station.StationDeviceCode, station.PickStationCode,1); |
| | | if (responseContent.Status) |
| | | { |
| | | WriteLog.Write_Log("äºæè¾é线æ£éåå
¥", $"{station.StationCode}", "äºæè¾é线æ£éåå
¥", $"W_PickToHodeåå
¥PLCä¿¡å·ï¼{containerFlowDTO.Direction}"); |
| | | WriteInfo(conveyorLine.DeviceCode, $"åå
¥PLCä¿¡å·W_PickToHode: {containerFlowDTO.Direction}ï¼ç«å°ï¼{station.StationCode}"); |
| | | conveyorLine.SetValue(ConveyorLineDBName.W_PickToHode, (short)containerFlowDTO.Direction.ObjToInt(), station.StationCode); |
| | | } |
| | | else |
| | |
| | | { |
| | | WriteError(conveyorLine.DeviceCode, $"{station.PickStationCode}æé®ç³è¯·ä¸º{DownRequest}æ¡ç 为空å¼"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | if (InRequest && !InResponse && InWeight>0) |
| | | { |
| | | string InBarCode = conveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_InBarCode, station.StationCode).Trim(); |
| | | WriteInfo(conveyorLine.DeviceCode, $"ç«å°{station.StationCode}æç®±{InBarCode}ç³è¯·å
¥åºæå"); |
| | | WriteLog.Write_Log("äºæè¾é线æ£éåå
¥", $"{station.StationCode}", $"ç«å°{station.StationCode}", $"æç®±{InBarCode}ç³è¯·å
¥åºæå"); |
| | | //æç®±å°è¾¾ |
| | | if (InBarCode.IsNotEmptyOrNull()) |
| | | { |
| | |
| | | WebResponseContent content =_taskService.RequestInTask(station.StationCode,InBarCode); |
| | | if (content.Status) |
| | | { |
| | | //åå
¥å
¥åºç¡®è®¤ |
| | | conveyorLine.SetValue(ConveyorLineDBName.W_InResponse, true, station.StationCode); |
| | | WriteInfo(conveyorLine.DeviceCode, $"ç«å°{station.StationCode}æç®±{InBarCode}ç³è¯·å
¥åºæå"); |
| | | WriteLog.Write_Log("äºæè¾é线æ£éåå
¥", $"{station.StationCode}", $"åå
¥ç¡®å®{ConveyorLineDBName.W_InResponse}", $"æç®±{InBarCode}"); |
| | | conveyorLine.SetValue(ConveyorLineDBName.W_InResponse, true, station.StationCode); |
| | | } |
| | | else |
| | | { |