Browse Source

测站水位数据详情

platform-api
blankk 2 years ago
parent
commit
2381fc0029
  1. 23
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/WaterPhotoInfoController.java
  2. 38
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/ChartData.java
  3. 4
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/WaterPhotoInfo.java
  4. 30
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/YcData.java
  5. 6
      ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/WaterPhotoInfoMapper.java
  6. 9
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/IWaterPhotoInfoService.java
  7. 65
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/WaterPhotoInfoServiceImpl.java
  8. 43
      ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml

23
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/WaterPhotoInfoController.java

@ -1,20 +1,14 @@
package com.ruoyi.code.camera.controller; package com.ruoyi.code.camera.controller;
import com.ruoyi.code.camera.service.IWaterPhotoInfoService; import com.ruoyi.code.camera.service.IWaterPhotoInfoService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -37,4 +31,15 @@ public class WaterPhotoInfoController extends BaseController
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestParam Map<String, Object> params){
return waterPhotoInfoService.queryPage(params); return waterPhotoInfoService.queryPage(params);
} }
@RequestMapping("/getScWaterCurrentDataList")
public R getScWaterCurrentDataList(@RequestParam Map<String, Object> params){
return waterPhotoInfoService.getScWaterCurrentDataList(params);
}
@RequestMapping("/getChart")
public R getChart(@RequestParam Map<String, Object> params){
Map<String, Object> map = waterPhotoInfoService.getChart(params);
return R.ok().put("data",map);
}
} }

38
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/ChartData.java

@ -0,0 +1,38 @@
package com.ruoyi.code.camera.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ChartData implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private Integer stnmId;
private String type;
private String barMaxWidth = "20";
private boolean smooth = false;
private String symbol = "none";
private List<Object> data;
public ChartData(Integer id, String name, Integer stnmId, String type, List<Object> data) {
this.id = id;
this.name = name;
this.stnmId = stnmId;
this.type = type;
this.data = data;
}
public ChartData() {
}
}

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

@ -3,11 +3,9 @@ package com.ruoyi.code.camera.domain;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
@ -43,7 +41,7 @@ public class WaterPhotoInfo implements Serializable
private String imgName; private String imgName;
/** 水位计名称*/ /** 水位计名称*/
private String name; private String stcd;
/** 起始时间*/ /** 起始时间*/
private String startTime; private String startTime;

30
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/YcData.java

@ -0,0 +1,30 @@
package com.ruoyi.code.camera.domain;
import lombok.Data;
import java.io.Serializable;
@Data
public class YcData implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String stnm;
private String stcd;
private Integer stnmId;
private String tm;
private Long clock;
private String status;
private Integer modNum;
private Double value;
private String dtmnm;
}

6
ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/WaterPhotoInfoMapper.java

@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.code.camera.domain.YcData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -19,4 +21,8 @@ import java.util.Map;
public interface WaterPhotoInfoMapper extends BaseMapper<WaterPhotoInfo> public interface WaterPhotoInfoMapper extends BaseMapper<WaterPhotoInfo>
{ {
IPage<WaterPhotoInfo> queryPhotoList(Page page, @Param("params") Map<String, Object> params); IPage<WaterPhotoInfo> queryPhotoList(Page page, @Param("params") Map<String, Object> params);
IPage<WaterPhotoInfo> selectWaterCurrentDataList(Page page, @Param("params") Map<String, Object> params);
List<YcData> selectWaterData(@Param("params") Map<String, Object> params);
} }

9
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/IWaterPhotoInfoService.java

@ -1,15 +1,9 @@
package com.ruoyi.code.camera.service; package com.ruoyi.code.camera.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -23,4 +17,7 @@ public interface IWaterPhotoInfoService extends IService<WaterPhotoInfo>
R queryPage(Map<String, Object> params); R queryPage(Map<String, Object> params);
R getScWaterCurrentDataList(Map<String, Object> params);
Map<String, Object> getChart(Map<String, Object> params);
} }

65
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/WaterPhotoInfoServiceImpl.java

