zyg 1 год назад
Родитель
Сommit
93db25656c

+ 5 - 5
hz-business/src/main/java/com/hz/business/service/impl/AnalysisReportServiceImpl.java

@@ -1420,11 +1420,11 @@ public class AnalysisReportServiceImpl extends ServiceImpl<AnalysisReportMapper,
         PreparedStatement psSelect = null;
         try {
             conn = PhoenixUtils.getConnection();
-            //psSelect = conn.prepareStatement(" use " + database + " ");
-            //psSelect.setFetchSize(1000);
-            //psSelect.execute();
-            //psSelect.close();
-            psSelect = conn.prepareStatement(sql.replace(" from "," from "+ database + "."));
+            psSelect = conn.prepareStatement(" use " + database + " ");
+            psSelect.setFetchSize(1000);
+            psSelect.execute();
+            psSelect.close();
+            psSelect = conn.prepareStatement(sql);
             ResultSet resultSet = psSelect.executeQuery();
             mapList = ResultSetToJson.toListMap(resultSet, false);
 

+ 11 - 11
hz-business/src/main/java/com/hz/business/service/impl/BatteryServiceImpl.java

@@ -201,10 +201,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         //周均能耗 能耗排名
         try {
             conn = PhoenixUtils.getConnection();
-            //psSelect = conn.prepareStatement(" use " + database + " ");
-            //psSelect.setFetchSize(1000);
-            //psSelect.close();
-            String sql = "select energy,eg_rank from " + database + "." + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
+            psSelect = conn.prepareStatement(" use " + database + " ");
+            psSelect.setFetchSize(1000);
+            psSelect.close();
+            String sql = "select energy,eg_rank from " + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
             psSelect = conn.prepareStatement(sql);
             ResultSet resultSet = psSelect.executeQuery();
 
@@ -324,10 +324,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         //周均能耗 能耗排名
         try {
             conn = PhoenixUtils.getConnection();
-            /*psSelect = conn.prepareStatement(" use " + database + " ");
+            psSelect = conn.prepareStatement(" use " + database + " ");
             psSelect.setFetchSize(1000);
-            psSelect.close();*/
-            String sql = "select energy,eg_rank from " + database + "." + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
+            psSelect.close();
+            String sql = "select energy,eg_rank from " + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
             psSelect = conn.prepareStatement(sql);
             ResultSet resultSet = psSelect.executeQuery();
 
@@ -2378,10 +2378,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         PreparedStatement psSelect = null;
         try {
             conn = PhoenixUtils.getConnection();
-            //psSelect = conn.prepareStatement(" use " + database + " ");
-            //psSelect.setFetchSize(1000);
-            //psSelect.execute();
-            //psSelect.close();
+            psSelect = conn.prepareStatement(" use " + database + " ");
+            psSelect.setFetchSize(1000);
+            psSelect.execute();
+            psSelect.close();
             psSelect = conn.prepareStatement(builder.toString());
             ResultSet resultSet = psSelect.executeQuery();
             flinkDataList = convertList(resultSet);

+ 4 - 4
hz-business/src/main/java/com/hz/business/service/impl/IndustryServiceAsyncImpl.java

@@ -105,10 +105,10 @@ public class IndustryServiceAsyncImpl {
         PreparedStatement psSelect = null;
         try {
             conn = PhoenixUtils.getConnection();
-            //psSelect = conn.prepareStatement(" use " + database + " ");
-            //psSelect.setFetchSize(1000);
-            //psSelect.execute();
-            //psSelect.close();
+            psSelect = conn.prepareStatement(" use " + database + " ");
+            psSelect.setFetchSize(1000);
+            psSelect.execute();
+            psSelect.close();
             psSelect = conn.prepareStatement(builder.toString());
             ResultSet resultSet = psSelect.executeQuery();
             mapList = ResultSetToJson.toListMap(resultSet, true);

+ 12 - 4
hz-business/src/test/java/com/hz/TestLindorm.java

@@ -10,6 +10,7 @@ import java.sql.ResultSet;
 import java.sql.Statement;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
 
 @Slf4j
 public class TestLindorm {
@@ -24,7 +25,7 @@ public class TestLindorm {
         try {
             Connection conn = PhoenixUtils.getConnection();
             Statement sta = conn.createStatement();
-            String sql = "select SN,Time,PackVoltage,PackCrnt,PackSoc,CellVoltage,CellTemp,InsulationRss,Info from vehicle_analysis.ods_signal_base where  SnKey<='1959277593_09SPE010DM0111C5S0000174_9223370357526775807' and  SnKey>='1959277593_09SPE010DM0111C5S0000174_9223370357094776807' limit 2000";
+            String sql = "select Time,CellVoltage,Info from vehicle_analysis.ods_signal_base where  SnKey<='1959277593_09SPE010DM0111C5S0000174_9223370353984375807' and  SnKey>='1959277593_09SPE010DM0111C5S0000174_9223370351305976807' order by SnKey desc  limit 10000";
             ResultSet rs = sta.executeQuery(sql.toUpperCase());
             while (rs.next()) {
                 System.out.println(rs.getString("SN"));
@@ -40,11 +41,18 @@ public class TestLindorm {
     @Test
     public void getLastMonth(){
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        Calendar instance = Calendar.getInstance();
+        // 调整日期到当月第一天
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+        cal.add(Calendar.WEEK_OF_MONTH, 0);
+        cal.set(Calendar.DAY_OF_WEEK, 2);
+
+        System.out.println(sf.format(cal.getTime()));
+
+        /*Calendar instance = Calendar.getInstance();
         // 调整日期到当月第一天
         instance.set(Calendar.DAY_OF_MONTH,1);
         // 再把日期减去一天即可
-        instance.add(Calendar.DAY_OF_MONTH,-1);
-        System.out.println(sf.format(instance.getTime()));
+        instance.add(Calendar.DAY_OF_MONTH,-1);*/
     }
 }