764360e2 张雷

人员定位系统对接开发

1 个父辈 dad1f09b
......@@ -25,8 +25,8 @@ public class UserLocationController {
//*****************************************义乌人员定位**********************************************//
@AutoLog(value = "义乌人员定位-获取所有人员列表")
@ApiOperation(value="义乌人员定位-获取所有人员列表", notes="义乌人员定位-获取所有人员列表")
@GetMapping(value = "/getAllUser")
public Result<List<UserBaseInfo>> getAllUser() {
@GetMapping(value = "/yw/getAllUser")
public Result<List<UserBaseInfo>> getAllUserYW() {
Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
List<UserBaseInfo> list = new ArrayList<>();
ILocationService locationService = UserLocationFactory.getLocationService("YW");
......@@ -36,9 +36,10 @@ public class UserLocationController {
return result;
}
//*****************************************义乌人员定位**********************************************//
@AutoLog(value = "义乌人员定位-获取所有人员实时定位数据")
@ApiOperation(value="义乌人员定位-获取所有人员实时定位数据", notes="义乌人员定位-获取所有人员实时定位数据")
@GetMapping(value = "/getAllUserGPS")
@GetMapping(value = "/yw/getAllUserGPS")
public Result<List<UserLocation>> getAllUserGPS() {
Result<List<UserLocation>> result = new Result<List<UserLocation>>();
List<UserLocation> list = new ArrayList<>();
......@@ -51,7 +52,7 @@ public class UserLocationController {
@AutoLog(value = "义乌人员定位-获取人员历史轨迹")
@ApiOperation(value="义乌人员定位-获取人员历史轨迹", notes="义乌人员定位-获取人员历史轨迹")
@GetMapping(value = "/getUserHistory")
@GetMapping(value = "/yw/getUserHistory")
public Result<List<UserLocation>> getUserHistory(String deviceCode,String startTime,String endTime) {
Result<List<UserLocation>> result = new Result<List<UserLocation>>();
List<UserLocation> list = new ArrayList<>();
......@@ -62,4 +63,17 @@ public class UserLocationController {
return result;
}
//***********************************************************************************************//
@AutoLog(value = "余杭人员定位-获取所有人员列表")
@ApiOperation(value="余杭人员定位-获取所有人员列表", notes="余杭人员定位-获取所有人员列表")
@GetMapping(value = "/yh/getAllUser")
public Result<List<UserBaseInfo>> getAllUserBKYH() {
Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
List<UserBaseInfo> list = new ArrayList<>();
ILocationService locationService = UserLocationFactory.getLocationService("BKYH");
list = locationService.getAllUser();
result.setResult(list);
result.setSuccess(true);
return result;
}
}
......
......@@ -18,5 +18,7 @@ public class UserBaseInfo {
private String userNo;
/**人员头像*/
private String userIcon;
/**在线状态*/
private String userStatus;
}
......
package com.skua.modules.location.entity;
import lombok.Data;
/**
* 人员详细信息
*/
@Data
public class UserBaseInfoBkyhResult {
private Integer usestatus;
private Integer electricity;
private String avatar;
private String signalRssi;
private Integer type;
private String deviceId;
private String cardNo;
private String buildingId;
private String groupName;
private String phone;
private String createTime;
private String groupLurl;
private String jobNo;
private String name;
private String comment;
private Integer id;
}
......@@ -24,5 +24,6 @@ public class UserLocation {
private String floor;
/**时间*/
private String dateTime;
/**状态*/
private String userStatus;
}
......
package com.skua.modules.location.entity;
import lombok.Data;
/**
* 人员定位数据
*/
@Data
public class UserLocationBkyhResult {
private int buildingId;
private String comment;
private String deviceId;
private String floorId;
private int groupId;
private String groupName;
private String locationType;
private String name;
private String number;
private long createTime;
private long updateTime;
private String userName;
private Double x;
private Double y;
}
......@@ -12,4 +12,6 @@ public interface ILocationService {
List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime);
List<UserBaseInfo> getAllUser();
}
......
package com.skua.modules.location.service.impl;
import com.skua.modules.location.entity.UserBaseInfo;
import com.skua.modules.location.entity.UserLocation;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.skua.modules.location.entity.*;
import com.skua.modules.location.service.ILocationService;
import com.skua.modules.location.util.ChangeLocationUtils;
import com.skua.modules.location.util.MD5Util;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service("BkyhLocationService")
public class BkyhLocationServiceImpl implements ILocationService {
private static final String BLD_ID = "10";//定位系统项目ID
private static final String KEY = "f9257afea27943d7bcd7cc510f1b50dc";//定位系统秘钥
private static final String URL = "http://101.132.108.99";//人员定位测试IP地址
//**********************联通坐标***************************
private static final Double DW_B1_X = 42.8238;//定位系统B1层X坐标
private static final Double DW_B1_Y = 325.8339;//定位系统B1层Y坐标
......@@ -52,8 +56,36 @@ public class BkyhLocationServiceImpl implements ILocationService {
@Override
public List<UserLocation> getAllUserGPS() {
List<UserLocation> list = new ArrayList<>();
return list;
List<UserLocation> result = new ArrayList<>();
String get = HttpUtil.get(URL + "/api/positionByBuildingId.shtml"+"?buildingId="+BLD_ID);
JSONObject json = JSONObject.parseObject(get);
List<UserLocationBkyhResult> list = JSONObject.parseArray(json.get("data").toString(), UserLocationBkyhResult.class);
getLocationBasicInfo();//坐标转换基础信息
for (UserLocationBkyhResult realTimeLocation:list) {
long now = System.currentTimeMillis() - 300000;
if(now < realTimeLocation.getCreateTime()){
UserLocation userLocation = new UserLocation();
Map<String,Object> map = new HashMap<>();//初始化
if("B2".equals(realTimeLocation.getName())){
map = ChangeLocationUtils.changeUserLocation("B2",realTimeLocation.getX().toString(),
realTimeLocation.getY().toString(),locationBasicInfo);
realTimeLocation.setX(Double.valueOf(map.get("x").toString()));
realTimeLocation.setY(Double.valueOf(map.get("y").toString()));
}else{
map = ChangeLocationUtils.changeUserLocation("B1",realTimeLocation.getX().toString(),
realTimeLocation.getY().toString(),locationBasicInfo);
realTimeLocation.setX(Double.valueOf(map.get("x").toString()));
realTimeLocation.setY(Double.valueOf(map.get("y").toString()));
}
userLocation.setFloor(realTimeLocation.getFloorId());
userLocation.setDeviceCode(realTimeLocation.getDeviceId());
userLocation.setX(realTimeLocation.getX());
userLocation.setY(realTimeLocation.getY());
userLocation.setUserName(realTimeLocation.getUserName());
result.add(userLocation);
}
}
return result;
}
@Override
......@@ -62,9 +94,44 @@ public class BkyhLocationServiceImpl implements ILocationService {
return list;
}
public String getBuildingAllInfo() {
HashMap<String,Object> map = new HashMap<>();
String tmsp = String.valueOf(System.currentTimeMillis()/1000);
map.put("bldId",BLD_ID);
map.put("ts",tmsp);
String str = StringUtils.join(Arrays.asList(new String[]{BLD_ID,tmsp,KEY}),",")
.replace(",","");
String strMd5 = MD5Util.getMD5LowerCase(str);
map.put("sgn",strMd5);
String post = HttpUtil.post(URL+"/api/v1/buildingAllInfo.shtml",map);
return post;
}
@Override
public List<UserBaseInfo> getAllUser() {
return null;
List<UserBaseInfo> list = new ArrayList<>();
String post = getBuildingAllInfo();
JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
List<UserBaseInfoBkyhResult> userList = JSONObject.parseArray(json.get("devices").toString(), UserBaseInfoBkyhResult.class);
List<UserLocation> onLineList = getAllUserGPS();
for (UserBaseInfoBkyhResult userBaseInfoBkyhResult : userList) {
UserBaseInfo userBaseInfo = new UserBaseInfo();
String deviceCode = userBaseInfoBkyhResult.getDeviceId();
if(onLineList.size()>0){
for (UserLocation userLocation:onLineList) {
if (deviceCode.equals(userLocation.getDeviceCode())){
userBaseInfo.setUserStatus("1");
break;
}
}
}else{
userBaseInfo.setUserStatus("0");
}
userBaseInfo.setDeviceCode(userBaseInfoBkyhResult.getDeviceId());
userBaseInfo.setUserName(userBaseInfoBkyhResult.getName());
list.add(userBaseInfo);
}
return list;
}
}
......
......@@ -15,57 +15,58 @@ import java.util.Map;
@Service("YwLocationService")
public class YwLocationServiceImpl implements ILocationService {
private static final String username = "admin";//人员定位账号
private static final String password = "admin";//人员定位密码
//**********************联通坐标***************************
private static final Double DW_B1_X = 42.8238;//定位系统B1层X坐标
private static final Double DW_B1_Y = 325.8339;//定位系统B1层Y坐标
private static final Double DW_B2_X = 22.4297;//定位系统B2层X坐标
private static final Double DW_B2_Y = 330.5528;//定位系统B2层Y坐标
private static final String username = "ywsjh";//人员定位账号
private static final String password = "ywsjh@2023";//人员定位密码
private static final String url = "http://xylie.tpddns.cn:8084/YWSJH/";
//**********************人员定位坐标***************************
private static final Double DW_X = 3990.0;//定位系统层X坐标
private static final Double DW_Y = -1683.0;//定位系统层Y坐标
//**********************三维坐标***************************
private static final Double SW_B1_X = -9850.00;//三维B1层X坐标
private static final Double SW_B1_Y = -7400.00;//三维B1层Y坐标
private static final Double SW_B2_X = -9850.00;//三维B2层X坐标
private static final Double SW_B2_Y = -7430.00;//三维B2层Y坐标
private static final Double SW_X = 32218.0;//三维层X坐标
private static final Double SW_Y = 15308.0;//三维层Y坐标
//**********************比例尺***************************
private static final Double BLC_X = 43.7;//X比例尺
private static final Double BLC_Y = 43.58;//Y比例尺
//**********************旋转角度***************************
private static final Double XZJD = 34.7989;//旋转角度
private static final Double BLC = 8.13395457;//比例尺
private static final Map<String, Double> locationBasicInfo = new HashMap<>();
/**
* 坐标转换基础信息
*/
public void getLocationBasicInfo() {
locationBasicInfo.put("DW_B1_X",DW_B1_X);
locationBasicInfo.put("DW_B1_Y",DW_B1_Y);
locationBasicInfo.put("DW_B2_X",DW_B2_X);
locationBasicInfo.put("DW_B2_Y",DW_B2_Y);
locationBasicInfo.put("SW_B1_X",SW_B1_X);
locationBasicInfo.put("SW_B1_Y",SW_B1_Y);
locationBasicInfo.put("SW_B2_X",SW_B2_X);
locationBasicInfo.put("SW_B2_Y",SW_B2_Y);
locationBasicInfo.put("BLC_X",BLC_X);
locationBasicInfo.put("BLC_Y",BLC_Y);
locationBasicInfo.put("XZJD",XZJD);
locationBasicInfo.put("DW_X",DW_X);
locationBasicInfo.put("DW_Y",DW_Y);
locationBasicInfo.put("SW_X",SW_X);
locationBasicInfo.put("SW_Y",SW_Y);
locationBasicInfo.put("BLC",BLC);
}
@Override
public List<UserLocation> getAllUserGPS() {
List<UserLocation> list = new ArrayList<>();
String get = "{\n" +
HashMap<String,Object> pMap = new HashMap<>();
pMap.put("username", username);
pMap.put("password", password);
String get = HttpUtil.get(url+"open/information/getRealGps.do",pMap);
get = "{\n" +
"\"data\":\n" +
"[{\n" +
"\"empName\":\"贾伟峰\",\n" +
"\"area\":\"2\",\n" +
"\"deviceNo\":\"16a7ebee\",\n" +
"\"crossY\":\"-8438\",\n" +
"\"crossX\":\"7186\",\n" +
"\"crossY\":\"2564\",\n" +
"\"crossX\":\"1508\",\n" +
"\"longitude\":104.04438600000114,\n" +
"\"latitude\":30.630693000000115,\n" +
"\"dateTime\":\"2022-05-05 11:35:52\",\n" +
"\"layer\":\"-1\",\n" +
"\"empNo\":\"108036\",\n" +
"\"specifictype\":\"0\"\n" +
"},\n" +
"{\n" +
"\"empName\":\"宋锡园\",\n" +
"\"area\":\"2\",\n" +
"\"deviceNo\":\"169c1502\",\n" +
"\"crossY\":\"2584\",\n" +
"\"crossX\":\"1538\",\n" +
"\"longitude\":104.04438600000114,\n" +
"\"latitude\":30.630693000000115,\n" +
"\"dateTime\":\"2022-05-05 11:35:52\",\n" +
......@@ -77,8 +78,8 @@ public class YwLocationServiceImpl implements ILocationService {
"\"empName\":\"何成翔\",\n" +
"\"area\":\"2\",\n" +
"\"deviceNo\":\"169c0cba\",\n" +
"\"crossY\":\"-8312\",\n" +
"\"crossX\":\"32438\",\n" +
"\"crossY\":\"2564\",\n" +
"\"crossX\":\"2816\",\n" +
"\"longitude\":124.01230000114,\n" +
"\"latitude\":31.6301230000115,\n" +
"\"dateTime\":\"2022-05-05 11:35:52\",\n" +
......@@ -98,12 +99,10 @@ public class YwLocationServiceImpl implements ILocationService {
userLocation.setFloor(userLocationYwResult.getLayer());
userLocation.setDeviceCode(userLocationYwResult.getDeviceNo());
userLocation.setUserName(userLocationYwResult.getEmpName());
// Map<String,Object> map = ChangeLocationUtils.changeUserLocation(userLocationYwResult.getLayer(), String.valueOf(userLocationYwResult.getCrossX()),
// String.valueOf(userLocationYwResult.getCrossY()), locationBasicInfo);
// userLocation.setX(Double.valueOf(map.get("x").toString()));
// userLocation.setY(Double.valueOf(map.get("y").toString()));
userLocation.setX(userLocationYwResult.getCrossX());
userLocation.setY(userLocationYwResult.getCrossY());
Map<String,Object> map = ChangeLocationUtils.changeUserLocationNTZX(String.valueOf(userLocationYwResult.getCrossX()),
String.valueOf(userLocationYwResult.getCrossY()), locationBasicInfo);
userLocation.setX(Double.valueOf(map.get("x").toString()));
userLocation.setY(Double.valueOf(map.get("y").toString()));
userLocation.setDateTime(userLocationYwResult.getDateTime());
list.add(userLocation);
}
......@@ -113,7 +112,14 @@ public class YwLocationServiceImpl implements ILocationService {
@Override
public List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime) {
List<UserLocation> list = new ArrayList<>();
String get = "{\n" +
HashMap<String,Object> pMap = new HashMap<>();
pMap.put("username", username);
pMap.put("password", password);
pMap.put("begintime", startTime);
pMap.put("endtime", endTime);
pMap.put("deveuis", deviceCode);
String get = HttpUtil.get(url+"open/information/getHis.do",pMap);
get = "{\n" +
"\"data\":[\n" +
"{\n" +
"\"name\":\"贾伟峰\",\n" +
......@@ -141,7 +147,7 @@ public class YwLocationServiceImpl implements ILocationService {
for (UserLocationHistoryYwResult userLocationHistoryYwResult : getList) {
UserLocation userLocation = new UserLocation();
userLocation.setUserName(userLocationHistoryYwResult.getName());
Map<String,Object> map = ChangeLocationUtils.changeUserLocation("", String.valueOf(userLocationHistoryYwResult.getX()),
Map<String,Object> map = ChangeLocationUtils.changeUserLocationNTZX(String.valueOf(userLocationHistoryYwResult.getX()),
String.valueOf(userLocationHistoryYwResult.getY()), locationBasicInfo);
userLocation.setX(Double.valueOf(map.get("x").toString()));
userLocation.setY(Double.valueOf(map.get("y").toString()));
......@@ -155,12 +161,12 @@ public class YwLocationServiceImpl implements ILocationService {
public List<UserBaseInfo> getAllUser() {
List<UserBaseInfo> list = new ArrayList<>();
HashMap<String,Object> map = new HashMap<>();
map.put("username","ywsjh");
map.put("password","ywsjh@2023");
map.put("username", username);
map.put("password", password);
map.put("page",1);
map.put("rows",800);
map.put("rows",1000);
map.put("emp","");
String post = HttpUtil.get("http://xylie.tpddns.cn:8084/YWSJH/open/information/getEmp.do",map);
String post = HttpUtil.get(url+"open/information/getEmp.do",map);
JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
List<UserBaseInfoYwResult> userList = JSONObject.parseArray(json.get("rows").toString(), UserBaseInfoYwResult.class);
for (UserBaseInfoYwResult userBaseInfoYwResult : userList) {
......
......@@ -72,5 +72,37 @@ public class ChangeLocationUtils{
return map;
}
/**
* 南通在线转换坐标
* @param x1 X坐标
* @param y1 Y坐标
* @param locationBasicInfo 基础信息
* @return
*/
public static Map<String,Object> changeUserLocationNTZX(String x1, String y1, Map<String, Double> locationBasicInfo) {
y1 = "-"+y1;
double DW_X = locationBasicInfo.get("DW_X");//定位系统X坐标
double DW_Y = locationBasicInfo.get("DW_Y");//定位系统Y坐标
double SW_X = locationBasicInfo.get("SW_X");//三维X坐标
double SW_Y = locationBasicInfo.get("SW_Y");//三维Y坐标
double BLC = locationBasicInfo.get("BLC");//比例尺
Map<String,Object> map = new HashMap<>();//初始化
map.put("x", 0.00);
map.put("y", 0.00);
//平移到原点
double x0 = Double.valueOf(x1) - DW_X;
double y0 = Double.valueOf(y1) - DW_Y;
//平移后的坐标
double py_x = x0 + SW_X / BLC;
double py_y = y0 + SW_Y / BLC;
//放大后的坐标
double fd_x = BLC * py_x;
double fd_y = BLC * py_y;
map.put("x",fd_x);
map.put("y",0-fd_y);
return map;
}
}
......
package com.skua.modules.location.util;
import java.math.BigInteger;
import java.security.MessageDigest;
public class MD5Util {
/**
* 对字符串md5加密
*
* @param str 传入要加密的字符串
* @return MD5加密后的字符串(小写+字母)
*/
public static String getMD5LowerCase(String str) {
try {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(str.getBytes());
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
return new BigInteger(1, md.digest()).toString(16);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 对字符串md5加密
*
* @param s 传入要加密的字符串
* @return MD5加密后的字符串(大写+数字)
*/
public static String getMD5UpperCase(String s) {
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F' };
try {
byte[] btInput = s.getBytes();
// 获得MD5摘要算法的 MessageDigest 对象
MessageDigest mdInst = MessageDigest.getInstance("MD5");
// 使用指定的字节更新摘要
mdInst.update(btInput);
// 获得密文
byte[] md = mdInst.digest();
// 把密文转换成十六进制的字符串形式
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
String str = "\"我+Admin1234~!@#¥%……&*()\"";
System.out.println(str);
//"我+Admin1234~!@#¥%……&*()"
String s1 = getMD5LowerCase(str);
System.out.println(s1);
//6bb6f83c026357a15cdf12e5d6b2b310
String s2 = getMD5UpperCase(str);
System.out.println(s2);
//6BB6F83C026357A15CDF12E5D6B2B310
}
}
spring:
profiles:
active: prod
active: dev
# 信息安全
security:
csrf:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!