| | |
| | | using MailKit.Search; |
| | | using Mapster; |
| | | using Masuit.Tools; |
| | | 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_InZdp_mes_htyRepository _InZdp_Mes_HtyRepository; |
| | | 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_InZdp_mes_htyRepository inZdp_Mes_HtyRepository, |
| | | IDt_ZdpStockRepository zdpStockRepository, |
| | | IDt_ZdpStock_htyRepository dt_ZdpStock_HtyRepository, |
| | | IDt_OutZdp_htyRepository dt_OutZdp_HtyRepository) : base(BaseDal) |
| | | IDt_OutZdp_htyRepository dt_OutZdp_HtyRepository, |
| | | IDt_PreOutboundRepository dt_PreOutboundRepository, |
| | | ILocationInfoRepository locationInfoRepository) : base(BaseDal) |
| | | |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _ZdpStockRepository = zdpStockRepository; |
| | | _ZdpStock_HtyRepository = dt_ZdpStock_HtyRepository; |
| | | _Dt_OutZdp_htyRepository = dt_OutZdp_HtyRepository; |
| | | _PreOutboundRepository = dt_PreOutboundRepository; |
| | | _locationInfoRepository = locationInfoRepository; |
| | | } |
| | | |
| | | #region å¤é¨æ¥å£æ¹æ³ |
| | |
| | | Wheels_mttype = stock.Wheels_mttype, |
| | | //Wheels_SequenceNum = "", |
| | | Wheels_ygljz = stock.Wheels_ygljz, |
| | | Wheels_DateDet = stock.Wheels_DateDet, |
| | | Wheels_Statue = stock.Wheels_Statue, |
| | | }; |
| | | |
| | | |
| | |
| | | Zdp_GKJZ = stock.Zdp_GKJZ, |
| | | Zdp_LSCSYMH = stock.Zdp_LSCSYMH, |
| | | Zdp_rksj = stock.Zdp_rksj, |
| | | Zdp_Statue= stock.Zdp_Statue, |
| | | Zdp_DateDet = stock.Zdp_DateDet, |
| | | }; |
| | | |
| | | // äºå¡å¤ç |
| | |
| | | SourceAddress = zdpInfo.Zdp_Location, |
| | | CurrentAddress =zdpInfo.Zdp_Location, |
| | | TaskState = (int)TaskOutStatusEnum.OutNew, |
| | | TaskType = outtype == "2" ? (int)TaskOutboundTypeEnum.OutBrake : (int)TaskOutboundTypeEnum.OutWheels, |
| | | TaskType = (int)TaskOutboundTypeEnum.OutBrake, |
| | | TaskNum = BaseDal.GetTaskNo().Result, |
| | | Creater = "System", |
| | | CreateDate = DateTime.Now, |
| | |
| | | { |
| | | Dt_WheelsStock stockInfo = _WheelsStockRepository.QueryFirst(x => x.Wheels_code == item); |
| | | if (stockInfo == null) return content.Error("æªæ¥è¯¢å°å¯¹åºçåºåä¿¡æ¯"); |
| | | |
| | | Dt_PreOutbound dt_Pre=_PreOutboundRepository.QueryFirst(x => x.PalletCode == stockInfo.Wheels_code); |
| | | if (dt_Pre != null) |
| | | { |
| | | return content.Error($"å½å车轮å·å·²å¨æååºåºä¸ï¼ä¸å¯ç´æ¥åºåºï¼ï¼ï¼ï¼è½¦è½®æ¡ç ï¼{dt_Pre.PalletCode}"); |
| | | } |
| | | |
| | | |
| | | stockInfo.Wheels_CurrentStatue = 4; |
| | | string Location = stockInfo.Wheels_Location; |
| | | var locationst = locationinfoData.Where(x => x.LocationCode== stockInfo.Wheels_Location).FirstOrDefault(); |
| | |
| | | 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); |
| | |
| | | return content.Error("å é¤ä»»å¡å¼å¸¸ï¼" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <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è·åä»»å¡ |
| | |
| | | |
| | | var wheels_Mes_Hty = inWheels_Mes.Adapt<Dt_InWheels_mes_hty>(); |
| | | |
| | | wheels_Mes_Hty.Wheels_Type = "è½®"; |
| | | wheels_Mes_Hty.Wheels_CurrentStatue = "2"; |
| | | wheels_Mes_Hty.FinishDate = DateTime.Now; |
| | | wheels_Mes_Hty.OperateType = (int)OperateTypeEnum.èªå¨å®æ; |
| | |
| | | #endregion ä»»å¡è¯·æ±æ¹æ³ |
| | | |
| | | #endregion private å
鍿¹æ³ |
| | | |
| | | |
| | | |
| | | public WebResponseContent GetStockStatue() |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | int Wherecount = _WheelsStockRepository.QueryData(x => x.Wheels_Statue == 1).Count(); |
| | | |
| | | int Zdpcount = _ZdpStockRepository.QueryData(x => x.Zdp_Statue == 1).Count(); |
| | | |
| | | content.Data = new |
| | | { |
| | | WheelsCount = Wherecount, |
| | | ZdpCount = Zdpcount |
| | | }; |
| | | return content; |
| | | } |
| | | } |