| | |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.IdentityModel.Tokens; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using SqlSugar; |
| | | using System.ComponentModel.Design; |
| | | using System.Linq.Expressions; |
| | | using System.Net.NetworkInformation; |
| | | using System.Reflection; |
| | | using System.Text; |
| | |
| | | private readonly IMapper _mapper; |
| | | private readonly ILocationInfoRepository _locationRepository; |
| | | private readonly IDt_HandAutomaticRepository _handAutomaticRepository; |
| | | private readonly IDt_HostErrorMessageRepository _errorMessageRepository; |
| | | |
| | | public Dt_TaskService(IDt_TaskRepository BaseDal, |
| | | IUnitOfWorkManage unitOfWorkManage, |
| | |
| | | IStockInfoDetailRepository stockInfoDetailRepository, |
| | | IDt_StationManagerRepository stationManagerRepository, |
| | | IDt_HandAutomaticRepository handAutomaticRepository, |
| | | IDt_StationManagerService stationManagerService) : base(BaseDal) |
| | | IDt_StationManagerService stationManagerService, |
| | | IDt_HostErrorMessageRepository errorMessageRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _stockInfoRepository = stockInfoRepository; |
| | |
| | | _stationManagerRepository = stationManagerRepository; |
| | | _handAutomaticRepository = handAutomaticRepository; |
| | | _stationManagerService = stationManagerService; |
| | | _errorMessageRepository = errorMessageRepository; |
| | | } |
| | | |
| | | |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic != null) |
| | | { |
| | | return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | } |
| | | //var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | //if (HandAutomatic != null) |
| | | //{ |
| | | // return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | //} |
| | | var station = _stationManagerRepository.QueryFirst(x => x.HostName == taskDTO.SourceAddress && x.stationType == 1); |
| | | if (station == null) |
| | | { |
| | |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = "16" , |
| | | d_task_type = "32" , |
| | | d_floor = "1", |
| | | d_involed1 = taskNew.SourceAddress, |
| | | d_involed2 = InsertHyphenEveryTwoChars(taskNew.TargetAddress), |
| | |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | _locationRepository.UpdateData(location); |
| | | BaseDal.AddData(taskNew); |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | LogFactory.GetLog("PDA").InfoFormat(true, $"InboundTask请æ±åæ°ï¼{JsonConvert.SerializeObject(taskDTO)}{Environment.NewLine}", ""); |
| | | return content.OK("å
¥åºä»»å¡ä¸åæåï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic != null) |
| | | { |
| | | return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | } |
| | | //var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | //if (HandAutomatic != null) |
| | | //{ |
| | | // return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | //} |
| | | var station = _stationManagerRepository.QueryFirst(x => x.HostName == taskDTO.SourceAddress && x.stationType == 1); |
| | | if (station == null) |
| | | { |
| | |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = "16", |
| | | d_task_type = "32", |
| | | d_floor = "1", |
| | | d_involed1 = taskNew.SourceAddress, |
| | | d_involed2 = InsertHyphenEveryTwoChars(taskNew.TargetAddress), |
| | |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | _locationRepository.UpdateData(location); |
| | | BaseDal.AddData(taskNew); |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | LogFactory.GetLog("PDA").InfoFormat(true, $"SamplingInboundTask请æ±åæ°ï¼{JsonConvert.SerializeObject(taskDTO)}{Environment.NewLine}", ""); |
| | | return content.OK("æ½æ£å
¥åºä»»å¡ä¸åæåï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic != null) |
| | | { |
| | | return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | } |
| | | StationStatus stationOut = _stationManagerService.GetStationStatus("B001"); |
| | | if (stationOut == null) |
| | | { |
| | |
| | | { |
| | | return content.Error("æªæ¾å°åºåºç«å°ä¿¡æ¯"); |
| | | } |
| | | var stock = _stockInfoRepository.QueryFirst(x => x.LocationCode == taskDTO.SourceAddress); |
| | | if (stock == null) |
| | | { |
| | | return content.Error("该æçåºåä¸åå¨"); |
| | | } |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == stock.PalletCode); |
| | | |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.PalletCode); |
| | | if (task != null) |
| | | { |
| | | return content.Error("该æçå·²åå¨ä»»å¡"); |
| | | } |
| | | |
| | | var location = _locationRepository.QueryFirst(x => x.LocationCode == stock.LocationCode); |
| | | if (location.LocationStatus != (int)LocationEnum.InStock) |
| | | { |
| | | return content.Error("该åºä½ä¸æ¯æè´§ç¶æï¼è¯·ç¡®è®¤ç¶æåä¸åä»»å¡ï¼"); |
| | | } |
| | | |
| | | Dt_Task taskNew = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | |
| | | Grade = 1, |
| | | SeqNo = Convert.ToInt32(0), |
| | | CommandID = Convert.ToInt32(0), |
| | | SourceAddress = station.stationName, |
| | | TargetAddress = stock.LocationCode, |
| | | CurrentAddress = station.stationName, |
| | | NextAddress = stock.LocationCode, |
| | | SourceAddress = taskDTO.SourceAddress, |
| | | TargetAddress = station.stationName, |
| | | CurrentAddress = taskDTO.SourceAddress, |
| | | NextAddress = station.stationName, |
| | | TaskType = (int)TaskOutboundTypeEnum.Outbound, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Roadway = "PDA", |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = "32", |
| | | d_task_type = "64", |
| | | d_floor = "1", |
| | | d_involed1 = InsertHyphenEveryTwoChars(taskNew.SourceAddress), |
| | | d_involed2 = taskNew.TargetAddress, |
| | | d_involed5 = taskNew.TaskNum.ToString(), |
| | | }; |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | _locationRepository.UpdateData(location); |
| | | BaseDal.AddData(taskNew); |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | LogFactory.GetLog("PDA").InfoFormat(true, $"OutboundTask请æ±åæ°ï¼{JsonConvert.SerializeObject(taskDTO)}{Environment.NewLine}", ""); |
| | | return content.OK("åºåºä»»å¡ä¸åæåï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var HandAutomatic = _handAutomaticRepository.QueryFirst(x => true && x.HandAutomatic == "Automatic"); |
| | | if (HandAutomatic != null) |
| | | { |
| | | return content.Error("å½å䏿¯æå¨æ¨¡å¼"); |
| | | } |
| | | |
| | | StationStatus stationOut = _stationManagerService.GetStationStatus("B002"); |
| | | if (stationOut == null) |
| | | { |
| | |
| | | { |
| | | return content.Error("该åºä½ä¸æ¯æè´§ç¶æï¼è¯·ç¡®è®¤ç¶æåä¸åä»»å¡ï¼"); |
| | | } |
| | | station.stationHasTask = "æ½æ£åºåº"; |
| | | _stationManagerRepository.UpdateData(station); |
| | | |
| | | Dt_Task taskNew = new Dt_Task() |
| | | { |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | PalletCode = taskDTO.PalletCode, |
| | | PalletCode = stock.PalletCode, |
| | | Dispatchertime = DateTime.Now, |
| | | Grade = 1, |
| | | SeqNo = Convert.ToInt32(0), |
| | | CommandID = Convert.ToInt32(0), |
| | | SourceAddress = station.stationName, |
| | | TargetAddress = stock.LocationCode, |
| | | CurrentAddress = station.stationName, |
| | | NextAddress = stock.LocationCode, |
| | | TargetAddress = station.stationName, |
| | | SourceAddress = stock.LocationCode, |
| | | NextAddress = station.stationName, |
| | | CurrentAddress = stock.LocationCode, |
| | | TaskType = (int)TaskOutboundTypeEnum.OutQuality, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | Roadway = "PDA", |
| | | }; |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = "32", |
| | | d_task_type = "128", |
| | | d_floor = "1", |
| | | d_involed1 = InsertHyphenEveryTwoChars(taskNew.SourceAddress), |
| | | d_involed2 = taskNew.TargetAddress, |
| | | d_involed5 = taskNew.TaskNum.ToString(), |
| | | }; |
| | | location.LocationStatus = (int)LocationEnum.Lock; |
| | | _locationRepository.UpdateData(location); |
| | | BaseDal.AddData(taskNew); |
| | | SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | return content.OK(); |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | LogFactory.GetLog("PDA").InfoFormat(true, $"SamplingOutboundTask请æ±åæ°ï¼{JsonConvert.SerializeObject(taskDTO)}{Environment.NewLine}", ""); |
| | | return content.OK("æ½æ£åºåºä»»å¡ä¸åæåï¼"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | public DtLocationInfo GetLocation() |
| | | { |
| | | List<DtLocationInfo> locations = _locationRepository.QueryData(x => x.LocationStatus == (int)LocationEnum.Free); |
| | | return locations.OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenBy(x => x.Row).FirstOrDefault(); |
| | | var location = locations.OrderBy(x => x.Column).ThenBy(x => x.Layer).ThenBy(x => x.Row).FirstOrDefault(); |
| | | if(location != null) |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.SourceAddress == location.LocationName || x.TargetAddress == location.LocationName); |
| | | if(task != null) |
| | | { |
| | | GetLocation(); |
| | | } |
| | | } |
| | | return location; |
| | | } |
| | | |
| | | public WebResponseContent TaskComplete(int? TaskNum) |
| | |
| | | return CompleteInboundTask(task); |
| | | |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | //case (int)TaskStationTypeEnum..: |
| | | |
| | | LogFactory.GetLog("ä»»å¡å®æ").InfoFormat(true, "åºåºä»»å¡", ""); |
| | | return CompleteOutboundTask(task); |
| | |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | BaseDal.Update(task); |
| | | break; |
| | | |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | case (int)TaskOutboundTypeEnum.OutQuality: |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | case (int)TaskStationTypeEnum.StationToStation: |
| | | task.TaskState = (int)TaskOutStatusEnum.AGV_OutExecuting; |
| | | BaseDal.Update(task); |
| | | break; |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | task.TaskState = (int)TaskRelocationStatusEnum.AGV_RelocationExecuting; |
| | | BaseDal.Update(task); |
| | | break; |
| | | case (int)TaskFireAlarmTypeEnum.FireAlarmOut: |
| | | task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmExecuting; |
| | | BaseDal.Update(task); |
| | | break; |
| | | |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | task.TaskState = (int)TaskInStatusEnum.AGV_InExecuting; |
| | | BaseDal.Update(task); |
| | | break; |
| | | default: |
| | | return content.Error("ä»»å¡ç±»åä¸åå¨"); |
| | | } |
| | |
| | | Creater = "system", |
| | | LocationId = locationInf.Id, |
| | | }; |
| | | _stockInfoRepository.AddData(stock); |
| | | SqlSugarHelper.DbWMS.Insertable(stock).ExecuteCommand(); |
| | | _locationRepository.UpdateData(locationInf); |
| | | TaskMoveHty(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | task.TaskState = 135; |
| | | var locationInf = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | locationInf.LocationStatus = 0; |
| | | var stock = _stockInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode); |
| | | if(stock!=null) |
| | | { |
| | | DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); |
| | | stockInfo_Hty.ModifyDate = DateTime.Now; |
| | | |
| | | AddStockInfoHty(stockInfo_Hty); |
| | | AddStcokHty(task.PalletCode, task.SourceAddress); |
| | | |
| | | _stockInfoRepository.DeleteData(stock); |
| | | } |
| | | _locationRepository.UpdateData(locationInf); |
| | | TaskMoveHty(task); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | _unitOfWorkManage.RollbackTran(); |
| | | LogFactory.GetLog("åºåºä»»å¡å®æ").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}", ""); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | |
| | | public WebResponseContent CompleteFireAlarmboundTask(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | task.TaskState = (int)TaskFireAlarmStatusEnum.AGV_FireAlarmFinish; |
| | | |
| | | AddStcokHty(task.PalletCode,task.SourceAddress); |
| | | |
| | | TaskMoveHty(task); |
| | | _unitOfWorkManage.CommitTran(); |
| | | LogFactory.GetLog("ç«è¦åºåºä»»å¡å®æ").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(task)}", ""); |
| | | return content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | LogFactory.GetLog("ç«è¦åºåºä»»å¡å®æ").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}", ""); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public void AddStcokHty(string PalletCode,string Location) |
| | | { |
| | | //var stock = _stockInfoRepository.QueryFirst(x => x.PalletCode == PalletCode); |
| | | var stock = SqlSugarHelper.DbWMS.Queryable<DtStockInfo>().Where(x => x.PalletCode == PalletCode).First(); |
| | | if (stock != null) |
| | | { |
| | | DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>(); |
| | | stockInfo_Hty.ModifyDate = DateTime.Now; |
| | | |
| | | AddStockInfoHty(stockInfo_Hty); |
| | | |
| | | //_stockInfoRepository.DeleteData(stock); |
| | | SqlSugarHelper.DbWMS.Deleteable(stock).ExecuteCommand(); |
| | | } |
| | | var locationInf = _locationRepository.QueryFirst(x => x.LocationCode == Location); |
| | | if (locationInf != null) |
| | | { |
| | | locationInf.LocationStatus = 0; |
| | | _locationRepository.UpdateData(locationInf); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent CompleteSamplingOutboundTask(Dt_Task task) |
| | | { |
| | |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public void UpdateTask(string SourceAddress,string TargetAddress, string PalletCode) |
| | | { |
| | | var task = BaseDal.QueryFirst(x => x.PalletCode == PalletCode); |
| | | if (task != null) |
| | | { |
| | | task.SourceAddress = SourceAddress; |
| | | task.TargetAddress = TargetAddress; |
| | | BaseDal.UpdateData(task); |
| | | InsertAGVTask(task); |
| | | } |
| | | } |
| | | private int InsertAGVTask(Dt_Task task) |
| | | { |
| | | var AgvTask = SqlSugarHelper.DbAGV.Queryable<task_call>().Where(x => x.d_involed5 == task.TaskNum.ToString()).First(); |
| | | if (AgvTask != null) |
| | | { |
| | | string SourceAddress = string.Empty; |
| | | string TargetAddress = string.Empty; |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | { |
| | | SourceAddress = task.SourceAddress; |
| | | TargetAddress = InsertHyphenEveryTwoChars(task.TargetAddress); |
| | | } |
| | | else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | SourceAddress = InsertHyphenEveryTwoChars(task.SourceAddress); |
| | | TargetAddress = task.TargetAddress; |
| | | } |
| | | else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation) |
| | | { |
| | | TargetAddress = InsertHyphenEveryTwoChars(task.TargetAddress); |
| | | SourceAddress = InsertHyphenEveryTwoChars(task.SourceAddress); |
| | | } |
| | | else if (task.TaskType == (int)TaskStationTypeEnum.StationToStation) |
| | | { |
| | | TargetAddress = task.TargetAddress; |
| | | SourceAddress = task.SourceAddress; |
| | | } |
| | | else if (task.TaskType == (int)TaskFireAlarmTypeEnum.FireAlarmOut) |
| | | { |
| | | TargetAddress = task.TargetAddress; |
| | | SourceAddress = task.SourceAddress; |
| | | } |
| | | |
| | | AgvTask.d_involed1 = SourceAddress; |
| | | AgvTask.d_involed2 = TargetAddress; |
| | | var x = SqlSugarHelper.DbAGV.Updateable(AgvTask).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | return x; |
| | | } |
| | | else |
| | | { |
| | | string SourceAddress = string.Empty; |
| | | string TargetAddress = string.Empty; |
| | | string AGVType = string.Empty; |
| | | if (task.TaskType == (int)TaskInboundTypeEnum.Inbound) |
| | | { |
| | | SourceAddress = task.SourceAddress; |
| | | AGVType = "2"; |
| | | TargetAddress = InsertHyphenEveryTwoChars(task.TargetAddress); |
| | | } |
| | | else if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) |
| | | { |
| | | SourceAddress = InsertHyphenEveryTwoChars(task.SourceAddress); |
| | | TargetAddress = task.TargetAddress; |
| | | AGVType = "4"; |
| | | } |
| | | else if (task.TaskType == (int)TaskRelocationTypeEnum.Relocation) |
| | | { |
| | | TargetAddress = InsertHyphenEveryTwoChars(task.TargetAddress); |
| | | SourceAddress = InsertHyphenEveryTwoChars(task.SourceAddress); |
| | | AGVType = "16"; |
| | | } |
| | | else if (task.TaskType == (int)TaskStationTypeEnum.StationToStation) |
| | | { |
| | | TargetAddress = task.TargetAddress; |
| | | SourceAddress = task.SourceAddress; |
| | | AGVType = "8"; |
| | | } |
| | | else if (task.TaskType == (int)TaskFireAlarmTypeEnum.FireAlarmOut) |
| | | { |
| | | TargetAddress = task.TargetAddress; |
| | | SourceAddress = task.SourceAddress; |
| | | AGVType = "1"; |
| | | } |
| | | task_call task_Call = new task_call() |
| | | { |
| | | d_task_type = AGVType, |
| | | d_floor = "1", |
| | | d_involed1 = SourceAddress, |
| | | d_involed2 = TargetAddress, |
| | | d_involed5 = task.TaskNum.ToString(), |
| | | }; |
| | | var x = SqlSugarHelper.DbAGV.Insertable(task_Call).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | return x; |
| | | } |
| | | } |
| | | public WebResponseContent TaskMoveHty(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | var AgvTask = SqlSugarHelper.DbAGV.Queryable<task_call>().Where(x => x.d_involed5 == taskNum).First(); |
| | | if (AgvTask != null) |
| | | { |
| | | SqlSugarHelper.DbAGV.Deleteable(AgvTask).ExecuteCommand(); |
| | | var x=SqlSugarHelper.DbAGV.Deleteable(AgvTask).ExecuteCommand(); |
| | | LogFactory.GetLog("æå
¥æ°æ®å°AGV").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(x)}", ""); |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content.OK(); |
| | |
| | | LogFactory.GetLog("å é¤ä»»å¡").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}", ""); |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent GetTaskInfo() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Expression<Func<Dt_Task, bool>> expression = x => true; |
| | | if (!App.User.IsSuperAdmin) |
| | | { |
| | | expression = x => x.Creater == App.User.UserName; |
| | | } |
| | | |
| | | var task = BaseDal.QueryData(x => true).ToList(); |
| | | var newTask = task.OrderByDescending(x => x.CreateDate).Select(x => new |
| | | { |
| | | x.TaskNum, |
| | | x.PalletCode, |
| | | x.SourceAddress, |
| | | x.TargetAddress, |
| | | TaskType = new List<string> { GetTaskTypeDesc(x.TaskType) }[0], // æ¯ä¸ªä»»å¡ç¬ç«çæ TaskType |
| | | TaskState = new List<string> { GetTaskStateDesc(x.TaskState) }[0] // æ¯ä¸ªä»»å¡ç¬ç«çæ TaskState |
| | | }).ToList(); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: newTask); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | public WebResponseContent GetHostError() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Expression<Func<Dt_Task, bool>> expression = x => true; |
| | | if (!App.User.IsSuperAdmin) |
| | | { |
| | | expression = x => x.Creater == App.User.UserName; |
| | | } |
| | | |
| | | var now = DateTime.Now; |
| | | var startOfDay = new DateTime(now.Year, now.Month, now.Day); |
| | | var newTask = _errorMessageRepository.QueryData(x =>x.CreateDate> startOfDay).OrderByDescending(x => x.CreateDate).Select(x => new |
| | | { |
| | | x.id, |
| | | x.ErrorCode, |
| | | x.ErrorMessage, |
| | | x.Grade, |
| | | x.CreateDate |
| | | }).ToList(); |
| | | |
| | | content = WebResponseContent.Instance.OK(data: newTask); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | public string GetTaskTypeDesc(int taskType) |
| | | { |
| | | return taskType switch |
| | | { |
| | | (int)TaskInboundTypeEnum.Inbound => TaskInboundTypeEnum.Inbound.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskRelocationTypeEnum.Relocation => TaskRelocationTypeEnum.Relocation.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskStationTypeEnum.StationToStation => TaskStationTypeEnum.StationToStation.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskFireAlarmTypeEnum.FireAlarmOut => TaskFireAlarmTypeEnum.FireAlarmOut.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskOutboundTypeEnum.Outbound => TaskOutboundTypeEnum.Outbound.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskOutboundTypeEnum.OutQuality => TaskOutboundTypeEnum.OutQuality.GetIntegralRuleTypeEnumDesc(), |
| | | }; |
| | | } |
| | | public string GetTaskStateDesc(int? taskState) |
| | | { |
| | | return taskState switch |
| | | { |
| | | (int)TaskInStatusEnum.InNew => TaskInStatusEnum.InNew.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskInStatusEnum.AGV_InExecuting => TaskInStatusEnum.AGV_InExecuting.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskInStatusEnum.AGV_InFinish => TaskInStatusEnum.AGV_InFinish.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskRelocationStatusEnum.RelocationNew => TaskRelocationStatusEnum.RelocationNew.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskRelocationStatusEnum.AGV_RelocationExecuting => TaskRelocationStatusEnum.AGV_RelocationExecuting.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskRelocationStatusEnum.AGV_RelocationFinish => TaskRelocationStatusEnum.AGV_RelocationFinish.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskOutStatusEnum.OutNew => TaskOutStatusEnum.OutNew.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskOutStatusEnum.AGV_OutExecuting => TaskOutStatusEnum.AGV_OutExecuting.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskOutStatusEnum.AGV_OutFinish => TaskOutStatusEnum.AGV_OutFinish.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskFireAlarmStatusEnum.FireAlarmNew => TaskFireAlarmStatusEnum.FireAlarmNew.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskFireAlarmStatusEnum.AGV_FireAlarmExecuting => TaskFireAlarmStatusEnum.AGV_FireAlarmExecuting.GetIntegralRuleTypeEnumDesc(), |
| | | (int)TaskFireAlarmStatusEnum.FireAlarmFinish => TaskFireAlarmStatusEnum.FireAlarmFinish.GetIntegralRuleTypeEnumDesc(), |
| | | }; |
| | | } |
| | | |
| | | #endregion å¤é¨æ¥å£æ¹æ³ |
| | |
| | | } |
| | | } |
| | | |
| | | public override WebResponseContent DeleteData(object[] key) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | // å建åå²ä»»å¡å®ä¾æ¨¡å |
| | | try |
| | | { |
| | | foreach (var item in key) |
| | | { |
| | | //var task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(item)); |
| | | //var taskHty = task.Adapt<Dt_Task_Hty>(); |
| | | //taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System"; |
| | | //_taskHtyRepository.AddData(taskHty); |
| | | |
| | | //return base.DeleteData(key); |
| | | Dt_Task task = BaseDal.QueryFirst(x => x.TaskId == Convert.ToInt32(item)); |
| | | if (task == null) |
| | | { |
| | | return content.Error("æªæ¾å°ä»»å¡ä¿¡æ¯!"); |
| | | } |
| | | var taskHtyNG = CreateHistoricalTask(task, true); |
| | | |
| | | // æ§è¡æ°æ®åºäºå¡ |
| | | |
| | | // æ·»å åå²ä»»å¡ |
| | | var isTaskHtyAdd = _task_HtyRepository.AddData(taskHtyNG) > 0; |
| | | |
| | | // å é¤ä»»å¡æ°æ® |
| | | var isTaskDelete = BaseDal.Delete(task.TaskId); |
| | | } |
| | | return content.OK("å 餿å!"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error("å é¤ä»»å¡å¼å¸¸ï¼" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | #endregion private å
鍿¹æ³ |
| | | } |