wangxinhui
9 天以前 b466b3135cd7f3b08f570efda0ffb691daff5270
一期输送线代码及AGV请求等

一期输送线代码及AGV请求等
已添加3个文件
已修改6个文件
276 ■■■■■ 文件已修改
项目代码/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskFlowDTO.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskReqContent.cs 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskRequestDTO.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WCSServices/WIDESEAWCS_Tasks/一期线体/ConveyorLineJob1.cs 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/AGV通信文档/WCS与RCS安全交互接口文档V1.6_11_13.pdf 补丁 | 查看 | 原始文档 | blame | 历史
项目资料/一期对接相关资料/哈尔滨一期输送线对接协议modbusTcp协议V1.1.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskFlowDTO.cs
@@ -6,6 +6,9 @@
namespace WIDESEAWCS_DTO.Agv
{
    /// <summary>
    /// AGV任务放行
    /// </summary>
    public class AgvTaskFlowDTO
    {
        /// <summary>
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskReqContent.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Core;
namespace WIDESEAWCS_DTO.Agv
{
    public class DataResult
    {
        /// <summary>
        /// è¯·æ±‚结果:0、禁止;1、允许;
        /// </summary>
        public string Result { get; set; }
    }
    /// <summary>
    /// AGV任务请求返回(取放)
    /// </summary>
    public class AgvTaskReqContent
    {
        /// <summary>
        /// è¯·æ±‚编号
        /// </summary>
        public string ReqCode { get; set; }
        /// <summary>
        /// è¿”回码, æˆåŠŸ 0,失败 1
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// success æˆ–者异常原因
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// ç»“果对象
        /// </summary>
        public DataResult Data { get; set; }
        public AgvTaskReqContent()
        {
        }
        public AgvTaskReqContent OK()
        {
            Code = "0";
            Message = "success";
            Data = new DataResult()
            {
                Result = "1"
            };
            return this;
        }
        public AgvTaskReqContent Error(string message = "")
        {
            Code = "1";
            Message = message;
            Data = new DataResult()
            {
                Result = "0"
            };
            return this;
        }
    }
}
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_DTO/Agv/AgvTaskRequestDTO.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WIDESEAWCS_DTO.Agv
{
    /// <summary>
    /// AGV任务请求(取放)
    /// </summary>
    public class AgvTaskRequestDTO
    {
        /// <summary>
        /// è¯·æ±‚编号
        /// </summary>
        public string ReqCode { get; set; }
        /// <summary>
        /// è¯·æ±‚时间截
        /// </summary>
        public string ReqTime { get; set; }
        /// <summary>
        /// ä»»åŠ¡ç¼–å·
        /// </summary>
        public string TaskId { get; set; }
        /// <summary>
        /// æœºå™¨äººç¼–号
        /// </summary>
        public string RobotId { get; set; }
        /// <summary>
        /// ä½ç½®ç¼–号
        /// </summary>
        public string PositionId { get; set; }
        /// <summary>
        /// æ–™ç®±ç¼–号
        /// </summary>
        public string ContainerCode { get; set; }
        /// <summary>
        /// è¯·æ±‚节点
        /// 1:带载请求进入(背着料车进入);<br/>
        /// 2:空载请求进入(不带料车进入);<br/>
        /// 3:请求离开;<br/>
        /// 4:请求放料;<br/>
        /// 5:请求取料;<br/>
        /// 6:通知 PLC æŠ•料;<br/>
        /// 7:通知 PLC æŽ¥æ–™ï¼›<br/>
        /// </summary>
        public string Action { get; set; }
    }
}
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs
@@ -15,6 +15,7 @@
using WIDESEAWCS_Core.LogHelper;
using WIDESEAWCS_DTO;
using WIDESEAWCS_DTO.Agv;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
@@ -86,6 +87,73 @@
            }
            return content;
        }
        /// <summary>
        /// AGV任务请求
        /// </summary>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("WorkRequest"), AllowAnonymous]
        public AgvTaskReqContent WorkRequest([FromBody] AgvTaskRequestDTO agvTaskRequestDTO)
        {
            AgvTaskReqContent content = new AgvTaskReqContent();
            try
            {
                //获取任务
                Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"未找到料箱{agvTaskRequestDTO.ContainerCode}任务");
                //获取站台
                Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"未找到{agvTaskRequestDTO.PositionId}站台位置");
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"未找到对应设备{stationManger.StationDeviceCode}");
                OtherDevice commonConveyorLine = (OtherDevice)device;
                if (stationManger.StationType==StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
                {
                    short IsPut = commonConveyorLine.Communicator.Read<short>("0");
                    if (IsPut != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}禁止放箱");
                }
                else
                {
                    short IsTake = commonConveyorLine.Communicator.Read<short>("11");
                    if (IsTake != 256) throw new Exception($"{agvTaskRequestDTO.PositionId}禁止取箱");
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// AGV作业完成
        /// </summary>
        /// <returns></returns>
        [HttpPost, HttpGet, Route("WorkFinish"), AllowAnonymous]
        public AgvTaskReqContent WorkFinish([FromBody] AgvTaskRequestDTO agvTaskRequestDTO)
        {
            AgvTaskReqContent content = new AgvTaskReqContent();
            try
            {
                //获取站台
                Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"未找到{agvTaskRequestDTO.PositionId}站台位置");
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"未找到对应设备{stationManger.StationDeviceCode}");
                OtherDevice commonConveyorLine = (OtherDevice)device;
                if (stationManger.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
                {
                    commonConveyorLine.Communicator.Write("21", (short)256);
                }
                else
                {
                    commonConveyorLine.Communicator.Write("23", (short)256);
                }
                content.OK();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_Server/Controllers/Task/TaskController.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Text;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
@@ -71,6 +72,21 @@
                {
                    return WebResponseContent.Instance.Error($"未找到对应设备{stationManger.StationDeviceCode}");
                }
                if (stationManger.StationDeviceCode== "CL1" || stationManger.StationDeviceCode == "CL2")
                {
                    OtherDevice commonConveyorLine = (OtherDevice)device;
                    byte[] bytesPick = commonConveyorLine.Communicator.Read("12", 5);
                    string PickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
                    if (containerFlowDTO.ContainerCode != PickBarCode) throw new Exception($"传入料箱码{containerFlowDTO.ContainerCode},输送料箱码{PickBarCode}数据错误");
                    if (containerFlowDTO.Direction == "100")
                    {
                        WebResponseContent responseContent = Service.ContainerFlow(containerFlowDTO, stationManger.StationDeviceCode);
                        if (!responseContent.Status) throw new Exception(responseContent.Message);
                    }
                    commonConveyorLine.Communicator.Write("22", (short)(containerFlowDTO.Direction == "100" ? 256 : 512));
                }
                else
                {
                CommonConveyorLine commonConveyorLine = (CommonConveyorLine)device;
                string PickBarCode = commonConveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.R_PickBarCode, stationManger.StationCode).Trim();
                if (containerFlowDTO.ContainerCode!= PickBarCode) throw new Exception($"传入料箱码{containerFlowDTO.ContainerCode},输送料箱码{PickBarCode}数据错误");
@@ -80,6 +96,7 @@
                    if (!responseContent.Status) throw new Exception(responseContent.Message);
                }
                commonConveyorLine.SetValue(ConveyorLineDBName.W_PickToHode,(short)containerFlowDTO.Direction.ObjToInt(), stationManger.StationCode);
                }
                content.OK();
            }
            catch (Exception ex)
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -223,7 +223,7 @@
            {
                lock (lock_requestInTask)
                {
                    Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == barCode && x.NextAddress == stationCode && x.TaskState == TaskStatusEnum.CL_Executing.ObjToInt());
                    Dt_Task task = BaseDal.QueryFirst(x => x.PalletCode == barCode && x.TaskType==TaskTypeEnum.Inbound.ObjToInt() && x.NextAddress == stationCode && x.TaskState == TaskStatusEnum.CL_Executing.ObjToInt());
                    if (task == null) throw new Exception($"{barCode}料箱未找到任务!");
                    Dt_LocationInfo? locationInfo = _locationInfoService.AssignLocation();
                    if (locationInfo == null) throw new Exception($"可用货位不足!");
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_Tasks/Ò»ÆÚÏßÌå/ConveyorLineJob1.cs
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components.Routing;
using Newtonsoft.Json;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Quartz;
using System;
using System.Collections.Generic;
@@ -9,6 +10,7 @@
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Text.Unicode;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.Helper;
@@ -54,7 +56,16 @@
            _routerService = routerService;
            _routerExtension = routerExtension;
        }
        /*
        1号位出库口允许放箱        0
        1号位放箱完成信号          21
        6号位拣选位料箱到达        1
        6号位拣选位料箱条码        2
        6号位拣选位料箱流动        22
        8号位入库口允许取箱        11
        8号位入库口料箱条码        12
        8号位机器人取箱完成        23
        */
        public Task Execute(IJobExecutionContext context)
        {
            try
@@ -65,13 +76,59 @@
                    OtherDevice device = (OtherDevice)value;
                    List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
                    
                    foreach (var item in stationMangers)
                    foreach (var station in stationMangers)
                    {
                        byte[] bytesPut = device.Communicator.Read("22", 1);
                       ;
                        device.Communicator.Write("22", new byte[] { 2, 0 });
                        byte[] bytesPuted = device.Communicator.Read("22",1);
                        device.Communicator.Write("22", new byte[] { 0, 0 });
                        if (station.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
                        {
                            //拣选申请
                            short pickArrived = device.Communicator.Read<short>("1");
                            if (pickArrived == 256)
                            {
                                byte[] bytesPick = device.Communicator.Read("2", 5);
                                string pickBarCode = Encoding.UTF8.GetString(bytesPick).Replace("\0", "").Replace("\\0", "");
                                //上报WMS料箱到达
                                if (pickBarCode.IsNotEmptyOrNull())
                                {
                                    WebResponseContent content = _taskService.WMSPickUp(station.PickStationCode, pickBarCode);
                                    if (content.Status)
                                    {
                                        WriteInfo(device.DeviceCode, $"{station.PickStationCode}拣选申请上报成功{pickBarCode}");
                                    }
                                    else
                                    {
                                        WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请上报WMS错误{pickBarCode},信息{content.Message}");
                                    }
                                }
                                else
                                {
                                    WriteError(device.DeviceCode, $"{station.PickStationCode}拣选申请为{pickArrived}条码为空值");
                                }
                            }
                        }
                        else
                        {
                            //入库申请
                            short InTake = device.Communicator.Read<short>("11");
                            byte[] bytesIn = device.Communicator.Read("12", 5);
                            string InBarCode = Encoding.UTF8.GetString(bytesIn).Replace("\0", "").Replace("\\0", "");
                            if (InTake==256 && InBarCode.IsNotEmptyOrNull())
                            {
                                //申请入库任务
                                Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == InBarCode && x.TaskType == TaskTypeEnum.Inbound.ObjToInt() && x.TaskState != TaskStatusEnum.CL_Executing.ObjToInt());
                                if (task != null) continue;
                                WebResponseContent content = _taskService.RequestInTask(station.StationCode, InBarCode);
                                if (content.Status)
                                {
                                    WriteInfo(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库成功");
                                }
                                else
                                {
                                    WriteError(device.DeviceCode, $"站台{station.StationCode}料箱{InBarCode}申请入库任务错误,信息{content.Message}");
                                }
                            }
                        }
                    }
                }
            }
ÏîÄ¿×ÊÁÏ/AGVͨÐÅÎĵµ/WCSÓëRCS°²È«½»»¥½Ó¿ÚÎĵµV1.6_11_13.pdf
Binary files differ
ÏîÄ¿×ÊÁÏ/Ò»ÆÚ¶Ô½ÓÏà¹Ø×ÊÁÏ/¹þ¶û±õÒ»ÆÚÊäËÍÏß¶Ô½ÓЭÒémodbusTcpЭÒéV1.1.xlsx
Binary files differ