| | |
| | | }; |
| | | passwordTimer.scheduleAtFixedRate(passwordTask,date,11000); |
| | | |
| | | Timer lockRestartStateTimer = new Timer();//定时各个锁的复位状态 |
| | | TimerTask lockRestartStateTask =new TimerTask(){ |
| | | @Override |
| | | public void run(){ |
| | | Thread thread = new Thread(){ |
| | | @Override |
| | | public void run() { |
| | | 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"); |
| | | |
| | | String finalSyURL = syURL; |
| | | |
| | | List<ArdTankLock> result = ardTankLockService.getArdTankLockAllWithState();//查询全部电磁锁及最终状态 |
| | | for(ArdTankLock ardTankLock : result){ |
| | | String restartState = ardTankLock.getRestartState(); |
| | | String sRestartState = ""; |
| | | if(ardTankLock.getArdTankLockState() != null){ |
| | | sRestartState = ardTankLock.getArdTankLockState().getRestartState(); |
| | | } |
| | | |
| | | if(sRestartState.equals("")){ |
| | | continue; |
| | | }else{ |
| | | sRestartState = sRestartState.substring(0,2); |
| | | if(!restartState.equals(sRestartState)){ |
| | | Thread lockThread = new Thread(finalSyURL){ |
| | | @Override |
| | | public void run() { |
| | | String process = ""; |
| | | if(restartState.equals("开锁")){ |
| | | process = "01"; |
| | | }else if(restartState.equals("关锁")){ |
| | | process = "02"; |
| | | }else{ |
| | | return; |
| | | } |
| | | |
| | | 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("03", 16) + Integer.parseInt(process, 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() + "03" + process + checkNum + "%22%7D"; |
| | | |
| | | sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); |
| | | } |
| | | }; |
| | | lockThread.start(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | thread.start(); |
| | | } |
| | | }; |
| | | lockRestartStateTimer.scheduleAtFixedRate(lockRestartStateTask,date,9000); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | public String getIdByLockNum(String lockNum); |
| | | |
| | | public List<ArdTankLock> selectArdTankLockWithPassword(); |
| | | |
| | | public List<ArdTankLock> getArdTankLockAllWithState(); |
| | | } |
| | |
| | | |
| | | public void readPassword(String userId,String password); |
| | | |
| | | public List<ArdTankLock> getArdTankLockAllWithState(); |
| | | |
| | | //public void getAlarm(String syUserId,String syPassword); |
| | | } |
| | |
| | | passwordThread.start(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdTankLock> getArdTankLockAllWithState() { |
| | | List<ArdTankLock> result = ardTankLockMapper.getArdTankLockAllWithState(); |
| | | return result; |
| | | } |
| | | |
| | | /*@Override |
| | | public void getAlarm(String syUserId,String syPassword) { |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | |
| | | atlp.create_time,atlp.use_time from ard_tank_lock atl |
| | | left join ard_tank_lock_password atlp on atl.id = atlp.lock_id and use_time is null |
| | | </select> |
| | | |
| | | <select id="getArdTankLockAllWithState" resultMap="ArdTankLockWithStateResult" > |
| | | select t.id,t.lock_num,t.lock_name,t.img_position_top,t.img_position_left, |
| | | t.car_id,t.enable,t.restart_state,t.online_time,t.sid,t.lock_id,t.slock_num, |
| | | t.lock_state,t.lock_position_state,t.lock_shell_state,t.srestart_state, |
| | | t.batter_voltage,t.power_voltage,t.upload_time,t.unique_mark, |
| | | t.lock_state_mark from (select atl.id,atl.lock_num,atl.lock_name,atl.img_position_top, |
| | | atl.img_position_left,atl.car_id,atl.enable,atl.restart_state, |
| | | coalesce(atl.online_time,'') as online_time,coalesce(atls.id,'') as sid, |
| | | coalesce(atls.lock_id,'') as lock_id,coalesce(atls.lock_num,'') as slock_num, |
| | | coalesce(atls.lock_state,'') as lock_state,coalesce(atls.lock_position_state,'') as lock_position_state, |
| | | coalesce(atls.lock_shell_state,'') as lock_shell_state,coalesce(atls.restart_state,'') as srestart_state, |
| | | coalesce(atls.batter_voltage,'') as batter_voltage,coalesce(atls.power_voltage,'') as power_voltage, |
| | | coalesce(atls.upload_time,'') as upload_time,coalesce(atls.unique_mark,'') as unique_mark, |
| | | case atls.lock_state |
| | | when '关锁状态' then false |
| | | when '异常状态' then false |
| | | when '动作状态' then false |
| | | when '开锁状态' then true |
| | | else false |
| | | end as lock_state_mark, |
| | | rank() over(partition by atl.lock_num order by atls.upload_time desc,atl.lock_num) rn |
| | | from ard_tank_lock atl |
| | | left join ard_tank_lock_state atls on atl."id" = atls.lock_id)t where t.rn = 1 |
| | | </select> |
| | | </mapper> |