dengjunjie
2026-03-13 1cf0b3dd6b2587934a8a34ddd1b3a5a851e9c375
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
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 海康AGV任务创建
        /// <summary>
        /// 创建海康AGV入库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public WebResponseContent CreateHKNewInTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                //获取货位信息
                Dt_HKLocationInfo? hKLocationInfo = _hKLocationInfoService.GetFreeLocationInfo(taskDTO.toAreaCode) ?? throw new Exception($"未找到终点库区【{taskDTO.toAreaCode}】可用空货位!"); ;
                Dt_Task dt_Task = new Dt_Task()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = hKLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = hKLocationInfo.LocationCode,
                    TargetAddress = hKLocationInfo.LocationCode,
                    Creater = "WMS",
                };
                hKLocationInfo.LocationStatus = LocationStatusEnum.InLock.ObjToInt();
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                _hKLocationInfoService.Repository.UpdateData(hKLocationInfo);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 创建海康AGV出库任务
        /// </summary>
        /// <param name="taskDTO"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public WebResponseContent CreateHKNewOutTask(TaskDTO taskDTO, int taskType)
        {
            try
            {
                Dt_HKLocationInfo? hKLocationInfo = _hKLocationInfoService.Repository.QueryFirst(x => x.LocationCode == taskDTO.fromLocationCode) ?? throw new Exception($"未找到起点库位【{taskDTO.fromLocationCode}】!");
                if (hKLocationInfo.LocationStatus != LocationStatusEnum.InStock.ObjToInt()) throw new Exception($"起点库位【{taskDTO.fromLocationCode}】当前库位状态不可出库!");
                Dt_Task dt_Task = new Dt_Task()
                {
                    TaskNum = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    WMSTaskNum = taskDTO.taskCode,
                    //WMSId = GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                    Grade = taskDTO.taskPriority,
                    PalletCode = taskDTO.containerCode,
                    Roadway = hKLocationInfo.RoadwayNo,
                    TaskState = TaskStatusEnum.New.ObjToInt(),
                    TaskType = taskType,
                    SourceAddress = taskDTO.fromLocationCode,
                    CurrentAddress = taskDTO.fromLocationCode,
                    NextAddress = taskDTO.toLocationCode,
                    TargetAddress = taskDTO.toLocationCode,
                    Creater = "WMS",
                };
                hKLocationInfo.LocationStatus = LocationStatusEnum.OutLock.ObjToInt();
                Db.Ado.BeginTran();
                BaseDal.AddData(dt_Task);
                _hKLocationInfoService.Repository.UpdateData(hKLocationInfo);
                Db.Ado.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                Db.Ado.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        #endregion
    }
}