@ -1,21 +1,18 @@
package com.ruoyi.code.camera.service.impl; package com.ruoyi.code.camera.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.camera.domain.ChartData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.code.camera.domain.YcData;
import com.ruoyi.code.camera.mapper.WaterPhotoInfoMapper; import com.ruoyi.code.camera.mapper.WaterPhotoInfoMapper;
import com.ruoyi.code.camera.service.IWaterPhotoInfoService; import com.ruoyi.code.camera.service.IWaterPhotoInfoService;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.Query; import com.ruoyi.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collection; import java.text.SimpleDateFormat;
import java.util.Map; import java.util.*;
import java.util.function.Function;
/** /**
* Service业务层处理 * Service业务层处理
@ -39,4 +36,58 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper,
return R.ok().put("count", page.getTotal()).put("data", page.getRecords()); return R.ok().put("count", page.getTotal()).put("data", page.getRecords());
} }
@Override
public R getScWaterCurrentDataList(Map<String, Object> params) {
IPage<WaterPhotoInfo> page = baseMapper.selectWaterCurrentDataList(
new Query<WaterPhotoInfo>().getPage(params),
params
);
return R.ok().put("count", page.getTotal()).put("data", page.getRecords());
}
@Override
public Map<String, Object> getChart(Map<String, Object> params) {
params.put("startTime",formatDate(new Long((String) params.get("startTime"))));
params.put("endTime",formatDate(new Long((String) params.get("endTime"))));
Map<String, Object> map = new HashMap<>();
List<String> legend = new ArrayList<>();
List<ChartData> series = new ArrayList<>();
// 图表的数据
ChartData chartData = getChartOptionData(params);
if (chartData != null) {
series.add(chartData);
legend.add(chartData.getName());
}
map.put("legend",legend);
map.put("series",series);
return map;
}
public String formatDate(Long d){
Date date = new Date(d);
SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sm.format(date);
}
public ChartData getChartOptionData(Map<String, Object> params){
ChartData data = null;
List<YcData> dataList = baseMapper.selectWaterData(params);
if(dataList != null && dataList.size()>0){
data = new ChartData();
data.setId(dataList.get(0).getId());
data.setStnmId(dataList.get(0).getStnmId());
data.setName(dataList.get(0).getStnm());
data.setType("line");
data.setData(formatChartData(dataList));
}
return data;
}
public List<Object> formatChartData(List<YcData> dataList){
List<Object> objs = new ArrayList<>();
for (int j = 0 ; j< dataList.size() ; j++){
objs.add(new Object[]{dataList.get(j).getClock()*1000,dataList.get(j).getValue()});
}
return objs;
}
} }

43
ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml

@ -12,11 +12,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join camera c on s.camera_sn = c.devsn left join camera c on s.camera_sn = c.devsn
left join sc_water_data w on s.id = w.stnm_id left join sc_water_data w on s.id = w.stnm_id
<where>
<if test="params.stnm !=null and params.stnm !=''">and s.stnm like concat('%',#{params.stnm},'%')</if> <if test="params.stnm !=null and params.stnm !=''">and s.stnm like concat('%',#{params.stnm},'%')</if>
<if test="params.name !=null and params.name !=''">and c.name like concat('%',#{params.name},'%')</if> <if test="params.stcd !=null and params.stcd !=''">and c.name like concat('%',#{params.name},'%')</if>
<if test="params.startTime != null and params.startTime !=''"> and w.tm &gt;= #{params.startTime }</if> <if test="params.startTime != null and params.startTime !=''"> and w.tm &gt;= #{params.startTime }</if>
<if test="params.endTime != null and params.endTime !=''"> and w.tm &lt;= #{params.endTime}</if> <if test="params.endTime != null and params.endTime !=''"> and w.tm &lt;= #{params.endTime}</if>
</where>
</select> </select>
<select id="selectWaterCurrentDataList" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
select
w.stnm_id id,
s.stnm,
c.name stcd,
w.tm,
w.value
from
sc_station_info s
left join sc_water_current_data w on w.stnm_id = s.id
left join camera c on c.devsn = s.camera_sn
<where>
<if test="params.stnm !=null and params.stnm !=''">and s.stnm like concat('%',#{params.stnm},'%')</if>
<if test="params.stcd !=null and params.stcd !=''">and c.name like concat('%',#{params.name},'%')</if>
</where>
</select>
<select id="selectWaterData" resultType="com.ruoyi.code.camera.domain.YcData">
select
s.id stnmId,
s.stnm,
w.tm,
unix_timestamp(w.tm) clock,
w.value
from
sc_station_info s
left join sc_water_data w on w.stnm_id = s.id
<where>
w.stnm_id = #{params.stnmId}
<if test="params.startTime != null">
and w.tm>=#{params.startTime}
</if>
<if test="params.endTime != null">
and w.tm &lt;=#{params.endTime}
</if>
</where>
order by w.tm
</select>
</mapper> </mapper>

Loading…
Cancel
Save