huangxiaoqiang
2025-06-03 975ea3c28b1661b3b6eabee5277cc98d853736d3
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
using HslCommunication;
using MoYu;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
 
namespace WIDESEAWCS_Tasks.ConveyorLineJob.StationHandler
{
    public class ExceptionPortStationHandler : IStationHandler
    {
        private readonly CommonConveyorLineJob _commonConveyorLineJob;
        private readonly ITaskRepository _taskRepository = App.GetService<ITaskRepository>();
        public ExceptionPortStationHandler(CommonConveyorLineJob commonConveyorLineJob)
        {
            _commonConveyorLineJob = commonConveyorLineJob;
        }
        public async Task HandleStationAsync(CommonConveyorLine conveyorLine, Dt_StationManager station, ConveyorLineTaskCommand command, ConveyorLineTaskCommandWrite commandWrite)
        {
            var structs = BitConverter.GetBytes(commandWrite.WriteInteractiveSignal).Reverse().ToArray().ToBoolArray();
            if (structs[0])
            {
                if (_taskRepository.QueryData(x => x.SourceAddress == station.stationChildCode).Count() > 0)
                {
                    return;
                }
                var log = $"【{conveyorLine.DeviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{station.stationChildCode}】【{station.stationRemark}】异常口请求扫码入库";
                await _commonConveyorLineJob.LogAndWarn(conveyorLine.DeviceName, log);
                await _commonConveyorLineJob.HandleNewTaskAsync(conveyorLine, command, station.stationChildCode, 0);
            }
            else
            {
                _commonConveyorLineJob.ConveyorLineSendFinish(conveyorLine, station.stationChildCode, 0, false);
            }
        }
    }
}