From 0bfe24ddf438636aeef8c1e6989d5c8c28b0bb1a Mon Sep 17 00:00:00 2001 From: Huangxiaoqiang-03 <1247017146@qq.com> Date: 星期四, 31 十月 2024 16:56:13 +0800 Subject: [PATCH] 1 --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 520 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 478 insertions(+), 42 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index 4e92639..573566f 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -24,6 +24,7 @@ using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Linq.Expressions; using System.Reflection; using System.Reflection.Metadata; using System.Text; @@ -37,6 +38,7 @@ using WIDESEA_DTO.Stock; using WIDESEA_IBasicRepository; using WIDESEA_IBasicService; +using WIDESEA_IInboundService; using WIDESEA_IOutboundRepository; using WIDESEA_IOutboundService; using WIDESEA_IRecordService; @@ -53,48 +55,169 @@ { private readonly IMapper _mapper; private readonly IUnitOfWorkManage _unitOfWorkManage; + + private readonly IBasicService _basicService; + private readonly IOutboundService _outboundService; + private readonly IInboundService _inboundService; + private readonly IRecordService _recordService; + private readonly IStockService _stockService; + private readonly ITask_HtyService _taskHtyService; private readonly ILocationInfoService _locationInfoService; - private readonly IStockInfoService _stockInfoService; - private readonly ILocationStatusChangeRecordSetvice _locationStatusChangeRecordSetvice; - private readonly IOutboundOrderDetailService _outboundOrderDetailService; - private readonly IRoadwayInfoRepository _roadwayInfoRepository; - private readonly IOutStockLockInfoService _outStockLockInfoService; public ITaskRepository Repository => BaseDal; - public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, ILocationInfoService locationInfoService, IStockInfoRepository stockInfoRepository, ILocationStatusChangeRecordSetvice locationStatusChangeRecordSetvice, IOutboundOrderDetailService outboundOrderDetailService, IRoadwayInfoRepository roadwayInfoRepository, IOutStockLockInfoService outStockLockInfoService, IStockInfoService stockInfoService) : base(BaseDal) + public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService) : base(BaseDal) { _mapper = mapper; - _locationInfoService = locationInfoService; - _stockInfoService = stockInfoService; - _locationStatusChangeRecordSetvice = locationStatusChangeRecordSetvice; - _outboundOrderDetailService = outboundOrderDetailService; - _roadwayInfoRepository = roadwayInfoRepository; _unitOfWorkManage = unitOfWorkManage; - _outStockLockInfoService = outStockLockInfoService; + _basicService = basicService; + _outboundService = outboundService; + _inboundService = inboundService; + _recordService = recordService; + _stockService = stockService; + _taskHtyService = taskHtyService; + _locationInfoService = locationInfoService; } + /// <summary> + /// 浠诲姟瀹屾垚 + /// </summary> + /// <param name="taskNum">浠诲姟鍙�</param> + /// <returns>杩斿洖澶勭悊缁撴灉</returns> + public WebResponseContent TaskCompleted(int taskNum) + { + try + { + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) + { + return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + } + MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); + if (methodInfo != null) + { + WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); + if (responseContent != null) + { + return responseContent; + } + } + return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } + public WebResponseContent TaskCancel(SaveModel saveModel) + { + try + { + int taskNum = int.Parse(saveModel.MainData["taskNum"].ToString()); + Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); + if (task == null) + { + return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); + } + MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCancel"); + if (methodInfo != null) + { + WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); + if (responseContent != null) + { + return responseContent; + } + } + return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔$被鍨嬪搴斾笟鍔″鐞嗛�昏緫"); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } public WebResponseContent InboundTaskCompleted(Dt_Task task) { - Dt_StockInfo stockInfo = _stockInfoService.Repository.GetStockInfo(task.PalletCode); + try + { + _unitOfWorkManage.BeginTran(); + decimal beforeQuantity = 0; - Dt_LocationInfo locationInfo = _locationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); - CheckInboundCompleted(stockInfo, locationInfo); + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); - stockInfo.LocationCode = locationInfo.LocationCode; - stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); - _stockInfoService.Repository.UpdateData(stockInfo); + CheckCompleted(stockInfo, locationInfo); - int beforeStatus = locationInfo.LocationStatus; - locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); - _locationInfoService.Repository.UpdateData(locationInfo); + stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); - BaseDal.DeleteData(task); + beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); - _locationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + int beforeStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); - return WebResponseContent.Instance.OK(); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); + + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound); + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + + } + + /// <summary> + /// 绌烘墭鐩樺叆搴撳畬鎴愬鐞� + /// </summary> + /// <param name="task">浠诲姟瀹炰綋瀵硅薄</param> + /// <returns>杩斿洖澶勭悊缁撴灉</returns> + public WebResponseContent PalletInboundTaskCompleted(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + + Dt_StockInfo stockInfo = new Dt_StockInfo() + { + PalletCode = task.PalletCode, + LocationCode = task.TargetAddress, + StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt() + }; + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + + CheckCompleted(stockInfo, locationInfo); + + + _stockService.StockInfoService.Repository.AddData(stockInfo); + + int beforeStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + + task.TaskStatus = InTaskStatusEnum.InFinish.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } } /// <summary> @@ -103,7 +226,7 @@ /// <param name="stockInfo"></param> /// <param name="locationInfo"></param> /// <returns></returns> - private (bool, string) CheckInboundCompleted(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, bool isCheckStockDetail = true) + private (bool, string) CheckCompleted(Dt_StockInfo stockInfo, Dt_LocationInfo locationInfo, bool isCheckStockDetail = true) { if (stockInfo == null) { @@ -123,29 +246,342 @@ return (true, "鎴愬姛"); } - /// <summary> - /// 浠诲姟瀹屾垚 - /// </summary> - /// <param name="taskNum">浠诲姟鍙�</param> - /// <returns>杩斿洖澶勭悊缁撴灉</returns> - public WebResponseContent TaskCompleted(int taskNum) + public WebResponseContent OutboundTaskCompleted(Dt_Task task) { - Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum); - if (task == null) + try { - return WebResponseContent.Instance.Error("鏈壘鍒颁换鍔′俊鎭�"); - } - MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted"); - if (methodInfo != null) - { - WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task }); - if (responseContent != null) + _unitOfWorkManage.BeginTran(); + decimal beforeQuantity = 0; + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + CheckCompleted(stockInfo, locationInfo); + + stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + int beforeStatus = locationInfo.LocationStatus; + if (task.Depth == 1) { - return responseContent; + if (DepthTask(task)) { } + else + { + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + } } + else + { + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + } + + task.TaskStatus = OutTaskStatusEnum.OutFinish.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + _stockService.StockInfoDetailService.Repository.DeleteAndMoveIntoHty(stockInfo.Details, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) - beforeQuantity, StockChangeType.Outbound); + + _unitOfWorkManage.CommitTran(); + return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); } - return WebResponseContent.Instance.Error(); + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } } + public WebResponseContent PalletOutboundTaskCompleted(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + CheckCompleted(stockInfo, locationInfo); + + int beforeStatus = locationInfo.LocationStatus; + + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + + + task.TaskStatus = OutTaskStatusEnum.OutFinish.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + public WebResponseContent RelocationTaskCompleted(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + + CheckCompleted(stockInfo, locationEnd); + + stockInfo.LocationCode = locationEnd.LocationCode; + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + + _basicService.LocationInfoService.RelocationFree(locationEnd, task.TaskNum); + + task.TaskStatus = InTaskStatusEnum.RelocationFinish.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + public WebResponseContent InboundTaskCancel(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + decimal beforeQuantity = 0; + + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + + CheckCompleted(stockInfo, locationInfo); + + stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + + beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); + + int beforeStatus = locationInfo.LocationStatus; + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false); + + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + task.TaskStatus = InTaskStatusEnum.InCancel.ObjToInt(); + + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + + } + + public WebResponseContent PalletInboundTaskCancel(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + + int beforeStatus = locationInfo.LocationStatus; + + locationInfo.LocationStatus = LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + + task.TaskStatus = InTaskStatusEnum.InCancel.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), "", task.TaskNum); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + + public WebResponseContent OutboundTaskCancel(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + decimal beforeQuantity = 0; + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + CheckCompleted(stockInfo, locationInfo); + + stockInfo.LocationCode = locationInfo.LocationCode; + stockInfo.StockStatus = StockStatusEmun.宸插叆搴�.ObjToInt(); + _stockService.StockInfoService.Repository.UpdateData(stockInfo); + int beforeStatus = locationInfo.LocationStatus; + if (task.Depth == 1) + { + if (!DepthTask(task)) + { + locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + } + } + else + { + locationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + } + + task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + beforeQuantity = stockInfo.Details.Where(x => x.Id != 0).Sum(x => x.StockQuantity); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) - beforeQuantity, StockChangeType.Outbound); + + _unitOfWorkManage.CommitTran(); + return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + public WebResponseContent PalletOutboundTaskCancel(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + CheckCompleted(stockInfo, locationInfo); + + int beforeStatus = locationInfo.LocationStatus; + + locationInfo.LocationStatus = LocationStatusEnum.Pallet.ObjToInt(); + _basicService.LocationInfoService.UpdateLocationFree(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false); + _basicService.LocationInfoService.Repository.UpdateData(locationInfo); + + + task.TaskStatus = OutTaskStatusEnum.OutCancel.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + + public WebResponseContent RelocationTaskCancel(Dt_Task task) + { + try + { + _unitOfWorkManage.BeginTran(); + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + Dt_LocationInfo locationEnd = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); + Dt_LocationInfo locationStart = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); + + locationEnd.LocationStatus= LocationStatusEnum.Free.ObjToInt(); + _basicService.LocationInfoService.RelocationFree(locationStart, task.TaskNum); + _basicService.LocationInfoService.Repository.UpdateData(locationEnd); + + task.TaskStatus = InTaskStatusEnum.RelocationCancel.ObjToInt(); + BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId == 0 ? OperateType.鑷姩瀹屾垚 : OperateType.浜哄伐瀹屾垚); + + _unitOfWorkManage.CommitTran(); + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + return WebResponseContent.Instance.Error(ex.Message); + } + } + public bool DepthTask(Dt_Task task) + { + Dt_LocationInfo location=_locationInfoService.Repository.QueryFirst(x=>x.LocationCode == task.SourceAddress); + if(location != null) + { + if(location.Row%2==0) + { + Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.Row == location.Row + 1 && x.Layer == location.Layer && x.Column == location.Column && x.RoadwayNo == location.RoadwayNo); + Dt_Task tasks=BaseDal.QueryFirst(x=>x.SourceAddress == locations.LocationCode); + return tasks != null ? true : false; + } + else + { + Dt_LocationInfo locations = _locationInfoService.Repository.QueryFirst(x => x.Row == location.Row - 1 && x.Layer == location.Layer && x.Column == location.Column && x.RoadwayNo == location.RoadwayNo); + Dt_Task tasks = BaseDal.QueryFirst(x => x.SourceAddress == locations.LocationCode); + return tasks != null ? true : false; + } + } + return false; + } + + public WebResponseContent GetTaskInfo() + { + WebResponseContent content = new WebResponseContent(); + try + { + Expression<Func<Dt_Task, bool>> expression = x => true; + if (!App.User.IsSuperAdmin) + { + expression = x => x.Creater == App.User.UserName; + } + var task = BaseDal.Db.Queryable<Dt_Task>().OrderByDescending(x => x.CreateDate).Take(10).Select(x => new Dt_Task { TaskNum = x.TaskNum, PalletCode=x.PalletCode, TaskType=x.TaskType,SourceAddress=x.SourceAddress,TargetAddress=x.TargetAddress }).ToList(); + content = WebResponseContent.Instance.OK(data: task); + } + catch (Exception ex) + { + content = WebResponseContent.Instance.Error(ex.Message); + } + return content; + } } } -- Gitblit v1.9.3