| | |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Database; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; |
| | | using SqlSugar; |
| | | using System.Diagnostics; |
| | | using System.Reflection.Emit; |
| | | using System.Text.RegularExpressions; |
| | |
| | | private readonly IDt_ZdpStockRepository _ZdpStockRepository; |
| | | private readonly IDt_ZdpStock_htyRepository _ZdpStock_HtyRepository; |
| | | private readonly IDt_PreOutboundRepository _PreOutboundRepository; |
| | | private readonly ILocationInfoRepository _locationInfoRepository; |
| | | |
| | | |
| | | public Dt_TaskService(IDt_TaskRepository BaseDal, |
| | |
| | | IDt_ZdpStockRepository zdpStockRepository, |
| | | IDt_ZdpStock_htyRepository dt_ZdpStock_HtyRepository, |
| | | IDt_OutZdp_htyRepository dt_OutZdp_HtyRepository, |
| | | IDt_PreOutboundRepository dt_PreOutboundRepository) : base(BaseDal) |
| | | IDt_PreOutboundRepository dt_PreOutboundRepository, |
| | | ILocationInfoRepository locationInfoRepository) : base(BaseDal) |
| | | |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _ZdpStock_HtyRepository = dt_ZdpStock_HtyRepository; |
| | | _Dt_OutZdp_htyRepository = dt_OutZdp_HtyRepository; |
| | | _PreOutboundRepository = dt_PreOutboundRepository; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | } |
| | | |
| | | #region å¤é¨æ¥å£æ¹æ³ |
| | |
| | | IsCheck = true, |
| | | Standards = stockInfo.Wheels_NewOrOld |
| | | }; |
| | | |
| | | |
| | | |
| | | task = new Dt_Task |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | // è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | //è·åWMS IPå°åç¨äºåéä»»å¡è¯·æ± |
| | | var wmsIpAddress = GetWCSIpReceiveTask(); |
| | | if (wmsIpAddress == null) |
| | | { |
| | |
| | | _WheelsStockRepository.UpdateData(WheelList); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | |
| | | return await BaseDal.Delete(ids); |
| | | } |
| | | |
| | | |
| | | #region å é¤ä»»å¡åæ» |
| | | public override WebResponseContent DeleteData(object[] key) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | |
| | | if (task.TaskState != (int)TaskInStatusEnum.InNew && task.TaskState != (int)TaskOutStatusEnum.OutNew && task.TaskState != (int)TaskStatus.Created) |
| | | { |
| | | return content.Error("ä»»å¡ä¸å¤äºæ°å»ºç¶æ,ç¦æ¢å é¤!"); |
| | | } |
| | | |
| | | ////å
¥åºæä¸¾ |
| | | //List<int> TaskInboundTypeEnums = Enum.GetValues(typeof(TaskInboundTypeEnum)).Cast<int>().ToList(); |
| | | ////åºåºæä¸¾ |
| | | //List<int> TaskOutboundTypeEnums = Enum.GetValues(typeof(TaskOutboundTypeEnum)).Cast<int>().ToList(); |
| | | ////ç§»åºæä¸¾ |
| | | //List<int> TaskMoveTypeEnums = Enum.GetValues(typeof(TaskRelocationTypeEnum)).Cast<int>().ToList(); |
| | | //夿任å¡ç±»å |
| | | // æ ¹æ®ä»»å¡ç±»åè°ç¨ç¸åºç宿任塿¹æ³ |
| | | |
| | | // éªè¯åºåæ¯å¦åå¨ |
| | | var stock = _WheelsStockRepository.QueryFirstNavAsync(x => x.Wheels_Num.Contains(task.PalletCode) && x.Wheels_Location == task.SourceAddress); |
| | | var ZdpStock = _ZdpStockRepository.QueryFirstNavAsync(x => x.Zdp_code == task.PalletCode && x.Zdp_Location == task.SourceAddress); |
| | | bool res = false; |
| | | switch (task.TaskType) |
| | | { |
| | | case (int)TaskInboundTypeEnum.Inbound: |
| | | case (int)TaskInboundTypeEnum.InWheels: |
| | | case (int)TaskInboundTypeEnum.InBrake: |
| | | LogFactory.GetLog("ä»»å¡å®æ").InfoFormat(true, "å
¥åºä»»å¡", ""); |
| | | res = SellectLocationInfo(task,1); |
| | | break; |
| | | |
| | | case (int)TaskOutboundTypeEnum.Outbound: |
| | | case (int)TaskOutboundTypeEnum.OutWheels: |
| | | LogFactory.GetLog("ä»»å¡å®æ").InfoFormat(true, "åºåºä»»å¡", ""); |
| | | res = SellectLocationInfo(task,2); |
| | | break; |
| | | |
| | | case (int)TaskOutboundTypeEnum.OutBrake: |
| | | LogFactory.GetLog("ä»»å¡å®æ").InfoFormat(true, "å¶å¨çåºåºä»»å¡", ""); |
| | | res = SellectLocationInfo(task,3); |
| | | break; |
| | | |
| | | case (int)TaskRelocationTypeEnum.Relocation: |
| | | if (stock != null) |
| | | { |
| | | res = SellectLocationInfo(task,4); |
| | | } |
| | | else |
| | | { |
| | | res = SellectLocationInfo(task,5); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | return content.Error("ä»»å¡ç±»åä¸åå¨"); |
| | | } |
| | | |
| | | if (!res) |
| | | { |
| | | return content.Error("卿§è¡ä»»å¡åç±»çæ¶ååºç°é误ï¼"); |
| | | } |
| | | |
| | | var taskHtyNG = CreateHistoricalTask(task, true); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·ååºä½ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="targetAddress"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="NotImplementedException"></exception> |
| | | private bool SellectLocationInfo(Dt_Task task,int taskType) |
| | | { |
| | | // è·ååºä½ä¿¡æ¯ |
| | | DtLocationInfo locationInfoT = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress); |
| | | DtLocationInfo locationInfoS = _locationInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | | |
| | | |
| | | Dt_WheelsStock stock = _WheelsStockRepository.QueryFirst(x => x.Wheels_Num.Contains(task.PalletCode) && x.Wheels_Location == task.SourceAddress); |
| | | Dt_ZdpStock ZdpStock = _ZdpStockRepository.QueryFirst(x => x.Zdp_code == task.PalletCode && x.Zdp_Location == task.SourceAddress); |
| | | |
| | | //if (locationInfoT == null) return false; |
| | | |
| | | //if (locationInfoS == null) return false; |
| | | //1-å
¥åº 2-åºåº 3-å¶å¨çåºåº 4-ç§»åº |
| | | var db = _locationInfoRepository.Db as SqlSugarClient; |
| | | try |
| | | { |
| | | db.Ado.BeginTran(); |
| | | if (taskType == 1) |
| | | { |
| | | locationInfoT.LocationStatus = (int)LocationEnum.Free; |
| | | bool res = _locationInfoRepository.UpdateData(locationInfoT); |
| | | if (res) |
| | | { |
| | | db.Ado.CommitTran(); |
| | | return true; |
| | | } |
| | | } |
| | | else if (taskType == 2) |
| | | { |
| | | locationInfoS.LocationStatus = (int)LocationEnum.InStock; |
| | | bool res = _locationInfoRepository.UpdateData(locationInfoS); |
| | | stock.Wheels_CurrentStatue = 1; |
| | | bool ress = _WheelsStockRepository.UpdateData(stock); |
| | | if (res && ress) |
| | | { |
| | | db.Ado.CommitTran(); |
| | | return true; |
| | | } |
| | | } |
| | | else if (taskType == 3) |
| | | { |
| | | locationInfoS.LocationStatus = (int)LocationEnum.InStock; |
| | | bool res = _locationInfoRepository.UpdateData(locationInfoS); |
| | | ZdpStock.Zdp_CurrentStatue = 1; |
| | | bool ress = _ZdpStockRepository.UpdateData(ZdpStock); |
| | | if (res && ress) |
| | | { |
| | | db.Ado.CommitTran(); |
| | | return true; |
| | | } |
| | | } |
| | | //ç§»åº |
| | | else |
| | | { |
| | | locationInfoT.LocationStatus = (int)LocationEnum.Free; |
| | | locationInfoS.LocationStatus = (int)LocationEnum.InStock; |
| | | bool res = _locationInfoRepository.UpdateData(locationInfoT); |
| | | bool res1 = _locationInfoRepository.UpdateData(locationInfoS); |
| | | if(taskType == 4) |
| | | { |
| | | stock.Wheels_CurrentStatue = 1; |
| | | } |
| | | else |
| | | { |
| | | ZdpStock.Zdp_CurrentStatue = 1; |
| | | } |
| | | bool ress = taskType == 4 ? _WheelsStockRepository.UpdateData(stock) : _ZdpStockRepository.UpdateData(ZdpStock); |
| | | if (res && res1 && ress) |
| | | { |
| | | db.Ado.CommitTran(); |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.Ado.RollbackTran(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// éè¿IDè·åä»»å¡ |
| | | /// </summary> |
| | | /// <param name="id">ä»»å¡ID</param> |