Authored by mali

转码

package com.yoho.order.dal;
import com.yoho.order.model.UserCameraRecord;
import org.apache.ibatis.annotations.Param;
/**
* Created by li.ma on 2018/12/21.
*/
public interface UserCameraRecordMapper {
UserCameraRecord selectUserCameraRecord(@Param("pid")Integer pid);
int insertUserCameraRecord(@Param("pid")Integer pid, @Param("cameraCode")Integer cameraCode);
}
... ...
package com.yoho.order.model;
/**
* Created by li.ma on 2018/12/21.
*/
import com.alibaba.fastjson.JSONObject;
/**
* 登录pid和摄像设备的关系表
*/
public class UserCameraRecord {
private Integer id;
private Integer pid;
private Integer cameraCode;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public Integer getCameraCode() {
return cameraCode;
}
public void setCameraCode(Integer cameraCode) {
this.cameraCode = cameraCode;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.order.dal.UserCameraRecordMapper" >
<resultMap id="BaseResultMap" type="com.yoho.order.model.UserCameraRecord" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="camera_code" property="cameraCode" javaType="INTEGER" />
<result column="pid" property="pid" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, camera_code, pid
</sql>
<select id="selectUserCameraRecord" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from user_camera_record WHERE pid = #{pid,jdbcType=INTEGER}
</select>
<insert id="insertUserCameraRecord" >
insert into user_camera_record (pid, camera_code)
values (#{pid,jdbcType=INTEGER}, #{cameraCode,jdbcType=INTEGER}) ON DUPLICATE KEY UPDATE camera_code = #{cameraCode,jdbcType=INTEGER}
</insert>
</mapper>
\ No newline at end of file
... ...
... ... @@ -72,4 +72,14 @@ public class UfoLiveController {
return new ApiResponse.ApiResponseBuilder().code(200).data(cameraRecordResps).message("查询成功").build();
}
@RequestMapping(value = "/queryInitCameraRecord")
public ApiResponse queryInitCameraRecord(QNliveReq req) {
LOGGER.info("queryInitCameraRecord in. req is {}", req);
Integer initCameraCode = ufoLiveService.queryInitCameraCode(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(initCameraCode).message("查询成功").build();
}
}
... ...
... ... @@ -41,7 +41,6 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
LOGGER.info("LiveEventsListener.onApplicationEvent method in. param is {}", event);
QiniuLiveRecord record = event.getRecord();
qiniuLiveRecordMapper.updateShowFlagBySkup(record.getSkup(), 0, record.getNotInId());
List<SellerOrderGoods> sellerOrderGoodses = sellerOrderGoodsMapper.selectByIds(Lists.newArrayList(record.getSkup()));
if (CollectionUtils.isEmpty(sellerOrderGoodses)) {
... ...
... ... @@ -4,8 +4,10 @@ import com.google.common.collect.Lists;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.order.dal.CameraRecordMapper;
import com.yoho.order.dal.QiniuLiveRecordMapper;
import com.yoho.order.dal.UserCameraRecordMapper;
import com.yoho.order.model.CameraRecord;
import com.yoho.order.model.QiniuLiveRecord;
import com.yoho.order.model.UserCameraRecord;
import com.yoho.ufo.exception.PlatformException;
import com.yoho.ufo.order.service.event.QiniuLiveRecordEvent;
import com.yoho.ufo.service.impl.QNLiveUtil;
... ... @@ -44,6 +46,9 @@ public class UfoLiveService implements ApplicationContextAware {
@Autowired
private CameraRecordMapper cameraRecordMapper;
@Autowired
private UserCameraRecordMapper userCameraRecordMapper;
public void setApplicationContext(ApplicationContext applicationContext) {
this.context = applicationContext;
}
... ... @@ -71,6 +76,8 @@ public class UfoLiveService implements ApplicationContextAware {
// 保存记录
private void saveRecord(QNliveReq req, String fileName, String persistId) {
qiniuLiveRecordMapper.updateShowFlagBySkup(req.getSkup(), 0, 0); // 先更新之前的视频记录为不可见
QiniuLiveRecord record = new QiniuLiveRecord();
record.setDepotNo(req.getDepotNo());
record.setCreateTime(DateUtil.getCurrentTimeSeconds());
... ... @@ -117,6 +124,8 @@ public class UfoLiveService implements ApplicationContextAware {
}
public String queryM3u8Url(Integer cameraCode) throws PlatformException {
userCameraRecordMapper.insertUserCameraRecord(new UserHelper().getUserId(), cameraCode);
List<CameraRecord> cameraRecordList = cameraRecordMapper.selectAllCameraRecord();
for (CameraRecord item : cameraRecordList) {
... ... @@ -135,4 +144,10 @@ public class UfoLiveService implements ApplicationContextAware {
return cameraRecordResps;
}
// 查询当前登录用户默认的摄像头设备
public Integer queryInitCameraCode(QNliveReq req) {
UserCameraRecord userCameraRecord = userCameraRecordMapper.selectUserCameraRecord(new UserHelper().getUserId());
return null == userCameraRecord ? null : userCameraRecord.getCameraCode();
}
}
... ...
... ... @@ -68,6 +68,20 @@
valueField: "cameraCode",
textField: "cameraName"
});
$.ajax({
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/live/queryInitCameraRecord',
success: function (data) {
if (data.code != 200) {
return;
} else if (data.data){
$('#cameraCode').combobox('setValue',data.data);
}
}
});
}
}
});
... ...