12-03-人员定位-再版
This commit is contained in:
@ -192,4 +192,15 @@ public class SysUserVo implements Serializable {
|
|||||||
* 纬度
|
* 纬度
|
||||||
*/
|
*/
|
||||||
private BigDecimal wd;
|
private BigDecimal wd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工种
|
||||||
|
*/
|
||||||
|
private String gz;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班组
|
||||||
|
*/
|
||||||
|
private String bz;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,8 @@ 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.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;
|
||||||
import org.dromara.system.service.impl.SysUserServiceImpl;
|
import org.dromara.system.service.impl.SysUserServiceImpl;
|
||||||
@ -46,6 +48,8 @@ public class RydwWebSocketServer {
|
|||||||
|
|
||||||
private final static GpsEquipmentSonServiceImpl gpsEquipmentSonService = SpringUtils.getBean(GpsEquipmentSonServiceImpl.class);
|
private final static GpsEquipmentSonServiceImpl gpsEquipmentSonService = SpringUtils.getBean(GpsEquipmentSonServiceImpl.class);
|
||||||
|
|
||||||
|
private final IBusProjectTeamService busProjectTeamService = SpringUtils.getBean(IBusProjectTeamService.class);
|
||||||
|
|
||||||
// 2. 静态会话存储(线程安全,项目启动时即初始化)
|
// 2. 静态会话存储(线程安全,项目启动时即初始化)
|
||||||
private static final Map<String, Session> ONLINE_SESSIONS = new ConcurrentHashMap<>();
|
private static final Map<String, Session> ONLINE_SESSIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@ -210,7 +214,7 @@ public class RydwWebSocketServer {
|
|||||||
queryWrapper.eq(SubConstructionUser::getProjectId, projectId);
|
queryWrapper.eq(SubConstructionUser::getProjectId, projectId);
|
||||||
queryWrapper.eq(StringUtils.isNotBlank(fbdwId), SubConstructionUser::getContractorId, fbdwId);
|
queryWrapper.eq(StringUtils.isNotBlank(fbdwId), SubConstructionUser::getContractorId, fbdwId);
|
||||||
queryWrapper.eq(StringUtils.isNotBlank(bzId), SubConstructionUser::getTeamId, bzId);
|
queryWrapper.eq(StringUtils.isNotBlank(bzId), SubConstructionUser::getTeamId, bzId);
|
||||||
List<SubConstructionUser> list = subConstructionUserService.list(queryWrapper);
|
List<SubConstructionUser> persons = subConstructionUserService.list(queryWrapper);
|
||||||
//获取此项目打卡范围
|
//获取此项目打卡范围
|
||||||
LambdaQueryWrapper<BusProjectPunchrange> busProjectPunchrangeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<BusProjectPunchrange> busProjectPunchrangeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
busProjectPunchrangeLambdaQueryWrapper.eq(BusProjectPunchrange::getProjectId, projectId);
|
busProjectPunchrangeLambdaQueryWrapper.eq(BusProjectPunchrange::getProjectId, projectId);
|
||||||
@ -225,7 +229,15 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("06:00",0);
|
map2.put("06:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("06:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":06:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "6:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("06:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00");
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00");
|
||||||
@ -233,7 +245,15 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("08:00",0);
|
map2.put("08:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("08:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":08:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "8:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("08:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00");
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00");
|
||||||
@ -241,7 +261,15 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("10:00",0);
|
map2.put("10:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("10:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":10:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "10:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("10:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00");
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00");
|
||||||
@ -249,7 +277,15 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("12:00",0);
|
map2.put("12:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("12:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":12:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "12:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("12:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00");
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00");
|
||||||
@ -257,7 +293,15 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("14:00",0);
|
map2.put("14:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("14:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":14:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "14:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("14:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00");
|
existsObject = RedisUtils.isExistsObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00");
|
||||||
@ -265,14 +309,30 @@ public class RydwWebSocketServer {
|
|||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("16:00",0);
|
map2.put("16:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("16:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":16:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "16:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("16:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!existsObject) {
|
if (!existsObject) {
|
||||||
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", 0, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00", 0, Duration.ofSeconds(expireSeconds));
|
||||||
map2.put("18:00",0);
|
map2.put("18:00",0);
|
||||||
}else {
|
}else {
|
||||||
map2.put("18:00",RedisUtils.getCacheObject(busProjectPunchrange.getId() + ":" + busProjectPunchrange.getPunchName() + ":18:00"));
|
//如果存在 循环找到打卡的人
|
||||||
|
Integer i = 0;
|
||||||
|
for (SubConstructionUser person : persons) {
|
||||||
|
boolean b = RedisUtils.isExistsObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + person.getSysUserId());
|
||||||
|
if ( b){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map2.put("18:00",i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String,Map> map1 = new HashMap<>();
|
Map<String,Map> map1 = new HashMap<>();
|
||||||
@ -280,22 +340,21 @@ public class RydwWebSocketServer {
|
|||||||
allValue.add(map1);
|
allValue.add(map1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zrys = 0;
|
//初始化
|
||||||
|
List<SysUserVo> gpsList = new ArrayList<>();
|
||||||
|
// int zrys = 0;
|
||||||
int ycry = 0;
|
int ycry = 0;
|
||||||
Integer dwcs = 0;
|
Integer dwcs = 0;
|
||||||
int zgry = 0;
|
int zgry = 0;
|
||||||
|
|
||||||
if (list != null && !list.isEmpty()){
|
if (persons != null && !persons.isEmpty()){
|
||||||
//初始化
|
|
||||||
List<SysUserVo> gpsList = new ArrayList<>();
|
|
||||||
//循环班组人员列表
|
//循环班组人员列表
|
||||||
for (SubConstructionUser constructionUser : list) {
|
for (SubConstructionUser constructionUser : persons) {
|
||||||
//从redis拿到缓存最新坐标
|
//从redis拿到缓存最新坐标
|
||||||
boolean existsObject = RedisUtils.isExistsObject("rydw_userId_:" + constructionUser.getSysUserId());
|
boolean existsObject = RedisUtils.isExistsObject("rydw_userId_:" + constructionUser.getSysUserId());
|
||||||
if (!existsObject){
|
if (!existsObject){
|
||||||
continue;
|
continue;
|
||||||
}else {
|
|
||||||
// zgry++;
|
|
||||||
}
|
}
|
||||||
GpsEquipmentSonBo bo = RedisUtils.getCacheObject("rydw_userId_:" + constructionUser.getSysUserId());
|
GpsEquipmentSonBo bo = RedisUtils.getCacheObject("rydw_userId_:" + constructionUser.getSysUserId());
|
||||||
GpsEquipmentSon one = gpsEquipmentSonService.getById(bo.getId());
|
GpsEquipmentSon one = gpsEquipmentSonService.getById(bo.getId());
|
||||||
@ -306,7 +365,13 @@ 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.setAvatar(1000000L);
|
sysUserVo.setGz(constructionUser.getTypeOfWork());
|
||||||
|
if (constructionUser.getTeamId() != null) {
|
||||||
|
BusProjectTeamVo teamVo = busProjectTeamService.queryById(constructionUser.getTeamId());
|
||||||
|
if (teamVo != null) {
|
||||||
|
sysUserVo.setBz(teamVo.getTeamName());
|
||||||
|
}
|
||||||
|
}
|
||||||
boolean isFind = false;
|
boolean isFind = false;
|
||||||
//循环打卡范围 判断是否是异常状态
|
//循环打卡范围 判断是否是异常状态
|
||||||
for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) {
|
for (BusProjectPunchrange busProjectPunchrange : busProjectPunchranges) {
|
||||||
@ -417,6 +482,7 @@ public class RydwWebSocketServer {
|
|||||||
//判断数据添加到redis
|
//判断数据添加到redis
|
||||||
RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds));
|
RedisUtils.setCacheObject("rydw_tj_"+busProjectPunchrange.getId() + "_" + "18:00" + "_" + constructionUser.getSysUserId(), 1, Duration.ofSeconds(expireSeconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,31 +507,31 @@ public class RydwWebSocketServer {
|
|||||||
gpsList.add(sysUserVo);
|
gpsList.add(sysUserVo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//地图实时坐标
|
|
||||||
map.put("gpsList", gpsList);
|
|
||||||
|
|
||||||
//在岗人员
|
|
||||||
map.put("zgry",zgry);
|
|
||||||
|
|
||||||
//异常人员
|
|
||||||
map.put("ycry",ycry);
|
|
||||||
|
|
||||||
//总人员数
|
|
||||||
map.put("zrys",zgry + ycry);
|
|
||||||
|
|
||||||
//定位次数
|
|
||||||
if (RedisUtils.isExistsObject("rydw_cs")){
|
|
||||||
dwcs = RedisUtils.getCacheObject("rydw_cs");
|
|
||||||
}
|
|
||||||
map.put("dwcs",dwcs);
|
|
||||||
|
|
||||||
//柱状图数据
|
|
||||||
map.put("zztsj",allValue);
|
|
||||||
|
|
||||||
//饼状图数据 区域时间段人数Map list人员列表 busProjectPunchranges打卡范围列表
|
|
||||||
map.put("bztsj",getPieData(allValue, list, busProjectPunchranges));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//在岗人员
|
||||||
|
map.put("zgry",zgry);
|
||||||
|
|
||||||
|
//异常人员
|
||||||
|
map.put("ycry",ycry);
|
||||||
|
|
||||||
|
//总人员数
|
||||||
|
map.put("zrys",zgry + ycry);
|
||||||
|
|
||||||
|
//地图实时坐标
|
||||||
|
map.put("gpsList", gpsList);
|
||||||
|
|
||||||
|
//柱状图数据
|
||||||
|
map.put("zztsj",allValue);
|
||||||
|
|
||||||
|
//饼状图数据 区域时间段人数Map list人员列表 busProjectPunchranges打卡范围列表
|
||||||
|
map.put("bztsj",getPieData(allValue, persons, busProjectPunchranges));
|
||||||
|
|
||||||
|
//定位次数
|
||||||
|
if (RedisUtils.isExistsObject("rydw_cs")){
|
||||||
|
dwcs = RedisUtils.getCacheObject("rydw_cs");
|
||||||
|
}
|
||||||
|
map.put("dwcs",dwcs);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -524,10 +590,10 @@ public class RydwWebSocketServer {
|
|||||||
//如果有则进行累加
|
//如果有则进行累加
|
||||||
countMap.put(fw.getId() + ":" + fw.getPunchName(), countMap.get(fw.getId() + ":" + fw.getPunchName()) + 1);
|
countMap.put(fw.getId() + ":" + fw.getPunchName(), countMap.get(fw.getId() + ":" + fw.getPunchName()) + 1);
|
||||||
}
|
}
|
||||||
//放一条测试数据
|
|
||||||
countMap.put("1000000:测试数据", 8);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//放一条测试数据
|
||||||
|
countMap.put("1000000:测试数据", 8);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ArrayList<>(countMap.entrySet());
|
return new ArrayList<>(countMap.entrySet());
|
||||||
|
|||||||
Reference in New Issue
Block a user