Explorar o código

江津相关修改

1037015548@qq.com hai 6 meses
pai
achega
6ff4a16524

+ 8 - 5
sql.properties

@@ -1,18 +1,21 @@
-spring.datasource.data.jdbc-url=jdbc:postgresql_postGIS://119.96.165.176:5432/watersmart?useSSL=false&useAffectedRows=false&allowMultiQueries=true
+#spring.datasource.data.jdbc-url=jdbc:postgresql_postGIS://119.96.165.176:5432/water_smart_develop_branch?useSSL=false&useAffectedRows=false&allowMultiQueries=true
+spring.datasource.data.jdbc-url=jdbc:postgresql_postGIS://1.197.77.125:5432/watersmart?useSSL=false&useAffectedRows=false&allowMultiQueries=true
 spring.datasource.data.username=postgres
 spring.datasource.data.password=kpr.23417.postgres
 spring.datasource.data.driver-class-name=org.postgis.DriverWrapper
 
-#pgsql 自来水水量预测数据库源
+#pgsql 水量预测数据库源
 #spring.datasource.db2.jdbc-url=jdbc:postgresql_postGIS://119.96.165.176:5432/water_volume_prediction?useSSL=false&useAffectedRows=false&allowMultiQueries=true
 #spring.datasource.db2.username=postgres
 #spring.datasource.db2.password=kpr.23417.postgres
 #spring.datasource.db2.driver-class-name=org.postgis.DriverWrapper
-spring.datasource.db2.jdbc-url=jdbc:postgresql_postGIS://10.101.5.50:5432/water_volume_prediction?useSSL=false&useAffectedRows=false&allowMultiQueries=true
+#spring.datasource.db2.jdbc-url=jdbc:postgresql_postGIS://10.101.5.50:5432/water_volume_prediction?useSSL=false&useAffectedRows=false&allowMultiQueries=true
+spring.datasource.db2.jdbc-url=jdbc:postgresql_postGIS://10.101.3.104:5432/water_volume_prediction_jiangjin?useSSL=false&useAffectedRows=false&allowMultiQueries=true
 spring.datasource.db2.username=postgres
-spring.datasource.db2.password=ygt.23417.postgres
+#spring.datasource.db2.password=ygt.23417.postgres
+spring.datasource.db2.password=kpr.23417.postgres
 spring.datasource.db2.driver-class-name=org.postgis.DriverWrapper
-
+spring,database.name=water_volume_prediction_jiangjin
 
 spring.datasource.data2.jdbc-url=jdbc:postgresql://119.96.165.176:5432/water_smart_central?useSSL=false&useAffectedRows=false&allowMultiQueries=true&useUnicode=true&characterEncoding=utf-8
 spring.datasource.data2.username=postgres

+ 236 - 96
src/main/java/com/shkpr/service/aimodelpower/bizmgr/KprAimWaterCollecationBizFun.java

@@ -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;
         }
     }

+ 43 - 17
src/main/java/com/shkpr/service/aimodelpower/dbdao/shizilaishuiDataSource/WaterCollecationDao.java

@@ -1,5 +1,6 @@
 package com.shkpr.service.aimodelpower.dbdao.shizilaishuiDataSource;
 
