From 58a5a9af83492c5bbb4fba88b4443f08fa4becfc Mon Sep 17 00:00:00 2001 From: 刘磊 <1161824510@qq.com> Date: 星期二, 17 十二月 2024 19:53:14 +0800 Subject: [PATCH] 解决冲突 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/GetStationService.cs | 66 +++++++++++++++++++++----------- 1 files changed, 43 insertions(+), 23 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/GetStationService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/GetStationService.cs index ae7d875..743d33f 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/GetStationService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/GetStationService.cs @@ -1,43 +1,63 @@ -锘縰sing System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WIDESEAWCS_BasicInfoRepository; +锘縰sing WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_Core; +using WIDESEAWCS_Core.BaseServices; +using WIDESEAWCS_ISystemServices; +using WIDESEAWCS_Model.Models; using WIDESEAWCS_QuartzJob; using WIDESEAWCS_Tasks.ConveyorLineJob; -namespace WIDESEAWCS_Tasks.ConveyorLineJob_GW +namespace WIDESEAWCS_Tasks { - public class GetStationService: IGetStationService + public class GetStationService : ServiceBase<Dt_StationManager, IDt_StationManagerRepository>, IGetStationService { - private readonly IDt_StationManagerRepository _stationManagerRepository; - public GetStationService(IDt_StationManagerRepository stationManagerRepository) { _stationManagerRepository = stationManagerRepository; } + //private readonly IDt_StationManagerRepository _stationManagerRepository; + + public GetStationService(IDt_StationManagerRepository BaseDal, ISys_ConfigService sys_ConfigService) : base(BaseDal) + { + } + public WebResponseContent GetStationHasPallet(List<string> stations) { - WebResponseContent content = new WebResponseContent(); + var content = new WebResponseContent(); + try { - var x = 0; - var stationManagers = _stationManagerRepository.QueryData(x => stations.Contains(x.stationChildCode)); - foreach (var item in stationManagers) - { - if (Convert.ToInt32(item.stationPLC) > 1010) - { - CommonConveyorLine_GW commonConveyorLine_GW = Storage.Devices.FirstOrDefault(x => x.DeviceCode == item.stationPLC) as CommonConveyorLine_GW; + int palletCount = 0; // 鐢ㄤ簬璁板綍娌℃湁鎵樼洏鐨勭珯鐐规暟閲� + var stationManagers = BaseDal.QueryData(s => stations.Contains(s.stationChildCode)); // 鏌ヨ鐩稿叧绔欑偣绠$悊淇℃伅 - var isHasPallet = Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.HasPallet, item.stationPLC)); - if (isHasPallet > 1) x++; + foreach (var station in stationManagers) + { + if (IsStationValid(station)) + { + var hasPallet = ReadPalletStatus(station); // 鑾峰彇鎵樼洏鐘舵�� + if (hasPallet == 0) // 濡傛灉娌℃湁鎵樼洏 + { + palletCount++; + } } } - content.OK(data: x); + + content.OK(data: palletCount); // 杩斿洖缁撴灉 } catch (Exception ex) { - content.Error(ex.Message); + content.Error(ex.Message); // 鎹曡幏骞惰繑鍥為敊璇俊鎭� } + return content; } + + // 楠岃瘉绔欑偣鏄惁鏈夋晥 + private bool IsStationValid(Dt_StationManager station) + { + return Convert.ToInt32(station.stationPLC) > 1010; + } + + // 璇诲彇鎵樼洏鐘舵�� + private int ReadPalletStatus(Dt_StationManager station) + { + var commonConveyorLine_GW = Storage.Devices.FirstOrDefault(device => device.DeviceCode == station.stationPLC) as CommonConveyorLine_GW; + return Convert.ToInt32(commonConveyorLine_GW.ReadValue(ConveyorLineDBName_After.HasPallet, station.stationChildCode)); + } } -} +} \ No newline at end of file -- Gitblit v1.9.3