|  |  |  | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEA_Common.LocationEnum; | 
|---|
|  |  |  | using WIDESEA_Common.OrderEnum; | 
|---|
|  |  |  | using WIDESEA_Common.StockEnum; | 
|---|
|  |  |  | using WIDESEA_Common.TaskEnum; | 
|---|
|  |  |  | using WIDESEA_Core; | 
|---|
|  |  |  | using WIDESEA_Core.Helper; | 
|---|
|  |  |  | using WIDESEA_DTO; | 
|---|
|  |  |  | using WIDESEA_DTO.MES; | 
|---|
|  |  |  | using WIDESEA_Model.Models; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEA_TaskInfoService | 
|---|
|  |  |  | 
|---|
|  |  |  | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="taskNum">ä»»å¡å·</param> | 
|---|
|  |  |  | /// <param name="roadwayNo">å··éå·</param> | 
|---|
|  |  |  | /// <param name="roadwayNos">å··éå·</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent AssignRoadwayByHeight(List<string> roadwayNos, int taskNum, int heightType = 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (heightType == 0 || heightType > 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"é«åº¦é误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); | 
|---|
|  |  |  | if (task == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥å
¥åºä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (_basicRepository.LocationInfoRepository.QueryFirst(x => x.LocationCode == task.TargetAddress) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: task.TargetAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string roadwayNo = ""; | 
|---|
|  |  |  | if (heightType == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 2) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="roadwayNos"></param> | 
|---|
|  |  |  | /// <param name="palletCode"></param> | 
|---|
|  |  |  | /// <param name="heightType"></param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent AssignRoadwayByHeightAndCode(List<string> roadwayNos, string palletCode, int heightType = 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (heightType == 0 || heightType > 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"é«åº¦é误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (roadwayNos == null || roadwayNos.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"å··éä¸è½ä¸ºç©º"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); | 
|---|
|  |  |  | if (locationInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°å··é对åºè´§ä½"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); | 
|---|
|  |  |  | if (warehouse == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); | 
|---|
|  |  |  | if (palletType == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æçå·è§£ææçç±»åé误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string roadwayNo = ""; | 
|---|
|  |  |  | if (heightType == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 2) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public string AssignRoadwayNo(List<string> roadwayNos, string palletCode, int heightType = 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (heightType == 0 || heightType > 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"é«åº¦é误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (roadwayNos == null || roadwayNos.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"å··éä¸è½ä¸ºç©º"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_LocationInfo locationInfo = _basicRepository.LocationInfoRepository.QueryFirst(x => x.RoadwayNo == roadwayNos[0]); | 
|---|
|  |  |  | if (locationInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°å··é对åºè´§ä½"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == locationInfo.WarehouseId); | 
|---|
|  |  |  | if (warehouse == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æªæ¾å°å··é对åºä»åºä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int palletType = _inboundOrderService.GetPalletType(warehouse, palletCode); | 
|---|
|  |  |  | if (palletType == -1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception($"æçå·è§£ææçç±»åé误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string roadwayNo = ""; | 
|---|
|  |  |  | if (heightType == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer <= 3).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 2) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 4).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (heightType == 3) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == palletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo) && x.Layer == 5).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? ( roadwayNo) : throw new Exception("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | throw new Exception(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="taskNum">ä»»å¡å·</param> | 
|---|
|  |  |  | /// <param name="roadwayNos">å··éå·</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent AssignRoadway(int taskNum, List<string> roadwayNos) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(data: task.TargetAddress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == 0) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == task.PalletType || x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo): WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class LocationCount | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// å
¥åºä»»å¡ç³è¯·åé
è´§ä½ | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="roadwayNos">å··éå·</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | public WebResponseContent SingleAssignRoadway(List<string> roadwayNos) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public string RoadwayNo { get; set; } | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<LocationCount> locationCounts = Db.Queryable<Dt_LocationInfo>().Where(x => (x.LocationType == LocationTypeEnum.Undefined.ObjToInt()) && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && roadwayNos.Contains(x.RoadwayNo)).GroupBy(x => x.RoadwayNo).Select(x => new LocationCount { RoadwayNo = x.RoadwayNo, Count = SqlFunc.AggregateCount(x) }).ToList(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int Count { get; set; } | 
|---|
|  |  |  | string roadwayNo = locationCounts.OrderBy(x => x.Count).FirstOrDefault()?.RoadwayNo ?? ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return !string.IsNullOrEmpty(roadwayNo) ? WebResponseContent.Instance.OK(data: roadwayNo) : WebResponseContent.Instance.Error("æªæ¾å°å¯åé
å··é"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public WebResponseContent HandSubstrateOut(int orderId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == orderId); | 
|---|
|  |  |  | if (mesOutboundOrder == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥è®¢å"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (mesOutboundOrder.OrderStatus != OutOrderStatusEnum.æªå¼å§.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"该订åä¸å¯ååºåº"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_Task> tasks = new List<Dt_Task>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Dt_StockInfo>? stockInfos = null; | 
|---|
|  |  |  | List<Dt_OutStockLockInfo>? outStockLockInfos = null; | 
|---|
|  |  |  | List<Dt_LocationInfo>? locationInfos = null; | 
|---|
|  |  |  | { | 
|---|
|  |  |  | (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder); | 
|---|
|  |  |  | if (result.Item1 != null && result.Item1.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound); | 
|---|
|  |  |  | result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt(); | 
|---|
|  |  |  | result.Item3.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.Status = OutLockStockStatusEnum.åºåºä¸.ObjToInt(); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | stockInfos = result.Item1; | 
|---|
|  |  |  | mesOutboundOrder = result.Item2; | 
|---|
|  |  |  | outStockLockInfos = result.Item3; | 
|---|
|  |  |  | locationInfos = result.Item4; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | throw new Exception("æ åºå"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | tasks.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOut.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.TaskType = TaskTypeEnum.MesHandOutbound.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (mesOutboundOrder.OrderType == MesOutboundOrderTypeEnum.HandSubstrateOutPick.ObjToInt()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.TaskType = TaskTypeEnum.MesHandPickOutbound.ObjToInt(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mesOutboundOrder.OrderStatus = OutOrderStatusEnum.åºåºä¸.ObjToInt(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | _unitOfWorkManage.BeginTran(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int id = BaseDal.AddData(tasks); | 
|---|
|  |  |  | outStockLockInfos.ForEach(x => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | x.OrderNo = mesOutboundOrder.TaskNo; | 
|---|
|  |  |  | x.OrderDetailId = id; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | _outboundService.MesOutboundOrderService.Repository.UpdateData(mesOutboundOrder); | 
|---|
|  |  |  | if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | WebResponseContent content = _outboundService.MesOutboundOrderService.LockOutboundStockDataUpdate(stockInfos, outStockLockInfos, locationInfos, tasks: tasks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!content.Status) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | _unitOfWorkManage.RollbackTran(); | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(content.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | _unitOfWorkManage.CommitTran(); | 
|---|
|  |  |  | PushTasksToWCS(tasks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class LocationCount | 
|---|
|  |  |  | { | 
|---|
|  |  |  | public string RoadwayNo { get; set; } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int Count { get; set; } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|