Преглед на файлове

装机总能量为空+用户画像数据为空

zyg преди 1 година
родител
ревизия
8f227bfcb4

+ 2 - 1
hz-admin/src/main/resources/application-prod.yml

@@ -151,7 +151,8 @@ mybatis-plus:
   global-config:
     banner: false
   configuration:
-    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+#    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 
 # PageHelper分页插件

+ 11 - 8
hz-business/src/main/java/com/hz/business/controller/UserPortraitController.java

@@ -47,29 +47,32 @@ public class UserPortraitController extends BaseController {
     @Value("${oos.userChartFile:}")
     private String userChartFile;
 
+    @Value("${lindorm.database:}")
+    private String database;
+
     @Resource
     AliyunOSSUtil ossUtil;
 
     Long maxValue = Long.MAX_VALUE;
 
     String sqlone = "select soc_sp,sn,delta_soc,meancrnt,sts_flg,time_st,temp_incr,temp_max " +
-            "from algo_charging_day " +
+            "from vehicle_analysis.algo_charging_day " +
             "where id >= ? and id <= ? and sts_flg > 0 order by id desc";
 
     String sqltwo = "select soc_sp,sn,delta_soc,meancrnt,sts_flg,delta_time,time_st,time_end,temp_incr,temp_max,gps_lon,gps_lat " +
-            "from algo_charging_day " +
+            "from vehicle_analysis.algo_charging_day " +
             "where id >= ? and id <= ? order by id desc";
 
     String sqltwoStsflg = "select soc_sp,sn,delta_soc,meancrnt,sts_flg,delta_time,time_st,time_end,temp_incr,temp_max,gps_lon,gps_lat " +
-            "from algo_charging_day " +
+            "from vehicle_analysis.algo_charging_day " +
             "where id >= ? and id <= ? and sts_flg > 0 order by id desc";
 
     String sqlthree = "select id,time_st,delta_odo,delta_time " +
-            "from algo_car_day " +
+            "from vehicle_analysis.algo_car_day " +
             "where id >= ? and id <= ? and delta_odo>0 order by id desc";
 
     String sqlfour = "select id,time_st,delta_odo,delta_time,odo_sp,spd_mean,fst_acc_pls,fst_acc_mus,fst_acc_trn,ftgedrv_flg,dschrg_ah,subpwr_medn,instpwr_medn,accon_mean " +
-            "from algo_car_day " +
+            "from vehicle_analysis.algo_car_day " +
             "where id >= ? and id <= ? and delta_odo>0 order by id asc";
 
 
@@ -930,10 +933,10 @@ public class UserPortraitController extends BaseController {
             for (int a = 0; a < i; a++) {
                 List<Double> val = new ArrayList<>();
                 //平均用车里程数、平均日用车时长、充电地点数量与充电次数比例、平均充电次数、快充比例
-                val.add(days > 0 ? Double.valueOf(odoMap.get("delta_odo") / Float.valueOf(days)): 0);
-                val.add(days > 0 ?Double.valueOf(odo / days): 0);
+                val.add(days > 0 ? Double.valueOf(odoMap.get("delta_odo") / Float.valueOf(days)) : 0);
+                val.add(days > 0 ? Double.valueOf(odo / days) : 0);
                 val.add(chargingMap.get("location"));
-                val.add(days > 0 ?chargingMap.get("charging") / Float.valueOf(days) : 0);
+                val.add(days > 0 ? chargingMap.get("charging") / Float.valueOf(days) : 0);
                 val.add(chargingMap.get("fast"));
                 list.add(val);
             }

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

@@ -204,7 +204,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             //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";
+            String sql = "select energy,eg_rank from " + database + "." + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
             psSelect = conn.prepareStatement(sql);
             ResultSet resultSet = psSelect.executeQuery();
 
@@ -216,10 +216,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         } catch (Exception e) {
 
         } finally {
-            if(psSelect!=null){
+            if (psSelect != null) {
                 psSelect.close();
             }
-            if(conn!=null){
+            if (conn != null) {
                 conn.close();
             }
         }
@@ -327,7 +327,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             /*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";
+            String sql = "select energy,eg_rank from " + database + "." + energyTable + " where sn ='" + vo.getSn() + "' order by id desc limit 1";
             psSelect = conn.prepareStatement(sql);
             ResultSet resultSet = psSelect.executeQuery();
 
@@ -339,10 +339,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         } catch (Exception e) {
 
         } finally {
-            if(psSelect!=null){
+            if (psSelect != null) {
                 psSelect.close();
             }
-            if(conn!=null){
+            if (conn != null) {
                 conn.close();
             }
         }
@@ -441,11 +441,11 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         List<String> cellList = new ArrayList<>();
         List<String> packList = new ArrayList<>();
         if (!param.getBatteryModel().isEmpty()) {
-             List<BatteryModel> batteryModel = batteryModelMapper.selectList(new LambdaQueryWrapper<BatteryModel>().in(!param.getBatteryModel().isEmpty(),BatteryModel::getId,param.getBatteryModel()));
-             batteryModel.forEach(o->{
+            List<BatteryModel> batteryModel = batteryModelMapper.selectList(new LambdaQueryWrapper<BatteryModel>().in(!param.getBatteryModel().isEmpty(), BatteryModel::getId, param.getBatteryModel()));
+            batteryModel.forEach(o -> {
                 cellList.add(o.getCellModel());
                 packList.add(o.getPackModel());
-             });
+            });
         }
 
         //故障状态
@@ -646,8 +646,8 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         List<String> cellList = new ArrayList<>();
         List<String> packList = new ArrayList<>();
         if (!param.getBatteryModel().isEmpty()) {
-            List<BatteryModel> batteryModel = batteryModelMapper.selectList(new LambdaQueryWrapper<BatteryModel>().in(!param.getBatteryModel().isEmpty(),BatteryModel::getId,param.getBatteryModel()));
-            batteryModel.forEach(o->{
+            List<BatteryModel> batteryModel = batteryModelMapper.selectList(new LambdaQueryWrapper<BatteryModel>().in(!param.getBatteryModel().isEmpty(), BatteryModel::getId, param.getBatteryModel()));
+            batteryModel.forEach(o -> {
                 cellList.add(o.getCellModel());
                 packList.add(o.getPackModel());
             });
@@ -921,7 +921,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
 
         //装机总量指标
         TodayCompareOtherVo totalElectricQuantityVo = new TodayCompareOtherVo();
-        totalElectricQuantityVo.setTitle("装机总能量(GWh)");
+        totalElectricQuantityVo.setTitle("装机总能量(kWh)");
         totalElectricQuantityVo.setContent("统计所有电池的能量总和");
         setWeekMonthData(totalElectricQuantityVo, quantityItemVoList, BatteryOverviewEnum.CAPACITY.code(), today, yesterday, lastWeek, todays, yesterdays, lastWeeks, lastMonth, total);
         bsVo.setTotalElectricQuantityVo(totalElectricQuantityVo);
@@ -998,7 +998,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             }
 
             if (type == 8) {
-                bsVo.setCount(DecimalFormat.getNumberInstance().format(tod.divide(BigDecimal.valueOf(1000000L), 2, RoundingMode.HALF_UP)));
+                bsVo.setCount(DecimalFormat.getNumberInstance().format(tod.divide(BigDecimal.valueOf(1L), 2, RoundingMode.HALF_UP)));
             } else {
                 bsVo.setCount(DecimalFormat.getNumberInstance().format(tod));
             }
@@ -1007,7 +1007,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
                 percent = true;
             }
             if (percent) {
-                if(law.compareTo(BigDecimal.ZERO)!=0&&yes.compareTo(BigDecimal.ZERO)!=0&&lam.compareTo(BigDecimal.ZERO)!=0){
+                if (law.compareTo(BigDecimal.ZERO) != 0 && yes.compareTo(BigDecimal.ZERO) != 0 && lam.compareTo(BigDecimal.ZERO) != 0) {
                     bsVo.setYesterday(calculateRate(tod, yes));
                     int res;
                     bsVo.setWeek(calculateRate(tod, law));
@@ -1016,7 +1016,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
                     bsVo.setMonth(calculateRate(tod, lam));
                     res = setFlag(tod, lam);
                     bsVo.setMonthFlag(res);
-                }else{
+                } else {
                     bsVo.setWeek("0");
                     bsVo.setMonth("0");
                     bsVo.setWeekFlag(3);
@@ -1034,7 +1034,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
      * @return com.hz.business.vo.BatteryStatisticsVo
      */
     @Override
-    @Cacheable(cacheNames = "query::batteryStatisticsCache", key = "#batteryOverviewParam")
+    //@Cacheable(cacheNames = "query::batteryStatisticsCache", key = "#batteryOverviewParam")
     public BatteryStatisticsVo getBatteryStatistics(BatteryOverviewParam batteryOverviewParam) {
         BatteryStatisticsVo bsVo = new BatteryStatisticsVo();
         //改为合众车型查询
@@ -1072,7 +1072,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         currentBatteryFaultVo.setTitle("累计报警电池数(台)");
         currentBatteryFaultVo.setPrompt("累计报警电池比例(%)");
         currentBatteryFaultVo.setContent("截⽌昨⽇平台累计报警电池数及比例,比例计算方式:累计报警电池数/电池总量*100%");
-        setFaultAverageTodayVo(currentBatteryFaultVo, batteryOverviewParam,carModelList, BigDecimal.valueOf(count));
+        setFaultAverageTodayVo(currentBatteryFaultVo, batteryOverviewParam, carModelList, BigDecimal.valueOf(count));
         bsVo.setCurrentBatteryFaultVo(currentBatteryFaultVo);
         //上高压电池总量
         TodayCompareOtherVo upperHighVoltageVo = new TodayCompareOtherVo();
@@ -1099,13 +1099,13 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         return bsVo;
     }
 
-    private void setBatteryOverviewParam(BatteryOverviewParam batteryOverviewParam){
+    private void setBatteryOverviewParam(BatteryOverviewParam batteryOverviewParam) {
         List<Integer> ids = batteryOverviewParam.getBatteryModel();
-        if(!ids.isEmpty()){
+        if (!ids.isEmpty()) {
             List<BatteryModel> batteryModelList = batteryModelMapper.getBatteryModelListByIds(ids);
             List<String> cellList = new ArrayList<>();
             List<String> packList = new ArrayList<>();
-            batteryModelList.forEach(o->{
+            batteryModelList.forEach(o -> {
                 cellList.add(o.getCellModel());
                 packList.add(o.getPackModel());
             });
@@ -2346,7 +2346,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(database+"."+tableName).append(" where ");
+                .append(database + "." + tableName).append(" where ");
 
 
         if (param.getStartTime() == null && param.getEndTime() == null) {
@@ -2387,10 +2387,10 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             flinkDataList = convertList(resultSet);
         } catch (Exception e) {
         } finally {
-            if(psSelect!=null){
+            if (psSelect != null) {
                 psSelect.close();
             }
-            if(conn!=null){
+            if (conn != null) {
                 conn.close();
             }
         }
@@ -2533,7 +2533,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             if (i > 1) {
                 BigDecimal b1 = BigDecimal.valueOf(singleList.get(i).getOdo() - singleList.get(i - 1).getOdo());
                 BigDecimal b2 = BigDecimal.valueOf(Double.parseDouble(String.valueOf(singleList.get(i).getTimeSt().getTime() / (1000 * 60 * 60 * 24) - singleList.get(i - 1).getTimeSt().getTime() / (1000 * 60 * 60 * 24))));
-                if(b1.compareTo(new BigDecimal(0))!=0||b2.compareTo(new BigDecimal(0))!=0){
+                if (b1.compareTo(new BigDecimal(0)) != 0 || b2.compareTo(new BigDecimal(0)) != 0) {
                     if (b1.divide(b2, 1, RoundingMode.UP).compareTo(new BigDecimal("400.0")) > 0) {
                         singleList.remove(i);
                         i--;
@@ -3138,7 +3138,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         } catch (Exception e) {
             log.error("文件导出报错: {}", e.getMessage(), e);
         } finally {
-            if(fis!=null){
+            if (fis != null) {
                 fis.close();
             }
         }
@@ -3510,7 +3510,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         List<List<String>> cellVoltObjectDiff = new ArrayList<>();
         // 输出流
         OutputStream outputStream = null;
-        List<FlinkData> flinkDataList =null;
+        List<FlinkData> flinkDataList = null;
         String fileFinalPath = HzConfig.getUploadPath() + File.separator + param.getVin() + ".xlsx";
         File file = new File(fileFinalPath);
         try {
@@ -3637,7 +3637,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         } catch (FileNotFoundException | ParseException | SQLException e) {
             throw new RuntimeException(e);
         } finally {
-            if(outputStream!=null){
+            if (outputStream != null) {
                 outputStream.close();
             }
         }
@@ -3765,11 +3765,11 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
 
             carPowerVoList = convertCarPowerVoList(resultSet);
         } catch (Exception e) {
-        }finally {
-            if(psSelect!=null){
+        } finally {
+            if (psSelect != null) {
                 psSelect.close();
             }
-            if(conn!=null){
+            if (conn != null) {
                 conn.close();
             }
         }
@@ -3789,7 +3789,7 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             String snKeyMin = snKey + "0";
             String snKeyMax = snKey + "a";
 
-            builder.append("select id,remain_odo from ").append(database+"."+tableName);
+            builder.append("select id,remain_odo from ").append(database + "." + tableName);
             builder.append(" where id > '").append(snKeyMin).append("' and id < '")
                     .append(snKeyMax).append("'");
             builder.append(" order by id limit 1 ");
@@ -3799,11 +3799,11 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
             ResultSet resultSet = psSelect.executeQuery();
             mapList = ResultSetToJson.toListMap(resultSet, false);
         } catch (Exception e) {
-        }finally {
-            if(psSelect!=null){
+        } finally {
+            if (psSelect != null) {
                 psSelect.close();
             }
-            if(conn!=null){
+            if (conn != null) {
                 conn.close();
             }
         }
@@ -4014,78 +4014,78 @@ public class BatteryServiceImpl extends ServiceImpl<BatteryMapper, Battery> impl
         bsVo.setMonthFlag(null);
         //当日数据提前准备
 //        if (quantityItemVoList.size() > 0) {
-            BigDecimal tod = BigDecimal.ZERO;
-            BigDecimal yes = BigDecimal.ZERO;
-            BigDecimal law = BigDecimal.ZERO;
-            BigDecimal lam = BigDecimal.ZERO;
-
-            List<QuantityItemDateStaticVo> list = quantityItemVoList.stream()
-                    .filter(o -> String.valueOf(type).equals(o.getItem())).collect(Collectors.toList());
-            for (QuantityItemDateStaticVo vo : list) {
-                if (Long.valueOf(sdf.format(new Date())) > Long.valueOf(sdf2.format(new Date()))) {
-                    if (vo.getStaticDate().equals(today)) {
-                        tod = vo.getQuantity();
-                    }
-                    if (vo.getStaticDate().equals(yesterday)) {
-                        yes = vo.getQuantity();
-                    }
-                    if (vo.getStaticDate().equals(lastWeek)) {
-                        law = vo.getQuantity();
-                    }
-                } else {
-                    if (vo.getStaticDate().equals(todays)) {
-                        tod = vo.getQuantity();
-                    }
-                    if (vo.getStaticDate().equals(yesterdays)) {
-                        yes = vo.getQuantity();
-                    }
-                    if (vo.getStaticDate().equals(lastWeeks)) {
-                        law = vo.getQuantity();
-                    }
+        BigDecimal tod = BigDecimal.ZERO;
+        BigDecimal yes = BigDecimal.ZERO;
+        BigDecimal law = BigDecimal.ZERO;
+        BigDecimal lam = BigDecimal.ZERO;
+
+        List<QuantityItemDateStaticVo> list = quantityItemVoList.stream()
+                .filter(o -> String.valueOf(type).equals(o.getItem())).collect(Collectors.toList());
+        for (QuantityItemDateStaticVo vo : list) {
+            if (Long.valueOf(sdf.format(new Date())) > Long.valueOf(sdf2.format(new Date()))) {
+                if (vo.getStaticDate().equals(today)) {
+                    tod = vo.getQuantity();
                 }
-                if (vo.getStaticDate().equals(lastMonth)) {
-                    lam = vo.getQuantity();
+                if (vo.getStaticDate().equals(yesterday)) {
+                    yes = vo.getQuantity();
+                }
+                if (vo.getStaticDate().equals(lastWeek)) {
+                    law = vo.getQuantity();
                 }
-            }
-
-            if (type == 8) {
-                bsVo.setCount(DecimalFormat.getNumberInstance().format(tod.divide(BigDecimal.valueOf(1000000L), 2, RoundingMode.HALF_UP)));
             } else {
-                bsVo.setCount(DecimalFormat.getNumberInstance().format(tod));
+                if (vo.getStaticDate().equals(todays)) {
+                    tod = vo.getQuantity();
+                }
+                if (vo.getStaticDate().equals(yesterdays)) {
+                    yes = vo.getQuantity();
+                }
+                if (vo.getStaticDate().equals(lastWeeks)) {
+                    law = vo.getQuantity();
+                }
             }
-            boolean percent = false;
-            if (type.equals(BatteryOverviewEnum.ONLINE.code()) ||
-                    type.equals(BatteryOverviewEnum.ALARM.code()) ||
-                    type.equals(BatteryOverviewEnum.HIGH_VOLT.code()) ||
-                    type.equals(BatteryOverviewEnum.SOH.code()) ||
-                    type.equals(BatteryOverviewEnum.CAPACITY.code()) ||
-                    type.equals(BatteryOverviewEnum.OPERATE_VEHICLE.code())) {
-                percent = true;
+            if (vo.getStaticDate().equals(lastMonth)) {
+                lam = vo.getQuantity();
             }
-            if (percent) {
-                bsVo.setYesterday(calculatePercent(tod, BigDecimal.valueOf(total)));
+        }
+
+        if (type == 8) {
+            bsVo.setCount(DecimalFormat.getNumberInstance().format(tod.divide(BigDecimal.valueOf(1000000L), 2, RoundingMode.HALF_UP)));
+        } else {
+            bsVo.setCount(DecimalFormat.getNumberInstance().format(tod));
+        }
+        boolean percent = false;
+        if (type.equals(BatteryOverviewEnum.ONLINE.code()) ||
+                type.equals(BatteryOverviewEnum.ALARM.code()) ||
+                type.equals(BatteryOverviewEnum.HIGH_VOLT.code()) ||
+                type.equals(BatteryOverviewEnum.SOH.code()) ||
+                type.equals(BatteryOverviewEnum.CAPACITY.code()) ||
+                type.equals(BatteryOverviewEnum.OPERATE_VEHICLE.code())) {
+            percent = true;
+        }
+        if (percent) {
+            bsVo.setYesterday(calculatePercent(tod, BigDecimal.valueOf(total)));
+            int res = setFlag(tod, yes);
+            bsVo.setYesterdayFlag(res);
+        } else {
+            if (law.compareTo(BigDecimal.ZERO) != 0 && yes.compareTo(BigDecimal.ZERO) != 0 && lam.compareTo(BigDecimal.ZERO) != 0) {
+                bsVo.setYesterday(calculateRate(tod, yes));
                 int res = setFlag(tod, yes);
                 bsVo.setYesterdayFlag(res);
+                bsVo.setWeek(calculateRate(tod, law));
+                res = setFlag(tod, law);
+                bsVo.setWeekFlag(res);
+                bsVo.setMonth(calculateRate(tod, lam));
+                res = setFlag(tod, lam);
+                bsVo.setMonthFlag(res);
             } else {
-                if(law.compareTo(BigDecimal.ZERO)!=0&&yes.compareTo(BigDecimal.ZERO)!=0&&lam.compareTo(BigDecimal.ZERO)!=0){
-                    bsVo.setYesterday(calculateRate(tod, yes));
-                    int res = setFlag(tod, yes);
-                    bsVo.setYesterdayFlag(res);
-                    bsVo.setWeek(calculateRate(tod, law));
-                    res = setFlag(tod, law);
-                    bsVo.setWeekFlag(res);
-                    bsVo.setMonth(calculateRate(tod, lam));
-                    res = setFlag(tod, lam);
-                    bsVo.setMonthFlag(res);
-                }else{
-                    bsVo.setYesterday("0");
-                    bsVo.setWeek("0");
-                    bsVo.setMonth("0");
-                    bsVo.setYesterdayFlag(3);
-                    bsVo.setWeekFlag(3);
-                    bsVo.setMonthFlag(3);
-                }
+                bsVo.setYesterday("0");
+                bsVo.setWeek("0");
+                bsVo.setMonth("0");
+                bsVo.setYesterdayFlag(3);
+                bsVo.setWeekFlag(3);
+                bsVo.setMonthFlag(3);
             }
+        }
 //        }
     }