|  | @@ -0,0 +1,1173 @@
 | 
	
		
			
				|  |  | +package net.lab1024.smartadmin.module.business.gps.service;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.TypeReference;
 | 
	
		
			
				|  |  | +import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  | +import com.google.common.collect.Maps;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.common.constant.ResponseCodeConst;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.common.domain.ResponseDTO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.common.exception.SmartResponseCodeException;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.amap.track.*;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.domain.DTO.GpsHistoryQueryDto;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.domain.entity.*;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.mileage.dao.GpsImeiMileageDao;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.mileage.domain.entity.GpsImeiMileageEntity;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.dao.GpsImeiVehicleDao;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.domain.dto.GpsImeiVehicleAddDTO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.domain.dto.GpsImeiVehicleQueryDTO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.domain.entity.GpsImeiVehicleEntity;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.domain.vo.GpsImeiVehicleVO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.gps.vehicle.service.GpsImeiVehicleService;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.paigong.dao.DispatchDao;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.paigong.domain.dto.DispatchQueryDTO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.module.business.paigong.domain.vo.DispatchVO;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.third.SmartRedisService;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.util.SmartCommonUtils;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.util.SmartDateUtil;
 | 
	
		
			
				|  |  | +import net.lab1024.smartadmin.util.SmartHttpUtil;
 | 
	
		
			
				|  |  | +import org.slf4j.Logger;
 | 
	
		
			
				|  |  | +import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * [  ]
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * @author yandanyang
 | 
	
		
			
				|  |  | + * @version 1.0
 | 
	
		
			
				|  |  | + * @company 1024lab.net
 | 
	
		
			
				|  |  | + * @copyright (c) 2019 1024lab.netInc. All rights reserved.
 | 
	
		
			
				|  |  | + * @date 2019-05-13 17:10:16
 | 
	
		
			
				|  |  | + * @since JDK1.8
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +@Service
 | 
	
		
			
				|  |  | +public class GpsService {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private SmartRedisService smartRedisService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GpsImeiVehicleDao gpsImeiVehicleDao;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GpsImeiMileageDao gpsImeiMileageDao;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GpsImeiVehicleService gpsImeiVehicleService;
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private DispatchDao dispatchDao;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	protected Logger logger = LoggerFactory.getLogger(getClass());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取token
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return token
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public String getToken() {
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | + 		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"account\": \"烟台晨曦\",\n" +
 | 
	
		
			
				|  |  | +				"        \"pwd_md5\": \"e003df7d8f6dc1393e333687c82db98f\",\n" +
 | 
	
		
			
				|  |  | +				"        \"lang\": \"ch\",\n" +
 | 
	
		
			
				|  |  | +				"        \"platform\": \"web\",\n" +
 | 
	
		
			
				|  |  | +				"        \"type\": 39,\n" +
 | 
	
		
			
				|  |  | +				"        \"info\": \"IP:124.131.63.104,山东省烟台市;projectName=远近在线,物联设备管控平台;system=windows(Win32);cookieEnabled=true;navigator=chrome;version=103.0.0.0\"\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"user\",\n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"Login\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +		return jsonObject.get("sid").toString();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取token
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return token
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public String getRedisToken(String imei) {
 | 
	
		
			
				|  |  | +//		if (!smartRedisService.hasKey(imei+"token")) {
 | 
	
		
			
				|  |  | +//			smartRedisService.set(imei+"token", this.getToken(), 6000);
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		return smartRedisService.get(imei+"token");
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public String getRedisToken() {
 | 
	
		
			
				|  |  | +		if (!smartRedisService.hasKey("loginToken")) {
 | 
	
		
			
				|  |  | +			smartRedisService.set("loginToken", this.getToken());
 | 
	
		
			
				|  |  | +			smartRedisService.expire("loginToken", 172800);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		System.out.println(smartRedisService.getExpire("loginToken"));
 | 
	
		
			
				|  |  | +		return smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 查询redis中token是否过期
 | 
	
		
			
				|  |  | +	 * false表示过期
 | 
	
		
			
				|  |  | +	 * @return token
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public boolean getRedisTokenExpire() {
 | 
	
		
			
				|  |  | +		if(smartRedisService.getExpire("loginToken") != -2){
 | 
	
		
			
				|  |  | +			return true;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return false;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取车组列表
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return familyId
 | 
	
		
			
				|  |  | +	 **/
 | 
	
		
			
				|  |  | +	public String getFamilyId() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"f_limit_size\": 100,\n" +
 | 
	
		
			
				|  |  | +				"        \"g_limit_size\": 100,\n" +
 | 
	
		
			
				|  |  | +				"        \"familyid\": \"\",\n" +
 | 
	
		
			
				|  |  | +				"        \"last_fid\": \"\",\n" +
 | 
	
		
			
				|  |  | +				"        \"last_gid\": \"\"\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"family\",\n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"GetFamilyList\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +		String familys = "";
 | 
	
		
			
				|  |  | +		String familyid = "";
 | 
	
		
			
				|  |  | +		if(!SmartCommonUtils.isEmpty(jsonObject.get("familys").toString())){
 | 
	
		
			
				|  |  | +			familys =  jsonObject.get("familys").toString();
 | 
	
		
			
				|  |  | +			int index = familys.lastIndexOf(":") + 1;
 | 
	
		
			
				|  |  | +			int lastIndex = familys.lastIndexOf("}") -1;
 | 
	
		
			
				|  |  | +			familyid = familys.substring(index+1,lastIndex);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return familyid;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 获取设备号
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return simeiId
 | 
	
		
			
				|  |  | +     **/
 | 
	
		
			
				|  |  | +    public String getSimeiId() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +        String familyId = this.getFamilyId();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"limit_size\": 100,\n" +
 | 
	
		
			
				|  |  | +				"        \"get_increment\": true,\n" +
 | 
	
		
			
				|  |  | +				"        \"familyid\": \""+familyId+"\"\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"family\",\n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"GetDeviceList\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String returnValue = null;
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +        } catch (Exception e) {
 | 
	
		
			
				|  |  | +            e.printStackTrace();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//		String json1 = returnValue.substring(json.indexOf("simei"));
 | 
	
		
			
				|  |  | +//		String json2 = json.substring(json.indexOf("simei")).substring(0,json1.indexOf(","));
 | 
	
		
			
				|  |  | +//		String json3 = json2.substring(json2.indexOf(":")+3,json2.lastIndexOf("\""));
 | 
	
		
			
				|  |  | +//		return json3;
 | 
	
		
			
				|  |  | +		return jsonObject.toString();
 | 
	
		
			
				|  |  | +//		return jsonObject.get("items").toString();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取单个设备最新位置信息
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public ResponseDTO tracking(String imei) {
 | 
	
		
			
				|  |  | +//		String httpUrl = "https://api.gpsoo.net/1/devices/tracking";
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		Map<String, Object> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//		map.put("imeis", imei);
 | 
	
		
			
				|  |  | +//		ResponseDTO responseDTO = this.returnInfo(httpUrl,map);
 | 
	
		
			
				|  |  | +//		if(!responseDTO.isSuccess()){
 | 
	
		
			
				|  |  | +//			return responseDTO;
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		List<TrackingGps> trackingGps = JSONObject.parseObject(responseDTO.getData().toString(), new TypeReference<ArrayList<TrackingGps>>() {});
 | 
	
		
			
				|  |  | +//		return ResponseDTO.succData(trackingGps);
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public JSONObject tracking(String simei) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +		simei = this.findDev(simei);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"  \"module\": \"location\",\n" +
 | 
	
		
			
				|  |  | +				"  \"func\": \"Tracking\",\n" +
 | 
	
		
			
				|  |  | +				"  \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"    \"effective_time\": 120,\n" +
 | 
	
		
			
				|  |  | +				"    \"interval_time\": 120,\n" +
 | 
	
		
			
				|  |  | +				"    \"is_add_log\": true,\n" +
 | 
	
		
			
				|  |  | +				"    \"simei\": \""+simei+"\"\n" +
 | 
	
		
			
				|  |  | +				"  }\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String resultValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			resultValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		JSONObject jsonObject = JSONObject.parseObject(resultValue);
 | 
	
		
			
				|  |  | +		return jsonObject;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 模糊查询设备号,返回加密后的设备号
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public String findDev(String imei){
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"imei\": \""+imei+"\",\n" +
 | 
	
		
			
				|  |  | +				"        \"recovery\": false\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"device\",\n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"FindDev\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String str =  jsonObject.get("items").toString();
 | 
	
		
			
				|  |  | +		String newSimei = str.substring(str.lastIndexOf(":")+2,str.length()-3);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		return newSimei;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 历史轨迹
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public ResponseDTO history(GpsHistoryQueryDto queryDto){
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		String simei = this.getSimeiId();
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		String sid = "";
 | 
	
		
			
				|  |  | +//		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +//			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +//		}else {
 | 
	
		
			
				|  |  | +//			sid = getRedisToken();
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		String json = "{\n" +
 | 
	
		
			
				|  |  | +//				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +//				"        \"limit_size\": 1000,\n" +
 | 
	
		
			
				|  |  | +//				"        \"time_begin\": 1655654400,\n" +
 | 
	
		
			
				|  |  | +//				"        \"time_end\": 1655740799,\n" +
 | 
	
		
			
				|  |  | +//				"        \"is_all\": false,\n" +
 | 
	
		
			
				|  |  | +//				"        \"simei\": \""+simei+"\"\n" +
 | 
	
		
			
				|  |  | +//				"    },\n" +
 | 
	
		
			
				|  |  | +//				"    \"module\": \"location\",\n" +
 | 
	
		
			
				|  |  | +//				"    \"func\": \"QueryLocation\"\n" +
 | 
	
		
			
				|  |  | +//				"}";
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +//		ResponseDTO responseDTO = this.returnInfo(httpUrl,json);
 | 
	
		
			
				|  |  | +//		if(!responseDTO.isSuccess()){
 | 
	
		
			
				|  |  | +//			return responseDTO;
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		List<GpsHistory> gpsHistories = JSONObject.parseObject(responseDTO.getData().toString(), new TypeReference<ArrayList<GpsHistory>>() {});
 | 
	
		
			
				|  |  | +//		return ResponseDTO.succData(gpsHistories);
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public ResponseDTO history(GpsHistoryQueryDto queryDto){
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String simei = this.findDev(queryDto.getImei());
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		BigDecimal thousand = new BigDecimal(1000);
 | 
	
		
			
				|  |  | +		BigDecimal beginTime = new BigDecimal(queryDto.getBeginDate().getTime()).divide(thousand);
 | 
	
		
			
				|  |  | +		BigDecimal endTime = new BigDecimal(queryDto.getEndDate().getTime()).divide(thousand);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"limit_size\": 1000,\n" +
 | 
	
		
			
				|  |  | +				"        \"time_begin\": "+beginTime+",\n" +
 | 
	
		
			
				|  |  | +				"        \"time_end\": "+endTime+",\n" +
 | 
	
		
			
				|  |  | +				"        \"is_all\": false,\n" +
 | 
	
		
			
				|  |  | +				"        \"simei\": \""+simei+"\"\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"location\",   \n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"QueryLocation\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +		ResponseDTO responseDTO = this.returnInfo(httpUrl,json);
 | 
	
		
			
				|  |  | +		if(!responseDTO.isSuccess() || SmartCommonUtils.isEmpty(responseDTO.getData())){
 | 
	
		
			
				|  |  | +			return responseDTO;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		List<GpsHistory> gpsHistories = JSONObject.parseObject(responseDTO.getData().toString(), new TypeReference<ArrayList<GpsHistory>>() {});
 | 
	
		
			
				|  |  | +		return ResponseDTO.succData(gpsHistories);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 返回接口信息
 | 
	
		
			
				|  |  | +	 * @param httpUrl 接口地址
 | 
	
		
			
				|  |  | +	 * @param json 参数
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public ResponseDTO returnInfo(String httpUrl, String json) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +			GpsReturnHisToryDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnHisToryDto.class);
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(gpsReturnDto.getErrcode()) && 0 != gpsReturnDto.getErrcode()) {
 | 
	
		
			
				|  |  | +				return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR,gpsReturnDto.getError_message());
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				return ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return ResponseDTO.succ();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	public ResponseDTO returnInfo2(String httpUrl, Map<String, Object> map) {
 | 
	
		
			
				|  |  | +		String tms;
 | 
	
		
			
				|  |  | +		if(SmartCommonUtils.isEmpty(map.get("timestamp"))){
 | 
	
		
			
				|  |  | +			 tms = String.valueOf(SmartDateUtil.parseYMDHMS("2021-10-20 00:00:00").getTime() / 1000);
 | 
	
		
			
				|  |  | +		}else{
 | 
	
		
			
				|  |  | +			tms = map.get("timestamp").toString();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		String imei = "威高汽车";
 | 
	
		
			
				|  |  | +		map.put("timestamp", String.valueOf("0"));
 | 
	
		
			
				|  |  | +//		map.put("access_token", this.getRedisToken(imei));
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendGet(httpUrl, map, null);
 | 
	
		
			
				|  |  | +			GpsReturnDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnDto.class);
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(gpsReturnDto.getRet()) && 0 != gpsReturnDto.getRet()) {
 | 
	
		
			
				|  |  | +				return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR,gpsReturnDto.getMsg());
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				return ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return ResponseDTO.succ();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 返回接口信息
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public ResponseDTO returnInfo1(String httpUrl, Map<String, Object> map) {
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		long tms =SmartDateUtil.getDate().getTime() / 1000;
 | 
	
		
			
				|  |  | +//		String imei = null;
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		if(SmartCommonUtils.isEmpty(map.get("imeis"))){
 | 
	
		
			
				|  |  | +//			imei = map.get("imei").toString();
 | 
	
		
			
				|  |  | +//		}else{
 | 
	
		
			
				|  |  | +//			imei = map.get("imeis").toString();
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		map.put("account", imei);
 | 
	
		
			
				|  |  | +////		map.put("access_token", this.getRedisToken(imei));
 | 
	
		
			
				|  |  | +//		String returnValue = null;
 | 
	
		
			
				|  |  | +//		try {
 | 
	
		
			
				|  |  | +//			returnValue = SmartHttpUtil.sendGet(httpUrl, map, null);
 | 
	
		
			
				|  |  | +//			GpsReturnDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnDto.class);
 | 
	
		
			
				|  |  | +//			if (!SmartCommonUtils.isEmpty(gpsReturnDto.getRet()) && 0 != gpsReturnDto.getRet()) {
 | 
	
		
			
				|  |  | +//				return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR,gpsReturnDto.getMsg());
 | 
	
		
			
				|  |  | +//			} else {
 | 
	
		
			
				|  |  | +//				return ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//		} catch (Exception e) {
 | 
	
		
			
				|  |  | +//			e.printStackTrace();
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		return ResponseDTO.succ();
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public ResponseDTO returnInfo1(String httpUrl, String json) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +			GpsReturnNewDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnNewDto.class);
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(gpsReturnDto.getErrcode()) && 0 != gpsReturnDto.getErrcode()) {
 | 
	
		
			
				|  |  | +				return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR,gpsReturnDto.getError_message());
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				return ResponseDTO.succData(gpsReturnDto.getItems());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return ResponseDTO.succ();
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//	/**
 | 
	
		
			
				|  |  | +//	 * 返回接口信息
 | 
	
		
			
				|  |  | +//	 * @param httpUrl 接口地址
 | 
	
		
			
				|  |  | +//	 * @param map 参数
 | 
	
		
			
				|  |  | +//	 * @return
 | 
	
		
			
				|  |  | +//	 */
 | 
	
		
			
				|  |  | +//	public ResponseDTO returnInfoByJson(String httpUrl, Map<String, Object> map) {
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//		map.put("sid", this.getToken());
 | 
	
		
			
				|  |  | +//		String returnValue = null;
 | 
	
		
			
				|  |  | +//		try {
 | 
	
		
			
				|  |  | +//			returnValue = SmartHttpUtil.sendPostJson(httpUrl, map, null);
 | 
	
		
			
				|  |  | +//			GpsReturnDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnDto.class);
 | 
	
		
			
				|  |  | +//			if (!SmartCommonUtils.isEmpty(gpsReturnDto.getRet()) && 0 != gpsReturnDto.getRet()) {
 | 
	
		
			
				|  |  | +//				return ResponseDTO.wrap(ResponseCodeConst.SYSTEM_ERROR,gpsReturnDto.getMsg());
 | 
	
		
			
				|  |  | +//			} else {
 | 
	
		
			
				|  |  | +//				return ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//		} catch (Exception e) {
 | 
	
		
			
				|  |  | +//			e.printStackTrace();
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		return ResponseDTO.succ();
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 添加新车辆,创建终端,新建默认轨迹
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +	public ResponseDTO addVehicle(GpsImeiVehicleAddDTO addDTO) {
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			//车辆id不能重复,车牌号不能重复,设备不能重复
 | 
	
		
			
				|  |  | +			GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +			gpsImeiVehicleQueryDTO.setImei(addDTO.getImei());
 | 
	
		
			
				|  |  | +			List<GpsImeiVehicleVO> list = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +			if(!SmartCommonUtils.isEmpty(list)){
 | 
	
		
			
				|  |  | +				throw new SmartResponseCodeException(9999,"该车辆信息已存在");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +//			AMapTrackClient client = new AMapTrackClient(Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +//			net.lab1024.smartadmin.module.business.amap.track.Service service = client.getService(null, "weigao");
 | 
	
		
			
				|  |  | +//			Terminal terminal = service.createTerminal(addDTO.getImei(), null, Maps.newHashMap());
 | 
	
		
			
				|  |  | +//			Trace trace = terminal.createTrace();
 | 
	
		
			
				|  |  | +			//保存车辆信息
 | 
	
		
			
				|  |  | +			GpsImeiVehicleEntity gpsImeiVehicleEntity = new GpsImeiVehicleEntity();
 | 
	
		
			
				|  |  | +			gpsImeiVehicleEntity.setImei(addDTO.getImei());
 | 
	
		
			
				|  |  | +			gpsImeiVehicleEntity.setVehLicense(addDTO.getVehLicense());
 | 
	
		
			
				|  |  | +//			gpsImeiVehicleEntity.setTerminalId(String.valueOf(terminal.getTid()));
 | 
	
		
			
				|  |  | +//			gpsImeiVehicleEntity.setServiceId(String.valueOf(service.getSid()));
 | 
	
		
			
				|  |  | +			gpsImeiVehicleDao.insert(gpsImeiVehicleEntity);
 | 
	
		
			
				|  |  | +			//创建当天的轨迹
 | 
	
		
			
				|  |  | +			GpsImeiMileageEntity gpsImeiMileageEntity = new GpsImeiMileageEntity();
 | 
	
		
			
				|  |  | +			gpsImeiMileageEntity.setImei(addDTO.getImei());
 | 
	
		
			
				|  |  | +			gpsImeiMileageEntity.setTime(SmartDateUtil.getDate());
 | 
	
		
			
				|  |  | +//			gpsImeiMileageEntity.setTraceId(String.valueOf(trace.getTrid()));
 | 
	
		
			
				|  |  | +			gpsImeiMileageDao.insert(gpsImeiMileageEntity);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			smartRedisService.set(gpsImeiMileageEntity.getImei(), gpsImeiMileageEntity.getTraceId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			//刷新redis缓存
 | 
	
		
			
				|  |  | +			smartRedisService.del("vehicleList");
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			throw new SmartResponseCodeException(9999, e.getMessage());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return ResponseDTO.succData(gpsImeiVehicleDao);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取车辆的里程
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public Integer getMileage(GpsHistoryQueryDto queryDto){
 | 
	
		
			
				|  |  | +//		//根据车牌号,获取车辆对应的设备
 | 
	
		
			
				|  |  | +//		List<String> getiIntervalDate = SmartDateUtil.getiIntervalDate(SmartDateUtil.formatYMDHMS(queryDto.getBeginDate()), SmartDateUtil.formatYMDHMS(queryDto.getEndDate()));
 | 
	
		
			
				|  |  | +//		Integer distance = 0;
 | 
	
		
			
				|  |  | +//		for (int i = 0; i < getiIntervalDate.size(); i++) {
 | 
	
		
			
				|  |  | +//			GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +//			gpsImeiVehicleQueryDTO.setVehLicense(queryDto.getVehLicense());
 | 
	
		
			
				|  |  | +//			List<GpsImeiVehicleVO> gpsImeiVehicleVO = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +//			if (i == getiIntervalDate.size() - 1) {
 | 
	
		
			
				|  |  | +//				break;
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//			for (GpsImeiVehicleVO imeiVehicleVO : gpsImeiVehicleVO) {
 | 
	
		
			
				|  |  | +//				Map<String, Object> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//				map.put("key", Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +//				map.put("sid", Const.GAODE_SERVICE);
 | 
	
		
			
				|  |  | +//				map.put("tid", imeiVehicleVO.getTerminalId());
 | 
	
		
			
				|  |  | +////				map.put("trid", 0);
 | 
	
		
			
				|  |  | +//				map.put("ispoints", 0);
 | 
	
		
			
				|  |  | +//				Points points = this.returnTrace2(map, SmartDateUtil.parseYMDHMS(getiIntervalDate.get(i)), SmartDateUtil.parseYMDHMS(getiIntervalDate.get(i + 1)));
 | 
	
		
			
				|  |  | +//				if (!SmartCommonUtils.isEmpty(points)) {
 | 
	
		
			
				|  |  | +//					distance += points.getDistance();
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		return distance;
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public Integer getMileage(GpsHistoryQueryDto queryDto){
 | 
	
		
			
				|  |  | +		Integer distance = 0;
 | 
	
		
			
				|  |  | +		String vehicle = queryDto.getVehLicense();
 | 
	
		
			
				|  |  | +		String simei = "";
 | 
	
		
			
				|  |  | +		long beginTime = queryDto.getBeginDate().getTime()/1000;
 | 
	
		
			
				|  |  | +		long endTime = queryDto.getEndDate().getTime()/1000;
 | 
	
		
			
				|  |  | +		GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +		gpsImeiVehicleQueryDTO.setVehLicense(vehicle);
 | 
	
		
			
				|  |  | +		List<GpsImeiVehicleVO> gpsImeiVehicleVOS = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +		GpsImeiVehicleVO gpsImeiVehicleVO = gpsImeiVehicleVOS.get(0);
 | 
	
		
			
				|  |  | +		if(!SmartCommonUtils.isEmpty(gpsImeiVehicleVO)){
 | 
	
		
			
				|  |  | +			simei = gpsImeiVehicleVO.getImei();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		simei = this.findDev(simei);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String sid = "";
 | 
	
		
			
				|  |  | +		if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +			sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +		}else {
 | 
	
		
			
				|  |  | +			sid = getRedisToken();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +		String json = "{\n" +
 | 
	
		
			
				|  |  | +				"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +				"        \"limit_size\": 100,\n" +
 | 
	
		
			
				|  |  | +				"        \"time_begin\": "+beginTime+",\n" +
 | 
	
		
			
				|  |  | +				"        \"time_end\": "+endTime+",\n" +
 | 
	
		
			
				|  |  | +				"        \"simei\": [\n" +
 | 
	
		
			
				|  |  | +				"            \""+simei+"\"\n" +
 | 
	
		
			
				|  |  | +				"        ]\n" +
 | 
	
		
			
				|  |  | +				"    },\n" +
 | 
	
		
			
				|  |  | +				"    \"module\": \"location\",\n" +
 | 
	
		
			
				|  |  | +				"    \"func\": \"Distance\"\n" +
 | 
	
		
			
				|  |  | +				"}";
 | 
	
		
			
				|  |  | +		String returnValue = null;
 | 
	
		
			
				|  |  | +		try {
 | 
	
		
			
				|  |  | +			returnValue = SmartHttpUtil.sendPostJson(httpUrl, json, null);
 | 
	
		
			
				|  |  | +			GpsReturnNewDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnNewDto.class);
 | 
	
		
			
				|  |  | +			if(gpsReturnDto.getErrcode() == 0 && gpsReturnDto.getError_message().equals("Distance succeed.")){
 | 
	
		
			
				|  |  | +				JSONArray jsonArray = (JSONArray) gpsReturnDto.getItems();
 | 
	
		
			
				|  |  | +				JSONObject jsonObject = JSON.parseObject(jsonArray.get(0).toString());
 | 
	
		
			
				|  |  | +				distance = jsonObject.getInteger("distance");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} catch (Exception e) {
 | 
	
		
			
				|  |  | +			e.printStackTrace();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return distance;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取设备轨迹
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param queryDto
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public Points getTrace(GpsHistoryQueryDto queryDto) {
 | 
	
		
			
				|  |  | +//		List<String> getiIntervalDate = SmartDateUtil.getiIntervalDate(SmartDateUtil.formatYMDHMS(queryDto.getBeginDate()), SmartDateUtil.formatYMDHMS(queryDto.getEndDate()));
 | 
	
		
			
				|  |  | +//		List<Point> points = new ArrayList<>();
 | 
	
		
			
				|  |  | +//		Points points1 = new Points();
 | 
	
		
			
				|  |  | +//		for (int i = 0; i < getiIntervalDate.size(); i++) {
 | 
	
		
			
				|  |  | +//			//获取终端id
 | 
	
		
			
				|  |  | +//			GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +//			gpsImeiVehicleQueryDTO.setImei(queryDto.getImei());
 | 
	
		
			
				|  |  | +//			List<GpsImeiVehicleVO> gpsImeiVehicleVO = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +//			Map<String, Object> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//			map.put("key", Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +//			map.put("sid", Const.GAODE_SERVICE);
 | 
	
		
			
				|  |  | +//			if (i == getiIntervalDate.size() - 1) {
 | 
	
		
			
				|  |  | +//				break;
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//			if (!SmartCommonUtils.isEmpty(gpsImeiVehicleVO)) {
 | 
	
		
			
				|  |  | +//				map.put("tid", gpsImeiVehicleVO.get(0).getTerminalId());
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//			Points tracePoints = this.returnTrace(map, SmartDateUtil.parseYMDHMS(getiIntervalDate.get(i)), SmartDateUtil.parseYMDHMS(getiIntervalDate.get(i + 1)));
 | 
	
		
			
				|  |  | +//			if(!SmartCommonUtils.isEmpty(tracePoints)){
 | 
	
		
			
				|  |  | +//				points.addAll(tracePoints.getPoints());
 | 
	
		
			
				|  |  | +//				if(!SmartCommonUtils.isEmpty(points)){
 | 
	
		
			
				|  |  | +//					points = points.stream().sorted(Comparator.comparing(Point::getLocatetime)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +//				points1.setPoints(points);
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		return points1;
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public Points getTrace(GpsHistoryQueryDto queryDto) {
 | 
	
		
			
				|  |  | +//		List<String> getiIntervalDate = SmartDateUtil.getiIntervalDate(SmartDateUtil.formatYMDHMS(queryDto.getBeginDate()), SmartDateUtil.formatYMDHMS(queryDto.getEndDate()));
 | 
	
		
			
				|  |  | +		List<Point> points = new ArrayList<>();
 | 
	
		
			
				|  |  | +		Points points1 = new Points();
 | 
	
		
			
				|  |  | +		ResponseDTO<List<GpsHistory>> responseDTO = this.history(queryDto);
 | 
	
		
			
				|  |  | +		if (responseDTO.isSuccess()&&!SmartCommonUtils.isEmpty(responseDTO.getData())) {
 | 
	
		
			
				|  |  | +			List<GpsHistory> gpsHistories = responseDTO.getData();
 | 
	
		
			
				|  |  | +			for (GpsHistory gpsHistory : gpsHistories) {
 | 
	
		
			
				|  |  | +				Point point = new Point();
 | 
	
		
			
				|  |  | +				point.setX(gpsHistory.getLat());
 | 
	
		
			
				|  |  | +				point.setY(gpsHistory.getLon());
 | 
	
		
			
				|  |  | +				point.setLocatetime(gpsHistory.getTime().longValue());
 | 
	
		
			
				|  |  | +				point.setXY(gpsHistory.getWgs());
 | 
	
		
			
				|  |  | +				point.setSpeed(gpsHistory.getSpeed());
 | 
	
		
			
				|  |  | +				point.setDirection(gpsHistory.getDirection());
 | 
	
		
			
				|  |  | +				point.setPtype(gpsHistory.getPtype());
 | 
	
		
			
				|  |  | +				point.setType(gpsHistory.getType());
 | 
	
		
			
				|  |  | +				points.add(point);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if(!SmartCommonUtils.isEmpty(points)){
 | 
	
		
			
				|  |  | +				points = points.stream().sorted(Comparator.comparing(Point::getLocatetime)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			points1.setPoints(points);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return points1;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 返回轨迹信息
 | 
	
		
			
				|  |  | +	 * @param map 参数
 | 
	
		
			
				|  |  | +	 * @param beginDate 开始时间
 | 
	
		
			
				|  |  | +	 * @param endDate 结束时间
 | 
	
		
			
				|  |  | +	 * @return 轨迹信息
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	private Points returnTrace(Map<String, Object> map, Date beginDate, Date endDate) {
 | 
	
		
			
				|  |  | +//		Trace trace = new Trace();
 | 
	
		
			
				|  |  | +//		Points points = null;
 | 
	
		
			
				|  |  | +//		List<Point> pointList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +//		//取出所有分页数据
 | 
	
		
			
				|  |  | +//		//查询时间段中的轨迹
 | 
	
		
			
				|  |  | +//		List tracks = trace.returnTracks(map, beginDate.getTime(), endDate.getTime());
 | 
	
		
			
				|  |  | +//		if (!SmartCommonUtils.isEmpty(tracks)) {
 | 
	
		
			
				|  |  | +//			for (Object track : tracks) {
 | 
	
		
			
				|  |  | +//				Map mp = (Map) track;
 | 
	
		
			
				|  |  | +//				map.put("trid", mp.get("trid"));
 | 
	
		
			
				|  |  | +//				for (int i = 1; i < 1000; i++) {
 | 
	
		
			
				|  |  | +//					points = trace.trsearch(map, beginDate.getTime(), endDate.getTime(), null, 5000, i, 999);
 | 
	
		
			
				|  |  | +//					for (Point point : points.getPoints()) {
 | 
	
		
			
				|  |  | +//						Date date = new Date();
 | 
	
		
			
				|  |  | +//						date.setTime(point.getLocatetime());
 | 
	
		
			
				|  |  | +//						point.setLocationTime(SmartDateUtil.formatYMDHMS(date));
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					pointList.addAll(points.getPoints());
 | 
	
		
			
				|  |  | +//					if (SmartCommonUtils.isEmpty(points.getPoints()) || points.getPoints().size() < 999) {
 | 
	
		
			
				|  |  | +//						break;
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//			points.setPoints(pointList);
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//			return points;
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +	 * 返回轨迹信息
 | 
	
		
			
				|  |  | +	 * @param map 参数
 | 
	
		
			
				|  |  | +	 * @param beginDate 开始时间
 | 
	
		
			
				|  |  | +	 * @param endDate 结束时间
 | 
	
		
			
				|  |  | +	 * @return 轨迹信息
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	private Points returnTrace2(Map<String, Object> map, Date beginDate, Date endDate) {
 | 
	
		
			
				|  |  | +		Trace trace = new Trace();
 | 
	
		
			
				|  |  | +//		List<Point> pointList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +		int pageNo = 1;
 | 
	
		
			
				|  |  | +		int pageSize = 999;
 | 
	
		
			
				|  |  | +		//取出所有分页数据
 | 
	
		
			
				|  |  | +		Points points = trace.trsearch(map,beginDate.getTime(), endDate.getTime(), null, 5000, pageNo, pageSize);
 | 
	
		
			
				|  |  | +//		if (!SmartCommonUtils.isEmpty(points)) {
 | 
	
		
			
				|  |  | +//			points.setPoints(pointList);
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +		return points;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//	/**
 | 
	
		
			
				|  |  | +//	 * 获取设备实时位置(高德)
 | 
	
		
			
				|  |  | +//	 *
 | 
	
		
			
				|  |  | +//	 * @param imei 设备号
 | 
	
		
			
				|  |  | +//	 * @return 终端信息
 | 
	
		
			
				|  |  | +//	 */
 | 
	
		
			
				|  |  | +//	public RealPosition getPosition(String imei) throws Exception {
 | 
	
		
			
				|  |  | +//		GpsImeiMileageVO gps = gpsImeiMileageService.selectOne(imei);
 | 
	
		
			
				|  |  | +//		if (!SmartCommonUtils.isEmpty(gps)) {
 | 
	
		
			
				|  |  | +//			AMapTrackClient client = new AMapTrackClient(Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +//			net.lab1024.smartadmin.module.business.amap.track.Service service = client.getService(null, "all");
 | 
	
		
			
				|  |  | +//			Terminal terminal = service.listTerminal(imei);
 | 
	
		
			
				|  |  | +//			Trace trace = terminal.getTrace(Integer.parseInt(gps.getTraceId()));
 | 
	
		
			
				|  |  | +//			Map<String,Object> map = trace.getPosition(service.getSid(), Const.GAODE_KEY, terminal.getTid(),11);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//			JSONObject json = JSONObject.parseObject(map.get("data").toString());
 | 
	
		
			
				|  |  | +//			RealPosition realPosition  = new RealPosition();
 | 
	
		
			
				|  |  | +//			realPosition.setLocation(json.get("location").toString());
 | 
	
		
			
				|  |  | +//			Date date = new Date();
 | 
	
		
			
				|  |  | +//			date.setTime(terminal.getLocatetime());
 | 
	
		
			
				|  |  | +//			realPosition.setLocateTime(SmartDateUtil.formatYMDHMS(date));
 | 
	
		
			
				|  |  | +//			return realPosition;
 | 
	
		
			
				|  |  | +//		} else{
 | 
	
		
			
				|  |  | +//			throw new SmartResponseCodeException(9999,"无法获取轨迹信息");
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取车辆状态为已出发的车辆,设备实时位置
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return 实时位置
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +//	public List<RealPosition> getVehiclePosition(String vehLicense) throws Exception {
 | 
	
		
			
				|  |  | +//		//获取所有状态为已出发的车辆
 | 
	
		
			
				|  |  | +//		List<RealPosition> realPositionList = new ArrayList<>();
 | 
	
		
			
				|  |  | +//		Map<String, Object> map1 = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//		Map<String, Object> map2 = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//		map2.put("key", Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +//		List<TrackingGps> gps = Lists.newArrayList();
 | 
	
		
			
				|  |  | +//		List<String> gpsList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +////		try {
 | 
	
		
			
				|  |  | +//			List<GpsImeiVehicleVO> gpsImeiVehicleVOS = gpsImeiVehicleService.setVehicleList();
 | 
	
		
			
				|  |  | +//			if (!SmartCommonUtils.isEmpty(gpsImeiVehicleVOS)) {
 | 
	
		
			
				|  |  | +//				String imeis = "";
 | 
	
		
			
				|  |  | +//				Map<String,String> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//				Map<String,Integer> vehTypeMap = Maps.newHashMap();
 | 
	
		
			
				|  |  | +//				if(!SmartCommonUtils.isEmpty(vehLicense)){
 | 
	
		
			
				|  |  | +//					gpsImeiVehicleVOS.clear();
 | 
	
		
			
				|  |  | +//					GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +//					gpsImeiVehicleQueryDTO.setVehLicense(vehLicense);
 | 
	
		
			
				|  |  | +//					List<GpsImeiVehicleVO> gpsImeiVehicleVOS1 = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +//					gpsImeiVehicleVOS.add(gpsImei
 | 
	
		
			
				|  |  | +//					VehicleVOS1.get(0));
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//				for (GpsImeiVehicleVO gpsImeiVehicleVO : gpsImeiVehicleVOS) {
 | 
	
		
			
				|  |  | +//					imeis += gpsImeiVehicleVO.getImei() + ",";
 | 
	
		
			
				|  |  | +//					map.put(gpsImeiVehicleVO.getImei(),gpsImeiVehicleVO.getVehLicense());
 | 
	
		
			
				|  |  | +//					vehTypeMap.put(gpsImeiVehicleVO.getImei(),gpsImeiVehicleVO.getVehType());
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +////				logger.info(SmartDateUtil.getDate()+"准备发送请求");
 | 
	
		
			
				|  |  | +//				String httpUrl = "http://api.gpsoo.net/1/account/monitor";
 | 
	
		
			
				|  |  | +////				map1.put("imeis", imeis);
 | 
	
		
			
				|  |  | +//				long tms = System.currentTimeMillis() / 1000;
 | 
	
		
			
				|  |  | +//				map1.put("target", "威高汽车");
 | 
	
		
			
				|  |  | +//				map1.put("account", "威高汽车");
 | 
	
		
			
				|  |  | +//				map1.put("time", String.valueOf(tms));
 | 
	
		
			
				|  |  | +////				map1.put("access_token", this.getRedisToken("威高汽车"));
 | 
	
		
			
				|  |  | +//				String returnValue = SmartHttpUtil.sendGet(httpUrl, map1, null);
 | 
	
		
			
				|  |  | +//				logger.error(returnValue);
 | 
	
		
			
				|  |  | +//				GpsReturnDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnDto.class);
 | 
	
		
			
				|  |  | +////				ResponseDTO responseDTO  =  ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +//				if (!SmartCommonUtils.isEmpty(gpsReturnDto) && 0 == gpsReturnDto.getRet()) {
 | 
	
		
			
				|  |  | +////					logger.info(SmartDateUtil.getDate()+"发送请求结束");
 | 
	
		
			
				|  |  | +//					if(SmartCommonUtils.isEmpty(gpsReturnDto.getData())){
 | 
	
		
			
				|  |  | +//						return realPositionList;
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//					List<TrackingGps> trackingGps = JSONObject.parseObject(gpsReturnDto.getData().toString(), new TypeReference<ArrayList<TrackingGps>>() {
 | 
	
		
			
				|  |  | +//					});
 | 
	
		
			
				|  |  | +////					logger.info(SmartDateUtil.getDate()+"开始循环");
 | 
	
		
			
				|  |  | +//					for (int i = 0; i < trackingGps.size(); i++) {
 | 
	
		
			
				|  |  | +////						gpsList.add(trackingGps.get(i).getLng() + "," + trackingGps.get(i).getLat());
 | 
	
		
			
				|  |  | +//						gps.add(trackingGps.get(i));
 | 
	
		
			
				|  |  | +//						if (gps.size() % 30 == 0 || i == trackingGps.size() - 1) {
 | 
	
		
			
				|  |  | +//							map2.put("locations", StringUtils.join(gpsList, "%7C" ));
 | 
	
		
			
				|  |  | +//							map2.put("coordsys", "gps" );
 | 
	
		
			
				|  |  | +//							String json = SmartHttpUtil.sendGet(Const.CONVERT, map2, null);
 | 
	
		
			
				|  |  | +//							JSONObject jsonObject = JSON.parseObject(json);
 | 
	
		
			
				|  |  | +//							List<String> strings = Arrays.stream(jsonObject.get("locations" ).toString().split(";" )).map(String::trim).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +////							for (int i1 = 0; i1 < gps.size(); i1++) {
 | 
	
		
			
				|  |  | +////								TrackingGps trackingGps1 = gps.get(i1);
 | 
	
		
			
				|  |  | +////								RealPosition realPosition = new RealPosition();
 | 
	
		
			
				|  |  | +////								realPosition.setLocateTime(trackingGps1.getGpsTime());
 | 
	
		
			
				|  |  | +////								realPosition.setLocation(new BigDecimal(strings.get(i1).split("," )[1]) + "," + new BigDecimal(strings.get(i1).split("," )[0]));
 | 
	
		
			
				|  |  | +////								realPosition.setImei(trackingGps1.getImei());
 | 
	
		
			
				|  |  | +////								realPosition.setCourse(trackingGps1.getCourse());
 | 
	
		
			
				|  |  | +////								realPosition.setCourse(trackingGps1.getCourse());
 | 
	
		
			
				|  |  | +////								realPosition.setDeviceInfo(trackingGps1.getDeviceInfo());
 | 
	
		
			
				|  |  | +////								realPosition.setVehLicense(map.get(trackingGps1.getImei()));
 | 
	
		
			
				|  |  | +////								realPosition.setVehType(vehTypeMap.get(trackingGps1.getImei()));
 | 
	
		
			
				|  |  | +////								realPosition.setSpeed(trackingGps1.getSpeed());
 | 
	
		
			
				|  |  | +//////									realPosition.setCenter(gpsGeofenceImeiVOS.get(0).getGfcenter());
 | 
	
		
			
				|  |  | +//////									realPosition.setGfName(gpsGeofenceImeiVOS.get(0).getGfname());
 | 
	
		
			
				|  |  | +//////									realPosition.setRadious(gpsGeofenceImeiVOS.get(0).getGfradius());
 | 
	
		
			
				|  |  | +////								realPositionList.add(realPosition);
 | 
	
		
			
				|  |  | +////							}
 | 
	
		
			
				|  |  | +//							gps.clear();
 | 
	
		
			
				|  |  | +//							gpsList.clear();
 | 
	
		
			
				|  |  | +//						}
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +////					logger.info(SmartDateUtil.getDate()+"循环完毕");
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +////		} catch (java.lang.Exception e) {
 | 
	
		
			
				|  |  | +////			throw new SmartResponseCodeException(9999, "获取位置异常");
 | 
	
		
			
				|  |  | +////		}
 | 
	
		
			
				|  |  | +//		return realPositionList;
 | 
	
		
			
				|  |  | +//	}
 | 
	
		
			
				|  |  | +	public List<RealPosition> getVehiclePosition1() throws Exception {
 | 
	
		
			
				|  |  | +		String vehLicense1 = "鲁KL7A89" ;
 | 
	
		
			
				|  |  | +		//获取所有状态为已出发的车辆
 | 
	
		
			
				|  |  | +		List<RealPosition> realPositionList = new ArrayList<>();
 | 
	
		
			
				|  |  | +		Map<String, Object> map2 = Maps.newHashMap();
 | 
	
		
			
				|  |  | +		map2.put("key", Const.GAODE_KEY);
 | 
	
		
			
				|  |  | +		List<TrackingGps> gps = Lists.newArrayList();
 | 
	
		
			
				|  |  | +		List<String> gpsList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +//		try {
 | 
	
		
			
				|  |  | +		List<GpsImeiVehicleVO> gpsImeiVehicleVOS = gpsImeiVehicleService.setVehicleList();
 | 
	
		
			
				|  |  | +		if (!SmartCommonUtils.isEmpty(gpsImeiVehicleVOS)) {
 | 
	
		
			
				|  |  | +			String imeis = "";
 | 
	
		
			
				|  |  | +			Map<String,String> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +			Map<String,Integer> vehTypeMap = Maps.newHashMap();
 | 
	
		
			
				|  |  | +			if(!SmartCommonUtils.isEmpty(vehLicense1)){
 | 
	
		
			
				|  |  | +				gpsImeiVehicleVOS.clear();
 | 
	
		
			
				|  |  | +				GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +				gpsImeiVehicleQueryDTO.setVehLicense(vehLicense1);
 | 
	
		
			
				|  |  | +				List<GpsImeiVehicleVO> gpsImeiVehicleVOS1 = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +				gpsImeiVehicleVOS.add(gpsImeiVehicleVOS1.get(0));
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			for (GpsImeiVehicleVO gpsImeiVehicleVO : gpsImeiVehicleVOS) {
 | 
	
		
			
				|  |  | +				imeis += gpsImeiVehicleVO.getImei() + ",";
 | 
	
		
			
				|  |  | +				map.put(gpsImeiVehicleVO.getImei(),gpsImeiVehicleVO.getVehLicense());
 | 
	
		
			
				|  |  | +				vehTypeMap.put(gpsImeiVehicleVO.getImei(),gpsImeiVehicleVO.getVehType());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +//				logger.info(SmartDateUtil.getDate()+"准备发送请求");
 | 
	
		
			
				|  |  | +			String sid = "";
 | 
	
		
			
				|  |  | +			if(this.getRedisTokenExpire()){
 | 
	
		
			
				|  |  | +				sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +			}else {
 | 
	
		
			
				|  |  | +				sid = getRedisToken();
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			String familyId = this.getFamilyId();
 | 
	
		
			
				|  |  | +			String jsons = "{\n" +
 | 
	
		
			
				|  |  | +					"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +					"        \"limit_size\": 500,\n" +
 | 
	
		
			
				|  |  | +					"        \"sfamily\": \""+familyId+"\"\n" +
 | 
	
		
			
				|  |  | +					"    },\n" +
 | 
	
		
			
				|  |  | +					"    \"module\": \"family\",\n" +
 | 
	
		
			
				|  |  | +					"    \"func\": \"GetRunInfo\"\n" +
 | 
	
		
			
				|  |  | +					"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			String returnValue = SmartHttpUtil.sendPostJson(httpUrl, jsons, null);
 | 
	
		
			
				|  |  | +			logger.error(returnValue);
 | 
	
		
			
				|  |  | +			JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +			String items = jsonObject.get("items").toString();
 | 
	
		
			
				|  |  | +			GpsReturnNewDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnNewDto.class);
 | 
	
		
			
				|  |  | +			gpsReturnDto.setItems(items);
 | 
	
		
			
				|  |  | +			// imeiVehicle 是所有设备的信息  size代表设备数 0是一个设备
 | 
	
		
			
				|  |  | +			JSONArray imeiVehicle = jsonObject.getJSONArray("items");
 | 
	
		
			
				|  |  | +//				ResponseDTO responseDTO  =  ResponseDTO.succData(gpsReturnDto.getData());
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(gpsReturnDto) && 0 == gpsReturnDto.getErrcode()) {
 | 
	
		
			
				|  |  | +//					logger.info(SmartDateUtil.getDate()+"发送请求结束");
 | 
	
		
			
				|  |  | + 				if(SmartCommonUtils.isEmpty(imeiVehicle)){
 | 
	
		
			
				|  |  | +// 				if(SmartCommonUtils.isEmpty(jsonObject.get("items").toString())){
 | 
	
		
			
				|  |  | +					return realPositionList;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +// 				// trackingGps 是单个设备中的轨迹点list
 | 
	
		
			
				|  |  | +// 				List<GpsHistory> lasPosList = null;
 | 
	
		
			
				|  |  | +//				for (int i = 0; i < imeiVehicle.size(); i++) {
 | 
	
		
			
				|  |  | +////					Map<String,GpsHistory> gpsHistoryMap = new HashMap<>();
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +////					GpsHistory gpsHistory = (GpsHistory) imeiVehicle.getJSONObject(i).get("las_pos");
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +////					gpsHistoryMap.put("las_pos",gpsHistory);
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +////					lasPosList.add(gpsHistory);
 | 
	
		
			
				|  |  | +//					//---------------------------
 | 
	
		
			
				|  |  | +//					JSONArray lastPosJsonArray = imeiVehicle.getJSONObject(i).getJSONArray("las_pos");
 | 
	
		
			
				|  |  | +//					for (int j = 0; j < lastPosJsonArray.size(); j++) {
 | 
	
		
			
				|  |  | +//						GpsHistory gpsHistory = (GpsHistory) lastPosJsonArray.getJSONObject(i).get("las_pos");
 | 
	
		
			
				|  |  | +//					}
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +				List<Map<String,Object>> deviceInfo = new ArrayList<>();
 | 
	
		
			
				|  |  | +				// deviceInfo 是一个包含车辆和车辆轨迹map的列表
 | 
	
		
			
				|  |  | +				for (int i = 0; i < imeiVehicle.size(); i++) {
 | 
	
		
			
				|  |  | +					Map<String,Object> lastPosMap = new HashMap<>();
 | 
	
		
			
				|  |  | +					//获取当前设备的车牌号
 | 
	
		
			
				|  |  | +					String vehLicense = (String) imeiVehicle.getJSONObject(i).get("car_number");
 | 
	
		
			
				|  |  | +					//获取当前设备的位置信息
 | 
	
		
			
				|  |  | +					String lastPos = (String) imeiVehicle.getJSONObject(i).get("last_pos");
 | 
	
		
			
				|  |  | +					lastPosMap.put("VehLicense",vehLicense);
 | 
	
		
			
				|  |  | +					lastPosMap.put("lastPos",lastPos);
 | 
	
		
			
				|  |  | +					deviceInfo.add(lastPosMap);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +//				List<TrackingGps> trackingGps = JSONObject.parseObject(jsonObject.get("items").toString(), new TypeReference<ArrayList<TrackingGps>>() {
 | 
	
		
			
				|  |  | +//				});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//					logger.info(SmartDateUtil.getDate()+"开始循环");
 | 
	
		
			
				|  |  | +//				for (int i = 0; i < trackingGps.size(); i++) {
 | 
	
		
			
				|  |  | +//					gps.add(trackingGps.get(i));
 | 
	
		
			
				|  |  | +//					for (int i = 0; i < lasPosList.size(); i++) {
 | 
	
		
			
				|  |  | +//					gps.add(trackingGps.get(i));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				//转坐标
 | 
	
		
			
				|  |  | +//					if (gps.size() % 30 == 0 || i == trackingGps.size() - 1) {
 | 
	
		
			
				|  |  | +//						map2.put("locations", StringUtils.join(gpsList, "%7C" ));
 | 
	
		
			
				|  |  | +//						map2.put("coordsys", "gps" );
 | 
	
		
			
				|  |  | +//						String json = SmartHttpUtil.sendGet(Const.CONVERT, map2, null);
 | 
	
		
			
				|  |  | +//						JSONObject jsonObject = JSON.parseObject(json);
 | 
	
		
			
				|  |  | +//						List<String> strings = Arrays.stream(jsonObject.get("locations" ).toString().split(";" )).map(String::trim).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +						for (int i1 = 0; i1 < deviceInfo.size(); i1++) {
 | 
	
		
			
				|  |  | +							Map<String,Object> lastPosMap = deviceInfo.get(i1);
 | 
	
		
			
				|  |  | +//							BigDecimal imei = (BigDecimal) imeiVehicle.getJSONObject(i1).get("imei");
 | 
	
		
			
				|  |  | +//							String vehLicense = imeiVehicle.getJSONObject(i1).get("carNumber").toString();
 | 
	
		
			
				|  |  | +							String lastPos = "";
 | 
	
		
			
				|  |  | +//							if(lastPosMap.containsKey(vehLicense)){
 | 
	
		
			
				|  |  | +								lastPos = (String) lastPosMap.get("lastPos");
 | 
	
		
			
				|  |  | +//							}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//							TrackingGps trackingGps1 = gps.get(i1);
 | 
	
		
			
				|  |  | +//							String lastPos = trackingGps1.getLastPos().toJSONString();
 | 
	
		
			
				|  |  | +//							List<GpsHistory> gpsHistoryList = new ArrayList<>(JSONArray.parseArray(lastPos, GpsHistory.class));
 | 
	
		
			
				|  |  | +//							List<GpsHistory> allGpsPosition = new ArrayList<>();
 | 
	
		
			
				|  |  | +//							for (int j = 0; j < gpsHistoryList.size(); j++) {
 | 
	
		
			
				|  |  | +//								GpsHistory gpsHistory = new GpsHistory();
 | 
	
		
			
				|  |  | +//								gpsHistory.setDirection(gpsHistoryList.get(j).getDirection());
 | 
	
		
			
				|  |  | +//								gpsHistory.setDuration(gpsHistoryList.get(j).getDuration());
 | 
	
		
			
				|  |  | +//								gpsHistory.setLat(gpsHistoryList.get(j).getLat());
 | 
	
		
			
				|  |  | +//								gpsHistory.setLon(gpsHistoryList.get(j).getLon());
 | 
	
		
			
				|  |  | +//								gpsHistory.setPtype(gpsHistoryList.get(j).getPtype());
 | 
	
		
			
				|  |  | +//								gpsHistory.setTime(gpsHistoryList.get(j).getTime());
 | 
	
		
			
				|  |  | +//								gpsHistory.setType(gpsHistoryList.get(j).getType());
 | 
	
		
			
				|  |  | +//								gpsHistory.setWgs(gpsHistoryList.get(j).getWgs());
 | 
	
		
			
				|  |  | +//								allGpsPosition.add(gpsHistory);
 | 
	
		
			
				|  |  | +//							}
 | 
	
		
			
				|  |  | +							RealPosition realPosition = new RealPosition();
 | 
	
		
			
				|  |  | +//							realPosition.setVehLicense(vehLicense);
 | 
	
		
			
				|  |  | +//							realPosition.setImei(imei);
 | 
	
		
			
				|  |  | +							realPosition.setLastPos(lastPos);
 | 
	
		
			
				|  |  | +//							for (int j = 0; j < gpsHistoryList.size(); j++) {
 | 
	
		
			
				|  |  | +//								realPosition.setVehLicense(trackingGps1.getCarNumber());
 | 
	
		
			
				|  |  | +//								realPosition.setImei(trackingGps1.getImei());
 | 
	
		
			
				|  |  | +//								realPosition.setLastPos(gpsHistoryList);
 | 
	
		
			
				|  |  | +//								gpsList.add(gpsHistoryList.get(j).getWgs());
 | 
	
		
			
				|  |  | +//								gpsHistory.setDirection(gpsHistoryList.get(j).getDirection());
 | 
	
		
			
				|  |  | +//								gpsHistory.setDuration(gpsHistoryList.get(j).getDuration());
 | 
	
		
			
				|  |  | +//								gpsHistory.setLat(gpsHistoryList.get(j).getLat());
 | 
	
		
			
				|  |  | +//								gpsHistory.setLon(gpsHistoryList.get(j).getLon());
 | 
	
		
			
				|  |  | +//								gpsHistory.setPtype(gpsHistoryList.get(j).getPtype());
 | 
	
		
			
				|  |  | +//								gpsHistory.setTime(gpsHistoryList.get(j).getTime());
 | 
	
		
			
				|  |  | +//								gpsHistory.setType(gpsHistoryList.get(j).getType());
 | 
	
		
			
				|  |  | +//								gpsHistory.setWgs(gpsHistoryList.get(j).getWgs());
 | 
	
		
			
				|  |  | +//							}
 | 
	
		
			
				|  |  | +							realPositionList.add(realPosition);
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +						gps.clear();
 | 
	
		
			
				|  |  | +						gpsList.clear();
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +//					logger.info(SmartDateUtil.getDate()+"循环完毕");
 | 
	
		
			
				|  |  | +//			}
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +//		} catch (java.lang.Exception e) {
 | 
	
		
			
				|  |  | +//			throw new SmartResponseCodeException(9999, "获取位置异常");
 | 
	
		
			
				|  |  | +//		}
 | 
	
		
			
				|  |  | +		return realPositionList;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	public List<RealPosition> getVehiclePosition(String vehLicense) throws Exception {
 | 
	
		
			
				|  |  | +//		vehLicense = "";//"鲁KL7A89";
 | 
	
		
			
				|  |  | +		//获取所有状态为已出发的车辆
 | 
	
		
			
				|  |  | +		List<RealPosition> realPositionList = new ArrayList<>();
 | 
	
		
			
				|  |  | +		List<TrackingGps> gps = Lists.newArrayList();
 | 
	
		
			
				|  |  | +		List<String> gpsList = Lists.newArrayList();
 | 
	
		
			
				|  |  | +		//redis中车辆信息的list
 | 
	
		
			
				|  |  | +		List<GpsImeiVehicleVO> gpsImeiVehicleVOS = gpsImeiVehicleService.setVehicleList();
 | 
	
		
			
				|  |  | +		if (!SmartCommonUtils.isEmpty(gpsImeiVehicleVOS)) {
 | 
	
		
			
				|  |  | +			Map<Long, String> map = Maps.newHashMap();
 | 
	
		
			
				|  |  | +			Map<String,Integer> vehTypeMap = Maps.newHashMap();
 | 
	
		
			
				|  |  | +			//如果传入车牌号不为空
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(vehLicense)) {
 | 
	
		
			
				|  |  | +				//清空包含车辆信息的list
 | 
	
		
			
				|  |  | +				gpsImeiVehicleVOS.clear();
 | 
	
		
			
				|  |  | +				GpsImeiVehicleQueryDTO gpsImeiVehicleQueryDTO = new GpsImeiVehicleQueryDTO();
 | 
	
		
			
				|  |  | +				//将车牌号set到实体类中
 | 
	
		
			
				|  |  | +				gpsImeiVehicleQueryDTO.setVehLicense(vehLicense);
 | 
	
		
			
				|  |  | +				//数据库中查询当前车牌号对应的车辆信息
 | 
	
		
			
				|  |  | +				List<GpsImeiVehicleVO> gpsImeiVehicleVOS1 = gpsImeiVehicleDao.listAll(gpsImeiVehicleQueryDTO);
 | 
	
		
			
				|  |  | +				gpsImeiVehicleVOS.add(gpsImeiVehicleVOS1.get(0));
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			for (GpsImeiVehicleVO gpsImeiVehicleVO : gpsImeiVehicleVOS) {
 | 
	
		
			
				|  |  | +				//每次循环都向map中存入设备号对应的设备信息
 | 
	
		
			
				|  |  | +				if(SmartCommonUtils.isEmpty(gpsImeiVehicleVO.getImei())){
 | 
	
		
			
				|  |  | +					continue;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				map.put(Long.parseLong(gpsImeiVehicleVO.getImei()), gpsImeiVehicleVO.getVehLicense());
 | 
	
		
			
				|  |  | +				Integer type = gpsImeiVehicleVO.getVehType();
 | 
	
		
			
				|  |  | +				vehTypeMap.put(gpsImeiVehicleVO.getImei(),type);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +//				logger.info(SmartDateUtil.getDate()+"准备发送请求");
 | 
	
		
			
				|  |  | +			String sid = "";
 | 
	
		
			
				|  |  | +			if (this.getRedisTokenExpire()) {
 | 
	
		
			
				|  |  | +				sid = smartRedisService.get("loginToken");
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				sid = getRedisToken();
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			String httpUrl = Const.WEIGAO + "?sid=" + sid;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			Thread.sleep(200);
 | 
	
		
			
				|  |  | +			String familyId = this.getFamilyId();
 | 
	
		
			
				|  |  | +			String jsons = "{\n" +
 | 
	
		
			
				|  |  | +					"    \"params\": {\n" +
 | 
	
		
			
				|  |  | +					"        \"limit_size\": 500,\n" +
 | 
	
		
			
				|  |  | +					"        \"sfamily\": \""+familyId+"\"\n" +
 | 
	
		
			
				|  |  | +					"    },\n" +
 | 
	
		
			
				|  |  | +					"    \"module\": \"family\",\n" +
 | 
	
		
			
				|  |  | +					"    \"func\": \"GetRunInfo\"\n" +
 | 
	
		
			
				|  |  | +					"}";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			String returnValue = SmartHttpUtil.sendPostJson(httpUrl, jsons, null);
 | 
	
		
			
				|  |  | +			logger.error(returnValue);
 | 
	
		
			
				|  |  | +			JSONObject jsonObject = JSONObject.parseObject(returnValue);
 | 
	
		
			
				|  |  | +			GpsReturnNewDto gpsReturnDto = JSONObject.parseObject(returnValue, GpsReturnNewDto.class);
 | 
	
		
			
				|  |  | +			// imeiVehicle 是所有设备的信息  size代表设备数 0是一个设备
 | 
	
		
			
				|  |  | +			JSONArray imeiVehicle = jsonObject.getJSONArray("items");
 | 
	
		
			
				|  |  | +			if (!SmartCommonUtils.isEmpty(gpsReturnDto) && 0 == gpsReturnDto.getErrcode()) {
 | 
	
		
			
				|  |  | +				if (SmartCommonUtils.isEmpty(imeiVehicle)) {
 | 
	
		
			
				|  |  | +					return realPositionList;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +//				List<Map<String, Object>> deviceInfo = new ArrayList<>();
 | 
	
		
			
				|  |  | +				// deviceInfo 是一个包含车辆和车辆轨迹map的列表
 | 
	
		
			
				|  |  | +				for (int i = 0; i < imeiVehicle.size(); i++) {
 | 
	
		
			
				|  |  | +					Map<String, Object> lastPosMap = new HashMap<>();
 | 
	
		
			
				|  |  | +					//获取当前设备的位置信息0
 | 
	
		
			
				|  |  | +					long imei = (long) imeiVehicle.getJSONObject(i).get("imei");
 | 
	
		
			
				|  |  | +					if (SmartCommonUtils.isEmpty(imeiVehicle.getJSONObject(i).get("last_pos"))) {
 | 
	
		
			
				|  |  | +						continue;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					String lastPos = (String) imeiVehicle.getJSONObject(i).get("last_pos");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					lastPosMap.put("VehLicense", map.get(imei));
 | 
	
		
			
				|  |  | +					lastPosMap.put("lastPos", lastPos);
 | 
	
		
			
				|  |  | +					lastPosMap.put("vehType", vehTypeMap.get(map.get(imei)));
 | 
	
		
			
				|  |  | +					long imei1 = (long) imeiVehicle.getJSONObject(i).get("imei");
 | 
	
		
			
				|  |  | +					vehLicense = (String) lastPosMap.get("VehLicense");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					lastPos = (String) lastPosMap.get("lastPos");
 | 
	
		
			
				|  |  | +					RealPosition realPosition = new RealPosition();
 | 
	
		
			
				|  |  | +					realPosition.setVehLicense(vehLicense);
 | 
	
		
			
				|  |  | +					realPosition.setImei(imei1);
 | 
	
		
			
				|  |  | +					realPosition.setLastPos(lastPos);
 | 
	
		
			
				|  |  | +					realPosition.setVehType(vehTypeMap.get(imei1));
 | 
	
		
			
				|  |  | +					realPositionList.add(realPosition);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//				for (int i1 = 0; i1 < deviceInfo.size(); i1++) {
 | 
	
		
			
				|  |  | +//					Map<String, Object> lastPosMap = deviceInfo.get(i1);
 | 
	
		
			
				|  |  | +//					long imei1 = (long) imeiVehicle.getJSONObject(i1).get("imei");
 | 
	
		
			
				|  |  | +//					vehLicense = (String) deviceInfo.get(i1).get("VehLicense");
 | 
	
		
			
				|  |  | +//					String lastPos = "";
 | 
	
		
			
				|  |  | +//					lastPos = (String) lastPosMap.get("lastPos");
 | 
	
		
			
				|  |  | +//					RealPosition realPosition = new RealPosition();
 | 
	
		
			
				|  |  | +//					realPosition.setVehLicense(vehLicense);
 | 
	
		
			
				|  |  | +//					realPosition.setImei(imei1);
 | 
	
		
			
				|  |  | +//					realPosition.setLastPos(lastPos);
 | 
	
		
			
				|  |  | +//					realPosition.setVehType(vehTypeMap.get(imei1));
 | 
	
		
			
				|  |  | +//					realPositionList.add(realPosition);
 | 
	
		
			
				|  |  | +//				}
 | 
	
		
			
				|  |  | +				gps.clear();
 | 
	
		
			
				|  |  | +				gpsList.clear();
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return realPositionList;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取车辆状态为已出发的车辆,设备实时位置
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @return 实时位置
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public ResponseDTO geth5(String paicheId) throws Exception {
 | 
	
		
			
				|  |  | +		List<String> list = Arrays.asList("已作废","已入库","已失效");
 | 
	
		
			
				|  |  | +		if (SmartCommonUtils.isEmpty(paicheId)) {
 | 
	
		
			
				|  |  | +			return ResponseDTO.wrap(ResponseCodeConst.NOT_EXISTS, "派车单已失效");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		Base64.Decoder decoder = Base64.getDecoder();
 | 
	
		
			
				|  |  | +		paicheId = new String(decoder.decode(paicheId));
 | 
	
		
			
				|  |  | +		DispatchQueryDTO dispatchQueryDTO = new DispatchQueryDTO();
 | 
	
		
			
				|  |  | +		dispatchQueryDTO.set单号(paicheId);
 | 
	
		
			
				|  |  | +		List<DispatchVO> dispatchVOS = dispatchDao.listAll(dispatchQueryDTO);
 | 
	
		
			
				|  |  | +		if (!SmartCommonUtils.isEmpty(dispatchVOS)) {
 | 
	
		
			
				|  |  | +			for (DispatchVO dispatchVO : dispatchVOS) {
 | 
	
		
			
				|  |  | +				if (list.contains(dispatchVO.get状态())) {
 | 
	
		
			
				|  |  | +					return ResponseDTO.wrap(ResponseCodeConst.NOT_EXISTS, "链接已失效");
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				return ResponseDTO.succData(this.getVehiclePosition(dispatchVO.get车牌号()));
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +			return ResponseDTO.wrap(ResponseCodeConst.NOT_EXISTS, "派车单已失效");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return ResponseDTO.wrap(ResponseCodeConst.NOT_EXISTS, "派车单已失效");
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +}
 |