| | |
| | | using System; |
| | | using NewLife.Serialization; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | |
| | | using WIDESEA.Core.Utilities; |
| | | using WIDESEA.Entity.DomainModels; |
| | | using WIDESEA.Services.Repositories; |
| | | using WIDESEA_Common.LogEnum; |
| | | using WIDESEA_Entity.CustomModels.RGVModel; |
| | | using WIDESEA_Services.Services.APIInvoke.RGV; |
| | | using static WIDESEA_Entity.CustomModels.RGVModel.RgvDeviceStatusModel; |
| | |
| | | /// ç»å
¥åºè¯·æ±åé
è´§ä½ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static Dt_locationinfo GetEmptyLocationAction() |
| | | public static Dt_locationinfo GetEmptyLocationAction(int? Gznumber = 0) |
| | | { |
| | | List<string> locationId = new List<string>(); |
| | | //åºåºä»»å¡ |
| | |
| | | |
| | | //å
¥åºä»»å¡ |
| | | Dt_locationinfo locationinfo = null; |
| | | List<Dt_taskinfo> inboundTask = Dt_taskinfoRepository.Instance.Find(r => r.task_type.Contains("Inbound")); |
| | | |
| | | |
| | | |
| | | List<int> listLayer = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| | | |
| | | |
| | | //// æ´æ¹è·åè´§ä½çä¿¡æ¯ è¿éè¦åä¸ä¸ªå¾ªç¯ |
| | | //List<Dt_taskinfo> outboundTask_temp = Dt_taskinfoRepository.Instance.Find(x => x.task_tolocationid == "10301" || x.task_endstation == "10301"); |
| | | //if (outboundTask_temp != null) |
| | | //{ |
| | | // string temp_layer = ""; |
| | | |
| | | // foreach (var item in outboundTask_temp) |
| | | // { |
| | | |
| | | // } |
| | | //} |
| | | |
| | | if (null != inboundTask && inboundTask.Count > 0) |
| | | // å½ä¼ è¿æ¥çæ¯1 å¤çå
¥åºåºçé»è¾ å½ä¼ è¿æ¥çæ¯2å¤çåºåºåºçé»è¾ |
| | | if (Gznumber == 1) |
| | | { |
| | | foreach (var item in inboundTask) |
| | | List<Dt_taskinfo> inbound = Dt_taskinfoRepository.Instance.Find(x => |
| | | x.task_beginstation == "20101" |
| | | ); |
| | | foreach (var item in inbound) |
| | | { |
| | | //妿åè´§å®æï¼å¯ä»¥åé
|
| | | if (string.IsNullOrEmpty(item.task_bak_2) || !"2".Equals(item.task_bak_2)) |
| | | string[] location = item.task_tolocationid.Split('-'); |
| | | //è·åå½åæä»»å¡çå± |
| | | int layer = int.Parse(location[0]); |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"åé
任塿¶ï¼æå
¥åºä»»å¡éè¦å é¤çå±ï¼{layer}ï¼å½åå±è´§ä½ç¼å·ï¼{item.ToJson()},å½åç°æä»»å¡{inbound.ToJson()}"); |
| | | listLayer.Remove(layer); |
| | | } |
| | | |
| | | List<Dt_taskinfo> outboundTask = Dt_taskinfoRepository.Instance.Find(r => ((r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()) |
| | | && (r.task_state == TaskState.TaskState_RGV_Received.ToString() || r.task_state == TaskState.TaskState_RGV_Finished.ToString())) |
| | | || r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()); |
| | | |
| | | if (null != outboundTask && outboundTask.Count > 0) |
| | | { |
| | | List<string> fromStation = outboundTask.Where(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()).Select(r => r.task_fromlocationid).ToList(); |
| | | fromStation.AddRange(outboundTask.Where(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()).Select(r => r.task_tolocationid).ToList()); |
| | | |
| | | foreach (var item in fromStation) |
| | | { |
| | | string[] location = item.task_tolocationid.Split('-'); |
| | | string[] location = item.Split('-'); |
| | | //è·åå½åæä»»å¡çå± |
| | | int layer = int.Parse(location[0]); |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"åé
任塿¶ï¼æå
¥åºä»»å¡éè¦å é¤çå±ï¼{layer}ï¼å½åå±è´§ä½ç¼å·ï¼{item.ToJson()},å½åç°æä»»å¡{outboundTask.ToJson()}"); |
| | | listLayer.Remove(layer); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // List<Dt_taskinfo> outboundTask = Dt_taskinfoRepository.Instance.Find(r => ((r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()) |
| | | // && (r.task_state.Equals(TaskState.TaskState_RGV_Received.ToString()) || r.task_state.Equals(TaskState.TaskState_RGV_Finished.ToString()))) |
| | | //|| r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()); |
| | | |
| | | List<Dt_taskinfo> outboundTask = Dt_taskinfoRepository.Instance.Find(r => ((r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()) |
| | | && (r.task_state == TaskState.TaskState_RGV_Received.ToString() || r.task_state == TaskState.TaskState_RGV_Finished.ToString())) |
| | | || r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()); |
| | | |
| | | //List<Dt_taskinfo> outboundTask = Dt_taskinfoRepository.Instance.Find(r =>(r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString() || r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()) |
| | | //&& (r.task_state != TaskState.TaskState_Create.ToString())); |
| | | |
| | | //if (outboundTask.Count < 3) |
| | | //{ |
| | | // int crtacount = 3 - outboundTask.Count; |
| | | // List<Dt_taskinfo> outboundcCrteateTask = Dt_taskinfoRepository.Instance.Find(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString() |
| | | //&& r.task_state == TaskState.TaskState_Create.ToString()).OrderBy(r=>r.task_createtime).Take(crtacount).ToList(); |
| | | |
| | | // outboundTask.AddRange(outboundcCrteateTask); |
| | | //} |
| | | |
| | | |
| | | if (null != outboundTask && outboundTask.Count > 0) |
| | | else if (Gznumber == 2) |
| | | { |
| | | List<string> fromStation = outboundTask.Where(r=>r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()).Select(r => r.task_fromlocationid).ToList(); |
| | | fromStation.AddRange(outboundTask.Where(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()).Select(r => r.task_tolocationid).ToList()); |
| | | |
| | | foreach (var item in fromStation) |
| | | List<Dt_taskinfo> outbound = Dt_taskinfoRepository.Instance.Find(x => |
| | | x.task_beginstation == "90101" |
| | | ); |
| | | foreach (var item in outbound) |
| | | { |
| | | string[] location = item.Split('-'); |
| | | string[] location = item.task_tolocationid.Split('-'); |
| | | //è·åå½åæä»»å¡çå± |
| | | int layer = int.Parse(location[0]); |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"åé
任塿¶ï¼æå
¥åºä»»å¡éè¦å é¤çå±ï¼{layer}ï¼å½åå±è´§ä½ç¼å·ï¼{item.ToJson()},å½åç°æä»»å¡{outbound.ToJson()}"); |
| | | listLayer.Remove(layer); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | List<Dt_taskinfo> inboundTask = Dt_taskinfoRepository.Instance.Find(r => r.task_type.Contains("Inbound")); |
| | | if (null != inboundTask && inboundTask.Count > 0) |
| | | { |
| | | foreach (var item in inboundTask) |
| | | { |
| | | //妿åè´§å®æï¼å¯ä»¥åé
|
| | | if (string.IsNullOrEmpty(item.task_bak_2) || !"2".Equals(item.task_bak_2)) |
| | | { |
| | | string[] location = item.task_tolocationid.Split('-'); |
| | | //è·åå½åæä»»å¡çå± |
| | | int layer = int.Parse(location[0]); |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"åé
任塿¶ï¼æå
¥åºä»»å¡éè¦å é¤çå±ï¼{layer}ï¼å½åå±è´§ä½ç¼å·ï¼{item.ToJson()},å½åç°æä»»å¡{inboundTask.ToJson()}"); |
| | | listLayer.Remove(layer); |
| | | } |
| | | } |
| | | } |
| | | List<Dt_taskinfo> outboundTask = Dt_taskinfoRepository.Instance.Find(r => ((r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()) |
| | | && (r.task_state == TaskState.TaskState_RGV_Received.ToString() || r.task_state == TaskState.TaskState_RGV_Finished.ToString())) |
| | | || r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()); |
| | | |
| | | if (null != outboundTask && outboundTask.Count > 0) |
| | | { |
| | | List<string> fromStation = outboundTask.Where(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Out.ToString()).Select(r => r.task_fromlocationid).ToList(); |
| | | fromStation.AddRange(outboundTask.Where(r => r.task_type == TaskType.TaskType_Box_Pallet_Measure_Back.ToString()).Select(r => r.task_tolocationid).ToList()); |
| | | |
| | | foreach (var item in fromStation) |
| | | { |
| | | string[] location = item.Split('-'); |
| | | //è·åå½åæä»»å¡çå± |
| | | int layer = int.Parse(location[0]); |
| | | LogRecord.WriteLog((int)LogEnum.InBound, $"åé
任塿¶ï¼æå
¥åºä»»å¡éè¦å é¤çå±ï¼{layer}ï¼å½åå±è´§ä½ç¼å·ï¼{item.ToJson()},å½åç°æä»»å¡{outboundTask.ToJson()}"); |
| | | listLayer.Remove(layer); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | List<int> rgvLayer = new List<int>(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | if (locationId.Count > 0) |
| | | { |
| | | //ä¼å
åé
ç©¿æ¢è½¦çå± |
| | | if (rgvLayer.Count > 0) |
| | | { |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() && |
| | | !locationId.Contains(x.location_id) && !x.location_islocked && rgvLayer.Contains(x.location_layer)).OrderBy(x => x.location_layer) |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() |
| | | && !x.location_islocked && rgvLayer.Contains(x.location_layer) && !locationId.Contains(x.location_id)).OrderBy(x => x.location_layer) |
| | | .ThenBy(x => x.location_column).FirstOrDefault(); |
| | | if (null != locationinfo) |
| | | return locationinfo; |
| | | return locationinfo; |
| | | else |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() && |
| | | !locationId.Contains(x.location_id) && !x.location_islocked && listLayer.Contains(x.location_layer)).OrderBy(x => x.location_layer) |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() |
| | | && !x.location_islocked && listLayer.Contains(x.location_layer) && !locationId.Contains(x.location_id)).OrderBy(x => x.location_layer) |
| | | .ThenBy(x => x.location_column).FirstOrDefault(); |
| | | } |
| | | else |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() && |
| | | !locationId.Contains(x.location_id) && !x.location_islocked && listLayer.Contains(x.location_layer)).OrderBy(x => x.location_layer) |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() |
| | | && !x.location_islocked && listLayer.Contains(x.location_layer) && !locationId.Contains(x.location_id)).OrderBy(x => x.location_layer) |
| | | .ThenBy(x => x.location_column).FirstOrDefault(); |
| | | |
| | | if (null != locationinfo) |
| | |
| | | && !x.location_islocked && listLayer.Contains(x.location_layer)).OrderBy(x => x.location_layer).ThenBy(x => x.location_column).FirstOrDefault(); |
| | | |
| | | if (null != locationinfo) |
| | | return locationinfo; |
| | | } |
| | | |
| | | if (locationinfo == null) |
| | | { |
| | | locationinfo = Dt_locationinfoRepository.Instance.Find(x => x.location_state == LocationState.LocationState_Empty.ToString() |
| | | && !x.location_islocked && listLayer.Contains(x.location_layer)).OrderBy(x => x.location_layer).ThenBy(x => x.location_column).FirstOrDefault(); |
| | | if (null != locationinfo) |
| | | return locationinfo; |
| | | } |
| | | throw new Exception("ææ è´§ä½å¯åé
"); |