From a6a33f6916afbf1fc629baecb772939cda2ee981 Mon Sep 17 00:00:00 2001 From: wankeda <Administrator@DESKTOP-HAU3ST3> Date: 星期四, 13 三月 2025 17:58:12 +0800 Subject: [PATCH] 代码提交 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 307 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 246 insertions(+), 61 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index dfd5943..9a8155e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -16,6 +16,7 @@ #endregion << 鐗� 鏈� 娉� 閲� >> using AutoMapper; +using Magicodes.IE.Core; using MailKit.Search; using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; @@ -31,6 +32,8 @@ using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; +using WIDESEA_Common; +using WIDESEA_Common.AGVEunm; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; @@ -83,7 +86,7 @@ } /// <summary> - /// 浠诲姟瀹屾垚 + /// 鎵嬪姩浠诲姟瀹屾垚 /// </summary> /// <param name="taskNum">浠诲姟鍙�</param> /// <returns>杩斿洖澶勭悊缁撴灉</returns> @@ -97,29 +100,36 @@ { return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } - _unitOfWorkManage.BeginTran(); - MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); - if (methodInfo != null) - { - WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); - if (responseContent != null) - { - if (App.User.UserId > 0) - { - var response = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "浠诲姟瀹屾垚"); - if (!response.Status) - { - _unitOfWorkManage.RollbackTran(); - return WebResponseContent.Instance.Error(response.Message); - } - _unitOfWorkManage.CommitTran(); - return content = responseContent; - } - _unitOfWorkManage.CommitTran(); - return content = responseContent; - } - } - return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + //_unitOfWorkManage.BeginTran(); + int TaskStatus = AGVTaskStatusEnum.AGV_Completion.ObjToInt(); + _taskHtyService.AddTaskHty(task, TaskStatus); + HCJFree(task, TaskStatus); + BaseDal.DeleteData(task); + #region + //MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); + //if (methodInfo != null) + //{ + // WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); + // if (responseContent != null) + // { + // if (App.User.UserId > 0) + // { + // var response = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "浠诲姟瀹屾垚"); + // if (!response.Status) + // { + // _unitOfWorkManage.RollbackTran(); + // return WebResponseContent.Instance.Error(response.Message); + // } + // _unitOfWorkManage.CommitTran(); + // return content = responseContent; + // } + // _unitOfWorkManage.CommitTran(); + // return content = responseContent; + // } + + //} + #endregion + return content = WebResponseContent.Instance.OK(); } catch (Exception ex) { @@ -128,7 +138,7 @@ } finally { - WriteLog.GetLog("浠诲姟瀹屾垚").Write($"鎿嶄綔浜猴細{(App.User.UserId>0? App.User.UserName: "System")}{ Environment.NewLine}浠诲姟鍙凤細{taskNum}{Environment.NewLine}{ JsonConvert.SerializeObject(content)}", "浠诲姟瀹屾垚"); + WriteLog.GetLog("浠诲姟瀹屾垚").Write($"鎿嶄綔浜猴細{(App.User.UserId > 0 ? App.User.UserName : "System")}{Environment.NewLine}浠诲姟鍙凤細{taskNum}{Environment.NewLine}{JsonConvert.SerializeObject(content)}", "浠诲姟瀹屾垚"); } } public WebResponseContent TaskCancel(int taskNum) @@ -139,39 +149,45 @@ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); if (task == null) { - return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + return content = WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); } - _unitOfWorkManage.BeginTran(); - MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCancel"); - if (methodInfo != null) - { - WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); - if (responseContent != null) - { - if (responseContent != null) - { - if (App.User.UserId > 0) - { - var response = HttpHelper.Post<WebResponseContent>(url + "TaskCancel?taskNum=" + task.TaskNum, "", "浠诲姟鍙栨秷"); - if (!response.Status) - { - _unitOfWorkManage.RollbackTran(); - return content=WebResponseContent.Instance.Error(response.Message); - } - _unitOfWorkManage.CommitTran(); - return content=responseContent; - } - _unitOfWorkManage.CommitTran(); - return content=responseContent; - } - } - } - return content=WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + //_unitOfWorkManage.BeginTran(); + int TaskStatus = AGVTaskStatusEnum.AGV_ManuallyCancel.ObjToInt(); + _taskHtyService.AddTaskHty(task, TaskStatus); + //HCJFree(task, TaskStatus); + BaseDal.DeleteData(task); + #region + //MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCancel"); + //if (methodInfo != null) + //{ + // WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); + // if (responseContent != null) + // { + // if (responseContent != null) + // { + // if (App.User.UserId > 0) + // { + // var response = HttpHelper.Post<WebResponseContent>(url + "TaskCancel?taskNum=" + task.TaskNum, "", "浠诲姟鍙栨秷"); + // if (!response.Status) + // { + // _unitOfWorkManage.RollbackTran(); + // return content = WebResponseContent.Instance.Error(response.Message); + // } + // _unitOfWorkManage.CommitTran(); + // return content = responseContent; + // } + // _unitOfWorkManage.CommitTran(); + // return content = responseContent; + // } + // } + //} + #endregion + return content = WebResponseContent.Instance.OK(); } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); - return content=WebResponseContent.Instance.Error(ex.Message); + return content = WebResponseContent.Instance.Error(ex.Message); } finally { @@ -211,7 +227,7 @@ task.Modifier = App.User.UserId > 0 ? App.User.UserName : "System"; BaseDal.UpdateData(task); _unitOfWorkManage.CommitTran(); - return content = WebResponseContent.Instance.OK(); + return content = WebResponseContent.Instance.OK(); } catch (Exception ex) { @@ -248,7 +264,7 @@ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); - _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound,task.TaskNum); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound, task.TaskNum); _unitOfWorkManage.CommitTran(); return WebResponseContent.Instance.OK(); } @@ -257,7 +273,7 @@ _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } - + } /// <summary> @@ -538,7 +554,7 @@ } } - + public WebResponseContent OutboundTaskCancel(Dt_Task task) { try @@ -617,7 +633,7 @@ task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); - + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _unitOfWorkManage.CommitTran(); @@ -643,7 +659,7 @@ stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); _stockService.StockInfoService.Repository.UpdateData(stockInfo); - locationEnd.LocationStatus= LocationStatusEnum.Free.ObjToInt(); + locationEnd.LocationStatus = LocationStatusEnum.Free.ObjToInt(); _basicService.LocationInfoService.RelocationFree(locationStart, task.TaskNum); _basicService.LocationInfoService.Repository.UpdateData(locationEnd); @@ -661,7 +677,7 @@ } public bool DepthTask(Dt_LocationInfo location) { - if (location != null ) + if (location != null) { Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.RoadwayNo == location.RoadwayNo && x.Column == location.Column && x.Layer == location.Layer && x.Depth != location.Depth && x.Row != location.Row && (SqlFunc.Abs(x.Row - location.Row) == 1)); if (locations != null) @@ -682,7 +698,7 @@ { expression = x => x.Creater == App.User.UserName; } - var task = BaseDal.Db.Queryable<Dt_Task>().OrderByDescending(x => x.CreateDate).Take(10).Select(x => new Dt_Task { TaskNum = x.TaskNum, PalletCode=x.PalletCode, TaskType=x.TaskType,SourceAddress=x.SourceAddress,TargetAddress=x.TargetAddress }).ToList(); + var task = BaseDal.Db.Queryable<Dt_Task>().OrderByDescending(x => x.CreateDate).Take(10).Select(x => new Dt_Task { TaskNum = x.TaskNum, PalletCode = x.PalletCode, TaskType = x.TaskType, SourceAddress = x.SourceAddress, TargetAddress = x.TargetAddress }).ToList(); content = WebResponseContent.Instance.OK(data: task); } catch (Exception ex) @@ -691,5 +707,174 @@ } return content; } + /// <summary> + /// 鍘熸潗鏂欏簱澶у睆浠诲姟鏄剧ず + /// </summary> + /// <param name="saveModel"></param> + /// <returns></returns> + public WebResponseContent GetAGVTaskData(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + string type = saveModel.MainData["AGVName"].ToString(); + List<Dt_Task> agvtask = new List<Dt_Task>(); + agvtask = BaseDal.QueryData(x => x.TaskStatus == AGVTaskStatusEnum.AGV_Query.ObjToInt()).ToList(); + if (agvtask.Count <= 0) return content.Error("鏈壘鍒颁换鍔�"); + foreach (var item in agvtask) + { + item.Remark = item.TaskStatus == AGVTaskStatusEnum.AGV_New.ObjToInt() ? "鏂板缓" : item.TaskStatus == AGVTaskStatusEnum.AGV_Query.ObjToInt() ? "闃熷垪涓�" : item.TaskStatus == AGVTaskStatusEnum.AGV_Executing.ObjToInt() ? "鎵ц涓�" : item.TaskStatus == AGVTaskStatusEnum.AGV_SendOut.ObjToInt() ? "宸蹭笅鍙�" : ""; + } + return content.OK(data: agvtask); + } + catch (Exception) + { + + throw; + } + } + /// <summary> + /// 鎴愬搧搴撳ぇ灞忎换鍔℃樉绀� + /// </summary> + /// <param name="saveModel"></param> + /// <returns></returns> + public WebResponseContent GetAGVTaskDataCP(SaveModel saveModel) + { + WebResponseContent content = new WebResponseContent(); + try + { + string type = saveModel.MainData["AGVName"].ToString(); + List<Dt_Task> agvtask = new List<Dt_Task>(); + agvtask = BaseDal.QueryData(x => x.TaskType == TaskTypeEnum.Inbound.ObjToInt()).ToList(); + if (agvtask.Count <= 0) return content.Error("鏈壘鍒颁换鍔�"); + foreach (var item in agvtask) + { + item.Remark = item.TaskStatus == AGVTaskStatusEnum.AGV_New.ObjToInt() ? "鏂板缓" : item.TaskStatus == AGVTaskStatusEnum.AGV_Query.ObjToInt() ? "闃熷垪涓�" : item.TaskStatus == AGVTaskStatusEnum.AGV_Executing.ObjToInt() ? "鎵ц涓�" : item.TaskStatus == AGVTaskStatusEnum.AGV_SendOut.ObjToInt() ? "宸蹭笅鍙�" : ""; + } + return content.OK(data: agvtask); + } + catch (Exception) + { + + throw; + } + } + + public WebResponseContent HCJLock(Dt_Task task) + { + WebResponseContent content = new WebResponseContent(); + Dt_CachePoint source = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == task.SourceAddress); + Dt_CachePoint target = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == task.TargetAddress); + if (target != null && source != null) + { + source.PointStatus = LocationStatusEnum.Lock.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(source); + target.PointStatus = LocationStatusEnum.Lock.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(target); + } + return content; + } + + public WebResponseContent HCJFree(Dt_Task task, int TaskStatus) + { + WebResponseContent content = new WebResponseContent(); + Dt_CachePoint source = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == task.SourceAddress); + Dt_CachePoint target = _basicService.CachePointService.Repository.QueryFirst(x => x.PointCode == task.TargetAddress); + var toaddress = JsonConvert.SerializeObject(target); + if (target != null && source != null) + { + if (toaddress.Contains("鎴愬搧搴�")) + { + source.PointStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(source); + target.PointStatus = LocationStatusEnum.InStock.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(target); + } + else + { + source.PointStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.CachePointService.Repository.UpdateData(source); + //target.PointStatus = LocationStatusEnum.Free.ObjToInt(); + //_basicService.CachePointService.Repository.UpdateData(target); + } + } + return content; + } + public WebResponseContent CacheStatus(SaveModel saveModel) + { + WebResponseContent response = new WebResponseContent(); + List<object> list = new List<object>(); + try + { + List<Dt_CachePoint> cachePoints = _basicService.CachePointService.Repository.QueryData(x => x.PointCode.Contains("鎴愬搧搴�")).ToList(); + foreach (var cachePoint in cachePoints) + { + bool isState = (cachePoint.PointStatus == LocationStatusEnum.Free.ObjToInt()); + string stateName = ""; + switch (cachePoint.PointStatus) + { + case 0: + stateName = "绌洪棽"; + break; + case 1: + stateName = "閿佸畾"; + break; + case 2: + stateName = "鏈夎揣"; + break; + default: + break; + } + list.Add(new { name = cachePoint.Depth, state = isState, statename = stateName }); + } + + response.OK(data: new { list }); + } + catch (Exception ex) + { + response.Error(ex.Message); + } + return response; + } + public WebResponseContent LEDloctionList() + { + WebResponseContent content = new WebResponseContent(); + { + //List<areaLocation> areaBucket = new List<areaLocation>(); + List<areaLocation> areaProduct = new List<areaLocation>(); + ////鎴愬搧鎬昏揣浣� + //List<Dt_locationinfo> productCount = locationinfoRepository.Find(x => x.location_areaid != "3" && x.location_areaid != "4"); + ////鎴愬搧绌鸿揣浣� + //List<Dt_locationinfo> emptyProductCount = locationinfoRepository.Find(x => x.location_areaid != "3" && x.location_areaid != "4" && x.location_state == LocationState.LocationState_Empty.ToString()); + ////鎴愬搧鏈夎揣璐т綅 + //List<Dt_locationinfo> storedyProductCount = locationinfoRepository.Find(x => x.location_areaid != "3" && x.location_areaid != "4" && x.location_state == LocationState.LocationState_Stored.ToString()); + ////鎴愬搧閿佸畾璐т綅 + //List<Dt_locationinfo> lockedProductCount = locationinfoRepository.Find(x => x.location_areaid != "3" && x.location_areaid != "4" + //&& x.location_state != LocationState.LocationState_Empty.ToString() && x.location_state != LocationState.LocationState_Stored.ToString()); + //areaProduct.Add(new areaLocation { name = "绌鸿揣浣�", count = emptyProductCount.Count }); + //areaProduct.Add(new areaLocation { name = "鎬昏揣浣�", count = productCount.Count }); + //areaProduct.Add(new areaLocation { name = "鎵ц璐т綅", count = lockedProductCount.Count }); + //areaProduct.Add(new areaLocation { name = "鏈夎揣璐т綅", count = storedyProductCount.Count }); + //content.OK(data: new { areaBucket, areaProduct }); + //鎴愬搧鎬昏揣浣� + List<Dt_CachePoint> productCount = _basicService.CachePointService.Repository.QueryData(x => x.PointCode.Contains("鎴愬搧搴�")); + //鎴愬搧绌鸿揣浣� + List<Dt_CachePoint> emptyProductCount = _basicService.CachePointService.Repository.QueryData(x => x.PointCode.Contains("鎴愬搧搴�") && x.PointStatus == LocationStatusEnum.Free.ObjToInt()); + //鎴愬搧鏈夎揣璐т綅 + List<Dt_CachePoint> storedyProductCount = _basicService.CachePointService.Repository.QueryData(x => x.PointCode.Contains("鎴愬搧搴�") && x.PointStatus == LocationStatusEnum.InStock.ObjToInt()); + //鎴愬搧閿佸畾璐т綅 + List<Dt_CachePoint> lockedProductCount = _basicService.CachePointService.Repository.QueryData(x => x.PointCode.Contains("鎴愬搧搴�") && x.PointStatus == LocationStatusEnum.Lock.ObjToInt()); + areaProduct.Add(new areaLocation { name = "绌鸿揣浣�", count = emptyProductCount.Count }); + areaProduct.Add(new areaLocation { name = "鎬昏揣浣�", count = productCount.Count }); + areaProduct.Add(new areaLocation { name = "鎵ц璐т綅", count = lockedProductCount.Count }); + areaProduct.Add(new areaLocation { name = "鏈夎揣璐т綅", count = storedyProductCount.Count }); + return content.OK(data: new { areaProduct }); + } + } + private class areaLocation + { + public string name { get; set; } + public int count { get; set; } + } } } -- Gitblit v1.9.3