Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
base-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
base-platform
Commits
e944a784
Commit
e944a784
authored
Apr 07, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加事项同步数据
parent
cf1dd547
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
174 additions
and
33 deletions
+174
-33
base-manager/src/main/java/com/mortals/xhx/module/area/service/impl/AreaServiceImpl.java
...mortals/xhx/module/area/service/impl/AreaServiceImpl.java
+11
-11
base-manager/src/main/java/com/mortals/xhx/module/site/service/SiteService.java
...java/com/mortals/xhx/module/site/service/SiteService.java
+25
-8
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
...mortals/xhx/module/site/service/impl/SiteServiceImpl.java
+99
-9
base-manager/src/main/java/com/mortals/xhx/module/site/web/SiteController.java
.../java/com/mortals/xhx/module/site/web/SiteController.java
+31
-2
base-manager/src/test/java/com/mortals/httpclient/http-client.env.json
...src/test/java/com/mortals/httpclient/http-client.env.json
+3
-3
base-manager/src/test/java/com/mortals/httpclient/site/SiteController.http
...test/java/com/mortals/httpclient/site/SiteController.http
+5
-0
No files found.
base-manager/src/main/java/com/mortals/xhx/module/area/service/impl/AreaServiceImpl.java
View file @
e944a784
...
@@ -133,9 +133,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
...
@@ -133,9 +133,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
public
List
<
AreaTreeSelect
>
buildAreaTreeSelect
(
List
<
AreaEntity
>
list
)
{
public
List
<
AreaTreeSelect
>
buildAreaTreeSelect
(
List
<
AreaEntity
>
list
)
{
List
<
AreaEntity
>
returnList
=
new
ArrayList
<>();
List
<
AreaEntity
>
returnList
=
new
ArrayList
<>();
List
<
Long
>
tempList
=
list
.
stream
().
map
(
AreaEntity:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
tempList
=
list
.
stream
().
map
(
AreaEntity:
:
getId
).
collect
(
Collectors
.
toList
());
for
(
AreaEntity
areaEntity
:
list
)
{
for
(
Iterator
<
AreaEntity
>
iterator
=
list
.
iterator
();
iterator
.
hasNext
();
)
{
AreaEntity
areaEntity
=
iterator
.
next
();
// 如果是顶级节点, 遍历该父节点的所有子节点
// 如果是顶级节点, 遍历该父节点的所有子节点
if
(!
tempList
.
contains
(
areaEntity
.
getPid
()))
{
if
(!
tempList
.
contains
(
areaEntity
.
getPid
()))
{
recursionFn
(
list
,
areaEntity
);
recursionFn
(
list
,
areaEntity
);
...
@@ -164,7 +162,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
...
@@ -164,7 +162,7 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
if
(!
ObjectUtils
.
isEmpty
(
areaEntity
))
{
if
(!
ObjectUtils
.
isEmpty
(
areaEntity
))
{
//查询当前区域是否有站点。
//查询当前区域是否有站点。
List
<
AreaTreeSelect
>
collect1
=
siteService
.
find
(
new
SiteQuery
().
areaCode
(
areaEntity
.
getAreaCode
()))
List
<
AreaTreeSelect
>
collect1
=
siteService
.
find
(
new
SiteQuery
().
areaCode
(
areaEntity
.
getAreaCode
()))
.
stream
().
map
(
site
->
new
AreaTreeSelect
(
site
)).
collect
(
Collectors
.
toList
());
.
stream
().
map
(
site
->
new
AreaTreeSelect
(
site
)).
collect
(
Collectors
.
toList
());
collect
.
addAll
(
collect1
);
collect
.
addAll
(
collect1
);
}
}
...
@@ -186,13 +184,6 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
...
@@ -186,13 +184,6 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
}
}
}
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
AreaEntity
>
list
,
AreaEntity
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
}
/**
/**
* 得到子节点列表
* 得到子节点列表
*/
*/
...
@@ -205,4 +196,13 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
...
@@ -205,4 +196,13 @@ public class AreaServiceImpl extends AbstractCRUDCacheServiceImpl<AreaDao, AreaE
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
}
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
AreaEntity
>
list
,
AreaEntity
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
}
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/site/service/SiteService.java
View file @
e944a784
package
com.mortals.xhx.module.site.service
;
package
com.mortals.xhx.module.site.service
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaTreeSelect
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* SiteService
* SiteService
*
* <p>
* 站点 service接口
* 站点 service接口
*
*
* @author zxfei
* @author zxfei
* @date 2022-01-12
* @date 2022-01-12
*/
*/
public
interface
SiteService
extends
ICRUDService
<
SiteEntity
,
Long
>{
public
interface
SiteService
extends
ICRUDService
<
SiteEntity
,
Long
>
{
/**
* 区域站点树
*
* @param context
* @return
*/
List
<
SiteTreeSelect
>
siteTree
(
Context
context
);
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
View file @
e944a784
package
com.mortals.xhx.module.site.service.impl
;
package
com.mortals.xhx.module.site.service.impl
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.model.AreaQuery
;
import
com.mortals.xhx.module.area.model.AreaTreeSelect
;
import
com.mortals.xhx.module.area.service.AreaService
;
import
com.mortals.xhx.module.area.service.AreaService
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
...
@@ -12,15 +16,19 @@ import com.mortals.xhx.module.site.model.SiteEntity;
...
@@ -12,15 +16,19 @@ import com.mortals.xhx.module.site.model.SiteEntity;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* SiteService
* SiteService
* 站点 service实现
* 站点 service实现
*
*
* @author zxfei
* @author zxfei
* @date 2022-01-12
* @date 2022-01-12
*/
*/
@Service
(
"siteService"
)
@Service
(
"siteService"
)
public
class
SiteServiceImpl
extends
AbstractCRUDServiceImpl
<
SiteDao
,
SiteEntity
,
Long
>
implements
SiteService
{
public
class
SiteServiceImpl
extends
AbstractCRUDServiceImpl
<
SiteDao
,
SiteEntity
,
Long
>
implements
SiteService
{
@Autowired
@Autowired
...
@@ -28,11 +36,11 @@ public class SiteServiceImpl extends AbstractCRUDServiceImpl<SiteDao, SiteEntity
...
@@ -28,11 +36,11 @@ public class SiteServiceImpl extends AbstractCRUDServiceImpl<SiteDao, SiteEntity
@Override
@Override
protected
void
validData
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
validData
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
if
(
ObjectUtils
.
isEmpty
(
entity
.
getAreaCode
()))
{
if
(
ObjectUtils
.
isEmpty
(
entity
.
getAreaCode
()))
{
throw
new
AppException
(
"区域编码不能为空!"
);
throw
new
AppException
(
"区域编码不能为空!"
);
}
}
AreaEntity
areaEntity
=
areaService
.
getCache
(
entity
.
getAreaCode
());
AreaEntity
areaEntity
=
areaService
.
getCache
(
entity
.
getAreaCode
());
if
(
ObjectUtils
.
isEmpty
(
areaEntity
))
{
if
(
ObjectUtils
.
isEmpty
(
areaEntity
))
{
throw
new
AppException
(
String
.
format
(
"区域不存在!区域编码:%s"
,
entity
.
getAreaCode
()));
throw
new
AppException
(
String
.
format
(
"区域不存在!区域编码:%s"
,
entity
.
getAreaCode
()));
}
}
super
.
validData
(
entity
,
context
);
super
.
validData
(
entity
,
context
);
...
@@ -41,7 +49,89 @@ public class SiteServiceImpl extends AbstractCRUDServiceImpl<SiteDao, SiteEntity
...
@@ -41,7 +49,89 @@ public class SiteServiceImpl extends AbstractCRUDServiceImpl<SiteDao, SiteEntity
@Override
@Override
protected
void
saveBefore
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
saveBefore
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
List
<
SiteEntity
>
siteEntities
=
this
.
find
(
new
SiteQuery
().
areaCode
(
entity
.
getAreaCode
()));
List
<
SiteEntity
>
siteEntities
=
this
.
find
(
new
SiteQuery
().
areaCode
(
entity
.
getAreaCode
()));
entity
.
setSiteCode
(
entity
.
getAreaCode
()
+
"#"
+(
siteEntities
.
size
()+
1
));
entity
.
setSiteCode
(
entity
.
getAreaCode
()
+
"#"
+
(
siteEntities
.
size
()
+
1
));
super
.
saveBefore
(
entity
,
context
);
super
.
saveBefore
(
entity
,
context
);
}
}
@Override
public
List
<
SiteTreeSelect
>
siteTree
(
Context
context
)
{
Map
<
String
,
AreaEntity
>
areaMap
=
new
HashMap
<>();
//查询所有已配置的站点
List
<
SiteEntity
>
siteList
=
this
.
find
(
new
SiteQuery
());
Map
<
String
,
SiteEntity
>
siteMap
=
this
.
find
(
new
SiteQuery
()).
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getSiteCode
(),
y
->
y
,
(
o
,
n
)
->
n
));
//遍历过滤站点树
for
(
SiteEntity
siteEntity
:
siteList
)
{
String
areaCode
=
siteEntity
.
getAreaCode
();
AreaEntity
areaEntity
=
areaService
.
getExtCache
(
areaCode
);
//根据区域添加父节点
if
(!
ObjectUtils
.
isEmpty
(
areaEntity
)
&&
!
ObjectUtils
.
isEmpty
(
areaEntity
.
getPid
()))
{
//递归查找父节点并添加
areaMap
.
put
(
areaEntity
.
getAreaCode
(),
areaEntity
);
recursionFn
(
areaMap
,
areaEntity
);
}
}
return
buildSiteTreeSelect
(
areaMap
,
siteMap
);
}
public
List
<
SiteTreeSelect
>
buildSiteTreeSelect
(
Map
<
String
,
AreaEntity
>
areaMap
,
Map
<
String
,
SiteEntity
>
siteMap
)
{
List
<
AreaEntity
>
list
=
areaMap
.
values
().
stream
().
collect
(
Collectors
.
toList
());
List
<
AreaEntity
>
returnList
=
new
ArrayList
<>();
List
<
String
>
tempList
=
list
.
stream
().
map
(
AreaEntity:
:
getIid
).
collect
(
Collectors
.
toList
());
for
(
AreaEntity
areaEntity
:
list
)
{
//查询当前区域列表中最顶级的节点 并构建树
if
(!
tempList
.
contains
(
areaEntity
.
getPid
()))
{
recursion
(
list
,
areaEntity
);
returnList
.
add
(
areaEntity
);
}
}
if
(
returnList
.
isEmpty
())
{
returnList
=
list
;
}
return
returnList
.
stream
().
map
(
item
->
new
SiteTreeSelect
(
item
,
siteMap
)
).
collect
(
Collectors
.
toList
());
}
private
void
recursion
(
List
<
AreaEntity
>
list
,
AreaEntity
t
)
{
// 得到子节点列表
List
<
AreaEntity
>
childList
=
getChildList
(
list
,
t
);
t
.
setChildren
(
childList
);
for
(
AreaEntity
tChild
:
childList
)
{
if
(
hasChild
(
list
,
tChild
))
{
recursion
(
list
,
tChild
);
}
}
}
/**
* 得到子节点列表
*/
private
List
<
AreaEntity
>
getChildList
(
List
<
AreaEntity
>
list
,
AreaEntity
t
)
{
return
list
.
stream
().
filter
(
item
->
item
.
getPid
().
equals
(
t
.
getIid
())).
collect
(
Collectors
.
toList
());
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
AreaEntity
>
list
,
AreaEntity
t
)
{
return
getChildList
(
list
,
t
).
size
()
>
0
?
true
:
false
;
}
/**
* 递归列表
*/
private
void
recursionFn
(
Map
<
String
,
AreaEntity
>
areaMap
,
AreaEntity
t
)
{
// 得到父节点并加入
AreaEntity
areaEntity
=
areaService
.
selectOne
(
new
AreaQuery
().
iid
(
t
.
getPid
()));
if
(!
ObjectUtils
.
isEmpty
(
areaEntity
))
{
areaMap
.
put
(
areaEntity
.
getAreaCode
(),
areaEntity
);
recursionFn
(
areaMap
,
areaEntity
);
}
}
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/site/web/SiteController.java
View file @
e944a784
package
com.mortals.xhx.module.site.web
;
package
com.mortals.xhx.module.site.web
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.web.BasePhpCRUDJsonMappingController
;
import
com.mortals.framework.web.BasePhpCRUDJsonMappingController
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.base.system.param.service.ParamService
;
import
com.mortals.xhx.module.model.model.ModelQuery
;
import
com.mortals.xhx.module.model.model.ModelQuery
;
import
com.mortals.xhx.module.model.service.ModelService
;
import
com.mortals.xhx.module.model.service.ModelService
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.
web.bind.annotation.RequestMapping
;
import
org.springframework.
util.ObjectUtils
;
import
org.springframework.web.bind.annotation.
RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -53,4 +58,28 @@ public class SiteController extends BasePhpCRUDJsonMappingController<SiteService
...
@@ -53,4 +58,28 @@ public class SiteController extends BasePhpCRUDJsonMappingController<SiteService
}
}
/**
* 构建站点树
*/
@GetMapping
(
value
=
"siteTree"
)
public
String
siteTree
()
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
this
.
getModuleDesc
()
+
"构建站点树"
;
try
{
List
<
SiteTreeSelect
>
siteTree
=
this
.
service
.
siteTree
(
getContext
());
model
.
put
(
"siteTree"
,
siteTree
);
this
.
init
(
model
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"构建站点树异常"
,
e
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
jsonObject
.
toJSONString
();
}
}
}
\ No newline at end of file
base-manager/src/test/java/com/mortals/httpclient/http-client.env.json
View file @
e944a784
{
{
"local"
:
{
"local"
:
{
"baseUrl"
:
"http://127.0.0.1:17311"
"baseUrl"
:
"http://127.0.0.1:17311
/zwfw
"
},
},
"dev"
:
{
"dev"
:
{
"baseUrl"
:
"http://192.168.0.217:17311"
"baseUrl"
:
"http://192.168.0.217:17311
/zwfw
"
},
},
"test"
:
{
"test"
:
{
"baseUrl"
:
"http://192.168.0.98:11023"
"baseUrl"
:
"http://192.168.0.98:11023
/zwfw
"
}
}
}
}
\ No newline at end of file
base-manager/src/test/java/com/mortals/httpclient/site/SiteController.http
View file @
e944a784
...
@@ -64,5 +64,10 @@ GET {{baseUrl}}/site/delete?id={{Site_id}}
...
@@ -64,5 +64,10 @@ GET {{baseUrl}}/site/delete?id={{Site_id}}
Accept: application/json
Accept: application/json
###构建站点树
GET {{baseUrl}}/site/siteTree
Accept: application/json
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