From d3e1346d52806f00d21eba23cabf9cfa4f61d7d4 Mon Sep 17 00:00:00 2001 From: hwh <332078369@qq.com> Date: 星期四, 05 九月 2024 16:34:00 +0800 Subject: [PATCH] 测试页面,修复bug --- Web/src/views/device/deviceInfo/index.vue | 13 ++++-- Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs | 10 +++-- Web/src/views/device/deviceMonitor/index.vue | 49 ++++++++++-------------- Admin.NET/WCS.Application/PLC/PLCUtil.cs | 5 +- Web/src/views/device/alarmManage/index.vue | 6 +- Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs | 11 ----- Web/src/api/wcs/wcsPlc.ts | 9 ++++ Admin.NET/WCS.Application/Hub/PlcHub.cs | 2 8 files changed, 52 insertions(+), 53 deletions(-) diff --git a/Admin.NET/WCS.Application/Hub/PlcHub.cs b/Admin.NET/WCS.Application/Hub/PlcHub.cs index f85da61..de41681 100644 --- a/Admin.NET/WCS.Application/Hub/PlcHub.cs +++ b/Admin.NET/WCS.Application/Hub/PlcHub.cs @@ -55,7 +55,7 @@ //鑷埛鏂� if (context.BoRefresh.HasValue) PLCTaskAction.boRefresh = context.BoRefresh.Value; - await _plcHubContext.Clients.All.UpdateService(context); + await _plcHubContext.Clients.All.UpdateService(new PLCServiceModel() { BoRunningState = PLCTaskAction.boRunningState, BoRefresh = PLCTaskAction.boRefresh, BoOffline = PLCTaskAction.boOffline }); } } public class PLCServiceModel diff --git a/Admin.NET/WCS.Application/PLC/PLCUtil.cs b/Admin.NET/WCS.Application/PLC/PLCUtil.cs index 481080c..27e6c55 100644 --- a/Admin.NET/WCS.Application/PLC/PLCUtil.cs +++ b/Admin.NET/WCS.Application/PLC/PLCUtil.cs @@ -42,8 +42,9 @@ /// <param name="DbNumber">DB鍖烘寚瀹氬��</param> /// <param name="PosType">瀛楃绫诲瀷</param> /// <param name="Pos">鍋忕Щ閲�/鍦板潃</param> + /// <param name="Length">闀垮害锛堝瓧绗︿覆锛�</param> /// <returns></returns> - public (IoTClient.Result, dynamic value) GetPlcDBValue(PLCDataTypeEnum PosType, string DbNumber, string Pos) + public (IoTClient.Result, dynamic value) GetPlcDBValue(PLCDataTypeEnum PosType, string DbNumber, string Pos, int? Length = 0) { lock (OLock) { @@ -86,7 +87,7 @@ result = _client.ReadDouble(address); break; case PLCDataTypeEnum.String: - result = _client.ReadString(address); + result = _client.ReadString(address, Convert.ToUInt16(Length)); break; default: result = new IoTClient.Result<object>(); diff --git a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs index 7b91e7e..165dd6c 100644 --- a/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs +++ b/Admin.NET/WCS.Application/Service/WcsDevice/WcsDeviceService.cs @@ -219,7 +219,9 @@ //璇诲彇plc鐨勫�� var modConn = PLCTaskAction.listPlcConn.FirstOrDefault(s => s != null && s.PlcId == modDevice.PlcId); if (modConn == null) - break; + { + continue; + } try { var listPosition = await _wcsDeviceRep.Context.Queryable<WcsPosition>().Where(s => s.DeviceId == modDevice.Id).ToListAsync(); @@ -229,7 +231,7 @@ modDevice.Wcs = Convert.ToString(wcs); //浠诲姟鍙� var modPositionTask = listPosition.FirstOrDefault(s => s.Text == "浠诲姟鍙�"); - (result, var taskNo) = modConn.GetPlcDBValue(modPositionTask.PosType, modDevice.DbNumber, modPositionTask.PlcPos); + (result, var taskNo) = modConn.GetPlcDBValue(modPositionTask.PosType, modDevice.DbNumber, modPositionTask.PlcPos, modPositionTask.StringLength); modDevice.TaskNo = Convert.ToString(taskNo); //浠诲姟绫诲瀷 var modPositionTaskType = listPosition.FirstOrDefault(s => s.Text == "浠诲姟绫诲瀷"); @@ -245,7 +247,7 @@ modDevice.EndLocatNo = Convert.ToString(endLocatNo); //鎵樼洏鐮� var modPositionPalletNo = listPosition.FirstOrDefault(s => s.Text == "鎵樼洏鐮�"); - (result, var palletNo) = modConn.GetPlcDBValue(modPositionPalletNo.PosType, modDevice.DbNumber, modPositionPalletNo.PlcPos); + (result, var palletNo) = modConn.GetPlcDBValue(modPositionPalletNo.PosType, modDevice.DbNumber, modPositionPalletNo.PlcPos, modPositionPalletNo.StringLength); modDevice.PalletNo = Convert.ToString(palletNo); } catch (Exception) @@ -288,7 +290,7 @@ .Select(u => new { id = u.Id, - name = u.Text + name = u.Text } ).ToListAsync(); } diff --git a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs index 4480c14..e4fce43 100644 --- a/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs +++ b/Admin.NET/WCS.Application/Service/WcsPlc/WcsPlcService.cs @@ -106,7 +106,7 @@ [DisplayName("鑾峰彇PLC鍒楄〃")] public async Task<List<WcsPlcOutput>> List([FromQuery] PageWcsPlcInput input) { - return await _wcsPlcRep.AsQueryable().Select<WcsPlcOutput>().ToListAsync(); + return await _wcsPlcRep.AsQueryable().WhereIF(input.Type != null, s => s.Type == input.Type).Select<WcsPlcOutput>().ToListAsync(); } /// <summary> @@ -147,15 +147,6 @@ [DisplayName("鑾峰彇浣嶇疆淇℃伅")] public List<PlcPositionInfo> ListPosition() { - //娴嬭瘯鐢� - //return new List<PlcPositionInfo>() - //{ - // new PlcPositionInfo(){ Type=PLCTypeEnum.ConveyorLine, StationNum="147", BoHaveItem=true }, - // new PlcPositionInfo(){ Type=PLCTypeEnum.ConveyorLine, StationNum="143", BoHaveItem=true }, - - // new PlcPositionInfo(){ Type=PLCTypeEnum.StackingMachine, StationNum="002", BoxHeight=30 }, - //}; - var list = PLCTaskAction.listPositionInfo.ToList(); return list; } diff --git a/Web/src/api/wcs/wcsPlc.ts b/Web/src/api/wcs/wcsPlc.ts index 9c8386a..cfccaff 100644 --- a/Web/src/api/wcs/wcsPlc.ts +++ b/Web/src/api/wcs/wcsPlc.ts @@ -5,6 +5,7 @@ UpdateWcsPlc = '/api/wcsPlc/update', PageWcsPlc = '/api/wcsPlc/page', DetailWcsPlc = '/api/wcsPlc/detail', + ListWcsPlc = '/api/wcsPlc/list', ListStatus = '/api/wcsPlc/ListStatus', ListPosition = 'api/wcsPlc/ListPosition' } @@ -48,7 +49,13 @@ method: 'get', data: { id }, }); - +// 鍒嗛〉鏌ヨPLC +export const listWcsPlc = (params?: any) => + request({ + url: Api.ListWcsPlc, + method: 'get', + data: params, + }); // 鑾峰彇PLC杩炴帴鐘舵�佸拰鏈嶅姟鐘舵�� export const listStatus = () => diff --git a/Web/src/views/device/alarmManage/index.vue b/Web/src/views/device/alarmManage/index.vue index a2e24b7..4013f0a 100644 --- a/Web/src/views/device/alarmManage/index.vue +++ b/Web/src/views/device/alarmManage/index.vue @@ -1961,19 +1961,19 @@ //鍒囨崲灞傚钩闈� function floorTogglePlain(buttonNumber) { if (buttonNumber === 1) { - isPlain1.value = !isPlain1.value; + isPlain1.value = false; isPlain2.value = true; isPlain3.value = true; //鍒囨崲杈撻�佺嚎鏁版嵁 cellsData.value = cellsDataOne.value; } else if (buttonNumber === 2) { - isPlain2.value = !isPlain2.value; + isPlain2.value = false; isPlain1.value = true; isPlain3.value = true; //鍒囨崲杈撻�佺嚎鏁版嵁 cellsData.value = cellsDataTwo.value; } else if (buttonNumber === 3) { - isPlain3.value = !isPlain3.value; + isPlain3.value = false; isPlain1.value = true; isPlain2.value = true; //鍒囨崲杈撻�佺嚎鏁版嵁 diff --git a/Web/src/views/device/deviceInfo/index.vue b/Web/src/views/device/deviceInfo/index.vue index 9101e17..9d46727 100644 --- a/Web/src/views/device/deviceInfo/index.vue +++ b/Web/src/views/device/deviceInfo/index.vue @@ -37,9 +37,12 @@ </el-col> <el-col :span="21"> <div class="card-page"> - <el-button type="primary" :plain="floorStates.isPlain1" @click="floorTogglePlain(1)">涓�灞傚钩闈�</el-button> - <el-button type="primary" :plain="floorStates.isPlain2" @click="floorTogglePlain(2)">浜屽眰骞抽潰</el-button> - <el-button type="primary" :plain="floorStates.isPlain3" @click="floorTogglePlain(3)">涓夊眰骞抽潰</el-button> + <el-button type="primary" :plain="floorStates.isPlain1" + @click="floorTogglePlain(1)">涓�灞傚钩闈�</el-button> + <el-button type="primary" :plain="floorStates.isPlain2" + @click="floorTogglePlain(2)">浜屽眰骞抽潰</el-button> + <el-button type="primary" :plain="floorStates.isPlain3" + @click="floorTogglePlain(3)">涓夊眰骞抽潰</el-button> </div> <div style="margin: 40px; height: 50%;"> <div class="grid-container-line"> @@ -148,7 +151,9 @@ }); }); const handleSwitchChange = (field: string, value: boolean) => { - signalR.invoke('UpdateService', state.value); + const param = { [field]: value }; + debugger; + signalR.invoke('UpdateService', param); }; // 鏇存柊杈撻�佺嚎鏁版嵁鐨勯�氱敤鍑芥暟 diff --git a/Web/src/views/device/deviceMonitor/index.vue b/Web/src/views/device/deviceMonitor/index.vue index 66a81a1..8865fab 100644 --- a/Web/src/views/device/deviceMonitor/index.vue +++ b/Web/src/views/device/deviceMonitor/index.vue @@ -4,14 +4,12 @@ <el-card class="box-card"> <div slot="header" class="linefix"> <span>杈撻�佺嚎</span> - <div - :class="['lineStatus', { 'device-status-0': stationValue.status === true }, { 'device-status-1': stationValue.status === false }]"> - </div> + <div :class="['lineStatus', stationValue.status ? 'device-status-0' : 'device-status-1']"></div> </div> <div class="choosefix"> <el-select v-model="lineValue" placeholder="璇烽�夋嫨" @change="handleLineChange('item', $event)"> - <el-option v-for="item in lineOptions" :key="item.value" :label="item.label" - :value="item.value"></el-option> + <el-option v-for="item in lineOptions" :key="item.id" :label="item.text" + :value="item.id"></el-option> </el-select> <el-select v-model="stationValue" placeholder="璇烽�夋嫨" style="margin-top: 10px;" value-key="stationNum"> @@ -27,8 +25,9 @@ </el-form-item> <el-form-item label="浠诲姟绫诲瀷"> <el-select clearable v-model="stationValue.taskType" placeholder="璇烽�夋嫨浠诲姟绫诲瀷"> - <el-option v-for="(item,index) in dl('TaskTypeEnum')" :key="index" :value="Number(item.value)" :label="`${item.name} [${item.value}]`"></el-option> - </el-select> + <el-option v-for="(item, index) in dl('TaskTypeEnum')" :key="index" + :value="Number(item.value)" :label="`${item.name} [${item.value}]`"></el-option> + </el-select> </el-form-item> <el-form-item label="璧峰宸ヤ綅"> <el-input v-model="stationValue.startLocatNo"></el-input> @@ -77,8 +76,7 @@ <el-form-item label="浠诲姟绫诲瀷"> <el-select clearable="" v-model="deviceInfo.taskType" placeholder="璇烽�夋嫨鐘舵��"> <el-option v-for="(item, index) in dl('TaskTypeEnum')" :key="index" - :value="Number(item.value)" - :label="`${item.name} [${item.value}] `" /> + :value="Number(item.value)" :label="`${item.name} [${item.value}] `" /> </el-select> </el-form-item> <el-form-item label="璧峰宸ヤ綅"> @@ -116,17 +114,17 @@ import { ref, reactive } from 'vue'; import { listWcsDevice } from '/@/api/wcs/wcsDevice'; import { getDictDataItem as di, getDictDataList as dl } from '/@/utils/dict-utils'; -import { getDictLabelByVal as dv } from '/@/utils/dict-utils'; +import { listWcsPlc } from '/@/api/wcs/wcsPlc'; const stations = ref<any>([]); const listStationsData = ref<any>([]); const listStackingMachineData = ref<any>([]); - +const lineOptions = ref<any>([]); const lineValue = ref(1); const stationValue = ref<any>({ taskNo: '', taskType: '', - startLocatNo:'', + startLocatNo: '', endLocatNo: '', plc: '', wcs: '', @@ -135,16 +133,17 @@ // 鏌ヨ鎿嶄綔 const handleQuery = async () => { + var listplc = await listWcsPlc({ type: 1 }); + lineOptions.value = listplc.data.result; + lineValue.value = listplc.data.result[0].id; var res = await listWcsDevice(); listStackingMachineData.value = res.data.result.filter(s => s.type == 0); - const listConveyorLineData = res.data.result.filter(s => s.type == 1 || s.type == 4); - stations.value = { - 1: listConveyorLineData.filter(s => s.text == '1灞傛墭鐩樿緭閫佺嚎'), - 2: listConveyorLineData.filter(s => s.text == '2灞傛墭鐩樿緭閫佺嚎'), - 3: listConveyorLineData.filter(s => s.text == '3灞傛墭鐩樿緭閫佺嚎') - } - if (stations.value[1].length > 0) { - listStationsData.value = stations.value[1]; + const listConveyorLineData = res.data.result.filter(s => s.type == 1); + listplc.data.result.forEach(s => { + stations.value[s.id] = listConveyorLineData.filter(c => c.plcId === s.id) + }); + if (stations.value[lineValue.value].length > 0) { + listStationsData.value = stations.value[lineValue.value]; stationValue.value = listStationsData.value[0]; } }; @@ -152,15 +151,9 @@ const handleLineChange = (field: string, value: number) => { listStationsData.value = stations.value[value]; - stationValue.value = {}; + if (listStationsData.value.length > 0) + stationValue.value = listStationsData.value[0]; }; - - -const lineOptions = [ - { value: 1, label: '涓�妤艰緭閫佺嚎' }, - { value: 2, label: '浜屾ゼ杈撻�佺嚎' }, - { value: 3, label: '涓夋ゼ杈撻�佺嚎' } -]; </script> -- Gitblit v1.8.0