| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.sy.domain.ArdSyCarDay; |
| | | import com.ruoyi.sy.mapper.ArdSyCarDayMapper; |
| | | import com.ruoyi.utils.tools.GisTool; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.device.hiksdk.config.MinioClientSingleton; |
| | | import com.ruoyi.storage.minio.utils.MinioUtils; |
| | |
| | | import io.minio.Result; |
| | | import io.minio.http.Method; |
| | | import io.minio.messages.Item; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import okhttp3.OkHttpClient; |
| | | import okhttp3.Request; |
| | | import okhttp3.Response; |
| | |
| | | * @date 2023-06-26 |
| | | */ |
| | | @Service |
| | | @Slf4j(topic = "sy") |
| | | public class ArdSyCarServiceImpl implements IArdSyCarService { |
| | | @Resource |
| | | private ArdSyCarMapper ardSyCarMapper; |
| | |
| | | |
| | | @Resource |
| | | private SYClient sYClient; |
| | | |
| | | @Resource |
| | | RedisCache redisCache; |
| | | @Resource |
| | | private ArdSyCarDayMapper ardSyCarDayMapper; |
| | | |
| | | private Map<Integer,Map<String,String>> logInMap = new HashMap(); |
| | | private Map<Integer, Map<String, String>> logInMap = new HashMap(); |
| | | |
| | | private Map<String, Timer> userCarTimerMap = new HashMap(); |
| | | private Map<String, Timer> userCarTimerMap = new HashMap(); |
| | | |
| | | /** |
| | | * æ¥è¯¢ä¸ä¸è½¦è¾ |
| | |
| | | */ |
| | | @Override |
| | | public int insertArdSyCar(ArdSyCar ardSyCar) { |
| | | return ardSyCarMapper.insertArdSyCar(ardSyCar); |
| | | return ardSyCarMapper.insertArdSyCar(ardSyCar); |
| | | } |
| | | |
| | | /** |
| | |
| | | public int deleteArdSyCarByIds(String[] ids) { |
| | | List<ArdSyCar> result = ardSyCarMapper.selectArdSyCarByIds(ids); |
| | | List<String> objectNames = new ArrayList(); |
| | | for(ArdSyCar ardSyCar : result){ |
| | | if(ardSyCar.getCarPicture() != null && !ardSyCar.getCarPicture().equals("")){ |
| | | for (ArdSyCar ardSyCar : result) { |
| | | if (ardSyCar.getCarPicture() != null && !ardSyCar.getCarPicture().equals("")) { |
| | | objectNames.add(ardSyCar.getCarPicture().split("/sycar/")[1]); |
| | | } |
| | | } |
| | |
| | | * è·åæªææ¥æéçä¸ä¸è½¦è¾ |
| | | */ |
| | | @Override |
| | | public Map<String,Object> getArdSyCarNoRight(String userId) { |
| | | public Map<String, Object> getArdSyCarNoRight(String userId) { |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey("syCarPT"); |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config); |
| | | String syURL = ""; |
| | | Map<String,Object> result = new HashMap(); |
| | | if(sysConfigResult.size() == 0){ |
| | | result.put("data","ä¸ä¸è½¦è¾url没æå½å
¥"); |
| | | result.put("code","500"); |
| | | Map<String, Object> result = new HashMap(); |
| | | if (sysConfigResult.size() == 0) { |
| | | result.put("data", "ä¸ä¸è½¦è¾url没æå½å
¥"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | }else{ |
| | | } else { |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); |
| | | if(ardSyUserList.size() == 0){ |
| | | result.put("data","ç¨æ·æªææ¥ä¸ä¸è½¦è¾"); |
| | | result.put("code","500"); |
| | | if (ardSyUserList.size() == 0) { |
| | | result.put("data", "ç¨æ·æªææ¥ä¸ä¸è½¦è¾"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | }else{ |
| | | } else { |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | //Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | //Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId); |
| | | if(((String)carListMap.get("rspCode")).equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list"); |
| | | Map<String, Object> carListMap = sYClient.getCarList(syURL, sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | ArdSyCar ardSyCar = new ArdSyCar(); |
| | | List<ArdSyCar> ardSyCarList = ardSyCarMapper.selectArdSyCarList(ardSyCar); |
| | | List<String> carIdList = new ArrayList(); |
| | | for(ArdSyCar innerArdSyCar : ardSyCarList){ |
| | | for (ArdSyCar innerArdSyCar : ardSyCarList) { |
| | | carIdList.add(innerArdSyCar.getCarId()); |
| | | } |
| | | |
| | | List<Map<String,Object>> carList = list.stream().filter(new Predicate<Map<String,Object>>(){ |
| | | List<Map<String, Object>> carList = list.stream().filter(new Predicate<Map<String, Object>>() { |
| | | @Override |
| | | public boolean test(Map<String,Object> map) { |
| | | return !carIdList.contains((String)map.get("carId")); |
| | | public boolean test(Map<String, Object> map) { |
| | | return !carIdList.contains((String) map.get("carId")); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | result.put("data",carList); |
| | | result.put("code","200"); |
| | | result.put("data", carList); |
| | | result.put("code", "200"); |
| | | return result; |
| | | }else{ |
| | | result.put("data","ä¸ä¸è½¦è¾å¹³å°åºé"); |
| | | result.put("code","500"); |
| | | } else { |
| | | result.put("data", "ä¸ä¸è½¦è¾å¹³å°åºé"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | config.setConfigKey("syCarPT"); |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config); |
| | | String syURL = ""; |
| | | Map<String,Object> result = new HashMap(); |
| | | if(sysConfigResult.size() == 0){ |
| | | result.put("data","ä¸ä¸è½¦è¾url没æå½å
¥"); |
| | | result.put("code","500"); |
| | | Map<String, Object> result = new HashMap(); |
| | | if (sysConfigResult.size() == 0) { |
| | | result.put("data", "ä¸ä¸è½¦è¾url没æå½å
¥"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | }else{ |
| | | } else { |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); |
| | | if(ardSyUserList.size() == 0){ |
| | | result.put("data","ç¨æ·æªææ¥ä¸ä¸è½¦è¾"); |
| | | result.put("code","500"); |
| | | if (ardSyUserList.size() == 0) { |
| | | result.put("data", "ç¨æ·æªææ¥ä¸ä¸è½¦è¾"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | }else{ |
| | | } else { |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | //Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | //Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId); |
| | | if(((String)carListMap.get("rspCode")).equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list"); |
| | | result.put("data",list); |
| | | result.put("code","200"); |
| | | Map<String, Object> carListMap = sYClient.getCarList(syURL, sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | result.put("data", list); |
| | | result.put("code", "200"); |
| | | return result; |
| | | }else{ |
| | | result.put("data","ä¸ä¸è½¦è¾å¹³å°åºé"); |
| | | result.put("code","500"); |
| | | } else { |
| | | result.put("data", "ä¸ä¸è½¦è¾å¹³å°åºé"); |
| | | result.put("code", "500"); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String,String>> getAllCarModel() { |
| | | public List<Map<String, String>> getAllCarModel() { |
| | | boolean exsit = MinioUtils.exitsBucket("sycar"); |
| | | if (exsit) { |
| | | List<Map<String,String>> listObjetcName = new ArrayList<>(); |
| | | List<Map<String, String>> listObjetcName = new ArrayList<>(); |
| | | try { |
| | | ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build(); |
| | | Iterable<Result<Item>> myObjects = MinioClientSingleton.getMinioClient().listObjects(listObjectsArgs); |
| | | for (Result<Item> result : myObjects) { |
| | | Item item = result.get(); |
| | | Map<String,String> map = new HashMap(); |
| | | map.put("carModel","sycar/" + item.objectName()); |
| | | switch(item.objectName()){ |
| | | case "carmodel/aodi.glb":map.put("carType","奥迪");break; |
| | | case "carmodel/baolai.glb":map.put("carType","宿¥");break; |
| | | case "carmodel/bieke.glb":map.put("carType","å«å
");break; |
| | | case "carmodel/bus1.glb":map.put("carType","大客车");break; |
| | | case "carmodel/car.glb":map.put("carType","å°å车");break; |
| | | case "carmodel/fire(1).glb":map.put("carType","æ¶é²è½¦");break; |
| | | case "carmodel/fute.glb":map.put("carType","ç¦ç¹");break; |
| | | case "carmodel/jingche_a.glb":map.put("carType","è¦è½¦");break; |
| | | case "carmodel/jiuhu.glb":map.put("carType","ææ¤è½¦");break; |
| | | case "carmodel/oil.glb":map.put("carType","æ²¹ç½è½¦");break; |
| | | case "carmodel/truck.glb":map.put("carType","å·¥ç¨ç¨è½¦");break; |
| | | case "carmodel/van1.glb":map.put("carType","大货车");break; |
| | | Map<String, String> map = new HashMap(); |
| | | map.put("carModel", "sycar/" + item.objectName()); |
| | | switch (item.objectName()) { |
| | | case "carmodel/aodi.glb": |
| | | map.put("carType", "奥迪"); |
| | | break; |
| | | case "carmodel/baolai.glb": |
| | | map.put("carType", "宿¥"); |
| | | break; |
| | | case "carmodel/bieke.glb": |
| | | map.put("carType", "å«å
"); |
| | | break; |
| | | case "carmodel/bus1.glb": |
| | | map.put("carType", "大客车"); |
| | | break; |
| | | case "carmodel/car.glb": |
| | | map.put("carType", "å°å车"); |
| | | break; |
| | | case "carmodel/fire(1).glb": |
| | | map.put("carType", "æ¶é²è½¦"); |
| | | break; |
| | | case "carmodel/fute.glb": |
| | | map.put("carType", "ç¦ç¹"); |
| | | break; |
| | | case "carmodel/jingche_a.glb": |
| | | map.put("carType", "è¦è½¦"); |
| | | break; |
| | | case "carmodel/jiuhu.glb": |
| | | map.put("carType", "ææ¤è½¦"); |
| | | break; |
| | | case "carmodel/oil.glb": |
| | | map.put("carType", "æ²¹ç½è½¦"); |
| | | break; |
| | | case "carmodel/truck.glb": |
| | | map.put("carType", "å·¥ç¨ç¨è½¦"); |
| | | break; |
| | | case "carmodel/van1.glb": |
| | | map.put("carType", "大货车"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public String uploadCarPicture(String id, MultipartFile carPicture) { |
| | | if(id != null && !id.equals("")){//id为éå¿
è¦ |
| | | if (id != null && !id.equals("")) {//id为éå¿
è¦ |
| | | ArdSyCar ardSyCarr = ardSyCarMapper.selectArdSyCarById(id); |
| | | List<String> objectNames = new ArrayList(); |
| | | if(ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")){ |
| | | if (ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")) { |
| | | String objectName = ardSyCarr.getCarPicture().split("/sycar/")[1]; |
| | | objectNames.add(objectName); |
| | | MinioUtils.removeObjects("sycar", objectNames); |
| | |
| | | //æä»¶å |
| | | String originalFilename = carPicture.getOriginalFilename(); |
| | | //æ°çæä»¶å |
| | | String fileName = "carpicture/" + IdUtils.fastSimpleUUID()+"_"+ originalFilename; |
| | | String fileName = "carpicture/" + IdUtils.fastSimpleUUID() + "_" + originalFilename; |
| | | try { |
| | | InputStream inputStream = carPicture.getInputStream(); |
| | | /*ä¸ä¼ 对象*/ |
| | |
| | | .method(Method.GET) |
| | | .build(); |
| | | String presignedObjectUrl = MinioClientSingleton.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs); |
| | | String ObjectUrl = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?")); |
| | | if(id != null && !id.equals("")){//id为éå¿
è¦ |
| | | String ObjectUrl = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?")); |
| | | if (id != null && !id.equals("")) {//id为éå¿
è¦ |
| | | ArdSyCar ardSyCar = new ArdSyCar(); |
| | | ardSyCar.setId(id); |
| | | ardSyCar.setCarPicture(ObjectUrl); |
| | |
| | | public Results carListById(String id) { |
| | | try { |
| | | List<ArdSyCar> list = ardSyCarMapper.carListById(id); |
| | | if(list.size()>0){ |
| | | if (list.size() > 0) { |
| | | ArdSyCar ardSyCar = list.get(0); |
| | | return Results.succeed(ardSyCar); |
| | | }else { |
| | | } else { |
| | | return Results.succeed(); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | @Override |
| | | public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) { |
| | | Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId); |
| | | if(result != null){ |
| | | if(result.get("carPicture") != null){ |
| | | if(!((String)result.get("carPicture")).equals("")){ |
| | | String url = ((String)result.get("carPicture")).split("sycar")[0]; |
| | | String carModel = url + (String)result.get("carModel"); |
| | | result.put("carModel",carModel); |
| | | if (result != null) { |
| | | if (result.get("carPicture") != null) { |
| | | if (!((String) result.get("carPicture")).equals("")) { |
| | | String url = ((String) result.get("carPicture")).split("sycar")[0]; |
| | | String carModel = url + (String) result.get("carModel"); |
| | | result.put("carModel", carModel); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void sendArdSyCarPosition() { |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(PositionContainer.getUserPositionMap().keySet().contains(key)){//å½è¿½è¸ªç车è¾å®¹å¨å
嫿¤ç¨æ·Idï¼å宿¶ä½ç½®æ¨ééè¦åé¤è¯¥è½¦è¾ |
| | | for (String key : ONLINE_USER_SESSIONS.keySet()) { |
| | | if (PositionContainer.getUserPositionMap().keySet().contains(key)) {//å½è¿½è¸ªç车è¾å®¹å¨å
嫿¤ç¨æ·Idï¼å宿¶ä½ç½®æ¨ééè¦åé¤è¯¥è½¦è¾ |
| | | SysUser sysUser = userMapper.selectUserById(key); |
| | | if(sysUser == null){ |
| | | if (sysUser == null) { |
| | | //return; |
| | | continue; |
| | | } |
| | | String deptId = String.valueOf(sysUser.getDeptId()); |
| | | Map<String,Map<String,Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | Map<String, Map<String, Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | List<String> carIdList = new ArrayList(); |
| | | carIdList.addAll(PositionContainer.getUserPositionMap().get(key).keySet()); |
| | | String carId = carIdList.get(0); |
| | | map.remove(carId); |
| | | if(map != null){ |
| | | Map<String,Object> data = new HashMap(); |
| | | if (map != null) { |
| | | Map<String, Object> data = new HashMap(); |
| | | data.put("30000", map.values()); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data)); |
| | | } |
| | | }else{ |
| | | } else { |
| | | SysUser sysUser = userMapper.selectUserById(key); |
| | | if(sysUser == null){ |
| | | if (sysUser == null) { |
| | | //return; |
| | | continue; |
| | | } |
| | | String deptId = String.valueOf(sysUser.getDeptId()); |
| | | Map<String,Map<String,Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | if(map != null){ |
| | | Map<String,Object> data = new HashMap(); |
| | | Map<String, Map<String, Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | if (map != null) { |
| | | Map<String, Object> data = new HashMap(); |
| | | data.put("30000", map.values()); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | | for(String userId : userCarTimerMap.keySet()){//ç¨æ·ç¦»çº¿åå°è½¦è¾è¿½è¸ªèµæºéæ¾ |
| | | if(!ONLINE_USER_SESSIONS.keySet().contains(userId)){ |
| | | for (String userId : userCarTimerMap.keySet()) {//ç¨æ·ç¦»çº¿åå°è½¦è¾è¿½è¸ªèµæºéæ¾ |
| | | if (!ONLINE_USER_SESSIONS.keySet().contains(userId)) { |
| | | userCarTimerMap.get(userId).cancel(); |
| | | userCarTimerMap.remove(userId); |
| | | PositionContainer.getUserPositionMap().remove(userId); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void sendArdSyCarAlarmByCarId(String carId, Map<String,Object> data) { |
| | | public void sendArdSyCarAlarmByCarId(String carId, Map<String, Object> data) { |
| | | List<SysUser> result = userMapper.getSysUserByCarId(carId); |
| | | for(SysUser sysUser : result){ |
| | | for (SysUser sysUser : result) { |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sysUser.getUserId()), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç¨æ·è·åä¸ä¸å表 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Map<String,Object> allListByUser(ArdSyUser ardSyUser,String syURL,String usersId){ |
| | | Map<String,Object> result0 = new HashMap(); |
| | | public Map<String, Object> allListByUser(ArdSyUser ardSyUser, String syURL, String usersId) { |
| | | Map<String, Object> result0 = new HashMap(); |
| | | //夿å
³è表æ¯å¦ææ°æ® |
| | | if(ardSyUser!=null){ |
| | | if (ardSyUser != null) { |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | //31ç¨æ·åå¯ç |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL,passwordMd5, username31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) result1.get("sessionId")); |
| | | try { |
| | | result0 = sYClient.getTeamList(syURL,result.get("userId"),result.get("sessionId")); |
| | | result0 = sYClient.getTeamList(syURL, result.get("userId"), result.get("sessionId")); |
| | | } catch (Exception e) { |
| | | Map<String,Object> map = new HashMap(); |
| | | Map<String, Object> map = new HashMap(); |
| | | map.put("rspCode", 0); |
| | | map.put("list", new ArrayList()); |
| | | return map; |
| | | } |
| | | int online = 0; |
| | | for(Map<String,Object> map : (List<Map<String,Object>>) result0.get("list")){ |
| | | Map<String,Object> resultMap = sYClient.getTeamCarList(syURL,(String)map.get("teamId"),result.get("sessionId")); |
| | | List<Map<String,Object>> carList = (List<Map<String, Object>>) resultMap.get("carList"); |
| | | for(Map<String,Object> m : carList){ |
| | | if(((String) m.get("stateCn")).contains("å¨çº¿")){ |
| | | for (Map<String, Object> map : (List<Map<String, Object>>) result0.get("list")) { |
| | | Map<String, Object> resultMap = sYClient.getTeamCarList(syURL, (String) map.get("teamId"), result.get("sessionId")); |
| | | List<Map<String, Object>> carList = (List<Map<String, Object>>) resultMap.get("carList"); |
| | | for (Map<String, Object> m : carList) { |
| | | if (((String) m.get("stateCn")).contains("å¨çº¿")) { |
| | | online = online + 1; |
| | | }else{ |
| | | } else { |
| | | continue; |
| | | } |
| | | } |
| | | for(Map<String,Object> m : (List<Map<String,Object>>) result0.get("list")){ |
| | | if(((String) m.get("teamId")).equals(((String) map.get("teamId")))){ |
| | | for (Map<String, Object> m : (List<Map<String, Object>>) result0.get("list")) { |
| | | if (((String) m.get("teamId")).equals(((String) map.get("teamId")))) { |
| | | map.put("count", Integer.parseInt((String) m.get("carNum"))); |
| | | } |
| | | } |
| | | map.put("online", online); |
| | | online = 0; |
| | | } |
| | | }else { |
| | | result0.put("å表为空ï¼","æ å
³èè´¦å·ï¼"); |
| | | } else { |
| | | result0.put("å表为空ï¼", "æ å
³èè´¦å·ï¼"); |
| | | } |
| | | return result0; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String,String>> getCarList(ArdSyUser ardSyUser, String syURL, String usersId,String teamId){ |
| | | List<Map<String,String>> list = new ArrayList<>(); |
| | | public List<Map<String, String>> getCarList(ArdSyUser ardSyUser, String syURL, String usersId, String teamId) { |
| | | List<Map<String, String>> list = new ArrayList<>(); |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | //31ç¨æ·åå¯ç |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL,passwordMd5, username31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) result1.get("sessionId")); |
| | | //æ¥è¯¢è¯¥teamIdä¸çè½¦è¾æ°æ® |
| | | Map<String,Object> carList31 = new HashMap(); |
| | | carList31 = sYClient.getCarList1(syURL,teamId, result.get("userId"),result.get("sessionId")); |
| | | Map<String, Object> carList31 = new HashMap(); |
| | | carList31 = sYClient.getCarList1(syURL, teamId, result.get("userId"), result.get("sessionId")); |
| | | //æ¿å°è½¦è¾æ°æ® |
| | | list= (List) carList31.get("list"); |
| | | if(list.isEmpty()){ |
| | | list = (List) carList31.get("list"); |
| | | if (list.isEmpty()) { |
| | | return list; |
| | | }else { |
| | | } else { |
| | | List<String> carIdList = new ArrayList(); |
| | | //ææcarId |
| | | for(Map<String,String> m : list){ |
| | | for (Map<String, String> m : list) { |
| | | carIdList.add(m.get("carId")); |
| | | } |
| | | if(carIdList.size() == 0){ |
| | | Map<String,String> map0 = new HashMap(); |
| | | if (carIdList.size() == 0) { |
| | | Map<String, String> map0 = new HashMap(); |
| | | map0.put("list", "{}"); |
| | | map0.put("rspCode", "1"); |
| | | list.add(map0); |
| | | return list; |
| | | } |
| | | //æ·»å 车è¾å±æ§ |
| | | for(Map<String,String> m : list){ |
| | | for (Map<String, String> m : list) { |
| | | switch (m.get("state")) { |
| | | case "1": |
| | | m.put("carState", "离线-仿ªæ¥å®ä½");break; |
| | | m.put("carState", "离线-仿ªæ¥å®ä½"); |
| | | break; |
| | | case "2": |
| | | m.put("carState", "离线-æ¬ è´¹");break; |
| | | m.put("carState", "离线-æ¬ è´¹"); |
| | | break; |
| | | case "3": |
| | | m.put("carState", "离线");break; |
| | | m.put("carState", "离线"); |
| | | break; |
| | | case "4": |
| | | m.put("carState", "离线-æ¥è¦");break; |
| | | m.put("carState", "离线-æ¥è¦"); |
| | | break; |
| | | case "5": |
| | | m.put("carState", "å¨çº¿-仿ªæ¥å®ä½");break; |
| | | m.put("carState", "å¨çº¿-仿ªæ¥å®ä½"); |
| | | break; |
| | | case "6": |
| | | m.put("carState", "å¨çº¿-æ¬ è´¹");break; |
| | | m.put("carState", "å¨çº¿-æ¬ è´¹"); |
| | | break; |
| | | case "7": |
| | | m.put("carState", "å¨çº¿-è¡é©¶");break; |
| | | m.put("carState", "å¨çº¿-è¡é©¶"); |
| | | break; |
| | | case "8": |
| | | m.put("carState", "å¨çº¿-è¡é©¶-æ¥è¦");break; |
| | | m.put("carState", "å¨çº¿-è¡é©¶-æ¥è¦"); |
| | | break; |
| | | case "9": |
| | | m.put("carState", "å¨çº¿-å车-ACCå
³");break; |
| | | m.put("carState", "å¨çº¿-å车-ACCå
³"); |
| | | break; |
| | | case "10": |
| | | m.put("carState", "å¨çº¿-å车-ACCå¼");break; |
| | | m.put("carState", "å¨çº¿-å车-ACCå¼"); |
| | | break; |
| | | case "11": |
| | | m.put("carState", "å¨çº¿-å车-ACCå
³-æ¥è¦");break; |
| | | m.put("carState", "å¨çº¿-å车-ACCå
³-æ¥è¦"); |
| | | break; |
| | | case "12": |
| | | m.put("carState", "å¨çº¿-å车-ACCå¼-æ¥è¦");break; |
| | | m.put("carState", "å¨çº¿-å车-ACCå¼-æ¥è¦"); |
| | | break; |
| | | case "13": |
| | | m.put("carState", "å¨çº¿-æ æå®ä½");break; |
| | | m.put("carState", "å¨çº¿-æ æå®ä½"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | |
| | | /** |
| | | * æ ¹æ®deptéåæ¥è¯¢åºææå¯¹åºçcarId |
| | | * |
| | | * @param deptList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String,String>> carIdByDeptList(List<Long> deptList,List<Map<String,String>> list){ |
| | | public List<Map<String, String>> carIdByDeptList(List<Long> deptList, List<Map<String, String>> list) { |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("dept_id",deptList); |
| | | queryWrapper.in("dept_id", deptList); |
| | | List<ArdSyCar> carList = ardSyCarMapper.selectList(queryWrapper); |
| | | //å¯¹æ¯æå¹é
å°çæ°æ®æ·»å å°listä¸ |
| | | for(Map<String,String> m : list){ |
| | | for (Map<String, String> m : list) { |
| | | String carId = m.get("carId"); |
| | | for (int i = 0; i < carList.size(); i++) { |
| | | ArdSyCar ardSyCar = carList.get(i); |
| | | if(carId.equals(ardSyCar.getCarId())){ |
| | | if (carId.equals(ardSyCar.getCarId())) { |
| | | String url = ""; |
| | | if(ardSyCar.getCarPicture() != null){ |
| | | if(!ardSyCar.getCarPicture().equals("")){ |
| | | if (ardSyCar.getCarPicture() != null) { |
| | | if (!ardSyCar.getCarPicture().equals("")) { |
| | | url = ardSyCar.getCarPicture().split("sycar")[0]; |
| | | } |
| | | } |
| | | m.put("carModel",url + ardSyCar.getCarModel());//zns |
| | | m.put("carModel", url + ardSyCar.getCarModel());//zns |
| | | //m.put("carModel",ardSyCar.getCarModel()); |
| | | m.put("carTypeArd",ardSyCar.getCarType()); |
| | | m.put("carBrand",ardSyCar.getCarBrand()); |
| | | m.put("carPicture",ardSyCar.getCarPicture()); |
| | | m.put("carTypeArd", ardSyCar.getCarType()); |
| | | m.put("carBrand", ardSyCar.getCarBrand()); |
| | | m.put("carPicture", ardSyCar.getCarPicture()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Results getCarGPSTrack(Map<String,String> map,String syURL, ArdSyUser ardSyUser){ |
| | | public Results getCarGPSTrack(Map<String, String> map, String syURL, ArdSyUser ardSyUser) { |
| | | String carId = map.get("carId"); |
| | | //String startTime = map.get("startTime").replace(" ", "").replace("-", "").replace(":", ""); |
| | | //String endTime = map.get("endTime").replace(" ", "").replace("-", "").replace(":", ""); |
| | | String time = map.get("time"); |
| | | time = time.replace("-", ""); |
| | | String startTime = time + "000000"; |
| | | String endTime = time +"235959"; |
| | | String endTime = time + "235959"; |
| | | String maxSpeed = map.get("maxSpeed"); |
| | | //31ç¨æ·åå¯ç |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL,passwordMd5, username31); |
| | | Map<String,Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarGPSTrack(syURL,carId,startTime,endTime,maxSpeed,(String) result1.get("sessionId")); |
| | | List<Map<String,Object>> list = (List<Map<String, Object>>) result0.get("list"); |
| | | if(list.isEmpty()){ |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | Map<String, Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId")); |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result0.get("list"); |
| | | if (list.isEmpty()) { |
| | | return Results.succeed(); |
| | | }else { |
| | | for(Map<String,Object> m : list) { |
| | | } else { |
| | | for (Map<String, Object> m : list) { |
| | | String alarmStts = (String) m.get("alarmStts"); |
| | | Map<String, List<String>> alarmMap = getInfo("alarm", alarmStts); |
| | | m.putAll(alarmMap); |
| | |
| | | } |
| | | |
| | | |
| | | public Map<String,List<String>> getInfo(String type,String stts){ |
| | | if(stts.isEmpty()){ |
| | | public Map<String, List<String>> getInfo(String type, String stts) { |
| | | if (stts.isEmpty()) { |
| | | return new HashMap<>(); |
| | | } |
| | | String[] alarmTypes = {"ç´§æ¥æ¥è¦","è¶
鿥è¦","ç²å³é©¾é©¶","å±é©é¢è¦","GNSS 模ååçæ
é","GNSS å¤©çº¿æªæ¥æè¢«åªæ","GNSS 天线çè·¯", |
| | | "ç»ç«¯ä¸»çµæºæ¬ å","ç»ç«¯ä¸»çµæºæçµ","ç»ç«¯LCD ææ¾ç¤ºå¨æ
é","TTS 模åæ
é","æå头æ
é","éè·¯è¿è¾è¯IC 塿¨¡åæ
é","è¶
éé¢è¦", |
| | | "ç²å³é©¾é©¶é¢è¦","è¿è§è¡é©¶æ¥è¦","èåé¢è¦","å³è½¬ç²åºå¼å¸¸æ¥è¦","å½å¤©ç´¯è®¡é©¾é©¶è¶
æ¶","è¶
æ¶å车","è¿åºåºå","è¿åºè·¯çº¿","路段è¡é©¶æ¶é´ä¸è¶³/è¿é¿", |
| | | "路线å离æ¥è¦","车è¾VSS æ
é","è½¦è¾æ²¹éå¼å¸¸","车è¾è¢«ç","车è¾éæ³ç¹ç«","车è¾éæ³ä½ç§»","碰æé¢è¦","ä¾§ç¿»é¢è¦","éæ³å¼é¨æ¥è¦"}; |
| | | String[] alarmTypes = {"ç´§æ¥æ¥è¦", "è¶
鿥è¦", "ç²å³é©¾é©¶", "å±é©é¢è¦", "GNSS 模ååçæ
é", "GNSS å¤©çº¿æªæ¥æè¢«åªæ", "GNSS 天线çè·¯", |
| | | "ç»ç«¯ä¸»çµæºæ¬ å", "ç»ç«¯ä¸»çµæºæçµ", "ç»ç«¯LCD ææ¾ç¤ºå¨æ
é", "TTS 模åæ
é", "æå头æ
é", "éè·¯è¿è¾è¯IC 塿¨¡åæ
é", "è¶
éé¢è¦", |
| | | "ç²å³é©¾é©¶é¢è¦", "è¿è§è¡é©¶æ¥è¦", "èåé¢è¦", "å³è½¬ç²åºå¼å¸¸æ¥è¦", "å½å¤©ç´¯è®¡é©¾é©¶è¶
æ¶", "è¶
æ¶å车", "è¿åºåºå", "è¿åºè·¯çº¿", "路段è¡é©¶æ¶é´ä¸è¶³/è¿é¿", |
| | | "路线å离æ¥è¦", "车è¾VSS æ
é", "è½¦è¾æ²¹éå¼å¸¸", "车è¾è¢«ç", "车è¾éæ³ç¹ç«", "车è¾éæ³ä½ç§»", "碰æé¢è¦", "ä¾§ç¿»é¢è¦", "éæ³å¼é¨æ¥è¦"}; |
| | | |
| | | String[] carTypes89 = {"空车","åè½½","ä¿ç","满载"}; |
| | | String[] carTypes89 = {"空车", "åè½½", "ä¿ç", "满载"}; |
| | | |
| | | Object[] carTypes = {"ACCå¼","å®ä½","å纬","西ç»","åè¿ç¶æ","ç»çº¬åº¦å·²ç»ä¿å¯æä»¶å å¯","ä¿ç","ä¿ç",carTypes89,"è½¦è¾æ²¹è·¯æå¼","车é¨å é", |
| | | "车è¾çµè·¯æå¼","é¨1å¼ï¼åé¨ï¼","é¨2å¼ï¼ä¸é¨ï¼","é¨3å¼ï¼åé¨","é¨4å¼ï¼é©¾é©¶å¸é¨","é¨5å¼","使ç¨GPS 嫿è¿è¡å®ä½","使ç¨åæå«æè¿è¡å®ä½", |
| | | "使ç¨GLONASS嫿è¿è¡å®ä½","使ç¨Galileo嫿è¿è¡å®ä½","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç"}; |
| | | Object[] carTypes = {"ACCå¼", "å®ä½", "å纬", "西ç»", "åè¿ç¶æ", "ç»çº¬åº¦å·²ç»ä¿å¯æä»¶å å¯", "ä¿ç", "ä¿ç", carTypes89, "è½¦è¾æ²¹è·¯æå¼", "车é¨å é", |
| | | "车è¾çµè·¯æå¼", "é¨1å¼ï¼åé¨ï¼", "é¨2å¼ï¼ä¸é¨ï¼", "é¨3å¼ï¼åé¨", "é¨4å¼ï¼é©¾é©¶å¸é¨", "é¨5å¼", "使ç¨GPS 嫿è¿è¡å®ä½", "使ç¨åæå«æè¿è¡å®ä½", |
| | | "使ç¨GLONASS嫿è¿è¡å®ä½", "使ç¨Galileo嫿è¿è¡å®ä½", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç"}; |
| | | |
| | | String[] sgnTypes = {"è¿å
ç¯ä¿¡å·","è¿å
ç¯ä¿¡å·","å³è½¬åç¯ä¿¡å·","左转åç¯ä¿¡å·","å¶å¨ä¿¡å·","åæ¡£ä¿¡å·","é¾ç¯ä¿¡å·","示å»ç¯","ååä¿¡å·","空è°ç¶æ", |
| | | "空æ¡ä¿¡å·","ç¼éå¨å·¥ä½","ABS å·¥ä½","å çå¨å·¥ä½","离åå¨ç¶æ","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç", |
| | | "ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç","ä¿ç"}; |
| | | String[] sgnTypes = {"è¿å
ç¯ä¿¡å·", "è¿å
ç¯ä¿¡å·", "å³è½¬åç¯ä¿¡å·", "左转åç¯ä¿¡å·", "å¶å¨ä¿¡å·", "åæ¡£ä¿¡å·", "é¾ç¯ä¿¡å·", "示å»ç¯", "ååä¿¡å·", "空è°ç¶æ", |
| | | "空æ¡ä¿¡å·", "ç¼éå¨å·¥ä½", "ABS å·¥ä½", "å çå¨å·¥ä½", "离åå¨ç¶æ", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", |
| | | "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç", "ä¿ç"}; |
| | | //Integer sttsHex = Integer.parseInt(stts, 16); |
| | | Long sttsHex = Long.parseLong(stts, 16); |
| | | //String sttsBin = Integer.toBinaryString(sttsHex); |
| | | String sttsBin = Long.toBinaryString(sttsHex); |
| | | if(sttsBin.length() < 32){ |
| | | while(sttsBin.length() < 32){ |
| | | if (sttsBin.length() < 32) { |
| | | while (sttsBin.length() < 32) { |
| | | sttsBin = "0" + sttsBin; |
| | | } |
| | | } |
| | |
| | | case "alarm": |
| | | List<String> alarmTypeArray = new ArrayList(); |
| | | for (int i = 0; i < sttsBinArray.length; i++) { |
| | | if(sttsBinArray[i].equals("1")){ |
| | | if (sttsBinArray[i].equals("1")) { |
| | | alarmTypeArray.add(alarmTypes[i]); |
| | | } |
| | | } |
| | | Map<String,List<String>> alarmMap = new HashMap(); |
| | | Map<String, List<String>> alarmMap = new HashMap(); |
| | | alarmMap.put(type, alarmTypeArray); |
| | | return alarmMap; |
| | | case "car": |
| | | List<String> carTypeArray = new ArrayList(); |
| | | for (int i = 0; i < sttsBinArray.length; i++) { |
| | | if(i <= 7 || i >= 10){ |
| | | if(sttsBinArray[i].equals("1")){ |
| | | if (i <= 7 || i >= 10) { |
| | | if (sttsBinArray[i].equals("1")) { |
| | | carTypeArray.add(alarmTypes[i]); |
| | | } |
| | | }else if(i == 8){ |
| | | switch (sttsBinArray[8]+sttsBinArray[9]) { |
| | | } else if (i == 8) { |
| | | switch (sttsBinArray[8] + sttsBinArray[9]) { |
| | | case "00": |
| | | carTypeArray.add(carTypes89[0]); |
| | | break; |
| | |
| | | default: |
| | | break; |
| | | } |
| | | }else if(i == 9){ |
| | | } else if (i == 9) { |
| | | continue; |
| | | }else{ |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | Map<String,List<String>> carMap = new HashMap(); |
| | | Map<String, List<String>> carMap = new HashMap(); |
| | | List<String> carTypeArray0 = new ArrayList(); |
| | | for(String str : carTypeArray){ |
| | | if(!str.equals("ä¿ç")){ |
| | | for (String str : carTypeArray) { |
| | | if (!str.equals("ä¿ç")) { |
| | | carTypeArray0.add(str); |
| | | } |
| | | } |
| | |
| | | case "sgn": |
| | | List<String> sgnTypeArray = new ArrayList(); |
| | | for (int i = 0; i < sttsBinArray.length; i++) { |
| | | if(sttsBinArray[i].equals("1")){ |
| | | if (sttsBinArray[i].equals("1")) { |
| | | sgnTypeArray.add(alarmTypes[i]); |
| | | } |
| | | } |
| | | Map<String,List<String>> sgnMap = new HashMap(); |
| | | Map<String, List<String>> sgnMap = new HashMap(); |
| | | List<String> sgnTypeArray0 = new ArrayList(); |
| | | for(String str : sgnTypeArray){ |
| | | if(!str.equals("ä¿ç")){ |
| | | for (String str : sgnTypeArray) { |
| | | if (!str.equals("ä¿ç")) { |
| | | sgnTypeArray0.add(str); |
| | | } |
| | | } |
| | | sgnMap.put(type, sgnTypeArray0); |
| | | return sgnMap; |
| | | default: |
| | | return new HashMap<String,List<String>>(); |
| | | return new HashMap<String, List<String>>(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Results getCarGPSBycarId(String usersId,String carId,String syURL,ArdSyUser ardSyUser){ |
| | | public Results getCarGPSBycarId(String usersId, String carId, String syURL, ArdSyUser ardSyUser) { |
| | | Map<String, String> result = logInMap.get(Integer.parseInt(usersId)); |
| | | //31ç¨æ·åå¯ç |
| | | String username31 = ardSyUser.getUserId(); |
| | | String password31 = ardSyUser.getPassword(); |
| | | String passwordMd5 = DigestUtils.md5Hex(password31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL,passwordMd5, username31); |
| | | Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31); |
| | | result = new HashMap(); |
| | | result.put("userId", username31); |
| | | result.put("sessionId", (String) result1.get("sessionId")); |
| | | Map<String,Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarNearPositionByCarId(syURL,carId,result.get("userId"),result.get("sessionId")); |
| | | Map<String, Object> result0 = new HashMap(); |
| | | result0 = sYClient.getCarNearPositionByCarId(syURL, carId, result.get("userId"), result.get("sessionId")); |
| | | return Results.succeed(result0); |
| | | } |
| | | |
| | | @Override |
| | | public Results chaseCarByCarId(String usersId, String carId, String cycle) { |
| | | try{ |
| | | try { |
| | | /*Map<String,Map<String,Object>> map = new HashMap(); |
| | | map.put(carId,new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId,map);*/ |
| | | if(cycle.equals("0")){ |
| | | if(userCarTimerMap.get(usersId) != null){ |
| | | if (cycle.equals("0")) { |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | } |
| | | return Results.succeed("åæ¢è¿½è¸ª"); |
| | | }else{ |
| | | if(userCarTimerMap.get(usersId) != null){ |
| | | } else { |
| | | if (userCarTimerMap.get(usersId) != null) { |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | Map<String,Map<String,Object>> map = new HashMap(); |
| | | map.put(carId,new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId,map); |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//宿¶æ¨é宿¶ä½ç½® |
| | | TimerTask carPositionTask =new TimerTask(){ |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run(){ |
| | | Map<String,Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId); |
| | | if(position != null){ |
| | | if(position.size() != 0){ |
| | | Map<String,Map<String,Object>> data = new HashMap(); |
| | | data.put("31000",position); |
| | | public void run() { |
| | | Map<String, Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId); |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | carPositionTimer.scheduleAtFixedRate(carPositionTask,date,Integer.parseInt(cycle));//å¯ç¨ |
| | | this.userCarTimerMap.put(usersId,carPositionTimer); |
| | | carPositionTimer.scheduleAtFixedRate(carPositionTask, date, Integer.parseInt(cycle));//å¯ç¨ |
| | | this.userCarTimerMap.put(usersId, carPositionTimer); |
| | | return Results.succeed("å¼å§è¿½è¸ª"); |
| | | }else{ |
| | | Map<String,Map<String,Object>> map = new HashMap(); |
| | | map.put(carId,new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId,map); |
| | | } else { |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | Date date = new Date(); |
| | | Timer carPositionTimer = new Timer();//宿¶æ¨é宿¶ä½ç½® |
| | | TimerTask carPositionTask =new TimerTask(){ |
| | | TimerTask carPositionTask = new TimerTask() { |
| | | @Override |
| | | public void run(){ |
| | | Map<String,Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId); |
| | | if(position != null){ |
| | | if(position.size() != 0){ |
| | | Map<String,Map<String,Object>> data = new HashMap(); |
| | | data.put("31000",position); |
| | | public void run() { |
| | | Map<String, Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId); |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | | Map<String, Map<String, Object>> data = new HashMap(); |
| | | data.put("31000", position); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | carPositionTimer.scheduleAtFixedRate(carPositionTask,date,Integer.parseInt(cycle));//å¯ç¨ |
| | | this.userCarTimerMap.put(usersId,carPositionTimer); |
| | | carPositionTimer.scheduleAtFixedRate(carPositionTask, date, Integer.parseInt(cycle));//å¯ç¨ |
| | | this.userCarTimerMap.put(usersId, carPositionTimer); |
| | | return Results.succeed("å¼å§è¿½è¸ª"); |
| | | } |
| | | } |
| | | }catch(Exception e){ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Results.error("追踪失败"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Results getExistTraceByCarIdAndMonth(String userId, String carId, String time) { |
| | | List<ArdSyCarDay> result = ardSyCarDayMapper.selectArdSyCarDayByCarIdAndDay(carId,time + "%"); |
| | | List<ArdSyCarDay> result = ardSyCarDayMapper.selectArdSyCarDayByCarIdAndDay(carId, time + "%"); |
| | | List<String> list = new ArrayList(); |
| | | for(ArdSyCarDay ardSyCarDay : result){ |
| | | for (ArdSyCarDay ardSyCarDay : result) { |
| | | // list.add(ardSyCarDay.getDay().split("-")[2]); |
| | | list.add(ardSyCarDay.getDay()); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | |
| | | public Map<String,Integer> getExistTraceByCarIdAndMonth(String url,String usersId,String password,String carId,String time){ |
| | | Map<String,Object> LogInResult = sYClient.logIn(url,password,usersId); |
| | | public Map<String, Integer> getExistTraceByCarIdAndMonth(String url, String usersId, String password, String carId, String time) { |
| | | Map<String, Object> LogInResult = sYClient.logIn(url, password, usersId); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//è·å该æå¤©æ° |
| | | Map<String,Integer> existTraceMap = new HashMap(); |
| | | Map<String, Integer> existTraceMap = new HashMap(); |
| | | ExecutorService newCachedThreadPoll = Executors.newCachedThreadPool(); |
| | | for (int i = 1; i <= maxDay; i = i + 7) { |
| | | int temp = i; |
| | | String finalTime = time.replace("-",""); |
| | | String finalTime = time.replace("-", ""); |
| | | String finalsyURL = url; |
| | | newCachedThreadPoll.execute(new Runnable(){ |
| | | newCachedThreadPoll.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | int temp0 = temp + 6; |
| | | if(temp0 > maxDay){ |
| | | if (temp0 > maxDay) { |
| | | temp0 = maxDay; |
| | | } |
| | | for (int j = temp; j <= temp0; j++) { |
| | | if(j <= 9){ |
| | | if (j <= 9) { |
| | | existTraceMap.put("0" + String.valueOf(j), -1); |
| | | }else{ |
| | | } else { |
| | | existTraceMap.put(String.valueOf(j), -1); |
| | | } |
| | | } |
| | | if(temp <= 9){ |
| | | if(temp0 <= 9){ |
| | | if (temp <= 9) { |
| | | if (temp0 <= 9) { |
| | | String startTime = finalTime + "0" + temp + "000000"; |
| | | String endTime = finalTime + "0" + temp0 + "235959"; |
| | | Map<String,Object> result = getCarGPSTrack(finalsyURL,carId,startTime,endTime,sessionId); |
| | | String rspCode = (String)result.get("rspCode"); |
| | | if(rspCode.equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for(Map<String,Object> m : list){ |
| | | Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId); |
| | | String rspCode = (String) result.get("rspCode"); |
| | | if (rspCode.equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for (Map<String, Object> m : list) { |
| | | String time = (String) m.get("time"); |
| | | time = time.split(" ")[0]; |
| | | time = time.split("-")[2]; |
| | | existTraceMap.put(time, 1); |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | String startTime = finalTime + "0" + temp + "000000"; |
| | | String endTime = finalTime + temp0 + "235959"; |
| | | Map<String,Object> result = getCarGPSTrack(finalsyURL,carId,startTime,endTime,sessionId); |
| | | String rspCode = (String)result.get("rspCode"); |
| | | if(rspCode.equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for(Map<String,Object> m : list){ |
| | | Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId); |
| | | String rspCode = (String) result.get("rspCode"); |
| | | if (rspCode.equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for (Map<String, Object> m : list) { |
| | | String time = (String) m.get("time"); |
| | | time = time.split(" ")[0]; |
| | | time = time.split("-")[2]; |
| | |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | String startTime = finalTime + temp + "000000"; |
| | | String endTime = finalTime + temp0 + "235959"; |
| | | Map<String,Object> result = getCarGPSTrack(finalsyURL,carId,startTime,endTime,sessionId); |
| | | String rspCode = (String)result.get("rspCode"); |
| | | if(rspCode.equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for(Map<String,Object> m : list){ |
| | | Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId); |
| | | String rspCode = (String) result.get("rspCode"); |
| | | if (rspCode.equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list"); |
| | | for (Map<String, Object> m : list) { |
| | | String time = (String) m.get("time"); |
| | | time = time.split(" ")[0]; |
| | | time = time.split("-")[2]; |
| | |
| | | } |
| | | } |
| | | } |
| | | for(int j = temp; j <= temp0; j++){ |
| | | for (int j = temp; j <= temp0; j++) { |
| | | String key = ""; |
| | | if(j <= 9){ |
| | | if (j <= 9) { |
| | | key = "0" + j; |
| | | }else{ |
| | | } else { |
| | | key = String.valueOf(j); |
| | | } |
| | | if(existTraceMap.get(key) == -1){ |
| | | if (existTraceMap.get(key) == -1) { |
| | | existTraceMap.put(key, 0); |
| | | } |
| | | |
| | |
| | | } |
| | | }); |
| | | } |
| | | while(true){ |
| | | if(!existTraceMap.values().contains(-1)){ |
| | | if(existTraceMap.size() == maxDay){ |
| | | while (true) { |
| | | if (!existTraceMap.values().contains(-1)) { |
| | | if (existTraceMap.size() == maxDay) { |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static Map<String,Object> getCarGPSTrack(String syURL,String carId,String startTime,String endTime,String sessionId){ |
| | | public static Map<String, Object> getCarGPSTrack(String syURL, String carId, String startTime, String endTime, String sessionId) { |
| | | OkHttpClient okHttpClient = new OkHttpClient(); |
| | | |
| | | Request request = new Request.Builder() |
| | | .url(syURL + "/gps-web/api/get_gps_h.jsp?carId="+carId+"&startTime="+startTime+"&endTime="+endTime+"&filter0=true&maxSpeed=&stopLong=5&queryAlarm=false&userId=yanshi&loginType=user&loginWay=android&loginLang=zh_CN&appDevId=&sessionId="+sessionId) |
| | | .url(syURL + "/gps-web/api/get_gps_h.jsp?carId=" + carId + "&startTime=" + startTime + "&endTime=" + endTime + "&filter0=true&maxSpeed=&stopLong=5&queryAlarm=false&userId=yanshi&loginType=user&loginWay=android&loginLang=zh_CN&appDevId=&sessionId=" + sessionId) |
| | | .build(); |
| | | |
| | | Response response = null; |
| | |
| | | |
| | | try { |
| | | String message = responseBody.string();// ååºä½ |
| | | Map<String,Object> map = (Map<String, Object>) JSON.parse(message); |
| | | Map<String, Object> map = (Map<String, Object>) JSON.parse(message); |
| | | //System.out.println(message); |
| | | return map; |
| | | } catch (IOException e) { |
| | |
| | | return new HashMap(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·åéè¿èå´å
ç车è¾ä¿¡æ¯ |
| | | */ |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getNearCar(SchedulingParam param) { |
| | | Double longitude = param.getLongitude(); |
| | | Double latitude = param.getLatitude(); |
| | | Integer radius = param.getSealingRadius(); |
| | | if (longitude == null && latitude == null) { |
| | | log.debug("åç¹åæ 为空"); |
| | | return null; |
| | | } |
| | | if (radius == null) { |
| | | log.debug("åå¾è·ç¦»ä¸ºç©º"); |
| | | return null; |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | ArdSyUser syUser = new ArdSyUser(); |
| | | syUser.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser); |
| | | if (ardSyUserList.size() == 0) { |
| | | log.debug("ç¨æ·æªææ¥ä¸ä¸è½¦è¾"); |
| | | return null; |
| | | } |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | String syUrl = redisCache.getCacheObject("sys_config:syCarPT"); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | |
| | | Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list"); |
| | | List<Map<String, Object>> allList = new ArrayList<>(); |
| | | for (Map<String, Object> team : listMap) { |
| | | String teamId = (String) team.get("teamId"); |
| | | Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId); |
| | | if (((String) carListMap.get("rspCode")).equals("1")) { |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list"); |
| | | allList.addAll(list); |
| | | } |
| | | } |
| | | //è¿æ»¤å¨çº¿è½¦è¾ |
| | | List<Map<String, Object>> onlineList = allList.stream() |
| | | .filter(map -> !"离线".equals(map.get("stateCn"))) |
| | | .collect(Collectors.toList()); |
| | | List<Map<String, Object>> filteredList = new ArrayList<>(); |
| | | //è¿æ»¤åå¾ |
| | | for (Map<String, Object> carMap : onlineList) { |
| | | String carId = (String) carMap.get("carId"); |
| | | Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId); |
| | | List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list"); |
| | | Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng")); |
| | | Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat")); |
| | | double distance = GisTool.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat}); |
| | | if (distance <= radius) { |
| | | filteredList.add(carMap); // å°æ»¡è¶³æ¡ä»¶çè½¦è¾æ·»å å°çéåè¡¨ä¸ |
| | | } |
| | | } |
| | | return filteredList; |
| | | } |
| | | } |