Browse Source

优化

master
4670101279 2 years ago
parent
commit
7955843341
  1. 7
      ruoyi-admin/src/main/resources/application.yml
  2. 2
      ruoyi-api/src/main/java/com/ruoyi/api/app/DapingController.java
  3. 2
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/DapingMapper.java
  4. 19
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/DapingServiceImpl.java
  5. 28
      ruoyi-api/src/main/resources/mapper/api/DapingMapper.xml
  6. 147
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/ApiController.java

7
ruoyi-admin/src/main/resources/application.yml

@ -129,12 +129,5 @@ xss:
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*
#camera:
# register:
# ip: 192.168.1.11
## ip: 172.17.0.2
# port: 8020
# username: admin
# password: admin123
localip: 172.16.46.58 localip: 172.16.46.58
serverip: 121.40.203.197 serverip: 121.40.203.197

2
ruoyi-api/src/main/java/com/ruoyi/api/app/DapingController.java

@ -14,7 +14,7 @@ import java.util.List;
* 大屏的接口 * 大屏的接口
*/ */
@RestController @RestController
@RequestMapping("/daping") @RequestMapping("/api/daping")
@Slf4j @Slf4j
public class DapingController { public class DapingController {

2
ruoyi-api/src/main/java/com/ruoyi/api/mapper/DapingMapper.java

@ -35,7 +35,7 @@ public interface DapingMapper extends BaseMapper<WaterPhotoInfo> {
* 查询id * 查询id
* @return * @return
*/ */
List<Integer> selectStationInfoId(); List<Map<String,Object>> selectStationInfoId();
/** /**
* 在线 * 在线

19
ruoyi-api/src/main/java/com/ruoyi/api/service/impl/DapingServiceImpl.java

@ -37,25 +37,26 @@ public class DapingServiceImpl extends ServiceImpl<DapingMapper, WaterPhotoInfo>
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Map<String, Object> valMap; Map<String, Object> valMap;
List<String> valueList; List<String> valueList;
Set<String> tmList = new HashSet<>(); List<String> tmList = new ArrayList<>();
Set<String> stnmList = new HashSet<>(); List<String> stnmList = new ArrayList<>();
List<Map<String, Object>> valuesList = new ArrayList<>(); List<Map<String, Object>> valuesList = new ArrayList<>();
List<Integer> idList = baseMapper.selectStationInfoId(); List<Map<String,Object>> stList = baseMapper.selectStationInfoId();
for (Integer id : idList) { for (Map<String,Object> m : stList) {
List<WaterPhotoInfo> waterPhotoInfos = baseMapper.selectWaterLevelTrend(id); List<WaterPhotoInfo> waterPhotoInfos = baseMapper.selectWaterLevelTrend(Integer.parseInt(m.get("id").toString()));
if (waterPhotoInfos.size()==0){ if (waterPhotoInfos.size()==0){
break; break;
} }
valueList = new ArrayList<>(); valueList = new ArrayList<>();
valMap = new HashMap<>(); valMap = new HashMap<>();
String name = "";
for (WaterPhotoInfo waterPhotoInfo : waterPhotoInfos) { for (WaterPhotoInfo waterPhotoInfo : waterPhotoInfos) {
name = waterPhotoInfo.getStnm();
valueList.add(waterPhotoInfo.getValue()); valueList.add(waterPhotoInfo.getValue());
stnmList.add(waterPhotoInfo.getStnm()); if(!tmList.contains(waterPhotoInfo.getTm())){
tmList.add(waterPhotoInfo.getTm()); tmList.add(waterPhotoInfo.getTm());
} }
valMap.put("stnm",name); }
stnmList.add(m.get("stnm").toString());
valMap.put("stnm",m.get("stnm").toString());
valMap.put("value",valueList); valMap.put("value",valueList);
valuesList.add(valMap); valuesList.add(valMap);
} }

28
ruoyi-api/src/main/resources/mapper/api/DapingMapper.xml

@ -9,7 +9,7 @@
longitude, longitude,
latitude, latitude,
s.id, s.id,
create_time as start_time, c.tm as start_time,
c.value, c.value,
c.img_name, c.img_name,
s.camera_sn s.camera_sn
@ -28,6 +28,21 @@
LEFT JOIN sc_water_current_data w ON w.stnm_id = s.id LEFT JOIN sc_water_current_data w ON w.stnm_id = s.id
</select> </select>
<select id="selectWaterLevelTrend" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo"> <select id="selectWaterLevelTrend" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
select tms.tm,d.id, d.stnm, ifnull(d.value,0) value
from (
select date_format( DATE_SUB( NOW(), INTERVAL 11 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 10 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 9 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 8 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 7 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 6 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 5 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 4 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 3 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 2 HOUR ) , '%Y-%m-%d %H:00:00') tm union all
select date_format( DATE_SUB( NOW(), INTERVAL 1 HOUR ) , '%Y-%m-%d %H:00:00') tm
) tms
left join (
SELECT SELECT
s.id, s.id,
s.stnm, s.stnm,
@ -38,13 +53,14 @@
LEFT JOIN sc_water_data w ON w.stnm_id = s.id LEFT JOIN sc_water_data w ON w.stnm_id = s.id
WHERE WHERE
tm BETWEEN DATE_SUB( NOW(), INTERVAL 12 HOUR ) tm BETWEEN DATE_SUB( NOW(), INTERVAL 12 HOUR )
AND now() AND DATE_SUB( NOW(), INTERVAL 1 HOUR )
AND RIGHT ( tm, 5 )= '00:00' and s.id= #{id} AND RIGHT ( tm, 5 )= '00:00' and s.id= #{id}
ORDER BY
tm ) d on tms.tm = d.tm
ORDER BY tms.tm
</select> </select>
<select id="selectStationInfoId" resultType="java.lang.Integer"> <select id="selectStationInfoId" resultType="java.util.Map">
select id from sc_station_info select id,stnm from sc_station_info
</select> </select>
<select id="selectStationByOnlineStatus" resultType="java.util.Map"> <select id="selectStationByOnlineStatus" resultType="java.util.Map">
select count(1) as value , '在线' as name from camera where status = '1'; select count(1) as value , '在线' as name from camera where status = '1';

147
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/ApiController.java

@ -2,6 +2,7 @@ package com.ruoyi.code.camera.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.code.camera.domain.Camera; import com.ruoyi.code.camera.domain.Camera;
import com.ruoyi.code.camera.domain.LogInfo;
import com.ruoyi.code.camera.service.ICameraService; import com.ruoyi.code.camera.service.ICameraService;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -12,15 +13,16 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.sun.jna.NativeLong; import com.sun.jna.NativeLong;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import sdk.java.lib.netmanager.NetEnums;
import sdk.java.lib.netmanager.NetStructs;
import utils.CameraUtil; import utils.CameraUtil;
import utils.RegisterUtil; import utils.RegisterUtil;
import utils.run_device_cfg;
import utils.run_device_log_search;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
/** /**
* 摄像机Controller * 摄像机Controller
@ -48,4 +50,141 @@ public class ApiController extends BaseController
return R.ok(); return R.ok();
} }
/**
* 重启注册服务
*/
@RequestMapping("register")
public R register(){
return cameraService.register();
}
/**
* 清空所有摄像机状态
*/
@RequestMapping("outLine")
public R outLine(){
return cameraService.outLine();
}
/**
* 重启摄像机
*/
@RequestMapping("reboot/{id}")
public R reboot(@PathVariable("id") Long id){
Camera c = cameraService.getById(id);
return cameraService.rebootByLoginId(c);
}
/**
* 刷新4G信号强度
*/
@RequestMapping("/refreshRssi/{id}")
public R refreshRssiLevel(@PathVariable("id") Long id){
Camera c = cameraService.getById(id);
if(c.getStatus() == 0 || StringUtils.isBlank(c.getLoginId())){
return R.error("设备未在线");
}
int level = CameraUtil.get4gRssiLevel(new NativeLong(Long.parseLong(c.getLoginId())));
c.setRssiLevel(level);
cameraService.updateById(c);
return R.ok();
}
/**
* 查询摄像头重启数据
*/
@RequestMapping("/getautocfg/{id}")
public R getAutoCfg(@PathVariable("id") Long id){
int nCommand = NetEnums.EM_DEVICE_CFG_TYPE.DEVICE_CFG_AUTO_MAINTAIN;
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
// Object data = JSON.toJSON(cfg.getAutoCfg(new NativeLong(Long.parseLong(camera.getLoginId())),nCommand)).toString();
NetStructs.STU_CFG_AUTO_MAINTAIN cc = cfg.getAutoCfg(new NativeLong(Long.parseLong(camera.getLoginId())),nCommand);
Map<String,Object> data = new HashMap<>();
data.put("bEnable",cc.bEnable);
data.put("uWeekDay",cc.uWeekDay);
data.put("uHour",cc.uHour);
return R.ok().put("data", data);
}
/**
* 设置摄像头重启
*/
@RequestMapping("/setautocfg")
public R setAutoCfg(@RequestBody Map<String, Object> params){
int id = (Integer) params.get("id");
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
return cfg.setAutoFtpCfg(new NativeLong(Long.parseLong(camera.getLoginId())),
Integer.parseInt(params.get("bEnable").toString()),
Integer.parseInt(params.get("uHour").toString()),
Integer.parseInt(params.get("uWeekDay").toString()));
}
/**
* 获取日志
*/
@RequestMapping("/getloginfo")
public R getloginfo(@RequestParam Map<String, Object> params){
String id = (String) params.get("id");
String startTime = (String) params.get("startTime");
String endTime = (String) params.get("endTime");
Camera camera = cameraService.getById(id);
run_device_log_search logSearch = new run_device_log_search();
List<LogInfo> data = logSearch.logInfoSearchByTime(new NativeLong(Long.parseLong(camera.getLoginId())), startTime, endTime);
return R.ok().put("data",data);
}
/**
* 获取补光灯配置
*/
@RequestMapping("/getLigntCfg/{id}")
public R getLigntCfg(@PathVariable("id") Long id){
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
NativeLong loginID = new NativeLong(Long.parseLong(camera.getLoginId()));
Map<String,Object> map = cfg.getLigntCfg(loginID);
return R.ok().put("data",map);
}
/**
* 修改补光灯配置
*/
@RequestMapping("/setLightCfg")
public R setLightCfg(@RequestBody Map<String,Object> params){
Integer id = (Integer) params.get("id");
Integer emMode = Integer.parseInt((String) params.get("emMode"));
Integer nPreValue = (Integer) params.get("nPreValue");
Integer nBrightness = (Integer) params.get("nBrightness");
String startTime1 = (String) params.get("startTime1");
String startTime2 = (String) params.get("startTime2");
String endTime1 = (String) params.get("endTime1");
String endTime2 = (String) params.get("endTime2");
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
NativeLong nativeID = new NativeLong(Long.parseLong(camera.getLoginId()));
boolean flag = cfg.setLightCfg(nativeID, emMode, nPreValue, nBrightness, startTime1, endTime1, startTime2, endTime2);
if (flag){
return R.ok();
}
return R.error();
}
/**
* 校准时间
*/
@RequestMapping("/setNowTime/{id}")
public R setNowTime(@PathVariable("id")Long id){
Camera camera = cameraService.getById(id);
CameraUtil.setNowTime(new NativeLong(Long.parseLong(camera.getLoginId())));
return R.ok();
}
} }

Loading…
Cancel
Save