c9473d90 张雷

人员定位修改

1 个父辈 c3fb87d8
...@@ -2,6 +2,7 @@ package com.jkdata.controller; ...@@ -2,6 +2,7 @@ package com.jkdata.controller;
2 2
3 import cn.hutool.http.HttpUtil; 3 import cn.hutool.http.HttpUtil;
4 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
5 import com.jkdata.entity.ThirdPosition;
5 import com.jkdata.service.IThirdService; 6 import com.jkdata.service.IThirdService;
6 import com.jkdata.tool.Result; 7 import com.jkdata.tool.Result;
7 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
...@@ -72,15 +73,29 @@ public class ThirdController { ...@@ -72,15 +73,29 @@ public class ThirdController {
72 } 73 }
73 74
74 /** 75 /**
76 * 获取人员实时定位
77 * @return
78 */
79 @GetMapping("/realTimeLocation")
80 public Result<ThirdPosition> getRealTimeLocation(String deviceId) {
81 Result<ThirdPosition> result = new Result<ThirdPosition>();
82 ThirdPosition thirdPosition = thirdService.getRealTimeLocation(deviceId);
83 result.setSuccess(true);
84 result.setResult(thirdPosition);
85 return result;
86 }
87
88 /**
75 * 获取静态资源信息 89 * 获取静态资源信息
76 * @return 90 * @return
77 */ 91 */
78 @GetMapping("/buildingAllInfo") 92 @GetMapping("/buildingAllInfo")
79 public Result<String> getBuildingAllInfo() { 93 public Result<JSONObject> getBuildingAllInfo() {
80 Result<String> result = new Result<String>(); 94 Result<JSONObject> result = new Result<JSONObject>();
81 String res = thirdService.getBuildingAllInfo(); 95 String res = thirdService.getBuildingAllInfo();
96 JSONObject json = JSONObject.parseObject(res);
82 result.setSuccess(true); 97 result.setSuccess(true);
83 result.setResult(res); 98 result.setResult(json);
84 return result; 99 return result;
85 } 100 }
86 101
...@@ -90,12 +105,40 @@ public class ThirdController { ...@@ -90,12 +105,40 @@ public class ThirdController {
90 * @return 105 * @return
91 */ 106 */
92 @GetMapping("/positionByDeviceId") 107 @GetMapping("/positionByDeviceId")
93 public Result<String> getPositionByDeviceId(String deviceId,String startTime,String endTime) { 108 public Result<JSONObject> getPositionByDeviceId(String deviceId,String startTime,String endTime) {
94 Result<String> result = new Result<String>(); 109 Result<JSONObject> result = new Result<JSONObject>();
95 String res = thirdService.getPositionByDeviceId(deviceId, startTime, endTime); 110 String res = thirdService.getPositionByDeviceId(deviceId, startTime, endTime);
111 JSONObject json = JSONObject.parseObject(res);
112 result.setSuccess(true);
113 result.setResult(json);
114 return result;
115 }
116
117 /**
118 * 获取告警信息-最新 n 条
119 * @return
120 */
121 @GetMapping("/alarmListByCount")
122 public Result<JSONObject> getAlarmListByCount() {
123 Result<JSONObject> result = new Result<JSONObject>();
124 String res = thirdService.getAlarmListByCount();
125 JSONObject json = JSONObject.parseObject(res);
96 result.setSuccess(true); 126 result.setSuccess(true);
97 result.setResult(res); 127 result.setResult(json);
98 return result; 128 return result;
99 } 129 }
100 130
131 /**
132 * 获取最近7天的告警统计数据
133 * @return
134 */
135 @GetMapping("/weekAlarmState")
136 public Result<JSONObject> getWeekAlarmState() {
137 Result<JSONObject> result = new Result<JSONObject>();
138 String res = thirdService.getWeekAlarmState();
139 JSONObject json = JSONObject.parseObject(res);
140 result.setSuccess(true);
141 result.setResult(json);
142 return result;
143 }
101 } 144 }
......
...@@ -9,4 +9,6 @@ import org.apache.ibatis.annotations.Param; ...@@ -9,4 +9,6 @@ import org.apache.ibatis.annotations.Param;
9 public interface ThirdMapper extends BaseMapper<ThirdPosition> { 9 public interface ThirdMapper extends BaseMapper<ThirdPosition> {
10 10
11 boolean addDataToDataBase(@Param("sql") String sql); 11 boolean addDataToDataBase(@Param("sql") String sql);
12
13 ThirdPosition getRealTimeLocation(@Param("deviceId")String deviceId);
12 } 14 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,4 +6,8 @@ ...@@ -6,4 +6,8 @@
6 ${sql} 6 ${sql}
7 </insert> 7 </insert>
8 8
9 <select id="getRealTimeLocation" resultType="com.jkdata.entity.ThirdPosition">
10 select * from sys_cmcc_position where node_id = #{deviceId} order by create_time limit 1
11 </select>
12
9 </mapper> 13 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.jkdata.service; 1 package com.jkdata.service;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.jkdata.entity.ThirdPosition;
4 5
5 import java.util.Map; 6 import java.util.Map;
6 7
...@@ -11,4 +12,10 @@ public interface IThirdService { ...@@ -11,4 +12,10 @@ public interface IThirdService {
11 String getBuildingAllInfo(); 12 String getBuildingAllInfo();
12 13
13 String getPositionByDeviceId(String deviceId,String startTime,String endTime); 14 String getPositionByDeviceId(String deviceId,String startTime,String endTime);
15
16 String getAlarmListByCount();
17
18 String getWeekAlarmState();
19
20 ThirdPosition getRealTimeLocation(String deviceId);
14 } 21 }
......
...@@ -70,10 +70,25 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -70,10 +70,25 @@ public class IThirdServiceImpl implements IThirdService {
70 return ok; 70 return ok;
71 } 71 }
72 72
73 public static void main(String[] args) {
74 String x1 = "463.7121276855469";
75 String y1 = "142.59878540039062";
76
77 double fd_x = CommonConstant.BLC1*(Double.valueOf(x1)-CommonConstant.LT_B1_X)+CommonConstant.LT_B1_X;
78 double fd_y = CommonConstant.BLC1*(Double.valueOf(y1)+CommonConstant.LT_B1_Y)-CommonConstant.LT_B1_Y;
79 System.out.println("放大后的坐标为:X:"+fd_x+",Y:"+fd_y);
80
81 double a = CommonConstant.MQ_B1_X - CommonConstant.LT_B1_X;//原点偏移x
82 double b = CommonConstant.MQ_B1_Y - CommonConstant.LT_B1_Y;//原点偏移y
83 System.out.println("偏移a:"+a+",b:"+b);
84
85 double x = Double.valueOf(fd_x) + a;
86 double y = Double.valueOf(fd_y) + b;
87 System.out.println("新坐标为:X:"+x+",Y:-"+y);
88 }
89
73 //B1定位坐标 90 //B1定位坐标
74 private void changCoordinateB1(ThirdPosition thirdPosition) { 91 private void changCoordinateB1(ThirdPosition thirdPosition) {
75 // String x1 = "101.1636962890625";
76 // String y1 = "325.2133483886719";
77 String x1 = thirdPosition.getPositionx(); 92 String x1 = thirdPosition.getPositionx();
78 String y1 = thirdPosition.getPositiony(); 93 String y1 = thirdPosition.getPositiony();
79 94
...@@ -137,15 +152,10 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -137,15 +152,10 @@ public class IThirdServiceImpl implements IThirdService {
137 String tmsp = String.valueOf(System.currentTimeMillis()/1000); 152 String tmsp = String.valueOf(System.currentTimeMillis()/1000);
138 map.put("bldId",CommonConstant.BLD_ID); 153 map.put("bldId",CommonConstant.BLD_ID);
139 map.put("ts",tmsp); 154 map.put("ts",tmsp);
140 String [] arr = { CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY };
141 Comparator<String> c = String::compareTo;
142 Arrays.sort(arr, c);
143 System.out.println("sign参数:"+Arrays.toString(arr));
144 String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY}),",") 155 String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY}),",")
145 .replace(",",""); 156 .replace(",","");
146 System.out.println("sign参数:"+str); 157 System.out.println("sign参数:"+str);
147 String strMd5 = MD5Util.getMD5LowerCase(str); 158 String strMd5 = MD5Util.getMD5LowerCase(str);
148
149 System.out.println("加密后参数:"+str); 159 System.out.println("加密后参数:"+str);
150 map.put("sgn",strMd5); 160 map.put("sgn",strMd5);
151 String post = HttpUtil.post(CommonConstant.BUILD_URL,map); 161 String post = HttpUtil.post(CommonConstant.BUILD_URL,map);
...@@ -156,35 +166,50 @@ public class IThirdServiceImpl implements IThirdService { ...@@ -156,35 +166,50 @@ public class IThirdServiceImpl implements IThirdService {
156 @Override 166 @Override
157 public String getPositionByDeviceId(String deviceId,String startTime,String endTime) { 167 public String getPositionByDeviceId(String deviceId,String startTime,String endTime) {
158 HashMap<String,Object> map = new HashMap<>(); 168 HashMap<String,Object> map = new HashMap<>();
159 String tmsp = String.valueOf(System.currentTimeMillis()/1000); 169 map.put("buildingId",CommonConstant.BLD_ID);
160 map.put("bldId",CommonConstant.BLD_ID);
161 map.put("ts",tmsp);
162 map.put("deviceId",deviceId); 170 map.put("deviceId",deviceId);
163 map.put("page","0"); 171 map.put("page","0");
164 map.put("count","200"); 172 map.put("count","200");
165 map.put("startTime",startTime); 173 map.put("startTime",startTime);
166 map.put("endTime",endTime); 174 map.put("endTime",endTime);
175 String post = HttpUtil.post(CommonConstant.HISTORY_URL,map);
176 return post;
177 }
167 178
168 String [] arr = { CommonConstant.BLD_ID,deviceId,startTime,endTime,"0","200",tmsp,CommonConstant.CMCC_KEY }; 179 @Override
169 Comparator<String> c = String::compareTo; 180 public String getAlarmListByCount() {
170 Arrays.sort(arr, c); 181 HashMap<String,Object> map = new HashMap<>();
171 System.out.println("sign参数:"+Arrays.toString(arr)); 182 String tmsp = String.valueOf(System.currentTimeMillis()/1000);
172 183 map.put("bldId",CommonConstant.BLD_ID);
173 String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,deviceId,startTime,endTime, 184 map.put("ts",tmsp);
174 "0","1000",tmsp,CommonConstant.CMCC_KEY}),",") 185 map.put("count","10");
186 String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,"10",tmsp,CommonConstant.CMCC_KEY}),",")
175 .replace(",",""); 187 .replace(",","");
176 System.out.println("sign参数:"+str);
177 String strMd5 = MD5Util.getMD5LowerCase(str); 188 String strMd5 = MD5Util.getMD5LowerCase(str);
178
179 System.out.println("加密后参数:"+str);
180 map.put("sgn",strMd5); 189 map.put("sgn",strMd5);
181 String post = HttpUtil.post(CommonConstant.HISTORY_URL,map); 190 String post = HttpUtil.post(CommonConstant.ALARM_URL,map);
182 System.out.println("请求结果:"+post);
183 return post; 191 return post;
192 }
184 193
194 @Override
195 public String getWeekAlarmState() {
196 HashMap<String,Object> map = new HashMap<>();
197 String tmsp = String.valueOf(System.currentTimeMillis()/1000);
198 map.put("bldId",CommonConstant.BLD_ID);
199 map.put("ts",tmsp);
200 String str = StringUtils.join(Arrays.asList(new String[]{CommonConstant.BLD_ID,tmsp,CommonConstant.CMCC_KEY}),",")
201 .replace(",","");
202 String strMd5 = MD5Util.getMD5LowerCase(str);
203 map.put("sgn",strMd5);
204 String post = HttpUtil.post(CommonConstant.WEEK_ALARM_URL,map);
205 return post;
206 }
185 207
186 208 @Override
187 209 public ThirdPosition getRealTimeLocation(String deviceId) {
210 ThirdPosition thirdPosition = new ThirdPosition();
211 thirdPosition = thirdMapper.getRealTimeLocation(deviceId);
212 return thirdPosition;
188 } 213 }
189 214
190 215
......
...@@ -28,15 +28,11 @@ public interface CommonConstant { ...@@ -28,15 +28,11 @@ public interface CommonConstant {
28 String BLD_ID = "10";//定位系统项目ID 28 String BLD_ID = "10";//定位系统项目ID
29 String CMCC_KEY = "f9257afea27943d7bcd7cc510f1b50dc";//定位系统秘钥 29 String CMCC_KEY = "f9257afea27943d7bcd7cc510f1b50dc";//定位系统秘钥
30 30
31 //************************场景信息******************************** 31 //*************************联通接口信息*******************************
32 String BUILD_URL = "http://52.131.253.116/api/v1/buildingAllInfo.shtml"; 32 String CMCC_IP = "http://52.131.253.116";//人员定位IP地址
33 33 String BUILD_URL = CMCC_IP + "/api/v1/buildingAllInfo.shtml";//场景信息
34 //************************历史轨迹******************************** 34 String HISTORY_URL = CMCC_IP + "/api/positionByDeviceId.shtml";//历史轨迹
35 String HISTORY_URL = "http://52.131.253.116/api/positionByDeviceId.shtml"; 35 String ALARM_URL = CMCC_IP + "/api/v1/alarmListByCount.shtml";//告警信息
36 36 String WEEK_ALARM_URL = CMCC_IP + "/api/v1/weekAlarmState.shtml";//获取最近7天的告警统计数据*
37 //************************历史轨迹********************************
38 String ALARM_URL = "http://52.131.253.116/api/v1/alarmListByCount.shtml";
39
40
41 37
42 } 38 }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!