| | |
| | | #endregion << ç æ¬ 注 é >> |
| | | |
| | | using AutoMapper; |
| | | using Magicodes.IE.Core; |
| | | using MailKit.Search; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®æ |
| | | /// æå¨ä»»å¡å®æ |
| | | /// </summary> |
| | | /// <param name="taskNum">ä»»å¡å·</param> |
| | | /// <returns>è¿åå¤çç»æ</returns> |
| | |
| | | { |
| | | 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) |
| | | { |
| | |
| | | } |
| | | 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) |
| | |
| | | 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 |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | 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(); |
| | | } |
| | |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent OutboundTaskCancel(Dt_Task task) |
| | | { |
| | | try |
| | |
| | | |
| | | 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(); |
| | |
| | | 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); |
| | | |
| | |
| | | } |
| | | 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) |
| | |
| | | { |
| | | 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) |
| | |
| | | } |
| | | 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; } |
| | | } |
| | | } |
| | | } |