f8d3f276 张雷

奥体项目接口修改

1 个父辈 035378aa
...@@ -261,4 +261,26 @@ public class OlympicCenterController { ...@@ -261,4 +261,26 @@ public class OlympicCenterController {
261 result.setSuccess(true); 261 result.setSuccess(true);
262 return result; 262 return result;
263 } 263 }
264
265 @ApiOperation(value="获取相同月份的累计流量数据", notes="获取相同月份的累计流量数据")
266 @GetMapping(value = "/getYearMonthSumFlow")
267 public Result<Map<String,Object>> getYearMonthSumFlow(SumFlowParams sumFlowParams){
268 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
269 Map<String,Object> map = new HashMap<>();
270 map = olympicCenterService.getYearMonthSumFlow(sumFlowParams);
271 result.setResult(map);
272 result.setSuccess(true);
273 return result;
274 }
275
276 @ApiOperation(value="获取年度的累计流量数据", notes="获取年度的累计流量数据")
277 @GetMapping(value = "/getYearSumFlow")
278 public Result<Map<String,Object>> getYearSumFlow(SumFlowParams sumFlowParams){
279 Result<Map<String,Object>> result = new Result<Map<String,Object>>();
280 Map<String,Object> map = new HashMap<>();
281 map = olympicCenterService.getYearSumFlow(sumFlowParams);
282 result.setResult(map);
283 result.setSuccess(true);
284 return result;
285 }
264 } 286 }
......
...@@ -49,4 +49,8 @@ public interface IOlympicCenterService { ...@@ -49,4 +49,8 @@ public interface IOlympicCenterService {
49 List<Map<String, Object>> getAlarmList(AlarmParams alarmParams); 49 List<Map<String, Object>> getAlarmList(AlarmParams alarmParams);
50 50
51 Map<String, Object> getSumFlowData(SumFlowParams sumFlowParams); 51 Map<String, Object> getSumFlowData(SumFlowParams sumFlowParams);
52
53 Map<String, Object> getYearMonthSumFlow(SumFlowParams sumFlowParams);
54
55 Map<String, Object> getYearSumFlow(SumFlowParams sumFlowParams);
52 } 56 }
......
...@@ -10,9 +10,16 @@ public class SumFlowParams { ...@@ -10,9 +10,16 @@ public class SumFlowParams {
10 10
11 /**聚合类型 日:day, 月:month,年:year*/ 11 /**聚合类型 日:day, 月:month,年:year*/
12 private String sumType; 12 private String sumType;
13
13 /**开始时间 yyyy-MM-DD*/ 14 /**开始时间 yyyy-MM-DD*/
14 private String start; 15 private String start;
15 /**结束时间 yyyy-MM-DD*/ 16 /**结束时间 yyyy-MM-DD*/
16 private String end; 17 private String end;
17 18
19 /**时间 年月 yyyy-MM*/
20 private String yearMonth;
21
22 /**时间 年 yyyy*/
23 private String year;
24
18 } 25 }
......
...@@ -21,10 +21,13 @@ public interface IFmPgQueryService { ...@@ -21,10 +21,13 @@ public interface IFmPgQueryService {
21 * @param tableType 表类型 0实时 1计算 21 * @param tableType 表类型 0实时 1计算
22 * @return 22 * @return
23 */ 23 */
24 public List<Map<String,Object>> queryFactoryInfos(String departId,String fields,String startTime,String endTime,String tableType); 24 List<Map<String,Object>> queryFactoryInfos(String departId,String fields,String startTime,String endTime,String tableType);
25 25
26 public List<Map<String, Object>> queryReportData(String departId,String fields,String startTime,String endTime,String reportType); 26 List<Map<String, Object>> queryReportData(String departId,String fields,String startTime,String endTime,String reportType);
27 27
28 public List<Map<String, Object>> queryAotiCurveData(String fields,String startTime,String endTime,String sumType,int strCount); 28 List<Map<String, Object>> queryAotiCurveData(String fields,String startTime,String endTime,String sumType,int strCount);
29 29
30 List<Map<String, Object>> queryAotiCurveDataByMonth(String fields, String startTime, String endTime, String month);
31
32 List<Map<String, Object>> queryAotiCurveDataByYear(String fields, String startTime, String endTime);
30 } 33 }
......
...@@ -393,4 +393,75 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService { ...@@ -393,4 +393,75 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService {
393 } 393 }
394 return dataList; 394 return dataList;
395 } 395 }
396
397 @Override
398 public List<Map<String, Object>> queryAotiCurveDataByMonth(String fields, String startTime, String endTime, String month) {
399 List<Map<String, Object>> dataList = new ArrayList<>();
400 //获取数据采集pg数据库,实时数据获取统一从数据采集pg库获取
401 JdbcTemplate pgDB = (JdbcTemplate)SpringContextUtils.getBean("pg-db");
402 String countTableName = "a01a21a03_count";
403 //获取要查询的指标
404 String fieldSqlPart = "";
405 String[] fieldsArr = fields.split(",");
406 for (int i = 0; i < fieldsArr.length; ++i){
407 fieldSqlPart = fieldSqlPart + (",'"+fieldsArr[i]+"'");
408 }
409 if(!StringUtils.isEmpty(fieldSqlPart)) {
410 fieldSqlPart = fieldSqlPart.substring(1);
411 }
412 try{
413 String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss"))/1000);
414 String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss"))/1000);
415 String sql = "SELECT * FROM (" +
416 "SELECT nm, " +
417 " LEFT(TO_CHAR(TO_TIMESTAMP(CAST(ts AS INTEGER)), 'YYYY-MM-DD HH24:MI:SS'), 7) AS time, " +
418 " SUM(v::numeric) AS value " +
419 " FROM " + countTableName +
420 " WHERE nm in ("+fieldSqlPart+")" +
421 " AND type = 'def'" +
422 " AND ts >= ? AND ts < ? " +
423 " GROUP BY nm, time " +
424 " ORDER BY time" +
425 ") a " +
426 "WHERE RIGHT(a.time,2) = '"+month+"' ";
427 dataList = pgDB.queryForList(sql,tsStartTime,tsEndTime);
428 }catch (Exception e){
429 e.printStackTrace();
430 }
431 return dataList;
432 }
433
434 @Override
435 public List<Map<String, Object>> queryAotiCurveDataByYear(String fields, String startTime, String endTime) {
436 List<Map<String, Object>> dataList = new ArrayList<>();
437 //获取数据采集pg数据库,实时数据获取统一从数据采集pg库获取
438 JdbcTemplate pgDB = (JdbcTemplate)SpringContextUtils.getBean("pg-db");
439 String countTableName = "a01a21a03_count";
440 //获取要查询的指标
441 String fieldSqlPart = "";
442 String[] fieldsArr = fields.split(",");
443 for (int i = 0; i < fieldsArr.length; ++i){
444 fieldSqlPart = fieldSqlPart + (",'"+fieldsArr[i]+"'");
445 }
446 if(!StringUtils.isEmpty(fieldSqlPart)) {
447 fieldSqlPart = fieldSqlPart.substring(1);
448 }
449 try{
450 String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss"))/1000);
451 String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss"))/1000);
452 String sql = "SELECT nm, " +
453 " LEFT(TO_CHAR(TO_TIMESTAMP(CAST(ts AS INTEGER)), 'YYYY-MM-DD HH24:MI:SS'), 4) AS time, " +
454 " SUM(v::numeric) AS value " +
455 " FROM " + countTableName +
456 " WHERE nm in ("+fieldSqlPart+")" +
457 " AND type = 'def'" +
458 " AND ts >= ? AND ts < ? " +
459 " GROUP BY nm, time " +
460 " ORDER BY time";
461 dataList = pgDB.queryForList(sql,tsStartTime,tsEndTime);
462 }catch (Exception e){
463 e.printStackTrace();
464 }
465 return dataList;
466 }
396 } 467 }
......
...@@ -96,17 +96,17 @@ spring: ...@@ -96,17 +96,17 @@ spring:
96 username: jk_test 96 username: jk_test
97 password: Jk_test1211rw 97 password: Jk_test1211rw
98 driver-class-name: com.mysql.jdbc.Driver 98 driver-class-name: com.mysql.jdbc.Driver
99 # mysql-alarm: 99 mysql-alarm:
100 # url: jdbc:mysql://47.104.99.86:3306/intelligent-devices?characterEncoding=UTF-8&useUnicode=true&useSSL=false 100 url: jdbc:mysql://47.104.99.86:3306/intelligent-devices?characterEncoding=UTF-8&useUnicode=true&useSSL=false
101 # username: id_rw 101 username: id_rw
102 # password: s2eCvUEPO2Vk3U1w 102 password: s2eCvUEPO2Vk3U1w
103 # driver-class-name: com.mysql.jdbc.Driver 103 driver-class-name: com.mysql.jdbc.Driver
104 # # 多数据源配置 104 # 多数据源配置
105 # pg-db: 105 pg-db:
106 # url: jdbc:postgresql://47.104.99.86:10086/postgres?useUnicode=true&characterEncoding=UTF8 106 url: jdbc:postgresql://47.104.99.86:10086/postgres?useUnicode=true&characterEncoding=UTF8
107 # username: postgres 107 username: postgres
108 # password: JKjnf9713xt 108 password: JKjnf9713xt
109 # driver-class-name: org.postgresql.Driver 109 driver-class-name: org.postgresql.Driver
110 #redis 配置 110 #redis 配置
111 redis: 111 redis:
112 database: 0 112 database: 0
......
1 spring: 1 spring:
2 profiles: 2 profiles:
3 active: dev 3 active: prod
4 # 信息安全 4 # 信息安全
5 security: 5 security:
6 csrf: 6 csrf:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!