Browse Source

优化

master
blankk 2 years ago
parent
commit
d54b83fcc1
  1. 105
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraBrandController.java
  2. 6
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/Camera.java
  3. 39
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/CameraBrand.java
  4. 18
      ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/CameraBrandMapper.java
  5. 60
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java
  6. 21
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/ICameraBrandService.java
  7. 33
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/CameraBrandServiceImpl.java

105
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraBrandController.java

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
package com.ruoyi.code.camera.controller;
import com.ruoyi.code.camera.domain.CameraBrand;
import com.ruoyi.code.camera.service.ICameraBrandService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* brandController
*
* @author ruoyi
* @date 2022-09-26
*/
@RestController
@RequestMapping("/web/brand")
public class CameraBrandController extends BaseController
{
@Resource
private ICameraBrandService cameraBrandService;
/**
* 查询列表
*/
@PreAuthorize("@ss.hasPermi('web:brand:list')")
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params){
return cameraBrandService.queryPage(params);
}
/**
* 查询列表 不带分页
*/
@RequestMapping("/brands")
public R listBrand(){
return R.ok().put("data",cameraBrandService.list());
}
/**
* 获取详细信息
*/
@RequestMapping("/info/{id}")
@PreAuthorize("@ss.hasPermi('web:brand:query')")
public R info(@PathVariable("id") Long id){
CameraBrand cameraBrand = cameraBrandService.getById(id);
return R.ok().put("data", cameraBrand);
}
/**
* 导出列表
*/
@PreAuthorize("@ss.hasPermi('web:brand:export')")
@Log(title = "列表", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CameraBrand cameraBrand)
{
List<CameraBrand> list = cameraBrandService.list();
ExcelUtil<CameraBrand> util = new ExcelUtil<CameraBrand>(CameraBrand.class);
util.exportExcel(response, list, "列表数据");
}
/**
* 新增
*/
@RequestMapping("/add")
@Log(title = "CameraBrand", businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('web:brand:add')")
public R add(@RequestBody CameraBrand cameraBrand){
cameraBrandService.save(cameraBrand);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/edit")
@PreAuthorize("@ss.hasPermi('web:brand:edit')")
@Log(title = "CameraBrand", businessType = BusinessType.UPDATE)
public R edit(@RequestBody CameraBrand cameraBrand){
cameraBrandService.updateById(cameraBrand);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete/{ids}")
@PreAuthorize("@ss.hasPermi('web:brand:remove')")
@Log(title = "CameraBrand", businessType = BusinessType.DELETE)
public R delete(@PathVariable Long[] ids){
cameraBrandService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}

6
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/Camera.java

@ -64,4 +64,10 @@ public class Camera implements Serializable @@ -64,4 +64,10 @@ public class Camera implements Serializable
private Date updateTime;
private Long platformId;
/** 接入方式 0-4G/5G 1-网络 */
private Long accessType;
/** 摄像机品牌,关联品牌表 */
private Long brand;
}

39
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/CameraBrand.java

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
package com.ruoyi.code.camera.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.ruoyi.common.annotation.Excel;
import java.io.Serializable;
import lombok.Data;
/**
* brand对象 camera_brand
*
* @author ruoyi
* @date 2022-09-26
*/
@Data
@TableName("camera_brand")
public class CameraBrand implements Serializable
{
private static final long serialVersionUID = 1L;
/** id */
@TableId(type = IdType.INPUT)
private Long id;
/** 品牌名称 */
private String name;
/** 品牌型号 */
private String model;
/** rtsp地址 */
private String rtsp;
}

18
ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/CameraBrandMapper.java

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
package com.ruoyi.code.camera.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.ruoyi.code.camera.domain.CameraBrand;
/**
* Mapper接口
*
* @author ruoyi
* @date 2022-09-26
*/
@Mapper
public interface CameraBrandMapper extends BaseMapper<CameraBrand>
{
}

60
ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RtspScreenshotTask.java

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
package com.ruoyi.code.camera.scheduled;
import cn.hutool.core.util.RuntimeUtil;
import com.ruoyi.code.camera.domain.Camera;
import com.ruoyi.code.camera.domain.CameraBrand;
import com.ruoyi.code.camera.service.ICameraBrandService;
import com.ruoyi.code.camera.service.ICameraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Component
@Configuration
@EnableScheduling
public class RtspScreenshotTask {
@Autowired
private ICameraService cameraService;
@Autowired
private ICameraBrandService iCameraBrandService;
@Scheduled(cron = "0 0/5 * * * ?")
// @Scheduled(cron = "0/5 * * * * ?")
public void rtspScreenshot(){
List<String> strList = new ArrayList<>();
String path = "D:" + File.separator + File.separator + "upload" + File.separator;
String ip = "192.168.1.40";
String userName = "admin";
String pwd = "admin123";
String currentDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + File.separator;
String currentTime = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()) + ".jpg";
List<Camera> list = cameraService.list();
for (Camera camera : list) {
CameraBrand cameraBrand = iCameraBrandService.getById(camera.getBrand());
String fileName = path+camera.getDevsn()+File.separator+currentDate;
File file = new File(fileName);
if (!file.exists()) {
file.mkdirs();
}
String ffmpeg =
"ffmpeg -i \"rtsp://"+userName+":"+pwd+"@"+ip+cameraBrand.getRtsp()+"\" -y -f image2 -t 0.001 \""+fileName+currentTime+"\"";
strList.add(ffmpeg);
}
for (String s : strList) {
RuntimeUtil.execForStr(s);
}
}
}

21
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/ICameraBrandService.java

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
package com.ruoyi.code.camera.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.R;
import java.util.Map;
import com.ruoyi.code.camera.domain.CameraBrand;
/**
* Service接口
*
* @author ruoyi
* @date 2022-09-26
*/
public interface ICameraBrandService extends IService<CameraBrand>
{
/**
* 查询
*/
R queryPage(Map<String, Object> params);
}

33
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/CameraBrandServiceImpl.java

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
package com.ruoyi.code.camera.service.impl;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.Query;
import org.springframework.stereotype.Service;
import com.ruoyi.code.camera.mapper.CameraBrandMapper;
import com.ruoyi.code.camera.domain.CameraBrand;
import com.ruoyi.code.camera.service.ICameraBrandService;
/**
* Service业务层处理
*
* @author ruoyi
* @date 2022-09-26
*/
@Service("cameraBrandService")
public class CameraBrandServiceImpl extends ServiceImpl<CameraBrandMapper, CameraBrand> implements ICameraBrandService
{
@Override
public R queryPage(Map<String, Object> params) {
IPage<CameraBrand> page = this.page(
new Query<CameraBrand>().getPage(params),
new QueryWrapper<CameraBrand>()
);
return R.ok().put("count", page.getTotal()).put("data", page.getRecords());
}
}
Loading…
Cancel
Save