duyongjia
2024-12-23 430404d69be9b5d420ad12b9ac087508f1fa2aca
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -353,7 +353,7 @@
                            SourceAddress = location.LocationCode,
                            TargetAddress = locationInfos.LocationCode,
                            TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(),
                            TaskType = TaskTypeEnum.Relocation.ObjToInt(),
                            //TaskType = TaskTypeEnum.Relocation.ObjToInt(),
                            Depth= location.Depth,
                            TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                        };
@@ -444,6 +444,10 @@
                {
                    return WebResponseContent.Instance.Error("鏈壘鍒扮┖鎵樼洏搴撳瓨");
                }
                if (BaseDal.QueryFirst(x => (x.TargetAddress == endStation) && x.TaskStatus == OutTaskStatusEnum.OutNew.ObjToInt()) != null)
                {
                    return WebResponseContent.Instance.Error("褰撳墠鍑哄簱绔欏彴宸茬粡鏈変竴鍙版柊鐨勫嚭搴撲换鍔★紒");
                }
                Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode && x.RoadwayNo == roadwayNo);
                if (locationInfo == null)
                {
@@ -467,53 +471,64 @@
                    TaskStatus = OutTaskStatusEnum.OutNew.ObjToInt(),
                    TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(),
                    Depth = locationInfo.Depth,
                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Creater ="System"
                };
                int beforeStatus = locationInfo.LocationStatus;
                _unitOfWorkManage.BeginTran();
                BaseDal.AddData(task);
                stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
                locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                tasks.Add(task);
                (List<Dt_Task>?, List<Dt_Task>?) result = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
                if (result.Item1 != null && result.Item1.Count > 0)
                {
                    for (int i = 0; i < result.Item1.Count; i++)
                    {
                        result.Item1[i].Grade = 1;
                    }
                    AddData(result.Item1);
                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item1, "鍏ュ簱浠诲姟涓嬪彂");
                    if (!response.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return  WebResponseContent.Instance.Error($"{response.Message}");
                    }
                }
                if (result.Item2 != null && result.Item2.Count > 0)
                {
                    for (int i = 0; i < result.Item2.Count; i++)
                    {
                        Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == result.Item2[i].SourceAddress && x.RoadwayNo == result.Item2[i].Roadway);
                        if (location.Depth == 2)
                        {
                            _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                        }
                        result.Item2[i].Grade = 1;
                    }
                    AddData(result.Item2);
                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item2, "鍑哄簱浠诲姟涓嬪彂");
                    if (!response.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return  WebResponseContent.Instance.Error($"{response.Message}");
                    }
                }
                //(List<Dt_Task>?, List<Dt_Task>?) result = RelocationTasks(tasks.OrderBy(x => x.Depth).ToList());
                //if (result.Item1 != null && result.Item1.Count > 0)
                //{
                //    for (int i = 0; i < result.Item1.Count; i++)
                //    {
                //        result.Item1[i].Grade = 1;
                //    }
                //    AddData(result.Item1);
                //    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item1, "鍏ュ簱浠诲姟涓嬪彂");
                //    if (!response.Status)
                //    {
                //        _unitOfWorkManage.RollbackTran();
                //        return  WebResponseContent.Instance.Error($"{response.Message}");
                //    }
                //}
                //if (result.Item2 != null && result.Item2.Count > 0)
                //{
                //    for (int i = 0; i < result.Item2.Count; i++)
                //    {
                //        Dt_LocationInfo location = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == result.Item2[i].SourceAddress && x.RoadwayNo == result.Item2[i].Roadway);
                //        if (location.Depth == 2)
                //        {
                //            _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                //        }
                //        result.Item2[i].Grade = 1;
                //    }
                //    AddData(result.Item2);
                //    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item2, "鍑哄簱浠诲姟涓嬪彂");
                //    if (!response.Status)
                //    {
                //        _unitOfWorkManage.RollbackTran();
                //        return  WebResponseContent.Instance.Error($"{response.Message}");
                //    }
                //}
                _stockService.StockInfoService.UpdateData(stockInfo);
                _basicService.LocationInfoService.UpdateData(locationInfo);
                _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Outbound.ObjToInt(), "", task.TaskNum);
                var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", tasks, "鍑哄簱浠诲姟涓嬪彂");
                if (!response.Status)
                {
                    _unitOfWorkManage.RollbackTran();
                    return WebResponseContent.Instance.Error($"{response.Message}");
                }
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK();
            }