| | |
| | | using System.Threading.Tasks; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Common.LocationEnum; |
| | | using WIDESEA_Common.OutboundOrder; |
| | | using WIDESEA_Common.StockEnum; |
| | | using WIDESEA_Common.TaskEnum; |
| | | using WIDESEA_Common.Warehouse; |
| | |
| | | using WIDESEA_IStockService; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.Basic; |
| | | using WIDESEA_Model.Models.Outbound; |
| | | using WIDESEA_Model.Models.Stock; |
| | | using WIDESEA_Model.View; |
| | | using WIDESEAWCS_DTO.Stock; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models.TaskInfo; |
| | |
| | | private readonly IRepository<Dt_StockInfoDetail> _IStockInfoDetailRepository; |
| | | private readonly IRepository<Dt_StockInfo_hty> _IStockInfohtyRepository; |
| | | private readonly IRepository<Dt_StockInfoDetail_Hty> _IStockInfoDetailHtyRepository; |
| | | private readonly IRepository<Dt_StockInfos> _IStockInfosRepository; |
| | | private readonly IRepository<Dt_FillingOrder> _FillingOrderRepository; |
| | | private readonly IRepository<Dt_OutboundOrder> _OutboundOrderRepository; |
| | | //WCS满桶åºåºä¿¡å· |
| | | private static bool kk = false; |
| | | |
| | | public TaskService(IRepository<Dt_Task> BaseDal, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | public TaskService(IRepository<Dt_Task> BaseDal, IRepository<Dt_OutboundOrder> OutboundOrderRepository, IRepository<Dt_FillingOrder> FillingOrderRepository, IRepository<Dt_StockInfos> IStockInfosRepository, ILocationInfoService ILocationInfoService, IRepository<Dt_StockInfoDetail> IStockInfoDetailRepository, IRepository<Dt_StockInfo_hty> IStockInfohtyRepository, IRepository<Dt_StockInfoDetail_Hty> IStockInfoDetailHtyRepository, IRepository<Dt_Outstockinfo> IOutstockinfoService, IStockService IStockService, IRepository<Dt_Warehouse> WarehouseService, IRepository<Dt_Outstockinfo> OutstockinfoRepository, ILocationInfoService LocationInfoService, IRepository<Dt_StockInfo> StockInfoRepository, IRepository<Dt_LocationInfo> LocationInfoRepository, IRepository<Dt_Task_Hty> Task_HtyRepository, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | { |
| | | _LocationInfoService = LocationInfoService; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | |
| | | _IStockInfoDetailRepository = IStockInfoDetailRepository; |
| | | _IStockInfohtyRepository = IStockInfohtyRepository; |
| | | _IStockInfoDetailHtyRepository = IStockInfoDetailHtyRepository; |
| | | _IStockInfosRepository = IStockInfosRepository; |
| | | _FillingOrderRepository = FillingOrderRepository; |
| | | _OutboundOrderRepository = OutboundOrderRepository; |
| | | } |
| | | |
| | | public IRepository<Dt_Task> Repository => BaseDal; |
| | | |
| | | |
| | | //æµè¯ |
| | | public WebResponseContent ceshi() |
| | | public string ceshi() |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | string mes = AppSettings.Get("MSE"); |
| | | if (!string.IsNullOrEmpty(mes)) |
| | | { |
| | | string k = ""; |
| | | HttpHelper.Get($"{mes}+{k}"); |
| | | } |
| | | return content; |
| | | Dt_LocationInfo locations = _LocationInfoService.AllotLocationInfo(2); |
| | | return "123"; |
| | | } |
| | | |
| | | |
| | |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_Task task = new Dt_Task(); |
| | | List<Dt_StockInfoDetail> stockInfoDetail = new List<Dt_StockInfoDetail>(); |
| | | List<MESSockInfo> MESSocks = new List<MESSockInfo>(); |
| | | //List<MESSockInfo> MESSocks = new List<MESSockInfo>(); |
| | | |
| | | string materielDetailedid = stock.MaterialCode1 + DateTime.Now.ToString("mmss").ObjToInt(); |
| | | |
| | | //å»MESæ¥è¯¢ç©æç¼å·è¯¦ç»ä¿¡æ¯ |
| | | int h = 0; |
| | | string mes = AppSettings.Get("MSE"); |
| | | if (!string.IsNullOrEmpty(mes)) |
| | | { |
| | | if (stock.MaterialCode1 != null && !stock.MaterialCode1.Equals("")) |
| | | { |
| | | MESSocks[0] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode1}")); |
| | | stockInfoDetail[0].MaterielCode = stock.MaterialCode1; |
| | | } |
| | | if (stock.MaterialCode2 != null && !stock.MaterialCode2.Equals("")) |
| | | { |
| | | MESSocks[1] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode2}")); |
| | | h++; |
| | | stockInfoDetail[1].MaterielCode = stock.MaterialCode2; |
| | | } |
| | | if (stock.MaterialCode3 != null && !stock.MaterialCode3.Equals("")) |
| | | { |
| | | MESSocks[2] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode3}")); |
| | | h++; |
| | | stockInfoDetail[2].MaterielCode = stock.MaterialCode3; |
| | | } |
| | | if (stock.MaterialCode4 != null && !stock.MaterialCode4.Equals("")) |
| | | { |
| | | MESSocks[3] = JsonConvert.DeserializeObject<MESSockInfo>(HttpHelper.Get($"{mes}+{stock.MaterialCode4}")); |
| | | h++; |
| | | stockInfoDetail[3].MaterielCode = stock.MaterialCode4; |
| | | } |
| | | } |
| | | //åå¨ç©æç¼å·è¯¦ç»ä¿¡æ¯ |
| | | for(int m = 0; m <= h; m++) |
| | | { |
| | | stockInfoDetail[m].MaterielDetailedid = materielDetailedid; |
| | | stockInfoDetail[m].BarcodeType = MESSocks[m].BarcodeType; |
| | | stockInfoDetail[m].AuxQty = MESSocks[m].AuxQty; |
| | | stockInfoDetail[m].Quantity = MESSocks[m].Quantity; |
| | | stockInfoDetail[m].MaxQty = MESSocks[m].MaxQty; |
| | | stockInfoDetail[m].BarWeight = MESSocks[m].BarWeight; |
| | | stockInfoDetail[m].PackageQty = MESSocks[m].PackageQty; |
| | | stockInfoDetail[m].QuantityIn = MESSocks[m].QuantityIn; |
| | | stockInfoDetail[m].QuantityOut = MESSocks[m].QuantityOut; |
| | | stockInfoDetail[m].Status = MESSocks[m].Status; |
| | | stockInfoDetail[m].Materialld = MESSocks[m].Materialld; |
| | | stockInfoDetail[m].BatchNum = MESSocks[m].BatchNum; |
| | | stockInfoDetail[m].CreateEmpld = MESSocks[m].CreateEmpld; |
| | | stockInfoDetail[m].Taskld = MESSocks[m].Taskld; |
| | | stockInfoDetail[m].TaskSubld = MESSocks[m].TaskSubld; |
| | | } |
| | | |
| | | string kk = stock.MaterialCode1.Replace("X", ""); |
| | | //åºåè´§åº |
| | | int k = 1; |
| | | Dt_Warehouse warehouse = _WarehouseRepository.QueryFirst(x => x.MaterialName == ""); |
| | | if (warehouse.MaterialType == (int)WarehouseTypeEnum.Food) |
| | | //æ¥è¯¢ç©æäºç»´ç¼ç |
| | | Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x => x.BarCode == kk); |
| | | if (FillingOrder == null) |
| | | { |
| | | LogLock.OutLogAOP("æ¥å£æ¥å¿", new string[] { "满桶å
¥åºä»»å¡çæ", $"{"äºç»´ç æ¥è¯¢å¼å¸¸"}" }); |
| | | content.Message = "äºç»´ç æ¥è¯¢å¼å¸¸"; |
| | | return content; |
| | | } |
| | | if (FillingOrder.WarehouseType.Equals("é£ååº")) |
| | | { |
| | | k = 2; |
| | | } |
| | | else if (warehouse.MaterialType == (int)WarehouseTypeEnum.Industry) |
| | | else if (FillingOrder.WarehouseType.Equals("å·¥ä¸åº")) |
| | | { |
| | | k = 3; |
| | | } |
| | |
| | | stockInfo.MaterielCode3 = stock.MaterialCode3; |
| | | stockInfo.MaterielCode4 = stock.MaterialCode4; |
| | | stockInfo.MaterielDetailedid = materielDetailedid; |
| | | stockInfo.StockType = (int)StockTypeEmun.æ°´; |
| | | stockInfo.MaterielName = FillingOrder.MaterialName; |
| | | //åå»ºç©æè¯¦ç»ä¿¡æ¯ |
| | | |
| | | //å¤å®å
¥åºæ¨¡å¼ |
| | |
| | | taskhty.Grade = task.Grade; |
| | | taskhty.Remark = task.Remark; |
| | | taskhty.TaskType = task.TaskType; |
| | | taskhty.TaskState = task.TaskState; |
| | | taskhty.TaskState = (int)TaskStatusEnum.Task_Finish; |
| | | |
| | | //å¼å§æ°æ®åºäºå¡ |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | stockInfo_Hty.MaterielDetailedid = stockInfo.MaterielDetailedid; |
| | | List<Dt_StockInfoDetail_Hty> stockInfoDetail_Hty = new List<Dt_StockInfoDetail_Hty>(); |
| | | int k = stockInfoDetail.Count() - 1; |
| | | for(int i = 0; i <= k; i++) |
| | | for (int i = 0; i <= k; i++) |
| | | { |
| | | stockInfoDetail_Hty[i].MaterielCode = stockInfoDetail[i].MaterielCode; |
| | | stockInfoDetail_Hty[i].MaterielDetailedid = stockInfoDetail[i].MaterielDetailedid; |
| | |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | //ç´æ¥åºåº |
| | | else if(task.TaskType == (int)TaskTypeEnum.OutDirect) |
| | | else if (task.TaskType == (int)TaskTypeEnum.OutDirect) |
| | | { |
| | | //å é¤åºåä¿¡æ¯ |
| | | Dt_StockInfo stockInfo = _StockInfoRepository.QueryFirst(x => x.LocationCode == task.SourceAddress); |
| | |
| | | Dt_Task task = new Dt_Task(); |
| | | //åºåºåé
ç©æ |
| | | Dt_LocationInfo locations = _LocationInfoService.AllotStock(1); |
| | | if (locations == null) |
| | | { |
| | | return content; |
| | | } |
| | | locations.LocationStatus = (int)LocationStatusEnum.Lock; |
| | | |
| | | task.SourceAddress = locations.LocationCode; |
| | |
| | | } |
| | | |
| | | //æ ¹æ®æ°éåç§ç±»ä¸å满桶åºåºä»»å¡ |
| | | public WebResponseContent ArtificialTask(int Num, int Type) |
| | | public WebResponseContent ArtificialTask(int Num, string Types) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | List<Dt_Task> tasks = new List<Dt_Task>(); |
| | | List<Dt_LocationInfo> LocationInfo = new List<Dt_LocationInfo>(); |
| | | List<Dt_StockInfo> StockInfo = new List<Dt_StockInfo>(); |
| | | |
| | | if (Num > 0 && Type > 0 && kk == true) |
| | | if (Num > 0 && !Types.Equals("") && Types != null && kk == true) |
| | | { |
| | | Dt_Outstockinfo outstockinfo = _OutstockinfoRepository.QueryFirst(x => x.Id == 1); |
| | | //满 |
| | | if (outstockinfo.BigOrLittle == 1) |
| | | { |
| | | //è·åå¹¶éå®ç©æ |
| | | StockInfo = _IStockService.PriorityBig(Num, Type); |
| | | StockInfo = _IStockService.PriorityBig(Num, Types); |
| | | if (StockInfo == null || StockInfo.Count <= 0) |
| | | { |
| | | StockInfo = _IStockService.PriorityLittle(Num, Types); |
| | | } |
| | | } |
| | | //æ® |
| | | else |
| | | { |
| | | //è·åå¹¶éå®ç©æ |
| | | StockInfo = _IStockService.PriorityLittle(Num, Type); |
| | | StockInfo = _IStockService.PriorityLittle(Num, Types); |
| | | if (StockInfo == null || StockInfo.Count <= 0) |
| | | { |
| | | StockInfo = _IStockService.PriorityBig(Num, Types); |
| | | } |
| | | } |
| | | |
| | | //åå»ºä»»å¡ |
| | | if (StockInfo != null) |
| | | if (StockInfo != null && StockInfo.Count > 0) |
| | | { |
| | | //è·åå¹¶éå®è´§ä½ |
| | | LocationInfo = _ILocationInfoService.StockLockLocation(StockInfo); |
| | |
| | | } |
| | | else |
| | | { |
| | | return WebResponseContent.Instance.Error($"ç©æä¸è¶³"); |
| | | return content.Error("ç©æä¸è¶³"); |
| | | } |
| | | |
| | | //å¼å§æ°æ®åºäºå¡ |
| | |
| | | } |
| | | else |
| | | { |
| | | LogLock.OutLogAOP("æ¥å£æ¥å¿", new string[] { "ä¸åæ°éãç§ç±»æä¿¡å·å¼å¸¸"}); |
| | | LogLock.OutLogAOP("æ¥å£æ¥å¿", new string[] { "ä¸åæ°éãç§ç±»æä¿¡å·å¼å¸¸" }); |
| | | return content.Error("ä¸åæ°éãç§ç±»æä¿¡å·å¼å¸¸"); |
| | | } |
| | | return content; |
| | | } |
| | |
| | | //WCS满桶åºåºä¿¡å· |
| | | public WebResponseContent WCSSignal(int k) |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | WebResponseContent content = new WebResponseContent(); |
| | | //å¯ä»¥åº |
| | | if (k == 1) { |
| | | if (k == 1) |
| | | { |
| | | kk = true; |
| | | } |
| | | //ä¸å¯ä»¥åº |
| | |
| | | |
| | | return content; |
| | | } |
| | | |
| | | //æ§è¡è®¢å |
| | | public string ExecuteOrder(int k) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_OutboundOrder OutboundOrder = _OutboundOrderRepository.QueryFirst(x => x.Id == k); |
| | | //ä¸åä»»å¡ |
| | | content = ArtificialTask(OutboundOrder.num, OutboundOrder.MaterielName); |
| | | if (content.Message == null || content.Message.Equals("")) |
| | | { |
| | | OutboundOrder.BoundOrderStatue = (int)OutboundOrderEnum.Execute; |
| | | _OutboundOrderRepository.UpdateData(OutboundOrder); |
| | | } |
| | | return content.Message; |
| | | } |
| | | } |
| | | } |