| | |
| | | ardTankLock.setImgPositionLeft(map.get("imgPositionLeft")); |
| | | ardTankLock.setCarId(carId); |
| | | ardTankLock.setEnable(map.get("enable")); |
| | | 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) { |
| | |
| | | @Override |
| | | public int deleteLockByCarId(String carId) { |
| | | int result = ardTankLockMapper.deleteLockByCarId(carId); |
| | | return result; |
| | | try{ |
| | | return result; |
| | | }finally { |
| | | PositionContainer.getCarLockProcessThreadMap().remove(carId);//移除容器 |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | return 1; |
| | | } |
| | | result = ardTankLockMapper.deleteLockByCarId(carId); |
| | | return result; |
| | | try{ |
| | | return result; |
| | | }finally { |
| | | PositionContainer.getCarLockProcessThreadMap().get(carId).clear(); |
| | | } |
| | | } |
| | | |
| | | List<ArdTankLock> ardTankLocks = new ArrayList(); |
| | |
| | | ardTankLock.setImgPositionLeft((String) map.get("imgPositionLeft")); |
| | | ardTankLock.setCarId((String) map.get("carId")); |
| | | ardTankLock.setEnable((String) map.get("enable")); |
| | | ardTankLock.setRestartState((String) map.get("restartState")); |
| | | result = result + ardTankLockMapper.updateArdTankLock(ardTankLock); |
| | | }else{//无主键,做新增操作 |
| | | ArdTankLock ardTankLock = new ArdTankLock(); |
| | |
| | | ardTankLock.setImgPositionTop((String) map.get("imgPositionTop")); |
| | | ardTankLock.setImgPositionLeft((String) map.get("imgPositionLeft")); |
| | | ardTankLock.setCarId(carId); |
| | | ardTankLock.setRestartState((String) map.get("restartState")); |
| | | ardTankLock.setEnable((String) map.get("enable")); |
| | | 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); |
| | | } |
| | |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | String finalSyURL = syURL; |
| | | Thread passwordThread = new Thread(syURL){ |
| | | Thread passwordThread = new Thread(){ |
| | | @Override |
| | | public void run() { |
| | | List<ArdTankLock> ardTankLockResult = ardTankLockMapper.selectArdTankLockWithPassword(); |
| | |
| | | } |
| | | 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 = ""; |
| | |
| | | } |
| | | 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); |
| | |
| | | } |
| | | 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{ |
| | |
| | | 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(); |
| | | if(PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).get("lockPassword") == null){ |
| | | PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockPassword",lockThread); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | passwordThread.start(); |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdTankLock> getArdTankLockAllWithState() { |
| | | List<ArdTankLock> result = ardTankLockMapper.getArdTankLockAllWithState(); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Long getArdTankLockCount() { |
| | | Long result = ardTankLockMapper.getArdTankLockCount(); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public int updateLockEnableByCarId(Map<String, Object> para) { |
| | | String carId = (String) para.get("carId"); |
| | | String enable = String.valueOf((Boolean) para.get("enable")); |
| | | int result = ardTankLockMapper.updateLockEnableByCarId(carId, enable); |
| | | return result; |
| | | } |
| | | |
| | | /*@Override |
| | | public void getAlarm(String syUserId,String syPassword) { |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |