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
a45b1c62
Commit
a45b1c62
authored
May 31, 2021
by
YANGYANG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户管理 终版提交
parent
5da72e86
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
114 additions
and
164 deletions
+114
-164
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/Device.java
+1
-1
common/common_utils/src/main/java/com/founder/commonutils/zdryEntity/UsersAndDevice.java
+17
-76
service/zdry/src/main/java/com/founder/zdry/ZdryApplication.java
+2
-0
service/zdry/src/main/java/com/founder/zdry/controller/UsersController.java
+33
-18
service/zdry/src/main/java/com/founder/zdry/fegin/ServerZdryApi.java
+8
-10
service/zdry/src/main/java/com/founder/zdry/fegin/fallback/FallBackZdryApi.java
+26
-0
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/fallback/FallBackZdryApi.java
+0
-31
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/controller/ZdryApiController.java
+4
-4
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
+3
-3
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
+20
-21
No files found.
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/
d
evice.java
→
common/common_utils/src/main/java/com/founder/commonutils/ZdryApiEntity/
D
evice.java
View file @
a45b1c62
...
...
@@ -16,7 +16,7 @@ import java.io.Serializable;
*/
@Data
@ApiModel
(
value
=
"device对象"
,
description
=
"device对象"
)
public
class
d
evice
implements
Serializable
{
public
class
D
evice
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
common/common_utils/src/main/java/com/founder/commonutils/zdryEntity/UsersAndDevice.java
View file @
a45b1c62
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
com.founder.commonutils.ZdryApiEntity.Device
;
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>
...
...
@@ -19,78 +11,27 @@ import java.util.Date;
* </p>
*
* @author yangyang
* @since 2021-05-3
0
* @since 2021-05-3
1
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@ApiModel
(
value
=
"Users对象"
,
description
=
""
)
@ApiModel
(
value
=
"UsersAndDevice对象"
,
description
=
"UsersAndDevice对象"
)
public
class
UsersAndDevice
implements
Serializable
{
private
Users
users
;
private
Device
device
;
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
;
public
Users
getUsers
()
{
return
users
;
}
@ApiModelProperty
(
value
=
"信息删除判断标志 1删除 0未删除"
)
private
Integer
xxscPdbz
;
public
void
setUsers
(
Users
users
)
{
this
.
users
=
users
;
}
public
Device
getDevice
()
{
return
device
;
}
public
void
setDevice
(
Device
device
)
{
this
.
device
=
device
;
}
}
service/zdry/src/main/java/com/founder/zdry/ZdryApplication.java
View file @
a45b1c62
...
...
@@ -3,11 +3,13 @@ package com.founder.zdry;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.ComponentScan
;
@SpringBootApplication
@ComponentScan
(
basePackages
=
{
"com.founder"
})
@EnableDiscoveryClient
@EnableFeignClients
public
class
ZdryApplication
{
...
...
service/zdry/src/main/java/com/founder/zdry/controller/UsersController.java
View file @
a45b1c62
...
...
@@ -6,7 +6,8 @@ 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.commonutils.zdryEntity.UsersAndDevice
;
import
com.founder.zdry.fegin.ServerZdryApi
;
import
com.founder.zdry.service.UsersService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -83,36 +84,50 @@ public class UsersController {
public
MapRestResult
getById
(
@ApiParam
(
name
=
"sbimei"
,
value
=
"设备IMEI"
,
required
=
true
)
@PathVariable
String
sbimei
){
UsersAndDevice
usersAndDevice
=
new
UsersAndDevice
();
Users
users
=
usersService
.
getById
(
sbimei
);
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功获取用户信息"
,
"1"
,
users
);
usersAndDevice
.
setUsers
(
users
);
usersAndDevice
.
setDevice
(
serverZdryApi
.
getDevice
(
sbimei
));
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功获取用户信息"
,
"1"
,
usersAndDevice
);
}
@ApiOperation
(
value
=
"新增用户"
)
@PostMapping
(
"/saveUsers"
)
public
MapRestResult
saveUsers
(
@ApiParam
(
name
=
"users"
,
value
=
"用户对象"
,
required
=
true
)
@RequestBody
Users
users
)
{
boolean
flag
=
usersService
.
save
(
users
);
if
(
flag
){
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功保存用户信息"
,
"1"
);
public
MapRestResult
saveUsers
(
@ApiParam
(
name
=
"UsersAndDevice"
,
value
=
"用户对象"
,
required
=
true
)
@RequestBody
UsersAndDevice
usersAndDevice
)
{
// 调用开关接口
String
result
=
serverZdryApi
.
updateDevice
(
usersAndDevice
.
getDevice
());
if
(
result
.
equals
(
"success"
)){
boolean
flag
=
usersService
.
save
(
usersAndDevice
.
getUsers
());
if
(
flag
){
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功保存用户信息"
,
"1"
);
}
else
{
return
MapRestResult
.
build
(
ResultCode
.
ERROR
,
"保存用户信息失败"
,
"1"
);
}
}
else
{
return
MapRestResult
.
build
(
ResultCode
.
ERROR
,
"保存用户信息失败"
,
"1"
);
return
MapRestResult
.
build
(
ResultCode
.
ERROR
,
"保存用户开关信息失败"
,
"1"
);
}
}
@ApiOperation
(
value
=
"根据设备IMEI修改用户信息"
)
@PostMapping
(
"/updateUsersBySbImei"
)
public
MapRestResult
savePermission
(
@ApiParam
(
name
=
"users"
,
value
=
"用户对象"
,
required
=
true
)
@RequestBody
Users
users
)
{
boolean
flag
=
usersService
.
updateById
(
users
);
if
(
flag
){
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功修改用户信息"
,
"1"
);
public
MapRestResult
savePermission
(
@ApiParam
(
name
=
"UsersAndDevice"
,
value
=
"用户对象"
,
required
=
true
)
@RequestBody
UsersAndDevice
usersAndDevice
)
{
// 调用开关接口
String
result
=
serverZdryApi
.
updateDevice
(
usersAndDevice
.
getDevice
());
if
(
result
.
equals
(
"success"
)){
boolean
flag
=
usersService
.
updateById
(
usersAndDevice
.
getUsers
());
if
(
flag
){
return
MapRestResult
.
build
(
ResultCode
.
SUCCESS
,
"成功修改用户信息"
,
"1"
);
}
else
{
return
MapRestResult
.
build
(
ResultCode
.
ERROR
,
"修改用户开关信息失败"
,
"1"
);
}
}
else
{
return
MapRestResult
.
build
(
ResultCode
.
ERROR
,
"修改用户信息失败"
,
"1"
);
}
}
...
...
service/zdry/src/main/java/com/founder/zdry/fegin/
fegin/
ServerZdryApi.java
→
service/zdry/src/main/java/com/founder/zdry/fegin/ServerZdryApi.java
View file @
a45b1c62
package
com
.
founder
.
zdry
.
fegin
.
fegin
;
package
com
.
founder
.
zdry
.
fegin
;
import
com.founder.commonutils.ZdryApiEntity.
d
evice
;
import
com.founder.zdry.fegin.f
egin.f
allback.FallBackZdryApi
;
import
com.founder.commonutils.ZdryApiEntity.
D
evice
;
import
com.founder.zdry.fegin.fallback.FallBackZdryApi
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
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子系统
...
...
@@ -16,9 +14,9 @@ import java.util.Map;
@FeignClient
(
value
=
"zdryapi"
,
fallback
=
FallBackZdryApi
.
class
)
public
interface
ServerZdryApi
{
@
Reque
stMapping
(
"/zdryapi/getDevice"
)
public
Map
<
String
,
Object
>
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
);
@
Po
stMapping
(
"/zdryapi/getDevice"
)
Device
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
);
@
Reque
stMapping
(
"/zdryapi/updateDevice"
)
public
Map
<
String
,
Object
>
updateDevice
(
@RequestBody
d
evice
deviceParam
);
@
Po
stMapping
(
"/zdryapi/updateDevice"
)
String
updateDevice
(
@RequestBody
D
evice
deviceParam
);
}
service/zdry/src/main/java/com/founder/zdry/fegin/fallback/FallBackZdryApi.java
0 → 100644
View file @
a45b1c62
package
com
.
founder
.
zdry
.
fegin
.
fallback
;
import
com.founder.commonutils.ZdryApiEntity.Device
;
import
com.founder.zdry.fegin.ServerZdryApi
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* Created by yangyang on 2021/05/31
* 调用ZdryApi子系统异常反馈
**/
@Component
public
class
FallBackZdryApi
implements
ServerZdryApi
{
@Override
public
Device
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
return
null
;
}
@Override
public
String
updateDevice
(
@RequestBody
Device
deviceParam
)
{
return
"zdryapi服务器发生异常,断路器进行反馈"
;
}
}
\ No newline at end of file
service/zdry/src/main/java/com/founder/zdry/fegin/fegin/fallback/FallBackZdryApi.java
deleted
100644 → 0
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
View file @
a45b1c62
package
com
.
founder
.
zdryapi
.
controller
;
import
com.founder.commonutils.ZdryApiEntity.
d
evice
;
import
com.founder.commonutils.ZdryApiEntity.
D
evice
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
io.swagger.annotations.Api
;
...
...
@@ -37,9 +37,9 @@ public class ZdryApiController {
@ApiOperation
(
value
=
"查看指定设备接口"
)
@PostMapping
(
value
=
"/getDevice"
)
public
MapRestResult
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
public
Device
getDevice
(
@RequestParam
(
value
=
"deviceId"
)
String
deviceId
)
{
long
startTime
=
new
Date
().
getTime
();
MapRestResult
result
=
zdryApiService
.
getDevice
(
deviceId
);
Device
result
=
zdryApiService
.
getDevice
(
deviceId
);
long
endTime
=
new
Date
().
getTime
();
long
timeDiffer
=
endTime
-
startTime
;
System
.
out
.
println
(
"查看指定设备接口**请求时长**********"
+
timeDiffer
+
"毫秒"
);
...
...
@@ -48,7 +48,7 @@ public class ZdryApiController {
@ApiOperation
(
value
=
"修改指定设备接口"
)
@PostMapping
(
value
=
"/updateDevice"
)
public
MapRestResult
updateDevice
(
@RequestBody
d
evice
deviceParam
)
{
public
String
updateDevice
(
@RequestBody
D
evice
deviceParam
)
{
return
zdryApiService
.
updateDevice
(
deviceParam
);
}
}
...
...
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/ZdryApiService.java
View file @
a45b1c62
package
com
.
founder
.
zdryapi
.
service
;
import
com.founder.commonutils.ZdryApiEntity.
d
evice
;
import
com.founder.commonutils.ZdryApiEntity.
D
evice
;
import
com.founder.commonutils.publicEntity.MapRestResult
;
/**
...
...
@@ -15,7 +15,7 @@ public interface ZdryApiService {
String
getToken
();
MapRestResult
getDevice
(
String
deviceId
);
Device
getDevice
(
String
deviceId
);
MapRestResult
updateDevice
(
d
evice
deviceParam
);
String
updateDevice
(
D
evice
deviceParam
);
}
serviceapi/zdryapi/src/main/java/com/founder/zdryapi/service/impl/ZdryApiServiceImpl.java
View file @
a45b1c62
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.commonutils.ZdryApiEntity.Device
;
import
com.founder.zdryapi.service.ZdryApiService
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -49,8 +48,8 @@ public class ZdryApiServiceImpl implements ZdryApiService {
@Autowired
private
RestTemplate
restTemplate
;
public
MapRestResult
getDevice
(
String
deviceId
){
device
d
=
new
d
evice
();
public
Device
getDevice
(
String
deviceId
){
Device
device
=
new
D
evice
();
try
{
String
resultString
=
restTemplate
.
getForEntity
(
zdryUrl
+
sbxxUrl
+
deviceId
,
String
.
class
).
getBody
();
if
(
StringUtils
.
isNotEmpty
(
resultString
))
{
...
...
@@ -61,7 +60,7 @@ public class ZdryApiServiceImpl implements ZdryApiService {
if
(
getToken
().
equals
(
"success"
)){
getDevice
(
deviceId
);
}
else
{
return
MapRestResult
.
build
(
200
,
"查看设备信息失败"
,
1
)
;
return
device
;
};
}
if
(
result
.
containsKey
(
"obj"
))
{
...
...
@@ -71,35 +70,35 @@ public class ZdryApiServiceImpl implements ZdryApiService {
String
track_enable
=
dataObject
.
getString
(
"track_enable"
);
String
heartrate_enable
=
dataObject
.
getString
(
"heartrate_enable"
);
if
(
pedometer_enable
.
equals
(
"true"
)){
d
.
setPedometer_enable
(
1
);
d
evice
.
setPedometer_enable
(
1
);
}
else
{
d
.
setPedometer_enable
(
0
);
d
evice
.
setPedometer_enable
(
0
);
}
if
(
sleep_enable
.
equals
(
"true"
)){
d
.
setSleep_enable
(
1
);
d
evice
.
setSleep_enable
(
1
);
}
else
{
d
.
setSleep_enable
(
0
);
d
evice
.
setSleep_enable
(
0
);
}
if
(
track_enable
.
equals
(
"true"
)){
d
.
setTrack_enable
(
1
);
d
evice
.
setTrack_enable
(
1
);
}
else
{
d
.
setTrack_enable
(
0
);
d
evice
.
setTrack_enable
(
0
);
}
if
(
heartrate_enable
.
equals
(
"true"
)){
d
.
setHeartrate_enable
(
1
);
d
evice
.
setHeartrate_enable
(
1
);
}
else
{
d
.
setHeartrate_enable
(
0
);
d
evice
.
setHeartrate_enable
(
0
);
}
d
.
setSbImei
(
deviceId
);
d
evice
.
setSbImei
(
deviceId
);
}
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"查看设备信息成功"
,
d
)
;
return
device
;
}
public
MapRestResult
updateDevice
(
d
evice
deviceParam
){
public
String
updateDevice
(
D
evice
deviceParam
){
try
{
HttpHeaders
headers
=
new
HttpHeaders
();
MediaType
type
=
MediaType
.
parseMediaType
(
"application/json"
);
...
...
@@ -108,8 +107,8 @@ public class ZdryApiServiceImpl implements ZdryApiService {
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"heartrate_enable"
,
deviceParam
.
getHeartrate_enable
());
json
.
put
(
"pedometer_enable"
,
deviceParam
.
getPedometer_enable
());
json
.
put
(
"
S
leep_enable"
,
deviceParam
.
getSleep_enable
());
json
.
put
(
"
T
rack_enable"
,
deviceParam
.
getTrack_enable
());
json
.
put
(
"
s
leep_enable"
,
deviceParam
.
getSleep_enable
());
json
.
put
(
"
t
rack_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
);
...
...
@@ -119,16 +118,16 @@ public class ZdryApiServiceImpl implements ZdryApiService {
if
(
getToken
().
equals
(
"success"
)){
updateDevice
(
deviceParam
);
}
else
{
return
MapRestResult
.
build
(
200
,
"修改设备信息失败"
,
1
)
;
return
"error"
;
};
}
if
(
result
.
containsKey
(
"success"
))
{
return
MapRestResult
.
build
(
200
,
"修改设备信息成功"
,
1
)
;
return
"success"
;
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
MapRestResult
.
build
(
200
,
"修改设备信息成功"
,
1
)
;
return
"success"
;
}
public
String
getToken
()
{
...
...
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