6a6f6fb0 康伟

kangwei :对外集团大屏数据接口

1 个父辈 280a35af
......@@ -15,6 +15,25 @@ import java.util.regex.Pattern;
public class BaseUtil {
/***
* 计算时间的前几个月的月份
* @param month
* @param time
* @return
*/
public static String getMonthBytime(int month,String time) {
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(format.parse(time));
} catch (ParseException e) {
e.printStackTrace();
}
calendar.add(Calendar.MONTH, month);
return format.format(calendar.getTime());
}
public static String dateformat(String date, String format) {
SimpleDateFormat sformat = new SimpleDateFormat(format);
Date _date = null;
......
......@@ -46,9 +46,9 @@ public class JTDisplayScreenController {
@AutoLog(value = "水量趋势")
@ApiOperation(value = "水量趋势", notes = "水量趋势")
@GetMapping("/waterTrend")
public Result<List<WaterTrendVO>> waterTrend(String departId, String startTime, String endTime){
public Result<List<WaterTrendVO>> waterTrend(String departId, String time ){
Result<List<WaterTrendVO>> result = new Result<>();
List<WaterTrendVO> list = displayScreenService.queryWaterTrend(departId ,startTime ,endTime);
List<WaterTrendVO> list = displayScreenService.queryWaterTrend(departId ,time );
result.setResult(list);
return result;
}
......@@ -64,9 +64,9 @@ public class JTDisplayScreenController {
@AutoLog(value = "水质水量:右侧图表")
@ApiOperation(value = "水质水量:右侧图表", notes = "水质水量:右侧图表")
@GetMapping("/waterQualityCchart")
public Result<List<WaterQualityChartVO>> waterQualityCchart(String departId, String startTime, String endTime){
public Result<List<WaterQualityChartVO>> waterQualityCchart(String departId, String time ){
Result<List<WaterQualityChartVO>> result = new Result<>();
List<WaterQualityChartVO> waterTrendVOList = displayScreenService.queryWaterQualityChart(departId ,startTime ,endTime);
List<WaterQualityChartVO> waterTrendVOList = displayScreenService.queryWaterQualityChart(departId ,time);
result.setResult(waterTrendVOList);
return result;
}
......
......@@ -27,11 +27,9 @@ public interface IJTDisplayScreenService {
/***
* 水量趋势
* @param departId
* @param startTime
* @param endTime
* @return
*/
List<WaterTrendVO> queryWaterTrend(String departId, String startTime, String endTime);
List<WaterTrendVO> queryWaterTrend(String departId, String time);
/***
* 水质水量数据
......@@ -44,11 +42,9 @@ public interface IJTDisplayScreenService {
/***
* 水质水量图标数据
* @param departId
* @param startTime
* @param endTime
* @return
*/
List<WaterQualityChartVO> queryWaterQualityChart(String departId, String startTime, String endTime);
List<WaterQualityChartVO> queryWaterQualityChart(String departId, String time );
/***
* 生态效益
......
......@@ -4,8 +4,10 @@ import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.common.vo.DateVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.threedimensional.service.IJTDisplayScreenService;
import com.skua.modules.threedimensional.vo.*;
import com.skua.tool.util.DigitalUtils;
......@@ -14,10 +16,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
......@@ -148,17 +147,21 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
/***
* 水量趋势
* @param departId
* @param startTime
* @param endTime
* @return
*/
public List<WaterTrendVO> queryWaterTrend(String departId, String startTime, String endTime){
public List<WaterTrendVO> queryWaterTrend(String departId, String time ){
if(time == null ){
time = DateUtils.format(new Date(),"yyyy-MM");
}
//查询当前时间往前推12个月的数据
String startTime= BaseUtil.getMonthBytime(-6,time)+"-01";
String endTime=BaseUtil.getMonthBytime(-1,time)+"-31";
//月产水量
String dataViewName2119 = ReportViewUtil.buildView(view2119,"CSL,JSL", null, startTime,endTime);
//System.out.println("dataViewName2119 ="+dataViewName2119);
StringBuffer sql = new StringBuffer("select date_format(bbb.time,'%Y-%m') 'time' ,round(sum(bbb.JSL),2) 'jsl',round(sum(bbb.CSL)',2) csl' from ");
StringBuffer sql = new StringBuffer("select date_format(bbb.time,'%Y-%m') 'time' ,round(sum(bbb.JSL),2) 'jsl',round(sum(bbb.CSL),2) 'csl' from ");
sql.append( dataViewName2119 );
sql.append( " bbb group by date_format(bbb.time,'%Y-%m') ORDER BY time");
sql.append( " bbb group by date_format(bbb.time,'%Y-%m') ORDER BY bbb.time");
List<WaterTrendVO> waterTrendList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterTrendVO>(WaterTrendVO.class));
......@@ -192,18 +195,22 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
/***
* 水质水量图标数据
* @param departId
* @param startTime
* @param endTime
* @return
*/
public List<WaterQualityChartVO> queryWaterQualityChart(String departId, String startTime, String endTime){
public List<WaterQualityChartVO> queryWaterQualityChart(String departId, String time){
if(time == null ){
time = DateUtils.format(new Date(),"yyyy-MM");
}
//查询当前时间往前推12个月的数据
String startTime= BaseUtil.getMonthBytime(-12,time)+"-01";
String endTime=BaseUtil.getMonthBytime(-1,time)+"-31";
//CSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD
String dataViewName2119 = ReportViewUtil.buildView(view2119,"JSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD", departId, startTime,endTime);
System.out.println("dataViewName2119 ="+dataViewName2119);
StringBuffer sql = new StringBuffer("select date_format(time, '%Y-%m') 'time' , round(sum(aaa.CSL),2) 'jsl',round(sum( aaa.JSCOD -aaa.CSCOD ),2) 'cod', ");
StringBuffer sql = new StringBuffer("select date_format(aaa.time, '%Y-%m') 'time' , round(sum(aaa.JSL),2) 'jsl',round(sum( aaa.JSCOD -aaa.CSCOD ),2) 'cod', ");
sql.append(" round(sum( aaa.JSZL -aaa.CSZL ),2) 'tp', round(sum( aaa.JSZD -aaa.CSTN ),2) 'tn',round(sum( aaa.JSAD -aaa.CSAD ),2) 'nh3n' from ");
sql.append(" "+dataViewName2119 +" aaa ");
sql.append(" GROUP BY date_format(time, '%Y-%m') order by time ");
sql.append(" GROUP BY date_format(aaa.time, '%Y-%m') order by aaa.time ");
List<WaterQualityChartVO> waterQualityChartVOList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterQualityChartVO>(WaterQualityChartVO.class));
return waterQualityChartVOList;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!