package com.sercurityControl.proteam.controller; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.google.common.collect.Maps; import com.securityControl.common.core.utils.aes.Aes; import com.securityControl.common.redis.service.RedisService; import com.sercurityControl.proteam.domain.BallGbBean; import com.sercurityControl.proteam.domain.BallUpDownEntity; import com.sercurityControl.proteam.domain.vo.SysVideoConfigVo; import com.sercurityControl.proteam.dutyTask.domain.BallStateVo; import com.sercurityControl.proteam.service.DeviceService; import com.sercurityControl.proteam.service.impl.BnsVideoServiceImpl; import com.sercurityControl.proteam.util.*; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * 提供给e基建接口校验 */ @RestController @RequestMapping("/api/ballrisk/") @Slf4j public class BnsVideoController { @Autowired private BnsVideoServiceImpl service; @Resource private VideoConfigUtil configUtil; @Autowired private DeviceService deviceService; /** * 查询球机编码路径 * @param macId * @return */ @PostMapping("findBallGb") public String findBallGb(String macId){ AjaxRes ar = new AjaxRes(); try{ System.err.print("macId=="+macId); macId=macId.replace(" ","+"); String decryptMacId= AesEncryptUtils.decrypt(macId,AesEncryptUtils.KEY_NAME); BallGbBean bean = service.findBeanByMac(decryptMacId); ar.setSucceed(bean); }catch (Exception e){ System.err.print(e.toString()); ar.setSucceed(0); } String result=new JacksonHelper().jsonSerialize(ar); System.err.print(result); result=AesEncryptUtils.encrypt(result,AesEncryptUtils.KEY_NAME); return result; } /** * 查询球机上下线 * @param * @return */ @PostMapping("findBallUpDown") public String findBallUpDown(@RequestBody String param){ AjaxRes ar = new AjaxRes(); try{ System.err.print("macId=="+param); param=param.replace(" ","+"); String decryptMacId= AesEncryptUtils.decrypt(param,AesEncryptUtils.KEY_NAME); List list = service.findBallUpDown(decryptMacId); ar.setSucceed(list); }catch (Exception e){ log.error(e.toString(),e); ar.setSucceed(new ArrayList<>()); } String result=new JacksonHelper().jsonSerialize(ar); result=AesEncryptUtils.encrypt(result,AesEncryptUtils.KEY_NAME); return result; } /** * 查询球机状态 * @return */ @PostMapping("findDeviceStatus") public String findDeviceStatus(@RequestBody String puids){ AjaxRes ar = new AjaxRes(); com.alibaba.fastjson2.JSONObject jsonObject=new com.alibaba.fastjson2.JSONObject(); try{ System.err.print("puid=="+puids); puids=puids.replace(" ","+"); String decryptPuid= AesEncryptUtils.decrypt(puids,AesEncryptUtils.KEY_NAME); com.alibaba.fastjson2.JSONObject object = com.alibaba.fastjson2.JSONObject.parseObject(decryptPuid); JSONArray data=object.getJSONArray("puids"); List list= com.alibaba.fastjson2.JSON.parseObject(data.toJSONString(),new com.alibaba.fastjson2.TypeReference>(){}); List allList=new ArrayList<>(); if(configUtil.getConfig().equals("ty")){ //统一视频平台 allList=service.getBallStateTys(list); }else{ allList=service.getBallStateQXS(list); } jsonObject.put("bailMillList",allList); ar.setSucceed(jsonObject); }catch (Exception e){ System.err.print(e.toString()); ar.setSucceed(0); } String result=AesEncryptUtils.encrypt(jsonObject.toString(),AesEncryptUtils.KEY_NAME); return result; } @PostMapping("getDeviceState") public Map getDeviceState(String puid, String type) { Map map= Maps.newHashMap(); map.put("code","1"); try{ Map maps= configUtil.getMaps(); String url= configUtil.getUrl(); puid=Aes.aesDecrypt(puid); type=Aes.aesDecrypt(type); map.put("type",type); String status="1"; if(configUtil.getConfig().equals("ty")) { //统一视频平台 status=service.getTyStatus(puid); }else{ String token = QxVideotape.login(maps,url); status = QxVideotape.getBallStatus(puid, token,maps,url); } SysVideoConfigVo configVo=deviceService.getVideoConfig(); map.put("config",configVo); map.put("status",status); map.put("msg","球机状态请求成功!"); }catch (Exception e){ map.put("code","0"); map.put("msg","接口处理异常,请联系管理员。"); } return map; } }