执法记录仪修改
This commit is contained in:
parent
fa4076b238
commit
c676a4007b
@ -97,6 +97,7 @@ public class PoliceCameraItemController {
|
||||
@ApiImplicitParam(name = "bindTicket", value = "1已绑定0空闲", paramType = "query", required = false, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "ticketId", value = "工作票id", paramType = "query", required = false, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "status", value = "状态:1:未开始;2:施工中;3:暂停中;4:已完工;", paramType = "query", required = false, dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "riskType", value = "风险类型:1:一般风险;2:高风险;", paramType = "query", required = false, dataType = "Integer"),
|
||||
})
|
||||
@GetMapping(value = "/page")
|
||||
public Result<IPage<PoliceCameraItemVo>> queryPageList(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
|
||||
@ -29,23 +29,23 @@ public class PoliceCameraItemVo extends PoliceCameraItem {
|
||||
@ApiModelProperty(value = "分组名称")
|
||||
private String groupName;
|
||||
/**
|
||||
* 未结束的工作票id
|
||||
* 施工中的工作票id
|
||||
*/
|
||||
@ApiModelProperty(value = "未结束的工作票id")
|
||||
@ApiModelProperty(value = "施工中的工作票id")
|
||||
private java.lang.Long workTicketId;
|
||||
/**
|
||||
* 未结束的工作票编号
|
||||
* 施工中的工作票编号
|
||||
*/
|
||||
@ApiModelProperty(value = "未结束的工作票编号")
|
||||
@ApiModelProperty(value = "施工中的工作票编号")
|
||||
private java.lang.String workTicketNumber;
|
||||
/**
|
||||
* 未结束的施工场站s(多个,分割)
|
||||
* 施工中的施工场站s(多个,分割)
|
||||
*/
|
||||
@ApiModelProperty(value = "未结束的施工场站s(多个,分割)")
|
||||
@ApiModelProperty(value = "施工中的施工场站s(多个,分割)")
|
||||
private java.lang.String constructionAreas;
|
||||
/**
|
||||
* 施工区域名称s(多个,分割)
|
||||
* 施工中施工区域名称s(多个,分割)
|
||||
*/
|
||||
@ApiModelProperty(value = "施工区域名称s(多个,分割)")
|
||||
@ApiModelProperty(value = "施工中施工区域名称s(多个,分割)")
|
||||
private java.lang.String constructionAreaNames;
|
||||
}
|
||||
|
||||
@ -6,6 +6,9 @@
|
||||
select t.*
|
||||
,if(t1.police_camera_id is null,0,1) as bind_ticket
|
||||
,pcg.group_name
|
||||
,t2.id as work_ticket_id
|
||||
,t2.work_ticket_number
|
||||
,t2.construction_areas
|
||||
from police_camera_item t
|
||||
join police_camera_group pcg on pcg.id=t.group_id
|
||||
left join (
|
||||
@ -22,10 +25,16 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
and wt.status = #{param.status}
|
||||
</if>
|
||||
) t1 on t1.police_camera_id=t.item_id
|
||||
left join (
|
||||
select distinct wtcr.police_camera_id,wt.id,wt.work_ticket_number,wt.construction_areas,wt.status,wt.risk_type
|
||||
from work_ticket wt
|
||||
join work_ticket_camera_rel wtcr on wt.id = wtcr.work_ticket_id
|
||||
where wt.status!=4
|
||||
<if test="param.projectSn != null and param.projectSn != ''">
|
||||
and wt.project_sn = #{param.projectSn}
|
||||
</if>
|
||||
) t2 on t2.police_camera_id=t.item_id
|
||||
where 1=1
|
||||
<if test="param.itemIdList != null and param.itemIdList.size() != 0">
|
||||
and t.item_id in
|
||||
@ -33,6 +42,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.status != null and param.status != ''">
|
||||
and t2.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.riskType != null and param.riskType != ''">
|
||||
and t2.risk_type = #{param.riskType}
|
||||
</if>
|
||||
)t
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
@ -1,29 +1,45 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.zhgd.xmgl.call.api.PoliceCameraManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.PoliceCameraManufacturerFactory;
|
||||
import com.zhgd.xmgl.modules.policecamera.entity.PoliceCameraItem;
|
||||
import com.zhgd.xmgl.modules.policecamera.entity.PoliceCameraVideoConfig;
|
||||
import com.zhgd.xmgl.modules.policecamera.service.IPoliceCameraItemService;
|
||||
import com.zhgd.xmgl.modules.policecamera.service.IPoliceCameraVideoConfigService;
|
||||
import com.zhgd.xmgl.modules.policecamera.service.IProjectPoliceCameraConfigService;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.util.AsyncTaskUtil;
|
||||
import com.zhgd.xmgl.util.HikVideoUtil;
|
||||
import com.zhgd.xmgl.util.PathUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("xmgl/task")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class Mcs8Task {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@ -37,10 +53,22 @@ public class Mcs8Task {
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IPoliceCameraVideoConfigService policeCameraVideoConfigService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IPoliceCameraItemService policeCameraItemService;
|
||||
/**
|
||||
* 截取rtsp流的host
|
||||
*/
|
||||
@Value("${screenshotUrl:http://127.0.0.1:51111}")
|
||||
private String screenshotUrl;
|
||||
|
||||
/**
|
||||
* 定时从Mcs8获取执法记录仪文件
|
||||
*/
|
||||
@SchedulerLock(name = "getPoliceCameraItemFile", lockAtMostFor = 1000 * 60 * 5, lockAtLeastFor = 1000 * 60 * 2)
|
||||
@Scheduled(cron = "0 */5 * * * ?")
|
||||
@RequestMapping("getPoliceCameraItemFile")
|
||||
public void getPoliceCameraItemFile() {
|
||||
@ -60,6 +88,86 @@ public class Mcs8Task {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新执法记录仪的封面
|
||||
*/
|
||||
@SchedulerLock(name = "updatePoliceCameraItemCoverUrl", lockAtMostFor = 1000 * 60 * 10, lockAtLeastFor = 1000 * 60 * 5)
|
||||
@Scheduled(cron = "* */30 * * * ?")
|
||||
@RequestMapping("updatePoliceCameraItemCoverUrl")
|
||||
public void updatePoliceCameraItemCoverUrl() {
|
||||
List<PoliceCameraVideoConfig> configs = policeCameraVideoConfigService.list(new LambdaQueryWrapper<PoliceCameraVideoConfig>());
|
||||
Map<String, List<PoliceCameraItem>> projectSn2ItemsMap = policeCameraItemService.list(new LambdaQueryWrapper<PoliceCameraItem>().eq(PoliceCameraItem::getDeviceState, 1)).stream().collect(Collectors.groupingBy(PoliceCameraItem::getProjectSn));
|
||||
for (PoliceCameraVideoConfig config : configs) {
|
||||
List<PoliceCameraItem> items = projectSn2ItemsMap.get(config.getProjectSn());
|
||||
if (items != null) {
|
||||
for (PoliceCameraItem item : items) {
|
||||
if (Objects.equals(item.getDeviceState(), 1)) {
|
||||
String url = null;
|
||||
try {
|
||||
url = HikVideoUtil.callPostApiGetPreviewURL(item.getMonitoringNumber(), "rtsp",
|
||||
1, config.getIp(),
|
||||
config.getPort(), config.getAppId(), config.getAppSecret(), 1);
|
||||
if (StrUtil.isNotBlank(url)) {
|
||||
String screenshot = downloadScreenshot(url);
|
||||
if (StrUtil.isNotBlank(screenshot)) {
|
||||
try {
|
||||
if (StrUtil.isNotBlank(item.getCoverUrl())) {
|
||||
FileUtil.del(PathUtil.getBasePath() + "/" + item.getCoverUrl());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
policeCameraItemService.update(null, new LambdaUpdateWrapper<PoliceCameraItem>()
|
||||
.set(PoliceCameraItem::getCoverUrl, screenshot)
|
||||
.eq(PoliceCameraItem::getItemId, item.getItemId())
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("更新执法记录仪的封面错误:{}", e.getMessage());
|
||||
log.info("更新执法记录仪的封面错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 截取rtsp流的图片
|
||||
*
|
||||
* @param playUrl
|
||||
* @return
|
||||
*/
|
||||
public String downloadScreenshot(String playUrl) {
|
||||
String apiUrl = screenshotUrl + "/screenshot";
|
||||
String name = IdUtil.randomUUID() + ".jpg";
|
||||
String savePath = PathUtil.getBasePath() + "/" + name;
|
||||
|
||||
// 构造请求参数
|
||||
String jsonBody = "{\"playUrl\":\"" + playUrl + "\"}";
|
||||
|
||||
try {
|
||||
log.info("发送http请求截取rtsp流的图片url:{},body:{}", apiUrl, jsonBody);
|
||||
// 发送 POST 请求并下载文件
|
||||
HttpResponse response = HttpRequest.post(apiUrl)
|
||||
.body(jsonBody)
|
||||
.execute();
|
||||
|
||||
if (response.isOk()) {
|
||||
// 将响应内容保存为文件
|
||||
FileUtil.writeFromStream(response.bodyStream(), savePath);
|
||||
System.out.println("图片下载成功: " + savePath);
|
||||
} else {
|
||||
System.out.println("下载失败,状态码: " + response.getStatus());
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("截取rtsp流错误:{}", e.getMessage());
|
||||
log.info("截取rtsp流错误:", e);
|
||||
return null;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 定时更新执法仪设备状态
|
||||
@ -80,5 +188,4 @@ public class Mcs8Task {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user