Browse Source

时段过程

platform-api
blankk 2 years ago
parent
commit
861b46f9d0
  1. 11
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/WaterPhotoInfoController.java
  2. 13
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/TableData.java
  3. 3
      ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/WaterPhotoInfoMapper.java
  4. 9
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/IWaterPhotoInfoService.java
  5. 57
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/WaterPhotoInfoServiceImpl.java
  6. 20
      ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml

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

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package com.ruoyi.code.camera.controller;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.service.IWaterPhotoInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.R;
@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
@ -42,4 +44,13 @@ public class WaterPhotoInfoController extends BaseController @@ -42,4 +44,13 @@ public class WaterPhotoInfoController extends BaseController
Map<String, Object> map = waterPhotoInfoService.getChart(params);
return R.ok().put("data",map);
}
/**
* 生成表数据
*/
@RequestMapping("/getTableData")
public R getTableData(@RequestParam Map<String, Object> params){
List<TableData> list = waterPhotoInfoService.getTableData(params);
return R.ok().put("data",list);
}
}

13
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/TableData.java

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
package com.ruoyi.code.camera.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TableData {
private String value;
private Object tm;
}

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

@ -3,6 +3,7 @@ package com.ruoyi.code.camera.mapper; @@ -3,6 +3,7 @@ package com.ruoyi.code.camera.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.code.camera.domain.YcData;
import org.apache.ibatis.annotations.Mapper;
@ -25,4 +26,6 @@ public interface WaterPhotoInfoMapper extends BaseMapper<WaterPhotoInfo> @@ -25,4 +26,6 @@ public interface WaterPhotoInfoMapper extends BaseMapper<WaterPhotoInfo>
IPage<WaterPhotoInfo> selectWaterCurrentDataList(Page page, @Param("params") Map<String, Object> params);
List<YcData> selectWaterData(@Param("params") Map<String, Object> params);
List<TableData> selectTableData(@Param("params") Map<String, Object> params);
}

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

@ -1,9 +1,11 @@ @@ -1,9 +1,11 @@
package com.ruoyi.code.camera.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R;
import java.util.List;
import java.util.Map;
/**
@ -20,4 +22,11 @@ public interface IWaterPhotoInfoService extends IService<WaterPhotoInfo> @@ -20,4 +22,11 @@ public interface IWaterPhotoInfoService extends IService<WaterPhotoInfo>
R getScWaterCurrentDataList(Map<String, Object> params);
Map<String, Object> getChart(Map<String, Object> params);
/**
* 生成表格数据
* @param params
* @return
*/
List<TableData> getTableData(Map<String, Object> params);
}

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

@ -3,12 +3,16 @@ package com.ruoyi.code.camera.service.impl; @@ -3,12 +3,16 @@ package com.ruoyi.code.camera.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.camera.domain.ChartData;
import com.ruoyi.code.camera.domain.TableData;
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.service.IWaterPhotoInfoService;
import com.ruoyi.code.sctaationinfo.domain.ScStationInfo;
import com.ruoyi.code.sctaationinfo.service.IScStationInfoService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
@ -24,6 +28,8 @@ import java.util.*; @@ -24,6 +28,8 @@ import java.util.*;
public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper, WaterPhotoInfo> implements IWaterPhotoInfoService
{
@Autowired
private IScStationInfoService scStationInfoService;
@Override
public R queryPage(Map<String, Object> params) {
@ -48,11 +54,21 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper, @@ -48,11 +54,21 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper,
@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<>();
String startTime = (String)params.get("startTime");
String endTime = (String)params.get("endTime");
if(!startTime.contains("-")){
params.put("startTime",formatDate(new Long(startTime)));
params.put("endTime",formatDate(new Long(endTime)));
}
// 获取表名
Integer dataType = Integer.parseInt((String) params.get("dataType"));
String dataTableName = getDataTableName(dataType);
params.put("tableName",dataTableName);
// 图表的数据
ChartData chartData = getChartOptionData(params);
if (chartData != null) {
@ -64,6 +80,43 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper, @@ -64,6 +80,43 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper,
return map;
}
@Override
public List<TableData> getTableData(Map<String, Object> params) {
List<TableData> tableDataList;
// 获取表名
Integer dataType = Integer.parseInt((String) params.get("dataType"));
String dataTableName = getDataTableName(dataType);
params.put("tableName",dataTableName);
// 根据id查询站点信息
Long stnmId = new Long((String)params.get("stnmId"));
ScStationInfo scStationInfo = scStationInfoService.getById(stnmId);
tableDataList = baseMapper.selectTableData(params);
// 去除 T
for (TableData tableData : tableDataList) {
tableData.setTm(tableData.getTm().toString().replace('T', ' '));
}
tableDataList.add(0,new TableData(scStationInfo.getStnm() ,"时间"));
return tableDataList;
}
/**
* 获取表名
* 0 小时 1 -1: 分钟
* @param dataType
* @return
*/
public String getDataTableName(Integer dataType){
if(dataType == 0){
return "sc_water_data_xs";
}else if(dataType == 1){
return "sc_water_data_day";
}else if(dataType == -1){
return "sc_water_data";
}
return "";
}
public String formatDate(Long d){
Date date = new Date(d);
SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

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

@ -46,7 +46,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -46,7 +46,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.value
from
sc_station_info s
left join sc_water_data w on w.stnm_id = s.id
left join ${params.tableName} 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>
<select id="selectTableData" resultType="com.ruoyi.code.camera.domain.TableData">
select
w.tm,
w.value
from
sc_station_info s
left join ${params.tableName} w on w.stnm_id = s.id
<where>
w.stnm_id = #{params.stnmId}
<if test="params.startTime != null">

Loading…
Cancel
Save