From 695571c6009ecbc12e7d4a4fb147df7967a1260e Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 07 七月 2025 20:21:19 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 270 insertions(+), 10 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
index eacf3b7..5ae5962 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/CTU_AGVController .cs"
@@ -4,14 +4,18 @@
using WIDESEA_DTO.Agv;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
using WIDESEAWCS_Core.Enums;
using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.Agv;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_Tasks;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
+using static Dm.net.buffer.ByteArrayBuffer;
namespace WIDESEAWCS_Server.Controllers
{
@@ -22,12 +26,14 @@
private readonly IStationMangerRepository _stationMangerRepository;
private readonly ITaskService _taskService;
private readonly ITaskRepository _taskRepository;
+ private readonly IUnitOfWorkManage _unitOfWorkManage;
- public CTU_AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository)
+ public CTU_AGVController(IStationMangerRepository stationMangerRepository, ITaskService taskService, ITaskRepository taskRepository,IUnitOfWorkManage unitOfWorkManage)
{
_stationMangerRepository = stationMangerRepository;
_taskService = taskService;
_taskRepository = taskRepository;
+ _unitOfWorkManage = unitOfWorkManage;
}
[HttpPost, HttpGet, Route("AGVFinish"), AllowAnonymous]
public WebResponseContent AGVFinish(string barcode)
@@ -90,7 +96,70 @@
//return _taskService.AgvSecureApply(secureApplyModel);
}
#endregion
-
+ /// <summary>
+ /// 鏂欑鍒ゆ柇
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost, HttpGet, Route("AgvCallbackBoxNo"), AllowAnonymous]
+ public AgvResponseContent AgvCallbackBoxNo([FromBody] AgvCallbackBoxNoDTO agvCallbackBox)
+ {
+ AgvResponseContent agvResponseContent = new AgvResponseContent();
+ try
+ {
+ var task = _taskRepository.QueryFirst(x => agvCallbackBox.TaskNo == x.AgvTaskNum);
+ if (task==null)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = $"鏈壘鍒颁换鍔agvCallbackBox.TaskNo}";
+ return agvResponseContent;
+ }
+ if (task.PalletCode!= agvCallbackBox.ContainerCode)
+ {
+ string Address = task?.CurrentAddress switch
+ {
+ "5206" => "5105",
+ "5212" => "5111",
+ "5218" => "5117",
+ "8005" => "8001",
+ "5135" => "5236",
+ _ => throw new Exception("鏈壘鍒板湴鍧�淇℃伅"),
+ };
+ AgvCTUCancelDTO agvCTUCancel=new AgvCTUCancelDTO()
+ {
+ ForceCancel="1",
+ MatterArea= task.CurrentAddress,
+ TaskCode=task.AgvTaskNum,
+ ReqCode = DateTime.Now.ToString("yyyyMMddHHmmss") + task.AgvTaskNum,
+ ReqTime= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ };
+ WebResponseContent content = _taskService.AgvBoxApplyPass(agvCTUCancel);
+ //鍙栨秷浠诲姟
+ if (content.Status)
+ {
+ agvResponseContent.Code = "0";
+ agvResponseContent.Message = $"鍙栨秷{task.AgvTaskNum}鎴愬姛";
+ task.ExceptionMessage = $"瀹為檯绠卞彿{task.PalletCode}鎵弿绠眥agvCallbackBox.ContainerCode}";
+ _taskService.UpdateTask(task, TaskStatusEnum.Cancel);
+ }
+ else
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = content.Message;
+ }
+ }
+ else
+ {
+ agvResponseContent.Code = "0";
+ agvResponseContent.Message = "鎴愬姛";
+ }
+ }
+ catch (Exception ex)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = ex.Message;
+ }
+ return agvResponseContent;
+ }
/// <summary>
/// CtuAGV浠诲姟鏇存柊/瀹屾垚
/// </summary>
@@ -104,13 +173,197 @@
{
if (agvUpdateModel == null) throw new Exception("鏈幏鍙栧埌璇锋眰鍙傛暟");
agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
- var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
- if (task == null) throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
-
- if (agvUpdateModel.Method == "end")
+ var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum) ?? throw new Exception($"鏈壘鍒颁换鍔�,浠诲姟鍙枫�恵agvUpdateModel.TaskCode}銆�");
+ switch (agvUpdateModel.Method.ToUpper())
{
- if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt()) PutFinish(task.NextAddress);
- _taskService.TaskCompleted(task.TaskNum);
+ case "END":
+ if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt()
+ || task.TaskType == TaskTypeEnum.OutAllocate.ObjToInt() || task.TaskType == TaskTypeEnum.OutProduct.ObjToInt())
+ PutFinish(task.NextAddress);
+ _taskService.TaskCompleted(task.TaskNum);
+ break;
+ case "APPLYTOAGV":
+ //鏇存敼鎴愬搧鍏ュ簱AGV鍙栬揣浠诲姟鐘舵��
+ if (task.TaskType == TaskTypeEnum.InProduct.ObjToInt() || task.TaskType == TaskTypeEnum.InProductBack.ObjToInt())
+ {
+
+ //鏄惁瀛樺湪杈撻�佺嚎浣撳緟AGV鎼繍浠诲姟
+ var taskExecutes = _taskRepository.QueryData(x => x.NextAddress == task.CurrentAddress && x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt() && x.TaskType == TaskTypeEnum.InProduct.ObjToInt());
+ if (taskExecutes.Count > 0)
+ {
+ string address = task.CurrentAddress switch
+ {
+ "5206" => "5105",
+ "5212" => "5111",
+ "5218" => "5117"
+ };
+ //璋冪敤AGV棰勮皟搴︽帴鍙�
+ AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
+ {
+ PositionCode = address,
+ NextTask = "90",
+ UseableLayers = "1",
+ CacheCount = "1",
+ Update = "0",
+ AgvTyp = "11",
+ PreTaskQty = "1",
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ };
+ WebResponseContent content = _taskService.AgvPreScheduleTask(agvScheduleTask);
+ if (!content.Status)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = content.Message;
+ return agvResponseContent;
+ }
+ }
+ Dt_StationManger stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == task.CurrentAddress);
+ if (stationManger==null)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = "鏈壘鍒扮珯鍙�";
+ return agvResponseContent;
+ }
+ IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode);
+ if (device == null)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = $"鏈壘璁惧{stationManger.StationDeviceCode}";
+ return agvResponseContent;
+ }
+ OtherDevice otherDevice = (OtherDevice)device;
+ short canTake = otherDevice.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, stationManger.StationCode);
+ if (canTake == 1)
+ {
+ //鑾峰彇璋冨叆鍙傛暟
+ AGVBoxApplyPassDTO boxApplyPassDTO = new AGVBoxApplyPassDTO()
+ {
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ TaskCode = task.AgvTaskNum
+ };
+ if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+ {
+ boxApplyPassDTO.Type = "1";
+ }
+ else
+ {
+ boxApplyPassDTO.Type = "2";
+ }
+ //璇锋眰鏂欑鍥炶皟鎺ュ彛
+ WebResponseContent content = _taskService.AgvBoxApplyPass(boxApplyPassDTO);
+ if (content.Status && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+ {
+ task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+ _taskRepository.UpdateData(task);
+ }
+ else
+ {
+ task.ExceptionMessage = content.Message;
+ _taskService.UpdateTask(task, TaskStatusEnum.Exception);
+ }
+ }
+ else
+ {
+ task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
+ task.Remark = task.TaskState.ToString();
+ _taskRepository.UpdateData(task);
+ }
+ }
+ else //鏇存敼杈呮枡鍙栬揣
+ {
+ //鏄惁瀛樺湪杈撻�佺嚎浣撳緟AGV鎼繍浠诲姟
+ var taskExecutesFL = _taskRepository.QueryData(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.DeviceCode == "AGV_FL" && !string.IsNullOrEmpty(x.DeviceCode));
+ if (taskExecutesFL.Count > 0)
+ {
+ //璋冪敤AGV棰勮皟搴︽帴鍙�
+ AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
+ {
+ PositionCode = "8001",
+ NextTask = "60",
+ UseableLayers = "1",
+ CacheCount = "1",
+ Update = "0",
+ AgvTyp = "10",
+ PreTaskQty = "1",
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ };
+ WebResponseContent contentFL = _taskService.AgvPreScheduleTask(agvScheduleTask);
+ if (!contentFL.Status)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = contentFL.Message;
+ return agvResponseContent;
+ }
+ }
+ else //绾夸綋鏃犱换鍔�
+ {
+ //璋冪敤AGV棰勮皟搴︽帴鍙�
+ AgvScheduleTaskDTO agvScheduleTask = new AgvScheduleTaskDTO()
+ {
+ PositionCode = "8001",
+ NextTask = "15",
+ UseableLayers = "1",
+ CacheCount = "1",
+ Update = "0",
+ AgvTyp = "10",
+ PreTaskQty = "1",
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ };
+ WebResponseContent contentFL = _taskService.AgvPreScheduleTask(agvScheduleTask);
+ if (!contentFL.Status)
+ {
+ agvResponseContent.Code = "1";
+ agvResponseContent.Message = contentFL.Message;
+ return agvResponseContent;
+ }
+ }
+ //鑾峰彇璋冨叆鍙傛暟
+ AGVBoxApplyPassDTO boxApplyPassDTO = new AGVBoxApplyPassDTO()
+ {
+ ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
+ ReqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+ TaskCode = task.AgvTaskNum
+ };
+ boxApplyPassDTO.Type = "1";
+ //璇锋眰鏂欑鍥炶皟鎺ュ彛
+ WebResponseContent content = _taskService.AgvBoxApplyPass(boxApplyPassDTO);
+ if (content.Status && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
+ {
+ task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+ _taskRepository.UpdateData(task);
+ }
+ else
+ {
+ task.ExceptionMessage = content.Message;
+ _taskService.UpdateTask(task, TaskStatusEnum.Exception);
+ }
+ }
+ break;
+ case "APPLYFROMAGV":
+ //鏇存敼鎴愬搧鍑篈GV鏀捐揣浠诲姟鐘舵��
+ //if (task.TaskType == TaskTypeEnum.OutProduct.ObjToInt())
+ //{
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_WaitToExecute);
+ //}
+ break;
+ case "OUTBIN":
+ if (task.TaskType == TaskTypeEnum.InProduct.ObjToInt() || task.TaskType == TaskTypeEnum.InProductBack.ObjToInt())
+ {
+ TakeFinish(task.CurrentAddress);
+ //_taskService.UpdateTask(task, TaskStatusEnum.AGV_Executing);
+ }
+ else if(task.TaskType == TaskTypeEnum.OutProduct.ObjToInt())
+ {
+ task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
+ _taskRepository.UpdateData(task);
+ }
+ break;
+ default:
+ throw new Exception($"鏂规硶{agvUpdateModel.Method}鍙傛暟涓嶅瓨鍦�");
}
agvResponseContent.Code = "0";
agvResponseContent.Message = "鎴愬姛";
@@ -181,7 +434,7 @@
/// <param name="code"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("PutFinish"), AllowAnonymous]
- public WebResponseContent PutFinish(string code)
+ public WebResponseContent PutFinish(string code,string barCode="",string taskNum="")
{
try
{
@@ -197,8 +450,15 @@
}
OtherDevice otherDevice = (OtherDevice)device;
+
+ if (!barCode.IsNullOrEmpty() && !taskNum.IsNullOrEmpty())
+ {
+ otherDevice.SetValue(W_ConveyorLineFLDB.Barcode, barCode, stationManger.StationCode);
+ Thread.Sleep(500);
+ otherDevice.SetValue(W_ConveyorLineFLDB.TaskNum, taskNum, stationManger.StationCode);
+ Thread.Sleep(500);
+ }
otherDevice.SetValue(GroundStationDBName.W_PutFinish, true, stationManger.StationCode);
-
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
--
Gitblit v1.9.3