缺少的文件

pull/14/head
dearlin 2024-01-06 10:52:36 +08:00
parent 9d8d1d4f7a
commit 12d0079c3b
6 changed files with 127 additions and 11 deletions

View File

@ -9,7 +9,7 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging><!-- 以war运行是改成war -->
<name>qa-prevention-gwj</name>
<name>qa-prevention-czks</name>
<description>qa-prevention-czks for Spring Boot</description>
<parent>

View File

@ -12,6 +12,7 @@ import com.zcloud.service.gatemachine.GateMachineService;
import com.zcloud.service.keyProjects.VideoManagerService;
import com.zcloud.service.system.DepartmentService;
import com.zcloud.service.system.UsersService;
import com.zcloud.util.HttpRequestUtil;
import com.zcloud.util.Jurisdiction;
import com.zcloud.util.ReturnMap;
import com.zcloud.util.Tools;
@ -325,6 +326,16 @@ public class MapController extends BaseController {
return map;
}
/**
* Alarm data
*/
@RequestMapping(value = "/getAlarmData")
@ResponseBody
public Object getAlarmData() {
return HttpRequestUtil.getPeopleApi("/statistics/alarmStatistics/todayAlarm","");
}
/**
*
*
@ -340,7 +351,7 @@ public class MapController extends BaseController {
return map;
}
// 获取人员定位信息 根据定位卡编码
// 获取人员定位信息 根据定位卡(身份证)编码
@RequestMapping(value = "/getPersonByCardNo")
@ResponseBody
public Object getPersonByCardNo() throws Exception {

View File

@ -1,5 +1,6 @@
package com.zcloud.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.lang.Nullable;
@ -9,6 +10,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
/**
* description: http
@ -368,4 +370,92 @@ public class HttpRequestUtil {
}
public static ReturnMap getPeopleApi(String httpUrl, String param) {
StringBuffer result = new StringBuffer();
//连接
HttpURLConnection connection = null;
OutputStream os = null;
InputStream is = null;
BufferedReader br = null;
try {
//创建连接对象
URL url = new URL(PerLocUtil.perLocUrl + httpUrl);
//创建连接
connection = (HttpURLConnection) url.openConnection();
//设置请求方法
connection.setRequestMethod("POST");
//设置连接超时时间
connection.setConnectTimeout(15000);
//设置读取超时时间
connection.setReadTimeout(15000);
//DoOutput设置是否向httpUrlConnection输出DoInput设置是否从httpUrlConnection读入此外发送post请求必须设置这两个
//设置是否可读取
connection.setDoOutput(true);
connection.setDoInput(true);
//设置通用的请求属性
// connection.setRequestProperty("accept", "*/*");
// connection.setRequestProperty("connection", "Keep-Alive");
// connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
// 必须添加token
connection.setRequestProperty("Authorization", PerLocUtil.getToken());
//拼装参数
if (null != param && !param.equals("")) {
//设置参数
os = connection.getOutputStream();
//拼装参数
os.write(param.getBytes());
}
//设置权限
//设置请求头等
//开启连接
//connection.connect();
//读取响应
if (connection.getResponseCode() == 200) {
is = connection.getInputStream();
if (null != is) {
br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String temp = null;
while (null != (temp = br.readLine())) {
result.append(temp);
result.append("\r\n");
}
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
//关闭连接
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//关闭连接
connection.disconnect();
}
HashMap o = JSON.parseObject(result.toString(), HashMap.class);
ReturnMap returnMap = new ReturnMap();
returnMap.putAll(o);
return returnMap;
}
}

View File

@ -15,8 +15,8 @@ import javax.annotation.Resource;
@Component
public class PerLocUtil {
@Value("${perLoc.url}")
private String perLocUrl;
// @Value("${perLoc.url}")
public static String perLocUrl = "http://172.16.130.86/gateway-service";
// @Value("${perLoc.userName}")
// private String userName;
// @Value("${perLoc.pwd}")
@ -33,13 +33,13 @@ public class PerLocUtil {
@Resource
private PersonLocationTokenMapper personLocationTokenMapper;
public String getToken() throws Exception {
public static String getToken(){
// token 不为空。验证token是否失效
if (Tools.notEmpty(perLocToken)) {
JSONObject request = new JSONObject();
request.put("pageNum", 1);
request.put("pageSize", 10);
String httpResponseStr = HttpRequestUtil.doPost(perLocToken, this.perLocUrl + "/system/menu/menuTree",request.toJSONString());
String httpResponseStr = HttpRequestUtil.doPost(perLocToken, perLocUrl + "/system/menu/menuTree",request.toJSONString());
JSONObject httpResponse = JSONObject.parseObject(httpResponseStr);
// token 有效
if (Tools.notEmpty(httpResponseStr) && httpResponse != null && httpResponse.get("code") != null && httpResponse.getInteger("code") == 200) {
@ -54,19 +54,19 @@ public class PerLocUtil {
}
private String goToLogin() throws Exception{
private static String goToLogin(){
JSONObject request = new JSONObject();
request.put("username", userName);
request.put("username", username);
request.put("password", password);
request.put("userName", userName);
request.put("source", source);
request.put("code", code);
String loginResStr = HttpRequestUtil.doPost(this.perLocUrl + "/auth/encryptLogin", request.toJSONString());
String loginResStr = HttpRequestUtil.doPost(perLocUrl + "/auth/encryptLogin", request.toJSONString());
JSONObject loginResponse = JSONObject.parseObject(loginResStr);
// 登录成功
if(Tools.notEmpty(loginResStr) && loginResponse != null
&& loginResponse.get("code") != null && loginResponse.getInteger("code") == 200
&& loginResponse.get("data") != null && loginResponse.getJSONObject("data").getString("access_token") != null){
&& loginResponse.get("data") != null && loginResponse.getJSONObject("data").getString("token") != null){
// personLocationTokenMapper.edit(loginResponse.getJSONObject("data").getString("access_token"));
return loginResponse.getJSONObject("data").getString("token");
} else { // 登录失败

View File

@ -1346,4 +1346,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ISASSESS = #{ISASSESS}
</if>
</select>
<select id="getPersonByCardNo" resultType="com.zcloud.entity.PageData">
SELECT
s.*,
d.`NAME` DEPARTMENT_NAME,
r.ROLE_NAME,
s.`NAME` POST_NAME
FROM
`qa-czks-prevention`.SYS_USER s
LEFT JOIN `qa-czks-prevention`.oa_department d ON s.DEPARTMENT_ID = d.DEPARTMENT_ID
LEFT JOIN `qa-czks-prevention`.sys_role r ON s.ROLE_ID = r.ROLE_ID
LEFT JOIN `qa-czks-prevention`.sys_post p ON p.POST_ID = s.POST_ID
WHERE
s.ISDELETE = '0'
AND s.cardNo = #{CARDNO}
</select>
</mapper>