| | |
| | | InDate = a.InDate, |
| | | StockId = a.Id |
| | | }).ToList(); |
| | | 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) |
| | | if (list.Count < 1) throw new Exception("æªæ¾å°ç©ºæåºå"); |
| | | var LocationCodes = list.Select(x => x.LocationCode).Distinct().ToList(); |
| | | StockViewDTO1? stockViewDTO = null; |
| | | foreach (var item in LocationCodes) |
| | | { |
| | | 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; |
| | | if (_taskRepository.QueryFirst(x => x.SourceAddress == item && x.TaskType != TaskTypeEnum.PalletOutbound.ObjToInt()) == null) |
| | | { |
| | | stockViewDTO = list.Where(x => x.LocationCode == item).OrderByDescending(x => x.InDate).FirstOrDefault(); |
| | | break; |
| | | } |
| | | } |
| | | 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(); |
| | | //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 = _stockService.Repository.QueryFirst(a => a.Id == stockViewDTO.StockId); |
| | | if (stockInfo == null) throw new Exception($"æªæ¾å°ç©ºæåºåä¿¡æ¯"); |
| | | Dt_StockInfoDetail _StockInfoDetail = _stockDetailService.Repository.QueryFirst(a => a.StockId == stockInfo.Id); |
| | | if (_StockInfoDetail == null) throw new Exception($"æªæ¾å°ç©ºæåºå详æ
"); |
| | | stockInfo.StockStatus = StockStatusEmun.åºåºä¸.ObjToInt(); |
| | | _StockInfoDetail.Status = StockStatusEmun.åºåºä¸.ObjToInt(); |
| | | Dt_Task _Task = new Dt_Task() |
| | | { |
| | | CurrentAddress = locationInfo.LocationCode, |
| | |
| | | TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), |
| | | Dispatchertime = DateTime.Now, |
| | | }; |
| | | locationInfo.CurrentQty--; |
| | | List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(new List<Dt_Task>() { _Task }); |
| | | Db.Ado.BeginTran(); |
| | | _basicRepository.LocationInfoRepository.UpdateData(locationInfo); |
| | | _stockService.Repository.UpdateData(stockInfo); |
| | | _stockDetailService.Repository.UpdateData(_StockInfoDetail); |
| | | _taskRepository.AddData(_Task); |
| | | var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>()); |
| | | if (ResultData.Result == null) throw new Exception($"åWCSä¸å空æåºåºä»»å¡è¶
æ¶"); |