|
@@ -23,10 +23,7 @@ import com.shkpr.service.aimodelpower.services.ServiceMgrProxy;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.InputStream;
|
|
|
+import java.io.*;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.YearMonth;
|
|
@@ -309,6 +306,35 @@ public class KprAimWaterCollecationBizFun {
|
|
|
static DateTimeFormatter formater = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
static DateTimeFormatter formater2 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
+ public static String databaseName = "";
|
|
|
+
|
|
|
+ //TODO 获取数据库名
|
|
|
+ public static void initDatabaseName(){
|
|
|
+ Properties prop = new Properties();
|
|
|
+ InputStream input = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ input = new FileInputStream("./sql.properties");
|
|
|
+
|
|
|
+ // 加载properties文件
|
|
|
+ prop.load(input);
|
|
|
+
|
|
|
+ // 根据属性名获取属性值
|
|
|
+ String databaseName = prop.getProperty("spring,database.name");
|
|
|
+ KprAimWaterCollecationBizFun.databaseName = databaseName;
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ if (input != null) {
|
|
|
+ try {
|
|
|
+ input.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//TODO 查询日取水量预测接口
|
|
|
|
|
|
/**
|
|
@@ -318,25 +344,47 @@ public class KprAimWaterCollecationBizFun {
|
|
|
public static ResponseRes selectTbWaterList(JPTbMWater jpTbMWater){
|
|
|
ResponseRes responseRes = new ResponseRes();
|
|
|
List<Map<String,Object>> list =new ArrayList<>();
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("ID",null);
|
|
|
- map.put("Date",null);
|
|
|
- map.put("Max_temperature",null);
|
|
|
- map.put("Min_temperature",null);
|
|
|
- map.put("Weather",null);
|
|
|
- map.put("Month",null);
|
|
|
- map.put("Week",null);
|
|
|
- map.put("Holiday",null);
|
|
|
- map.put("LastActualWaterWithdrawals",null);
|
|
|
- map.put("LastActualWaterSupply",null);
|
|
|
- map.put("ActualWaterWithdrawals",null);
|
|
|
- map.put("ActualWaterSupply",null);
|
|
|
- map.put("ForecastWaterWithdrawals",null);
|
|
|
- map.put("ForecastActualWaterSupply",null);
|
|
|
- map.put("isAbnormal",null);
|
|
|
- map.put("isForecast",null);
|
|
|
- map.put("LastModifyTime",null);
|
|
|
- list.add(map);
|
|
|
+ if("water_volume_prediction_jiangjin".equals(databaseName)){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", null);
|
|
|
+ map.put("date", null);
|
|
|
+ map.put("max_temperature", null);
|
|
|
+ map.put("min_temperature", null);
|
|
|
+ map.put("weather", null);
|
|
|
+ map.put("month", null);
|
|
|
+ map.put("week", null);
|
|
|
+ map.put("holiday", null);
|
|
|
+ map.put("last_actual_water_withdrawals", null);
|
|
|
+ map.put("last_actual_water_supply", null);
|
|
|
+ map.put("actual_water_withdrawals", null);
|
|
|
+ map.put("actual_water_supply", null);
|
|
|
+ map.put("forecast_water_withdrawals", null);
|
|
|
+ map.put("forecast_actual_water_supply", null);
|
|
|
+ map.put("is_abnormal", null);
|
|
|
+ map.put("is_forecast", null);
|
|
|
+ map.put("last_modify_time", null);
|
|
|
+ list.add(map);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ID", null);
|
|
|
+ map.put("Date", null);
|
|
|
+ map.put("Max_temperature", null);
|
|
|
+ map.put("Min_temperature", null);
|
|
|
+ map.put("Weather", null);
|
|
|
+ map.put("Month", null);
|
|
|
+ map.put("Week", null);
|
|
|
+ map.put("Holiday", null);
|
|
|
+ map.put("LastActualWaterWithdrawals", null);
|
|
|
+ map.put("LastActualWaterSupply", null);
|
|
|
+ map.put("ActualWaterWithdrawals", null);
|
|
|
+ map.put("ActualWaterSupply", null);
|
|
|
+ map.put("ForecastWaterWithdrawals", null);
|
|
|
+ map.put("ForecastActualWaterSupply", null);
|
|
|
+ map.put("isAbnormal", null);
|
|
|
+ map.put("isForecast", null);
|
|
|
+ map.put("LastModifyTime", null);
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
responseRes.setResdata(list);
|
|
|
responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
responseRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
@@ -364,21 +412,38 @@ public class KprAimWaterCollecationBizFun {
|
|
|
*/
|
|
|
public static ResponseRes selectTbHourWaterList(JPTbMHourWater jpTbMHourWater){
|
|
|
ResponseRes responseRes = new ResponseRes();
|
|
|
- List<Map<String,Object>> list =new ArrayList<>();
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("ID",null);
|
|
|
- map.put("Date",null);
|
|
|
- map.put("Hour",null);
|
|
|
- map.put("HourForecastWaterWithdrawals",null);
|
|
|
- map.put("HourForecastActualWaterSupply",null);
|
|
|
- map.put("WaterWithdrawalsEnergy",null);
|
|
|
- map.put("WaterSupplyEnergy",null);
|
|
|
- map.put("RealWaterWithdrawalsEnergy",null);
|
|
|
- map.put("RealWaterSupplyEnergy",null);
|
|
|
- map.put("LastModifyTime",null);
|
|
|
- map.put("HourActualWaterWithdrawals",null);
|
|
|
- map.put("HourActualWaterSupply ",null);
|
|
|
- list.add(map);
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ if("water_volume_prediction_jiangjin".equals(databaseName)){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", null);
|
|
|
+ map.put("date", null);
|
|
|
+ map.put("hour", null);
|
|
|
+ map.put("hour_forecast_water_withdrawals", null);
|
|
|
+ map.put("hour_forecast_actual_water_supply", null);
|
|
|
+ map.put("water_withdrawals_energy", null);
|
|
|
+ map.put("water_supply_energy", null);
|
|
|
+ map.put("real_water_withdrawals_energy", null);
|
|
|
+ map.put("real_water_supply_energy", null);
|
|
|
+ map.put("last_modify_time", null);
|
|
|
+ map.put("hour_actual_water_withdrawals", null);
|
|
|
+ map.put("hour_actual_water_supply ", null);
|
|
|
+ list.add(map);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ID", null);
|
|
|
+ map.put("Date", null);
|
|
|
+ map.put("Hour", null);
|
|
|
+ map.put("HourForecastWaterWithdrawals", null);
|
|
|
+ map.put("HourForecastActualWaterSupply", null);
|
|
|
+ map.put("WaterWithdrawalsEnergy", null);
|
|
|
+ map.put("WaterSupplyEnergy", null);
|
|
|
+ map.put("RealWaterWithdrawalsEnergy", null);
|
|
|
+ map.put("RealWaterSupplyEnergy", null);
|
|
|
+ map.put("LastModifyTime", null);
|
|
|
+ map.put("HourActualWaterWithdrawals", null);
|
|
|
+ map.put("HourActualWaterSupply ", null);
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
responseRes.setResdata(list);
|
|
|
responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
responseRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
@@ -413,20 +478,37 @@ public class KprAimWaterCollecationBizFun {
|
|
|
entity.setPumpId(null);
|
|
|
entity.setSubType(subType);
|
|
|
List<Map<String, Object>> defaultRes = new ArrayList<>();
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("ID",null);
|
|
|
- map.put("Date",null);
|
|
|
- map.put("Hour",null);
|
|
|
- map.put("PumpID",null);
|
|
|
- map.put("PumpStatus",null);
|
|
|
- map.put("HourForecastWaterWithdrawals",null);
|
|
|
- map.put("PumpWater",null);
|
|
|
- map.put("RealPumpStatus",null);
|
|
|
- map.put("PumpEnergy",null);
|
|
|
- map.put("RealPumpEnergy",null);
|
|
|
- map.put("LastModifyTime",null);
|
|
|
- map.put("orgId",null);
|
|
|
- defaultRes.add(map);
|
|
|
+ if("water_volume_prediction_jiangjin".equals(databaseName)){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", null);
|
|
|
+ map.put("date", null);
|
|
|
+ map.put("hour", null);
|
|
|
+ map.put("pump_id", null);
|
|
|
+ map.put("pump_status", null);
|
|
|
+ map.put("hour_forecast_water_withdrawals", null);
|
|
|
+ map.put("pump_water", null);
|
|
|
+ map.put("real_pump_status", null);
|
|
|
+ map.put("pump_energy", null);
|
|
|
+ map.put("real_pump_energy", null);
|
|
|
+ map.put("last_modify_time", null);
|
|
|
+ map.put("zone_id", null);
|
|
|
+ defaultRes.add(map);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ID", null);
|
|
|
+ map.put("Date", null);
|
|
|
+ map.put("Hour", null);
|
|
|
+ map.put("PumpID", null);
|
|
|
+ map.put("PumpStatus", null);
|
|
|
+ map.put("HourForecastWaterWithdrawals", null);
|
|
|
+ map.put("PumpWater", null);
|
|
|
+ map.put("RealPumpStatus", null);
|
|
|
+ map.put("PumpEnergy", null);
|
|
|
+ map.put("RealPumpEnergy", null);
|
|
|
+ map.put("LastModifyTime", null);
|
|
|
+ map.put("orgId", null);
|
|
|
+ defaultRes.add(map);
|
|
|
+ }
|
|
|
defaultModels.add(entity);
|
|
|
responseRes.setResdata(defaultModels);
|
|
|
responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
@@ -488,20 +570,37 @@ public class KprAimWaterCollecationBizFun {
|
|
|
entity.setPumpId(null);
|
|
|
entity.setSubType(subType);
|
|
|
List<Map<String, Object>> defaultRes = new ArrayList<>();
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("ID",null);
|
|
|
- map.put("Date",null);
|
|
|
- map.put("Hour",null);
|
|
|
- map.put("PumpID",null);
|
|
|
- map.put("PumpStatus",null);
|
|
|
- map.put("HourForecastActualWaterSupply",null);
|
|
|
- map.put("PumpWater",null);
|
|
|
- map.put("RealPumpStatus",null);
|
|
|
- map.put("PumpEnergy",null);
|
|
|
- map.put("RealPumpEnergy",null);
|
|
|
- map.put("LastModifyTime",null);
|
|
|
- map.put("orgId",null);
|
|
|
- defaultRes.add(map);
|
|
|
+ if("water_volume_prediction_jiangjin".equals(databaseName)){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", null);
|
|
|
+ map.put("date", null);
|
|
|
+ map.put("hour", null);
|
|
|
+ map.put("pump_id", null);
|
|
|
+ map.put("pump_status", null);
|
|
|
+ map.put("hour_forecast_actual_water_supply", null);
|
|
|
+ map.put("pump_water", null);
|
|
|
+ map.put("real_pump_status", null);
|
|
|
+ map.put("pump_energy", null);
|
|
|
+ map.put("real_pump_energy", null);
|
|
|
+ map.put("last_modify_time", null);
|
|
|
+ map.put("zone_id", null);
|
|
|
+ defaultRes.add(map);
|
|
|
+ }else {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("ID", null);
|
|
|
+ map.put("Date", null);
|
|
|
+ map.put("Hour", null);
|
|
|
+ map.put("PumpID", null);
|
|
|
+ map.put("PumpStatus", null);
|
|
|
+ map.put("HourForecastActualWaterSupply", null);
|
|
|
+ map.put("PumpWater", null);
|
|
|
+ map.put("RealPumpStatus", null);
|
|
|
+ map.put("PumpEnergy", null);
|
|
|
+ map.put("RealPumpEnergy", null);
|
|
|
+ map.put("LastModifyTime", null);
|
|
|
+ map.put("orgId", null);
|
|
|
+ defaultRes.add(map);
|
|
|
+ }
|
|
|
defaultModels.add(entity);
|
|
|
responseRes.setResdata(defaultModels);
|
|
|
responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
@@ -510,43 +609,84 @@ public class KprAimWaterCollecationBizFun {
|
|
|
//
|
|
|
List<Map<String, Object>> resList = getWaterTapWaterApi().getTbMHourwaterWatersupply(jpTbMHourWater.getIsPage(),
|
|
|
jpTbMHourWater.getLimit(), jpTbMHourWater.getOffset(), jpTbMHourWater.getForDateStr());
|
|
|
- //TODO 按水厂分组
|
|
|
- Map<Object, List<Map<String, Object>>> groupedData =
|
|
|
- resList.stream().collect(Collectors.groupingBy(item -> item.get("orgId")));
|
|
|
- //TODO 查询水厂的取水泵,然后将数据拼接
|
|
|
- List<InPumpModel> inPumpModels = new ArrayList<>();
|
|
|
- for (Object key:groupedData.keySet()) {
|
|
|
- InPumpModel model = new InPumpModel();
|
|
|
- List<Map<String,Object>> zoonList = getWaterTapWaterApi().getZoonInfoList(key.toString(),subType);
|
|
|
- if(!CollectionUtils.isEmpty(zoonList)){
|
|
|
- model.setPumpId(zoonList.get(0).get("uid").toString());
|
|
|
+ if("water_volume_prediction_jiangjin".equals(databaseName)){
|
|
|
+ //TODO 按水厂分组
|
|
|
+ Map<Object, List<Map<String, Object>>> groupedData =
|
|
|
+ resList.stream().collect(Collectors.groupingBy(item -> item.get("zone_id")));
|
|
|
+ //TODO 查询水厂的取水泵,然后将数据拼接
|
|
|
+ List<InPumpModel> inPumpModels = new ArrayList<>();
|
|
|
+ for (Object key : groupedData.keySet()) {
|
|
|
+ InPumpModel model = new InPumpModel();
|
|
|
+ List<Map<String, Object>> zoonList = getWaterTapWaterApi().getZoonInfoList(key.toString(), subType);
|
|
|
+ if (!CollectionUtils.isEmpty(zoonList)) {
|
|
|
+ model.setPumpId(zoonList.get(0).get("uid").toString());
|
|
|
+ }
|
|
|
+ model.setOrgId(key.toString());
|
|
|
+ model.setSubType(subType);
|
|
|
+ List<Map<String, Object>> dataList = groupedData.get(key);
|
|
|
+ //TODO 将年月日时作为分组条件
|
|
|
+ Map<String, List<Map<String, Object>>> dataMap = dataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(emp ->
|
|
|
+ emp.get("date") + " " + emp.get("hour") // 创建复合键
|
|
|
+ ));
|
|
|
+ model.setDataList(dataMap);
|
|
|
+ //TODO 查询相应方案数据
|
|
|
+ List<Map<String, Object>> drawalsList = getWaterTapWaterApi().getTbMWatersupplypump(false,
|
|
|
+ 20, 0, " AND \"zone_id\" = '" + key.toString() + "'");
|
|
|
+ model.setDrawalsList(drawalsList);
|
|
|
+ inPumpModels.add(model);
|
|
|
}
|
|
|
- model.setOrgId(key.toString());
|
|
|
- model.setSubType(subType);
|
|
|
- List<Map<String, Object>> dataList = groupedData.get(key);
|
|
|
- //TODO 将年月日时作为分组条件
|
|
|
- Map<String, List<Map<String, Object>>> dataMap = dataList.stream()
|
|
|
- .collect(Collectors.groupingBy(emp ->
|
|
|
- emp.get("Date") + " " + emp.get("Hour") // 创建复合键
|
|
|
- ));
|
|
|
- model.setDataList(dataMap);
|
|
|
- //TODO 查询相应方案数据
|
|
|
- List<Map<String,Object>> drawalsList = getWaterTapWaterApi().getTbMWatersupplypump(false,
|
|
|
- 20,0," AND \"orgId\" = '"+key.toString()+"'");
|
|
|
- model.setDrawalsList(drawalsList);
|
|
|
- inPumpModels.add(model);
|
|
|
- }
|
|
|
|
|
|
- if(!CollectionUtils.isEmpty(inPumpModels)){
|
|
|
- responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
- responseRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
- responseRes.setResdata(inPumpModels);
|
|
|
+ if (!CollectionUtils.isEmpty(inPumpModels)) {
|
|
|
+ responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ responseRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ responseRes.setResdata(inPumpModels);
|
|
|
+ }
|
|
|
+ return responseRes;
|
|
|
+ }else {
|
|
|
+ //TODO 按水厂分组
|
|
|
+ Map<Object, List<Map<String, Object>>> groupedData =
|
|
|
+ resList.stream().collect(Collectors.groupingBy(item -> item.get("orgId")));
|
|
|
+ //TODO 查询水厂的取水泵,然后将数据拼接
|
|
|
+ List<InPumpModel> inPumpModels = new ArrayList<>();
|
|
|
+ for (Object key : groupedData.keySet()) {
|
|
|
+ InPumpModel model = new InPumpModel();
|
|
|
+ List<Map<String, Object>> zoonList = getWaterTapWaterApi().getZoonInfoList(key.toString(), subType);
|
|
|
+ if (!CollectionUtils.isEmpty(zoonList)) {
|
|
|
+ model.setPumpId(zoonList.get(0).get("uid").toString());
|
|
|
+ }
|
|
|
+ model.setOrgId(key.toString());
|
|
|
+ model.setSubType(subType);
|
|
|
+ List<Map<String, Object>> dataList = groupedData.get(key);
|
|
|
+ //TODO 将年月日时作为分组条件
|
|
|
+ Map<String, List<Map<String, Object>>> dataMap = dataList.stream()
|
|
|
+ .collect(Collectors.groupingBy(emp ->
|
|
|
+ emp.get("Date") + " " + emp.get("Hour") // 创建复合键
|
|
|
+ ));
|
|
|
+ model.setDataList(dataMap);
|
|
|
+ //TODO 查询相应方案数据
|
|
|
+ List<Map<String, Object>> drawalsList = getWaterTapWaterApi().getTbMWatersupplypump(false,
|
|
|
+ 20, 0, " AND \"orgId\" = '" + key.toString() + "'");
|
|
|
+ model.setDrawalsList(drawalsList);
|
|
|
+ inPumpModels.add(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(inPumpModels)) {
|
|
|
+ responseRes.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ responseRes.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ responseRes.setResdata(inPumpModels);
|
|
|
+ }
|
|
|
+ return responseRes;
|
|
|
}
|
|
|
- return responseRes;
|
|
|
}catch(Exception ex){
|
|
|
responseRes.setResdata(null);
|
|
|
responseRes.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
|
|
|
responseRes.setRescode(ResponseCode.RESULT_BAD.toStrCode());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR
|
|
|
+ , mStrClassName
|
|
|
+ , mStrClassName
|
|
|
+ , String.format("预测泵供水小时数据调用异常 ERROR:{%s} ",
|
|
|
+ ex.getLocalizedMessage()));
|
|
|
return responseRes;
|
|
|
}
|
|
|
}
|