7dfb2818 张雷

人员定位系统对接开发

1 个父辈 5ad3f647
package com.skua.modules.location;
import com.skua.core.context.SpringContextUtils;
import com.skua.modules.location.service.ILocationService;
public class UserLocationFactory {
public UserLocationFactory() {
}
public static ILocationService getLocationService(String locationType) {
ILocationService locationService = null;
if (locationType.equals("BKYH")) {
locationService = (ILocationService) SpringContextUtils.getBean("BkyhLocationService");
} else if (locationType.equals("YW")) {
locationService = (ILocationService)SpringContextUtils.getBean("YwLocationService");
}
return locationService;
}
}
package com.skua.modules.location.controller;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.location.UserLocationFactory;
import com.skua.modules.location.entity.UserLocation;
import com.skua.modules.location.service.ILocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags="人员定位系统对接")
@RestController
@RequestMapping("/userLocation")
public class UserLocationController {
//*****************************************义乌人员定位**********************************************//
@AutoLog(value = "义乌人员定位-获取所有人员实时定位数据")
@ApiOperation(value="义乌人员定位-获取所有人员实时定位数据", notes="义乌人员定位-获取所有人员实时定位数据")
@GetMapping(value = "/getAllUserGPS")
public Result<List<UserLocation>> getAllUserGPS() {
Result<List<UserLocation>> result = new Result<List<UserLocation>>();
List<UserLocation> list = new ArrayList<>();
ILocationService locationService = UserLocationFactory.getLocationService("YW");
list = locationService.getAllUserGPS();
result.setResult(list);
result.setSuccess(true);
return result;
}
@AutoLog(value = "义乌人员定位-获取人员历史轨迹")
@ApiOperation(value="义乌人员定位-获取人员历史轨迹", notes="义乌人员定位-获取人员历史轨迹")
@GetMapping(value = "/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<>();
ILocationService locationService = UserLocationFactory.getLocationService("YW");
list = locationService.getUserHistory(deviceCode, startTime, endTime);
result.setResult(list);
result.setSuccess(true);
return result;
}
//***********************************************************************************************//
}
package com.skua.modules.location.entity;
import lombok.Data;
/**
* 人员定位数据
*/
@Data
public class UserLocation {
/**设备编码*/
private String deviceCode;
/**人员名称*/
private String userName;
/**X坐标*/
private Double x;
/**Y坐标*/
private Double y;
/**楼层*/
private String floor;
/**时间*/
private String dateTime;
}
package com.skua.modules.location.entity;
import lombok.Data;
/**
* 人员定位数据
*/
@Data
public class UserLocationHistoryYwResult {
/**人员名称*/
private String name;
/**X坐标*/
private String x;
/**Y坐标*/
private String y;
/**经度*/
private Double lon;
/**纬度*/
private Double lat;
/**时间*/
private String time;
}
package com.skua.modules.location.entity;
import lombok.Data;
/**
* 人员定位数据
*/
@Data
public class UserLocationYwResult {
/**设备编码*/
private String deviceNo;
/**人员名称*/
private String empName;
/**员工工号*/
private String empNo;
/**X坐标*/
private Double crossX;
/**Y坐标*/
private Double crossY;
/**经度*/
private Double longitude;
/**纬度*/
private Double latitude;
/**楼层*/
private String layer;
/**时间*/
private String dateTime;
/**区域*/
private String area;
/**人员卡类型 0:员工,1:访客,2:承包商,3:物品,4:车辆,5:司机*/
private String specifictype;
}
package com.skua.modules.location.service;
import com.skua.modules.location.entity.UserLocation;
import java.util.List;
public interface ILocationService {
List<UserLocation> getAllUserGPS();
List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime);
}
package com.skua.modules.location.service.impl;
import com.skua.modules.location.entity.UserLocation;
import com.skua.modules.location.service.ILocationService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("BkyhLocationService")
public class BkyhLocationServiceImpl implements ILocationService {
//**********************联通坐标***************************
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 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 BLC_X = 43.7;//X比例尺
private static final Double BLC_Y = 43.58;//Y比例尺
//**********************旋转角度***************************
private static final Double XZJD = 64.7989;//旋转角度
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);
}
@Override
public List<UserLocation> getAllUserGPS() {
List<UserLocation> list = new ArrayList<>();
return list;
}
@Override
public List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime) {
List<UserLocation> list = new ArrayList<>();
return list;
}
}
package com.skua.modules.location.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.skua.modules.location.entity.UserLocation;
import com.skua.modules.location.entity.UserLocationYwResult;
import com.skua.modules.location.entity.UserLocationHistoryYwResult;
import com.skua.modules.location.service.ILocationService;
import com.skua.modules.location.util.ChangeLocationUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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 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 BLC_X = 43.7;//X比例尺
private static final Double BLC_Y = 43.58;//Y比例尺
//**********************旋转角度***************************
private static final Double XZJD = 34.7989;//旋转角度
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);
}
@Override
public List<UserLocation> getAllUserGPS() {
List<UserLocation> list = new ArrayList<>();
String get = "{\n" +
"\"data\":\n" +
"[{\n" +
"\"empName\":\"张小凡\",\n" +
"\"area\":\"2\",\n" +
"\"deviceNo\":\"f1843311\",\n" +
"\"crossY\":\"1100\",\n" +
"\"crossX\":\"2670\",\n" +
"\"longitude\":104.04438600000114,\n" +
"\"latitude\":30.630693000000115,\n" +
"\"dateTime\":\"2019-05-05 11:35:52\",\n" +
"\"layer\":\"1\",\n" +
"\"empNo\":\"12123\",\n" +
"\"specifictype\":\"0\"\n" +
"},\n" +
"{\n" +
"\"empName\":\"张大凡\",\n" +
"\"area\":\"2\",\n" +
"\"deviceNo\":\"f1843310\",\n" +
"\"crossY\":\"1111\",\n" +
"\"crossX\":\"2666\",\n" +
"\"longitude\":124.04438600000114,\n" +
"\"latitude\":31.630693000000115,\n" +
"\"dateTime\":\"2019-05-05 11:35:52\",\n" +
"\"layer\":\"1\",\n" +
"\"empNo\":\"12121\",\n" +
"\"specifictype\":\"0\"\n" +
"}],\n" +
"\"status\":0,\n" +
"\"msginfo\":\"接口调用成功!\"\n" +
"}";
JSONObject json = JSONObject.parseObject(get);
List<UserLocationYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationYwResult.class);
getLocationBasicInfo();//坐标转换基础信息
for (UserLocationYwResult userLocationYwResult : getList) {
UserLocation userLocation = new UserLocation();
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.setDateTime(userLocationYwResult.getDateTime());
list.add(userLocation);
}
return list;
}
@Override
public List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime) {
List<UserLocation> list = new ArrayList<>();
String get = "{\n" +
"\"data\":[\n" +
"{\n" +
"\"name\":\"何小龙\",\n" +
"\"time\":\"2020-04-20 00:02:35\",\n" +
"\"x\":\"3539.05\",\n" +
"\"y\":\"2711.93\",\n" +
"\"lat\":32.54224453987491,\n" +
"\"lon\":121.05223514735032\n" +
"},\n" +
"{\n" +
"\"name\":\"何小龙\",\n" +
"\"time\":\"2020-04-20 00:02:45\",\n" +
"\"x\":\"3536.05\",\n" +
"\"y\":\"2611.93\",\n" +
"\"lat\":32.54212353987491,\n" +
"\"lon\":121.05123514735032\n" +
"}\n" +
"],\n" +
"\"msginfo\":\"成功!\",\n" +
"\"status\":0\n" +
"}";
JSONObject json = JSONObject.parseObject(get);
List<UserLocationHistoryYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationHistoryYwResult.class);
getLocationBasicInfo();//坐标转换基础信息
for (UserLocationHistoryYwResult userLocationHistoryYwResult : getList) {
UserLocation userLocation = new UserLocation();
userLocation.setUserName(userLocationHistoryYwResult.getName());
Map<String,Object> map = ChangeLocationUtils.changeUserLocation("", 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()));
userLocation.setDateTime(userLocationHistoryYwResult.getTime());
list.add(userLocation);
}
return list;
}
}
package com.skua.modules.location.util;
import java.util.*;
public class ChangeLocationUtils{
/**
* 转换坐标
* @param floor 楼层
* @param x1 X坐标
* @param y1 Y坐标
* @param locationBasicInfo 基础信息
* @return
*/
public static Map<String,Object> changeUserLocation(String floor, String x1, String y1, Map<String, Double> locationBasicInfo) {
double DW_B1_X = locationBasicInfo.get("DW_B1_X");//定位系统B1层X坐标
double DW_B1_Y = locationBasicInfo.get("DW_B1_Y");//定位系统B1层Y坐标
double DW_B2_X = locationBasicInfo.get("DW_B2_X");//定位系统B2层X坐标
double DW_B2_Y = locationBasicInfo.get("DW_B2_Y");//定位系统B2层Y坐标
double SW_B1_X = locationBasicInfo.get("SW_B1_X");//三维B1层X坐标
double SW_B1_Y = locationBasicInfo.get("SW_B1_Y");//三维B1层Y坐标
double SW_B2_X = locationBasicInfo.get("SW_B2_X");//三维B2层X坐标
double SW_B2_Y = locationBasicInfo.get("SW_B2_Y");//三维B2层Y坐标
double BLC_X = locationBasicInfo.get("BLC_X");//X比例尺
double BLC_Y = locationBasicInfo.get("BLC_Y");//Y比例尺
double XZJD = locationBasicInfo.get("XZJD");//旋转角度
Map<String,Object> map = new HashMap<>();//初始化
map.put("x", 0.00);
map.put("y", 0.00);
double py_x = 0.00;
double py_y = 0.00;
double sin = Math.sin(XZJD);
double cos = Math.cos(XZJD);
if("B2".equals(floor)){
//平移到原点
double x0 = Double.valueOf(x1) - DW_B2_X;
double y0 = Double.valueOf(y1) - DW_B2_Y;
//旋转坐标
double x = x0*sin + y0*cos;
double y = y0*sin - x0*cos;
//平移后的坐标
py_x = x + SW_B2_X / BLC_X;
py_y = y + SW_B2_Y / BLC_Y;
}else if("B1".equals(floor)){
//平移到原点
double x0 = Double.valueOf(x1) - DW_B1_X;
double y0 = Double.valueOf(y1) - DW_B1_Y;
//旋转坐标
double x = x0*sin + y0*cos;
double y = y0*sin - x0*cos;
//平移后的坐标
py_x = x + SW_B1_X / BLC_X;
py_y = y + SW_B1_Y / BLC_Y;
}else{//位置跟B1相同
//平移到原点
double x0 = Double.valueOf(x1) - DW_B1_X;
double y0 = Double.valueOf(y1) - DW_B1_Y;
//旋转坐标
double x = x0*sin + y0*cos;
double y = y0*sin - x0*cos;
//平移后的坐标
py_x = x + SW_B1_X / BLC_X;
py_y = y + SW_B1_Y / BLC_Y;
}
//放大后的坐标
double fd_x = BLC_X * py_x;
double fd_y = BLC_Y * py_y;
map.put("x",fd_x);
map.put("y",fd_y);
return map;
}
}
......@@ -2,7 +2,9 @@ package com.skua.modules.video.controller;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.video.entity.CameraInfo;
import com.skua.modules.video.service.ITVideoService;
import com.skua.modules.video.service.VideoSteamService;
import com.skua.modules.video.vo.VideoIntegrateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -24,6 +26,8 @@ public class VideoIntegrateController {
@Autowired
private ITVideoService itVideoService;
@Autowired
private VideoSteamService videoSteamService;
/**
* 获取三方视频连接配置数据
......@@ -69,4 +73,20 @@ public class VideoIntegrateController {
result.setResult(rtsp);
return result;
}
@AutoLog(value = "获取Flv视频流")
@ApiOperation(value="获取Flv视频流", notes="获取Flv视频流")
@GetMapping(value = "/getFlv")
public Result<String> getFlv(String cameraIndexCode) {
Result<String> result = new Result<>();
try {
String rtsp = itVideoService.getRtsp(cameraIndexCode);
CameraInfo openCamera = videoSteamService.openCamera(rtsp, cameraIndexCode);
result.setSuccess(true);
result.setResult(openCamera.getFlv());
} catch (Exception e) {
result.error500("获取视频流失败");
}
return result;
}
}
......
......@@ -5,6 +5,7 @@ import java.util.Map;
import java.util.concurrent.ExecutionException;
public interface VideoSteamService {
CameraInfo openCamera(String rtsp, String token) throws ExecutionException, InterruptedException;
String closeCamera(String token);
......
......@@ -84,6 +84,7 @@ public class ShiroConfig {
//鸣启3D接口
filterChainDefinitionMap.put("/3d/**", "anon");
filterChainDefinitionMap.put("/userLocation/**", "anon");
//暂时放开表维护的shiro权限
filterChainDefinitionMap.put("/v1/expert/expertInitConfig/**", "anon");
filterChainDefinitionMap.put("/sys/sysGeneralProcess/**", "anon");
......@@ -100,6 +101,7 @@ public class ShiroConfig {
//视频对接获取视频三方配置接口,认证放开
filterChainDefinitionMap.put("/v1/sys/video/getVideoIntegrateInfo", "anon");
filterChainDefinitionMap.put("/sys/video/getRtsp", "anon");
filterChainDefinitionMap.put("/sys/video/getFlv", "anon");
//三维系统对接设备台账档案请求权限放行
filterChainDefinitionMap.put("/sys/sysCustomField/listModel", "anon");
filterChainDefinitionMap.put("/sys/sysCustomField/listHead", "anon");
......
......@@ -100,7 +100,7 @@ spring:
pg-db:
url: jdbc:postgresql://120.24.205.69:10086/postgres?useUnicode=true&characterEncoding=UTF8
username: postgres
password: server_2021_%Jksc
password: Sever@3202_Jksc$
driver-class-name: org.postgresql.Driver
#redis 配置
redis:
......@@ -157,13 +157,14 @@ skua :
collectionFrequency: 10
#视频对接相关配置
video:
ip: 222.222.110.90
port: 8899
username: jk
password: 1qaz@WSX
ip: 120.25.102.53
port: 8667
username: admin
password: xrjkauto@123
#海康威视需要填写密钥
appkey: 23259573
secretkey: 0zoBqIJeudIhgCysCe0r
appkey: 22650577
secretkey: yKovn09uAsl2NTfebzqA
streamMediaIp: 120.25.102.53
#消息推送
push:
#是否开启流程消息推送
......
......@@ -164,6 +164,7 @@ skua :
#海康威视需要填写密钥
appkey: 22650577
secretkey: yKovn09uAsl2NTfebzqA
streamMediaIp: 120.25.102.53
#消息推送
push:
#是否开启流程消息推送
......
......@@ -159,11 +159,12 @@ skua :
video:
ip: 10.0.210.204
port: 8667
username: root
password: Jkauto@123yw
username: admin
password: jkauto@123yw
#海康威视需要填写密钥
appkey: 21969915
secretkey: lQFFEBvmiMg5qeJbQenw
streamMediaIp: 10.0.210.110
#消息推送
push:
#是否开启流程消息推送
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!