From 257d09aff7ec7b858b037607869d23ec61ac75bc Mon Sep 17 00:00:00 2001
From: helongyang <647556386@qq.com>
Date: 星期二, 19 八月 2025 09:03:49 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/成品仓/ConveyorLineJob_CP.cs | 98 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 96 insertions(+), 2 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
index 4d5acbb..1b4c87b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/\346\210\220\345\223\201\344\273\223/ConveyorLineJob_CP.cs"
@@ -1,20 +1,27 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Microsoft.AspNetCore.Components.Routing;
+using Newtonsoft.Json;
using Quartz;
+using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
-namespace WIDESEAWCS_Tasks.鎴愬搧浠�
+namespace WIDESEAWCS_Tasks
{
[DisallowConcurrentExecution]
public class ConveyorLineJob_CP : JobBase, IJob
@@ -63,6 +70,93 @@
WriteError(device.DeviceName, $"璇烽厤缃粨搴撹澶囦俊鎭�");
return Task.CompletedTask;
}
+ List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).ToList();
+ List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
+ foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
+ {
+ DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(R_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+ DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode && x.DeviceProParamType == nameof(W_ConveyorLineCPDB)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+ if (item.StationType==StationTypeEnum.StationType_OnlyInbound.ObjToInt() && deviceProWrite!=null)
+ {
+ Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.New.ObjToInt()) && x.DeviceCode == device.DeviceCode);
+ if (task!=null)
+ {
+ //鑾峰彇绔欏彴
+ Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
+ if (stationManger == null)
+ {
+ WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ continue;
+ }
+ //鏌ヨ璺敱
+ Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == task.CurrentAddress);
+ if (router == null)
+ {
+ WriteError(item.StationName, $"鏈壘鍒拌矾鐢遍厤缃俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ continue;
+ }
+ //string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, "AGV_CP");
+ //if (string.IsNullOrEmpty(locationCode) && task.TaskType != TaskTypeEnum.EmptyProductBack.ObjToInt())
+ //{
+ // WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ // continue;
+ //}
+ device.SetValue(W_ConveyorLineCPDB.StartPos, router.StartPosi, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.EndPos, router.NextPosi, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.Barcode, task.PalletCode, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.TaskNum, task.TaskNum, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.WorkType, task.PalletType, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.WorkMode, 1, item.StationCode);
+ device.SetValue(W_ConveyorLineCPDB.CheckPos, 1, item.StationCode);
+ //鍚姩鎸囦护
+ device.SetValue(W_ConveyorLineCPDB.ConveyArrival, 1, item.StationCode);
+ _taskService.UpdateTask(task, TaskStatusEnum.Line_Executing, nextAddress: router.NextPosi, targetAddress: router.NextPosi);
+ if (task.TaskType==TaskTypeEnum.EmptyProductBack.ObjToInt())
+ {
+ _taskService.TaskCompleted(task.TaskNum);
+ }
+ }
+ }
+ else if (item.StationType == StationTypeEnum.StationType_InStartAndOutEnd.ObjToInt() && deviceProRead != null)
+ {
+ R_ConveyorLineCPInfo conveyorLineInfoRead = device.Communicator.ReadCustomer<R_ConveyorLineCPInfo>(deviceProRead.DeviceProAddress);
+ if (conveyorLineInfoRead != null && conveyorLineInfoRead.EndPos.ToString() == item.StationCode)
+ {
+ short isCanTake = device.GetValue<GroundStationDBName, short>(GroundStationDBName.R_IsCanTake, item.StationCode);
+ if (conveyorLineInfoRead.ConveyArrivaled == 1 && isCanTake == 1)
+ {
+ //鑾峰彇浠诲姟
+ Dt_Task task = _taskRepository.QueryFirst(x => x.NextAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType) && (x.TaskState == TaskStatusEnum.Line_Executing.ObjToInt()) && x.DeviceCode == device.DeviceCode && x.TaskNum == conveyorLineInfoRead.TaskNum.ObjToInt());
+ //鑾峰彇绔欏彴
+ if (task != null)
+ {
+ Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
+ if (stationManger == null)
+ {
+ WriteError(item.StationName, $"鏈壘鍒板搴旂珯鍙颁俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ continue;
+ }
+ //鏌ヨ璺敱
+ Dt_Router router = _routerRepository.QueryFirst(x => x.InOutType == task.TaskType && x.StartPosi == task.NextAddress);
+ if (router == null)
+ {
+ WriteError(item.StationName, $"鏈壘鍒拌矾鐢遍厤缃俊鎭�,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ continue;
+ }
+ string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode);
+ if (string.IsNullOrEmpty(locationCode))
+ {
+ WriteError(item.StationName, $"璇锋眰鍒嗛厤璐т綅杩斿洖淇℃伅閿欒,璁惧缂栧彿:{item.StationCode},浠诲姟鍙�:{task.TaskNum}");
+ continue;
+ }
+ _taskService.UpdateTask(task, TaskStatusEnum.AGV_Execute, deviceCode: router.ChildPosiDeviceCode, currentAddress: router.StartPosi, nextAddress: locationCode, targetAddress: locationCode);
+ }
+ }
+
+ }
+
+ }
+ }
}
return Task.CompletedTask;
}
--
Gitblit v1.9.3