| | |
| | | import org.springblade.modules.equipage.vo.CarVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.awt.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhongrj |
| | | * @time 2021-07-06 |
| | |
| | | public class CarController { |
| | | |
| | | private final CarService carService; |
| | | private static String csvurl; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | |
| | | CarVo detail = carService.selectCarInfo(car); |
| | | return R.data(detail); |
| | | } |
| | | /** |
| | | * 查询车辆实时位置 |
| | | */ |
| | | @GetMapping("/locationcar") |
| | | public String locationcar(String imei) { |
| | | String url = "http://dvopenapi.aimap.net.cn/openapi/device/location"; |
| | | String res = null; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("imei", imei); |
| | | params.put("appId", "PO00000761"); |
| | | params.put("timestamp", System.currentTimeMillis()); |
| | | String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx"; |
| | | |
| | | String computeSign = ""; |
| | | try { |
| | | computeSign = Md5SignUtil.signRequest(params, secert); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | params.put("sign", computeSign); |
| | | try { |
| | | //String res = HttpReqUtil.getInstance().doGet(url, params, null); |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | System.out.println("----" + res); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 查询车辆轨迹 |
| | | */ |
| | | |
| | | @GetMapping("/locationhistoryTrack") |
| | | public R locationhistoryTrack(String beginTime, String endTime, String rectify) throws AWTException { |
| | | String url = "http://dvopenapi.aimap.net.cn/openapi/device/historyTrack"; |
| | | String res = null; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("imei", "861636056082414"); |
| | | params.put("beginTime", beginTime); |
| | | params.put("endTime", endTime); |
| | | params.put("rectify", rectify); |
| | | params.put("callbackUrl", "http://s16s652780.51mypc.cn/api/car/SaveUrl"); |
| | | params.put("callbackId", "1"); |
| | | params.put("appId", "PO00000761"); |
| | | params.put("timestamp", System.currentTimeMillis()); |
| | | String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx"; |
| | | |
| | | String computeSign = ""; |
| | | try { |
| | | computeSign = Md5SignUtil.signRequest(params, secert); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | params.put("sign", computeSign); |
| | | try { |
| | | //String res = HttpReqUtil.getInstance().doGet(url, params, null); |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | Thread.sleep(2000); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return R.data(csvurl); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 实时视频直播指令下发接口 |
| | | */ |
| | | @GetMapping("/cmd") |
| | | public String cmd(int camera, String action) { |
| | | String url = "http://dvopenapi.aimap.net.cn/openapi/live/cmd"; |
| | | String res = null; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //设备imei号 |
| | | params.put("imei", "861636056082414"); |
| | | //摄像头ID |
| | | params.put("camera", camera); |
| | | //实时视频指令类型 |
| | | params.put("action", action); |
| | | params.put("appId", "PO00000761"); |
| | | params.put("timestamp", System.currentTimeMillis()); |
| | | String secert = "dXRGb2pRNVdWOGQ3d1ouV29UYzc1MnJaUnBwTzUx"; |
| | | String computeSign = ""; |
| | | try { |
| | | computeSign = Md5SignUtil.signRequest(params, secert); |
| | | } catch (IOException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | params.put("sign", computeSign); |
| | | try { |
| | | //String res = HttpReqUtil.getInstance().doGet(url, params, null); |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | System.out.println("----" + res); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 轨迹回调 |
| | | * |
| | | * @param callbackId |
| | | * @param fileUrl |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | @PostMapping("/SaveUrl") |
| | | @ApiOperation(value = "详情", notes = "传入car") |
| | | public void SaveUrl(String callbackId, String fileUrl) throws Exception { |
| | | csvurl = null; |
| | | List<String> allString = new ArrayList<>(); |
| | | DowloadZipUtil dowloadZipUtil = new DowloadZipUtil(); |
| | | File file = dowloadZipUtil.downloadFile(fileUrl, "E:\\nginx-1.18.0\\dist\\car"); |
| | | //文件名 |
| | | String name = file.getName(); |
| | | String substring = name.substring(0, name.length() - 4); |
| | | System.out.println(substring); |
| | | //解压数据 |
| | | FileZip fileZip = new FileZip(); |
| | | fileZip.ZipUncompress("E:\\nginx-1.18.0\\dist\\car\\" + substring + ".zip", "E:\\nginx-1.18.0\\dist\\car"); |
| | | //fileZip.ZipUncompress("D:\\caiji\\" + substring + ".zip", "D:\\caiji\\car"); |
| | | csvurl = substring + ".csv"; |
| | | } |
| | | /** |
| | | * 人员 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/Peo") |
| | | public String cs() throws Exception { |
| | | String url = "http://223.82.109.183:2080/Escort/getgis.php"; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //设备imei号 |
| | | //params.put("number", "7730"); |
| | | params.put("acc", "7731"); |
| | | String res = null; |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | | * 人员轨迹 |
| | | * @return、 |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/Peog") |
| | | public String Peocar(String startTime,String endTime) throws Exception { |
| | | String url = "http://223.82.109.183:2080/Escort/getgistrack.php"; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | //设备imei号 |
| | | params.put("number", "7730"); |
| | | params.put("acc", "7731"); |
| | | params.put("startTime", startTime); |
| | | params.put("endTime", endTime); |
| | | String res = null; |
| | | res = HttpReqUtil.getInstance().doPost(url, params, null); |
| | | return res; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询押运车辆 |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectCar") |
| | | public R selectCar() { |
| | | List<Map<Object, Object>> maps = carService.selectCar(); |
| | | return R.data(maps); |
| | | } |
| | | } |