Commit 0137b204 by 向延琳

修改统计方式

1 parent fe94b97d
......@@ -30,7 +30,7 @@ public interface AlarmElectricFenceMapper extends CommonBaseMapper<AlarmElectric
* @param query 查询条件
* @return 当前用户有权限的报警数量
*/
@DataPerm(showSql = true)
@DataPermShare(showSql = true)
Integer countActiveDeviceFenceAlarm(RangeTimeDTO query);
@DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true)
List<Integer> countActiveDeviceFenceAlarm(RangeTimeDTO query);
}
\ No newline at end of file
......@@ -68,7 +68,7 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
*/
@DataPerm(permTable = "tv", 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> {
*/
@DataPerm(permTable = "tv", 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
......@@ -29,7 +29,7 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
*/
@DataPerm(permTable = "tv", 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);
......
......@@ -163,15 +163,16 @@ public class DashboardService extends AbstractCommonService {
StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d");
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());
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);
......@@ -189,7 +190,8 @@ public class DashboardService extends AbstractCommonService {
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);
}
......@@ -200,7 +202,8 @@ public class DashboardService extends AbstractCommonService {
injectSettled(offlineSearch);
offlineSearch.setOfflineTime(Constants.OFFLINE_TIME_OTHER);
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);
//计算在线率
NumberFormat numberFormat = NumberFormat.getInstance();
......
......@@ -63,6 +63,7 @@
from t_alarm_electric_fence taef
left join t_electric_fence tef on tef.id = taef.fence_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>
and taef.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!