wxw
1 天以前 6b2ec7bd05459ddb4ea99df00267dbfda49cbdc7
设备控制增加电量显示
4个文件已修改
71 ■■■■■ 已修改文件
Admin.NET/WCS.Application/Configuration/Database.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web/src/api/wcs/wcsDevice.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Web/src/views/device/deviceStartStop/index.vue 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Admin.NET/WCS.Application/Configuration/Database.json
@@ -12,6 +12,7 @@
        //"ConnectionString": "Server=localhost;Database=xxx;Uid=xxx;Pwd=xxx;SslMode=None;", // MySql 库连接字符串",
        //"ConnectionString": "User Id=xxx; Password=xxx; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)))", // Oracle 库连接字符串
        "ConnectionString": "Server=10.26.200.29;Database=WCS_JC34;User Id=sa;Password=boxline@2016;", // SqlServer 库连接字符串
        //"ConnectionString": "Server=192.168.62.200;Database=WCS_JC34;User Id=sa;Password=sql2019;", // SqlServer 库连接字符串
        //"SlaveConnectionConfigs": [ // 读写分离/主从
Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs
@@ -11,6 +11,7 @@
{
    private readonly SqlSugarRepository<WcsPlc> _wcsPlcRep;
    private readonly SysCacheService _sysCacheService;
    private static readonly ISqlSugarClient _db = SqlSugarSetup.ITenant.GetConnectionScope(SqlSugarConst.MainConfigId);
    public WcsPlcService(SqlSugarRepository<WcsPlc> wcsPlcRep, SysCacheService sysCacheService)
    {
        _wcsPlcRep = wcsPlcRep;
@@ -139,6 +140,38 @@
        var modService = new { PLCTaskAction.boRunningState, PLCTaskAction.boOffline, PLCTaskAction.boRefresh, PLCTaskAction.boDemo, PLCTaskAction.boDrumReversal, PLCTaskAction.boOutLock, PLCTaskAction.boEnterLock };
        return new { listPlc, modService };
    }
    [HttpGet]
    [ApiDescriptionSettings(Name = "GetCarDL")]
    [DisplayName("获取穿梭车电量")]
    public async Task<dynamic> GetCarDL()
    {
        var listPlc = await _wcsPlcRep.AsQueryable()
            .Where(s => s.Type == PLCTypeEnum.ShuttleCar)
            .ToListAsync();
        List<Dictionary<string, string>> _dicList = new List<Dictionary<string, string>>();
        foreach (var modPlc in listPlc)
        {
            var modbus = new ModbusUtil(modPlc);
            var listPlcDevice = _db.Queryable<WcsDevice>().First(s => s.PlcId == modPlc.Id);
            var (result, value) = modbus.GetDBValue(listPlcDevice.PosType, listPlcDevice.PlcPos);
            if (result.IsSucceed)
            {
                var listPlcStation = _db.Queryable<WcsPosition>().Where(s => s.DeviceId == modPlc.Id).ToList();
                var modCarDl = listPlcStation.FirstOrDefault(s => s.Text == "电池电量");
                var (resultDl, valueDl) = modbus.GetDBValue(modCarDl.PosType, modCarDl.PlcPos);
                if (resultDl.IsSucceed)
                {
                    Dictionary<string, string> _dic = new Dictionary<string, string>();
                    _dic.Add(modPlc.Text, valueDl);
                    _dicList.Add(_dic);
                }
            }
        }
        return new { _dicList };
    }
    /// <summary>
    /// 获取位置信息
    /// </summary>
Web/src/api/wcs/wcsDevice.ts
@@ -21,6 +21,7 @@
  WriteInfo = '/api/wcsDevice/WriteInfo',
  WriteTaskInfo = '/api/wcsDevice/WriteTaskInfo',
  WriteStartStop = '/api/wcsDevice/WriteStartStop',
  GetCarDL = '/api/wcsPLC/GetCarDL',
}
// 增加设备信息
export const WriteLocationInfo = (params?: any) =>
@@ -58,6 +59,14 @@
        data: params,
    });
export const GetCarDL = () =>
    request({
            url: Api.GetCarDL,
            method: 'get',
            data: {},
        });
// 增加设备信息
export const addWcsDevice = (params?: any) =>
    request({
Web/src/views/device/deviceStartStop/index.vue
@@ -5,15 +5,18 @@
                <el-collapse-item title="仓库一层" name="1">
                    <el-card class="box-card" shadow="hover">
                        <el-text style="margin-right: 15px;">1号穿梭车</el-text>
                        <el-text style="margin-right: 15px;">电量:{{carDL1}}</el-text>
                        <el-button @click="write('ShuttleCar', '1', '41093', '1')">复位</el-button>
                        <el-button @click="write('ShuttleCar', '1', '41096', '1')">正向寻码</el-button>
                        <el-button @click="write('ShuttleCar', '1', '41096', '2')">反向寻码</el-button>
                    </el-card>
                    <el-card class="box-card" shadow="hover">
                        <el-text style="margin-right: 15px;">2号穿梭车</el-text>
                        <el-text style="margin-right: 15px;">电量:{{carDL2}}</el-text>
                        <el-button @click="write('ShuttleCar', '2', '41093', '1')">复位</el-button>
                        <el-button @click="write('ShuttleCar', '2', '41096', '1')">正向寻码</el-button>
                        <el-button @click="write('ShuttleCar', '2', '41096', '2')">反向寻码</el-button>
                        <el-button @click="write('ShuttleCar', '2', '41096', '2')">反向寻码</el-button>
                    </el-card>
                </el-collapse-item>
            </el-collapse>
@@ -45,12 +48,32 @@
import { ref, reactive, onMounted } from 'vue';
import { listStatus, listPosition } from '/@/api/wcs/wcsPlc';
import { WriteStartStop } from '/@/api/wcs/wcsDevice';
import { WriteStartStop,GetCarDL } from '/@/api/wcs/wcsDevice';
import { ElMessage } from "element-plus";
const carDL1= ref<any>({});
carDL1.value="获取中..";
const carDL2= ref<any>({});
carDL2.value="获取中..";
const activeNames = ref(['1'])
const activeNames2 = ref(['2'])
const state = ref<any>({});
const handleQuery = async () => {
    var resCar = await GetCarDL();
    if (resCar.data.result._dicList && resCar.data.result._dicList.length > 0) {
       resCar.data.result._dicList.forEach(car => {
            const name = Object.keys(car)[0];
            if(name=="穿梭车1"){
                carDL1.value=car[name]+"%";
            }
            if(name=="穿梭车2"){
                carDL2.value=car[name]+"%";
            }
        });
    }
};
handleQuery();
const write = async (type: string, no: string, layer: string, FuncName: string) => {
@@ -60,7 +83,6 @@
        Layer: layer,
        FuncName: FuncName
    };
    var res = await WriteStartStop(data);
    console.log(res.data.result);
    // ElMessage.success(res.data.result);