Browse Source

大屏接口

platform-api
blank 2 years ago
parent
commit
a3e29d0fbf
  1. 44
      ruoyi-api/src/main/java/com/ruoyi/api/app/DapingController.java
  2. 51
      ruoyi-api/src/main/java/com/ruoyi/api/mapper/DapingMapper.java
  3. 32
      ruoyi-api/src/main/java/com/ruoyi/api/service/DapingService.java
  4. 71
      ruoyi-api/src/main/java/com/ruoyi/api/service/impl/DapingServiceImpl.java
  5. 54
      ruoyi-api/src/main/resources/mapper/api/DapingMapper.xml
  6. 9
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/WaterPhotoInfo.java

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

@ -0,0 +1,44 @@
package com.ruoyi.api.app;
import com.ruoyi.api.service.DapingService;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 大屏的接口
*/
@RestController
@RequestMapping("/daping")
@Slf4j
public class DapingController {
@Autowired
private DapingService dapingService;
@RequestMapping("/station/info")
public List<WaterPhotoInfo> getStationInfo(){
return dapingService.getStationInfo();
}
@RequestMapping("/station/waterLevel")
public List<WaterPhotoInfo> getStationWaterLevel(){
return dapingService.getStationWaterLevel();
}
@RequestMapping("/station/waterLevelTrend")
public R getWaterLevelTrend(){
return dapingService.getWaterLevelTrend();
}
@RequestMapping("/station/status")
public R getStationByStatus(){
return dapingService.getStationByStatus();
}
}

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

@ -0,0 +1,51 @@
package com.ruoyi.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 大屏的接口
*/
@Mapper
public interface DapingMapper extends BaseMapper<WaterPhotoInfo> {
/**
* 大屏查询查询站点信息
* @return
*/
List<WaterPhotoInfo> selectStationInfo();
/**
* 实时水位
* @return
*/
List<WaterPhotoInfo> selectWaterLevel();
/**
* 水位趋势
* @return
*/
List<WaterPhotoInfo> selectWaterLevelTrend(@Param("id") Integer id);
/**
* 查询id
* @return
*/
List<Integer> selectStationInfoId();
/**
* 在线
* @return
*/
Map<String,Object> selectStationByOnlineStatus();
/**
* 不在线
* @return
*/
Map<String,Object> selectStationByOfflineStatus();
}

32
ruoyi-api/src/main/java/com/ruoyi/api/service/DapingService.java

@ -0,0 +1,32 @@
package com.ruoyi.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R;
import java.util.List;
public interface DapingService extends IService<WaterPhotoInfo> {
/**
* 大屏查询查询站点信息
* @return
*/
List<WaterPhotoInfo> getStationInfo();
/**
* 实时水位
* @return
*/
List<WaterPhotoInfo> getStationWaterLevel();
/**
* 水位趋势
* @return
*/
R getWaterLevelTrend();
/**
* 查询状态
* @return
*/
R getStationByStatus();
}

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

@ -0,0 +1,71 @@
package com.ruoyi.api.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.api.mapper.DapingMapper;
import com.ruoyi.api.service.DapingService;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class DapingServiceImpl extends ServiceImpl<DapingMapper, WaterPhotoInfo> implements DapingService{
/**
* 大屏查询查询站点信息
* @return
*/
@Override
public List<WaterPhotoInfo> getStationInfo() {
return baseMapper.selectStationInfo();
}
/**
* 实时水位
* @return
*/
@Override
public List<WaterPhotoInfo> getStationWaterLevel() {
return baseMapper.selectWaterLevel();
}
/**
* 水位趋势
* @return
*/
@Override
public R getWaterLevelTrend() {
Map<String, Object> map = new HashMap<>();
Map<String, Object> valMap = new HashMap<>();
List<String> valueList;
Set<String> tmList = new HashSet<>();
Set<String> stnmList = new HashSet<>();
List<Integer> idList = baseMapper.selectStationInfoId();
for (Integer id : idList) {
List<WaterPhotoInfo> waterPhotoInfos = baseMapper.selectWaterLevelTrend(id);
valueList = new ArrayList<>();
String stnm = "";
for (WaterPhotoInfo waterPhotoInfo : waterPhotoInfos) {
valueList.add(waterPhotoInfo.getValue());
stnmList.add(waterPhotoInfo.getStnm());
stnm = waterPhotoInfo.getStnm();
tmList.add(waterPhotoInfo.getTm());
}
valMap.put(stnm,valueList);
}
map.put("values",valMap);
map.put("tms",tmList);
map.put("stnms",stnmList);
return R.ok().put("map",map);
}
@Override
public R getStationByStatus() {
Map<String, Object> map1 = baseMapper.selectStationByOnlineStatus();
Map<String, Object> map2 = baseMapper.selectStationByOfflineStatus();
List<Map<String, Object>> resultList = new ArrayList<>();
resultList.add(map1);
resultList.add(map2);
return R.ok().put("data",resultList);
}
}

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

@ -0,0 +1,54 @@
<?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.ruoyi.api.mapper.DapingMapper">
<select id="selectStationInfo" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
SELECT
stnm,
longitude,
latitude,
s.id,
create_time,
c.value,
c.img_name
FROM
sc_station_info s
left join sc_water_current_data c on c.stnm_id = s.id
</select>
<select id="selectWaterLevel" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
SELECT
s.id,
s.stnm,
s.camera_sn,
w.value
FROM
sc_station_info s
LEFT JOIN sc_water_current_data w ON w.stnm_id = s.id
</select>
<select id="selectWaterLevelTrend" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
SELECT
s.id,
s.stnm,
w.value,
w.tm
FROM
sc_station_info s
LEFT JOIN sc_water_data w ON w.stnm_id = s.id
WHERE
tm BETWEEN DATE_SUB( NOW(), INTERVAL 12 HOUR )
AND now()
AND RIGHT ( tm, 5 )= '00:00' and s.id=#{id}
ORDER BY
tm
</select>
<select id="selectStationInfoId" resultType="java.lang.Integer">
select id from sc_station_info
</select>
<select id="selectStationByOnlineStatus" resultType="java.util.Map">
select count(1) as value , '在线' as name from camera where status = '1';
</select>
<select id="selectStationByOfflineStatus" resultType="java.util.Map">
select count(1) as value , '不在线' as name from camera where status = '2';
</select>
</mapper>

9
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/WaterPhotoInfo.java

@ -50,4 +50,13 @@ public class WaterPhotoInfo implements Serializable
private String endTime; private String endTime;
/** 经度 */
private String longitude;
/** 纬度 */
private String latitude;
/** 摄像头编号 */
private String cameraSn;
} }

Loading…
Cancel
Save