wangxinhui
9 天以前 2aec0a99e559fb11b7046b148e5f357b3208cb66
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
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_Tasks.ConveyorLineJob;
 
namespace WIDESEAWCS_Tasks
{
    public partial class ConveyorLineJob_YL2ndFloor
    {
        /// <summary>
        /// 处理新任务
        /// </summary>
        private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManger stationManger)
        {
            switch (stationManger.StationType)
            {
                case 1:
                    RequestWmsRoadwayNo(conveyorLine, command, stationManger);
                    break;
                case 21:
                    ConveyorLineInFinish(conveyorLine, command, stationManger);
                    break;
            }
 
        }
 
        /// <summary>
        /// 请求WMS任务
        /// </summary>
        private void RequestWmsRoadwayNo(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command,  Dt_StationManger stationManager)
        {
            try
            {
                if (command.Barcode.IsNullOrEmpty()) return;
 
                var AGVFinishTask = _taskService.QueryBarCodeAGVFinishTask(command.TaskNum, stationManager.StationCode);
                if (AGVFinishTask == null)
                {
                    var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.Barcode}】任务号:【{command.TaskNum}】设备编码:【{stationManager.StationCode}】【未找到任务】";
                    ConsoleHelper.WriteSuccessLine(log);
 
                    WriteInfo(conveyorLine.DeviceName, log);
                    return;
                }
                WebResponseContent content = _taskService.UpdateTaskStatusToNext(AGVFinishTask, stationManager);
 
                if (content.Status)
                {
                    var ExecuteTask = _taskService.QueryLineExecuteTaskByBarcode(command.TaskNum, stationManager.StationCode);
                    if (ExecuteTask != null)
                    {
                        ConveyorLineTaskCommandWrite taskCommand = _mapper.Map<ConveyorLineTaskCommandWrite>(ExecuteTask);
                        bool sendFlag = SendCommand(taskCommand, conveyorLine, stationManager.StationCode);
                        if (sendFlag)
                        {
                            //_taskService.UpdateTask(task, TaskStatusEnum.Line_Executing);
                            _taskService.UpdateTaskStatusToNext(ExecuteTask, stationManager);
                        }
                    }
                }
                else
                {
                    WriteInfo(conveyorLine.DeviceName, content.Message);
                }
            }
            catch (Exception ex)
            {
                WriteInfo(conveyorLine.DeviceName, $"【{conveyorLine.DeviceName}】托盘号:【{command.Barcode}】请求点位:【{stationManager.StationCode}】异常信息【{ex.Message}】异常行【{ex.StackTrace}】");
            }
        }
    }
}