package com.stylefeng.guns.modular.api;
|
|
import com.alibaba.fastjson.JSON;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.common.constant.JwtConstants;
|
import com.stylefeng.guns.core.page.PageInfoBT;
|
import com.stylefeng.guns.core.util.JwtTokenUtil;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.model.enums.ImageModelEnum;
|
import com.stylefeng.guns.modular.system.model.enums.VideoChannelEnum;
|
import com.stylefeng.guns.modular.system.model.vo.*;
|
import com.stylefeng.guns.modular.system.service.IPatrolTaskService;
|
import com.stylefeng.guns.modular.system.service.ITaskDetailService;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.util.videoGateway.VideoGateway;
|
import com.stylefeng.guns.modular.system.util.videoGateway.model.Ship;
|
import com.stylefeng.guns.modular.system.util.videoGateway.model.Vehicle;
|
import com.stylefeng.guns.modular.system.warpper.VehicleSpeed;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.*;
|
|
/**
|
* @author zhibing.pu
|
* @Date 2024/12/17 20:18
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("")
|
public class PatrolTaskController extends BaseController {
|
|
@Resource
|
private IPatrolTaskService patrolTaskService;
|
|
@Resource
|
private ITaskDetailService taskDetailService;
|
|
|
|
@GetMapping("/api/patrolTask/getTaskDetailList")
|
@ApiOperation(value = "获取任务列表数据", tags = {"任务管理"})
|
public PageInfoBT<TaskDetailList> getTaskDetailList(TaskDetailListVo vo){
|
Page<TaskDetailList> pageInfo = new Page(vo.getLimit(), vo.getOffset());
|
List<TaskDetailList> taskDetailList = taskDetailService.getTaskDetailList(pageInfo, vo);
|
pageInfo.setRecords(taskDetailList);
|
PageInfoBT<TaskDetailList> taskDetailListPageInfoBT = super.packForBT(pageInfo);
|
taskDetailListPageInfoBT.setSize(vo.getOffset());
|
taskDetailListPageInfoBT.setCurrent(vo.getLimit());
|
return taskDetailListPageInfoBT;
|
}
|
|
|
|
@DeleteMapping("/api/patrolTask/delTaskDetail")
|
@ApiOperation(value = "删除任务", tags = {"任务管理"})
|
public ResultUtil delTaskDetail(String ids){
|
List<String> id = Arrays.asList(ids.split(","));
|
taskDetailService.delTaskDetail(id);
|
return ResultUtil.success();
|
}
|
|
|
|
@PostMapping("/api/patrolTask/addPatrolTask")
|
@ApiOperation(value = "添加巡查任务", tags = {"任务管理"})
|
public ResultUtil addPatrolTask(@RequestBody PatrolTaskVo vo, HttpServletRequest request){
|
String token = request.getHeader(JwtConstants.AUTH_HEADER);
|
if (token != null && token.startsWith("Bearer ")) {
|
token = token.substring(token.indexOf(" ") + 1);
|
}
|
String userId = JwtTokenUtil.getPrivateClaimFromToken(token, "userId");
|
patrolTaskService.addPatrolTask(vo, userId);
|
return ResultUtil.success();
|
}
|
|
@GetMapping("/api/patrolTask/getImageModel")
|
@ApiOperation(value = "获取图片模型", tags = {"任务管理"})
|
public ResultUtil<List<Map<String, Object>>> getImageModel(){
|
ImageModelEnum[] values = ImageModelEnum.values();
|
List<Map<String, Object>> list = new ArrayList<>();
|
for (ImageModelEnum modelEnum : values) {
|
String name = modelEnum.getName();
|
String code = modelEnum.getCode();
|
Map<String, Object> map = new HashMap<>();
|
map.put("name", name);
|
map.put("code", code);
|
list.add(map);
|
}
|
return ResultUtil.success(list);
|
}
|
|
|
|
@GetMapping("/api/patrolTask/getVideoChannel")
|
@ApiOperation(value = "获取视频通道", tags = {"任务管理"})
|
public ResultUtil<List<Map<String, Object>>> getVideoChannel(){
|
VideoChannelEnum[] values = VideoChannelEnum.values();
|
List<Map<String, Object>> list = new ArrayList<>();
|
for (VideoChannelEnum modelEnum : values) {
|
String name = modelEnum.getName();
|
Integer id = modelEnum.getId();
|
Map<String, Object> map = new HashMap<>();
|
map.put("name", name);
|
map.put("id", id);
|
list.add(map);
|
}
|
return ResultUtil.success(list);
|
}
|
|
|
@GetMapping("/api/patrolTask/getVehicleList")
|
@ApiOperation(value = "获取车辆列表", tags = {"任务管理"})
|
public ResultUtil<List<Vehicle>> getVehicleList(Integer year){
|
List<Vehicle> vehicleList = VideoGateway.getVehicleList(null, null, null, 0);
|
List<Vehicle> list = new ArrayList<>();
|
if(null != year){
|
for (Vehicle vehicle : vehicleList) {
|
String vehicleGpsProtocol = vehicle.getVehicleGpsProtocol();
|
if(2023 == year && null != vehicleGpsProtocol && vehicleGpsProtocol.equals("2")){
|
list.add(vehicle);
|
}
|
}
|
}else{
|
list = vehicleList;
|
}
|
return ResultUtil.success(list);
|
}
|
|
|
|
@GetMapping("/api/patrolTask/getShipList")
|
@ApiOperation(value = "获取船舶列表", tags = {"任务管理"})
|
public ResultUtil<List<Ship>> getShipList(Integer year){
|
List<Ship> shipList = VideoGateway.getShipList(null, null, null, 0);
|
List<Ship> list = new ArrayList<>();
|
if(null != year){
|
for (Ship ship : shipList) {
|
String vehicleGpsProtocol = ship.getVehicleGpsProtocol();
|
if(2023 == year && null != vehicleGpsProtocol && vehicleGpsProtocol.equals("2")){
|
list.add(ship);
|
}
|
}
|
}else{
|
list = shipList;
|
}
|
return ResultUtil.success(list);
|
}
|
|
|
|
@GetMapping("/api/patrolTask/getTaskRecordList")
|
@ApiOperation(value = "获取任务记录列表", tags = {"任务记录"})
|
public PageInfoBT<TaskRecordList> getTaskRecordList(TaskRecordListVo vo){
|
Page<TaskRecordList> pageInfo = new Page(vo.getLimit(), vo.getOffset());
|
List<TaskRecordList> taskRecordList = taskDetailService.getTaskRecordList(pageInfo, vo);
|
pageInfo.setRecords(taskRecordList);
|
PageInfoBT<TaskRecordList> taskRecordListPageInfoBT = super.packForBT(pageInfo);
|
taskRecordListPageInfoBT.setSize(vo.getOffset());
|
taskRecordListPageInfoBT.setCurrent(vo.getLimit());
|
return taskRecordListPageInfoBT;
|
}
|
|
|
|
@GetMapping("/api/patrolTask/getTaskRecordInfo")
|
@ApiOperation(value = "获取任务记录详情", tags = {"任务记录"})
|
public ResultUtil<TaskRecordInfo> getTaskRecordInfo(Integer id){
|
TaskRecordInfo taskRecordInfo = taskDetailService.getTaskRecordInfo(id);
|
return ResultUtil.success(taskRecordInfo);
|
}
|
|
@PostMapping("/api/patrolTask/getPictureDetailsVehicle")
|
@ApiOperation(value = "获取任务记录详情中的车船数据", tags = {"任务记录"})
|
public ResultUtil<PictureDetailsVehicle> getPictureDetailsVehicle(@RequestBody PictureDetailsVo vo){
|
PictureDetailsVehicle pictureDetailsVehicle = taskDetailService.getPictureDetailsVehicle(vo);
|
return ResultUtil.success(pictureDetailsVehicle);
|
}
|
|
|
|
@PostMapping("/api/patrolTask/getPictureDetails")
|
@ApiOperation(value = "获取任务记录详情中的视频通道数据", tags = {"任务记录"})
|
public PageInfoBT<PictureDetails> getPictureDetails(@RequestBody PictureDetailsVo vo){
|
Page<PictureDetails> pageInfo = new Page(vo.getLimit(), vo.getOffset());
|
List<PictureDetails> pictureDetails = taskDetailService.getPictureDetails(pageInfo, vo);
|
pageInfo.setRecords(pictureDetails);
|
PageInfoBT<PictureDetails> pictureDetailsPageInfoBT = super.packForBT(pageInfo);
|
pictureDetailsPageInfoBT.setSize(vo.getOffset());
|
pictureDetailsPageInfoBT.setCurrent(vo.getLimit());
|
return pictureDetailsPageInfoBT;
|
}
|
|
|
|
@PostMapping("/api/patrolTask/manualAudit")
|
@ApiOperation(value = "人工审核视频通道数据", tags = {"任务记录"})
|
public ResultUtil manualAudit(@RequestBody ManualAuditVo vo, HttpServletRequest request){
|
String token = request.getHeader(JwtConstants.AUTH_HEADER);
|
if (token != null && token.startsWith("Bearer ")) {
|
token = token.substring(token.indexOf(" ") + 1);
|
}
|
String userId = JwtTokenUtil.getPrivateClaimFromToken(token, "userId");
|
return taskDetailService.manualAudit(vo, userId);
|
}
|
|
|
|
@GetMapping("/api/patrolTask/downloadTaskRecord")
|
@ApiOperation(value = "下载任务记录数据", tags = {"任务记录"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "列表数据id,多个逗号分隔", name = "ids", dataType = "String"),
|
@ApiImplicitParam(value = "状态(1=待执行,2=进行中,3=成功,4=失败)", name = "status", dataType = "int"),
|
@ApiImplicitParam(value = "规则编号", name = "code", dataType = "String"),
|
})
|
public void downloadTaskRecord(String ids, String code, Integer status, HttpServletResponse response){
|
List<String> id = null;
|
if(ToolUtil.isNotEmpty(ids)){
|
String[] split = ids.split(",");
|
id = Arrays.asList(split);
|
}
|
taskDetailService.downloadTaskRecord(id, code, status, response);
|
}
|
|
|
@PostMapping("/base/patrolTask/vehicleSpeed")
|
@ApiOperation(value = "变更车辆状态", tags = {"互联互通接口"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "车牌号", name = "vehicleNum", dataType = "String", required = true),
|
@ApiImplicitParam(value = "状态(1=行驶中,2=已停止)", name = "vehicleStatus", dataType = "int", required = true),
|
@ApiImplicitParam(value = "车辆类型(1=车,2=船)", name = "vehicleType", dataType = "int", required = true),
|
@ApiImplicitParam(value = "通信号", name = "communicationNum", dataType = "String", required = true),
|
@ApiImplicitParam(value = "gps协议", name = "vehicleGpsProtocol", dataType = "String", required = true),
|
@ApiImplicitParam(value = "纬度", name = "latitude", dataType = "double", required = true),
|
@ApiImplicitParam(value = "经度", name = "longitude", dataType = "double", required = true),
|
})
|
public ResultUtil vehicleSpeed(@RequestBody VehicleSpeed vehicleSpeed){
|
log.info("推送车辆状态:{}", JSON.toJSONString(vehicleSpeed));
|
patrolTaskService.vehicleSpeed(vehicleSpeed.getVehicleNum(), vehicleSpeed.getVehicleStatus(), vehicleSpeed.getVehicleType(),
|
vehicleSpeed.getCommunicationNum(), vehicleSpeed.getVehicleGpsProtocol(), vehicleSpeed.getLatitude(), vehicleSpeed.getLongitude());
|
return ResultUtil.success();
|
}
|
}
|