hwh
2024-09-02 3609a43ca4d7842a839524dee1baaf4f84bc4801
绑定首页服务状态
4个文件已修改
97 ■■■■ 已修改文件
Admin.NET/WCS.Application/Hub/IPlcHub.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Admin.NET/WCS.Application/Hub/PlcHub.cs 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web/src/views/device/deviceInfo/index.vue 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Admin.NET/WCS.Application/Hub/IPlcHub.cs
@@ -28,5 +28,10 @@
        /// <param name="context"></param>
        /// <returns></returns>
        Task PublicAlarm(WcsAlarmInfoOutput context);
        /// <summary>
        /// 修改服务状态
        /// </summary>
        /// <param name="context"></param>
        Task UpdateService(PLCServiceModel context);
    }
}
Admin.NET/WCS.Application/Hub/PlcHub.cs
@@ -34,4 +34,31 @@
    //{
    //    await _plcHubContext.Clients.All.PublicStationStatus(context);
    //}
    /// <summary>
    /// 下发服务状态
    /// </summary>
    public async Task UpdateService(PLCServiceModel context)
    {
        //运行状态
        if (context.BoRunningState.HasValue)
            PLCTaskAction.boRunningState = context.BoRunningState.Value;
        //脱机模式
        if (context.BoOffline.HasValue)
            PLCTaskAction.boOffline = context.BoOffline.Value;
        //自刷新
        if (context.BoRefresh.HasValue)
            PLCTaskAction.boRefresh = context.BoRefresh.Value;
        await _plcHubContext.Clients.All.UpdateService(context);
    }
}
public class PLCServiceModel
{
    public bool? BoRunningState { get; set; }
    public bool? BoOffline { get; set; }
    public bool? BoRefresh { get; set; }
}
Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs
@@ -1,4 +1,6 @@

using Admin.NET.Core.Service;
namespace WCS.Application;
/// <summary>
@@ -8,9 +10,11 @@
public class WcsDeviceService : IDynamicApiController, ITransient
{
    private readonly SqlSugarRepository<WcsDevice> _wcsDeviceRep;
    public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep)
    private readonly SysCacheService _sysCacheService;
    public WcsDeviceService(SqlSugarRepository<WcsDevice> wcsDeviceRep, SysCacheService sysCacheService)
    {
        _wcsDeviceRep = wcsDeviceRep;
        _sysCacheService = sysCacheService;
    }
    /// <summary>
@@ -202,13 +206,18 @@
                                    .Select<WcsDeviceOutput>((a, b) => new WcsDeviceOutput() { Type = b.Type }, true)
                                    .ToListAsync();
        //获取跺机的状态
        var listConn = PLCTaskAction.listPlcConn;
        foreach (var modDevice in list)
        {
            var modUtil = listConn.FirstOrDefault(s => s != null && s.PlcId == modDevice.PlcId);
            modDevice.Status = modUtil == null ? false : modUtil.Connected;
            if (_sysCacheService.ExistKey("PlcConn" + modDevice.PlcId))
            {
                var cachePlc = _sysCacheService.Get<WcsPlc>("PlcConn" + modDevice.PlcId);
                modDevice.Status = cachePlc.IsConn;
        }
            else
            {
                modDevice.Status = false;
            }
        }
        return list;
    }
Web/src/views/device/deviceInfo/index.vue
@@ -5,27 +5,32 @@
                <el-collapse v-model="activeName">
                    <el-collapse-item title="设备控制" name="1">
                        <el-card class="box-card" shadow="hover">
                            <el-switch v-model="state.boRunningState" active-text="" inactive-text="程序服务"></el-switch>
                            <el-switch v-model="state.boRunningState" active-text="" inactive-text="程序服务"
                                @change="handleSwitchChange('boRunningState', $event)"></el-switch>
                        </el-card>
                        <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                            <el-switch v-model="state.boOffline" active-text="" inactive-text="脱机模式"></el-switch>
                            <el-switch v-model="state.boOffline" active-text="" inactive-text="脱机模式"
                                @change="handleSwitchChange('boOffline', $event)"></el-switch>
                        </el-card>
                        <el-card class="box-card" shadow="hover" style="margin-top: 3px;">
                            <el-switch v-model="state.boRefresh" active-text="" inactive-text="自刷新"></el-switch>
                            <el-switch v-model="state.boRefresh" active-text="" inactive-text="自刷新"
                                @change="handleSwitchChange('boRefresh', $event)"></el-switch>
                        </el-card>
                    </el-collapse-item>
                    <el-collapse-item title="堆垛机" name="2">
                        <div style="overflow-x: auto;white-space: nowrap;">
                            <el-card v-for="(stacker, index) in stackers" :key="index" class="box-card" shadow="hover">
                                <el-switch v-model="stacker.isConn" :inactive-text="`${stacker.text}`" disabled ></el-switch>
                                <el-switch v-model="stacker.isConn" :inactive-text="`${stacker.text}`"
                                    disabled></el-switch>
                            </el-card>
                        </div>
                    </el-collapse-item>
                    <el-collapse-item title="输送线" name="3">
                        <el-card v-for="(conveyor, index) in conveyors" :key="index" class="box-card" shadow="hover">
                            <el-switch v-model="conveyor.isConn" :inactive-text="`${conveyor.text}`" disabled ></el-switch>
                            <el-switch v-model="conveyor.isConn" :inactive-text="`${conveyor.text}`"
                                disabled></el-switch>
                        </el-card>
                    </el-collapse-item>
                </el-collapse>
@@ -101,7 +106,15 @@
        }
        console.log(stackers.value[0].isConn)
    });
    signalR.off('UpdateService');
    signalR.on('UpdateService', (data: any) => {
        state.value = data;
});
});
const handleSwitchChange = (field: string, value: boolean) => {
    signalR.invoke('UpdateService',state.value);
};
const activeName = ['1', '2', '3'];
const value1 = ref(false);
@@ -1971,12 +1984,16 @@
.grid-container-line {
    display: grid;
    grid-template-columns: repeat(51, 1fr); /* 自适应列宽 */
    grid-template-rows: 1fr; /* 自适应行高 */
    grid-template-columns: repeat(51, 1fr);
    /* 自适应列宽 */
    grid-template-rows: 1fr;
    /* 自适应行高 */
    gap: 0;
    margin-top: 25px;
    width: 100%; /* 宽度自适应 */
    height: 1fr; /* 高度自适应 */
    width: 100%;
    /* 宽度自适应 */
    height: 1fr;
    /* 高度自适应 */
}
.grid-item-line {
@@ -2053,9 +2070,12 @@
    background-color: #9c9c9c;
    border: 1px solid #797777;
    text-align: center;
    line-height: 1.4vw; /* 行高 */
    width: 100%; /* 自适应宽度 */
    height: 100%; /* 自适应高度 */
    line-height: 1.4vw;
    /* 行高 */
    width: 100%;
    /* 自适应宽度 */
    height: 100%;
    /* 自适应高度 */
    color: #fff;
    font-size: 0.7vw;
}
@@ -2069,10 +2089,12 @@
.active2>div {
    display: none;
}
.active3 {
    background-color: #fff;
    border:1px solid red;
}
.active3>div {
    display: none;
}