ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -153,6 +153,17 @@ //删除结束时间为null的记录 int result = ardTankAbnormalParkAlarmService.deleteArdTankAbnormalParkAlarmByEndTime(); List<ArdSyCar> ardSyCarAndLockList = ardSyCarService.selectArdSyCarAndTankLock();//查询全部罐车及下挂电磁锁 for(ArdSyCar ardSyCar : ardSyCarAndLockList){//构造容器 Map<String,Map<String,Thread>> carMap = new HashMap();//车辆容器 for(ArdTankLock ardTankLock : ardSyCar.getArdTankLockList()){ Map<String,Thread> lockMap = new HashMap();//锁容器 carMap.put(ardTankLock.getLockNum(),lockMap); } PositionContainer.getCarLockProcessThreadMap().put(ardSyCar.getCarId(),carMap); } Timer lockStateTimer = new Timer();//定时获取各个锁的状态 TimerTask lockStateTask =new TimerTask(){ @Override @@ -193,11 +204,17 @@ } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "01" + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); try{ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockState"); }catch(Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockState"); } } }; lockThread.start(); //lockThread.start(); //将状态线程放入容器 PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockState",lockThread); } } }; @@ -209,86 +226,92 @@ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Timer lockCheckTimeTimer = new Timer();//定时校准时间 TimerTask lockCheckTimeTask =new TimerTask(){ TimerTask lockCheckTimeTask = new TimerTask(){ @Override public void run() { SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; if(sysConfigResult.size() == 0){ return; }else{ syURL = sysConfigResult.get(0).getConfigValue(); } String passwordMd5 = DigestUtils.md5Hex(password); Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId); String sessionId = (String) LogInResult.get("sessionId"); if(sysConfigResult.size() == 0){ return; }else{ syURL = sysConfigResult.get(0).getConfigValue(); } String passwordMd5 = DigestUtils.md5Hex(password); Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId); String sessionId = (String) LogInResult.get("sessionId"); String finalSyURL = syURL; String finalSyURL = syURL; List<ArdTankLock> result = ardTankLockService.getArdTankLockAll();//查询全部电磁锁 for(ArdTankLock ardTankLock : result){ Thread lockThread = new Thread(finalSyURL){ @Override public void run() { //获取时间并拆分年月日时分秒 String nowTime = sdf.format(new Date()); String nowYear = nowTime.substring(2,4); String nowMonth = nowTime.substring(5,7); String nowDay = nowTime.substring(8,10); String nowHour = nowTime.substring(11,13); String nowMinute = nowTime.substring(14,16); String nowSecond = nowTime.substring(17,19); List<ArdTankLock> result = ardTankLockService.getArdTankLockAll();//查询全部电磁锁 for(ArdTankLock ardTankLock : result){ Thread lockThread = new Thread(finalSyURL){ @Override public void run() { //获取时间并拆分年月日时分秒 String nowTime = sdf.format(new Date()); String nowYear = nowTime.substring(2,4); String nowMonth = nowTime.substring(5,7); String nowDay = nowTime.substring(8,10); String nowHour = nowTime.substring(11,13); String nowMinute = nowTime.substring(14,16); String nowSecond = nowTime.substring(17,19); String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear)); if(nowYearHex.length() == 1){ nowYearHex = "0" + nowYearHex; String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear)); if(nowYearHex.length() == 1){ nowYearHex = "0" + nowYearHex; } String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth)); if(nowMonthHex.length() == 1){ nowMonthHex = "0" + nowMonthHex; } String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay)); if(nowDayHex.length() == 1){ nowDayHex = "0" + nowDayHex; } String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour)); if(nowHourHex.length() == 1){ nowHourHex = "0" + nowHourHex; } String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute)); if(nowMinuteHex.length() == 1){ nowMinuteHex = "0" + nowMinuteHex; } String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond)); if(nowSecondHex.length() == 1){ nowSecondHex = "0" + nowSecondHex; } //16进制时间 String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex; String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.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)); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D"; try{ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockTime"); }catch(Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockTime"); } } String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth)); if(nowMonthHex.length() == 1){ nowMonthHex = "0" + nowMonthHex; } String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay)); if(nowDayHex.length() == 1){ nowDayHex = "0" + nowDayHex; } String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour)); if(nowHourHex.length() == 1){ nowHourHex = "0" + nowHourHex; } String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute)); if(nowMinuteHex.length() == 1){ nowMinuteHex = "0" + nowMinuteHex; } String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond)); if(nowSecondHex.length() == 1){ nowSecondHex = "0" + nowSecondHex; } //16进制时间 String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex; String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.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)); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); } }; lockThread.start(); } }; //lockThread.start(); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockTime",lockThread); } } }; lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,7000); //lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,7000); lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,67000); Timer sendTimer = new Timer();//定时发送锁状态 TimerTask sendLockStateTask = new TimerTask(){ @@ -314,10 +337,11 @@ ardTankLockService.readPassword(userId,password); } }; passwordTimer.scheduleAtFixedRate(passwordTask,date,11000); //passwordTimer.scheduleAtFixedRate(passwordTask,date,11000); passwordTimer.scheduleAtFixedRate(passwordTask,date,13000); Timer lockRestartStateTimer = new Timer();//定时各个锁的复位状态 TimerTask lockRestartStateTask =new TimerTask(){ TimerTask lockRestartStateTask = new TimerTask(){ @Override public void run(){ Thread thread = new Thread(){ @@ -376,11 +400,16 @@ } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "03" + process + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); try{ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockRestart"); }catch (Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockRestart"); } } }; lockThread.start(); //lockThread.start(); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockRestart",lockThread); } } } @@ -389,7 +418,82 @@ thread.start(); } }; lockRestartStateTimer.scheduleAtFixedRate(lockRestartStateTask,date,9000); lockRestartStateTimer.scheduleAtFixedRate(lockRestartStateTask,date,17000); Set<String> lockNumSet = new HashSet();//存放发送过的锁编号 Timer mainLockTimer = new Timer();//主定时器 TimerTask mainLockTask = new TimerTask(){ @Override public void run() { Long count = ardTankLockService.getArdTankLockCount(); if(lockNumSet.size() >= count){//防止锁被删除,采用大于等于 lockNumSet.clear();//全部执行过,清空容器 } for(String carId : PositionContainer.getCarLockProcessThreadMap().keySet()){ Thread thread = new Thread(){ @Override public void run() { Map<String, Map<String,Thread>> lockMap = PositionContainer.getCarLockProcessThreadMap().get(carId); for(String lockNum : lockMap.keySet()){ if(lockNumSet.contains(lockNum)){//若执行过,本次忽略 continue; } if(lockMap.get(lockNum).get("lockProcess") != null){ break;//锁操作级别最高 }else{ if(lockMap.get(lockNum).get("lockTime") != null){ if(lockMap.get(lockNum).get("lockTime").isAlive()){ lockNumSet.add(lockNum); break;//锁校时次之 }else{ lockMap.get(lockNum).get("lockTime").start(); lockNumSet.add(lockNum); break;//锁校时次之 } }else{ if(lockMap.get(lockNum).get("lockPassword") != null){ if(lockMap.get(lockNum).get("lockPassword").isAlive()){ lockNumSet.add(lockNum); break;//锁密码次之 }else{ lockMap.get(lockNum).get("lockPassword").start(); lockNumSet.add(lockNum); break;//锁密码次之 } }else{ if(lockMap.get(lockNum).get("lockRestart") != null) { if(lockMap.get(lockNum).get("lockRestart").isAlive()){ lockNumSet.add(lockNum); }else{ lockMap.get(lockNum).get("lockRestart").start(); lockNumSet.add(lockNum); break;//锁复位次之 } }else{ if(lockMap.get(lockNum).get("lockState") != null) { if(lockMap.get(lockNum).get("lockState").isAlive()){ lockNumSet.add(lockNum); }else{ lockMap.get(lockNum).get("lockState").start(); lockNumSet.add(lockNum); break;//锁状态次之 } }else{ break; } } } } } } } }; thread.start(); } } }; mainLockTimer.scheduleAtFixedRate(mainLockTask,date,2000); } ard-work/src/main/java/com/ruoyi/sy/gps31/PositionContainer.java
@@ -19,7 +19,7 @@ private static Map<String, Set<String>> carLockPasswordMap = new HashMap();//依电磁锁编号存放生成的密码 private static Map<String, Map<String, Map<String,Thread>>> carLockProcessThreadMap = new HashMap();//依车辆,电磁锁,操作类型存放线程;lockState:锁状态,lockTime:锁校时,lockPassword:锁密码(包括读写),lockRestart:锁复位,lockProcess:锁操作 public static Map<String, List<ArdSyCarLock>> getTopicSubscribe() { return topicSubscribe; @@ -72,4 +72,11 @@ PositionContainer.carLockPasswordMap = carLockPasswordMap; } public static synchronized Map<String, Map<String, Map<String, Thread>>> getCarLockProcessThreadMap() { return carLockProcessThreadMap; } public static synchronized void setCarLockProcessThreadMap(Map<String, Map<String, Map<String, Thread>>> carLockProcessThreadMap) { PositionContainer.carLockProcessThreadMap = carLockProcessThreadMap; } } ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyCarMapper.java
@@ -96,4 +96,6 @@ public List<ArdSyCar> selectArdSyCarAndTankLockByUserId(String userId); public List<ArdSyCar> selectByBrandAndType(@Param("carBrand")String carBrand,@Param("carType")String carType); public List<ArdSyCar> selectArdSyCarAndTankLock(); } ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockMapper.java
@@ -87,4 +87,6 @@ public List<ArdTankLock> selectArdTankLockWithPassword(); public List<ArdTankLock> getArdTankLockAllWithState(); public Long getArdTankLockCount(); } ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
@@ -165,4 +165,6 @@ Map<String, Object> getAlarmHPfmCountDetail(String sessionId,String usersId,String carId,String startTime,String endTime,String syURL); public Map<String,Object> getOnlineSYCarPosition(String soilderId); public List<ArdSyCar> selectArdSyCarAndTankLock(); } ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockService.java
@@ -81,5 +81,7 @@ public List<ArdTankLock> getArdTankLockAllWithState(); public Long getArdTankLockCount(); //public void getAlarm(String syUserId,String syPassword); } ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -1553,6 +1553,12 @@ } } @Override public List<ArdSyCar> selectArdSyCarAndTankLock() { List<ArdSyCar> result = ardSyCarMapper.selectArdSyCarAndTankLock(); return result; } public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){ deptIdListr.addAll(deptIdList); List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList); ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockProcessLogServiceImpl.java
@@ -12,6 +12,7 @@ import com.ruoyi.sy.domain.ArdSyUser; import com.ruoyi.sy.domain.ArdTankLock; import com.ruoyi.sy.domain.ArdTankWall; import com.ruoyi.sy.gps31.PositionContainer; import com.ruoyi.sy.mapper.ArdSyUserMapper; import com.ruoyi.sy.mapper.ArdTankLockMapper; import com.ruoyi.sy.mapper.ArdTankWallMapper; @@ -208,7 +209,9 @@ String paramsStr = lockNum + "02" + process + checkNum; paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + paramsStr + "%22%7D"; PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).put("lockProcess",new Thread());//加入容器 Map<String,Object> result = sendCmd(syURL, ardSyUser.getUserId(), carId, 199, "DataDownTransfer", paramsStr, sessionId); PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).remove("lockProcess");//移除容器 if(((String)result.get("rspCode")).equals("0")){ ArdTankLockProcessLog ardTankLockProcessLog = new ArdTankLockProcessLog(); ardTankLockProcessLog.setId(IdUtils.simpleUUID()); @@ -252,6 +255,7 @@ } }catch(Exception e){ e.printStackTrace(); PositionContainer.getCarLockProcessThreadMap().get(carId).get(lockNum).remove("lockProcess");//移除容器 return AjaxResult.error("发送失败" + e.toString()); } } ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockServiceImpl.java
@@ -110,7 +110,24 @@ ardTankLock.setRestartState(map.get("restartState")); ardTankLocks.add(ardTankLock); } return ardTankLockMapper.insertArdTankLocks(ardTankLocks); try{ return ardTankLockMapper.insertArdTankLocks(ardTankLocks); }finally { if(PositionContainer.getCarLockProcessThreadMap().keySet().contains(carId)){ Map<String, Map<String,Thread>> lockMap = PositionContainer.getCarLockProcessThreadMap().get(carId); for(Map<String,String> map : lockList){ Map<String,Thread> lockThreadMap = new HashMap(); lockMap.put(map.get("lockNum"),lockThreadMap); } }else{ Map<String,Map<String,Thread>> carMap = new HashMap();//车辆容器 for(Map<String,String> map : lockList){ Map<String,Thread> lockMap = new HashMap();//锁容器 carMap.put(map.get("lockNum"),lockMap); } PositionContainer.getCarLockProcessThreadMap().put(carId,carMap); } } } /*@Override public int insertArdTankLock(ArdTankLock ardTankLock) { @@ -312,7 +329,11 @@ @Override public int deleteLockByCarId(String carId) { int result = ardTankLockMapper.deleteLockByCarId(carId); return result; try{ return result; }finally { PositionContainer.getCarLockProcessThreadMap().remove(carId);//移除容器 } } @Override @@ -331,7 +352,11 @@ return 1; } result = ardTankLockMapper.deleteLockByCarId(carId); return result; try{ return result; }finally { PositionContainer.getCarLockProcessThreadMap().get(carId).clear(); } } List<ArdTankLock> ardTankLocks = new ArrayList(); @@ -362,6 +387,22 @@ ardTankLocks.add(ardTankLock); } } //更新容器 if(PositionContainer.getCarLockProcessThreadMap().keySet().contains(carId)){ Map<String, Map<String,Thread>> lockMap = PositionContainer.getCarLockProcessThreadMap().get(carId); for(Map<String,Object> map : lockList){ Map<String,Thread> lockThreadMap = new HashMap(); lockMap.put((String) map.get("lockNum"),lockThreadMap); } }else{ Map<String,Map<String,Thread>> carMap = new HashMap();//车辆容器 for(Map<String,Object> map : lockList){ Map<String,Thread> lockMap = new HashMap();//锁容器 carMap.put((String) map.get("lockNum"),lockMap); } PositionContainer.getCarLockProcessThreadMap().put(carId,carMap); } if(ardTankLocks.size() != 0){ result = result + ardTankLockMapper.insertArdTankLocks(ardTankLocks); } @@ -696,36 +737,29 @@ } data = data + checkNum; String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + data + "%22%7D"; Map<String,Object> syResult = sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); if(((String)syResult.get("rspCode")).equals("0")){ List<ArdTankLockPassword> ardTankLockPasswordList = new ArrayList(); int i = 0; for(String password : passwordSet){ ArdTankLockPassword ardTankLockPassword = new ArdTankLockPassword(); ardTankLockPassword.setId(IdUtils.simpleUUID()); ardTankLockPassword.setLockId(ardTankLock.getLockNum());//暂存锁编号 ardTankLockPassword.setPassword(password); ardTankLockPassword.setNo(String.valueOf(i)); ardTankLockPasswordList.add(ardTankLockPassword); i = i + 1; try{ Map<String,Object> syResult = sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); if(((String)syResult.get("rspCode")).equals("0")){ List<ArdTankLockPassword> ardTankLockPasswordList = new ArrayList(); int i = 0; for(String password : passwordSet){ ArdTankLockPassword ardTankLockPassword = new ArdTankLockPassword(); ardTankLockPassword.setId(IdUtils.simpleUUID()); ardTankLockPassword.setLockId(ardTankLock.getLockNum());//暂存锁编号 ardTankLockPassword.setPassword(password); ardTankLockPassword.setNo(String.valueOf(i)); ardTankLockPasswordList.add(ardTankLockPassword); i = i + 1; } int result = ardTankLockPasswordMapper.insertArdTankLockPasswordList(ardTankLockPasswordList); PositionContainer.getCarLockPasswordMap().remove(ardTankLock.getLockNum()); } int result = ardTankLockPasswordMapper.insertArdTankLockPasswordList(ardTankLockPasswordList); PositionContainer.getCarLockPasswordMap().remove(ardTankLock.getLockNum()); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); }catch (Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); } }else{//读取密码 /*String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.getLockNum().substring(2,4); //计算校验 String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("05", 16)); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "05" + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);*/ Set<String> passwordSet = new HashSet(); while(passwordSet.size() != 10){ String password = ""; @@ -734,8 +768,6 @@ } passwordSet.add(password); } System.out.println("1111111111111111"); System.out.println(passwordSet); //设置新密码 String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.getLockNum().substring(2,4); @@ -762,20 +794,25 @@ } data = data + checkNum; String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + data + "%22%7D"; Map<String,Object> syResult = sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); if(((String)syResult.get("rspCode")).equals("0")){ List<ArdTankLockPassword> ardTankLockPasswordList = new ArrayList(); int i = 0; for(String password : passwordSet){ ArdTankLockPassword ardTankLockPassword = new ArdTankLockPassword(); ardTankLockPassword.setId(IdUtils.simpleUUID()); ardTankLockPassword.setLockId(ardTankLock.getLockNum());//暂存锁编号 ardTankLockPassword.setPassword(password); ardTankLockPassword.setNo(String.valueOf(i)); ardTankLockPasswordList.add(ardTankLockPassword); i = i + 1; try{ Map<String,Object> syResult = sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); if(((String)syResult.get("rspCode")).equals("0")){ List<ArdTankLockPassword> ardTankLockPasswordList = new ArrayList(); int i = 0; for(String password : passwordSet){ ArdTankLockPassword ardTankLockPassword = new ArdTankLockPassword(); ardTankLockPassword.setId(IdUtils.simpleUUID()); ardTankLockPassword.setLockId(ardTankLock.getLockNum());//暂存锁编号 ardTankLockPassword.setPassword(password); ardTankLockPassword.setNo(String.valueOf(i)); ardTankLockPasswordList.add(ardTankLockPassword); i = i + 1; } int result = ardTankLockPasswordMapper.insertArdTankLockPasswordList(ardTankLockPasswordList); } int result = ardTankLockPasswordMapper.insertArdTankLockPasswordList(ardTankLockPasswordList); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); }catch(Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); } } }else{ @@ -790,12 +827,17 @@ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "05" + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); try{ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); }catch (Exception e){ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockPassword"); } } } }; lockThread.start(); //lockThread.start(); PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockPassword",lockThread); } } @@ -809,6 +851,12 @@ return result; } @Override public Long getArdTankLockCount() { Long result = ardTankLockMapper.getArdTankLockCount(); return result; } /*@Override public void getAlarm(String syUserId,String syPassword) { List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockStateServiceImpl.java
@@ -109,15 +109,9 @@ ardTankLockMapper.updateArdTankLock(ardTankLock);//更改状态 }*/ try{ System.out.println("////////////"); System.out.println(ardTankLockState.getLockState()); System.out.println(ardTankLockState.getUniqueMark()); int result = ardTankLockStateMapper.insertArdTankLockState(ardTankLockState); return result; }catch(Exception e){ System.out.println("111111111111"); System.out.println(ardTankLockState.getLockState()); System.out.println(ardTankLockState.getUniqueMark()); int result = ardTankLockStateMapper.updateArdTankLockStateByUniqueMark(ardTankLockState.getUniqueMark(),ardTankLockState.getUploadTime()); return result; }finally { ard-work/src/main/resources/mapper/sy/ArdSyCarMapper.xml
@@ -187,4 +187,14 @@ <if test="carBrand != null and carBrand != ''"> and car_brand = #{carBrand}</if> </where> </select> <select id="selectArdSyCarAndTankLock" resultMap="ArdSyCarLockResult" > select "asc".id,"asc".car_id,"asc".car_model,"asc".car_type, "asc".car_brand,"asc".dept_id,"asc".car_picture,atl.id as lid, atl.lock_num,atl.lock_name,atl.img_position_top,atl.img_position_left, atl.car_id as lcar_id,atl.enable,coalesce(atl.restart_state,'') as restart_state, coalesce(atl.online_time,'') as online_time from ard_sy_car "asc" inner join ard_tank_lock atl on "asc".car_id = atl.car_id order by "asc".car_id desc,atl.lock_num </select> </mapper> ard-work/src/main/resources/mapper/sy/ArdTankLockMapper.xml
@@ -170,7 +170,8 @@ case atls.lock_state when '关锁状态' then false when '异常状态' then false when '动作状态' then false /*when '动作状态' then false*/ when '操控中...' then false when '开锁状态' then true else false end as lock_state_mark, @@ -257,7 +258,8 @@ case atls.lock_state when '关锁状态' then false when '异常状态' then false when '动作状态' then false /*when '动作状态' then false*/ when '操控中...' then false when '开锁状态' then true else false end as lock_state_mark, @@ -265,4 +267,8 @@ from ard_tank_lock atl left join ard_tank_lock_state atls on atl."id" = atls.lock_id)t where t.rn = 1 </select> <select id="getArdTankLockCount" resultType="java.lang.Long" > select count(*) from ard_tank_lock </select> </mapper>