dengjunjie
2025-06-17 4f39dcc195f28fa275fc2d065fbf1bf6a46c21b7
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -98,28 +98,41 @@
                    return WebResponseContent.Instance.Error("未找到任务信息");
                }
                _unitOfWorkManage.BeginTran();
                MethodInfo? methodInfo = GetType().GetMethod(((TaskTypeEnum)task.TaskType) + "TaskCompleted");
                if (methodInfo != null)
                #region MyRegion
                switch ((TaskTypeEnum)task.TaskType)
                {
                    WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { task });
                    if (responseContent != null)
                    case TaskTypeEnum.Inbound:
                        content = InboundTaskCompleted(task);
                        break;
                    case TaskTypeEnum.Outbound:
                        content = OutboundTaskCompleted(task);
                        break;
                    case TaskTypeEnum.PalletInbound:
                        content = PalletInboundTaskCompleted(task);
                        break;
                    case TaskTypeEnum.PalletOutbound:
                        content = PalletOutboundTaskCompleted(task);
                        break;
                    case TaskTypeEnum.Relocation:
                        content = RelocationTaskCompleted(task);
                        break;
                    case TaskTypeEnum.AGVCarry:
                        break;
                    default:
                        return content = WebResponseContent.Instance.Error("未找到任务类型对应业务处理逻辑");
                }
                if (content.Status)
                    {
                        if (App.User.UserId > 0)
                        {
                            var response = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "任务完成");
                            if (!response.Status)
                            {
                                _unitOfWorkManage.RollbackTran();
                                return WebResponseContent.Instance.Error(response.Message);
                        content = HttpHelper.Post<WebResponseContent>(url + "StackCraneTaskCompleted?taskNum=" + task.TaskNum, "", "任务完成");
                        if (!content.Status) throw new Exception(content.Message);
                            }
                            _unitOfWorkManage.CommitTran();
                            return content = responseContent;
                        }
                        _unitOfWorkManage.CommitTran();
                        return content = responseContent;
                    }
                }
                return content = WebResponseContent.Instance.Error("未找到任务类型对应业务处理逻辑");
                return content;
                #endregion
            }
            catch (Exception ex)
            {
@@ -228,14 +241,37 @@
        {
            try
            {
                _unitOfWorkManage.BeginTran();
                decimal beforeQuantity = 0;
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);
                Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault();
                Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
                CheckCompleted(stockInfo, locationInfo);
                Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(stockInfoDetail.OrderNo);
                if (inboundOrder != null)
                {
                    Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == stockInfoDetail.BatchNo).FirstOrDefault();
                    if (inboundOrderDetail != null)
                    {
                        inboundOrderDetail.OverInQuantity++;
                        inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
                        if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt())
                        {
                            if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt() && x.BatchNo != inboundOrderDetail.BatchNo) == null)
                            {
                                inboundOrder.OrderStatus = InboundStatusEnum.入库完成.ObjToInt();
                                _inboundService.InbounOrderService.Repository.DeleteAndMoveIntoHty(inboundOrder, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成);
                                _inboundService.InboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrder.Details, App.User.UserId == 0 ? OperateType.自动完成 : OperateType.人工完成);
                            }
                        }
                        _inboundService.InboundOrderDetailService.Repository.UpdateData(inboundOrderDetail);
                    }
                    _inboundService.InbounOrderService.Repository.UpdateData(inboundOrder);
                }
                stockInfo.LocationCode = locationInfo.LocationCode;
                stockInfo.StockStatus = StockStatusEmun.已入库.ObjToInt();
@@ -254,12 +290,10 @@
                _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,task.TaskNum);
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
            
@@ -340,7 +374,6 @@
        {
            try
            {
                _unitOfWorkManage.BeginTran();
                decimal beforeQuantity = 0;
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode);
@@ -373,13 +406,11 @@
                _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, task.TaskNum);
                _unitOfWorkManage.CommitTran();
                return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }