地图人员定位
parent
331e779e11
commit
84245b934c
6
pom.xml
6
pom.xml
|
@ -56,6 +56,12 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- DevTools 热部署 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class MyRedisConfig {
|
||||
|
||||
@Bean(name = "redisTemplate")
|
||||
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
|
||||
RedisTemplate redisTemplate = new RedisTemplate<>();
|
||||
////参照StringRedisTemplate内部实现指定序列化器
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
redisTemplate.setKeySerializer(keySerializer());
|
||||
redisTemplate.setHashKeySerializer(keySerializer());
|
||||
redisTemplate.setValueSerializer(valueSerializer());
|
||||
redisTemplate.setHashValueSerializer(valueSerializer());
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
private RedisSerializer keySerializer(){
|
||||
return new StringRedisSerializer();
|
||||
}
|
||||
|
||||
//使用Jackson序列化器
|
||||
private RedisSerializer valueSerializer(){
|
||||
return new StringRedisSerializer();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
import com.zcloud.plugins.websocketPositioning.PositioningServer;
|
||||
import org.java_websocket.WebSocketImpl;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
|
@ -25,6 +26,7 @@ public class StartWebsocketServer implements ApplicationRunner{
|
|||
public void run(ApplicationArguments var1) throws Exception{
|
||||
startWebsocketOnline(); //启动在线管理服务
|
||||
startWebsocketInstantMsg(); //启动即时聊天服务
|
||||
startWebsocketPositioning();
|
||||
System.out.println("-------------------系统启动成功-------------------");
|
||||
}
|
||||
|
||||
|
@ -60,4 +62,20 @@ public class StartWebsocketServer implements ApplicationRunner{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动即时人员定位推送
|
||||
*/
|
||||
public void startWebsocketPositioning(){
|
||||
WebSocketImpl.DEBUG = false;
|
||||
PositioningServer s;
|
||||
try {
|
||||
String infFilePath = PathUtil.getClasspath()+Const.SYSSET; //启动即时人员定位推送
|
||||
String positioningPort = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "positioningPort", "8899"); //启动即时人员定位推送
|
||||
s = new PositioningServer(Integer.parseInt(positioningPort));
|
||||
s.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.zcloud.controller.base.BaseController;
|
|||
import com.zcloud.entity.Page;
|
||||
import com.zcloud.entity.PageData;
|
||||
import com.zcloud.service.map.MapEightService;
|
||||
import com.zcloud.service.system.UserInfoService;
|
||||
import com.zcloud.service.system.UsersService;
|
||||
import com.zcloud.util.Jurisdiction;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -28,6 +30,8 @@ public class MapEightController extends BaseController {
|
|||
@Autowired
|
||||
private MapEightService mapEightService;
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
/**
|
||||
|
@ -186,4 +190,23 @@ public class MapEightController extends BaseController {
|
|||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动火防护措施
|
||||
*
|
||||
* @param
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/findEightsByUserCardNo")
|
||||
@ResponseBody
|
||||
public Object findEightsByUserId() throws Exception {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String errInfo = "success";
|
||||
PageData pd = new PageData();
|
||||
pd = this.getPageData();
|
||||
PageData byCardNo = usersService.findByCardNo(pd);
|
||||
map.put("INFO", byCardNo);
|
||||
map.put("result", errInfo);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,6 +105,10 @@ public class HeadController extends BaseController {
|
|||
String imPort = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "imPort", "8869"); //即时聊天端口
|
||||
map.put("wimadress", imIp+":"+imPort); //即时聊天websocket地址
|
||||
|
||||
String positioningIP = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "positioningIP", "127.0.0.1"); //即时聊天IP
|
||||
String positioningPort = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "positioningPort", "8899"); //即时聊天端口
|
||||
map.put("positioningAdress", positioningIP+":"+positioningPort); //即时聊天websocket地址
|
||||
|
||||
String alarmIp = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "alarmIp", "127.0.0.1"); //即时聊天IP
|
||||
String alarmPort = IniFileUtil.readCfgValue(infFilePath, "SysSet1", "alarmPort", "8889"); //即时聊天端口
|
||||
map.put("alarmAdress", alarmIp+":"+alarmPort); //重大危险源报警推送websocket地址
|
||||
|
@ -251,6 +255,7 @@ public class HeadController extends BaseController {
|
|||
pd.put("onlinePort", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "onlinePort", "8869")); //在线管理端口
|
||||
pd.put("imIp", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "imIp", "127.0.0.1")); //即时聊天IP
|
||||
pd.put("imPort", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "imPort", "8879")); //即时聊天端口
|
||||
pd.put("positioningPort", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "positioningPort", "8899")); //即时聊天端口
|
||||
pd.put("fhsmsSound", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "fhsmsSound", "m1")); //信息提示音
|
||||
pd.put("SMTP", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "SMTP", "smtp.qq.com")); //邮箱服务器SMTP
|
||||
pd.put("PORT", IniFileUtil.readCfgValue(infFilePath, "SysSet1", "PORT", "465")); //邮箱服务器端口
|
||||
|
|
|
@ -305,4 +305,6 @@ public interface UsersMapper {
|
|||
PageData getPersonByCardNo(PageData pd);
|
||||
|
||||
PageData findByCardNo(PageData pd);
|
||||
|
||||
void updateCardNoByPhone(String phone, String cardId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package com.zcloud.plugins.websocketPositioning;
|
||||
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.WebSocketImpl;
|
||||
import org.java_websocket.handshake.ClientHandshake;
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* 人员的定位
|
||||
*/
|
||||
public class PositioningServer extends WebSocketServer {
|
||||
|
||||
public PositioningServer(int port) {
|
||||
super(new InetSocketAddress(port));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||
PositioningServerPool.addUser(null,conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||
PositioningServerPool.remove(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(WebSocket conn, Exception ex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
public static void main( String[] args ) throws InterruptedException , IOException {
|
||||
WebSocketImpl.DEBUG = false;
|
||||
int port = 8899; //端口
|
||||
PositioningServer s = new PositioningServer(port);
|
||||
s.start();
|
||||
System.out.println( "服务器的端口" + s.getPort() );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.zcloud.plugins.websocketPositioning;
|
||||
|
||||
import org.java_websocket.WebSocket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class PositioningServerPool {
|
||||
|
||||
private static final Map<WebSocket,String> userconnections = new HashMap<WebSocket,String>();
|
||||
|
||||
/**
|
||||
* 向连接池中添加连接
|
||||
* @param inbound
|
||||
*/
|
||||
public static void addUser(String user, WebSocket conn){
|
||||
userconnections.put(conn,user); //添加连接
|
||||
}
|
||||
|
||||
/**
|
||||
* 向所有的用户发送消息
|
||||
* @param message
|
||||
*/
|
||||
public static void sendMessage(String message){
|
||||
Set<WebSocket> keySet = userconnections.keySet();
|
||||
for (WebSocket conn : keySet) {
|
||||
conn.send(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除
|
||||
* @param conn
|
||||
*/
|
||||
public static void remove(WebSocket conn){
|
||||
userconnections.remove(conn);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.zcloud.service.bus;
|
||||
|
||||
import com.zcloud.entity.PageData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PositioningService {
|
||||
|
||||
public List<String> findRedisAll();
|
||||
|
||||
void syncCardNo() throws Exception;
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.zcloud.service.bus.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zcloud.service.bus.PositioningService;
|
||||
import com.zcloud.service.system.UsersService;
|
||||
import com.zcloud.util.HttpRequestUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service(value="iPositioningServiceImpl")
|
||||
public class PositioningServiceImpl implements PositioningService {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private UsersService usersService;
|
||||
|
||||
@Override
|
||||
public List<String> findRedisAll() {
|
||||
Set<String> keys = redisTemplate.keys("*");
|
||||
return redisTemplate.opsForValue().multiGet(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncCardNo() throws Exception {
|
||||
String _response = HttpRequestUtil.doGet("https://badge.hongchuankeji.com:7812/mapi/v1/queryWorkCardLocation");
|
||||
JSONObject responseResult = JSONObject.parseObject(_response);
|
||||
JSONArray jsonArray = responseResult.getJSONArray("data");
|
||||
for (int i = 0; i < jsonArray.size() ; i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
if (
|
||||
StringUtils.isNotBlank(jsonObject.getString("phone"))
|
||||
&& StringUtils.isNotBlank(jsonObject.getString("cardId"))
|
||||
) {
|
||||
usersService.updateCardNoByPhone(jsonObject.getString("phone"), jsonObject.getString("cardId"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -364,4 +364,6 @@ public interface UsersService {
|
|||
Object getPersonPositioningStatistics(PageData pd) throws Exception;
|
||||
|
||||
Object getCurrentLocationCount(PageData pd);
|
||||
|
||||
void updateCardNoByPhone(String phone, String cardId);
|
||||
}
|
||||
|
|
|
@ -548,6 +548,11 @@ public class UsersServiceImpl implements UsersService {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCardNoByPhone(String phone, String cardId) {
|
||||
usersMapper.updateCardNoByPhone(phone, cardId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询人员在线统计数据
|
||||
* @param pd
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.zcloud.util;
|
||||
|
||||
import com.zcloud.plugins.websocketPositioning.PositioningServerPool;
|
||||
import com.zcloud.service.bus.PositioningService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class PositioningScheduled {
|
||||
|
||||
@Autowired
|
||||
private PositioningService positioningService;
|
||||
|
||||
@Scheduled(cron ="0/10 * * * * ? ")
|
||||
public void syncPositioning(){
|
||||
try {
|
||||
System.out.println("==========定时发送人员定位信息==========");
|
||||
List<String> varList = positioningService.findRedisAll();
|
||||
PositioningServerPool.sendMessage(varList.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron ="0 0 2 * * ? ") // 凌晨两点
|
||||
public void syncCardNo(){
|
||||
try {
|
||||
System.out.println("==========定时同步定位卡号==========");
|
||||
positioningService.syncCardNo();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -106,3 +106,22 @@ mq.group.docking=scheduled_tasks_docking
|
|||
base.info.USER_IDENTITY=GWJ
|
||||
base.info.baseImgPath=https://qgqy.qhdsafety.com/file/
|
||||
base.info.BACKENDADDR=http://192.168.0.31:8992/qa-regulatory-gwj/
|
||||
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.redis.database=0
|
||||
# Redis服务器地址
|
||||
spring.redis.host=39.103.224.166
|
||||
# Redis服务器连接端口
|
||||
spring.redis.port=63799
|
||||
# Redis服务器连接密码(默认为空)
|
||||
spring.redis.password=redis@zcloud88888
|
||||
# 连接池最大连接数(使用负值表示没有限制)
|
||||
spring.redis.jedis.pool.max-active=20
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
spring.redis.jedis.pool.max-wait=-1
|
||||
# 连接池中的最大空闲连接
|
||||
spring.redis.jedis.pool.max-idle=10
|
||||
# 连接池中的最小空闲连接
|
||||
spring.redis.jedis.pool.min-idle=0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.redis.timeout=1000
|
||||
|
|
|
@ -29,3 +29,8 @@ imPort=8879
|
|||
alarmIp=192.168.210.7
|
||||
;重大危险源报警推送端口
|
||||
alarmPort=8889
|
||||
|
||||
;人员定位
|
||||
alarmIp=127.0.0.1
|
||||
;人员定位
|
||||
alarmPort=8899
|
||||
|
|
|
@ -1205,6 +1205,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update sys_user set CARDNO = null where CARDNO = #{CARDNO}
|
||||
</update>
|
||||
|
||||
<update id="updateCardNoByPhone">
|
||||
update sys_user
|
||||
set CARDNO = #{cardId}
|
||||
where USERNAME = #{phone}
|
||||
</update>
|
||||
|
||||
<!-- 通过岗位ID查用户列表-->
|
||||
<select id="findByPostId" parameterType="pd" resultType="pd">
|
||||
select
|
||||
|
@ -1397,9 +1403,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.NAME as DEPARTMENT_NAME,
|
||||
p.NAME as POST_NAME
|
||||
from
|
||||
`qa-czks-prevention`.sys_user u
|
||||
left join `qa-czks-prevention`oa_department d on d.DEPARTMENT_ID = u.DEPARTMENT_ID
|
||||
left join `qa-czks-prevention`sys_post p on p.POST_ID = u.POST_ID
|
||||
sys_user u
|
||||
left join oa_department d on d.DEPARTMENT_ID = u.DEPARTMENT_ID
|
||||
left join sys_post p on p.POST_ID = u.POST_ID
|
||||
where
|
||||
u.CARDNO = #{CARDNO}
|
||||
</select>
|
||||
|
|
Loading…
Reference in New Issue