|
@ -3,10 +3,14 @@ package com.yihu.jw.care.service.device;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.jw.care.config.YsConfig;
|
|
import com.yihu.jw.care.config.YsConfig;
|
|
|
|
import com.yihu.jw.care.dao.device.BaseMqttCallbackRecordDao;
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
import com.yihu.jw.care.dao.device.YsConfigDao;
|
|
import com.yihu.jw.care.dao.device.YsConfigDao;
|
|
import com.yihu.jw.care.util.DeviceUtil;
|
|
import com.yihu.jw.care.util.DeviceUtil;
|
|
import com.yihu.jw.care.util.HttpClientUtilCare;
|
|
import com.yihu.jw.care.util.HttpClientUtilCare;
|
|
|
|
import com.yihu.jw.care.util.MQTTKXClientUtil;
|
|
|
|
import com.yihu.jw.entity.base.message.MqMessageSubscriberDO;
|
|
|
|
import com.yihu.jw.entity.care.device.BaseMqttCallbackRecordDO;
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
import com.yihu.jw.entity.care.device.YsConfigDo;
|
|
import com.yihu.jw.entity.care.device.YsConfigDo;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
@ -33,6 +37,8 @@ import java.text.MessageFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import static java.lang.Thread.sleep;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Bing on 2021/6/1.
|
|
* Created by Bing on 2021/6/1.
|
|
*/
|
|
*/
|
|
@ -55,6 +61,10 @@ public class YsDeviceService {
|
|
private YsConfigDao ysConfigDao;
|
|
private YsConfigDao ysConfigDao;
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Autowired
|
|
|
|
private BaseMqttCallbackRecordDao mqttCallbackRecordDao;
|
|
|
|
@Autowired
|
|
|
|
private MQTTKXClientUtil mqttkxClientUtil;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取萤石设备assesToken
|
|
* 获取萤石设备assesToken
|
|
@ -334,6 +344,154 @@ public class YsDeviceService {
|
|
*/
|
|
*/
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取凯旋街道视频地址
|
|
|
|
*/
|
|
|
|
public JSONObject getKxDeviceLiveAddress(String patient,String deviceSerial,Integer channelNo,HttpServletRequest request) throws Exception {
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if (StringUtils.isBlank(deviceSerial)){
|
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
|
|
|
|
if (devices.size()>0){
|
|
|
|
deviceSerial = devices.get(0).getDeviceSn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
|
param.add("deviceSerial",deviceSerial);
|
|
|
|
param.add("channelNo",channelNo+"");
|
|
|
|
BaseMqttCallbackRecordDO baseMqttCallbackRecordDO=kaixuanSpOperate(deviceSerial,"ipcam_video_start");
|
|
|
|
if (baseMqttCallbackRecordDO!=null){
|
|
|
|
//{"ipcam_video_start":"1","sourceURL":"http://121.40.135.79/live/18183412724e5573_1679361245235/hls.m3u8","retCode":"0","message":"success."}
|
|
|
|
JSONObject payloadJson = new JSONObject();
|
|
|
|
if (StringUtils.isNoneBlank(baseMqttCallbackRecordDO.getPayload())){
|
|
|
|
payloadJson = JSONObject.parseObject(baseMqttCallbackRecordDO.getPayload());
|
|
|
|
payloadJson.put("deviceSerial",deviceSerial);
|
|
|
|
}
|
|
|
|
result.put(ResponseContant.resultFlag,ResponseContant.success);
|
|
|
|
result.put(ResponseContant.resultMsg,payloadJson);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
//https://open.ys7.com/doc/zh/book/index/address.html#address-api2
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {
|
|
|
|
* "msg":"操作成功!",
|
|
|
|
* "code":"200",
|
|
|
|
* "data":{
|
|
|
|
* "deviceSerial":"F56826706",
|
|
|
|
* "channelNo":1,
|
|
|
|
* "deviceName":"C6Wi(F56826706)",
|
|
|
|
* "liveAddress":"http://hls01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.m3u8", HLS流畅直播地址
|
|
|
|
* "hdAddress":"http://hls01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd.m3u8", HLS高清直播地址
|
|
|
|
* "rtmp":"rtmp://rtmp01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf", RTMP流畅直播地址
|
|
|
|
* "rtmpHd":"rtmp://rtmp01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd", RTMP高清直播地址
|
|
|
|
* "flvAddress":"https://flvopen.ys7.com:9188/openlive/99c146f11ab042849fd4b49f7b0d86cf.flv", FLV流畅直播地址
|
|
|
|
* "hdFlvAddress":"https://flvopen.ys7.com:9188/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd.flv", FLV高清直播地址
|
|
|
|
* "status":1,
|
|
|
|
* "exception":0,0-正常,1-设备不在线,2-设备开启视频加密,3-设备删除,4-失效,5-未绑定,6-账户下流量已超出,7-设备接入限制,0/1/2/6状态返回地址,其他不返回
|
|
|
|
* "beginTime":1622615659000,
|
|
|
|
* "endTime":1622615659000
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
public BaseMqttCallbackRecordDO selectKxSpOperate(String deviceSn,String operate){
|
|
|
|
if (operate.equalsIgnoreCase("ipcam_video_start1")){
|
|
|
|
operate="ipcam_video_start";
|
|
|
|
}else if (operate.equalsIgnoreCase("ipcam_audio_start1")){
|
|
|
|
operate="ipcam_audio_start";
|
|
|
|
}
|
|
|
|
String topic = mqttkxClientUtil.commandMapRes.get(operate).replace("{deviceId}",deviceSn);
|
|
|
|
BaseMqttCallbackRecordDO mqttCallbackRecordDO = new BaseMqttCallbackRecordDO();
|
|
|
|
List<BaseMqttCallbackRecordDO> mqttCallbackRecordDOS = mqttCallbackRecordDao.findByDeviceIdAndAndTopic(deviceSn,topic);
|
|
|
|
if (mqttCallbackRecordDOS!=null&&mqttCallbackRecordDOS.size()!=0){
|
|
|
|
mqttCallbackRecordDO = mqttCallbackRecordDOS.get(0);
|
|
|
|
}
|
|
|
|
return mqttCallbackRecordDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ipcam_video_start 开启视频
|
|
|
|
* ipcam_video_start1 关闭视频推流
|
|
|
|
* ipcam_audio_start 开启音频推流
|
|
|
|
* ipcam_audio_start1 关闭音频推流
|
|
|
|
* ipcam_jpeg_snapshot 视频画面截图保存
|
|
|
|
* ipcam_motor_reset 控制云台复位(校准)
|
|
|
|
* ipcam_motor_left 控制云台左移
|
|
|
|
* ipcam_motor_right 控制云台右移
|
|
|
|
* ipcam_motor_up 控制云台上移
|
|
|
|
* ipcam_motor_down 控制云台下移
|
|
|
|
* @param deviceId
|
|
|
|
* @param operate
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public BaseMqttCallbackRecordDO kaixuanSpOperate(String deviceId,String operate) throws Exception {
|
|
|
|
// 心跳
|
|
|
|
mqttkxClientUtil.heart(deviceId);
|
|
|
|
|
|
|
|
//订阅消息
|
|
|
|
mqttkxClientUtil.subscribe(deviceId);
|
|
|
|
Scanner scanner = new Scanner(System.in);
|
|
|
|
switch (operate){
|
|
|
|
case "ipcam_video_start":
|
|
|
|
logger.info("开启视频推流");
|
|
|
|
mqttkxClientUtil.common("1",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_video_start1":
|
|
|
|
logger.info("关闭视频推流");
|
|
|
|
operate = operate.substring(0,operate.length()-1);
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_audio_start":
|
|
|
|
logger.info("开启音频推流");
|
|
|
|
mqttkxClientUtil.common("1",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_audio_start1":
|
|
|
|
logger.info("关闭音频推流");
|
|
|
|
operate = operate.substring(0,operate.length()-1);
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_jpeg_snapshot":
|
|
|
|
logger.info("视频画面截图保存");
|
|
|
|
mqttkxClientUtil.common("1",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_motor_reset":
|
|
|
|
logger.info("控制云台复位(校准)");
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_motor_left":
|
|
|
|
logger.info("控制云台左移");
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_motor_right":
|
|
|
|
logger.info("控制云台右移");
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_motor_up":
|
|
|
|
logger.info("控制云台上移");
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
case "ipcam_motor_down":
|
|
|
|
logger.info("控制云台下移");
|
|
|
|
mqttkxClientUtil.common("0",deviceId,operate);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
System.out.println("结束");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
String topic = mqttkxClientUtil.commandMapRes.get(operate).replace("{deviceId}",deviceId);
|
|
|
|
sleep(5000);
|
|
|
|
BaseMqttCallbackRecordDO mqttCallbackRecordDO = new BaseMqttCallbackRecordDO();
|
|
|
|
List<BaseMqttCallbackRecordDO> mqttCallbackRecordDOS = mqttCallbackRecordDao.findByDeviceIdAndAndTopic(deviceId,topic);
|
|
|
|
if (mqttCallbackRecordDOS!=null&&mqttCallbackRecordDOS.size()!=0){
|
|
|
|
mqttCallbackRecordDO = mqttCallbackRecordDOS.get(0);
|
|
|
|
}
|
|
|
|
return mqttCallbackRecordDO;
|
|
|
|
}
|
|
|
|
|
|
public JSONObject deviceFailConfig(String deviceSerial,Integer type,HttpServletRequest request) throws Exception {
|
|
public JSONObject deviceFailConfig(String deviceSerial,Integer type,HttpServletRequest request) throws Exception {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
JSONObject responseBody = new JSONObject();
|
|
JSONObject responseBody = new JSONObject();
|