f8d3f276 张雷

奥体项目接口修改

1 个父辈 035378aa
......@@ -261,4 +261,26 @@ public class OlympicCenterController {
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取相同月份的累计流量数据", notes="获取相同月份的累计流量数据")
@GetMapping(value = "/getYearMonthSumFlow")
public Result<Map<String,Object>> getYearMonthSumFlow(SumFlowParams sumFlowParams){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
map = olympicCenterService.getYearMonthSumFlow(sumFlowParams);
result.setResult(map);
result.setSuccess(true);
return result;
}
@ApiOperation(value="获取年度的累计流量数据", notes="获取年度的累计流量数据")
@GetMapping(value = "/getYearSumFlow")
public Result<Map<String,Object>> getYearSumFlow(SumFlowParams sumFlowParams){
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
map = olympicCenterService.getYearSumFlow(sumFlowParams);
result.setResult(map);
result.setSuccess(true);
return result;
}
}
......
......@@ -49,4 +49,8 @@ public interface IOlympicCenterService {
List<Map<String, Object>> getAlarmList(AlarmParams alarmParams);
Map<String, Object> getSumFlowData(SumFlowParams sumFlowParams);
Map<String, Object> getYearMonthSumFlow(SumFlowParams sumFlowParams);
Map<String, Object> getYearSumFlow(SumFlowParams sumFlowParams);
}
......
......@@ -10,9 +10,16 @@ public class SumFlowParams {
/**聚合类型 日:day, 月:month,年:year*/
private String sumType;
/**开始时间 yyyy-MM-DD*/
private String start;
/**结束时间 yyyy-MM-DD*/
private String end;
/**时间 年月 yyyy-MM*/
private String yearMonth;
/**时间 年 yyyy*/
private String year;
}
......
......@@ -21,10 +21,13 @@ public interface IFmPgQueryService {
* @param tableType 表类型 0实时 1计算
* @return
*/
public List<Map<String,Object>> queryFactoryInfos(String departId,String fields,String startTime,String endTime,String tableType);
List<Map<String,Object>> queryFactoryInfos(String departId,String fields,String startTime,String endTime,String tableType);
public List<Map<String, Object>> queryReportData(String departId,String fields,String startTime,String endTime,String reportType);
List<Map<String, Object>> queryReportData(String departId,String fields,String startTime,String endTime,String reportType);
public List<Map<String, Object>> queryAotiCurveData(String fields,String startTime,String endTime,String sumType,int strCount);
List<Map<String, Object>> queryAotiCurveData(String fields,String startTime,String endTime,String sumType,int strCount);
List<Map<String, Object>> queryAotiCurveDataByMonth(String fields, String startTime, String endTime, String month);
List<Map<String, Object>> queryAotiCurveDataByYear(String fields, String startTime, String endTime);
}
......
......@@ -393,4 +393,75 @@ public class FmPgQueryServiceImpl implements IFmPgQueryService {
}
return dataList;
}
@Override
public List<Map<String, Object>> queryAotiCurveDataByMonth(String fields, String startTime, String endTime, String month) {
List<Map<String, Object>> dataList = new ArrayList<>();
//获取数据采集pg数据库,实时数据获取统一从数据采集pg库获取
JdbcTemplate pgDB = (JdbcTemplate)SpringContextUtils.getBean("pg-db");
String countTableName = "a01a21a03_count";
//获取要查询的指标
String fieldSqlPart = "";
String[] fieldsArr = fields.split(",");
for (int i = 0; i < fieldsArr.length; ++i){
fieldSqlPart = fieldSqlPart + (",'"+fieldsArr[i]+"'");
}
if(!StringUtils.isEmpty(fieldSqlPart)) {
fieldSqlPart = fieldSqlPart.substring(1);
}
try{
String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss"))/1000);
String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss"))/1000);
String sql = "SELECT * FROM (" +
"SELECT nm, " +
" LEFT(TO_CHAR(TO_TIMESTAMP(CAST(ts AS INTEGER)), 'YYYY-MM-DD HH24:MI:SS'), 7) AS time, " +
" SUM(v::numeric) AS value " +
" FROM " + countTableName +
" WHERE nm in ("+fieldSqlPart+")" +
" AND type = 'def'" +
" AND ts >= ? AND ts < ? " +
" GROUP BY nm, time " +
" ORDER BY time" +
") a " +
"WHERE RIGHT(a.time,2) = '"+month+"' ";
dataList = pgDB.queryForList(sql,tsStartTime,tsEndTime);
}catch (Exception e){
e.printStackTrace();
}
return dataList;
}
@Override
public List<Map<String, Object>> queryAotiCurveDataByYear(String fields, String startTime, String endTime) {
List<Map<String, Object>> dataList = new ArrayList<>();
//获取数据采集pg数据库,实时数据获取统一从数据采集pg库获取
JdbcTemplate pgDB = (JdbcTemplate)SpringContextUtils.getBean("pg-db");
String countTableName = "a01a21a03_count";
//获取要查询的指标
String fieldSqlPart = "";
String[] fieldsArr = fields.split(",");
for (int i = 0; i < fieldsArr.length; ++i){
fieldSqlPart = fieldSqlPart + (",'"+fieldsArr[i]+"'");
}
if(!StringUtils.isEmpty(fieldSqlPart)) {
fieldSqlPart = fieldSqlPart.substring(1);
}
try{
String tsStartTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(startTime, "yyyy-MM-dd HH:mm:ss"))/1000);
String tsEndTime = String.valueOf(DateUtils.getMillis(DateUtils.parseDate(endTime, "yyyy-MM-dd HH:mm:ss"))/1000);
String sql = "SELECT nm, " +
" LEFT(TO_CHAR(TO_TIMESTAMP(CAST(ts AS INTEGER)), 'YYYY-MM-DD HH24:MI:SS'), 4) AS time, " +
" SUM(v::numeric) AS value " +
" FROM " + countTableName +
" WHERE nm in ("+fieldSqlPart+")" +
" AND type = 'def'" +
" AND ts >= ? AND ts < ? " +
" GROUP BY nm, time " +
" ORDER BY time";
dataList = pgDB.queryForList(sql,tsStartTime,tsEndTime);
}catch (Exception e){
e.printStackTrace();
}
return dataList;
}
}
......
......@@ -96,17 +96,17 @@ spring:
username: jk_test
password: Jk_test1211rw
driver-class-name: com.mysql.jdbc.Driver
# mysql-alarm:
# url: jdbc:mysql://47.104.99.86:3306/intelligent-devices?characterEncoding=UTF-8&useUnicode=true&useSSL=false
# username: id_rw
# password: s2eCvUEPO2Vk3U1w
# driver-class-name: com.mysql.jdbc.Driver
# # 多数据源配置
# pg-db:
# url: jdbc:postgresql://47.104.99.86:10086/postgres?useUnicode=true&characterEncoding=UTF8
# username: postgres
# password: JKjnf9713xt
# driver-class-name: org.postgresql.Driver
mysql-alarm:
url: jdbc:mysql://47.104.99.86:3306/intelligent-devices?characterEncoding=UTF-8&useUnicode=true&useSSL=false
username: id_rw
password: s2eCvUEPO2Vk3U1w
driver-class-name: com.mysql.jdbc.Driver
# 多数据源配置
pg-db:
url: jdbc:postgresql://47.104.99.86:10086/postgres?useUnicode=true&characterEncoding=UTF8
username: postgres
password: JKjnf9713xt
driver-class-name: org.postgresql.Driver
#redis 配置
redis:
database: 0
......
spring:
profiles:
active: dev
active: prod
# 信息安全
security:
csrf:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!