|
@ -9,6 +9,7 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
import com.yihu.jw.care.service.device.DeviceService;
|
|
import com.yihu.jw.care.service.device.DeviceService;
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
|
import com.yihu.jw.care.util.HlsDownloader;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
@ -17,8 +18,10 @@ import com.yihu.jw.entity.care.device.DeviceDetail;
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
|
|
import com.yihu.jw.file_upload.FileUploadService;
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
|
import com.yihu.jw.restmodel.iot.common.UploadVO;
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
@ -28,10 +31,12 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@ -69,6 +74,10 @@ public class DetectionPlatformService {
|
|
private RoleService roleService;
|
|
private RoleService roleService;
|
|
@Autowired
|
|
@Autowired
|
|
private BaseDoctorDao doctorDao;
|
|
private BaseDoctorDao doctorDao;
|
|
|
|
@Autowired
|
|
|
|
private FileUploadService fileUploadService;
|
|
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
|
|
private String fastdfs_file_url;
|
|
|
|
|
|
private static final String ARTEMIS_PATH = "/artemis";
|
|
private static final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
@ -703,6 +712,13 @@ public class DetectionPlatformService {
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
if("200".equals(jsonObject.getString("code"))){
|
|
if("200".equals(jsonObject.getString("code"))){
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
JSONArray data = jsonObject.getJSONArray("data");
|
|
|
|
//循环获取videoUrl
|
|
|
|
Iterator iterator = data.iterator();
|
|
|
|
while (iterator.hasNext()){
|
|
|
|
JSONObject next = (JSONObject) iterator.next();
|
|
|
|
String videoUrl = this.getVideoUrl(next.getString("indexCode"));
|
|
|
|
next.put("videoUrl",videoUrl);
|
|
|
|
}
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",data,page,pageSize,Long.parseLong(jsonObject.getJSONObject("page").getString("total")));
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",data,page,pageSize,Long.parseLong(jsonObject.getJSONObject("page").getString("total")));
|
|
}else {
|
|
}else {
|
|
return PageEnvelop.getError(result);
|
|
return PageEnvelop.getError(result);
|
|
@ -717,7 +733,7 @@ public class DetectionPlatformService {
|
|
* @param indexCode
|
|
* @param indexCode
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public ObjEnvelop getVideoUrl(String indexCode){
|
|
|
|
|
|
public String getVideoUrl(String indexCode){
|
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v1/preview";
|
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v1/preview";
|
|
Map<String,String> querys = new HashMap<String,String>();//get请求的查询参数
|
|
Map<String,String> querys = new HashMap<String,String>();//get请求的查询参数
|
|
querys.put("cameraIndexCode", indexCode);
|
|
querys.put("cameraIndexCode", indexCode);
|
|
@ -736,11 +752,56 @@ public class DetectionPlatformService {
|
|
result = result.replace("\\n","").replace("\\","");
|
|
result = result.replace("\\n","").replace("\\","");
|
|
JSONObject objects = JSONObject.parseObject(result);
|
|
JSONObject objects = JSONObject.parseObject(result);
|
|
if("200".equals(objects.getString("code"))){
|
|
if("200".equals(objects.getString("code"))){
|
|
return ObjEnvelop.getSuccess("success",objects.getString("playrealUrl"));
|
|
|
|
}else {
|
|
|
|
return ObjEnvelop.getError(result);
|
|
|
|
|
|
return objects.getString("playrealUrl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 将m3u8链接保存到本地的mp4格式
|
|
|
|
* @param originUrlpath
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public ObjEnvelop downM3u8Video(String originUrlpath){
|
|
|
|
//文件存放的路径
|
|
|
|
//TODO 替换成linux系统路径
|
|
|
|
String rootPath = "E:\\videodir";
|
|
|
|
//String originUrlpath = "http://videocdn.renrenjiang.cn/Act-ss-m3u8-sd/1037359_1546064640169/1037359_1546064640169.m3u8";
|
|
|
|
String preUrlPath = originUrlpath.substring(0, originUrlpath.lastIndexOf("/")+1);
|
|
|
|
String fileName = "";
|
|
|
|
HlsDownloader downLoader = new HlsDownloader(originUrlpath, preUrlPath, rootPath);
|
|
|
|
//downLoader.setThreadQuantity(10);
|
|
|
|
try{
|
|
|
|
//是否开启异步下载
|
|
|
|
fileName = downLoader.download(true);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*String fileName = "111.mp4";
|
|
|
|
String rootPath = "D:\\xiao\\Videos";*/
|
|
|
|
if(StringUtils.isNotBlank(fileName)){
|
|
|
|
System.err.println("下载成功"+fileName);
|
|
|
|
System.out.println("完整路径:"+rootPath+"\\"+fileName);
|
|
|
|
|
|
|
|
try {
|
|
|
|
//文件上传
|
|
|
|
UploadVO uploadVO = fileUploadService.uploadStream(new FileInputStream(rootPath + "\\" + fileName), fileName, fastdfs_file_url);
|
|
|
|
return ObjEnvelop.getSuccess("成功",uploadVO);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}finally {
|
|
|
|
//TODO 删除文件
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ObjEnvelop.getError("响应结果为空");
|
|
|
|
|
|
return ObjEnvelop.getError("失败");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
String sss= "qwe.mp4";
|
|
|
|
System.out.println(sss.substring(0,sss.lastIndexOf(".")));
|
|
}
|
|
}
|
|
}
|
|
}
|