From 6bab172dc8767e93c8889c15a146c76e4d38e9c0 Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期六, 27 七月 2024 09:23:04 +0800 Subject: [PATCH] 电磁锁报警查询bug修改提交 --- ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java | 52 ++++++++++++++++++++++++++++------------------------ 1 files changed, 28 insertions(+), 24 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java index ce166a3..ee4a60d 100644 --- a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java +++ b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplSerialPort.java @@ -113,6 +113,25 @@ Date now = new Date(); try { String data = (String) dataMap.get("data"); + if(data.length() %2 != 0){//闀垮害涓嶆槸鍋舵暟锛屽氨杩斿洖 + return; + } + + Integer sum = 0; + for(int i = 0;i <= data.length() - 4;i = i + 2){ + String str = data.substring(i, i + 2); + sum = sum + Integer.parseInt(str, 16); + }//姹傚拰 + String checkNum = data.substring(data.length() - 2, data.length()); + String checkNumComputed = Integer.toHexString(sum).toUpperCase();//璁$畻鏍¢獙 + //褰撴牎楠屾暟鎹ぇ浜�2涓瓧绗︼紝鎴彇鏈�鍚庝袱浣� + if(checkNumComputed.length() != 2){ + checkNumComputed = checkNumComputed.substring(checkNumComputed.length() - 2,checkNumComputed.length()); + } + if(!checkNum.equals(checkNumComputed)){//鏍¢獙涓嶉�氳繃锛屽氨杩斿洖 + return; + } + String lockNum = data.substring(0, 4); String code = data.substring(4, 6); if(code.equals("01")){//鍔熻兘鐮�01涓洪攣瀹炴椂鐘舵�� @@ -182,80 +201,63 @@ } long cha = now.getTime() - sdf.parse(time).getTime(); - System.out.println("////////////////"); - System.out.println(time); - System.out.println(cha); - /*if(Math.abs(cha) >= 5 * 1000){ + if(Math.abs(cha) >= 5 * 1000){ //鏃堕棿鏍″噯 - String url = "http://" + ip + ":9999"; + /*String url = "http://" + ip + ":9999"; String passwordMd5 = DigestUtils.md5Hex(password); Map<String, Object> LogInResult = loginIn(url, userId, passwordMd5); String sessionId = (String) LogInResult.get("sessionId"); //鑾峰彇鏃堕棿骞舵媶鍒嗗勾鏈堟棩鏃跺垎绉� String nowTime = sdf.format(now); String nowYear = nowTime.substring(2,4); - System.out.println(nowYear); String nowMonth = nowTime.substring(5,7); - System.out.println(nowMonth); String nowDay = nowTime.substring(8,10); - System.out.println(nowDay); String nowHour = nowTime.substring(11,13); - System.out.println(nowHour); String nowMinute = nowTime.substring(14,16); - System.out.println(nowMinute); String nowSecond = nowTime.substring(17,19); - System.out.println(nowSecond); String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear)); if(nowYearHex.length() == 1){ nowYearHex = "0" + nowYearHex; } - System.out.println(nowYearHex); String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth)); if(nowMonthHex.length() == 1){ nowMonthHex = "0" + nowMonthHex; } - System.out.println(nowMonthHex); String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay)); if(nowDayHex.length() == 1){ nowDayHex = "0" + nowDayHex; } - System.out.println(nowDayHex); String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour)); if(nowHourHex.length() == 1){ nowHourHex = "0" + nowHourHex; } - System.out.println(nowHourHex); String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute)); if(nowMinuteHex.length() == 1){ nowMinuteHex = "0" + nowMinuteHex; } - System.out.println(nowMinuteHex); String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond)); if(nowSecondHex.length() == 1){ nowSecondHex = "0" + nowSecondHex; } - System.out.println(nowSecondHex); //16杩涘埗鏃堕棿 String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex; - System.out.println(timeHex); String lockNumHead = ardTankLockResult.get(0).getLockNum().substring(0,2); String lockNumTail = ardTankLockResult.get(0).getLockNum().substring(2,4); //璁$畻鏍¢獙 String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("08", 16) + Integer.parseInt(nowYearHex, 16) + Integer.parseInt(nowMonthHex, 16) + Integer.parseInt(nowDayHex, 16) + Integer.parseInt(nowHourHex, 16) + Integer.parseInt(nowMinuteHex, 16) + Integer.parseInt(nowSecondHex, 16)); - System.out.println(checkNum); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } - System.out.println(checkNum); String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D"; System.out.println(ardTankLock.getLockNum() + "08" + timeHex + checkNum); - sendCmd(url,userId,ardTankLockResult.get(0).getCarId(),199,"DataDownTransfer", paramsStr,sessionId); - }else{*/ + sendCmd(url,userId,ardTankLockResult.get(0).getCarId(),199,"DataDownTransfer", paramsStr,sessionId);*/ + return; + }else{ ArdTankLockState ardTankLockState = new ArdTankLockState(); ardTankLockState.setId(IdUtils.simpleUUID()); ardTankLockState.setLockId(ardTankLockResult.get(0).getId()); @@ -264,6 +266,7 @@ case "01": ardTankLockState.setLockState("寮�閿佺姸鎬�");break; case "02": ardTankLockState.setLockState("鍏抽攣鐘舵��");break; case "03": ardTankLockState.setLockState("寮傚父鐘舵��");break; + case "04": ardTankLockState.setLockState("鍔ㄤ綔鐘舵��");break; default: break; } @@ -326,9 +329,10 @@ ardTankLockState.setUploadTime(time); ardTankLockState.setUniqueMark(uniqueMark); ((ArdTankLockStateServiceImpl)SpringUtils.getBean("ardTankLockStateServiceImpl")).insertOrUpdateArdTankLockState(ardTankLockState); + } + }/*else if(code.equals("06")){//鍔熻兘鐮�06涓洪攣鍘嗗彶鎶ヨ - //} - } + }*/ }catch (Exception e){ e.printStackTrace(); return;//寮鸿浆澶辫触杩斿洖 -- Gitblit v1.9.3