Commit 7a2b3d19 by 向延琳

看板统计信息

1 parent be7af38b
...@@ -51,6 +51,13 @@ ...@@ -51,6 +51,13 @@
<version>1.2.0-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- usercenter-api -->
<dependency>
<groupId>com.glsx</groupId>
<artifactId>ne-shield-usercenter-api</artifactId>
<version>1.2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.AlarmElectricFence; import cn.com.glsx.app.modules.entity.AlarmElectricFence;
import cn.com.glsx.app.modules.model.RangeTimeDTO;
import cn.com.glsx.app.modules.model.vo.FenceAlarmVO; import cn.com.glsx.app.modules.model.vo.FenceAlarmVO;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare; import com.glsx.plat.common.annotation.DataPermShare;
...@@ -22,4 +23,13 @@ public interface AlarmElectricFenceMapper extends CommonBaseMapper<AlarmElectric ...@@ -22,4 +23,13 @@ public interface AlarmElectricFenceMapper extends CommonBaseMapper<AlarmElectric
@DataPerm(permTable = "tv", showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
List<FenceAlarmVO> getFenceAlarmInfo(); List<FenceAlarmVO> getFenceAlarmInfo();
/**
* 获取当前用户有权限的报警数量
* @param query 查询条件
* @return 当前用户有权限的报警数量
*/
@DataPerm(showSql = true)
@DataPermShare(showSql = true)
Integer countActiveDeviceFenceAlarm(RangeTimeDTO query);
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,7 @@ import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder; ...@@ -5,6 +5,7 @@ import cn.com.glsx.app.modules.entity.VehicleDeviceWorkOrder;
import cn.com.glsx.app.modules.model.RangeTimeDTO; import cn.com.glsx.app.modules.model.RangeTimeDTO;
import cn.com.glsx.app.modules.model.param.DeviceActiveSearch; import cn.com.glsx.app.modules.model.param.DeviceActiveSearch;
import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice; import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice;
import cn.com.glsx.app.modules.model.stat.StatSearch;
import cn.com.glsx.app.modules.model.vo.DeviceVO; import cn.com.glsx.app.modules.model.vo.DeviceVO;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare; import com.glsx.plat.common.annotation.DataPermShare;
...@@ -65,7 +66,16 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> { ...@@ -65,7 +66,16 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
* *
* @return 当前用户有权限看到的激活设备总数 * @return 当前用户有权限看到的激活设备总数
*/ */
@DataPerm(showSql = true) @DataPerm(permTable = "tv", showSql = true)
@DataPermShare(showSql = true) @DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countDeviceWithAuth(RangeTimeDTO query); Integer countDeviceWithAuth(@Param("rangeTime") RangeTimeDTO rangeTime, @Param("search") StatSearch search);
/**
* 统计当前用户有权限看到的离线设备总数
*
* @return 当前用户有权限看到的激活离线总数
*/
@DataPerm(permTable = "tv", showSql = true)
@DataPermShare(linkTable = "t_vehicle", showSql = true)
Integer countOfflineDeviceWithAuth(@Param("search") StatSearch search);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.mapper; package cn.com.glsx.app.modules.mapper;
import cn.com.glsx.app.modules.entity.Vehicle; import cn.com.glsx.app.modules.entity.Vehicle;
import cn.com.glsx.app.modules.model.stat.StatSearch;
import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO; import cn.com.glsx.app.modules.model.view.VehicleDeviceDTO;
import com.glsx.plat.common.annotation.DataPerm; import com.glsx.plat.common.annotation.DataPerm;
import com.glsx.plat.common.annotation.DataPermShare; import com.glsx.plat.common.annotation.DataPermShare;
...@@ -25,6 +26,6 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> { ...@@ -25,6 +26,6 @@ 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(); Integer countDeviceWithAuth(@Param("search") StatSearch search);
} }
\ No newline at end of file \ No newline at end of file
...@@ -31,4 +31,9 @@ public class BasicSearch extends Page { ...@@ -31,4 +31,9 @@ public class BasicSearch extends Page {
@ApiModelProperty("") @ApiModelProperty("")
private String checkedUserIdsStr; private String checkedUserIdsStr;
/**
* 结清条件
*/
private String settleCondition;
} }
package cn.com.glsx.app.modules.model.stat;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper=true)
@Accessors(chain = true)
public class StatSearch extends BasicSearch {
private String statPattern;
private String statScope;
private String statBeginScope;
private String statEndScope;
private String appendSql;
private Long offlineTime;
private String offlineSnStr;
}
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.auth.model.BizDataPermission;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public abstract class AbstractCommonService {
@Autowired
protected UserApiService userApiService;
/**
* 组织树过滤业务数据
*
* @param search
*/
public void injectOrgChecked(BasicSearch search) {
if (search.getOrgId() != null) {
search.setCheckedOrgIds(Lists.newArrayList(search.getOrgId()));
userApiService.setCheckedOrgUsers(search);
}
}
/**
* 注入
*
* @param search
*/
public void injectSettled(BasicSearch search) {
List<BizDataPermission> bizDataPermissionList = ShieldContextHolder.getRoleBizDataPermissions();
if (CollectionUtils.isEmpty(bizDataPermissionList)) {
return;
}
bizDataPermissionList.forEach(bdp -> {
if (bdp.getType() == 1) {
if (bdp.getVisibility() == 1) {//可见
//设置结清标识为(结清、未结清)
search.setSettleCondition(" AND (settle_flag IN (0, 1) or settle_flag is null) ");
} else if (bdp.getVisibility() == 2) {//不可见
//设置结清标识不为结清
search.setSettleCondition(" AND (settle_flag not in (1) or settle_flag is null) ");
}
}
});
}
}
...@@ -9,23 +9,30 @@ import cn.com.glsx.app.modules.model.RangeTimeDTO; ...@@ -9,23 +9,30 @@ import cn.com.glsx.app.modules.model.RangeTimeDTO;
import cn.com.glsx.app.modules.model.param.BasicSearch; import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.app.modules.model.param.DeviceActiveSearch; import cn.com.glsx.app.modules.model.param.DeviceActiveSearch;
import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice; import cn.com.glsx.app.modules.model.stat.StatActivatedVehicleDevice;
import cn.com.glsx.app.modules.model.stat.StatSearch;
import cn.com.glsx.app.modules.model.view.LowPowerVO; import cn.com.glsx.app.modules.model.view.LowPowerVO;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO; import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.app.modules.model.vo.DeviceActiveVO; import cn.com.glsx.app.modules.model.vo.DeviceActiveVO;
import cn.com.glsx.app.modules.model.vo.FenceAlarmVO; import cn.com.glsx.app.modules.model.vo.FenceAlarmVO;
import cn.com.glsx.app.modules.model.vo.OfflineAlarmVO; import cn.com.glsx.app.modules.model.vo.OfflineAlarmVO;
import cn.com.glsx.app.modules.model.vo.TrackAlarmVO; import cn.com.glsx.app.modules.model.vo.TrackAlarmVO;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.hutool.db.Page; import cn.hutool.db.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -37,7 +44,7 @@ import java.util.stream.Collectors; ...@@ -37,7 +44,7 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
public class DashboardService { public class DashboardService extends AbstractCommonService{
@Autowired @Autowired
private VehicleDeviceMapper vehicleDeviceMapper; private VehicleDeviceMapper vehicleDeviceMapper;
...@@ -135,33 +142,48 @@ public class DashboardService { ...@@ -135,33 +142,48 @@ public class DashboardService {
} }
public StatisticalInfoVO getStatisticalInfo() { public StatisticalInfoVO getStatisticalInfo() {
StatSearch activeSearch = new StatSearch().setStatPattern("%Y-%m-%d");
injectSettled(activeSearch);
//激活设备总数 //激活设备总数
Integer totalActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO()); Integer totalActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(), activeSearch);
//车辆总数 //车辆总数
Integer totalVehicle = vehicleMapper.countDeviceWithAuth(); Integer totalVehicle = vehicleMapper.countDeviceWithAuth(activeSearch);
//今日激活
Integer todayActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(new RangeTimeDTO(DateUtil.getTodayFirstDateTimeStr(), DateUtil.getTodayLastDateTimeStr()));
//今日激活
RangeTimeDTO today = new RangeTimeDTO(DateUtil.getTodayFirstDateTimeStr(), DateUtil.getTodayLastDateTimeStr());
Integer todayActiveDevice = vehicleDeviceMapper.countDeviceWithAuth(today, activeSearch);
//断电报警
AlarmTrackRecQueryBO queryBO = new AlarmTrackRecQueryBO(); AlarmTrackRecQueryBO queryBO = new AlarmTrackRecQueryBO();
queryBO.setStartTime(DateUtil.getTodayFirstDateTimeStr()); queryBO.setStartTime(DateUtil.getTodayFirstDateTimeStr());
queryBO.setStartTime(DateUtil.getTodayLastDateTimeStr()); queryBO.setStartTime(DateUtil.getTodayLastDateTimeStr());
queryBO.setAlarmType(Constants.ALARM_TYPE_POWER_OFF); queryBO.setAlarmType(Constants.ALARM_TYPE_POWER_OFF);
//断电报警
Integer powerOffCount = alarmTrackRecMapper.countAlarmByType(queryBO); Integer powerOffCount = alarmTrackRecMapper.countAlarmByType(queryBO);
//围栏报警 //围栏报警
Integer fenceCount = alarmElectricFenceMapper.countActiveDeviceFenceAlarm(today);
//光感报警 //光感报警
queryBO.setAlarmType(Constants.ALARM_TYPE_LIGHT); queryBO.setAlarmType(Constants.ALARM_TYPE_LIGHT);
Integer lightCount = alarmTrackRecMapper.countAlarmByType(queryBO); Integer lightCount = alarmTrackRecMapper.countAlarmByType(queryBO);
//在线率 //在线率
return new StatisticalInfoVO(totalActiveDevice, String onLineRate = getOnLineRate(totalActiveDevice);
totalVehicle, return new StatisticalInfoVO(totalActiveDevice, totalVehicle, todayActiveDevice, powerOffCount, fenceCount, lightCount, onLineRate);
todayActiveDevice, }
powerOffCount,
0, public String getOnLineRate(Integer totalActiveDevice) {
lightCount, //获取不计算离线的设备列表(并同时将该设备计算为在线设备数量) by 杨林龙
""); String offlineSnWhitelist = PropertiesUtils.getProperty("uncalculated.offline.device.sns");
StatSearch offlineSearch = new StatSearch().setStatPattern("%Y-%m-%d");
injectSettled(offlineSearch);
offlineSearch.setOfflineTime(Constants.OFFLINE_TIME_OTHER);
offlineSearch.setOfflineSnStr(offlineSnWhitelist);
Integer onlineNumber = vehicleDeviceMapper.countOfflineDeviceWithAuth(offlineSearch);
//计算在线率
NumberFormat numberFormat = NumberFormat.getInstance();
return numberFormat.format((float) onlineNumber / (float) totalActiveDevice * 100);
} }
......
package cn.com.glsx.app.modules.service;
import cn.com.glsx.admin.common.enums.OrgVehicleTreeIdTag;
import cn.com.glsx.app.modules.model.param.BasicSearch;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.ApiUserService;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 用户服务
*/
@Slf4j
@Service
public class UserApiService {
@Autowired
private cn.com.glsx.usercenter.api.feign.UserService userService;
/**
* 不需要登录得开放用户服务
*/
@Autowired
private ApiUserService apiUserService;
/**
* 根据用户id查找用户信息
*
* @param userId
* @return
*/
public User getUserById(Long userId) {
R<User> userR = userService.getById(userId);
if (userR == null) {
return null;
}
User user = userR.getData(User.class);
return user;
}
/**
* 根据用户id查找上级用户信息
*
* @param userIds
* @return
*/
public Map<Long, User> getSuperiorUserMapByIds(Collection<Long> userIds) {
Map<Long, User> userMap = Maps.newHashMap();
R<List<User>> listR = userService.getSuperiorByIds(userIds);
if (listR == null) {
return userMap;
}
List<User> userList = listR.getDataList(new TypeToken<List<User>>() {
}.getType());
if (CollectionUtils.isNotEmpty(userList)) {
userMap = userList.stream().collect(Collectors.toMap(User::getMid, Function.identity()));
}
return userMap;
}
/**
* 根据用户id查找下级用户(含自己)信息
*
* @param userId
* @return
*/
public Set<Long> getSubordinateById(Long userId) {
R<Set<Long>> setR = userService.getSubordinateById(userId);
if (setR == null) {
return Sets.newHashSet();
}
return setR.getDataList(new TypeToken<Set<Long>>() {
}.getType());
}
/**
* 根据用户名称查找用户id
*
* @param username
* @return
*/
public Long getUserIdByUsername(String username) {
if (StringUtils.isNullOrEmpty(username)) {
return null;
}
R<List<User>> userR = apiUserService.findByUsername(username);
if (userR == null) {
return null;
}
Long userId = null;
List<User> userList = userR.getDataList(new TypeToken<List<User>>() {
}.getType());
if (CollectionUtils.isNotEmpty(userList) && userList.size() == 1) {
userId = userList.get(0).getId();
}
return userId;
}
/**
* 根据用户id获取用户列表
*
* @param userIds
* @return
*/
public List<User> findByUser(Set<Long> userIds) {
R<List<User>> userR = userService.findByUser(new FindUserRequest().setUserIds(userIds));
if (userR == null || !userR.isSuccess()) {
return Lists.newArrayList();
}
List<User> userList = userR.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
// @Cacheable(value = "user", key = "#userId")
// public User getUser(Long userId) {
// List<User> userList = this.findAllUser();
// Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, t -> t));
// return userMap.get(userId);
// }
/**
* 根据组织id获取用户列表
*
* @param orgIds
* @return
*/
public List<User> findAllByOrg(List<Long> orgIds) {
R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(orgIds));
if (byOrg == null || !byOrg.isSuccess()) {
return Lists.newArrayList();
}
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
/**
* 根据组织id获取用户列表-用户权限内
*
* @param orgIds
* @return
*/
public List<User> findByOrg(List<Long> orgIds) {
R<List<User>> byOrg = userService.findByOrg(new FindUserRequest().setOrgIds(orgIds));
if (byOrg == null || !byOrg.isSuccess()) {
return Lists.newArrayList();
}
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
/**
* 查找所有用户信息
*
* @return
*/
public List<User> findAllUser() {
R<List<User>> listR = userService.findAll();
if (listR == null || !listR.isSuccess()) {
return Lists.newArrayList();
}
List<User> userList = listR.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
/**
* 封装用户信息 key:用户账号 value:用户对象
*
* @return
*/
public Map<String, User> findUserMapByAccount() {
Map<String, User> userMap = Maps.newHashMap();
List<User> userList = this.findAllUser();
if (userList == null) {
return userMap;
}
//要去重,避免以后出现不同租户下允许相同账号名的需求
userMap = userList.stream().collect(Collectors.toMap(User::getAccount, Function.identity(), (o, n) -> n));
return userMap;
}
/**
* 封装用户信息 key:用户id value:用户对象
*
* @return
*/
public Map<Long, User> findUserMapByUserId() {
Map<Long, User> userMap = Maps.newHashMap();
List<User> userList = this.findAllUser();
if (userList == null) {
return userMap;
}
userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
return userMap;
}
public void setCheckedOrgUsers(BasicSearch search) {
if (CollectionUtils.isEmpty(search.getCheckedOrgIds())) {
return;
}
if (OrgVehicleTreeIdTag.USER.getTag().equals(search.getOrgType())) {
search.setCheckedUserIdsStr(StringUtils.join(search.getCheckedOrgIds().toArray(), ","));
} else {
List<User> userList = this.findAllByOrg(Lists.newArrayList(search.getCheckedOrgIds()));
if (CollectionUtils.isEmpty(userList)) {
search.setCheckedUserIdsStr("0");
} else {
search.setCheckedUserIdsStr(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
}
log.info("组织机构选中节点用户:{}", search.getCheckedUserIdsStr());
}
}
public Map<String, User> getUserListByUserIds(Set<Long> userIds) {
Map<String, User> userMapper = Maps.newHashMap();
if (CollectionUtils.isEmpty(userIds)) {
return userMapper;
}
for (Long userId : userIds) {
if (userId == null) {
continue;
}
User user = getUserById(userId);
if (user == null) {
log.info("getUserListByUserIds userId{} empty.", userId);
continue;
}
userMapper.put(user.getUsername(), user);
}
return userMapper;
}
}
...@@ -58,4 +58,22 @@ where tv.del_flag = 0 ...@@ -58,4 +58,22 @@ where tv.del_flag = 0
) )
order by taef.alarm_time desc order by taef.alarm_time desc
</select> </select>
<select id="countActiveDeviceFenceAlarm" resultType="java.lang.Integer">
select count(taef.id)
from t_alarm_electric_fence taef
inner join t_vehicle_device tvd on tvd.id = taef.vd_id
<where>
and taef.del_flag = 0
and tvd.del_flag = 0
and tvd.bind_status = 1
<if test="startTime != null">
AND taef.alarm_time <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null">
AND taef.alarm_time <![CDATA[ <= ]]> #{endTime}
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -70,10 +70,10 @@ ...@@ -70,10 +70,10 @@
and tatr.alarm_type = #{alarmType} and tatr.alarm_type = #{alarmType}
</if> </if>
<if test="startTime != null"> <if test="startTime != null">
AND tatr.create_by <![CDATA[ >= ]]> #{startTime} AND tatr.begin_time <![CDATA[ >= ]]> #{startTime}
</if> </if>
<if test="endTime != null"> <if test="endTime != null">
AND tatr.create_by <![CDATA[ <= ]]> #{endTime} AND tatr.begin_time <![CDATA[ <= ]]> #{endTime}
</if> </if>
</where> </where>
</select> </select>
......
...@@ -117,12 +117,39 @@ ...@@ -117,12 +117,39 @@
and tvd.bind_status = 1 and tvd.bind_status = 1
and tvd.del_flag = 0 and tvd.del_flag = 0
and tv.del_flag = 0 and tv.del_flag = 0
<if test="startTime != null"> <if test="rangeTime.startTime != null">
AND tvd.create_by <![CDATA[ >= ]]> #{startTime} AND tvd.created_date <![CDATA[ >= ]]> #{rangeTime.startTime}
</if> </if>
<if test="endTime != null"> <if test="rangeTime.endTime != null">
AND tvd.create_by <![CDATA[ <= ]]> #{endTime} AND tvd.created_date <![CDATA[ <= ]]> #{rangeTime.endTime}
</if>
<if test="search.appendSql != null and search.appendSql !=''">
${search.appendSql}
</if>
<if test="search.settleCondition != null and search.settleCondition !=''">
${search.settleCondition}
</if> </if>
</where> </where>
</select> </select>
<select id="countOfflineDeviceWithAuth" resultType="java.lang.Integer">
select count(tvd.id)
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device td on td.sn = tvd.sn
left join t_device_location tdl on tdl.sn = td.sn
WHERE tvd.del_flag = 0 and tv.del_flag = 0 and tvd.bind_status = 1
and ((timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{search.offlineTime} and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{search.offlineTime})
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and timestampdiff(SECOND, tdl.last_bs_time, now()) &gt; #{search.offlineTime})
or (timestampdiff(SECOND, tdl.last_gps_time, now()) &gt; #{search.offlineTime} and tdl.last_bs_time is null)
)
<if test="search.offlineSnStr != null and search.offlineSnStr != ''">
and tvd.sn not in (${search.offlineSnStr})
</if>
<if test="search.settleCondition != null and search.settleCondition != ''">
${search.settleCondition}
</if>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -89,7 +89,13 @@ ...@@ -89,7 +89,13 @@
from t_vehicle tv from t_vehicle tv
<where> <where>
and tv.del_flag = 0 and tv.del_flag = 0
and tv.validate_status = 1 <!-- and tv.validate_status = 1-->
<if test="search.appendSql != null and search.appendSql !=''">
${search.appendSql}
</if>
<if test="search.settleCondition != null and search.settleCondition !=''">
${search.settleCondition}
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.app.modules.service;
import cn.com.glsx.app.Application;
import cn.com.glsx.app.modules.model.view.StatisticalInfoVO;
import cn.com.glsx.auth.api.AuthFeignClient;
import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author xiangyanlin
* @date 2022/7/5
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DashboardServiceTest {
@Autowired
private AuthFeignClient authFeignClient;
@BeforeEach
public void runBeforeTestMethod() {
R<SyntheticUser> userR = authFeignClient.getAuthUserById(1L);
ShieldContextHolder.setUser(userR.getData(SyntheticUser.class));
}
@Autowired
private DashboardService dashboardService;
@Test
public void testGetStatisticalInfo() {
StatisticalInfoVO statisticalInfo = dashboardService.getStatisticalInfo();
System.out.println(JSON.toJSONString(statisticalInfo));
}
}
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!