12-04-人员定位-终版-优化版之修复版
This commit is contained in:
@ -1,17 +1,15 @@
|
|||||||
package org.dromara.gps.domain.bo;
|
package org.dromara.gps.domain.bo;
|
||||||
|
|
||||||
import org.dromara.gps.domain.GpsEquipmentSon;
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
||||||
import org.dromara.common.core.validate.AddGroup;
|
|
||||||
import org.dromara.common.core.validate.EditGroup;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import jakarta.validation.constraints.*;
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.gps.domain.GpsEquipmentSon;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GPS设备定位信息业务对象 gps_equipment_son
|
* GPS设备定位信息业务对象 gps_equipment_son
|
||||||
@ -137,4 +135,14 @@ public class GpsEquipmentSonBo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long tripId;
|
private Long tripId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像地址
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.common.core.domain.dto.OssDTO;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.service.OssService;
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
@ -81,6 +83,8 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
|||||||
private IVehVehicleInfoService iVehVehicleInfoService;
|
private IVehVehicleInfoService iVehVehicleInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IVehVehicleTripService iVehVehicleTripService;
|
private IVehVehicleTripService iVehVehicleTripService;
|
||||||
|
@Autowired
|
||||||
|
private OssService ossService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IGpsSafetyUserRecordService safetyUserRecordService;
|
private IGpsSafetyUserRecordService safetyUserRecordService;
|
||||||
@ -623,6 +627,19 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
|||||||
}
|
}
|
||||||
|
|
||||||
//将打卡用户存入Redis中 过期时间为当天23:59:59
|
//将打卡用户存入Redis中 过期时间为当天23:59:59
|
||||||
|
SysUserVo sysUserVo = userService.queryById(gpsEquipment.getUserId());
|
||||||
|
if (sysUserVo != null){
|
||||||
|
if (sysUserVo.getNickName() != null) {
|
||||||
|
gpsEquipmentSonBo.setUserName(sysUserVo.getNickName());
|
||||||
|
}
|
||||||
|
if (sysUserVo.getAvatar() != null){
|
||||||
|
List<OssDTO> ossDTOS = ossService.selectByIds(sysUserVo.getAvatar().toString());
|
||||||
|
if (ossDTOS != null && !ossDTOS.isEmpty()) {
|
||||||
|
gpsEquipmentSonBo.setAvatar(ossDTOS.getFirst().getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gpsEquipmentSonBo.setCreateTime(new Date());
|
||||||
setPersonToRedis(gpsEquipmentSonBo,expireSeconds);
|
setPersonToRedis(gpsEquipmentSonBo,expireSeconds);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -203,4 +203,9 @@ public class SysUserVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String bz;
|
private String bz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头像地址
|
||||||
|
*/
|
||||||
|
private String avatarUrl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,11 +13,10 @@ import org.dromara.common.redis.utils.RedisUtils;
|
|||||||
import org.dromara.common.utils.JSTUtil;
|
import org.dromara.common.utils.JSTUtil;
|
||||||
import org.dromara.contractor.domain.SubConstructionUser;
|
import org.dromara.contractor.domain.SubConstructionUser;
|
||||||
import org.dromara.contractor.service.impl.SubConstructionUserServiceImpl;
|
import org.dromara.contractor.service.impl.SubConstructionUserServiceImpl;
|
||||||
import org.dromara.gps.domain.GpsEquipmentSon;
|
|
||||||
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
|
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
|
||||||
import org.dromara.gps.service.impl.GpsEquipmentSonServiceImpl;
|
import org.dromara.gps.service.impl.GpsEquipmentSonServiceImpl;
|
||||||
import org.dromara.project.domain.BusProjectPunchrange;
|
import org.dromara.project.domain.BusProjectPunchrange;
|
||||||
import org.dromara.project.domain.vo.projectteam.BusProjectTeamVo;
|
import org.dromara.project.domain.BusProjectTeam;
|
||||||
import org.dromara.project.service.IBusProjectTeamService;
|
import org.dromara.project.service.IBusProjectTeamService;
|
||||||
import org.dromara.project.service.impl.BusProjectPunchrangeServiceImpl;
|
import org.dromara.project.service.impl.BusProjectPunchrangeServiceImpl;
|
||||||
import org.dromara.system.domain.vo.SysUserVo;
|
import org.dromara.system.domain.vo.SysUserVo;
|
||||||
@ -221,6 +220,8 @@ public class RydwWebSocketServer {
|
|||||||
LambdaQueryWrapper<BusProjectPunchrange> busProjectPunchrangeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BusProjectPunchrange> busProjectPunchrangeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
busProjectPunchrangeLambdaQueryWrapper.eq(BusProjectPunchrange::getProjectId, projectId);
|
busProjectPunchrangeLambdaQueryWrapper.eq(BusProjectPunchrange::getProjectId, projectId);
|
||||||
List<BusProjectPunchrange> busProjectPunchranges = busProjectPunchrangeService.list(busProjectPunchrangeLambdaQueryWrapper);
|
List<BusProjectPunchrange> busProjectPunchranges = busProjectPunchrangeService.list(busProjectPunchrangeLambdaQueryWrapper);
|
||||||
|
//获取班组列表
|
||||||
|
List<BusProjectTeam> bzList = busProjectTeamService.list();
|
||||||
//通过打卡范围构建下方统计数据
|
//通过打卡范围构建下方统计数据
|
||||||
List<Map<String, Map>> allValue = new ArrayList<>();
|
List<Map<String, Map>> allValue = new ArrayList<>();
|
||||||
//初始化柱状图数据
|
//初始化柱状图数据
|
||||||
@ -235,15 +236,16 @@ public class RydwWebSocketServer {
|
|||||||
|
|
||||||
if (persons != null && !persons.isEmpty()){
|
if (persons != null && !persons.isEmpty()){
|
||||||
|
|
||||||
//循环班组人员列表
|
//循环考勤人员信息列表
|
||||||
for (SubConstructionUser constructionUser : persons) {
|
for (SubConstructionUser constructionUser : persons) {
|
||||||
//从redis拿到缓存最新坐标
|
//从redis拿到缓存最新坐标 优化:直接获取值 没有为null
|
||||||
boolean existsObject = RedisUtils.isExistsObject("rydw_userId_:" + constructionUser.getSysUserId());
|
GpsEquipmentSonBo one = RedisUtils.getCacheObject("rydw_userId_:" + constructionUser.getSysUserId());
|
||||||
if (!existsObject){
|
// boolean existsObject = RedisUtils.isExistsObject("rydw_userId_:" + constructionUser.getSysUserId());
|
||||||
|
if (one == null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GpsEquipmentSonBo bo = RedisUtils.getCacheObject("rydw_userId_:" + constructionUser.getSysUserId());
|
//这里可优化 坐标上报时存入名称
|
||||||
GpsEquipmentSon one = gpsEquipmentSonService.getById(bo.getId());
|
// GpsEquipmentSon one = gpsEquipmentSonService.getById(bo.getId());
|
||||||
|
|
||||||
if (one != null){
|
if (one != null){
|
||||||
//获取人员
|
//获取人员
|
||||||
@ -251,12 +253,20 @@ public class RydwWebSocketServer {
|
|||||||
sysUserVo.setJd(one.getLocLongitude());
|
sysUserVo.setJd(one.getLocLongitude());
|
||||||
sysUserVo.setWd(one.getLocLatitude());
|
sysUserVo.setWd(one.getLocLatitude());
|
||||||
sysUserVo.setZhdwsj(one.getCreateTime());
|
sysUserVo.setZhdwsj(one.getCreateTime());
|
||||||
|
sysUserVo.setAvatarUrl(one.getAvatar());
|
||||||
sysUserVo.setGz(constructionUser.getTypeOfWork());
|
sysUserVo.setGz(constructionUser.getTypeOfWork());
|
||||||
if (constructionUser.getTeamId() != null) {
|
//获取班组 这里做优化 先查询获取全部 然后循环找到数据
|
||||||
BusProjectTeamVo teamVo = busProjectTeamService.queryById(constructionUser.getTeamId());
|
if (constructionUser.getTeamId() != null && bzList != null && !bzList.isEmpty()) {
|
||||||
if (teamVo != null) {
|
for (BusProjectTeam team : bzList) {
|
||||||
sysUserVo.setBz(teamVo.getTeamName());
|
if (constructionUser.getTeamId().equals(team.getId())){
|
||||||
|
sysUserVo.setBz(team.getTeamName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// BusProjectTeamVo teamVo = busProjectTeamService.queryById(constructionUser.getTeamId());
|
||||||
|
// if (teamVo != null) {
|
||||||
|
// sysUserVo.setBz(teamVo.getTeamName());
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
boolean isFind = false;
|
boolean isFind = false;
|
||||||
//循环打卡范围 判断是否是异常状态
|
//循环打卡范围 判断是否是异常状态
|
||||||
@ -279,22 +289,21 @@ public class RydwWebSocketServer {
|
|||||||
//给坐标柱状图赋值
|
//给坐标柱状图赋值
|
||||||
setZztData(key,allValue,one,busProjectPunchrange,constructionUser,expireSeconds);
|
setZztData(key,allValue,one,busProjectPunchrange,constructionUser,expireSeconds);
|
||||||
}
|
}
|
||||||
|
//找到打卡范围后 赋值后 跳出循环
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//进一步判断状态
|
//进一步判断状态
|
||||||
if (sysUserVo.getZxzt() == null || sysUserVo.getZxzt().isEmpty()){
|
if (sysUserVo.getZxzt() == null || sysUserVo.getZxzt().isEmpty()){
|
||||||
if (ChatServerHandler.getOnlineUserList().contains(constructionUser.getSysUserId().toString()) && !isFind){
|
if (ChatServerHandler.getOnlineUserList().contains(constructionUser.getSysUserId().toString()) && !isFind){
|
||||||
sysUserVo.setZxzt("异常");
|
sysUserVo.setZxzt("异常");
|
||||||
|
//统计异常数
|
||||||
|
ycry++;
|
||||||
}else if (!ChatServerHandler.getOnlineUserList().contains(constructionUser.getSysUserId().toString())){
|
}else if (!ChatServerHandler.getOnlineUserList().contains(constructionUser.getSysUserId().toString())){
|
||||||
sysUserVo.setZxzt("离线");
|
sysUserVo.setZxzt("离线");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//统计异常数
|
|
||||||
if (!isFind){
|
|
||||||
ycry++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//人员级GPS坐标列表
|
//人员级GPS坐标列表
|
||||||
gpsList.add(sysUserVo);
|
gpsList.add(sysUserVo);
|
||||||
}
|
}
|
||||||
@ -366,7 +375,7 @@ public class RydwWebSocketServer {
|
|||||||
/**
|
/**
|
||||||
* 柱状图 数据
|
* 柱状图 数据
|
||||||
*/
|
*/
|
||||||
public void setZztData(String key, List<Map<String, Map>> allValue, GpsEquipmentSon one,
|
public void setZztData(String key, List<Map<String, Map>> allValue, GpsEquipmentSonBo one,
|
||||||
BusProjectPunchrange busProjectPunchrange, SubConstructionUser constructionUser, long expireSeconds) {
|
BusProjectPunchrange busProjectPunchrange, SubConstructionUser constructionUser, long expireSeconds) {
|
||||||
|
|
||||||
// 先找到对应的map,避免在循环内部多次判断
|
// 先找到对应的map,避免在循环内部多次判断
|
||||||
|
|||||||
Reference in New Issue
Block a user