|
@@ -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);
|
|
|
}
|
|
|
+ }
|
|
|
// }
|
|
|
}
|
|
|
|