Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-admin
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 41af67b4
authored
May 17, 2021
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新e盾业务管理系统后台-围栏
1 parent
77c25bd2
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
151 additions
and
24 deletions
pom.xml
src/main/java/cn/com/glsx/admin/common/constants/ConstantsElectricFence.java
src/main/java/cn/com/glsx/admin/config/WebConfig.java
src/main/java/cn/com/glsx/admin/modules/component/EFenceComponent.java
src/main/java/cn/com/glsx/admin/modules/controller/ElectricFenceController.java
src/main/java/cn/com/glsx/admin/modules/service/ElectricFenceService.java
src/test/java/cn/com/glsx/test/AdminApplicationTests.java
pom.xml
View file @
41af67b
...
@@ -10,11 +10,18 @@
...
@@ -10,11 +10,18 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
war
</packaging>
<packaging>
war
</packaging>
<artifactId>
glsx-
ne-shield-admin
</artifactId>
<artifactId>
ne-shield-admin
</artifactId>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
<artifactId>
glsx-ne-shield-auth-client
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-alliance
</artifactId>
<artifactId>
rest-admin-alliance
</artifactId>
</dependency>
</dependency>
<!-- <dependency>-->
<!-- <dependency>-->
...
...
src/main/java/cn/com/glsx/admin/common/constants/ConstantsElectricFence.java
View file @
41af67b
...
@@ -2,33 +2,22 @@ package cn.com.glsx.admin.common.constants;
...
@@ -2,33 +2,22 @@ package cn.com.glsx.admin.common.constants;
public
class
ConstantsElectricFence
{
public
class
ConstantsElectricFence
{
//围栏形状类型 1.圆形(默认) 2.矩形 3.多边形 4.行政区域
/**
/**
* 围栏形状 圆形
* 围栏形状 圆形
*/
*/
public
static
final
int
FENC
E_TYPE_CIRCLE
=
1
;
public
static
final
int
SHAP
E_TYPE_CIRCLE
=
1
;
/**
/**
* 围栏形状 多边形
* 围栏形状 多边形
*/
*/
public
static
final
int
FENC
E_TYPE_POLYGON
=
3
;
public
static
final
int
SHAP
E_TYPE_POLYGON
=
3
;
/**
/**
* 围栏形状 行政区域
* 围栏形状 行政区域
*/
*/
public
static
final
int
FENC
E_TYPE_ADMINISTRATIVE
=
4
;
public
static
final
int
SHAP
E_TYPE_ADMINISTRATIVE
=
4
;
/**
* 围栏类型 自定义
*/
public
static
final
int
ELEFENCE_SHAPE_TYPE_ONESELF
=
2
;
/**
* 围栏类型 行政区域
*/
public
static
final
int
ELEFENCE_SHAPE_TYPE_ADMINISTRATIVE
=
3
;
/**
* 围栏形状 多边形
*/
public
static
final
int
FENCE_SHAPE_TYPE_POLYGON
=
5
;
/**
/**
* 电子围栏 删除状态
* 电子围栏 删除状态
...
...
src/main/java/cn/com/glsx/admin/config/WebConfig.java
0 → 100644
View file @
41af67b
package
cn
.
com
.
glsx
.
admin
.
config
;
import
cn.com.glsx.auth.interceptor.WebRequestAuthorizeInterceptor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
* @author payu
*/
@Configuration
public
class
WebConfig
implements
WebMvcConfigurer
{
@Autowired
private
WebRequestAuthorizeInterceptor
authInterceptor
;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
//1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry
.
addInterceptor
(
authInterceptor
).
addPathPatterns
(
"/**"
)
.
excludePathPatterns
(
"/"
)
.
excludePathPatterns
(
"/actuator/**"
)
.
excludePathPatterns
(
"/api/**"
);
}
}
src/main/java/cn/com/glsx/admin/modules/component/EFenceComponent.java
View file @
41af67b
...
@@ -169,6 +169,7 @@ public class EFenceComponent {
...
@@ -169,6 +169,7 @@ public class EFenceComponent {
fenceInfoBuilder
.
setFenceId
(
Math
.
toIntExact
(
electricFence
.
getId
()));
fenceInfoBuilder
.
setFenceId
(
Math
.
toIntExact
(
electricFence
.
getId
()));
fenceInfoBuilder
.
setSvcSystemId
(
5
);
fenceInfoBuilder
.
setSvcSystemId
(
5
);
//围栏业务类型:0警情围栏,1试驾围栏 add by liuyf on 20210419
//围栏业务类型:0警情围栏,1试驾围栏 add by liuyf on 20210419
//旧e盾子系统id为11,新e盾子系统id为12
if
(
electricFence
.
getBizFenceType
()
==
1
)
{
if
(
electricFence
.
getBizFenceType
()
==
1
)
{
fenceInfoBuilder
.
setSvcSystemId
(
12
);
fenceInfoBuilder
.
setSvcSystemId
(
12
);
}
}
...
...
src/main/java/cn/com/glsx/admin/modules/controller/ElectricFenceController.java
0 → 100644
View file @
41af67b
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@RestController
@RequestMapping
(
value
=
"/fence"
)
public
class
ElectricFenceController
{
}
src/main/java/cn/com/glsx/admin/modules/service/ElectricFenceService.java
View file @
41af67b
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
import
cn.com.glsx.admin.common.constants.ConstantsElectricFence
;
import
cn.com.glsx.admin.modules.entity.ElectricFence
;
import
cn.com.glsx.admin.modules.entity.ElectricFence
;
import
cn.com.glsx.admin.modules.mapper.ElectricFenceMapper
;
import
cn.com.glsx.admin.modules.mapper.ElectricFenceMapper
;
import
cn.com.glsx.admin.modules.mapper.ElectricFenceSnsMapper
;
import
cn.com.glsx.admin.modules.mapper.ElectricFenceSnsMapper
;
import
cn.com.glsx.admin.modules.model.ElectricFenceBO
;
import
cn.com.glsx.admin.modules.model.ElectricFenceBO
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
com.glsx.plat.common.utils.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.
apache.commons.beanutils.Property
Utils
;
import
org.
springframework.beans.Bean
Utils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -27,25 +30,67 @@ public class ElectricFenceService {
...
@@ -27,25 +30,67 @@ public class ElectricFenceService {
*
*
* @param fenceBO
* @param fenceBO
*/
*/
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addFence
(
ElectricFenceBO
fenceBO
)
throws
Exception
{
public
void
addFence
(
ElectricFenceBO
fenceBO
)
throws
Exception
{
//1.新增围栏信息
//1.新增围栏信息
ElectricFence
fence
=
new
ElectricFence
();
ElectricFence
fence
=
new
ElectricFence
();
PropertyUtils
.
copyProperties
(
fence
,
fenceBO
);
BeanUtils
.
copyProperties
(
fenceBO
,
fence
);
fence
.
setLocationType
(
fenceBO
.
getLocationType
()
==
null
?
1
:
fenceBO
.
getLocationType
());
//设置定位信息类型为gps类型 默认都是创建gps类型围栏
//设置定位信息类型为gps类型 默认都是创建gps类型围栏
fence
.
setLocationType
(
1
);
fence
.
setLocationType
(
fenceBO
.
getLocationType
()
==
null
?
1
:
fenceBO
.
getLocationType
());
//fence.setRecord("操作时间:" + DateUtils.formatDate(new Date()) + " 操作人:" + loginUserId + "<br/>");
fence
.
setRecord
(
"操作时间:"
+
DateUtils
.
formatNormal
(
new
Date
())
+
" 操作人:"
+
ShieldContextHolder
.
getAccount
()
+
"("
+
ShieldContextHolder
.
getUserId
()
+
")"
+
"<br/>"
);
fence
.
setCreatedBy
(
ShieldContextHolder
.
getUserId
());
fence
.
setCreatedDate
(
new
Date
());
fence
.
setCreatedDate
(
new
Date
());
int
insertCnt
=
electricFenceMapper
.
insert
(
fence
);
int
insertCnt
=
electricFenceMapper
.
insert
(
fence
);
//2.向大数据推送新增围栏信息(kafka)
//2.向大数据推送新增围栏信息(kafka)
if
(
insertCnt
>
0
)
{
// eFenceComponent.addElectricFence(fence);
// eFenceComponent.addElectricFence(fence);
}
}
}
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateFence
(
ElectricFenceBO
fenceBO
)
throws
Exception
{
public
void
updateFence
(
ElectricFenceBO
fenceBO
)
throws
Exception
{
//1.更新围栏信息
ElectricFence
localFence
=
electricFenceMapper
.
selectByPrimaryKey
(
fenceBO
.
getId
());
ElectricFence
fence
=
new
ElectricFence
();
BeanUtils
.
copyProperties
(
fenceBO
,
fence
);
if
(
fenceBO
.
getShapeType
()
!=
null
)
{
//围栏形状类型 1.圆形(默认) 2.矩形 3.多边形 4.行政区域
fence
.
setShapeType
(
fenceBO
.
getShapeType
());
fence
.
setRadius
(
null
);
fence
.
setAreaCode
(
null
);
fence
.
setAreaText
(
null
);
if
(
fenceBO
.
getShapeType
()
==
ConstantsElectricFence
.
SHAPE_TYPE_CIRCLE
)
{
fence
.
setRadius
(
fenceBO
.
getRadius
());
}
else
if
(
fenceBO
.
getShapeType
()
==
ConstantsElectricFence
.
SHAPE_TYPE_POLYGON
)
{
//do nothing
}
else
if
(
fenceBO
.
getShapeType
()
==
ConstantsElectricFence
.
SHAPE_TYPE_ADMINISTRATIVE
)
{
fence
.
setAreaCode
(
fenceBO
.
getAreaCode
());
fence
.
setAreaText
(
fence
.
getAreaText
());
}
}
fence
.
setFenceNo
(
localFence
.
getFenceNo
());
//业务围栏类型:0警情围栏,1试驾围栏 add by liuyf on 20210426
fence
.
setBizFenceType
(
fenceBO
.
getBizFenceType
()
==
null
?
localFence
.
getBizFenceType
()
:
fenceBO
.
getBizFenceType
());
fence
.
setLocationType
(
fenceBO
.
getLocationType
()
==
null
?
localFence
.
getLocationType
()
:
fenceBO
.
getLocationType
());
fence
.
setRecord
(
localFence
.
getRecord
()
+
"操作时间:"
+
DateUtils
.
formatNormal
(
new
Date
())
+
ShieldContextHolder
.
getAccount
()
+
"("
+
ShieldContextHolder
.
getUserId
()
+
")"
+
"<br/>"
);
fence
.
setStartTime
(
fenceBO
.
getStartTime
());
fence
.
setEndTime
(
fenceBO
.
getEndTime
());
fence
.
setUpdatedDate
(
new
Date
());
fence
.
setUpdatedBy
(
ShieldContextHolder
.
getUserId
());
int
updateCnt
=
electricFenceMapper
.
updateByPrimaryKey
(
fence
);
if
(
updateCnt
>
1
)
{
// 更新围栏 向大数据推送围栏更新(kafka)
// eFenceComponent.updateElectricFence(fence);
}
}
}
@Transactional
@Transactional
...
...
src/test/java/cn/com/glsx/test/AdminApplicationTests.java
View file @
41af67b
...
@@ -3,8 +3,12 @@ package cn.com.glsx.test;
...
@@ -3,8 +3,12 @@ package cn.com.glsx.test;
import
cn.com.glsx.Application
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.admin.modules.model.ElectricFenceBO
;
import
cn.com.glsx.admin.modules.model.ElectricFenceBO
;
import
cn.com.glsx.admin.modules.service.ElectricFenceService
;
import
cn.com.glsx.admin.modules.service.ElectricFenceService
;
import
cn.com.glsx.auth.model.SyntheticUser
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.lang.UUID
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,6 +25,25 @@ public class AdminApplicationTests {
...
@@ -21,6 +25,25 @@ public class AdminApplicationTests {
@Autowired
@Autowired
private
ElectricFenceService
electricFenceService
;
private
ElectricFenceService
electricFenceService
;
// Should rename to @BeforeTestMethod
// e.g. Creating an similar object and share for all @Test
@Before
public
void
runBeforeTestMethod
()
{
System
.
out
.
println
(
"@Before - runBeforeTestMethod"
);
SyntheticUser
user
=
new
SyntheticUser
();
user
.
setUserId
(
2L
);
user
.
setAdmin
(
false
);
user
.
setAccount
(
"payxz"
);
ShieldContextHolder
.
setUser
(
user
);
}
// Should rename to @AfterTestMethod
@After
public
void
runAfterTestMethod
()
{
System
.
out
.
println
(
"@After - runAfterTestMethod"
);
}
@Test
@Test
public
void
testAddFence
()
throws
Exception
{
public
void
testAddFence
()
throws
Exception
{
ElectricFenceBO
fenceBO
=
new
ElectricFenceBO
();
ElectricFenceBO
fenceBO
=
new
ElectricFenceBO
();
...
@@ -46,7 +69,26 @@ public class AdminApplicationTests {
...
@@ -46,7 +69,26 @@ public class AdminApplicationTests {
@Test
@Test
public
void
testUpdateFence
()
throws
Exception
{
public
void
testUpdateFence
()
throws
Exception
{
ElectricFenceBO
fenceBO
=
new
ElectricFenceBO
();
fenceBO
.
setId
(
1L
);
fenceBO
.
setFenceName
(
"测试围栏-1"
);
fenceBO
.
setFenceNo
(
UUID
.
randomUUID
().
toString
());
fenceBO
.
setBizFenceType
(
1
);
fenceBO
.
setLocationType
(
0
);
fenceBO
.
setShapeType
(
1
);
fenceBO
.
setRadius
(
1000
);
fenceBO
.
setLnglat
(
"113.528632,22.443676"
);
fenceBO
.
setTriggerType
(
1
);
fenceBO
.
setTimeType
(
0
);
fenceBO
.
setStartTime
(
new
Date
());
fenceBO
.
setEndTime
(
new
Date
());
fenceBO
.
setEnableStatus
(
1
);
fenceBO
.
setRemark
(
"这是一个测试围栏"
);
fenceBO
.
setAreaCode
(
"12213"
);
fenceBO
.
setAreaText
(
"深圳"
);
fenceBO
.
setAnalysisAddress
(
"深圳深南大道333"
);
fenceBO
.
setTelNumbers
(
"13800138000"
);
electricFenceService
.
updateFence
(
fenceBO
);
}
}
}
}
\ No newline at end of file
\ No newline at end of file
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