c9473d90 张雷

人员定位修改

1 个父辈 c3fb87d8
......@@ -2,6 +2,7 @@ package com.jkdata.controller;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.jkdata.entity.ThirdPosition;
import com.jkdata.service.IThirdService;
import com.jkdata.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -72,15 +73,29 @@ public class ThirdController {
}
/**
* 获取人员实时定位
* @return
*/
@GetMapping("/realTimeLocation")
public Result<ThirdPosition> getRealTimeLocation(String deviceId) {
Result<ThirdPosition> result = new Result<ThirdPosition>();
ThirdPosition thirdPosition = thirdService.getRealTimeLocation(deviceId);
result.setSuccess(true);
result.setResult(thirdPosition);
return result;
}
/**
* 获取静态资源信息
* @return
*/
@GetMapping("/buildingAllInfo")
public Result<String> getBuildingAllInfo() {
Result<String> result = new Result<String>();
public Result<JSONObject> getBuildingAllInfo() {
Result<JSONObject> result = new Result<JSONObject>();
String res = thirdService.getBuildingAllInfo();
JSONObject json = JSONObject.parseObject(res);
result.setSuccess(true);
result.setResult(res);
result.setResult(json);
return result;
}
......@@ -90,12 +105,40 @@ public class ThirdController {
* @return
*/
@GetMapping("/positionByDeviceId")
public Result<String> getPositionByDeviceId(String deviceId,String startTime,String endTime) {
Result<String> result = new Result<String>();
public Result<JSONObject> getPositionByDeviceId(String deviceId,String startTime,String endTime) {
Result<JSONObject> result = new Result<JSONObject>();
String res = thirdService.getPositionByDeviceId(deviceId, startTime, endTime);
JSONObject json = JSONObject.parseObject(res);
result.setSuccess(true);
result.setResult(json);
return result;
}
/**
* 获取告警信息-最新 n 条
* @return
*/
@GetMapping("/alarmListByCount")
public Result<JSONObject> getAlarmListByCount() {
Result<JSONObject> result = new Result<JSONObject>();
String res = thirdService.getAlarmListByCount();
JSONObject json = JSONObject.parseObject(res);
result.setSuccess(true);
result.setResult(res);
result.setResult(json);
return result;
}
/**
* 获取最近7天的告警统计数据
* @return
*/
@GetMapping("/weekAlarmState")
public Result<JSONObject> getWeekAlarmState() {
Result<JSONObject> result = new Result<JSONObject>();
String res = thirdService.getWeekAlarmState();
JSONObject json = JSONObject.parseObject(res);
result.setSuccess(true);
result.setResult(json);
return result;
}
}
......
......@@ -9,4 +9,6 @@ import org.apache.ibatis.annotations.Param;
public interface ThirdMapper extends BaseMapper<ThirdPosition> {
boolean addDataToDataBase(@Param("sql") String sql);
ThirdPosition getRealTimeLocation(@Param("deviceId")String deviceId);
}
\ No newline at end of file
......
......@@ -6,4 +6,8 @@
${sql}
</insert>
<select id="getRealTimeLocation" resultType="com.jkdata.entity.ThirdPosition">
select * from sys_cmcc_position where node_id = #{deviceId} order by create_time limit 1
</select>
</mapper>
\ No newline at end of file
......
package com.jkdata.service;
import com.alibaba.fastjson.JSONObject;
import com.jkdata.entity.ThirdPosition;
import java.util.Map;
......@@ -11,4 +12,10 @@ public interface IThirdService {
String getBuildingAllInfo();
String getPositionByDeviceId(String deviceId,String startTime,String endTime);
String getAlarmListByCount();
String getWeekAlarmState();
ThirdPosition getRealTimeLocation(String deviceId);
}
......
......@@ -70,10 +70,25 @@ public class IThirdServiceImpl implements IThirdService {
return ok;
}
public static void main(String[] args) {
String x1 = "463.7121276855469";
String y1 = "142.59878540039062";
double fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X;
double fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y;
System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
double b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y
System.out.println("偏移a:"+a+",b:"+b);
double x = Double.valueOf(fd_x) + a;
double y = Double.valueOf(fd_y) + b;
System.out.println("新坐标为:X:"+x+",Y:-"+y);
}
//B1定位坐标
private void changCoordinateB1(ThirdPosition thirdPosition) {
// String x1 = "101.1636962890625";
// String y1 = "325.2133483886719";
String x1 = thirdPosition.getPositionx();
String y1 = thirdPosition.getPositiony();
......@@ -137,15 +152,10 @@ public class IThirdServiceImpl implements IThirdService {
String tmsp = String.valueOf(System.currentTimeMillis()/1000);
map.put("bldId",CommonConstant.BLD_ID);
map.put("ts",tmsp);
String [] arr = { CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY };
Comparator<String> c = String::compareTo;
Arrays.sort(arr, c);
System.out.println("sign参数:"+Arrays.toString(arr));
String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY}),",")
.replace(",","");
System.out.println("sign参数:"+str);
String strMd5 = MD5Util.getMD5LowerCase(str);
System.out.println("加密后参数:"+str);
map.put("sgn",strMd5);
String post = HttpUtil.post(CommonConstant.BUILD_URL,map);
......@@ -156,35 +166,50 @@ public class IThirdServiceImpl implements IThirdService {
@Override
public String getPositionByDeviceId(String deviceId,String startTime,String endTime) {
HashMap<String,Object> map = new HashMap<>();
String tmsp = String.valueOf(System.currentTimeMillis()/1000);
map.put("bldId",CommonConstant.BLD_ID);
map.put("ts",tmsp);
map.put("buildingId",CommonConstant.BLD_ID);
map.put("deviceId",deviceId);
map.put("page","0");
map.put("count","200");
map.put("startTime",startTime);
map.put("endTime",endTime);
String post = HttpUtil.post(CommonConstant.HISTORY_URL,map);
return post;
}
String [] arr = { CommonConstant.BLD_ID,deviceId,startTime,endTime,"0","200",tmsp,CommonConstant.CMCC_KEY };
Comparator<String> c = String::compareTo;
Arrays.sort(arr, c);
System.out.println("sign参数:"+Arrays.toString(arr));
String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,deviceId,startTime,endTime,
"0","1000",tmsp,CommonConstant.CMCC_KEY}),",")
@Override
public String getAlarmListByCount() {
HashMap<String,Object> map = new HashMap<>();
String tmsp = String.valueOf(System.currentTimeMillis()/1000);
map.put("bldId",CommonConstant.BLD_ID);
map.put("ts",tmsp);
map.put("count","10");
String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,"10",tmsp,CommonConstant.CMCC_KEY}),",")
.replace(",","");
System.out.println("sign参数:"+str);
String strMd5 = MD5Util.getMD5LowerCase(str);
System.out.println("加密后参数:"+str);
map.put("sgn",strMd5);
String post = HttpUtil.post(CommonConstant.HISTORY_URL,map);
System.out.println("请求结果:"+post);
String post = HttpUtil.post(CommonConstant.ALARM_URL,map);
return post;
}
@Override
public String getWeekAlarmState() {
HashMap<String,Object> map = new HashMap<>();
String tmsp = String.valueOf(System.currentTimeMillis()/1000);
map.put("bldId",CommonConstant.BLD_ID);
map.put("ts",tmsp);
String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY}),",")
.replace(",","");
String strMd5 = MD5Util.getMD5LowerCase(str);
map.put("sgn",strMd5);
String post = HttpUtil.post(CommonConstant.WEEK_ALARM_URL,map);
return post;
}
@Override
public ThirdPosition getRealTimeLocation(String deviceId) {
ThirdPosition thirdPosition = new ThirdPosition();
thirdPosition = thirdMapper.getRealTimeLocation(deviceId);
return thirdPosition;
}
......
......@@ -28,15 +28,11 @@ public interface CommonConstant {
String BLD_ID = "10";//定位系统项目ID
String CMCC_KEY = "f9257afea27943d7bcd7cc510f1b50dc";//定位系统秘钥
//************************场景信息********************************
String BUILD_URL = "http://52.131.253.116/api/v1/buildingAllInfo.shtml";
//************************历史轨迹********************************
String HISTORY_URL = "http://52.131.253.116/api/positionByDeviceId.shtml";
//************************历史轨迹********************************
String ALARM_URL = "http://52.131.253.116/api/v1/alarmListByCount.shtml";
//*************************联通接口信息*******************************
String CMCC_IP = "http://52.131.253.116";//人员定位IP地址
String BUILD_URL = CMCC_IP + "/api/v1/buildingAllInfo.shtml";//场景信息
String HISTORY_URL = CMCC_IP + "/api/positionByDeviceId.shtml";//历史轨迹
String ALARM_URL = CMCC_IP + "/api/v1/alarmListByCount.shtml";//告警信息
String WEEK_ALARM_URL = CMCC_IP + "/api/v1/weekAlarmState.shtml";//获取最近7天的告警统计数据*
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!