@ -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" ) ;