Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-devicemonitor
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 56a1fd5c
authored
Jul 05, 2021
by
黄小葱
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
引入mybatis、查询设备信息
1 parent
0b076bd3
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
299 additions
and
1 deletions
pom.xml
src/main/java/cn/com/glsx/Application.java
src/main/java/cn/com/glsx/devicemonitor/modules/controller/DeviceController.java
src/main/java/cn/com/glsx/devicemonitor/modules/entity/Device.java
src/main/java/cn/com/glsx/devicemonitor/modules/mapper/DeviceMapper.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/DeviceDTO.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/DeviceService.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
src/main/resources/bootstrap.properties
src/main/resources/mapper/DeviceMapper.xml
src/test/java/cn/com/glsx/test/gpsbs/TestDeviceController.java
pom.xml
View file @
56a1fd5
...
@@ -26,6 +26,11 @@
...
@@ -26,6 +26,11 @@
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-mybatis
</artifactId>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
glsx-ne-shield-common
</artifactId>
<artifactId>
glsx-ne-shield-common
</artifactId>
<version>
${neshield.common.version}
</version>
<version>
${neshield.common.version}
</version>
<scope>
compile
</scope>
<scope>
compile
</scope>
...
...
src/main/java/cn/com/glsx/Application.java
View file @
56a1fd5
...
@@ -25,7 +25,7 @@ import static java.util.TimeZone.getTimeZone;
...
@@ -25,7 +25,7 @@ import static java.util.TimeZone.getTimeZone;
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
})
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
})
@EnableTransactionManagement
@EnableTransactionManagement
@EnableMBeanExport
(
registration
=
RegistrationPolicy
.
IGNORE_EXISTING
)
@EnableMBeanExport
(
registration
=
RegistrationPolicy
.
IGNORE_EXISTING
)
@SpringBootApplication
(
scanBasePackages
=
{
"cn.com.glsx.devicemonitor
"
,
"cn.com.glsx.auth
"
})
@SpringBootApplication
(
scanBasePackages
=
{
"cn.com.glsx.devicemonitor
.*
"
})
public
class
Application
{
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/controller/DeviceController.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
controller
;
import
cn.com.glsx.devicemonitor.modules.model.DeviceDTO
;
import
cn.com.glsx.devicemonitor.modules.service.DeviceService
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.constraints.NotBlank
;
@Slf4j
@Validated
@RestController
@RequestMapping
(
"/device"
)
public
class
DeviceController
{
@Autowired
private
DeviceService
deviceService
;
/**
* 根据设备号查询设备信息
* @param sn
* @return
*/
@GetMapping
(
value
=
"/getDeviceBySn"
)
public
R
getDeviceBySn
(
@NotBlank
(
message
=
"设备号不能为空"
)
@RequestParam
(
value
=
"sn"
)
String
sn
)
{
DeviceDTO
deviceDTO
=
deviceService
.
getDeviceBySn
(
sn
);
return
R
.
ok
().
data
(
deviceDTO
);
}
}
src/main/java/cn/com/glsx/devicemonitor/modules/entity/Device.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
@Data
@Table
(
name
=
"t_device"
)
public
class
Device
extends
BaseEntity
{
/**
* 设备名称
*/
private
String
name
;
/**
* 设备序列号
*/
private
String
sn
;
/**
* 国际移动用户识别码
*/
private
String
imsi
;
/**
* 集成电路卡识别码
*/
private
String
iccid
;
/**
* 国际移动设备识别码
*/
private
String
imei
;
/**
* 用户识别卡
*/
private
String
sim
;
/**
* 校验码
*/
@Column
(
name
=
"check_code"
)
private
String
checkCode
;
/**
* 设备类型
*/
@Column
(
name
=
"device_type"
)
private
Integer
deviceType
;
/**
* 设备厂商
*/
private
String
manufacturer
;
/**
* 型号id
*/
@Column
(
name
=
"model_id"
)
private
Integer
modelId
;
/**
* 型号名称
*/
@Column
(
name
=
"model_name"
)
private
String
modelName
;
/**
* 固件版本
*/
@Column
(
name
=
"soft_version"
)
private
String
softVersion
;
/**
* 1有源 0无源
*/
private
Integer
source
;
/**
* 激活状态:0未激活,1激活
*/
@Column
(
name
=
"activate_status"
)
private
Integer
activateStatus
;
/**
* 激活时间
*/
@Column
(
name
=
"activate_time"
)
private
Date
activateTime
;
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/devicemonitor/modules/mapper/DeviceMapper.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
mapper
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
DeviceMapper
extends
CommonBaseMapper
<
Device
>
{
Device
selectBySn
(
String
sn
);
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/devicemonitor/modules/model/DeviceDTO.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
model
;
import
lombok.Data
;
import
javax.persistence.Column
;
@Data
public
class
DeviceDTO
{
private
String
sn
;
/**
* 1有源 0无源
*/
private
Integer
source
;
/**
* 校验码
*/
private
String
checkCode
;
/**
* 设备类型
*/
private
Integer
deviceType
;
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/DeviceService.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
service
;
import
cn.com.glsx.devicemonitor.modules.model.DeviceDTO
;
public
interface
DeviceService
{
/**
* 根据设备号查询设备信息
* @param sn
* @return
*/
DeviceDTO
getDeviceBySn
(
String
sn
);
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
service
.
impl
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper
;
import
cn.com.glsx.devicemonitor.modules.model.DeviceDTO
;
import
cn.com.glsx.devicemonitor.modules.service.DeviceService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
public
class
DeviceServiceImpl
implements
DeviceService
{
@Autowired
private
DeviceMapper
deviceMapper
;
@Override
public
DeviceDTO
getDeviceBySn
(
String
sn
)
{
Device
device
=
deviceMapper
.
selectBySn
(
sn
);
DeviceDTO
deviceDTO
=
new
DeviceDTO
();
BeanUtils
.
copyProperties
(
device
,
deviceDTO
);
return
deviceDTO
;
}
}
src/main/resources/bootstrap.properties
View file @
56a1fd5
...
@@ -31,3 +31,14 @@ spring.cloud.nacos.config.prefix=${spring.application.name}
...
@@ -31,3 +31,14 @@ spring.cloud.nacos.config.prefix=${spring.application.name}
spring.profiles.active
=
${profile.active}
spring.profiles.active
=
${profile.active}
#配置格式
#配置格式
spring.cloud.nacos.config.file-
extension
=
properties
spring.cloud.nacos.config.file-
extension
=
properties
#微服务sentinel、zipkin、actuator等公共配置
spring.cloud.nacos.config.shared-configs[0].data-
id
=
glsx-rest-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0]
.group
=
DEV_GROUP
spring.cloud.nacos.config.shared-configs[0]
.refresh
=
true
#数据库、redis等公共配置
spring.cloud.nacos.config.shared-configs[1]
.group
=
NESHIELD_DEV_GROUP
spring.cloud.nacos.config.shared-configs[1].data-
id
=
glsx-ne-shield-share-dev.properties
spring.cloud.nacos.config.shared-configs[1]
.refresh
=
true
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/DeviceMapper.xml
0 → 100644
View file @
56a1fd5
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.devicemonitor.modules.entity.Device"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"imsi"
jdbcType=
"VARCHAR"
property=
"imsi"
/>
<result
column=
"iccid"
jdbcType=
"VARCHAR"
property=
"iccid"
/>
<result
column=
"imei"
jdbcType=
"VARCHAR"
property=
"imei"
/>
<result
column=
"sim"
jdbcType=
"VARCHAR"
property=
"sim"
/>
<result
column=
"check_code"
jdbcType=
"VARCHAR"
property=
"checkCode"
/>
<result
column=
"device_type"
jdbcType=
"INTEGER"
property=
"deviceType"
/>
<result
column=
"manufacturer"
jdbcType=
"VARCHAR"
property=
"manufacturer"
/>
<result
column=
"model_id"
jdbcType=
"INTEGER"
property=
"modelId"
/>
<result
column=
"model_name"
jdbcType=
"VARCHAR"
property=
"modelName"
/>
<result
column=
"soft_version"
jdbcType=
"VARCHAR"
property=
"softVersion"
/>
<result
column=
"source"
jdbcType=
"TINYINT"
property=
"source"
/>
<result
column=
"activate_status"
jdbcType=
"TINYINT"
property=
"activateStatus"
/>
<result
column=
"activate_time"
jdbcType=
"TIMESTAMP"
property=
"activateTime"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, `name`, sn, imsi, iccid, imei, sim, check_code, device_type, manufacturer, model_id,
model_name, soft_version, `source`, activate_status, activate_time, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
<select
id=
"selectBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device
where del_flag = 0
and sn = #{sn}
</select>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/test/java/cn/com/glsx/test/gpsbs/TestDeviceController.java
0 → 100644
View file @
56a1fd5
package
cn
.
com
.
glsx
.
test
.
gpsbs
;
import
cn.hutool.http.HttpUtil
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
TestDeviceController
{
private
static
String
localUrl
=
"http://localhost:8080/ne-shield-devicemonitor"
;
private
static
String
serverUrl
=
localUrl
;
public
static
void
main
(
String
[]
args
)
{
testGetDeviceBySn
();
}
public
static
void
testGetDeviceBySn
()
{
String
url
=
serverUrl
+
"/device/getDeviceBySn"
;
String
sn
=
"8130912152"
;
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"sn"
,
sn
);
String
res
=
HttpUtil
.
get
(
url
,
paramMap
,
20000
);
System
.
out
.
println
(
res
);
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment