6a6f6fb0 康伟

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

1 个父辈 280a35af
...@@ -15,6 +15,25 @@ import java.util.regex.Pattern; ...@@ -15,6 +15,25 @@ import java.util.regex.Pattern;
15 15
16 public class BaseUtil { 16 public class BaseUtil {
17 17
18
19 /***
20 * 计算时间的前几个月的月份
21 * @param month
22 * @param time
23 * @return
24 */
25 public static String getMonthBytime(int month,String time) {
26 SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
27 Calendar calendar = Calendar.getInstance();
28 try {
29 calendar.setTime(format.parse(time));
30 } catch (ParseException e) {
31 e.printStackTrace();
32 }
33 calendar.add(Calendar.MONTH, month);
34 return format.format(calendar.getTime());
35 }
36
18 public static String dateformat(String date, String format) { 37 public static String dateformat(String date, String format) {
19 SimpleDateFormat sformat = new SimpleDateFormat(format); 38 SimpleDateFormat sformat = new SimpleDateFormat(format);
20 Date _date = null; 39 Date _date = null;
......
...@@ -46,9 +46,9 @@ public class JTDisplayScreenController { ...@@ -46,9 +46,9 @@ public class JTDisplayScreenController {
46 @AutoLog(value = "水量趋势") 46 @AutoLog(value = "水量趋势")
47 @ApiOperation(value = "水量趋势", notes = "水量趋势") 47 @ApiOperation(value = "水量趋势", notes = "水量趋势")
48 @GetMapping("/waterTrend") 48 @GetMapping("/waterTrend")
49 public Result<List<WaterTrendVO>> waterTrend(String departId, String startTime, String endTime){ 49 public Result<List<WaterTrendVO>> waterTrend(String departId, String time ){
50 Result<List<WaterTrendVO>> result = new Result<>(); 50 Result<List<WaterTrendVO>> result = new Result<>();
51 List<WaterTrendVO> list = displayScreenService.queryWaterTrend(departId ,startTime ,endTime); 51 List<WaterTrendVO> list = displayScreenService.queryWaterTrend(departId ,time );
52 result.setResult(list); 52 result.setResult(list);
53 return result; 53 return result;
54 } 54 }
...@@ -64,9 +64,9 @@ public class JTDisplayScreenController { ...@@ -64,9 +64,9 @@ public class JTDisplayScreenController {
64 @AutoLog(value = "水质水量:右侧图表") 64 @AutoLog(value = "水质水量:右侧图表")
65 @ApiOperation(value = "水质水量:右侧图表", notes = "水质水量:右侧图表") 65 @ApiOperation(value = "水质水量:右侧图表", notes = "水质水量:右侧图表")
66 @GetMapping("/waterQualityCchart") 66 @GetMapping("/waterQualityCchart")
67 public Result<List<WaterQualityChartVO>> waterQualityCchart(String departId, String startTime, String endTime){ 67 public Result<List<WaterQualityChartVO>> waterQualityCchart(String departId, String time ){
68 Result<List<WaterQualityChartVO>> result = new Result<>(); 68 Result<List<WaterQualityChartVO>> result = new Result<>();
69 List<WaterQualityChartVO> waterTrendVOList = displayScreenService.queryWaterQualityChart(departId ,startTime ,endTime); 69 List<WaterQualityChartVO> waterTrendVOList = displayScreenService.queryWaterQualityChart(departId ,time);
70 result.setResult(waterTrendVOList); 70 result.setResult(waterTrendVOList);
71 return result; 71 return result;
72 } 72 }
......
...@@ -27,11 +27,9 @@ public interface IJTDisplayScreenService { ...@@ -27,11 +27,9 @@ public interface IJTDisplayScreenService {
27 /*** 27 /***
28 * 水量趋势 28 * 水量趋势
29 * @param departId 29 * @param departId
30 * @param startTime
31 * @param endTime
32 * @return 30 * @return
33 */ 31 */
34 List<WaterTrendVO> queryWaterTrend(String departId, String startTime, String endTime); 32 List<WaterTrendVO> queryWaterTrend(String departId, String time);
35 33
36 /*** 34 /***
37 * 水质水量数据 35 * 水质水量数据
...@@ -44,11 +42,9 @@ public interface IJTDisplayScreenService { ...@@ -44,11 +42,9 @@ public interface IJTDisplayScreenService {
44 /*** 42 /***
45 * 水质水量图标数据 43 * 水质水量图标数据
46 * @param departId 44 * @param departId
47 * @param startTime
48 * @param endTime
49 * @return 45 * @return
50 */ 46 */
51 List<WaterQualityChartVO> queryWaterQualityChart(String departId, String startTime, String endTime); 47 List<WaterQualityChartVO> queryWaterQualityChart(String departId, String time );
52 48
53 /*** 49 /***
54 * 生态效益 50 * 生态效益
......
...@@ -4,8 +4,10 @@ import com.skua.common.report.ReportViewUtil; ...@@ -4,8 +4,10 @@ import com.skua.common.report.ReportViewUtil;
4 import com.skua.core.context.SpringContextUtils; 4 import com.skua.core.context.SpringContextUtils;
5 5
6 import com.skua.core.util.ConvertUtils; 6 import com.skua.core.util.ConvertUtils;
7 import com.skua.core.util.DateUtils;
7 import com.skua.modules.common.vo.DateVO; 8 import com.skua.modules.common.vo.DateVO;
8 import com.skua.modules.guest.util.DateUtil; 9 import com.skua.modules.guest.util.DateUtil;
10 import com.skua.modules.quartz.util.BaseUtil;
9 import com.skua.modules.threedimensional.service.IJTDisplayScreenService; 11 import com.skua.modules.threedimensional.service.IJTDisplayScreenService;
10 import com.skua.modules.threedimensional.vo.*; 12 import com.skua.modules.threedimensional.vo.*;
11 import com.skua.tool.util.DigitalUtils; 13 import com.skua.tool.util.DigitalUtils;
...@@ -14,10 +16,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper; ...@@ -14,10 +16,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
14 import org.springframework.jdbc.core.JdbcTemplate; 16 import org.springframework.jdbc.core.JdbcTemplate;
15 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
16 18
17 import java.util.ArrayList; 19 import java.util.*;
18 import java.util.HashMap;
19 import java.util.List;
20 import java.util.Map;
21 20
22 21
23 /** 22 /**
...@@ -148,17 +147,21 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -148,17 +147,21 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
148 /*** 147 /***
149 * 水量趋势 148 * 水量趋势
150 * @param departId 149 * @param departId
151 * @param startTime
152 * @param endTime
153 * @return 150 * @return
154 */ 151 */
155 public List<WaterTrendVO> queryWaterTrend(String departId, String startTime, String endTime){ 152 public List<WaterTrendVO> queryWaterTrend(String departId, String time ){
153 if(time == null ){
154 time = DateUtils.format(new Date(),"yyyy-MM");
155 }
156 //查询当前时间往前推12个月的数据
157 String startTime= BaseUtil.getMonthBytime(-6,time)+"-01";
158 String endTime=BaseUtil.getMonthBytime(-1,time)+"-31";
156 //月产水量 159 //月产水量
157 String dataViewName2119 = ReportViewUtil.buildView(view2119,"CSL,JSL", null, startTime,endTime); 160 String dataViewName2119 = ReportViewUtil.buildView(view2119,"CSL,JSL", null, startTime,endTime);
158 //System.out.println("dataViewName2119 ="+dataViewName2119); 161 //System.out.println("dataViewName2119 ="+dataViewName2119);
159 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 "); 162 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 ");
160 sql.append( dataViewName2119 ); 163 sql.append( dataViewName2119 );
161 sql.append( " bbb group by date_format(bbb.time,'%Y-%m') ORDER BY time"); 164 sql.append( " bbb group by date_format(bbb.time,'%Y-%m') ORDER BY bbb.time");
162 165
163 List<WaterTrendVO> waterTrendList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterTrendVO>(WaterTrendVO.class)); 166 List<WaterTrendVO> waterTrendList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterTrendVO>(WaterTrendVO.class));
164 167
...@@ -192,18 +195,22 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -192,18 +195,22 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
192 /*** 195 /***
193 * 水质水量图标数据 196 * 水质水量图标数据
194 * @param departId 197 * @param departId
195 * @param startTime
196 * @param endTime
197 * @return 198 * @return
198 */ 199 */
199 public List<WaterQualityChartVO> queryWaterQualityChart(String departId, String startTime, String endTime){ 200 public List<WaterQualityChartVO> queryWaterQualityChart(String departId, String time){
201 if(time == null ){
202 time = DateUtils.format(new Date(),"yyyy-MM");
203 }
204 //查询当前时间往前推12个月的数据
205 String startTime= BaseUtil.getMonthBytime(-12,time)+"-01";
206 String endTime=BaseUtil.getMonthBytime(-1,time)+"-31";
200 //CSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD 207 //CSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD
201 String dataViewName2119 = ReportViewUtil.buildView(view2119,"JSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD", departId, startTime,endTime); 208 String dataViewName2119 = ReportViewUtil.buildView(view2119,"JSL,JSCOD,CSCOD,JSZL,CSZL,JSZD,CSTN,JSAD,CSAD", departId, startTime,endTime);
202 System.out.println("dataViewName2119 ="+dataViewName2119); 209 System.out.println("dataViewName2119 ="+dataViewName2119);
203 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', "); 210 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', ");
204 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 "); 211 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 ");
205 sql.append(" "+dataViewName2119 +" aaa "); 212 sql.append(" "+dataViewName2119 +" aaa ");
206 sql.append(" GROUP BY date_format(time, '%Y-%m') order by time "); 213 sql.append(" GROUP BY date_format(aaa.time, '%Y-%m') order by aaa.time ");
207 List<WaterQualityChartVO> waterQualityChartVOList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterQualityChartVO>(WaterQualityChartVO.class)); 214 List<WaterQualityChartVO> waterQualityChartVOList = getJdbcTemplate().query(sql.toString(),new BeanPropertyRowMapper<WaterQualityChartVO>(WaterQualityChartVO.class));
208 215
209 return waterQualityChartVOList; 216 return waterQualityChartVOList;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!