11
yanjinhui
2026-03-02 ef4e456bb392c7260f2d8af886d7786f471b6ae0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common.LocationEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Common;
using WIDESEAWCS_Core;
using WIDESEAWCS_DTO.WMS;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_Core.Helper;
 
namespace WIDESEAWCS_TaskInfoService
{
    public partial class TaskService
    {
        #region RGV任务创建
        /// <summary>
        /// 创建四向车入库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public WebResponseContent CreateRGVNewInTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                //List<Dt_RGVLocationInfo>? rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => x.WarehouseId.ToString() == taskDTO.toAreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt());
                //if (rGVLocationInfos.Count < 1) throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                //var rGVLocationInfo = rGVLocationInfos.OrderBy(x => x.Depth).First();
                //var rGVLocationInfo = _rGVLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!");
                Dt_StationManger stationManger = _stationMangerService.GetInStationInfo(taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点位置【{taskDTO.fromLocationCode}】站台信息!");
                //if (stationManger.IsOccupied == 1) throw new Exception($"起点位置【{taskDTO.fromLocationCode}】站台被占用,请释放!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = taskDTO.toAreaCode,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = stationManger.Remark,//找入库站台对应的外形检测编号
                    TargetAddress = "",
                    //Remark = taskDTO.toAreaCode,
                    Creater = "WMS",
                };
                //rGVLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
                //Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                //_rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
                //Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// 创建四向车出库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public WebResponseContent CreateRGVNewOutTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                //Dt_Task dt_Task = BaseDal.QueryFirst(x => x.PalletCode == taskDTO.containerCode);
                //if (dt_Task != null) throw new Exception($"托盘号【{taskDTO.containerCode}】已存在任务");
                Dt_RGVLocationInfo rGVLocationInfo = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                if (rGVLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                Dt_Task dt_Task = new()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = rGVLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = taskDTO.toLocationCode,
                    TargetAddress = taskDTO.toLocationCode,
                    Creater = "WMS",
                };
                rGVLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                _rGVLocationInfoService.Repository.UpdateData(rGVLocationInfo);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        #endregion
    }
}