Commit 0137b204 by 向延琳

修改统计方式

1 parent fe94b97d
...@@ -30,7 +30,7 @@ public interface AlarmElectricFenceMapper extends CommonBaseMapper<AlarmElectric ...@@ -30,7 +30,7 @@ public interface AlarmElectricFenceMapper extends CommonBaseMapper<AlarmElectric
* @param query 查询条件 * @param query 查询条件
* @return 当前用户有权限的报警数量 * @return 当前用户有权限的报警数量
*/ */
@DataPerm(showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countActiveDeviceFenceAlarm(RangeTimeDTO query); List<Integer> countActiveDeviceFenceAlarm(RangeTimeDTO query);
} }
\ No newline at end of file \ No newline at end of file
...@@ -68,7 +68,7 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> { ...@@ -68,7 +68,7 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
*/ */
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countDeviceWithAuth(@Param("rangeTime") RangeTimeDTO rangeTime, @Param("search") StatSearch search); List<Integer> countDeviceWithAuth(@Param("rangeTime") RangeTimeDTO rangeTime, @Param("search") StatSearch search);
/** /**
* 统计当前用户有权限看到的离线设备总数 * 统计当前用户有权限看到的离线设备总数
...@@ -77,5 +77,5 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> { ...@@ -77,5 +77,5 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
*/ */
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countOfflineDeviceWithAuth(@Param("search") StatSearch search); List<Integer> countOfflineDeviceWithAuth(@Param("search") StatSearch search);
} }
\ No newline at end of file \ No newline at end of file
...@@ -29,7 +29,7 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> { ...@@ -29,7 +29,7 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
*/ */
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countDeviceWithAuth(@Param("search") StatSearch search); List<Integer> countDeviceWithAuth(@Param("search") StatSearch search);
VehicleDeviceDTO selectVehicleDeviceByVehicleId(@Param("vehicleId") Long vehicleId); VehicleDeviceDTO selectVehicleDeviceByVehicleId(@Param("vehicleId") Long vehicleId);
......
...@@ -163,15 +163,16 @@ public class DashboardService extends AbstractCommonService { ...@@ -163,15 +163,16 @@ public class DashboardService extends AbstractCommonService {
StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d"); StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d");
injectSettled(activeSearch); injectSettled(activeSearch);
//激活设备总数 //激活设备总数
Integer totalActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(), activeSearch); List<Integer> listActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(), activeSearch);
int totalActiveDevice = listActiveDevice.stream().reduce(0, Integer::sum);
//车辆总数 //车辆总数
Integer totalVehicle = vehicleMapper.countDeviceWithAuth(activeSearch); List<Integer> listVehicle = vehicleMapper.countDeviceWithAuth(activeSearch);
int totalVehicle = listVehicle.stream().reduce(0, Integer::sum);
//今日激活 //今日激活
RangeTimeDTO today = new RangeTimeDTO(DateUtil.getTodayFirstDateTimeStr(), DateUtil.getTodayLastDateTimeStr()); RangeTimeDTO today = new RangeTimeDTO(DateUtil.getTodayFirstDateTimeStr(), DateUtil.getTodayLastDateTimeStr());
Integer todayActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(today, activeSearch); List<Integer> listTodayActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(today, activeSearch);
int todayActiveDevice = listTodayActiveDevice.stream().reduce(0, Integer::sum);
//在线率 //在线率
String onLineRate = getOnLineRate(totalActiveDevice); String onLineRate = getOnLineRate(totalActiveDevice);
...@@ -189,7 +190,8 @@ public class DashboardService extends AbstractCommonService { ...@@ -189,7 +190,8 @@ public class DashboardService extends AbstractCommonService {
Integer lightCount = remoteAlarmService.getAlarmCount(query); Integer lightCount = remoteAlarmService.getAlarmCount(query);
//围栏报警 //围栏报警
Integer fenceCount = alarmElectricFenceMapper.countActiveDeviceFenceAlarm(today); List<Integer> fenceList = alarmElectricFenceMapper.countActiveDeviceFenceAlarm(today);
int fenceCount = fenceList.stream().reduce(0, Integer::sum);
return new StatisticalInfoVO(totalActiveDevice, totalVehicle, todayActiveDevice, powerOffCount, fenceCount, lightCount, onLineRate); return new StatisticalInfoVO(totalActiveDevice, totalVehicle, todayActiveDevice, powerOffCount, fenceCount, lightCount, onLineRate);
} }
...@@ -200,7 +202,8 @@ public class DashboardService extends AbstractCommonService { ...@@ -200,7 +202,8 @@ public class DashboardService extends AbstractCommonService {
injectSettled(offlineSearch); injectSettled(offlineSearch);
offlineSearch.setOfflineTime(Constants.OFFLINE_TIME_OTHER); offlineSearch.setOfflineTime(Constants.OFFLINE_TIME_OTHER);
offlineSearch.setOfflineSnStr(offlineSnWhitelist); offlineSearch.setOfflineSnStr(offlineSnWhitelist);
Integer allOfflineNumber = vehicleDeviceMapper.countOfflineDeviceWithAuth(offlineSearch); List<Integer> allOfflineList = vehicleDeviceMapper.countOfflineDeviceWithAuth(offlineSearch);
int allOfflineNumber = allOfflineList.stream().reduce(0, Integer::sum);
int onlineNumber = Math.abs(totalActiveDevice - allOfflineNumber); int onlineNumber = Math.abs(totalActiveDevice - allOfflineNumber);
//计算在线率 //计算在线率
NumberFormat numberFormat = NumberFormat.getInstance(); NumberFormat numberFormat = NumberFormat.getInstance();
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
from t_alarm_electric_fence taef from t_alarm_electric_fence taef
left join t_electric_fence tef on tef.id = taef.fence_id left join t_electric_fence tef on tef.id = taef.fence_id
inner join t_vehicle_device tvd on tvd.id = taef.vd_id inner join t_vehicle_device tvd on tvd.id = taef.vd_id
left join t_vehicle tv on tv.id = tvd.vehicle_id
<where> <where>
and taef.del_flag = 0 and taef.del_flag = 0
and tef.del_flag = 0 and tef.del_flag = 0
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!