浏览代码

分析报告

zyg 1 年之前
父节点
当前提交
b289e39496

+ 3 - 0
hz-business/src/main/java/com/hz/business/domain/AnalysisReport.java

@@ -48,6 +48,9 @@ public class AnalysisReport extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "电池编号")
     private String sn;
 
+    @ApiModelProperty(value = "电池编号")
+    private String vin;
+
     @ApiModelProperty(value = "数据集id")
     private Long dataSetId;
 

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

@@ -575,7 +575,7 @@ public class AnalysisReportServiceImpl extends ServiceImpl<AnalysisReportMapper,
                     if(one==null){
                         return null;
                     }else{
-                        newSns.add(one.getSn());
+                        newSns.add(one.getVin());
                     }
                 }
             }
@@ -1381,7 +1381,7 @@ public class AnalysisReportServiceImpl extends ServiceImpl<AnalysisReportMapper,
         String snKey = Math.abs(resultId.hashCode()) + "_" + resultId + "_";
         long timeStamp = Long.MAX_VALUE;
         builder.append("select time,").append(fields)
-                .append(" from ").append(tableName);
+                .append(" from ").append(database+"."+tableName);
 
         if (param.getStartTime() == null && param.getEndTime() == null) {
             String snKeyMin = snKey + "0";
@@ -1422,12 +1422,8 @@ 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);
-            ResultSet resultSet = psSelect.executeQuery();
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(sql);
             mapList = ResultSetToJson.toListMap(resultSet, false);
 
         } catch (Exception e) {
@@ -1459,7 +1455,7 @@ public class AnalysisReportServiceImpl extends ServiceImpl<AnalysisReportMapper,
 
         builder.append("select Time,").append(ResultSetToJson.queryParam(param.getFields())).append(" from ")
 //        builder.append("select Time,").append(param.getFields()).append(" from ")
-                .append(batteryTableName)
+                .append(database+"."+batteryTableName)
                 .append(" where ");
         if (param.getStartTime() == null && param.getEndTime() == null) {
 
@@ -1625,7 +1621,7 @@ public class AnalysisReportServiceImpl extends ServiceImpl<AnalysisReportMapper,
             String snKeyMin = snKey + "0";
             String snKeyMax = snKey + "a";
             builder.append("select id,time,").append(fields)
-                    .append(" from ").append(tableName)
+                    .append(" from ").append(database+"."+tableName)
                     .append(" where id > '")
                     .append(snKeyMin).append("' and id < '")
                     .append(snKeyMax).append("'");

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

@@ -201,12 +201,9 @@ 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 " + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
-            psSelect = conn.prepareStatement(sql);
-            ResultSet resultSet = psSelect.executeQuery();
+            String sql = "select energy,eg_rank from " + database+"."+energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(sql);
 
             List<Map<String, Object>> mapList = ResultSetToJson.toListMap(resultSet, false);
             if (mapList.size() > 0) {
@@ -324,12 +321,9 @@ 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 " + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
-            psSelect = conn.prepareStatement(sql);
-            ResultSet resultSet = psSelect.executeQuery();
+            String sql = "select energy,eg_rank from " + database+"."+energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(sql);
 
             List<Map<String, Object>> mapList = ResultSetToJson.toListMap(resultSet, false);
             if (mapList.size() > 0) {
@@ -2346,7 +2340,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
 
         // CellMaxVol,CellMinVol,CellMaxTemp,CellMinTemp,BmsCellVoltDiff,VehSpd
         builder.append("select SN,Time,PackVoltage,PackCrnt,PackSoc,CellVoltage,CellTemp,InsulationRss,Info from ")
-                .append(tableName).append(" where ");
+                .append(database+"."+tableName).append(" where ");
 
 
         if (param.getStartTime() == null && param.getEndTime() == null) {
@@ -2378,12 +2372,8 @@ 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(builder.toString());
-            ResultSet resultSet = psSelect.executeQuery();
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(builder.toString());
             flinkDataList = convertList(resultSet);
         } catch (Exception e) {
         } finally {
@@ -3751,18 +3741,13 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             String snKeyMin = snKey + "0";
             String snKeyMax = snKey + "a";
 
-            builder.append("select * from ").append(behaviorTable)
+            builder.append("select * from ").append(database+"."+behaviorTable)
                     .append(" where id >= '").append(snKeyMin)
                     .append("' and id <= '").append(snKeyMax).append("' order by id");
 
             conn = PhoenixUtils.getConnection();
-            psSelect = conn.prepareStatement(" use " + database + " ");
-            psSelect.setFetchSize(1000);
-            psSelect.execute();
-            psSelect.close();
-            psSelect = conn.prepareStatement(builder.toString());
-            ResultSet resultSet = psSelect.executeQuery();
-
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(builder.toString());
             carPowerVoList = convertCarPowerVoList(resultSet);
         } catch (Exception e) {
         } finally {

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

@@ -38,12 +38,10 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.Date;
 import java.util.concurrent.Future;
 import java.util.stream.Collectors;
 
@@ -719,7 +717,7 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetMapper, DataSet> impl
             StringBuilder builder = new StringBuilder();
 
             builder.append("select ").append(fields)
-                    .append(" from ").append(tableName)
+                    .append(" from ").append(database+"."+tableName)
                     .append(" where result_id='").append(resultId).append("'");
             if (param.getPageIndex() > 1) {
                 builder.append(" and row_id >=").append((param.getPageIndex() - 1) * param.getPageSize());
@@ -728,12 +726,8 @@ public class DataSetServiceImpl extends ServiceImpl<DataSetMapper, DataSet> impl
             builder.append(" limit 0,").append(param.getPageSize());
 
             conn = PhoenixUtils.getConnection();
-            psSelect = conn.prepareStatement(" use " + database + " ");
-            psSelect.setFetchSize(1000);
-            psSelect.execute();
-            psSelect.close();
-            psSelect = conn.prepareStatement(builder.toString());
-            ResultSet resultSet = psSelect.executeQuery();
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(builder.toString());
 
             mapList = ResultSetToJson.toListMap(resultSet, true);
         } catch (Exception e) {

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

@@ -20,10 +20,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -105,12 +102,8 @@ 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(builder.toString());
-            ResultSet resultSet = psSelect.executeQuery();
+            Statement sta = conn.createStatement();
+            ResultSet resultSet = sta.executeQuery(builder.toString());
             mapList = ResultSetToJson.toListMap(resultSet, true);
         } catch (Exception e) {
         } finally {

+ 3 - 0
hz-business/src/main/java/com/hz/business/vo/AnalysisReportResultVo.java

@@ -87,6 +87,9 @@ public class AnalysisReportResultVo implements Serializable {
     @ApiModelProperty(value = "电池编号")
     private String sn;
 
+    @ApiModelProperty(value = "VIN")
+    private String vin;
+
     @ApiModelProperty(value = "起始时间")
     @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     private Date startTime;