Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
fmboot
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
7a86522a
由
张雷
编写于
2023-05-15 18:59:49 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
义乌人员筛选
1 个父辈
e88be2ce
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
209 行增加
和
97 行删除
fm-product/src/main/java/com/skua/modules/location/controller/UserLocationController.java
fm-product/src/main/java/com/skua/modules/location/service/ILocationService.java
fm-product/src/main/java/com/skua/modules/location/service/impl/BkyhLocationServiceImpl.java
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
fm-system/src/main/java/com/skua/config/ShiroConfig.java
fm-system/src/main/java/com/skua/modules/system/controller/WeChatApiController.java
fm-system/src/main/java/com/skua/modules/system/util/ConstantPropertiesUtil.java
fm-system/src/main/java/com/skua/modules/system/vo/Member.java
fm-product/src/main/java/com/skua/modules/location/controller/UserLocationController.java
查看文件 @
7a86522
...
...
@@ -26,11 +26,11 @@ public class UserLocationController {
@AutoLog
(
value
=
"义乌人员定位-获取所有人员列表"
)
@ApiOperation
(
value
=
"义乌人员定位-获取所有人员列表"
,
notes
=
"义乌人员定位-获取所有人员列表"
)
@GetMapping
(
value
=
"/yw/getAllUser"
)
public
Result
<
List
<
UserBaseInfo
>>
getAllUserYW
()
{
public
Result
<
List
<
UserBaseInfo
>>
getAllUserYW
(
String
userName
)
{
Result
<
List
<
UserBaseInfo
>>
result
=
new
Result
<
List
<
UserBaseInfo
>>();
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
ILocationService
locationService
=
UserLocationFactory
.
getLocationService
(
"YW"
);
list
=
locationService
.
getAllUser
();
list
=
locationService
.
getAllUser
(
userName
);
result
.
setResult
(
list
);
result
.
setSuccess
(
true
);
return
result
;
...
...
@@ -66,11 +66,11 @@ public class UserLocationController {
@AutoLog
(
value
=
"余杭人员定位-获取所有人员列表"
)
@ApiOperation
(
value
=
"余杭人员定位-获取所有人员列表"
,
notes
=
"余杭人员定位-获取所有人员列表"
)
@GetMapping
(
value
=
"/yh/getAllUser"
)
public
Result
<
List
<
UserBaseInfo
>>
getAllUserBKYH
()
{
public
Result
<
List
<
UserBaseInfo
>>
getAllUserBKYH
(
String
userName
)
{
Result
<
List
<
UserBaseInfo
>>
result
=
new
Result
<
List
<
UserBaseInfo
>>();
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
ILocationService
locationService
=
UserLocationFactory
.
getLocationService
(
"BKYH"
);
list
=
locationService
.
getAllUser
();
list
=
locationService
.
getAllUser
(
userName
);
result
.
setResult
(
list
);
result
.
setSuccess
(
true
);
return
result
;
...
...
fm-product/src/main/java/com/skua/modules/location/service/ILocationService.java
查看文件 @
7a86522
...
...
@@ -11,7 +11,7 @@ public interface ILocationService {
List
<
UserLocation
>
getUserHistory
(
String
deviceCode
,
String
startTime
,
String
endTime
);
List
<
UserBaseInfo
>
getAllUser
();
List
<
UserBaseInfo
>
getAllUser
(
String
userName
);
}
...
...
fm-product/src/main/java/com/skua/modules/location/service/impl/BkyhLocationServiceImpl.java
查看文件 @
7a86522
...
...
@@ -108,7 +108,7 @@ public class BkyhLocationServiceImpl implements ILocationService {
}
@Override
public
List
<
UserBaseInfo
>
getAllUser
()
{
public
List
<
UserBaseInfo
>
getAllUser
(
String
userName
)
{
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
String
post
=
getBuildingAllInfo
();
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
parseObject
(
post
).
get
(
"data"
).
toString
());
...
...
fm-product/src/main/java/com/skua/modules/location/service/impl/YwLocationServiceImpl.java
查看文件 @
7a86522
...
...
@@ -46,50 +46,6 @@ public class YwLocationServiceImpl implements ILocationService {
pMap
.
put
(
"username"
,
username
);
pMap
.
put
(
"password"
,
password
);
String
get
=
HttpUtil
.
get
(
url
+
"open/information/getRealGps.do"
,
pMap
);
// String get = "{\n" +
// "\"data\":\n" +
// "[{\n" +
// "\"empName\":\"贾伟峰\",\n" +
// "\"area\":\"2\",\n" +
// "\"deviceNo\":\"16a7ebee\",\n" +
// "\"crossY\":\"2564\",\n" +
// "\"crossX\":\"1508\",\n" +
// "\"longitude\":104.04438600000114,\n" +
// "\"latitude\":30.630693000000115,\n" +
// "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
// "\"layer\":\"-1\",\n" +
// "\"empNo\":\"108036\",\n" +
// "\"specifictype\":\"0\"\n" +
// "},\n" +
// "{\n" +
// "\"empName\":\"宋锡园\",\n" +
// "\"area\":\"2\",\n" +
// "\"deviceNo\":\"169c1502\",\n" +
// "\"crossY\":\"2584\",\n" +
// "\"crossX\":\"1538\",\n" +
// "\"longitude\":104.04438600000114,\n" +
// "\"latitude\":30.630693000000115,\n" +
// "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
// "\"layer\":\"-1\",\n" +
// "\"empNo\":\"108037\",\n" +
// "\"specifictype\":\"0\"\n" +
// "},\n" +
// "{\n" +
// "\"empName\":\"何成翔\",\n" +
// "\"area\":\"2\",\n" +
// "\"deviceNo\":\"169c0cba\",\n" +
// "\"crossY\":\"2564\",\n" +
// "\"crossX\":\"2816\",\n" +
// "\"longitude\":124.01230000114,\n" +
// "\"latitude\":31.6301230000115,\n" +
// "\"dateTime\":\"2022-05-05 11:35:52\",\n" +
// "\"layer\":\"-1\",\n" +
// "\"empNo\":\"147258\",\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
();
//坐标转换基础信息
...
...
@@ -119,28 +75,6 @@ public class YwLocationServiceImpl implements ILocationService {
pMap
.
put
(
"endtime"
,
endTime
);
pMap
.
put
(
"deveuis"
,
deviceCode
);
String
get
=
HttpUtil
.
get
(
url
+
"open/information/getHis.do"
,
pMap
);
// 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
();
//坐标转换基础信息
...
...
@@ -152,44 +86,23 @@ public class YwLocationServiceImpl implements ILocationService {
userLocation
.
setX
(
Double
.
valueOf
(
map
.
get
(
"x"
).
toString
()));
userLocation
.
setY
(
Double
.
valueOf
(
map
.
get
(
"y"
).
toString
()));
userLocation
.
setDateTime
(
userLocationHistoryYwResult
.
getTime
());
userLocation
.
setFloor
(
"-1"
);
userLocation
.
setDeviceCode
(
deviceCode
);
list
.
add
(
userLocation
);
}
return
list
;
}
@Override
public
List
<
UserBaseInfo
>
getAllUser
()
{
public
List
<
UserBaseInfo
>
getAllUser
(
String
userName
)
{
List
<
UserBaseInfo
>
list
=
new
ArrayList
<>();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"username"
,
username
);
map
.
put
(
"password"
,
password
);
map
.
put
(
"page"
,
1
);
map
.
put
(
"rows"
,
1000
);
map
.
put
(
"emp"
,
""
);
map
.
put
(
"emp"
,
userName
);
String
post
=
HttpUtil
.
get
(
url
+
"open/information/getEmp.do"
,
map
);
// String post = "{\n" +
// "\t\"data\": {\n" +
// "\t\t\"total\": 3,\n" +
// "\t\t\"rows\": [{\n" +
// "\t\t\t\"id\": 1,\n" +
// "\t\t\t\"empno\": \"108036\",\n" +
// "\t\t\t\"empname\": \"贾伟峰\",\n" +
// "\t\t\t\"deviceno\": \"16a7ebee\"\n" +
// "\t\t},{\n" +
// "\t\t\t\"id\": 2,\n" +
// "\t\t\t\"empno\": \"108037\",\n" +
// "\t\t\t\"empname\": \"宋锡园\",\n" +
// "\t\t\t\"deviceno\": \"169c1502\"\n" +
// "\t\t},{\n" +
// "\t\t\t\"id\": 3,\n" +
// "\t\t\t\"empno\": \"147258\",\n" +
// "\t\t\t\"empname\": \"何成翔\",\n" +
// "\t\t\t\"deviceno\": \"169c0cba\"\n" +
// "\t\t}]\n" +
// "\t},\n" +
// "\t\"msginfo\": \"成功!\",\n" +
// "\t\"status\": 0\n" +
// "} ";
JSONObject
json
=
JSONObject
.
parseObject
(
JSONObject
.
parseObject
(
post
).
get
(
"data"
).
toString
());
List
<
UserBaseInfoYwResult
>
userList
=
JSONObject
.
parseArray
(
json
.
get
(
"rows"
).
toString
(),
UserBaseInfoYwResult
.
class
);
for
(
UserBaseInfoYwResult
userBaseInfoYwResult
:
userList
)
{
...
...
@@ -198,6 +111,7 @@ public class YwLocationServiceImpl implements ILocationService {
userBaseInfo
.
setUserName
(
userBaseInfoYwResult
.
getEmpname
());
userBaseInfo
.
setUserNo
(
userBaseInfoYwResult
.
getEmpno
());
userBaseInfo
.
setUserType
(
"员工"
);
userBaseInfo
.
setUserStatus
(
"0"
);
list
.
add
(
userBaseInfo
);
}
return
list
;
...
...
fm-system/src/main/java/com/skua/config/ShiroConfig.java
查看文件 @
7a86522
...
...
@@ -43,6 +43,7 @@ public class ShiroConfig {
//cas验证登录
filterChainDefinitionMap
.
put
(
"/cas/client/validateLogin"
,
"anon"
);
// 配置不会被拦截的链接 顺序判断
filterChainDefinitionMap
.
put
(
"/wechat/login"
,
"anon"
);
//微信登录二维码接口排除
filterChainDefinitionMap
.
put
(
"/sys/login"
,
"anon"
);
//登录接口排除
filterChainDefinitionMap
.
put
(
"/sys/appLogin"
,
"anon"
);
//移动端登录接口排除
filterChainDefinitionMap
.
put
(
"/sys/thirdLogin"
,
"anon"
);
//三方系统登录接口排除
...
...
fm-system/src/main/java/com/skua/modules/system/controller/WeChatApiController.java
0 → 100644
查看文件 @
7a86522
package
com
.
skua
.
modules
.
system
.
controller
;
import
cn.hutool.http.HttpUtil
;
import
com.google.gson.Gson
;
import
com.skua.core.api.vo.Result
;
import
com.skua.modules.system.util.ConstantPropertiesUtil
;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.skua.modules.system.vo.Member
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.UUID
;
@RequestMapping
(
"/wechat"
)
@Api
(
tags
=
"微信相关接口"
)
@RestController
@Slf4j
public
class
WeChatApiController
{
/**
* 生成微信扫描二维码
* @return
*/
@GetMapping
(
"login"
)
public
Result
<
Map
<
String
,
Object
>>
getWxCode
()
{
Result
<
Map
<
String
,
Object
>>
result
=
new
Result
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
// 回调地址
String
redirectUrl
=
ConstantPropertiesUtil
.
WX_OPEN_REDIRECT_URL
;
//获取业务服务器重定向地址
try
{
redirectUrl
=
URLEncoder
.
encode
(
redirectUrl
,
"UTF-8"
);
//url编码
}
catch
(
UnsupportedEncodingException
e
)
{
}
// 防止csrf攻击(跨站请求伪造攻击)
String
state
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
//一般情况下会使用一个随机数
// 微信开放平台授权baseUrl
String
qrcodeUrl
=
"https://open.weixin.qq.com/connect/qrconnect"
+
"?appid="
+
ConstantPropertiesUtil
.
WX_OPEN_APP_ID
+
"&redirect_uri="
+
redirectUrl
+
"&response_type=code"
+
"&scope=snsapi_login"
+
"&state="
+
state
;
// 采用redis等进行缓存state 使用sessionId为key 30分钟后过期,可配置
//键:"wechar-open-state-" + httpServletRequest.getSession().getId()
//值:satte
//过期时间:30分钟
String
get
=
HttpUtil
.
get
(
qrcodeUrl
);
int
index
=
get
.
indexOf
(
"connect/qrcode/"
);
if
(
index
>
0
){
//截取_之前字符串
String
qrUrl
=
get
.
substring
(
get
.
indexOf
(
"connect/qrcode/"
),
get
.
length
()).
substring
(
15
,
31
);
map
.
put
(
"qrUrl"
,
"https://open.weixin.qq.com/connect/qrcode/"
+
qrUrl
);
map
.
put
(
"state"
,
state
);
map
.
put
(
"code"
,
""
);
result
.
setResult
(
map
);
result
.
setSuccess
(
true
);
}
else
{
map
.
put
(
"qrUrl"
,
""
);
map
.
put
(
"state"
,
""
);
map
.
put
(
"code"
,
""
);
result
.
setResult
(
map
);
result
.
setSuccess
(
false
);
}
return
result
;
}
/**
* 用户扫描授权同意的回调
*/
/**
* @param code
* @param state
* @return
*/
@GetMapping
(
"callback"
)
public
String
callback
(
String
code
,
String
state
){
//得到授权临时票据code
System
.
out
.
println
(
code
);
System
.
out
.
println
(
state
);
//从redis中将state获取出来,和当前传入的state作比较
//如果一致则放行,如果不一致则抛出异常:非法访问
//向认证服务器发送请求换取access_token
String
baseAccessTokenUrl
=
"https://api.weixin.qq.com/sns/oauth2/access_token"
+
"?appid=%s"
+
"&secret=%s"
+
"&code=%s"
+
"&grant_type=authorization_code"
;
String
accessTokenUrl
=
String
.
format
(
baseAccessTokenUrl
,
ConstantPropertiesUtil
.
WX_OPEN_APP_ID
,
ConstantPropertiesUtil
.
WX_OPEN_APP_SECRET
,
code
);
String
result
=
null
;
try
{
result
=
HttpUtil
.
get
(
accessTokenUrl
);
System
.
out
.
println
(
"accessToken============="
+
result
);
}
catch
(
Exception
e
)
{
}
//解析json字符串
Gson
gson
=
new
Gson
();
HashMap
map
=
gson
.
fromJson
(
result
,
HashMap
.
class
);
String
accessToken
=
(
String
)
map
.
get
(
"access_token"
);
String
openid
=
(
String
)
map
.
get
(
"openid"
);
//查询数据库当前用用户是否曾经使用过微信登录
// Member member = memberService.getByOpenid(openid);
Member
member
=
null
;
if
(
member
==
null
){
System
.
out
.
println
(
"新用户注册"
);
//访问微信的资源服务器,获取用户信息
String
baseUserInfoUrl
=
"https://api.weixin.qq.com/sns/userinfo"
+
"?access_token=%s"
+
"&openid=%s"
;
String
userInfoUrl
=
String
.
format
(
baseUserInfoUrl
,
accessToken
,
openid
);
String
resultUserInfo
=
null
;
try
{
resultUserInfo
=
HttpUtil
.
get
(
userInfoUrl
);
System
.
out
.
println
(
"resultUserInfo=========="
+
resultUserInfo
);
}
catch
(
Exception
e
)
{
}
//解析json
HashMap
<
String
,
Object
>
mapUserInfo
=
gson
.
fromJson
(
resultUserInfo
,
HashMap
.
class
);
String
nickname
=
(
String
)
mapUserInfo
.
get
(
"nickname"
);
String
headimgurl
=
(
String
)
mapUserInfo
.
get
(
"headimgurl"
);
//向数据库中插入一条记录
member
=
new
Member
();
member
.
setNickname
(
nickname
);
member
.
setOpenid
(
openid
);
member
.
setAvatar
(
headimgurl
);
// memberService.save(member);
System
.
out
.
println
(
"插入数据库"
);
}
//TODO 登录
return
"redirect:http://localhost:3000"
;
}
}
fm-system/src/main/java/com/skua/modules/system/util/ConstantPropertiesUtil.java
0 → 100644
查看文件 @
7a86522
package
com
.
skua
.
modules
.
system
.
util
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ConstantPropertiesUtil
implements
InitializingBean
{
@Value
(
"${wx.app-id}"
)
private
String
appId
;
@Value
(
"${wx.app-secret}"
)
private
String
appSecret
;
@Value
(
"${wx.redirect-url}"
)
private
String
redirectUrl
;
public
static
String
WX_OPEN_APP_ID
;
public
static
String
WX_OPEN_APP_SECRET
;
public
static
String
WX_OPEN_REDIRECT_URL
;
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
WX_OPEN_APP_ID
=
appId
;
WX_OPEN_APP_SECRET
=
appSecret
;
WX_OPEN_REDIRECT_URL
=
redirectUrl
;
}
}
fm-system/src/main/java/com/skua/modules/system/vo/Member.java
0 → 100644
查看文件 @
7a86522
package
com
.
skua
.
modules
.
system
.
vo
;
import
lombok.Data
;
@Data
public
class
Member
{
/**名称*/
private
String
nickname
;
/**openId*/
private
String
openid
;
/**头像*/
private
String
avatar
;
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论