Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
map-parent
Commits
5da72e86
Commit
5da72e86
authored
May 31, 2021
by
YANGYANG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户管理 初版提交
parent
21743d5b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
421 additions
and
0 deletions
+421
-0
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/device.java
+37
-0
common/common_utils/src/main/java/com/founder/commonutils/zdryEntity/UsersAndDevice.java
+96
-0
service/zdry/src/main/java/com/founder/zdry/controller/UsersController.java
+3
-0
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/ServerZdryApi.java
+24
-0
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/fallback/FallBackZdryApi.java
+31
-0
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/controller/ZdryApiController.java
+55
-0
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
+21
-0
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
+154
-0
No files found.
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/device.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
commonutils
.
ZdryApiEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
@Data
@ApiModel
(
value
=
"device对象"
,
description
=
"device对象"
)
public
class
device
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
" 计步数据开关"
)
int
pedometer_enable
;
@ApiModelProperty
(
value
=
"睡眠数据开关"
)
int
sleep_enable
;
@ApiModelProperty
(
value
=
"轨迹开关"
)
int
track_enable
;
@ApiModelProperty
(
value
=
"心率、血氧、血压定时测量开关"
)
int
heartrate_enable
;
@ApiModelProperty
(
value
=
"IMEI"
)
String
sbImei
;
}
common/common_utils/src/main/java/com/founder/commonutils/zdryEntity/UsersAndDevice.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
commonutils
.
zdryEntity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
* <p>
*
* </p>
*
* @author yangyang
* @since 2021-05-30
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"Users对象"
,
description
=
""
)
public
class
UsersAndDevice
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"姓名"
)
private
String
xm
;
@ApiModelProperty
(
value
=
"性别 1男 2女 0未知"
)
private
Integer
xb
;
@ApiModelProperty
(
value
=
"家庭住址"
)
private
String
jtZz
;
@ApiModelProperty
(
value
=
"是否有前科 1是 0否"
)
private
Integer
sfyQk
;
@ApiModelProperty
(
value
=
"现住址"
)
private
String
xzz
;
@ApiModelProperty
(
value
=
"病史"
)
private
String
bs
;
@ApiModelProperty
(
value
=
"病情等级 1低 2中 3高 4极高"
)
private
Integer
bqDj
;
@ApiModelProperty
(
value
=
"监护人1姓名"
)
private
String
jhr1Xm
;
@ApiModelProperty
(
value
=
"监护人1关系"
)
private
String
jhr1Gx
;
@ApiModelProperty
(
value
=
"监护人1联系电话"
)
private
String
jhr1Lxdh
;
@ApiModelProperty
(
value
=
"监护人1紧急电话"
)
private
String
jhr1Jjdh
;
@ApiModelProperty
(
value
=
"监护人2姓名"
)
private
String
jhr2Xm
;
@ApiModelProperty
(
value
=
"监护人2关系"
)
private
String
jhr2Gx
;
@ApiModelProperty
(
value
=
"监护人2联系电话"
)
private
String
jhr2Lxdh
;
@ApiModelProperty
(
value
=
"监护人2紧急电话"
)
private
String
jhr2Jjdh
;
@ApiModelProperty
(
value
=
"设备IMEI"
)
@TableId
(
value
=
"sb_imei"
,
type
=
IdType
.
ID_WORKER_STR
)
private
String
sbImei
;
@ApiModelProperty
(
value
=
"设备型号"
)
private
String
sbXh
;
@ApiModelProperty
(
value
=
"登记时间"
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
djsj
;
@ApiModelProperty
(
value
=
"改写时间"
)
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
gxsj
;
@ApiModelProperty
(
value
=
"信息删除判断标志 1删除 0未删除"
)
private
Integer
xxscPdbz
;
}
service/zdry/src/main/java/com/founder/zdry/controller/UsersController.java
View file @
5da72e86
...
...
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.commonutils.publicEntity.ResultCode
;
import
com.founder.commonutils.zdryEntity.Users
;
import
com.founder.zdry.fegin.fegin.ServerZdryApi
;
import
com.founder.zdry.service.UsersService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -31,6 +32,8 @@ public class UsersController {
@Autowired
private
UsersService
usersService
;
@Autowired
private
ServerZdryApi
serverZdryApi
;
@ApiOperation
(
value
=
"分页用户列表"
)
@GetMapping
(
"userPageList/{page}/{limit}"
)
...
...
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/ServerZdryApi.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
zdry
.
fegin
.
fegin
;
import
com.founder.commonutils.ZdryApiEntity.device
;
import
com.founder.zdry.fegin.fegin.fallback.FallBackZdryApi
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.Map
;
/**
* Created by yyon 2021/05/31
* 调用zdryapi子系统
**/
@FeignClient
(
value
=
"zdryapi"
,
fallback
=
FallBackZdryApi
.
class
)
public
interface
ServerZdryApi
{
@RequestMapping
(
"/zdryapi/getDevice"
)
public
Map
<
String
,
Object
>
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
);
@RequestMapping
(
"/zdryapi/updateDevice"
)
public
Map
<
String
,
Object
>
updateDevice
(
@RequestBody
device
deviceParam
);
}
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/fallback/FallBackZdryApi.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
zdry
.
fegin
.
fegin
.
fallback
;
import
com.founder.commonutils.ZdryApiEntity.device
;
import
com.founder.zdry.fegin.fegin.ServerZdryApi
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* Created by yyon 2021/05/31
* 调用zdryapi子系统
**/
@Component
public
class
FallBackZdryApi
implements
ServerZdryApi
{
@Override
public
Map
<
String
,
Object
>
getDevice
(
String
deviceId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"msg"
,
"server-bz服务器发生异常,断路器进行反馈"
);
return
map
;
}
@Override
public
Map
<
String
,
Object
>
updateDevice
(
device
deviceParam
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"msg"
,
"server-bz服务器发生异常,断路器进行反馈"
);
return
map
;
}
}
\ No newline at end of file
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/controller/ZdryApiController.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
zdryapi
.
controller
;
import
com.founder.commonutils.ZdryApiEntity.device
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
/**
* <p>
* 第三方爱牵挂接口管理 前端控制器
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
@Api
(
description
=
"第三方接口管理-爱牵挂"
)
@RestController
@RequestMapping
(
"/zdryapi"
)
@Component
public
class
ZdryApiController
{
@Autowired
private
ZdryApiService
zdryApiService
;
//获取token
@ApiOperation
(
value
=
"token获取"
)
@PostMapping
(
"/token"
)
public
MapRestResult
getToken
()
{
String
accessToken
=
zdryApiService
.
getToken
();
return
MapRestResult
.
build
(
202
,
"成功获取token信息"
,
accessToken
);
}
@ApiOperation
(
value
=
"查看指定设备接口"
)
@PostMapping
(
value
=
"/getDevice"
)
public
MapRestResult
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
long
startTime
=
new
Date
().
getTime
();
MapRestResult
result
=
zdryApiService
.
getDevice
(
deviceId
);
long
endTime
=
new
Date
().
getTime
();
long
timeDiffer
=
endTime
-
startTime
;
System
.
out
.
println
(
"查看指定设备接口**请求时长**********"
+
timeDiffer
+
"毫秒"
);
return
result
;
}
@ApiOperation
(
value
=
"修改指定设备接口"
)
@PostMapping
(
value
=
"/updateDevice"
)
public
MapRestResult
updateDevice
(
@RequestBody
device
deviceParam
)
{
return
zdryApiService
.
updateDevice
(
deviceParam
);
}
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
zdryapi
.
service
;
import
com.founder.commonutils.ZdryApiEntity.device
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
/**
* <p>
* 接口 服务类
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
public
interface
ZdryApiService
{
String
getToken
();
MapRestResult
getDevice
(
String
deviceId
);
MapRestResult
updateDevice
(
device
deviceParam
);
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
0 → 100644
View file @
5da72e86
package
com
.
founder
.
zdryapi
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.founder.commonutils.ZdryApiEntity.device
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
/*
*
* <p>
* 云天接口 服务实现类
* </p>
*
* @author yangyang
* @since 2021-05-31
*/
@Service
public
class
ZdryApiServiceImpl
implements
ZdryApiService
{
@Value
(
"${username}"
)
private
String
username
;
@Value
(
"${password}"
)
private
String
password
;
@Value
(
"${zdryUrl}"
)
private
String
zdryUrl
;
@Value
(
"${loginUrl}"
)
private
String
loginUrl
;
@Value
(
"${sbxxUrl}"
)
private
String
sbxxUrl
;
@Value
(
"${updateSbxxUrl}"
)
private
String
updateSbxxUrl
;
@Autowired
private
RestTemplate
restTemplate
;
public
MapRestResult
getDevice
(
String
deviceId
){
device
d
=
new
device
();
try
{
String
resultString
=
restTemplate
.
getForEntity
(
zdryUrl
+
sbxxUrl
+
deviceId
,
String
.
class
).
getBody
();
if
(
StringUtils
.
isNotEmpty
(
resultString
))
{
JSONObject
result
=
JSONObject
.
parseObject
(
resultString
);
// 查看是否登录{"error_desc": "\u60a8\u7684\u767b\u5f55\u72b6\u6001\u5df2\u7ecf\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u9646", "error_code": 101, "error_url": "/api/device/868221001088478", "success": false}
if
(
result
.
containsKey
(
"error_code"
))
{
if
(
getToken
().
equals
(
"success"
)){
getDevice
(
deviceId
);
}
else
{
return
MapRestResult
.
build
(
200
,
"查看设备信息失败"
,
1
);
};
}
if
(
result
.
containsKey
(
"obj"
))
{
JSONObject
dataObject
=
result
.
getJSONObject
(
"obj"
);
String
pedometer_enable
=
dataObject
.
getString
(
"pedometer_enable"
);
String
sleep_enable
=
dataObject
.
getString
(
"sleep_enable"
);
String
track_enable
=
dataObject
.
getString
(
"track_enable"
);
String
heartrate_enable
=
dataObject
.
getString
(
"heartrate_enable"
);
if
(
pedometer_enable
.
equals
(
"true"
)){
d
.
setPedometer_enable
(
1
);
}
else
{
d
.
setPedometer_enable
(
0
);
}
if
(
sleep_enable
.
equals
(
"true"
)){
d
.
setSleep_enable
(
1
);
}
else
{
d
.
setSleep_enable
(
0
);
}
if
(
track_enable
.
equals
(
"true"
)){
d
.
setTrack_enable
(
1
);
}
else
{
d
.
setTrack_enable
(
0
);
}
if
(
heartrate_enable
.
equals
(
"true"
)){
d
.
setHeartrate_enable
(
1
);
}
else
{
d
.
setHeartrate_enable
(
0
);
}
d
.
setSbImei
(
deviceId
);
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"查看设备信息成功"
,
d
);
}
public
MapRestResult
updateDevice
(
device
deviceParam
){
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
MediaType
type
=
MediaType
.
parseMediaType
(
"application/json"
);
// 设置请求的格式类型
headers
.
setContentType
(
type
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"heartrate_enable"
,
deviceParam
.
getHeartrate_enable
());
json
.
put
(
"pedometer_enable"
,
deviceParam
.
getPedometer_enable
());
json
.
put
(
"Sleep_enable"
,
deviceParam
.
getSleep_enable
());
json
.
put
(
"Track_enable"
,
deviceParam
.
getTrack_enable
());
HttpEntity
<
JSONObject
>
params
=
new
HttpEntity
<>(
json
,
headers
);
String
resultString
=
restTemplate
.
postForEntity
(
zdryUrl
+
updateSbxxUrl
+
deviceParam
.
getSbImei
()+
"/4g/edit/"
,
params
,
String
.
class
).
getBody
();
JSONObject
result
=
JSONObject
.
parseObject
(
resultString
);
// 查看是否登录
if
(
result
.
containsKey
(
"error_code"
))
{
if
(
getToken
().
equals
(
"success"
)){
updateDevice
(
deviceParam
);
}
else
{
return
MapRestResult
.
build
(
200
,
"修改设备信息失败"
,
1
);
};
}
if
(
result
.
containsKey
(
"success"
))
{
return
MapRestResult
.
build
(
200
,
"修改设备信息成功"
,
1
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"修改设备信息成功"
,
1
);
}
public
String
getToken
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
MediaType
type
=
MediaType
.
parseMediaType
(
"application/json"
);
// 设置请求的格式类型
headers
.
setContentType
(
type
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"username"
,
"18234077206"
);
json
.
put
(
"password"
,
"cc150520"
);
HttpEntity
<
JSONObject
>
params
=
new
HttpEntity
<>(
json
,
headers
);
String
resultString
=
restTemplate
.
postForEntity
(
zdryUrl
+
loginUrl
,
params
,
String
.
class
).
getBody
();
JSONObject
result
=
JSONObject
.
parseObject
(
resultString
);
// 查看是否登录
if
(
result
.
containsKey
(
"error_code"
))
{
return
"error"
;
}
else
{
return
"success"
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment