dengjunjie
2025-04-19 9e579eda4601ed7b492b9d19a24e8146f6ebdf8d
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs
@@ -39,7 +39,7 @@
            {
                ISugarQueryable<Dt_StockInfo> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfo>();
                ISugarQueryable<Dt_StockInfoDetail> sugarQueryable2 = _dbBase.Queryable<Dt_StockInfoDetail>();
                List<StockViewDTO1> list = sugarQueryable1.InnerJoin(sugarQueryable2, (a, b) => a.Id == b.StockId && b.MaterielName.Contains("空托") && a.StockStatus == StockStatusEmun.已入库.ObjToInt()).Select((a, b) => new StockViewDTO1
                List<StockViewDTO1> list = sugarQueryable1.InnerJoin(sugarQueryable2, (a, b) => a.Id == b.StockId && b.MaterielName.Contains("空托盘") && a.StockStatus == StockStatusEmun.已入库.ObjToInt()).Select((a, b) => new StockViewDTO1
                {
                    LocationCode = a.LocationCode,
                    PalletCode = a.PalletCode,
@@ -48,24 +48,32 @@
                    InDate = a.InDate,
                    StockId = a.Id
                }).ToList();
                StockViewDTO1? stockViewDTO = list.OrderByDescending(x => x.InDate).FirstOrDefault();
                StockViewDTO1? stockViewDTO = list.OrderBy(x => x.InDate).FirstOrDefault();
                if (stockViewDTO == null) throw new Exception("未找到可出库空托");
                #region åˆ¤æ–­æ˜¯å¦ä¸ºç¬¬ä¸€æŽ’货位
                var strings = stockViewDTO.LocationCode.ToLower().Split('-');
                var Row = Convert.ToInt32(strings[0]);
                if (Row == 1)
                {
                    var locationcode = 2.ToString("000") + "-" + strings[1] + "-" + strings[2];
                    var stockViewDTO1 = list.Where(x => x.LocationCode == locationcode).OrderBy(x => x.InDate).FirstOrDefault();
                    if (stockViewDTO1 != null) stockViewDTO = stockViewDTO1;
                }
                #endregion
                stockViewDTO = list.Where(x => x.LocationCode == stockViewDTO.LocationCode).OrderByDescending(x => x.InDate).FirstOrDefault();
                Dt_LocationInfo locationInfo = _dbBase.Queryable<Dt_LocationInfo>().Where(x => x.LocationCode == stockViewDTO.LocationCode).First();
                if (locationInfo == null) throw new Exception($"未找到货位【{stockViewDTO.LocationCode}】信息");
                Dt_StockInfo stockInfo = sugarQueryable1.Where(x => x.Id == stockViewDTO.StockId).Includes(x => x.Details).First();
                Dt_StockInfo stockInfo = _stockService.Repository.QueryFirst(a => a.Id == stockViewDTO.StockId);
                if (stockInfo == null) throw new Exception($"未找到空托库存信息");
                stockInfo.StockStatus = StockStatusEmun.出库中.ObjToInt();
                stockInfo.Details.ForEach(x =>
                {
                    x.Status = StockStatusEmun.出库中.ObjToInt();
                });
                locationInfo.CurrentQty--;
                Dt_Task _Task = new Dt_Task()
                {
                    CurrentAddress = locationInfo.LocationCode,
                    NextAddress = "SC01",
                    SourceAddress = locationInfo.LocationCode,
                    TargetAddress = "SC01",
                    SourceIsPickPlace = locationInfo.Row == 1 ? false : locationInfo.CurrentQty == locationInfo.MaxQty,
                    TargetIsPickPlace = false,
                    TargetAddress = "1008",
                    CreateDate = DateTime.Now,
                    Creater = "System",
                    PalletCode = stockViewDTO.PalletCode,
@@ -76,11 +84,11 @@
                    TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(),
                    Dispatchertime = DateTime.Now,
                };
                List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(_Task);
                locationInfo.CurrentQty--;
                List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task>() { _Task });
                Db.Ado.BeginTran();
                _dbBase.Updateable(locationInfo);
                _stockService.UpdateData(stockInfo);
                _stockDetailService.UpdateData(stockInfo.Details);
                _basicRepository.LocationInfoRepository.UpdateData(locationInfo);
                _stockService.Repository.UpdateData(stockInfo);
                _taskRepository.AddData(_Task);
                var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>());
                if (ResultData.Result == null) throw new Exception($"向WCS下发空托出库任务超时");