|  |  |  | 
|---|
|  |  |  | package com.ruoyi.sy.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.InputStream; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.text.ParseException; | 
|---|
|  |  |  | import java.text.SimpleDateFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.concurrent.ExecutorService; | 
|---|
|  |  |  | import java.util.concurrent.Executors; | 
|---|
|  |  |  | import java.util.function.Predicate; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.utils.uuid.IdUtils; | 
|---|
|  |  |  | import com.ruoyi.sy.domain.ArdSyCarDay; | 
|---|
|  |  |  | import com.ruoyi.sy.mapper.ArdSyCarDayMapper; | 
|---|
|  |  |  | import com.ruoyi.utils.websocket.util.WebSocketUtils; | 
|---|
|  |  |  | import com.ruoyi.device.hiksdk.config.MinioClientSingleton; | 
|---|
|  |  |  | import com.ruoyi.device.hiksdk.util.minio.MinioUtils; | 
|---|
|  |  |  | import com.ruoyi.storage.minio.utils.MinioUtils; | 
|---|
|  |  |  | import com.ruoyi.sy.domain.ArdSyUser; | 
|---|
|  |  |  | import com.ruoyi.sy.gps31.PositionContainer; | 
|---|
|  |  |  | import com.ruoyi.sy.mapper.ArdSyUserMapper; | 
|---|
|  |  |  | import com.ruoyi.system.domain.SysConfig; | 
|---|
|  |  |  | import com.ruoyi.system.mapper.SysConfigMapper; | 
|---|
|  |  |  | import com.ruoyi.system.mapper.SysUserMapper; | 
|---|
|  |  |  | import com.ruoyi.system.service.ISysConfigService; | 
|---|
|  |  |  | import com.ruoyi.utils.httpclient.SYCarClient; | 
|---|
|  |  |  | import com.ruoyi.utils.forest.SYClient; | 
|---|
|  |  |  | import com.ruoyi.utils.result.Results; | 
|---|
|  |  |  | import io.minio.GetPresignedObjectUrlArgs; | 
|---|
|  |  |  | import io.minio.ListObjectsArgs; | 
|---|
|  |  |  | import io.minio.PutObjectArgs; | 
|---|
|  |  |  | import io.minio.Result; | 
|---|
|  |  |  | import io.minio.http.Method; | 
|---|
|  |  |  | import io.minio.messages.Item; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import okhttp3.OkHttpClient; | 
|---|
|  |  |  | import okhttp3.Request; | 
|---|
|  |  |  | import okhttp3.Response; | 
|---|
|  |  |  | import okhttp3.ResponseBody; | 
|---|
|  |  |  | import org.apache.commons.codec.digest.DigestUtils; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import com.ruoyi.sy.mapper.ArdSyCarMapper; | 
|---|
|  |  |  | import com.ruoyi.sy.domain.ArdSyCar; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 三一车辆Service业务层处理 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ArdSyUserMapper ardSyUserMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private SysUserMapper userMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private SYClient sYClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private ArdSyCarDayMapper ardSyCarDayMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Map<Integer,Map<String,String>> logInMap = new HashMap(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private  Map<String, Timer> userCarTimerMap = new HashMap(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询三一车辆 | 
|---|
|  |  |  | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ArdSyUser ardSyUser = ardSyUserList.get(0); | 
|---|
|  |  |  | Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); | 
|---|
|  |  |  | //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()); | 
|---|
|  |  |  | String sessionId = (String) LogInResult.get("sessionId"); | 
|---|
|  |  |  | Map<String,Object> carListMap = SYCarClient.getCarList(syURL,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"); | 
|---|
|  |  |  | ArdSyCar ardSyCar = new ArdSyCar(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ArdSyUser ardSyUser = ardSyUserList.get(0); | 
|---|
|  |  |  | Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); | 
|---|
|  |  |  | //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()); | 
|---|
|  |  |  | String sessionId = (String) LogInResult.get("sessionId"); | 
|---|
|  |  |  | Map<String,Object> carListMap = SYCarClient.getCarList(syURL,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"); | 
|---|
|  |  |  | /*ArdSyCar ardSyCar = new ArdSyCar(); | 
|---|
|  |  |  | List<ArdSyCar> ardSyCarList = ardSyCarMapper.selectArdSyCarList(ardSyCar); | 
|---|
|  |  |  | List<String> carIdList = new ArrayList(); | 
|---|
|  |  |  | for(ArdSyCar innerArdSyCar : ardSyCarList){ | 
|---|
|  |  |  | carIdList.add(innerArdSyCar.getCarId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).collect(Collectors.toList()); | 
|---|
|  |  |  | result.put("data",carList);*/ | 
|---|
|  |  |  | result.put("data",list); | 
|---|
|  |  |  | result.put("code","200"); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | 
|---|
|  |  |  | return ""; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @Override | 
|---|
|  |  |  | //    public List<ArdSyCar> getArdSyCarWithRightByCarIdList(List<String> carIdList) { | 
|---|
|  |  |  | //        List<ArdSyCar> result = ardSyCarMapper.getArdSyCarWithRightByCarIdList(carIdList); | 
|---|
|  |  |  | //        return result; | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Results carListById(String id) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<ArdSyCar> list = ardSyCarMapper.carListById(id); | 
|---|
|  |  |  | if(list.size()>0){ | 
|---|
|  |  |  | ArdSyCar ardSyCar = list.get(0); | 
|---|
|  |  |  | return Results.succeed(ardSyCar); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | return Results.succeed(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return Results.error(e.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void sendArdSyCarPosition() { | 
|---|
|  |  |  | for(String key : ONLINE_USER_SESSIONS.keySet()){ | 
|---|
|  |  |  | if(PositionContainer.getUserPositionMap().keySet().contains(key)){//当追踪的车辆容器包含此用户Id,则实时位置推送需要剔除该车辆 | 
|---|
|  |  |  | SysUser sysUser = userMapper.selectUserById(key); | 
|---|
|  |  |  | if(sysUser == null){ | 
|---|
|  |  |  | //return; | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String deptId = String.valueOf(sysUser.getDeptId()); | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | data.put("30000", map.values()); | 
|---|
|  |  |  | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | SysUser sysUser = userMapper.selectUserById(key); | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | 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)){ | 
|---|
|  |  |  | userCarTimerMap.get(userId).cancel(); | 
|---|
|  |  |  | userCarTimerMap.remove(userId); | 
|---|
|  |  |  | PositionContainer.getUserPositionMap().remove(userId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void sendArdSyCarAlarmByCarId(String carId, Map<String,Object> data) { | 
|---|
|  |  |  | List<SysUser> result = userMapper.getSysUserByCarId(carId); | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | //判断关联表是否有数据 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | 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("在线")){ | 
|---|
|  |  |  | online = online + 1; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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("列表为空!","无关联账号!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | //拿到车辆数据 | 
|---|
|  |  |  | list= (List) carList31.get("list"); | 
|---|
|  |  |  | if(list.isEmpty()){ | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | List<String> carIdList = new ArrayList(); | 
|---|
|  |  |  | //所有carId | 
|---|
|  |  |  | for(Map<String,String> m : list){ | 
|---|
|  |  |  | carIdList.add(m.get("carId")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | switch (m.get("state")) { | 
|---|
|  |  |  | case "1": | 
|---|
|  |  |  | m.put("carState", "离线-从未报定位");break; | 
|---|
|  |  |  | case "2": | 
|---|
|  |  |  | m.put("carState", "离线-欠费");break; | 
|---|
|  |  |  | case "3": | 
|---|
|  |  |  | m.put("carState", "离线");break; | 
|---|
|  |  |  | case "4": | 
|---|
|  |  |  | m.put("carState", "离线-报警");break; | 
|---|
|  |  |  | case "5": | 
|---|
|  |  |  | m.put("carState", "在线-从未报定位");break; | 
|---|
|  |  |  | case "6": | 
|---|
|  |  |  | m.put("carState", "在线-欠费");break; | 
|---|
|  |  |  | case "7": | 
|---|
|  |  |  | m.put("carState", "在线-行驶");break; | 
|---|
|  |  |  | case "8": | 
|---|
|  |  |  | m.put("carState", "在线-行驶-报警");break; | 
|---|
|  |  |  | case "9": | 
|---|
|  |  |  | m.put("carState", "在线-停车-ACC关");break; | 
|---|
|  |  |  | case "10": | 
|---|
|  |  |  | m.put("carState", "在线-停车-ACC开");break; | 
|---|
|  |  |  | case "11": | 
|---|
|  |  |  | m.put("carState", "在线-停车-ACC关-报警");break; | 
|---|
|  |  |  | case "12": | 
|---|
|  |  |  | m.put("carState", "在线-停车-ACC开-报警");break; | 
|---|
|  |  |  | case "13": | 
|---|
|  |  |  | m.put("carState", "在线-无效定位");break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据dept集合查询出所有对应的carId | 
|---|
|  |  |  | * @param deptList | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Map<String,String>> carIdByDeptList(List<Long> deptList,List<Map<String,String>> list){ | 
|---|
|  |  |  | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | queryWrapper.in("dept_id",deptList); | 
|---|
|  |  |  | List<ArdSyCar> carList = ardSyCarMapper.selectList(queryWrapper); | 
|---|
|  |  |  | //对比把匹配到的数据添加到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())){ | 
|---|
|  |  |  | String url = ""; | 
|---|
|  |  |  | if(ardSyCar.getCarPicture() != null){ | 
|---|
|  |  |  | if(!ardSyCar.getCarPicture().equals("")){ | 
|---|
|  |  |  | url = ardSyCar.getCarPicture().split("sycar")[0]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 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 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()){ | 
|---|
|  |  |  | return Results.succeed(); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | for(Map<String,Object> m : list) { | 
|---|
|  |  |  | String alarmStts = (String) m.get("alarmStts"); | 
|---|
|  |  |  | Map<String, List<String>> alarmMap = getInfo("alarm", alarmStts); | 
|---|
|  |  |  | m.putAll(alarmMap); | 
|---|
|  |  |  | String carStts = (String) m.get("carStts"); | 
|---|
|  |  |  | Map<String, List<String>> carMap = getInfo("car", carStts); | 
|---|
|  |  |  | m.putAll(carMap); | 
|---|
|  |  |  | String sgnStts = (String) m.get("sgnStts"); | 
|---|
|  |  |  | Map<String, List<String>> sgnMap = getInfo("sgn", sgnStts); | 
|---|
|  |  |  | m.putAll(sgnMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Results.succeed(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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[] carTypes89 = {"空车","半载","保留","满载"}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Object[] carTypes = {"ACC开","定位","南纬","西经","停运状态","经纬度已经保密插件加密","保留","保留",carTypes89,"车辆油路断开","车门加锁", | 
|---|
|  |  |  | "车辆电路断开","门1开(前门)","门2开(中门)","门3开(后门","门4开(驾驶席门","门5开","使用GPS 卫星进行定位","使用北斗卫星进行定位", | 
|---|
|  |  |  | "使用GLONASS卫星进行定位","使用Galileo卫星进行定位","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留"}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String[] sgnTypes = {"近光灯信号","远光灯信号","右转向灯信号","左转向灯信号","制动信号","倒档信号","雾灯信号","示廓灯","喇叭信号","空调状态", | 
|---|
|  |  |  | "空挡信号","缓速器工作","ABS 工作","加热器工作","离合器状态","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留","保留", | 
|---|
|  |  |  | "保留","保留","保留","保留","保留","保留"}; | 
|---|
|  |  |  | Integer sttsHex = Integer.parseInt(stts, 16); | 
|---|
|  |  |  | String sttsBin = Integer.toBinaryString(sttsHex); | 
|---|
|  |  |  | if(sttsBin.length() < 32){ | 
|---|
|  |  |  | while(sttsBin.length() < 32){ | 
|---|
|  |  |  | sttsBin = "0" + sttsBin; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String[] sttsBinArray = sttsBin.split(""); | 
|---|
|  |  |  | switch (type) { | 
|---|
|  |  |  | case "alarm": | 
|---|
|  |  |  | List<String> alarmTypeArray = new ArrayList(); | 
|---|
|  |  |  | for (int i = 0; i < sttsBinArray.length; i++) { | 
|---|
|  |  |  | if(sttsBinArray[i].equals("1")){ | 
|---|
|  |  |  | alarmTypeArray.add(alarmTypes[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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")){ | 
|---|
|  |  |  | carTypeArray.add(alarmTypes[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(i == 8){ | 
|---|
|  |  |  | switch (sttsBinArray[8]+sttsBinArray[9]) { | 
|---|
|  |  |  | case "00": | 
|---|
|  |  |  | carTypeArray.add(carTypes89[0]); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "01": | 
|---|
|  |  |  | carTypeArray.add(carTypes89[1]); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "10": | 
|---|
|  |  |  | carTypeArray.add(carTypes89[2]); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case "11": | 
|---|
|  |  |  | carTypeArray.add(carTypes89[3]); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(i == 9){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String,List<String>> carMap = new HashMap(); | 
|---|
|  |  |  | List<String> carTypeArray0 = new ArrayList(); | 
|---|
|  |  |  | for(String str : carTypeArray){ | 
|---|
|  |  |  | if(!str.equals("保留")){ | 
|---|
|  |  |  | carTypeArray0.add(str); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | carMap.put(type, carTypeArray0); | 
|---|
|  |  |  | return carMap; | 
|---|
|  |  |  | case "sgn": | 
|---|
|  |  |  | List<String> sgnTypeArray = new ArrayList(); | 
|---|
|  |  |  | for (int i = 0; i < sttsBinArray.length; i++) { | 
|---|
|  |  |  | if(sttsBinArray[i].equals("1")){ | 
|---|
|  |  |  | sgnTypeArray.add(alarmTypes[i]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String,List<String>> sgnMap = new HashMap(); | 
|---|
|  |  |  | List<String> sgnTypeArray0 = new ArrayList(); | 
|---|
|  |  |  | for(String str : sgnTypeArray){ | 
|---|
|  |  |  | if(!str.equals("保留")){ | 
|---|
|  |  |  | sgnTypeArray0.add(str); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sgnMap.put(type, sgnTypeArray0); | 
|---|
|  |  |  | return sgnMap; | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | return new HashMap<String,List<String>>(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | return Results.succeed(result0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Results chaseCarByCarId(String usersId, String carId, String cycle) { | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | userCarTimerMap.get(usersId).cancel(); | 
|---|
|  |  |  | userCarTimerMap.remove(usersId); | 
|---|
|  |  |  | PositionContainer.getUserPositionMap().remove(usersId); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Results.succeed("停止追踪"); | 
|---|
|  |  |  | }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); | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | Timer carPositionTimer = new Timer();//定时推送实时位置 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | Date date = new Date(); | 
|---|
|  |  |  | Timer carPositionTimer = new Timer();//定时推送实时位置 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | carPositionTimer.scheduleAtFixedRate(carPositionTask,date,Integer.parseInt(cycle));//启用 | 
|---|
|  |  |  | this.userCarTimerMap.put(usersId,carPositionTimer); | 
|---|
|  |  |  | return Results.succeed("开始追踪"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return Results.error("追踪失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*@Override | 
|---|
|  |  |  | public Results getExistTraceByCarIdAndMonth(String userId, String carId, String time) { | 
|---|
|  |  |  | SysConfig config = new SysConfig(); | 
|---|
|  |  |  | config.setConfigKey("syCarPT"); | 
|---|
|  |  |  | List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config); | 
|---|
|  |  |  | String syURL = ""; | 
|---|
|  |  |  | if(sysConfigResult.size() == 0){ | 
|---|
|  |  |  | return Results.succeed("三一车辆url没有录入"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | syURL = sysConfigResult.get(0).getConfigValue(); | 
|---|
|  |  |  | ArdSyUser ardSyUserPara = new ArdSyUser(); | 
|---|
|  |  |  | ardSyUserPara.setSysUserId(userId); | 
|---|
|  |  |  | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); | 
|---|
|  |  |  | if(ardSyUserList.size() == 0){ | 
|---|
|  |  |  | return Results.succeed("用户未挂接三一车辆"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | ArdSyUser ardSyUser = ardSyUserList.get(0); | 
|---|
|  |  |  | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); | 
|---|
|  |  |  | Map<String,Integer> existTraceMap = getExistTraceByCarIdAndMonth(syURL,ardSyUser.getUserId(),passwordMd5,carId,time); | 
|---|
|  |  |  | return Results.succeed(existTraceMap); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Results getExistTraceByCarIdAndMonth(String userId, String carId, String time) { | 
|---|
|  |  |  | List<ArdSyCarDay> result = ardSyCarDayMapper.selectArdSyCarDayByCarIdAndDay(carId,time + "%"); | 
|---|
|  |  |  | List<String> list = new ArrayList(); | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | String sessionId = (String) LogInResult.get("sessionId"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); | 
|---|
|  |  |  | Date date = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | date = sdf.parse(time); | 
|---|
|  |  |  | } catch (ParseException e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Calendar calendar = Calendar.getInstance(); | 
|---|
|  |  |  | calendar.setTime(date); | 
|---|
|  |  |  | int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//获取该月天数 | 
|---|
|  |  |  | 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 finalsyURL = url; | 
|---|
|  |  |  | newCachedThreadPoll.execute(new Runnable(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | int temp0 = temp + 6; | 
|---|
|  |  |  | if(temp0 > maxDay){ | 
|---|
|  |  |  | temp0 = maxDay; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (int j = temp; j <= temp0; j++) { | 
|---|
|  |  |  | if(j <= 9){ | 
|---|
|  |  |  | existTraceMap.put("0" + String.valueOf(j), -1); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | existTraceMap.put(String.valueOf(j), -1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | String time = (String) m.get("time"); | 
|---|
|  |  |  | time = time.split(" ")[0]; | 
|---|
|  |  |  | time = time.split("-")[2]; | 
|---|
|  |  |  | existTraceMap.put(time, 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }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){ | 
|---|
|  |  |  | String time = (String) m.get("time"); | 
|---|
|  |  |  | time = time.split(" ")[0]; | 
|---|
|  |  |  | time = time.split("-")[2]; | 
|---|
|  |  |  | existTraceMap.put(time, 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }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){ | 
|---|
|  |  |  | String time = (String) m.get("time"); | 
|---|
|  |  |  | time = time.split(" ")[0]; | 
|---|
|  |  |  | time = time.split("-")[2]; | 
|---|
|  |  |  | existTraceMap.put(time, 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for(int j = temp; j <= temp0; j++){ | 
|---|
|  |  |  | String key = ""; | 
|---|
|  |  |  | if(j <= 9){ | 
|---|
|  |  |  | key = "0" + j; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | key = String.valueOf(j); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(existTraceMap.get(key) == -1){ | 
|---|
|  |  |  | existTraceMap.put(key, 0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | while(true){ | 
|---|
|  |  |  | if(!existTraceMap.values().contains(-1)){ | 
|---|
|  |  |  | if(existTraceMap.size() == maxDay){ | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | return existTraceMap; | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | newCachedThreadPoll.shutdown(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | .build(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Response response = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = okHttpClient.newCall(request).execute(); | 
|---|
|  |  |  | } catch (IOException e1) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e1.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | response.headers(); //响应头 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ResponseBody responseBody = response.body(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String message = responseBody.string();// 响应体 | 
|---|
|  |  |  | Map<String,Object> map = (Map<String, Object>) JSON.parse(message); | 
|---|
|  |  |  | //System.out.println(message); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return new HashMap(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|