WaterCollecationDao.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package com.shkpr.service.aimodelpower.dbdao.shizilaishuiDataSource;
  2. import com.shkpr.service.aimodelpower.bizmgr.KprAimWaterCollecationBizFun;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.beans.factory.annotation.Qualifier;
  6. import org.springframework.jdbc.core.JdbcTemplate;
  7. import org.springframework.stereotype.Repository;
  8. import org.springframework.util.StringUtils;
  9. import javax.sql.DataSource;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * @ClassName WaterCollecationDao
  14. * @Description: TODO
  15. * @Author LX
  16. * @Date 2024/5/27
  17. * @Version V1.0
  18. **/
  19. @Slf4j
  20. @Repository
  21. public class WaterCollecationDao {
  22. @Autowired
  23. @Qualifier("childDatasource")
  24. private DataSource childDataSource;
  25. //TODO 查询样本及预测水量表;支持是否分页
  26. public List<Map<String,Object>> getTbMWater(boolean isPage,int limit,int offset,String extend){
  27. String sql = "";
  28. if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
  29. sql = "SELECT " +
  30. " a.\"id\",to_char(a.\"date\", 'YYYY-MM-DD') AS \"date\",a.\"max_temperature\",a.\"min_temperature\",a.\"weather\",a.\"month\",a.\"week\",a.\"holiday\",a.\"last_actual_water_withdrawals\",a.\"last_actual_water_supply\",a.\"actual_water_withdrawals\",a.\"actual_water_supply\",a.\"forecast_water_withdrawals\",a.\"forecast_actual_water_supply\",a.\"is_abnormal\",a.\"is_forecast\",a.\"last_modify_time\",a.\"zone_id\" " +
  31. " FROM tb_m_water AS a WHERE 1=1 ";
  32. }else {
  33. sql = "SELECT " +
  34. " a.\"ID\",to_char(a.\"Date\", 'YYYY-MM-DD') AS \"Date\",a.\"Max_temperature\",a.\"Min_temperature\",a.\"Weather\",a.\"Month\",a.\"Week\",a.\"Holiday\",a.\"LastActualWaterWithdrawals\",a.\"LastActualWaterSupply\",a.\"ActualWaterWithdrawals\",a.\"ActualWaterSupply\",a.\"ForecastWaterWithdrawals\",a.\"ForecastActualWaterSupply\",a.\"isAbnormal\",a.\"isForecast\",a.\"LastModifyTime\",a.\"orgId\" " +
  35. " FROM tb_m_water AS a WHERE 1=1 ";
  36. }
  37. if(!StringUtils.isEmpty(extend)){
  38. sql+=extend;
  39. }
  40. if(isPage) {
  41. sql += " LIMIT " + limit + " OFFSET " + offset;
  42. }
  43. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  44. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  45. return tableData;
  46. }
  47. //TODO 查询小时水量预测表;支持是否分页
  48. public List<Map<String,Object>> getTbMHourwater(boolean isPage,int limit,int offset,String extend){
  49. String sql = "";
  50. if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
  51. sql = "SELECT " +
  52. " a.\"id\",to_char(a.\"date\", 'YYYY-MM-DD') AS \"date\",a.\"hour\",a.\"hour_forecast_water_withdrawals\",a.\"hour_forecast_actual_water_supply\",a.\"water_withdrawals_energy\",a.\"water_supply_energy\",a.\"real_water_withdrawals_energy\",a.\"real_water_supply_energy\",a.\"last_modify_time\",a.\"zone_id\"," +
  53. " a.\"hour_actual_water_withdrawals\",a.\"hour_actual_water_supply\" " +
  54. " FROM tb_m_hourwater AS a WHERE 1=1 ";
  55. }else {
  56. sql = "SELECT " +
  57. " a.\"ID\",to_char(a.\"Date\", 'YYYY-MM-DD') AS \"Date\",a.\"Hour\",a.\"HourForecastWaterWithdrawals\",a.\"HourForecastActualWaterSupply\",a.\"WaterWithdrawalsEnergy\",a.\"WaterSupplyEnergy\",a.\"RealWaterWithdrawalsEnergy\",a.\"RealWaterSupplyEnergy\",a.\"LastModifyTime\",a.\"orgId\"," +
  58. " a.\"HourActualWaterWithdrawals\",a.\"HourActualWaterSupply\" " +
  59. " FROM tb_m_hourwater AS a WHERE 1=1 ";
  60. }
  61. if(!StringUtils.isEmpty(extend)){
  62. sql+=extend;
  63. }
  64. if(isPage) {
  65. sql += " LIMIT " + limit + " OFFSET " + offset;
  66. }
  67. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  68. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  69. return tableData;
  70. }
  71. //TODO 查询取水泵房电耗预测接口,支持是否分页
  72. public List<Map<String,Object>> getTbMHourwaterWaterwithdrawals(boolean isPage,int limit,int offset,String extend){
  73. String sql = "";
  74. if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
  75. sql = "SELECT " +
  76. " to_char(a.\"date\", 'YYYY-MM-DD') AS \"date\",a.\"hour\",a.\"pump_id\",a.\"pump_status\",a.\"hour_forecast_water_withdrawals\",a.\"pump_water\",a.\"real_pump_status\",a.\"pump_energy\",a.\"real_pump_energy\",a.\"last_modify_time\",a.\"id\",a.\"zone_id\" " +
  77. " FROM tb_m_hourwater_waterwithdrawals AS a WHERE 1=1 ";
  78. }else {
  79. sql = "SELECT " +
  80. " to_char(a.\"Date\", 'YYYY-MM-DD') AS \"Date\",a.\"Hour\",a.\"PumpID\",a.\"PumpStatus\",a.\"HourForecastWaterWithdrawals\",a.\"PumpWater\",a.\"RealPumpStatus\",a.\"PumpEnergy\",a.\"RealPumpEnergy\",a.\"LastModifyTime\",a.\"ID\",a.\"orgId\" " +
  81. " FROM tb_m_hourwater_waterwithdrawals AS a WHERE 1=1 ";
  82. }
  83. if(!StringUtils.isEmpty(extend)){
  84. sql+=extend;
  85. }
  86. if(isPage) {
  87. sql += " LIMIT " + limit + " OFFSET " + offset;
  88. }
  89. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  90. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  91. return tableData;
  92. }
  93. //TODO 查询供水泵房电耗预测接口,支持是否分页
  94. public List<Map<String,Object>> getTbMHourwaterWatersupply(boolean isPage,int limit,int offset,String extend){
  95. String sql = "";
  96. if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
  97. sql = "SELECT " +
  98. " a.\"id\",to_char(a.\"date\", 'YYYY-MM-DD') AS \"date\",a.\"hour\",a.\"pump_id\",a.\"pump_status\",a.\"hour_forecast_actual_water_supply\",a.\"pump_water\",a.\"real_pump_status\",a.\"pump_energy\",a.\"real_pump_energy\",a.\"last_modify_time\",a.\"zone_id\" " +
  99. " FROM tb_m_hourwater_watersupply AS a WHERE 1=1 ";
  100. }else {
  101. sql = "SELECT " +
  102. " a.\"ID\",to_char(a.\"Date\", 'YYYY-MM-DD') AS \"Date\",a.\"Hour\",a.\"PumpID\",a.\"PumpStatus\",a.\"HourForecastActualWaterSupply\",a.\"PumpWater\",a.\"RealPumpStatus\",a.\"PumpEnergy\",a.\"RealPumpEnergy\",a.\"LastModifyTime\",a.\"orgId\" " +
  103. " FROM tb_m_hourwater_watersupply AS a WHERE 1=1 ";
  104. }
  105. if(!StringUtils.isEmpty(extend)){
  106. sql+=extend;
  107. }
  108. if(isPage) {
  109. sql += " LIMIT " + limit + " OFFSET " + offset;
  110. }
  111. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  112. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  113. return tableData;
  114. }
  115. //TODO 查询水厂id配置列表
  116. public List<Map<String,Object>> getOrgConfig(boolean isPage,int limit,int offset,String extend){
  117. String sql = "SELECT * FROM water_org_config WHERE 1=1 ";
  118. if(!StringUtils.isEmpty(extend)){
  119. sql+=extend;
  120. }
  121. if(isPage) {
  122. sql += " LIMIT " + limit + " OFFSET " + offset;
  123. }
  124. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  125. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  126. return tableData;
  127. }
  128. //TODO 查询取水泵房方案数据,支持是否分页
  129. public List<Map<String,Object>> getTbMWaterwithdrawalspump(boolean isPage,int limit,int offset,String extend){
  130. String sql = "SELECT * FROM tb_m_waterwithdrawalspump WHERE 1=1 ";
  131. if(!StringUtils.isEmpty(extend)){
  132. sql+=extend;
  133. }
  134. if(isPage) {
  135. sql += " LIMIT " + limit + " OFFSET " + offset;
  136. }
  137. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  138. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  139. return tableData;
  140. }
  141. //TODO 查询供水泵房方案数据,支持是否分页
  142. public List<Map<String,Object>> getTbMWatersupplypump(boolean isPage,int limit,int offset,String extend){
  143. String sql = "SELECT * FROM tb_m_watersupplypump WHERE 1=1 ";
  144. if(!StringUtils.isEmpty(extend)){
  145. sql+=extend;
  146. }
  147. if(isPage) {
  148. sql += " LIMIT " + limit + " OFFSET " + offset;
  149. }
  150. JdbcTemplate pgJdbc = new JdbcTemplate(childDataSource);
  151. List<Map<String, Object>> tableData = pgJdbc.queryForList(sql);
  152. return tableData;
  153. }
  154. }