package com.ruoyi.sy.controller; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.text.SimpleDateFormat; import java.util.*; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson2.JSON; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.sy.domain.ArdTankLock; import com.ruoyi.sy.gps31.PushClientImplSerialPort; import com.ruoyi.sy.param.ArdSyCarParam; import com.ruoyi.sy.service.IArdTankAbnormalParkAlarmService; import com.ruoyi.sy.service.IArdTankLockService; import com.ruoyi.sy.service.impl.ArdTankLockServiceImpl; import com.ruoyi.sy.vo.ArdSyCarVo; import com.ruoyi.sy.domain.ArdSyUser; import com.ruoyi.sy.gps31.PositionContainer; import com.ruoyi.sy.gps31.PushClientImplAlarm; import com.ruoyi.sy.gps31.PushClientImplPosition; import com.ruoyi.sy.service.IArdSyUserService; import com.ruoyi.common.core.domain.entity.SysConfig; import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.impl.SysConfigServiceImpl; import com.ruoyi.utils.forest.SYClient; import com.ruoyi.utils.result.Results; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.sy.domain.ArdSyCar; import com.ruoyi.sy.service.IArdSyCarService; import com.ruoyi.common.utils.poi.ExcelUtil; import org.springframework.web.multipart.MultipartFile; import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; /** * 三一车辆Controller * * @author ard * @date 2023-06-26 */ @RestController @RequestMapping("/sy/syCar") @Api(tags = "三一车辆管理接口") public class ArdSyCarController extends BaseController { @Autowired private IArdSyCarService ardSyCarService; @Autowired private ISysConfigService sysConfigService; private Map> logInMap = new HashMap(); @Autowired private IArdSyUserService iArdSyUserService; @Autowired private ISysUserService sysUserService; @Autowired private ISysDeptService sysDeptService; @Autowired private IArdTankAbnormalParkAlarmService ardTankAbnormalParkAlarmService; @Autowired private IArdTankLockService ardTankLockService; @Resource private SYClient sYClient; private ArdSyCarController ardSyCarController; @Value("${syCar.enabled}") private Boolean syCarEnabled; @Value("${syCar.userId}") private String userId; @Value("${syCar.password}") private String password; private Timer lockStateTimer; @PostConstruct public void init(){ ardSyCarController = this; ardSyCarController.sysConfigService = this.sysConfigService; ardSyCarController.iArdSyUserService = this.iArdSyUserService; SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; //if(sysConfigResult.size() == 0){ if(!syCarEnabled){//三一车辆加入开关 return; }else{ syURL = sysConfigResult.get(0).getConfigValue(); } String ip = syURL.split(":")[1].replace("//", ""); List ardSyUserList = iArdSyUserService.selectSyUser(); //车辆实时位置线程 if(ardSyUserList.size()==0) { return; } //PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword()); PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,userId,password); Thread pushClientImplPositionThread = new Thread(pushClientImplPosition); pushClientImplPositionThread.start(); Date date = new Date(); Timer carPositionTimer = new Timer();//定时推送实时位置 TimerTask carPositionTask =new TimerTask(){ @Override public void run(){ ardSyCarService.sendArdSyCarPosition(); } }; //carPositionTimer.scheduleAtFixedRate(carPositionTask,date,3*1000);//弃用 //车辆实时报警线程 //PushClientImplAlarm pushClientImplAlarm = new PushClientImplAlarm(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword()); PushClientImplAlarm pushClientImplAlarm = new PushClientImplAlarm(ip,userId,password); Thread pushClientImplAlarmThread = new Thread(pushClientImplAlarm); pushClientImplAlarmThread.start(); //串口线程 PushClientImplSerialPort pushClientImplSerialPort = new PushClientImplSerialPort(ip,userId,password); Thread pushClientImplSerialPortThread = new Thread(pushClientImplSerialPort); pushClientImplSerialPortThread.start(); //删除结束时间为null的记录 int result = ardTankAbnormalParkAlarmService.deleteArdTankAbnormalParkAlarmByEndTime(); this.lockStateTimer = new Timer();//定时获取各个锁的状态 TimerTask lockStateTask =new TimerTask(){ @Override public void run(){ Thread thread = new Thread(){ @Override public void run() { SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; if(sysConfigResult.size() == 0){ return; }else{ syURL = sysConfigResult.get(0).getConfigValue(); } String passwordMd5 = DigestUtils.md5Hex(password); Map LogInResult = sYClient.logIn(syURL, passwordMd5, userId); String sessionId = (String) LogInResult.get("sessionId"); String finalSyURL = syURL; List result = ardTankLockService.getArdTankLockAll();//查询全部电磁锁 for(ArdTankLock ardTankLock : result){ Thread LockThread = new Thread(finalSyURL){ @Override public void run() { String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.getLockNum().substring(2,4); //计算校验 String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("01", 16)); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "01" + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); } }; LockThread.start(); } } }; thread.start(); } }; //lockStateTimer.scheduleAtFixedRate(lockStateTask,date,3000); lockStateTimer.scheduleAtFixedRate(lockStateTask,date,5000); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Timer lockCheckTimeTimer = new Timer();//定时校准时间 TimerTask lockCheckTimeTask =new TimerTask(){ @Override public void run() { SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; if(sysConfigResult.size() == 0){ return; }else{ syURL = sysConfigResult.get(0).getConfigValue(); } String passwordMd5 = DigestUtils.md5Hex(password); Map LogInResult = sYClient.logIn(syURL, passwordMd5, userId); String sessionId = (String) LogInResult.get("sessionId"); String finalSyURL = syURL; List result = ardTankLockService.getArdTankLockAll();//查询全部电磁锁 for(ArdTankLock ardTankLock : result){ Thread LockThread = new Thread(finalSyURL){ @Override public void run() { //获取时间并拆分年月日时分秒 String nowTime = sdf.format(new Date()); String nowYear = nowTime.substring(2,4); String nowMonth = nowTime.substring(5,7); String nowDay = nowTime.substring(8,10); String nowHour = nowTime.substring(11,13); String nowMinute = nowTime.substring(14,16); String nowSecond = nowTime.substring(17,19); String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear)); if(nowYearHex.length() == 1){ nowYearHex = "0" + nowYearHex; } String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth)); if(nowMonthHex.length() == 1){ nowMonthHex = "0" + nowMonthHex; } String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay)); if(nowDayHex.length() == 1){ nowDayHex = "0" + nowDayHex; } String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour)); if(nowHourHex.length() == 1){ nowHourHex = "0" + nowHourHex; } String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute)); if(nowMinuteHex.length() == 1){ nowMinuteHex = "0" + nowMinuteHex; } String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond)); if(nowSecondHex.length() == 1){ nowSecondHex = "0" + nowSecondHex; } //16进制时间 String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex; String lockNumHead = ardTankLock.getLockNum().substring(0,2); String lockNumTail = ardTankLock.getLockNum().substring(2,4); //计算校验 String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("08", 16) + Integer.parseInt(nowYearHex, 16) + Integer.parseInt(nowMonthHex, 16) + Integer.parseInt(nowDayHex, 16) + Integer.parseInt(nowHourHex, 16) + Integer.parseInt(nowMinuteHex, 16) + Integer.parseInt(nowSecondHex, 16)); if(checkNum.length() == 1){ checkNum = "0" + checkNum; }else if(checkNum.length() > 2){ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length()); } String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D"; sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId); } }; LockThread.start(); } } }; lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,13000); Timer sendTimer = new Timer();//定时发送锁状态 TimerTask sendLockStateTask = new TimerTask(){ @Override public void run() { for (String key : ONLINE_USER_SESSIONS.keySet()){ Thread lockThread = new Thread() { @Override public void run() { ardTankLockService.sendLockState(key,userId,password); } }; lockThread.start(); } } }; sendTimer.scheduleAtFixedRate(sendLockStateTask,date,3000); try{ Thread.sleep(3000); }catch(Exception e){ } Timer alarmTimer = new Timer();//定时获取报警 TimerTask alarmTask = new TimerTask(){ @Override public void run() { Thread alarmThread = new Thread() { @Override public void run() { ardTankLockService.getAlarm(userId,password); } }; alarmThread.start(); } }; alarmTimer.scheduleAtFixedRate(alarmTask,date,3000); } /** * 查询三一车辆列表 */ @PreAuthorize("@ss.hasPermi('sy:syCar:list')") @GetMapping("/list") @ApiOperation("查询三一车辆列表") public AjaxResult list(ArdSyCarParam ardSyCarParam) { PageHelper.startPage(ardSyCarParam.getPageNum(),ardSyCarParam.getPageSize()); String userId = SecurityUtils.getUserId(); Map result = ardSyCarService.getArdSyCarAll(userId); return ardSyCarService.ardSyCarList(ardSyCarParam,result); } /** * 导出三一车辆列表 */ @PreAuthorize("@ss.hasPermi('sy:syCar:export')") @Log(title = "三一车辆", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ArdSyCar ardSyCar) { List list = ardSyCarService.selectArdSyCarList(ardSyCar); ExcelUtil util = new ExcelUtil(ArdSyCar.class); util.exportExcel(response, list, "三一车辆数据"); } /** * 获取三一车辆详细信息 */ @PreAuthorize("@ss.hasPermi('sy:syCar:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") String id) { return success(ardSyCarService.selectArdSyCarById(id)); } /** * 新增三一车辆 */ @PreAuthorize("@ss.hasPermi('sy:syCar:add')") @Log(title = "三一车辆", businessType = BusinessType.INSERT) @PostMapping @ApiOperation("新增三一车辆") public AjaxResult add(@RequestBody ArdSyCar ardSyCar) { String id = IdUtils.simpleUUID(); ardSyCar.setId(id); return toAjax(ardSyCarService.insertArdSyCar(ardSyCar)); } /** * 修改三一车辆 */ @PreAuthorize("@ss.hasPermi('sy:syCar:edit')") @Log(title = "三一车辆", businessType = BusinessType.UPDATE) @PutMapping @ApiOperation("修改三一车辆") public AjaxResult edit(@RequestBody ArdSyCar ardSyCar) { return toAjax(ardSyCarService.updateArdSyCar(ardSyCar)); } /** * 删除三一车辆 */ @PreAuthorize("@ss.hasPermi('sy:syCar:remove')") @Log(title = "三一车辆", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") @ApiOperation("删除三一车辆") public AjaxResult remove(@PathVariable String[] ids) { return toAjax(ardSyCarService.deleteArdSyCarByIds(ids)); } /** * 获取三一车辆登录信息 */ @PreAuthorize("@ss.hasPermi('sy:syCar:loginSY')") @PostMapping("/loginSY") @ApiOperation("获取三一车辆登录信息") public Map loginSY(@RequestBody Map map){ //startPage(); String userId = map.get("userId"); String password = map.get("password"); SysConfig config = new SysConfig(); config.setConfigKey("syCarPT"); List sysConfigResult = sysConfigService.selectConfigList(config); String syURL = ""; if(sysConfigResult.size() == 0){ return error("三一车辆url没有录入"); }else{ syURL = sysConfigResult.get(0).getConfigValue(); //Map result = SYCarClient.logIn(syURL,userId, password); String passwordMd5 = DigestUtils.md5Hex(password); Map result = sYClient.logIn(syURL,passwordMd5,userId); return success(result); } } /** * 获取未挂接权限的三一车辆 */ // @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyCarNoRight')") @PostMapping("/getArdSyCarNoRight") @ApiOperation("获取未挂接权限的三一车辆") public Map getArdSyCarNoRight(){ String userId = SecurityUtils.getUserId(); Map result = ardSyCarService.getArdSyCarNoRight(userId); if(((String)result.get("code")).equals("500")){ return error((String) result.get("data")); }else if(((String)result.get("code")).equals("200")){ return success(result.get("data")); }else{ return error(""); } } /** * 获取全部的三一车辆 */ // @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyCarAll')") @PostMapping("/getArdSyCarAll") @ApiOperation("获取全部的三一车辆") public Map getArdSyCarAll(){ String userId = SecurityUtils.getUserId(); Map result = ardSyCarService.getArdSyCarAll(userId); if(((String)result.get("code")).equals("500")){ return error((String) result.get("data")); }else if(((String)result.get("code")).equals("200")){ return success(result.get("data")); }else{ return error(""); } } /** * 获取全部车辆模型 */ // @PreAuthorize("@ss.hasPermi('sy:syCar:getAllCarModel')") @PostMapping("/getAllCarModel") @ApiOperation("获取全部车辆模型") public Map getAllCarModel(){ try{ List> result = ardSyCarService.getAllCarModel(); return toAjaxList(result); } catch(Exception e){ return toAjaxList(new ArrayList()); } } /** * 上传车辆图片 */ @PreAuthorize("@ss.hasPermi('sy:syCar:uploadCarPicture')") @PostMapping("/uploadCarPicture") @ApiOperation("上传车辆图片") public Map uploadCarPicture(@RequestParam(value = "id",required = false,defaultValue = "") String id,@RequestParam("carPicture") MultipartFile carPicture){ try{ String result = ardSyCarService.uploadCarPicture(id,carPicture); return success(result); } catch(Exception e){ return error(""); } } @PreAuthorize("@ss.hasPermi('sy:syCar:allListByUser')") @PostMapping("allListByUser") @ApiOperation("根据用户获取三一列表") public Map allListByUser(){ String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String syURL = sysConfigService.getSYURL(); //根据userId查询部门Id SysUser sysUser = sysUserService.selectUserById(usersId); //根据当前deptId或者当前及所属下级的所有deptId List deptList = sysDeptService.deptIdBySub(sysUser.getDeptId()); return ardSyCarService.allListByUser(ardSyUser,syURL,usersId,deptList); } @PreAuthorize("@ss.hasPermi('sy:syCar:carList')") @PostMapping("carList") @ApiOperation("根据teamId获取车辆列表") public Results getCarList(@RequestBody Map map){ String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String syURL = sysConfigService.getSYURL(); String teamId = map.get("teamId"); //判断关联表是否有数据 if(ardSyUser!=null) { //查询出31的车辆数据 List> list = ardSyCarService.getCarList(ardSyUser,syURL,usersId,teamId); if(list.isEmpty()){ return Results.succeed(new ArrayList()); } //根据userId查询部门Id SysUser sysUser = sysUserService.selectUserById(usersId); //根据当前deptId或者当前及所属下级的所有deptId List deptList = sysDeptService.deptIdBySub(sysUser.getDeptId()); //根据dept集合查询出所有对应的车辆列表并赋值 return Results.succeed(ardSyCarService.carIdByDeptList(deptList,list)); }else { return Results.error("列表为空!无关联账号!"); } } // @PreAuthorize("@ss.hasPermi('sy:syCar:carListById')") @PostMapping("/carListById/{id}") @ApiOperation("根据车辆ID获取车辆列表") public Results carListById(@PathVariable String id){ return ardSyCarService.carListById(id); } @PreAuthorize("@ss.hasPermi('sy:syCar:getCarGPSHistory')") @PostMapping("getCarGPSHistory") @ApiOperation("根据车辆ID获取历史轨迹") public Results getCarGPSTrack(@RequestBody Map map) { String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String syURL = sysConfigService.getSYURL(); return ardSyCarService.getCarGPSTrack(map,syURL, ardSyUser); } @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyUserByUsersId')") @PostMapping("getArdSyUserByUsersId") @ApiOperation("获取三一平台对应用户名密码") public Results getArdSyUserByUsersId() { String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); Map map = new HashMap<>(); if(ardSyUser==null){ return Results.succeed(); }else { map.put("userId",ardSyUser.getUserId()); map.put("password",ardSyUser.getPassword()); map.put("passwords",DigestUtils.md5Hex(ardSyUser.getPassword())); } return Results.succeed(map); } @PreAuthorize("@ss.hasPermi('sy:syCar:getSDKCarPositionByRight')") @PostMapping("getSDKCarPositionByRight") @ApiOperation("获取部门权限下所有车辆位置") public Results getSDKCarPositionByRight(){ String usersId = SecurityUtils.getUserId(); //根据userId查询部门Id SysUser sysUser = sysUserService.selectUserById(usersId); Map>> deptPositionMap = PositionContainer.getDeptPositionMap(); if(deptPositionMap.isEmpty()){ return Results.error("31平台无车辆位置返回"); }else { // return Results.succeed(deptPositionMap.get(sysUser.getDeptId().toString()).get(map.get("carId"))); return Results.succeed(deptPositionMap.get(sysUser.getDeptId().toString())); } } @PreAuthorize("@ss.hasPermi('sy:syCar:getCarNearPositionByCarId')") @PostMapping("getCarNearPositionByCarId") @ApiOperation("获取单个车辆位置") public Results getCarNearPositionByCarId(@RequestBody Map map){ String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String carId = map.get("carId"); String syURL = sysConfigService.getSYURL(); return Results.succeed(ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser)); } @PreAuthorize("@ss.hasPermi('sy:syCar:chaseCarByCarId')") @PostMapping("chaseCarByCarId") @ApiOperation("根据车辆主键追踪车辆") public Results chaseCarByCarId(@RequestBody Map map){ String usersId = SecurityUtils.getUserId(); String carId = map.get("carId"); String cycle = map.get("cycle"); return ardSyCarService.chaseCarByCarId(usersId,carId,cycle); } @PreAuthorize("@ss.hasPermi('sy:syCar:getExistTraceByCarIdAndMonth')") @PostMapping("getExistTraceByCarIdAndMonth") @ApiOperation("根据车辆主键及月份查询轨迹存在") public Results getExistTraceByCarIdAndMonth(@RequestBody Map map){ String userId = SecurityUtils.getUserId(); String carId = map.get("carId"); String time = map.get("time"); return ardSyCarService.getExistTraceByCarIdAndMonth(userId,carId,time); } @GetMapping("getCarPicture") @ApiOperation("清淤获取照片") public AjaxResult getCarNearPositionByCarId(String carId) throws UnsupportedEncodingException { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); Date currentTime = new Date(); long tenSeconds = 1000L; Date beforeTenSeconds = new Date(currentTime.getTime() - tenSeconds); String startTime = sdf.format(beforeTenSeconds); String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String syURL = sysConfigService.getSYURL(); String sessionId = ardSyCarService.getSessionId(syURL,ardSyUser); System.out.println("sessionId:"+sessionId); //获取摄像通道信息 Map result = ardSyCarService.getCarPicture(carId,syURL,sessionId); String vs = ""; try { //提取通道信息 Map map = ((List>)result.get("list")).get(0); Map videos = (Map) JSON.parse((String) map.get("videos")); System.out.println("通道:"+videos); vs = (String) videos.get("vs"); } catch (Exception e) { return AjaxResult.error("该车辆没有摄像通道无照片数据!"); } //筛选通道信息 String[] vsArray = vs.split(","); List channelList = new ArrayList<>(); for (int i = 0; i < vsArray.length; i++) { channelList.add(vsArray[i].substring(0,1)); } //拍照 Map sendCmdMap = ardSyCarService.sendCmd(ardSyUser.getUserId(),syURL,sessionId,carId,channelList); System.out.println("拍照:"+sendCmdMap); //获取照片 Map photoMap = ardSyCarService.getPhoto(syURL,carId,sessionId,startTime); System.out.println("获取照片:"+photoMap); return AjaxResult.success(photoMap); } @GetMapping("getVideo") @ApiOperation("清淤获取视频") public AjaxResult getVideo(String carId){ String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String syURL = sysConfigService.getSYURL(); Map video = ardSyCarService.getVideo(syURL,carId,ardSyUser); return AjaxResult.success(video); } @GetMapping("getThreeOne") @ApiOperation("获取三一视频地址") public AjaxResult getThreeOne() { return AjaxResult.success("获取地址成功!",sysConfigService.getSYVideo()); } @PreAuthorize("@ss.hasPermi('sy:syCar:getAlarmHPfmCountDetail')") @PostMapping("getAlarmHPfmCountDetail") @ApiOperation("根据车辆和时间段查询报警历史记录详情") public AjaxResult getAlarmHPfmCountDetail(@RequestBody Map map){ String usersId = SecurityUtils.getUserId(); ArdSyUser ardSyUser = iArdSyUserService.userById(usersId); String carId = map.get("carId"); String startTime = map.get("startTime"); String endTime = map.get("endTime"); String syURL = sysConfigService.getSYURL(); String sessionId = ardSyCarService.getSessionId(syURL,ardSyUser); Map mapDetail = ardSyCarService.getAlarmHPfmCountDetail(sessionId,usersId,carId,startTime,endTime,syURL); return AjaxResult.success(mapDetail); } @GetMapping("/getOnlineSYCarPosition") @ApiOperation("单兵端查看已通过审批的在线三一车辆位置") public AjaxResult getOnlineSYCarPosition() { String soilderId = SecurityUtils.getUserId(); try{ Map result = ardSyCarService.getOnlineSYCarPosition(soilderId); return AjaxResult.success(result); }catch(Exception e){ e.printStackTrace(); return AjaxResult.error(); } } public Map sendCmd(String syURL,String userId,String carId,Integer cmdId,String cmd,String paramsStr,String sessionId){ OkHttpClient okHttpClient = new OkHttpClient(); Request request = new Request.Builder() .url(syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId) .build(); //System.out.println("url = " + syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId); Response response = null; try { response = okHttpClient.newCall(request).execute(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } okhttp3.ResponseBody responseBody = response.body(); try { String message = responseBody.string();// 响应体 Map map = (Map) JSON.parse(message); return map; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return new HashMap(); } } }