7a86522a 张雷

义乌人员筛选

1 个父辈 e88be2ce
...@@ -26,11 +26,11 @@ public class UserLocationController { ...@@ -26,11 +26,11 @@ public class UserLocationController {
26 @AutoLog(value = "义乌人员定位-获取所有人员列表") 26 @AutoLog(value = "义乌人员定位-获取所有人员列表")
27 @ApiOperation(value="义乌人员定位-获取所有人员列表", notes="义乌人员定位-获取所有人员列表") 27 @ApiOperation(value="义乌人员定位-获取所有人员列表", notes="义乌人员定位-获取所有人员列表")
28 @GetMapping(value = "/yw/getAllUser") 28 @GetMapping(value = "/yw/getAllUser")
29 public Result<List<UserBaseInfo>> getAllUserYW() { 29 public Result<List<UserBaseInfo>> getAllUserYW(String userName) {
30 Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>(); 30 Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
31 List<UserBaseInfo> list = new ArrayList<>(); 31 List<UserBaseInfo> list = new ArrayList<>();
32 ILocationService locationService = UserLocationFactory.getLocationService("YW"); 32 ILocationService locationService = UserLocationFactory.getLocationService("YW");
33 list = locationService.getAllUser(); 33 list = locationService.getAllUser(userName);
34 result.setResult(list); 34 result.setResult(list);
35 result.setSuccess(true); 35 result.setSuccess(true);
36 return result; 36 return result;
...@@ -66,11 +66,11 @@ public class UserLocationController { ...@@ -66,11 +66,11 @@ public class UserLocationController {
66 @AutoLog(value = "余杭人员定位-获取所有人员列表") 66 @AutoLog(value = "余杭人员定位-获取所有人员列表")
67 @ApiOperation(value="余杭人员定位-获取所有人员列表", notes="余杭人员定位-获取所有人员列表") 67 @ApiOperation(value="余杭人员定位-获取所有人员列表", notes="余杭人员定位-获取所有人员列表")
68 @GetMapping(value = "/yh/getAllUser") 68 @GetMapping(value = "/yh/getAllUser")
69 public Result<List<UserBaseInfo>> getAllUserBKYH() { 69 public Result<List<UserBaseInfo>> getAllUserBKYH(String userName) {
70 Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>(); 70 Result<List<UserBaseInfo>> result = new Result<List<UserBaseInfo>>();
71 List<UserBaseInfo> list = new ArrayList<>(); 71 List<UserBaseInfo> list = new ArrayList<>();
72 ILocationService locationService = UserLocationFactory.getLocationService("BKYH"); 72 ILocationService locationService = UserLocationFactory.getLocationService("BKYH");
73 list = locationService.getAllUser(); 73 list = locationService.getAllUser(userName);
74 result.setResult(list); 74 result.setResult(list);
75 result.setSuccess(true); 75 result.setSuccess(true);
76 return result; 76 return result;
......
...@@ -11,7 +11,7 @@ public interface ILocationService { ...@@ -11,7 +11,7 @@ public interface ILocationService {
11 11
12 List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime); 12 List<UserLocation> getUserHistory(String deviceCode, String startTime, String endTime);
13 13
14 List<UserBaseInfo> getAllUser(); 14 List<UserBaseInfo> getAllUser(String userName);
15 15
16 16
17 } 17 }
......
...@@ -108,7 +108,7 @@ public class BkyhLocationServiceImpl implements ILocationService { ...@@ -108,7 +108,7 @@ public class BkyhLocationServiceImpl implements ILocationService {
108 } 108 }
109 109
110 @Override 110 @Override
111 public List<UserBaseInfo> getAllUser() { 111 public List<UserBaseInfo> getAllUser(String userName) {
112 List<UserBaseInfo> list = new ArrayList<>(); 112 List<UserBaseInfo> list = new ArrayList<>();
113 String post = getBuildingAllInfo(); 113 String post = getBuildingAllInfo();
114 JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString()); 114 JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
......
...@@ -46,50 +46,6 @@ public class YwLocationServiceImpl implements ILocationService { ...@@ -46,50 +46,6 @@ public class YwLocationServiceImpl implements ILocationService {
46 pMap.put("username", username); 46 pMap.put("username", username);
47 pMap.put("password", password); 47 pMap.put("password", password);
48 String get = HttpUtil.get(url+"open/information/getRealGps.do",pMap); 48 String get = HttpUtil.get(url+"open/information/getRealGps.do",pMap);
49 // String get = "{\n" +
50 // "\"data\":\n" +
51 // "[{\n" +
52 // "\"empName\":\"贾伟峰\",\n" +
53 // "\"area\":\"2\",\n" +
54 // "\"deviceNo\":\"16a7ebee\",\n" +
55 // "\"crossY\":\"2564\",\n" +
56 // "\"crossX\":\"1508\",\n" +
57 // "\"longitude\":104.04438600000114,\n" +
58 // "\"latitude\":30.630693000000115,\n" +
59 // "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
60 // "\"layer\":\"-1\",\n" +
61 // "\"empNo\":\"108036\",\n" +
62 // "\"specifictype\":\"0\"\n" +
63 // "},\n" +
64 // "{\n" +
65 // "\"empName\":\"宋锡园\",\n" +
66 // "\"area\":\"2\",\n" +
67 // "\"deviceNo\":\"169c1502\",\n" +
68 // "\"crossY\":\"2584\",\n" +
69 // "\"crossX\":\"1538\",\n" +
70 // "\"longitude\":104.04438600000114,\n" +
71 // "\"latitude\":30.630693000000115,\n" +
72 // "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
73 // "\"layer\":\"-1\",\n" +
74 // "\"empNo\":\"108037\",\n" +
75 // "\"specifictype\":\"0\"\n" +
76 // "},\n" +
77 // "{\n" +
78 // "\"empName\":\"何成翔\",\n" +
79 // "\"area\":\"2\",\n" +
80 // "\"deviceNo\":\"169c0cba\",\n" +
81 // "\"crossY\":\"2564\",\n" +
82 // "\"crossX\":\"2816\",\n" +
83 // "\"longitude\":124.01230000114,\n" +
84 // "\"latitude\":31.6301230000115,\n" +
85 // "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
86 // "\"layer\":\"-1\",\n" +
87 // "\"empNo\":\"147258\",\n" +
88 // "\"specifictype\":\"0\"\n" +
89 // "}],\n" +
90 // "\"status\":0,\n" +
91 // "\"msginfo\":\"接口调用成功!\"\n" +
92 // "}";
93 JSONObject json = JSONObject.parseObject(get); 49 JSONObject json = JSONObject.parseObject(get);
94 List<UserLocationYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationYwResult.class); 50 List<UserLocationYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationYwResult.class);
95 getLocationBasicInfo();//坐标转换基础信息 51 getLocationBasicInfo();//坐标转换基础信息
...@@ -119,28 +75,6 @@ public class YwLocationServiceImpl implements ILocationService { ...@@ -119,28 +75,6 @@ public class YwLocationServiceImpl implements ILocationService {
119 pMap.put("endtime", endTime); 75 pMap.put("endtime", endTime);
120 pMap.put("deveuis", deviceCode); 76 pMap.put("deveuis", deviceCode);
121 String get = HttpUtil.get(url+"open/information/getHis.do",pMap); 77 String get = HttpUtil.get(url+"open/information/getHis.do",pMap);
122 // String get = "{\n" +
123 // "\"data\":[\n" +
124 // "{\n" +
125 // "\"name\":\"贾伟峰\",\n" +
126 // "\"time\":\"2020-04-20 00:02:35\",\n" +
127 // "\"x\":\"3539.05\",\n" +
128 // "\"y\":\"2711.93\",\n" +
129 // "\"lat\":32.54224453987491,\n" +
130 // "\"lon\":121.05223514735032\n" +
131 // "},\n" +
132 // "{\n" +
133 // "\"name\":\"贾伟峰\",\n" +
134 // "\"time\":\"2020-04-20 00:02:45\",\n" +
135 // "\"x\":\"3536.05\",\n" +
136 // "\"y\":\"2611.93\",\n" +
137 // "\"lat\":32.54212353987491,\n" +
138 // "\"lon\":121.05123514735032\n" +
139 // "}\n" +
140 // "],\n" +
141 // "\"msginfo\":\"成功!\",\n" +
142 // "\"status\":0\n" +
143 // "}";
144 JSONObject json = JSONObject.parseObject(get); 78 JSONObject json = JSONObject.parseObject(get);
145 List<UserLocationHistoryYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationHistoryYwResult.class); 79 List<UserLocationHistoryYwResult> getList = JSONObject.parseArray(json.get("data").toString(), UserLocationHistoryYwResult.class);
146 getLocationBasicInfo();//坐标转换基础信息 80 getLocationBasicInfo();//坐标转换基础信息
...@@ -152,44 +86,23 @@ public class YwLocationServiceImpl implements ILocationService { ...@@ -152,44 +86,23 @@ public class YwLocationServiceImpl implements ILocationService {
152 userLocation.setX(Double.valueOf(map.get("x").toString())); 86 userLocation.setX(Double.valueOf(map.get("x").toString()));
153 userLocation.setY(Double.valueOf(map.get("y").toString())); 87 userLocation.setY(Double.valueOf(map.get("y").toString()));
154 userLocation.setDateTime(userLocationHistoryYwResult.getTime()); 88 userLocation.setDateTime(userLocationHistoryYwResult.getTime());
89 userLocation.setFloor("-1");
90 userLocation.setDeviceCode(deviceCode);
155 list.add(userLocation); 91 list.add(userLocation);
156 } 92 }
157 return list; 93 return list;
158 } 94 }
159 95
160 @Override 96 @Override
161 public List<UserBaseInfo> getAllUser() { 97 public List<UserBaseInfo> getAllUser(String userName) {
162 List<UserBaseInfo> list = new ArrayList<>(); 98 List<UserBaseInfo> list = new ArrayList<>();
163 HashMap<String,Object> map = new HashMap<>(); 99 HashMap<String,Object> map = new HashMap<>();
164 map.put("username", username); 100 map.put("username", username);
165 map.put("password", password); 101 map.put("password", password);
166 map.put("page",1); 102 map.put("page",1);
167 map.put("rows",1000); 103 map.put("rows",1000);
168 map.put("emp",""); 104 map.put("emp",userName);
169 String post = HttpUtil.get(url+"open/information/getEmp.do",map); 105 String post = HttpUtil.get(url+"open/information/getEmp.do",map);
170 // String post = "{\n" +
171 // "\t\"data\": {\n" +
172 // "\t\t\"total\": 3,\n" +
173 // "\t\t\"rows\": [{\n" +
174 // "\t\t\t\"id\": 1,\n" +
175 // "\t\t\t\"empno\": \"108036\",\n" +
176 // "\t\t\t\"empname\": \"贾伟峰\",\n" +
177 // "\t\t\t\"deviceno\": \"16a7ebee\"\n" +
178 // "\t\t},{\n" +
179 // "\t\t\t\"id\": 2,\n" +
180 // "\t\t\t\"empno\": \"108037\",\n" +
181 // "\t\t\t\"empname\": \"宋锡园\",\n" +
182 // "\t\t\t\"deviceno\": \"169c1502\"\n" +
183 // "\t\t},{\n" +
184 // "\t\t\t\"id\": 3,\n" +
185 // "\t\t\t\"empno\": \"147258\",\n" +
186 // "\t\t\t\"empname\": \"何成翔\",\n" +
187 // "\t\t\t\"deviceno\": \"169c0cba\"\n" +
188 // "\t\t}]\n" +
189 // "\t},\n" +
190 // "\t\"msginfo\": \"成功!\",\n" +
191 // "\t\"status\": 0\n" +
192 // "} ";
193 JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString()); 106 JSONObject json = JSONObject.parseObject(JSONObject.parseObject(post).get("data").toString());
194 List<UserBaseInfoYwResult> userList = JSONObject.parseArray(json.get("rows").toString(), UserBaseInfoYwResult.class); 107 List<UserBaseInfoYwResult> userList = JSONObject.parseArray(json.get("rows").toString(), UserBaseInfoYwResult.class);
195 for (UserBaseInfoYwResult userBaseInfoYwResult : userList) { 108 for (UserBaseInfoYwResult userBaseInfoYwResult : userList) {
...@@ -198,6 +111,7 @@ public class YwLocationServiceImpl implements ILocationService { ...@@ -198,6 +111,7 @@ public class YwLocationServiceImpl implements ILocationService {
198 userBaseInfo.setUserName(userBaseInfoYwResult.getEmpname()); 111 userBaseInfo.setUserName(userBaseInfoYwResult.getEmpname());
199 userBaseInfo.setUserNo(userBaseInfoYwResult.getEmpno()); 112 userBaseInfo.setUserNo(userBaseInfoYwResult.getEmpno());
200 userBaseInfo.setUserType("员工"); 113 userBaseInfo.setUserType("员工");
114 userBaseInfo.setUserStatus("0");
201 list.add(userBaseInfo); 115 list.add(userBaseInfo);
202 } 116 }
203 return list; 117 return list;
......
...@@ -43,6 +43,7 @@ public class ShiroConfig { ...@@ -43,6 +43,7 @@ public class ShiroConfig {
43 //cas验证登录 43 //cas验证登录
44 filterChainDefinitionMap.put("/cas/client/validateLogin", "anon"); 44 filterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
45 // 配置不会被拦截的链接 顺序判断 45 // 配置不会被拦截的链接 顺序判断
46 filterChainDefinitionMap.put("/wechat/login", "anon"); //微信登录二维码接口排除
46 filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除 47 filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
47 filterChainDefinitionMap.put("/sys/appLogin", "anon"); //移动端登录接口排除 48 filterChainDefinitionMap.put("/sys/appLogin", "anon"); //移动端登录接口排除
48 filterChainDefinitionMap.put("/sys/thirdLogin", "anon"); //三方系统登录接口排除 49 filterChainDefinitionMap.put("/sys/thirdLogin", "anon"); //三方系统登录接口排除
......
1 package com.skua.modules.system.controller;
2
3 import cn.hutool.http.HttpUtil;
4 import com.google.gson.Gson;
5 import com.skua.core.api.vo.Result;
6 import com.skua.modules.system.util.ConstantPropertiesUtil;
7 import io.swagger.annotations.Api;
8 import lombok.extern.slf4j.Slf4j;
9 import org.springframework.stereotype.Controller;
10 import org.springframework.web.bind.annotation.GetMapping;
11 import org.springframework.web.bind.annotation.RequestMapping;
12 import com.skua.modules.system.vo.Member;
13 import org.springframework.web.bind.annotation.RestController;
14
15 import java.io.UnsupportedEncodingException;
16 import java.net.URLEncoder;
17 import java.util.HashMap;
18 import java.util.Map;
19 import java.util.UUID;
20
21 @RequestMapping("/wechat")
22 @Api(tags = "微信相关接口")
23 @RestController
24 @Slf4j
25 public class WeChatApiController {
26
27 /**
28 * 生成微信扫描二维码
29 * @return
30 */
31 @GetMapping("login")
32 public Result<Map<String,Object>> getWxCode() {
33 Result<Map<String,Object>> result = new Result<>();
34 Map<String,Object> map = new HashMap<>();
35 // 回调地址
36 String redirectUrl = ConstantPropertiesUtil.WX_OPEN_REDIRECT_URL; //获取业务服务器重定向地址
37 try {
38 redirectUrl = URLEncoder.encode(redirectUrl, "UTF-8"); //url编码
39 } catch (UnsupportedEncodingException e) {
40 }
41 // 防止csrf攻击(跨站请求伪造攻击)
42 String state = UUID.randomUUID().toString().replace("-", "");//一般情况下会使用一个随机数
43 // 微信开放平台授权baseUrl
44 String qrcodeUrl = "https://open.weixin.qq.com/connect/qrconnect" +
45 "?appid=" + ConstantPropertiesUtil.WX_OPEN_APP_ID +
46 "&redirect_uri=" + redirectUrl +
47 "&response_type=code" +
48 "&scope=snsapi_login" +
49 "&state=" + state;
50 // 采用redis等进行缓存state 使用sessionId为key 30分钟后过期,可配置
51 //键:"wechar-open-state-" + httpServletRequest.getSession().getId()
52 //值:satte
53 //过期时间:30分钟
54 String get = HttpUtil.get(qrcodeUrl);
55 int index = get.indexOf("connect/qrcode/");
56 if(index > 0){
57 //截取_之前字符串
58 String qrUrl = get.substring(get.indexOf("connect/qrcode/"),get.length()).substring(15,31);
59 map.put("qrUrl","https://open.weixin.qq.com/connect/qrcode/"+qrUrl);
60 map.put("state", state);
61 map.put("code","");
62 result.setResult(map);
63 result.setSuccess(true);
64 }else{
65 map.put("qrUrl","");
66 map.put("state", "");
67 map.put("code","");
68 result.setResult(map);
69 result.setSuccess(false);
70 }
71 return result;
72 }
73
74
75 /**
76 * 用户扫描授权同意的回调
77 */
78 /**
79 * @param code
80 * @param state
81 * @return
82 */
83 @GetMapping("callback")
84 public String callback(String code, String state){
85 //得到授权临时票据code
86 System.out.println(code);
87 System.out.println(state);
88
89 //从redis中将state获取出来,和当前传入的state作比较
90 //如果一致则放行,如果不一致则抛出异常:非法访问
91
92 //向认证服务器发送请求换取access_token
93 String baseAccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token" +
94 "?appid=%s" +
95 "&secret=%s" +
96 "&code=%s" +
97 "&grant_type=authorization_code";
98
99 String accessTokenUrl = String.format(baseAccessTokenUrl,
100 ConstantPropertiesUtil.WX_OPEN_APP_ID,
101 ConstantPropertiesUtil.WX_OPEN_APP_SECRET,
102 code);
103
104 String result = null;
105 try {
106 result = HttpUtil.get(accessTokenUrl);
107 System.out.println("accessToken=============" + result);
108 } catch (Exception e) {
109 }
110
111 //解析json字符串
112 Gson gson = new Gson();
113 HashMap map = gson.fromJson(result, HashMap.class);
114 String accessToken = (String)map.get("access_token");
115 String openid = (String)map.get("openid");
116
117 //查询数据库当前用用户是否曾经使用过微信登录
118 // Member member = memberService.getByOpenid(openid);
119 Member member = null;
120 if(member == null){
121 System.out.println("新用户注册");
122
123 //访问微信的资源服务器,获取用户信息
124 String baseUserInfoUrl = "https://api.weixin.qq.com/sns/userinfo" +
125 "?access_token=%s" +
126 "&openid=%s";
127 String userInfoUrl = String.format(baseUserInfoUrl, accessToken, openid);
128 String resultUserInfo = null;
129 try {
130 resultUserInfo = HttpUtil.get(userInfoUrl);
131 System.out.println("resultUserInfo==========" + resultUserInfo);
132 } catch (Exception e) {
133 }
134
135 //解析json
136 HashMap<String, Object> mapUserInfo = gson.fromJson(resultUserInfo, HashMap.class);
137 String nickname = (String)mapUserInfo.get("nickname");
138 String headimgurl = (String)mapUserInfo.get("headimgurl");
139
140 //向数据库中插入一条记录
141 member = new Member();
142 member.setNickname(nickname);
143 member.setOpenid(openid);
144 member.setAvatar(headimgurl);
145 // memberService.save(member);
146 System.out.println("插入数据库");
147 }
148
149 //TODO 登录
150 return "redirect:http://localhost:3000";
151 }
152
153 }
1 package com.skua.modules.system.util;
2
3
4 import org.springframework.beans.factory.InitializingBean;
5 import org.springframework.beans.factory.annotation.Value;
6 import org.springframework.stereotype.Component;
7
8 @Component
9 public class ConstantPropertiesUtil implements InitializingBean {
10
11 @Value("${wx.app-id}")
12 private String appId;
13 @Value("${wx.app-secret}")
14 private String appSecret;
15 @Value("${wx.redirect-url}")
16 private String redirectUrl;
17
18 public static String WX_OPEN_APP_ID;
19 public static String WX_OPEN_APP_SECRET;
20 public static String WX_OPEN_REDIRECT_URL;
21
22
23 @Override
24 public void afterPropertiesSet() throws Exception {
25 WX_OPEN_APP_ID = appId;
26 WX_OPEN_APP_SECRET = appSecret;
27 WX_OPEN_REDIRECT_URL = redirectUrl;
28 }
29 }
1 package com.skua.modules.system.vo;
2
3 import lombok.Data;
4
5 @Data
6 public class Member {
7
8 /**名称*/
9 private String nickname;
10 /**openId*/
11 private String openid;
12 /**头像*/
13 private String avatar;
14
15 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!