From fbc6fae6c793220d0b67ac603ce9bbf22837de79 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期四, 19 六月 2025 17:50:47 +0800 Subject: [PATCH] 1 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs | 49 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 35 insertions(+), 14 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs" index 60c1dd3..576f20a 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/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,45 @@ InDate = a.InDate, StockId = a.Id }).ToList(); - StockViewDTO1? stockViewDTO = list.OrderByDescending(x => x.InDate).FirstOrDefault(); - if (stockViewDTO == null) throw new Exception("鏈壘鍒板彲鍑哄簱绌烘墭"); + if (list.Count < 1) throw new Exception("鏈壘鍒扮┖鎵樺簱瀛�"); + var LocationCodes = list.Select(x => x.LocationCode).Distinct().ToList(); + StockViewDTO1? stockViewDTO = null; + foreach (var item in LocationCodes) + { + 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(); 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($"鏈壘鍒扮┖鎵樺簱瀛樹俊鎭�"); + Dt_StockInfoDetail _StockInfoDetail = _stockDetailService.Repository.QueryFirst(a => a.StockId == stockInfo.Id); + if (_StockInfoDetail == null) throw new Exception($"鏈壘鍒扮┖鎵樺簱瀛樿鎯�"); stockInfo.StockStatus = StockStatusEmun.鍑哄簱涓�.ObjToInt(); - stockInfo.Details.ForEach(x => - { - x.Status = StockStatusEmun.鍑哄簱涓�.ObjToInt(); - }); - locationInfo.CurrentQty--; + _StockInfoDetail.Status = StockStatusEmun.鍑哄簱涓�.ObjToInt(); 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 +97,11 @@ TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), Dispatchertime = DateTime.Now, }; - List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(_Task); + 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); + _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($"鍚慦CS涓嬪彂绌烘墭鍑哄簱浠诲姟瓒呮椂"); -- Gitblit v1.9.3