1
Huangxiaoqiang-03
2024-11-04 fe941b73b9496f6cfab1a8957f319f74ea09fe1d
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -12,6 +12,7 @@
using System.Reflection.Metadata;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SkiaSharp;
using System.Collections;
namespace WIDESEA_TaskInfoService
{
@@ -156,14 +157,31 @@
                _unitOfWorkManage.BeginTran();
                //鍒ゆ柇绉诲簱
                (List<Dt_Task>?, List<Dt_Task>?) result=RelocationTasks(tasks.OrderBy(x=>x.Depth).ToList());
                if(result.Item1 != null)
                if (result.Item1 != null && result.Item1.Count >0)
                {
                    AddData(result.Item1);
                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item1, "鍏ュ簱浠诲姟涓嬪彂");
                    if (!response.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return content = WebResponseContent.Instance.Error($"{response.Message}");
                    }
                }
                for (int i = 0; i < result.Item2.Count; i++)
                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);
                        _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                    }
                    AddData(result.Item2);
                    var response = HttpHelper.Post<WebResponseContent>(url + "ReceiveTask/", result.Item2, "鍏ュ簱浠诲姟涓嬪彂");
                    if (!response.Status)
                    {
                        _unitOfWorkManage.RollbackTran();
                        return content = WebResponseContent.Instance.Error($"{response.Message}");
                    }
                }
                
@@ -215,8 +233,8 @@
                        int befoStatus=location.LocationStatus.ObjToInt();
                        if (location != null)
                        {
                            Dt_LocationInfo result = isDepth(location);
                            if (result != null && result.LocationStatus == LocationStatusEnum.Lock.ObjToInt() && result.LocationStatus != LocationStatusEnum.PalletLock.ObjToInt() && result.LocationStatus != LocationStatusEnum.Free.ObjToInt())
                            Dt_LocationInfo result = _basicService.LocationInfoService.isDepth(location);
                            if (result != null && result.LocationStatus != LocationStatusEnum.Lock.ObjToInt() && result.LocationStatus != LocationStatusEnum.PalletLock.ObjToInt() && result.LocationStatus != LocationStatusEnum.Free.ObjToInt())
                            {
                                int sum = 0;
                                for (int j = 0; j < task.Count; j++)
@@ -230,8 +248,8 @@
                                {
                                    Dt_Task relocariontask = RelocationTask(result);
                                    task[i].Grade=1;
                                    tasks.Add(task[i]);
                                    relocationList.Add(relocariontask);
                                    relocationList.Add(task[i]);
                                }
                                else
                                {
@@ -270,7 +288,7 @@
                            break;
                        }
                    }
                    return (tasks, relocationList);
                    return (relocationList,tasks);
                }
                else
                {
@@ -309,8 +327,12 @@
                            TargetAddress = locationInfos.LocationCode,
                            TaskStatus = InTaskStatusEnum.RelocationNew.ObjToInt(),
                            TaskType = TaskTypeEnum.Relocation.ObjToInt(),
                            Depth= location.Depth,
                            TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                        };
                        _basicService.LocationInfoService.RelocationLock(location, locationInfos, tasks.TaskNum);
                        stockInfo.StockStatus= StockStatusEmun.绉诲簱閿佸畾.ObjToInt();
                        _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                        return tasks;
                    }
                    else
@@ -418,20 +440,46 @@
                    TaskType = TaskTypeEnum.PalletOutbound.ObjToInt(),
                    Depth = locationInfo.Depth,
                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum))
                };
                int beforeStatus = locationInfo.LocationStatus;
                _unitOfWorkManage.BeginTran();
                stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
                locationInfo.LocationStatus = LocationStatusEnum.Lock.ObjToInt();
                BaseDal.AddData(task);
                List<Dt_Task> tasks=new List<Dt_Task>();
                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)
                {
                    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);
                        _basicService.LocationInfoService.UpdateLocationLock(location, result.Item2[i].TaskNum, StockChangeType.Outbound.ObjToInt(), false);
                    }
                    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);
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK();
            }
@@ -439,33 +487,6 @@
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        public Dt_LocationInfo 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)
                    {
                        return dt_LocationInfo;
                    }
                }
                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;
                    }
                }
            }
            return null;
        }
    }
}