| | |
| | | using WIDESEA_DTO.Stock; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Core.Helper; |
| | | using Microsoft.AspNetCore.Http; |
| | | using System.Reflection.Metadata; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; |
| | | |
| | | namespace WIDESEA_TaskInfoService |
| | | { |
| | |
| | | TargetAddress = roadwayInfo.OutStationCode, |
| | | TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Outbound.ObjToInt(), |
| | | Depth = locationInfo.Depth, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | }; |
| | | tasks.Add(task); |
| | |
| | | { |
| | | try |
| | | { |
| | | WebResponseContent content=new WebResponseContent(); |
| | | _unitOfWorkManage.BeginTran(); |
| | | //å¤æç§»åº |
| | | /*List<Dt_Task> RelocationTasks = */ |
| | | RelocationTask(tasks); |
| | | //BaseDal.AddData(RelocationTasks); |
| | | |
| | | BaseDal.AddData(tasks); |
| | | content=RelocationTasks(tasks.OrderBy(x=>x.Depth).ToList()); |
| | | if (content.Status) |
| | | { |
| | | _unitOfWorkManage.CommitTran(); |
| | | } |
| | | else |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content; |
| | | } |
| | | //BaseDal.AddData(tasks); |
| | | if (stockInfos != null && outboundOrderDetails != null && outStockLockInfos != null && locationInfos != null) |
| | | { |
| | | WebResponseContent content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | content = _outboundService.OutboundOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks); |
| | | |
| | | if (content.Status) |
| | | { |
| | |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// ç§»åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RelocationTask(List<Dt_Task> task) |
| | | public WebResponseContent RelocationTasks(List<Dt_Task> task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | _unitOfWorkManage.BeginTran(); |
| | | for (int i = 0; i < task.Count; i++) |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task[i].SourceAddress && x.RoadwayNo == task[i].Roadway); |
| | | if (locationInfo != null) |
| | | Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task[i].SourceAddress && x.RoadwayNo == task[i].Roadway); |
| | | if (location != null) |
| | | { |
| | | Dt_LocationInfo location = _basicService.LocationInfoService.isDepth(locationInfo); |
| | | if (location != null) |
| | | //(Dt_LocationInfo?, int?) result = _basicService.LocationInfoService.isDepth(location); |
| | | (Dt_LocationInfo?, int?) result = isDepth(location); |
| | | if (result.Item1 != null &&result.Item2 != LocationStatusEnum.Lock.ObjToInt() && result.Item2 != LocationStatusEnum.PalletLock.ObjToInt() && result.Item2 != LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == location.LocationCode); |
| | | if (stockInfo != null && location.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | int sum = 0; |
| | | for (int j = 0; j < task.Count; j++) |
| | | { |
| | | Dt_LocationInfo? locationInfos = _basicService.LocationInfoService.AssignLocation(location.RoadwayNo); |
| | | if(locationInfos != null) |
| | | if (result.Item1.LocationCode == task[j].SourceAddress) |
| | | { |
| | | Dt_Task tasks = new() |
| | | { |
| | | CurrentAddress = location.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = locationInfos.LocationCode, |
| | | Roadway = location.RoadwayNo, |
| | | SourceAddress = location.LocationCode, |
| | | TargetAddress = locationInfos.LocationCode, |
| | | TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Relocation.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | }; |
| | | BaseDal.AddData(tasks); |
| | | stockInfo.StockStatus = StockStatusEmun.ç§»åºéå®.ObjToInt(); |
| | | _stockService.StockInfoService.UpdateData(stockInfo); |
| | | _basicService.LocationInfoService.RelocationLock(location, locationInfos,tasks.TaskNum); |
| | | sum++; |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("æªæ¾å°å¯åé
è´§ä½"); |
| | | } |
| | | } |
| | | if (sum == 0) |
| | | { |
| | | return content = RelocationTask(task[i]); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("æªæ¾å°åºåä¿¡æ¯"); |
| | | BaseDal.AddData(task[i]); |
| | | _basicService.LocationInfoService.UpdateLocationLock(location, task[i].TaskNum, StockChangeType.Outbound.ObjToInt(), true); |
| | | } |
| | | } |
| | | else if (result.Item1 == null && result.Item2 == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else if (result.Item1 != null && result.Item2 == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | _basicService.LocationInfoService.UpdateLocationLock(location, task[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else if (result.Item1 != null && (result.Item2 == LocationStatusEnum.Lock.ObjToInt() || result.Item2 == LocationStatusEnum.PalletLock.ObjToInt())) |
| | | { |
| | | Dt_Task TaskInfo = BaseDal.QueryFirst(x => x.SourceAddress == result.Item1.LocationCode); |
| | | if (TaskInfo == null) |
| | | { |
| | | return content = WebResponseContent.Instance.Error("è´§ä½è¢«éå®ä¸å¯åºåº"); |
| | | } |
| | | else |
| | | { |
| | | BaseDal.AddData(task[i]); |
| | | location.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(location); |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("ä»»å¡ä¿¡æ¯å¼å¸¸"); |
| | | return content = WebResponseContent.Instance.OK("ä»»å¡å¼å¸¸"); |
| | | } |
| | | |
| | | } |
| | | _unitOfWorkManage.CommitTran(); |
| | | return content; |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | return content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// ç§»åºä»»å¡ |
| | | /// </summary> |
| | | /// <param name="task"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent RelocationTask(Dt_Task task) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway); |
| | | if (locationInfo != null) |
| | | { |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | //(Dt_LocationInfo?,int?) Result = _basicService.LocationInfoService.isDepth(locationInfo); |
| | | (Dt_LocationInfo?,int?) Result = isDepth(locationInfo); |
| | | if (Result.Item1 != null&& Result.Item2== LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == Result.Item1.LocationCode); |
| | | Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId==stockInfo.Id); |
| | | if (stockInfo != null&& stockInfoDetail != null) |
| | | { |
| | | (Dt_Task ?, Dt_LocationInfo ?) result= AddRelocationTask(Result.Item1, stockInfo, task); |
| | | if (result.Item1!=null&&result.Item2!=null) |
| | | { |
| | | _basicService.LocationInfoService.RelocationLock(Result.Item1, result.Item2, result.Item1.TaskNum); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Relocation.ObjToInt(), "", task.TaskNum); |
| | | return content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("ç§»åºä»»å¡çæå¤±è´¥"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("æªæ¾å°åºåä¿¡æ¯"); |
| | | } |
| | | } |
| | | else if(Result.Item1 != null && Result.Item2 == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == Result.Item1.LocationCode); |
| | | if (stockInfo != null) |
| | | { |
| | | (Dt_Task?, Dt_LocationInfo?) result = AddRelocationTask(Result.Item1, stockInfo, task); |
| | | if (result.Item1 != null && result.Item2 != null) |
| | | { |
| | | _basicService.LocationInfoService.RelocationLock(Result.Item1, result.Item2, result.Item1.TaskNum); |
| | | locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt(); |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Relocation.ObjToInt(), "", task.TaskNum); |
| | | return content = WebResponseContent.Instance.OK(); |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("ç§»åºä»»å¡çæå¤±è´¥"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("æªæ¾å°åºåä¿¡æ¯"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("å¼å¸¸"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return content = WebResponseContent.Instance.Error("ä»»å¡ä¿¡æ¯å¼å¸¸"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | |
| | | return content; |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | public (Dt_Task?,Dt_LocationInfo?) AddRelocationTask(Dt_LocationInfo location,Dt_StockInfo stockInfo,Dt_Task task) |
| | | { |
| | | Dt_LocationInfo? locationInfos = _basicService.LocationInfoService.AssignLocation(location.RoadwayNo); |
| | | if (locationInfos != null) |
| | | { |
| | | Dt_Task tasks = new() |
| | | { |
| | | CurrentAddress = location.LocationCode, |
| | | Grade = 0, |
| | | PalletCode = stockInfo.PalletCode, |
| | | NextAddress = locationInfos.LocationCode, |
| | | Roadway = location.RoadwayNo, |
| | | SourceAddress = location.LocationCode, |
| | | TargetAddress = locationInfos.LocationCode, |
| | | TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.Relocation.ObjToInt(), |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | }; |
| | | BaseDal.AddData(tasks); |
| | | BaseDal.AddData(task); |
| | | stockInfo.StockStatus = StockStatusEmun.ç§»åºéå®.ObjToInt(); |
| | | _stockService.StockInfoService.UpdateData(stockInfo); |
| | | } |
| | | return (task, locationInfos); |
| | | } |
| | | /// <summary> |
| | | /// çæåºåºä»»å¡ |
| | | /// </summary> |
| | |
| | | List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>(); |
| | | foreach (int key in keys) |
| | | { |
| | | |
| | | (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(key, stockSelectViews); |
| | | if (result.Item2 != null && result.Item2.Count > 0) |
| | | { |
| | |
| | | { |
| | | tasks.AddRange(result.Item1); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | WebResponseContent content = GenerateOutboundTaskDataUpdate(tasks, stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos); |
| | |
| | | TargetAddress = endStation, |
| | | TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(), |
| | | TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(), |
| | | Depth = locationInfo.Depth, |
| | | TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)) |
| | | |
| | | }; |
| | | int beforeStatus = locationInfo.LocationStatus; |
| | | _unitOfWorkManage.BeginTran(); |
| | |
| | | BaseDal.AddData(task); |
| | | _stockService.StockInfoService.UpdateData(stockInfo); |
| | | |
| | | _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum); |
| | | _basicService.LocationInfoService.UpdateData(locationInfo); |
| | | |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Relocation.ObjToInt(), "", task.TaskNum); |
| | | _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); |
| | | _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), "", task.TaskNum); |
| | | |
| | | _unitOfWorkManage.CommitTran(); |
| | | return WebResponseContent.Instance.OK(); |
| | |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public (Dt_LocationInfo?, int?) isDepth(Dt_LocationInfo locationInfo) |
| | | { |
| | | if (locationInfo.Depth == 2) |
| | | { |
| | | if (locationInfo.Row == 1 || locationInfo.Row == 5) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); |
| | | |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); |
| | | } |
| | | } |
| | | else if (locationInfo.Row == 4 || locationInfo.Row == 8) |
| | | { |
| | | Dt_LocationInfo dt_LocationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.Row == locationInfo.Row + 1 && x.Layer == locationInfo.Layer && x.Column == locationInfo.Column && x.RoadwayNo == locationInfo.RoadwayNo); |
| | | |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.InStock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.InStock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Free.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Lock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.PalletLock.ObjToInt()); |
| | | } |
| | | if (dt_LocationInfo != null && dt_LocationInfo.LocationStatus == LocationStatusEnum.Pallet.ObjToInt()) |
| | | { |
| | | return (dt_LocationInfo, LocationStatusEnum.Pallet.ObjToInt()); |
| | | } |
| | | } |
| | | } |
| | | return (null, LocationStatusEnum.Free.ObjToInt()); |
| | | } |
| | | } |
| | | } |