+import com.shkpr.service.aimodelpower.bizmgr.KprAimWaterCollecationBizFun;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -27,10 +28,16 @@ public class WaterCollecationDao {
 
     //TODO 查询样本及预测水量表;支持是否分页
     public List<Map<String,Object>> getTbMWater(boolean isPage,int limit,int offset,String extend){
-        
-            String sql = "SELECT " +
-                    " 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\" " +
-                    " FROM tb_m_water AS a WHERE 1=1 ";
+            String sql = "";
+            if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_water AS a WHERE 1=1 ";
+            }else {
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_water AS a WHERE 1=1 ";
+            }
             if(!StringUtils.isEmpty(extend)){
                 sql+=extend;
             }
@@ -45,11 +52,18 @@ public class WaterCollecationDao {
 
     //TODO 查询小时水量预测表;支持是否分页
     public List<Map<String,Object>> getTbMHourwater(boolean isPage,int limit,int offset,String extend){
-        
-            String sql = "SELECT " +
-                    " 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\"," +
-                    " a.\"HourActualWaterWithdrawals\",a.\"HourActualWaterSupply\" " +
-                    " FROM tb_m_hourwater AS a WHERE 1=1 ";
+            String sql = "";
+            if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
+                sql = "SELECT " +
+                        " 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\"," +
+                        " a.\"hour_actual_water_withdrawals\",a.\"hour_actual_water_supply\" " +
+                        " FROM tb_m_hourwater AS a WHERE 1=1 ";
+            }else {
+                sql = "SELECT " +
+                        " 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\"," +
+                        " a.\"HourActualWaterWithdrawals\",a.\"HourActualWaterSupply\" " +
+                        " FROM tb_m_hourwater AS a WHERE 1=1 ";
+            }
             if(!StringUtils.isEmpty(extend)){
                 sql+=extend;
             }
@@ -64,10 +78,16 @@ public class WaterCollecationDao {
 
     //TODO 查询取水泵房电耗预测接口,支持是否分页
     public List<Map<String,Object>> getTbMHourwaterWaterwithdrawals(boolean isPage,int limit,int offset,String extend){
-        
-            String sql = "SELECT " +
-                    " 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\" " +
-                    " FROM tb_m_hourwater_waterwithdrawals AS a WHERE 1=1 ";
+            String sql = "";
+            if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_hourwater_waterwithdrawals AS a WHERE 1=1 ";
+            }else {
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_hourwater_waterwithdrawals AS a WHERE 1=1 ";
+            }
             if(!StringUtils.isEmpty(extend)){
                 sql+=extend;
             }
@@ -82,10 +102,16 @@ public class WaterCollecationDao {
 
     //TODO 查询供水泵房电耗预测接口,支持是否分页
     public List<Map<String,Object>> getTbMHourwaterWatersupply(boolean isPage,int limit,int offset,String extend){
-        
-            String sql = "SELECT " +
-                    " 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\" " +
-                    " FROM tb_m_hourwater_watersupply AS a WHERE 1=1 ";
+            String sql = "";
+            if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_hourwater_watersupply AS a WHERE 1=1 ";
+            }else {
+                sql = "SELECT " +
+                        " 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\" " +
+                        " FROM tb_m_hourwater_watersupply AS a WHERE 1=1 ";
+            }
             if(!StringUtils.isEmpty(extend)){
                 sql+=extend;
             }

+ 19 - 21
src/main/java/com/shkpr/service/aimodelpower/globalmgr/ScheduleTaskMgr.java

@@ -102,30 +102,17 @@ public class ScheduleTaskMgr {
     }
 
     //TODO 每天整点的五分执行检查小时用水量是否对齐,检查时间范围为当前时间到昨天
-    @Scheduled(cron = "0 5 * * * *")
+    /*@Scheduled(cron = "0 5 * * * *")
 //    @Scheduled(cron = "0 0/1 * * * ?")
     public void executeTaskEveryHourAtTenMinutesRecordAll() {
         KprAimTapWaterBizFun.checkRecordAllData();
-    }
+    }*/
 
     //TODO 每天整点的十分执行检查小时用水量是否对齐,检查时间范围为当前时间到昨天
-    @Scheduled(cron = "0 10 * * * *")
+    /*@Scheduled(cron = "0 10 * * * *")
     public void executeTaskEveryHourAtTenMinutesRecord() {
         KprAimTapWaterBizFun.checkRecordData();
-    }
-
-//    //TODO 每天整点的15分执行配置月预测日数据(目前实际上是先调对应日期的实际预测接口在去调修改实际数据的逻辑)
-//    @Scheduled(cron = "0 15 * * * *")
-////    @Scheduled(cron = "0 0/1 * * * ?")
-//    public void executeTbMWater() {
-//        KprAimWaterCollecationBizFun.insertYuceDataScheduled(null);
-//    }
-//
-//    //TODO 每天每小时的16分执行配置月预测日小时数据(目前实际上是先调对应日期的实际预测接口在去调修改实际数据的逻辑)
-//    @Scheduled(cron = "0 16 * * * *")
-//    public void executeTbMHourWater() {
-//        KprAimWaterCollecationBizFun.insertYuceHourDataScheduled(null);
-//    }
+    }*/
 
     //TODO 每天每小时的20分执行当前月预测日数据
     @Scheduled(cron = "0 20 * * * *")
@@ -174,8 +161,8 @@ public class ScheduleTaskMgr {
 //    }
 
 
-    //TODO 启动时执行一次
-    @PostConstruct
+    //TODO 启动时执行一次 江津的就给注释掉
+    /*@PostConstruct
     public void initOneTapWater(){
         Timer timer = new Timer();
         // 创建定时器任务
@@ -198,7 +185,7 @@ public class ScheduleTaskMgr {
             }
         };
         timer.schedule(timerTask1,11000);//11秒后执行一次
-    }
+    }*/
 
     @PostConstruct
     public void initWaterDay(){
@@ -223,11 +210,22 @@ public class ScheduleTaskMgr {
                 String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
                 KprAimWaterCollecationBizFun.insertYuceHourData(time);
                 KprAimWaterCollecationBizFun.insertYuceHourAddData(time);
-                KprAimWaterCollecationBizFun.insertYuceHourDataScheduled(time);
+                /*KprAimWaterCollecationBizFun.insertYuceHourDataScheduled(time);*///江津的给注释掉
             }
         };
         timer.schedule(timerTask1,9000);//9秒后执行一次
     }
+    @PostConstruct
+    public void initDatabaseName(){
+        Timer timer = new Timer();
+        TimerTask timerTask1 = new TimerTask() {
+            @Override
+            public void run() {
+                KprAimWaterCollecationBizFun.initDatabaseName();
+            }
+        };
+        timer.schedule(timerTask1,6000);//6秒后执行一次
+    }
 
     @Scheduled(cron = "${cron.check.wo.dispatch.plan}")
     public void checkPatrolPlan(){

+ 57 - 23
src/main/java/com/shkpr/service/aimodelpower/jsonbean/zilaishui/JPTbMHourWater.java

@@ -2,6 +2,7 @@ package com.shkpr.service.aimodelpower.jsonbean.zilaishui;
 
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.aimodelpower.bizmgr.KprAimWaterCollecationBizFun;
 import com.shkpr.service.aimodelpower.commtools.TimeTool;
 import com.shkpr.service.aimodelpower.controllervalid.CommonParamValidList;
 import com.shkpr.service.aimodelpower.controllervalid.CommonParamValidSS;
@@ -40,35 +41,68 @@ public class JPTbMHourWater {
     private String forDateStr;
 
     public boolean checkValid(){
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        StringBuilder strSql = new StringBuilder("");
-        if(!StringUtils.isEmpty(orgId)){
-            strSql.append(" AND \"orgId\" = '"+orgId+"'");
-        }
-        if(queryDate==null){
-            //TODO 说明前端没传,那么默认为今天
-            LocalDateTime nowDate = LocalDateTime.now();//结束时间
-            nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
-            nowDate = nowDate.withHour(0);
-            nowDate = nowDate.withMinute(0);
-            nowDate = nowDate.withSecond(0);
+        if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)) {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            StringBuilder strSql = new StringBuilder("");
+            if (!StringUtils.isEmpty(orgId)) {
+                strSql.append(" AND \"zone_id\" = '" + orgId + "'");
+            }
+            if (queryDate == null) {
+                //TODO 说明前端没传,那么默认为今天
+                LocalDateTime nowDate = LocalDateTime.now();//结束时间
+                nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
+                nowDate = nowDate.withHour(0);
+                nowDate = nowDate.withMinute(0);
+                nowDate = nowDate.withSecond(0);
+
+                strSql.append(" AND \"date\" =  '" + nowDate.format(formatter) + "' ");
+                forDateStr = strSql.toString();
+            } else if (queryDate != null) {
+                try {
+                    //TODO 说明符合可组成查询日期的条件
+                    String sqlStr = LocalDateTime.ofInstant(Instant.ofEpochMilli(queryDate), ZoneId.systemDefault())
+                            .withHour(0).withMinute(0).withSecond(0).format(formatter);
+                    strSql.append(" AND \"date\" =  '" + sqlStr + "' ");
+                    forDateStr = strSql.toString();
+                } catch (Exception ex) {
+                    LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
+                            , String.format("errorMsg:%s====>"
+                                    , ex.getLocalizedMessage()));
+                    return false;
+                }
+            }
+            return true;
+        }else {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            StringBuilder strSql = new StringBuilder("");
+            if (!StringUtils.isEmpty(orgId)) {
+                strSql.append(" AND \"orgId\" = '" + orgId + "'");
+            }
+            if (queryDate == null) {
+                //TODO 说明前端没传,那么默认为今天
+                LocalDateTime nowDate = LocalDateTime.now();//结束时间
+                nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
+                nowDate = nowDate.withHour(0);
+                nowDate = nowDate.withMinute(0);
+                nowDate = nowDate.withSecond(0);
 
-            strSql.append(" AND \"Date\" =  '"+nowDate.format(formatter)+"' ");
-            forDateStr = strSql.toString();
-        }else if(queryDate!=null){
-            try {
+                strSql.append(" AND \"Date\" =  '" + nowDate.format(formatter) + "' ");
+                forDateStr = strSql.toString();
+            } else if (queryDate != null) {
+                try {
                     //TODO 说明符合可组成查询日期的条件
                     String sqlStr = LocalDateTime.ofInstant(Instant.ofEpochMilli(queryDate), ZoneId.systemDefault())
                             .withHour(0).withMinute(0).withSecond(0).format(formatter);
-                    strSql.append(" AND \"Date\" =  '"+sqlStr+"' ");
+                    strSql.append(" AND \"Date\" =  '" + sqlStr + "' ");
                     forDateStr = strSql.toString();
-            }catch(Exception ex){
-                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
-                        ,String.format("errorMsg:%s====>"
-                                ,ex.getLocalizedMessage()));
-                return false;
+                } catch (Exception ex) {
+                    LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
+                            , String.format("errorMsg:%s====>"
+                                    , ex.getLocalizedMessage()));
+                    return false;
+                }
             }
+            return true;
         }
-        return true;
     }
 }

+ 124 - 57
src/main/java/com/shkpr/service/aimodelpower/jsonbean/zilaishui/JPTbMWater.java

@@ -2,6 +2,7 @@ package com.shkpr.service.aimodelpower.jsonbean.zilaishui;
 
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.aimodelpower.bizmgr.KprAimWaterCollecationBizFun;
 import com.shkpr.service.aimodelpower.commtools.TimeTool;
 import com.shkpr.service.aimodelpower.controllervalid.CommonParamValidList;
 import com.shkpr.service.aimodelpower.controllervalid.CommonParamValidSS;
@@ -40,70 +41,136 @@ public class JPTbMWater {
     private String forDateStr;
 
     public boolean checkValid(){
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        if(startDate==null&&endDate!=null){
-            return false;
-        }
-        StringBuilder strSql = new StringBuilder("");
-        if(!StringUtils.isEmpty(orgId)){
-            strSql.append(" AND \"orgId\" = '"+orgId+"'");
-        }
-        if(startDate==null&&endDate==null){
-            //TODO 说明前端没传,那么默认为当前月往前推到一号作为开始和结束条件
-            LocalDateTime nowDate = LocalDateTime.now();//结束时间
-            nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
-            nowDate = nowDate.withHour(0);
-            nowDate = nowDate.withMinute(0);
-            nowDate = nowDate.withSecond(0);
+        if ("water_volume_prediction_jiangjin".equals(KprAimWaterCollecationBizFun.databaseName)){
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            if (startDate == null && endDate != null) {
+                return false;
+            }
+            StringBuilder strSql = new StringBuilder("");
+            if (!StringUtils.isEmpty(orgId)) {
+                strSql.append(" AND \"zone_id\" = '" + orgId + "'");
+            }
+            if (startDate == null && endDate == null) {
+                //TODO 说明前端没传,那么默认为当前月往前推到一号作为开始和结束条件
+                LocalDateTime nowDate = LocalDateTime.now();//结束时间
+                nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
+                nowDate = nowDate.withHour(0);
+                nowDate = nowDate.withMinute(0);
+                nowDate = nowDate.withSecond(0);
 
-            LocalDateTime startLocalDate = nowDate;
-            startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
+                LocalDateTime startLocalDate = nowDate;
+                startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
 
-            String startLocalDateStr = startLocalDate.format(formatter);
-            String endLocalDateStr = nowDate.format(formatter);
-            strSql.append(" AND \"Date\" BETWEEN  '"+startLocalDateStr+"' "+"AND '"+endLocalDateStr+"'");
-            forDateStr = strSql.toString();
-            startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
-            endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
-        }else if(startDate!=null&&endDate!=null){
-            try {
-                LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
-                LocalDateTime endLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(endDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
+                String startLocalDateStr = startLocalDate.format(formatter);
+                String endLocalDateStr = nowDate.format(formatter);
+                strSql.append(" AND \"date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                forDateStr = strSql.toString();
+                startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
+                endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+            } else if (startDate != null && endDate != null) {
+                try {
+                    LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
+                    LocalDateTime endLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(endDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
 //                long monthsBetween = ChronoUnit.MONTHS.between(startLocalDate, endLocalDate);
-                if(startLocalDate.isAfter(endLocalDate)){
-                    return false;
-                }else if(endLocalDate.isBefore(startLocalDate)){
+                    if (startLocalDate.isAfter(endLocalDate)) {
+                        return false;
+                    } else if (endLocalDate.isBefore(startLocalDate)) {
+                        return false;
+                    } else if (startLocalDate.equals(endLocalDate) || startLocalDate.isBefore(endLocalDate)) {
+                        //TODO 说明符合可组成查询日期的条件
+                        //TODO 按照需求,特殊化结束时间再加4天
+                        startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
+                        endLocalDate = endLocalDate.minusDays(-4);
+                        String startLocalDateStr = startLocalDate.format(formatter);
+                        String endLocalDateStr = endLocalDate.format(formatter);
+                        strSql.append(" AND \"date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                        forDateStr = strSql.toString();
+                        startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
+                        endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+                    }
+                } catch (Exception ex) {
+                    LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
+                            , String.format("errorMsg:%s====>"
+                                    , ex.getLocalizedMessage()));
                     return false;
-                }else if(startLocalDate .equals(endLocalDate)||startLocalDate.isBefore(endLocalDate)){
-                    //TODO 说明符合可组成查询日期的条件
-                    //TODO 按照需求,特殊化结束时间再加4天
-                    startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
-                    endLocalDate = endLocalDate.minusDays(-4);
-                    String startLocalDateStr = startLocalDate.format(formatter);
-                    String endLocalDateStr = endLocalDate.format(formatter);
-                    strSql.append(" AND \"Date\" BETWEEN  '"+startLocalDateStr+"' "+"AND '"+endLocalDateStr+"'");
-                    forDateStr = strSql.toString();
-                    startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
-                    endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
                 }
-            }catch(Exception ex){
-                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
-                        ,String.format("errorMsg:%s====>"
-                                ,ex.getLocalizedMessage()));
+            } else if (startDate != null && endDate == null) {//警告没事,增加代码可读性
+                //TODO 说明startDate传了  endDate没传 , 那么endDate为startDate月的最后一天
+                LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT))
+                        .with(TemporalAdjusters.firstDayOfMonth());
+                LocalDateTime endLocalDate = startLocalDate.with(TemporalAdjusters.lastDayOfMonth());
+                String startLocalDateStr = startLocalDate.format(formatter);
+                String endLocalDateStr = endLocalDate.format(formatter);
+                strSql.append(" AND \"date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                forDateStr = strSql.toString();
+                endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+            }
+            return true;
+        }else {
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            if (startDate == null && endDate != null) {
                 return false;
             }
-        }else
-        if(startDate!=null&&endDate==null){//警告没事,增加代码可读性
-            //TODO 说明startDate传了  endDate没传 , 那么endDate为startDate月的最后一天
-            LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT))
-                    .with(TemporalAdjusters.firstDayOfMonth());
-            LocalDateTime endLocalDate = startLocalDate.with(TemporalAdjusters.lastDayOfMonth());
-            String startLocalDateStr = startLocalDate.format(formatter);
-            String endLocalDateStr = endLocalDate.format(formatter);
-            strSql.append(" AND \"Date\" BETWEEN  '"+startLocalDateStr+"' "+"AND '"+endLocalDateStr+"'");
-            forDateStr = strSql.toString();
-            endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+            StringBuilder strSql = new StringBuilder("");
+            if (!StringUtils.isEmpty(orgId)) {
+                strSql.append(" AND \"orgId\" = '" + orgId + "'");
+            }
+            if (startDate == null && endDate == null) {
+                //TODO 说明前端没传,那么默认为当前月往前推到一号作为开始和结束条件
+                LocalDateTime nowDate = LocalDateTime.now();//结束时间
+                nowDate = nowDate.with(TemporalAdjusters.lastDayOfMonth());
+                nowDate = nowDate.withHour(0);
+                nowDate = nowDate.withMinute(0);
+                nowDate = nowDate.withSecond(0);
+
+                LocalDateTime startLocalDate = nowDate;
+                startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
+
+                String startLocalDateStr = startLocalDate.format(formatter);
+                String endLocalDateStr = nowDate.format(formatter);
+                strSql.append(" AND \"Date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                forDateStr = strSql.toString();
+                startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
+                endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+            } else if (startDate != null && endDate != null) {
+                try {
+                    LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
+                    LocalDateTime endLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(endDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT));
+//                long monthsBetween = ChronoUnit.MONTHS.between(startLocalDate, endLocalDate);
+                    if (startLocalDate.isAfter(endLocalDate)) {
+                        return false;
+                    } else if (endLocalDate.isBefore(startLocalDate)) {
+                        return false;
+                    } else if (startLocalDate.equals(endLocalDate) || startLocalDate.isBefore(endLocalDate)) {
+                        //TODO 说明符合可组成查询日期的条件
+                        //TODO 按照需求,特殊化结束时间再加4天
+                        startLocalDate = startLocalDate.with(TemporalAdjusters.firstDayOfMonth());
+                        endLocalDate = endLocalDate.minusDays(-4);
+                        String startLocalDateStr = startLocalDate.format(formatter);
+                        String endLocalDateStr = endLocalDate.format(formatter);
+                        strSql.append(" AND \"Date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                        forDateStr = strSql.toString();
+                        startDate = TimeTool.convertDateStr2UTC(startLocalDateStr);
+                        endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+                    }
+                } catch (Exception ex) {
+                    LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, "JPCustomerMeterSS", "JPCustomerMeterSS"
+                            , String.format("errorMsg:%s====>"
+                                    , ex.getLocalizedMessage()));
+                    return false;
+                }
+            } else if (startDate != null && endDate == null) {//警告没事,增加代码可读性
+                //TODO 说明startDate传了  endDate没传 , 那么endDate为startDate月的最后一天
+                LocalDateTime startLocalDate = LocalDateTime.parse(TimeTool.convertUTC2DateStr(startDate, TimeTool.TIMESTAMP_FORMAT), DateTimeFormatter.ofPattern(TimeTool.TIMESTAMP_FORMAT))
+                        .with(TemporalAdjusters.firstDayOfMonth());
+                LocalDateTime endLocalDate = startLocalDate.with(TemporalAdjusters.lastDayOfMonth());
+                String startLocalDateStr = startLocalDate.format(formatter);
+                String endLocalDateStr = endLocalDate.format(formatter);
+                strSql.append(" AND \"Date\" BETWEEN  '" + startLocalDateStr + "' " + "AND '" + endLocalDateStr + "'");
+                forDateStr = strSql.toString();
+                endDate = TimeTool.convertDateStr2UTC(endLocalDateStr);
+            }
+            return true;
         }
-        return true;
     }
 }

+ 4 - 2
src/main/resources/application.properties

@@ -145,6 +145,8 @@ cloud.data.service.address=https://119.96.165.176:9090/
 cloud.gw.service.call.password=Tri@Tech
 #数据网关服务访问地址
 cloud.gw.service.address=https://119.96.165.176:9090/
+#理工大水量调度接口地址
+cloud.3tp.water.service.address=http://111.160.8.74:10320/
 
 #工单服务的内部通信可信任口令
 cloud.task.service.call.password=Tri@Tech
@@ -157,8 +159,8 @@ cron.refresh.timer.clock=0 0-5 0 * * ?
 #每天凌晨03:00:00执行
 cron.clear.local.cache=0 0 3 * * ?
 #每隔5分钟执行一次
-cron.check.wo.dispatch.plan=0 0/5 * * * ?
-#cron.check.wo.dispatch.plan=0 * * * * ?
+#cron.check.wo.dispatch.plan=0 0/5 * * * ?
+cron.check.wo.dispatch.plan=0 * * * * ?
 
 #自来水相关
 #查询分区类型配置: