Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_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
赵啸非
smart_gov_platform
Commits
25a92094
Commit
25a92094
authored
Mar 06, 2024
by
“yiyousong”
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.scsmile.cn/zxf/smart_gov_platform
parents
5e59d933
0ee29257
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
531 additions
and
35 deletions
+531
-35
base-manager/src/main/java/com/mortals/xhx/busiz/web/DemoWebApiController.java
.../java/com/mortals/xhx/busiz/web/DemoWebApiController.java
+63
-8
base-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
.../java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
+20
-2
base-manager/src/main/java/com/mortals/xhx/module/matter/dao/MatterDao.java
...ain/java/com/mortals/xhx/module/matter/dao/MatterDao.java
+13
-0
base-manager/src/main/java/com/mortals/xhx/module/matter/dao/ibatis/MatterDaoImpl.java
...m/mortals/xhx/module/matter/dao/ibatis/MatterDaoImpl.java
+33
-0
base-manager/src/main/java/com/mortals/xhx/module/matter/service/MatterExtService.java
...m/mortals/xhx/module/matter/service/MatterExtService.java
+12
-1
base-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterExtServiceImpl.java
.../xhx/module/matter/service/impl/MatterExtServiceImpl.java
+259
-7
base-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterServiceImpl.java
...als/xhx/module/matter/service/impl/MatterServiceImpl.java
+33
-13
base-manager/src/main/java/com/mortals/xhx/module/site/service/SiteMatterService.java
...om/mortals/xhx/module/site/service/SiteMatterService.java
+5
-0
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteMatterServiceImpl.java
...s/xhx/module/site/service/impl/SiteMatterServiceImpl.java
+59
-3
base-manager/src/main/resources/sqlmap/module/matter/MatterMapperExt.xml
...c/main/resources/sqlmap/module/matter/MatterMapperExt.xml
+34
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/busiz/web/DemoWebApiController.java
View file @
25a92094
...
...
@@ -7,9 +7,11 @@ import com.mortals.framework.annotation.UnAuth;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.ParamDto
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.web.BaseJsonBodyController
;
import
com.mortals.xhx.common.code.DxTypeEnum
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.keys.RedisCacheKeys
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
...
...
@@ -40,15 +42,13 @@ import org.apache.http.impl.client.HttpClientBuilder;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
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.RestController
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
framework
.
ap
.
SysConstains
.
MESSAGE_INFO
;
...
...
@@ -205,13 +205,68 @@ public class DemoWebApiController {
return
Rest
.
ok
();
}
@PostMapping
(
value
=
"testAllMatter"
)
@UnAuth
public
Rest
<
String
>
testAllMatter
(
@RequestBody
SiteEntity
siteEntity
)
{
StopWatch
stopWatch
=
new
StopWatch
(
"stopwatch syncmatter"
);
log
.
info
(
"开始查询事项=="
);
stopWatch
.
start
(
"开始同步事项方法"
);
MatterQuery
matterQuery
=
new
MatterQuery
();
matterQuery
.
setAreaCode
(
siteEntity
.
getAreaCode
());
matterQuery
.
setSource
(
SourceEnum
.
政务网
.
getValue
());
List
<
MatterEntity
>
matterList
=
matterService
.
getDao
().
getMatterListByAreaCode
(
matterQuery
);
stopWatch
.
stop
();
log
.
info
(
"本地事项总数:{},{}s"
,
matterList
.
size
(),
stopWatch
.
getLastTaskTimeMillis
()
/
1000
);
return
Rest
.
ok
();
}
@PostMapping
(
value
=
"testAllMatterPage"
)
@UnAuth
public
Rest
<
String
>
testAllMatterPage
(
@RequestBody
SiteEntity
siteEntity
)
{
StopWatch
stopWatch
=
new
StopWatch
(
"stopwatch syncmatter"
);
log
.
info
(
"开始查询事项=="
);
stopWatch
.
start
(
"开始同步事项方法"
);
MatterQuery
matterQuery
=
new
MatterQuery
();
matterQuery
.
setAreaCode
(
siteEntity
.
getAreaCode
());
matterQuery
.
setSource
(
SourceEnum
.
政务网
.
getValue
());
ParamDto
param
=
new
ParamDto
();
param
.
getCondition
().
put
(
"areaCode"
,
matterQuery
.
getAreaCode
());
if
(!
ObjectUtils
.
isEmpty
(
matterQuery
.
getSource
()))
{
param
.
getCondition
().
put
(
"source"
,
matterQuery
.
getSource
());
}
int
count
=
matterService
.
getDao
().
getMatterListByAreaCodeCount
(
param
);
ArrayList
<
MatterEntity
>
allList
=
new
ArrayList
<>();
if
(
count
>
0
)
{
//分页获取
int
pages
=
count
/
500
+
1
;
for
(
int
i
=
1
;
i
<=
pages
;
i
++)
{
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setCurrPage
(
i
);
pageInfo
.
setPrePageResult
(
500
);
Result
<
MatterEntity
>
rest
=
matterService
.
getDao
().
getMatterListByAreaCodePage
(
matterQuery
,
pageInfo
);
allList
.
addAll
(
rest
.
getList
());
}
stopWatch
.
stop
();
log
.
info
(
"本地事项总数:{},{}s"
,
allList
.
size
(),
stopWatch
.
getLastTaskTimeMillis
()
/
1000
);
}
return
Rest
.
ok
();
}
public
static
void
main
(
String
[]
args
)
{
HttpClient
http
=
null
;
System
.
out
.
println
(
1001
/
500
);
/* HttpClient http = null;
CookieStore httpCookieStore = new BasicCookieStore();
http = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build();
/* do stuff */
*//* do stuff *//*
HttpGet httpRequest = new HttpGet("http://zxbl.sczwfw.gov.cn/app/account/imageCode");
HttpResponse httpResponse = null;
try {
...
...
@@ -228,9 +283,9 @@ public class DemoWebApiController {
} catch (Exception e) {
log.error("异常", e);
}
/* check cookies */
*//* check cookies *//*
String cookieStr = Arrays.asList(httpCookieStore.getCookies()).stream().map(item -> JSON.toJSONString(item)).collect(Collectors.joining("|"));
// log.info("cookies:{}", cookieStr);
// log.info("cookies:{}", cookieStr);
*/
}
...
...
base-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
View file @
25a92094
...
...
@@ -17,6 +17,7 @@ import com.mortals.xhx.module.area.service.AreaService;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
com.mortals.xhx.module.matter.model.MatterQuery
;
import
com.mortals.xhx.module.matter.service.MatterExtService
;
import
com.mortals.xhx.module.matter.service.MatterService
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
...
...
@@ -30,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StopWatch
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -64,13 +66,28 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
MatterExtService
matterExtService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
log
.
info
(
"开始同步事项!"
);
List
<
SiteEntity
>
siteEntities
=
siteService
.
find
(
new
SiteEntity
());
for
(
SiteEntity
siteEntity
:
siteEntities
)
{
syncMatter
(
siteEntity
);
StopWatch
stopWatch
=
new
StopWatch
(
"stopwatch syncmatter"
);
log
.
info
(
"开始同步事项==》{}"
,
siteEntity
.
getSiteName
());
stopWatch
.
start
(
"开始同步事项方法"
);
matterExtService
.
doMatterBySiteId
(
siteEntity
,
null
);
stopWatch
.
stop
();
log
.
info
(
"同步事项完成,耗时:{}s"
,
stopWatch
.
getLastTaskTimeMillis
()/
1000
);
log
.
info
(
"开始添加站点事项==》{}"
,
siteEntity
.
getSiteName
());
stopWatch
.
start
(
"开始添加站点事项"
);
siteMatterService
.
doSyncSiteMatter
(
siteEntity
,
null
);
stopWatch
.
stop
();
log
.
info
(
"开始添加站点事项,耗时:{} s"
,
stopWatch
.
getLastTaskTimeMillis
()/
1000
);
// syncMatter(siteEntity);
}
// syncDevice();
log
.
info
(
"结束同步事项!"
);
...
...
@@ -82,8 +99,9 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
Rest
<
String
>
deptRest
=
deptService
.
syncDeptBySiteId
(
siteEntity
,
null
);
log
.
info
(
"同步站点部门结果:"
+
JSON
.
toJSONString
(
deptRest
));
Rest
<
String
>
rest
=
siteService
.
syncMatterBySiteId
(
siteEntity
,
null
);
log
.
info
(
"同步事项列表:"
+
JSON
.
toJSONString
(
rest
));
//
log.info("同步事项列表:" + JSON.toJSONString(rest));
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
List
<
MatterEntity
>
matterEntityList
=
matterService
.
find
(
new
MatterQuery
().
areaCode
(
siteEntity
.
getAreaCode
()).
source
(
SourceEnum
.
政务网
.
getValue
()));
log
.
info
(
"查询本地事项列表,size:{}"
,
matterEntityList
.
size
());
List
<
MatterEntity
>
unSyncDetailMatterList
=
matterEntityList
.
stream
()
...
...
base-manager/src/main/java/com/mortals/xhx/module/matter/dao/MatterDao.java
View file @
25a92094
...
...
@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.dao;
import
com.mortals.framework.dao.ICRUDDao
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.ParamDto
;
import
com.mortals.framework.model.Result
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
org.apache.poi.ss.formula.functions.T
;
...
...
@@ -21,7 +22,19 @@ public interface MatterDao extends ICRUDDao<MatterEntity, Long> {
String
SQLID_SUB_COUNT
=
"getSubListCount"
;
String
SQLID_MATTERLIST_AREACODE
=
"getMatterListByAreaCode"
;
String
SQLID_MATTERLIST_AREACODE_COUNT
=
"getMatterListByAreaCodeCount"
;
Result
<
MatterEntity
>
getSubList
(
MatterEntity
matterQuery
,
PageInfo
pageInfo
);
List
<
MatterEntity
>
getMatterListByAreaCode
(
MatterEntity
matterQuery
);
Result
<
MatterEntity
>
getMatterListByAreaCodePage
(
MatterEntity
matterQuery
,
PageInfo
pageInfo
);
int
getMatterListByAreaCodeCount
(
ParamDto
paramDto
);
}
base-manager/src/main/java/com/mortals/xhx/module/matter/dao/ibatis/MatterDaoImpl.java
View file @
25a92094
...
...
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis
;
import
org.springframework.util.ObjectUtils
;
import
java.util.List
;
...
...
@@ -50,13 +51,45 @@ public class MatterDaoImpl extends BaseCRUDDaoMybatis<MatterEntity, Long> implem
public
int
getSubCount
(
ParamDto
paramDto
)
{
return
this
.
getSqlSession
().
selectOne
(
this
.
getSqlId
(
SQLID_SUB_COUNT
),
this
.
cpyQueryParamDto
(
paramDto
));
}
@Override
public
int
getMatterListByAreaCodeCount
(
ParamDto
paramDto
)
{
return
this
.
getSqlSession
().
selectOne
(
this
.
getSqlId
(
SQLID_MATTERLIST_AREACODE_COUNT
),
this
.
cpyQueryParamDto
(
paramDto
));
}
@Override
public
List
<
MatterEntity
>
getMatterListByAreaCode
(
MatterEntity
matterQuery
)
{
ParamDto
param
=
new
ParamDto
();
param
.
getCondition
().
put
(
"areaCode"
,
matterQuery
.
getAreaCode
());
if
(!
ObjectUtils
.
isEmpty
(
matterQuery
.
getSource
())){
param
.
getCondition
().
put
(
"source"
,
matterQuery
.
getSource
());
}
return
this
.
getSqlSession
().
selectList
(
this
.
getSqlId
(
"getMatterListByAreaCode"
),
param
);
}
/**
* @param matterQuery
* @param pageInfo
* @return
*/
@Override
public
Result
<
MatterEntity
>
getMatterListByAreaCodePage
(
MatterEntity
matterQuery
,
PageInfo
pageInfo
)
{
Result
<
MatterEntity
>
result
=
new
Result
();
ParamDto
paramDto
=
this
.
getQueryParam
(
matterQuery
);
int
count
=
this
.
getMatterListByAreaCodeCount
(
paramDto
);
List
list
=
null
;
if
(
count
==
0
)
{
list
=
new
ArrayList
();
}
else
if
(
pageInfo
.
getPrePageResult
()
==
-
1
)
{
list
=
this
.
getSqlSession
().
selectList
(
this
.
getSqlId
(
SQLID_MATTERLIST_AREACODE
),
paramDto
);
}
else
{
RowBounds
rowBounds
=
new
RowBounds
(
pageInfo
.
getBeginIndex
(),
pageInfo
.
getPrePageResult
());
list
=
this
.
getSqlSession
().
selectList
(
this
.
getSqlId
(
SQLID_MATTERLIST_AREACODE
),
this
.
cpyQueryParamDto
(
paramDto
),
rowBounds
);
}
pageInfo
.
setTotalResult
(
count
);
result
.
setPageInfo
(
pageInfo
);
result
.
setList
(
list
);
return
result
;
}
}
base-manager/src/main/java/com/mortals/xhx/module/matter/service/MatterExtService.java
View file @
25a92094
package
com.mortals.xhx.module.matter.service
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.matter.dao.MatterExtDao
;
import
com.mortals.xhx.module.matter.model.MatterExtEntity
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
/**
* MatterExtService
*
...
...
@@ -12,5 +16,12 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity;
*/
public
interface
MatterExtService
extends
ICRUDService
<
MatterExtEntity
,
Long
>{
MatterExtDao
getDao
();
Rest
<
String
>
doMatterBySiteId
(
SiteEntity
siteEntity
,
Context
context
);
Rest
<
String
>
doMatterThemeBySiteId
(
SiteEntity
siteEntity
,
Context
context
);
void
deleteByMatterId
(
Long
matterId
,
Context
context
);
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterExtServiceImpl.java
View file @
25a92094
package
com.mortals.xhx.module.matter.service.impl
;
import
cn.hutool.core.collection.ListUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.common.code.DxTypeEnum
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.utils.MatterHtmlParseUtil
;
import
com.mortals.xhx.module.area.model.AreaEntity
;
import
com.mortals.xhx.module.area.service.AreaService
;
import
com.mortals.xhx.module.dept.model.DeptEntity
;
import
com.mortals.xhx.module.dept.model.DeptQuery
;
import
com.mortals.xhx.module.dept.service.DeptService
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
com.mortals.xhx.module.matter.model.MatterQuery
;
import
com.mortals.xhx.module.matter.service.MatterService
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
import
com.mortals.xhx.module.site.model.SiteMatterQuery
;
import
com.mortals.xhx.module.site.model.SiteQuery
;
import
com.mortals.xhx.module.site.service.SiteMatterService
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.module.site.service.SiteThemeMatterService
;
import
com.mortals.xhx.module.site.service.SiteThemeService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.exception.AppException
;
...
...
@@ -6,14 +34,238 @@ import com.mortals.framework.model.Context;
import
com.mortals.xhx.module.matter.dao.MatterExtDao
;
import
com.mortals.xhx.module.matter.model.MatterExtEntity
;
import
com.mortals.xhx.module.matter.service.MatterExtService
;
import
org.springframework.util.ObjectUtils
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* MatterExtService
* 事项扩展 service实现
*
* @author zxfei
* @date 2022-11-23
*/
* MatterExtService
* 事项扩展 service实现
*
* @author zxfei
* @date 2022-11-23
*/
@Service
(
"matterExtService"
)
@Slf4j
public
class
MatterExtServiceImpl
extends
AbstractCRUDServiceImpl
<
MatterExtDao
,
MatterExtEntity
,
Long
>
implements
MatterExtService
{
@Autowired
private
AreaService
areaService
;
@Autowired
private
DeptService
deptService
;
@Autowired
private
MatterService
matterService
;
@Autowired
private
SiteService
siteService
;
@Autowired
private
SiteMatterService
siteMatterService
;
@Autowired
private
SiteThemeMatterService
siteThemeMatterService
;
@Autowired
private
SiteThemeService
siteThemeService
;
/**
* 根据站点 同步事项
*
* @param siteEntity
* @param context
* @return
*/
@Override
public
Rest
<
String
>
doMatterBySiteId
(
SiteEntity
siteEntity
,
Context
context
)
{
AreaEntity
areaEntity
=
areaService
.
getCache
(
siteEntity
.
getAreaCode
());
// List<MatterEntity> govMatterList = new ArrayList<>();
List
<
DeptEntity
>
deptEntities
=
deptService
.
find
(
new
DeptQuery
().
siteId
(
siteEntity
.
getId
()).
source
(
SourceEnum
.
政务网
.
getValue
()));
List
<
MatterEntity
>
govMatterList
=
deptEntities
.
parallelStream
().
flatMap
(
deptEntity
->
{
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"areaCode"
,
areaEntity
.
getAreaCode
());
params
.
put
(
"dxType"
,
"6"
);
params
.
put
(
"deptCode"
,
deptEntity
.
getDeptNumber
());
params
.
put
(
"searchtext"
,
""
);
params
.
put
(
"taskType"
,
""
);
List
<
MatterEntity
>
deptMatterList
=
this
.
getMatters
(
params
,
context
);
return
deptMatterList
.
stream
();
}).
collect
(
Collectors
.
toList
());
/* for (DeptEntity deptEntity : deptEntities) {
HashMap<String, String> params = new HashMap<>();
params.put("areaCode", areaEntity.getAreaCode());
params.put("dxType", "6");
params.put("deptCode", deptEntity.getDeptNumber());
params.put("searchtext", "");
params.put("taskType", "");
List<MatterEntity> deptMatterList = this.getMatters(params, context);
if (!ObjectUtils.isEmpty(deptMatterList)) {
govMatterList.addAll(deptMatterList);
}
}*/
//当前本地区事项全部事项
log
.
info
(
"计算差集"
);
MatterQuery
matterQuery
=
new
MatterQuery
();
matterQuery
.
setAreaCode
(
siteEntity
.
getAreaCode
());
matterQuery
.
setSource
(
SourceEnum
.
政务网
.
getValue
());
List
<
MatterEntity
>
matterList
=
matterService
.
getDao
().
getMatterListByAreaCode
(
matterQuery
);
log
.
info
(
"本地事项总数:{}"
,
matterList
.
size
());
Set
<
String
>
matterNoSet
=
matterList
.
parallelStream
().
map
(
i
->
i
.
getMatterNo
()).
collect
(
Collectors
.
toSet
());
List
<
MatterEntity
>
subList
=
this
.
subListSet
(
govMatterList
,
matterNoSet
);
subList
=
subList
.
parallelStream
().
distinct
().
collect
(
Collectors
.
toList
());
log
.
info
(
"抓取事项总数:{} 需要添加事项数量:{}"
,
govMatterList
.
size
(),
subList
.
size
());
//差集进行插入
if
(!
ObjectUtils
.
isEmpty
(
subList
))
{
for
(
MatterEntity
matterEntity
:
subList
)
{
DeptEntity
deptCache
=
deptService
.
getExtCache
(
matterEntity
.
getDeptCode
());
matterEntity
.
setDeptName
(
deptCache
==
null
?
""
:
deptCache
.
getName
());
matterEntity
.
setCreateTime
(
new
Date
());
matterEntity
.
setMatterEdition
(
"0"
);
}
matterService
.
save
(
subList
,
context
);
matterList
=
matterService
.
getDao
().
getMatterListByAreaCode
(
matterQuery
.
areaCode
(
siteEntity
.
getAreaCode
()));
}
for
(
MatterEntity
matterEntity
:
matterList
)
{
Rest
<
String
>
rest
=
matterService
.
buildMatterDetail
(
matterEntity
,
null
);
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
matterEntity
.
setUpdateTime
(
new
Date
());
matterService
.
update
(
matterEntity
,
null
);
}
}
// Rest<String> syncSiteMatterRest = siteMatterService.doSyncSiteMatter(siteEntity, context);
/* //查询站点事项相关
List<SiteEntity> siteEntities = siteService.find(new SiteQuery().areaCode(siteEntity.getAreaCode()));
if (!ObjectUtils.isEmpty(siteEntities)) {
log.info("同步站点事项到站点.....");
for (SiteEntity site : siteEntities) {
//判断是否已经有站点事项,如果有则不添加
Boolean bool = checkSiteMatter(site);
if (!bool) {
//添加站点事项 批量添加
List<SiteMatterEntity> siteMatterList = matterList.stream().map(item -> {
return matterService.switchMatterToSiteMatter(item, site, null).getData();
}).filter(f -> f != null).collect(Collectors.toList());
siteMatterService.save(siteMatterList);
}
}
log.info("同步站点事项到站点完成.....");
}*/
return
Rest
.
ok
();
}
private
Boolean
checkSiteMatter
(
SiteEntity
site
)
{
SiteMatterQuery
siteMatterQuery
=
new
SiteMatterQuery
();
siteMatterQuery
.
setSiteId
(
site
.
getId
());
siteMatterQuery
.
setSource
(
SourceEnum
.
政务网
.
getValue
());
int
count
=
siteMatterService
.
count
(
siteMatterQuery
,
null
);
if
(
count
>
0
)
{
return
true
;
}
return
false
;
}
public
List
<
MatterEntity
>
subListSet
(
List
<
MatterEntity
>
firstList
,
Set
<
String
>
secondSet
)
{
return
firstList
.
parallelStream
().
filter
(
item
->
!
secondSet
.
contains
(
item
.
getMatterNo
())).
collect
(
Collectors
.
toList
());
}
private
List
<
MatterEntity
>
getMatters
(
HashMap
<
String
,
String
>
params
,
Context
context
)
{
String
url
=
GlobalSysInfo
.
getParamValue
(
Constant
.
GOV_MATTER_PAGELIST_URL
,
"http://www.sczwfw.gov.cn/jiq/interface/item/tags"
);
Rest
<
Map
<
String
,
Integer
>>
restStat
=
MatterHtmlParseUtil
.
statSiteMatterCount
(
params
,
url
);
if
(
restStat
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
Integer
pageNum
=
restStat
.
getData
().
getOrDefault
(
"pageNum"
,
0
);
Integer
total
=
restStat
.
getData
().
getOrDefault
(
"total"
,
0
);
//获取事项全列表
Rest
<
List
<
MatterEntity
>>
matterAllRest
=
this
.
getMatterAllListByGOV
(
params
,
pageNum
,
context
);
if
(
matterAllRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
return
matterAllRest
.
getData
();
}
}
return
new
ArrayList
<>();
}
public
Rest
<
List
<
MatterEntity
>>
getMatterAllListByGOV
(
Map
<
String
,
String
>
params
,
Integer
pageNum
,
Context
context
)
{
//分页获取所有事项列表
List
<
MatterEntity
>
allList
=
new
ArrayList
<>();
String
url
=
GlobalSysInfo
.
getParamValue
(
Constant
.
GOV_MATTER_PAGELIST_URL
,
"http://www.sczwfw.gov.cn/jiq/interface/item/tags"
);
for
(
int
i
=
1
;
i
<=
pageNum
;
i
++)
{
params
.
put
(
"pageno"
,
String
.
valueOf
(
i
));
Rest
<
List
<
MatterEntity
>>
rest
=
MatterHtmlParseUtil
.
getMatterList
(
params
,
url
);
if
(
rest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
rest
.
getData
()))
{
allList
.
addAll
(
rest
.
getData
());
}
}
return
Rest
.
ok
(
allList
);
}
/**
* @param matterId
* @param context
*/
@Override
public
void
deleteByMatterId
(
Long
matterId
,
Context
context
)
{
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
condition
.
put
(
"matterId"
,
matterId
);
this
.
dao
.
delete
(
condition
);
}
/**
* 同步站点主题事项
*
* @param siteEntity
* @param context
* @return
*/
@Override
public
Rest
<
String
>
doMatterThemeBySiteId
(
SiteEntity
siteEntity
,
Context
context
)
{
AreaEntity
areaEntity
=
areaService
.
getCache
(
siteEntity
.
getAreaCode
());
//判断站点区域乡镇情况
if
(
areaEntity
.
getAreaLevel
()
<=
3
)
{
//省,市,区
Rest
<
String
>
themeRest
=
siteThemeService
.
syncThemeBySiteId
(
siteEntity
,
null
);
log
.
info
(
"同步站点主题:"
+
JSON
.
toJSONString
(
themeRest
));
log
.
info
(
"同步站点个人主题事项开始....."
);
siteThemeMatterService
.
deleteGovBySiteId
(
siteEntity
.
getId
(),
null
);
Rest
<
String
>
grRest
=
siteThemeMatterService
.
syncThemeMatterBySiteId
(
siteEntity
.
getId
(),
"2"
,
null
);
log
.
info
(
"同步站点主题个人事项:"
+
JSON
.
toJSONString
(
grRest
));
log
.
info
(
"同步站点法人主题事项开始....."
);
Rest
<
String
>
frRest
=
siteThemeMatterService
.
syncThemeMatterBySiteId
(
siteEntity
.
getId
(),
"3"
,
null
);
log
.
info
(
"同步站点主题法人事项:"
+
JSON
.
toJSONString
(
frRest
));
}
else
if
(
areaEntity
.
getAreaLevel
()
>
3
)
{
//街道,镇,乡
Rest
<
String
>
themeTownRest
=
siteThemeService
.
syncTownThemeBySiteId
(
siteEntity
,
null
);
log
.
info
(
"同步乡镇站点主题:"
+
JSON
.
toJSONString
(
themeTownRest
));
if
(
themeTownRest
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
siteThemeMatterService
.
deleteGovBySiteId
(
siteEntity
.
getId
(),
null
);
String
dxType
=
DxTypeEnum
.
街道镇服务
.
getValue
();
if
(
areaEntity
.
getAreaLevel
()
==
5
)
{
dxType
=
DxTypeEnum
.
乡村服务
.
getValue
();
}
Rest
<
String
>
townThemeRest
=
siteThemeMatterService
.
syncTownThemeMatterBySiteId
(
siteEntity
,
dxType
,
null
);
log
.
info
(
"同步站点乡镇主题事项:"
+
JSON
.
toJSONString
(
townThemeRest
));
}
else
{
try
{
// cacheService.del(RedisCacheKeys.getSyncMatterLockKey() + siteEntity.getAreaCode(), siteEntity.getAreaCode());
log
.
info
(
"同步站点乡镇主题事项失败:"
+
themeTownRest
.
getData
());
}
catch
(
Exception
e
)
{
log
.
error
(
"同步站点乡镇主题事项失败"
,
e
);
}
}
}
return
Rest
.
ok
();
}
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterServiceImpl.java
View file @
25a92094
...
...
@@ -267,11 +267,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
siteMatterEntity
.
setMatterId
(
item
.
getId
());
siteMatterEntity
.
setMatterCode
(
item
.
getMatterNo
());
siteMatterEntity
.
setMatterName
(
item
.
getMatterName
());
siteMatterEntity
.
setDeptCode
(
item
.
getDeptCode
());
siteMatterEntity
.
setSource
(
item
.
getSource
());
siteMatterEntity
.
setEventTypeShow
(
item
.
getEventTypeShow
());
siteMatterEntity
.
setDeptName
(
deptEntity
==
null
?
""
:
deptEntity
.
getName
());
siteMatterEntity
.
setDeptId
(
deptEntity
==
null
?
-
1L
:
deptEntity
.
getId
());
siteMatterEntity
.
setDeptCode
(
deptEntity
==
null
?
""
:
deptEntity
.
getDeptNumber
());
siteMatterEntity
.
setCreateUserId
(
context
==
null
?
1L
:
context
.
getUser
()
==
null
?
1L
:
context
.
getUser
().
getId
());
siteMatterEntity
.
setCreateTime
(
new
Date
());
return
Rest
.
ok
(
siteMatterEntity
);
...
...
@@ -284,9 +284,10 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override
public
Result
<
MatterEntity
>
findSubList
(
MatterEntity
matterQuery
,
PageInfo
pageInfo
,
Context
context
)
throws
AppException
{
// SiteEntity siteCache = siteService.getCache(matterQuery.getSiteId().toString());
// SiteEntity siteCache = siteService.getCache(matterQuery.getSiteId().toString());
SiteEntity
siteCache
=
siteService
.
get
(
matterQuery
.
getSiteId
());
if
(
ObjectUtils
.
isEmpty
(
siteCache
))
throw
new
AppException
(
"查询站点id不能为空!siteId:"
+
matterQuery
.
getSiteId
());
if
(
ObjectUtils
.
isEmpty
(
siteCache
))
throw
new
AppException
(
"查询站点id不能为空!siteId:"
+
matterQuery
.
getSiteId
());
if
(
ObjectUtils
.
isEmpty
(
matterQuery
.
getAreaCode
()))
{
matterQuery
.
setAreaCode
(
siteCache
==
null
?
null
:
siteCache
.
getAreaCode
());
}
...
...
@@ -1021,7 +1022,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//根据事项url 获取事项详细信息,构建相关详细信息
String
html
=
null
;
try
{
Document
dom
=
Jsoup
.
connect
(
matterEntity
.
getUrl
()).
timeout
(
30
*
1000
).
get
();
if
(
ObjectUtils
.
isEmpty
(
matterEntity
.
getUrl
()))
{
return
Rest
.
fail
(
"事项url不能为空!"
);
}
Document
dom
=
Jsoup
.
connect
(
matterEntity
.
getUrl
()).
timeout
(
60
*
1000
).
get
();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html);
...
...
@@ -1030,16 +1035,25 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
Setting
baseInfoSetting
=
interceptorConfig
.
getBaseInfoSetting
();
Setting
sqclInfoSetting
=
interceptorConfig
.
getSqclInfoSetting
();
//更新部门信息
DeptEntity
extCache
=
deptService
.
getExtCache
(
matterEntity
.
getDeptCode
());
matterEntity
.
setDeptName
(
extCache
==
null
?
""
:
extCache
.
getName
());
/* if(!ObjectUtils.isEmpty(matterEntity.getDeptCode())&&ObjectUtils.isEmpty(matterEntity.getDeptName())){
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache==null?"":extCache.getName());
}*/
//根据本地与远端事项版本觉得是否更新或者新增
Integer
matterEditionLocal
=
DataUtil
.
converStr2Int
(
matterEntity
.
getMatterEdition
(),
0
);
Map
<
String
,
String
>
baseInfoMap
=
MatterDetailHtmlParseUtil
.
getbaseInfoMapByHtml
(
dom
);
Integer
matterEditionRemote
=
DataUtil
.
converStr2Int
(
baseInfoMap
.
getOrDefault
(
"事项版本"
,
"0"
),
0
);
if
(
matterEditionLocal
>=
matterEditionRemote
)
{
return
Rest
.
fail
(
"本地事项版本大于等于远端,不需要更新!"
);
}
//更新部门信息
DeptEntity
extCache
=
deptService
.
getExtCache
(
matterEntity
.
getDeptCode
());
matterEntity
.
setDeptName
(
extCache
==
null
?
""
:
extCache
.
getName
());
//构建基础信息参数
savebaseInfo
(
matterEntity
,
dom
,
baseInfoSetting
);
savebaseInfo
(
matterEntity
,
baseInfoMap
,
baseInfoSetting
);
//更新材料属性
saveDatumInfo
(
matterEntity
,
context
,
dom
,
sqclInfoSetting
);
...
...
@@ -1168,8 +1182,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
matterChargesService
.
save
(
matterChargesEntity
);
}
private
void
savebaseInfo
(
MatterEntity
matterEntity
,
Document
dom
,
Setting
baseInfoSetting
)
{
Map
<
String
,
String
>
baseInfoMap
=
MatterDetailHtmlParseUtil
.
getbaseInfoMapByHtml
(
dom
);
private
void
savebaseInfo
(
MatterEntity
matterEntity
,
Map
<
String
,
String
>
baseInfoMap
,
Setting
baseInfoSetting
)
{
//
Map<String, String> baseInfoMap = MatterDetailHtmlParseUtil.getbaseInfoMapByHtml(dom);
List
<
MatterExtEntity
>
matterExtEntities
=
new
ArrayList
<>();
long
sortN
=
1
;
for
(
Map
.
Entry
<
String
,
String
>
m
:
baseInfoMap
.
entrySet
())
{
...
...
@@ -1202,6 +1216,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
if
(!
ObjectUtils
.
isEmpty
(
matterExtEntities
))
{
//先删除后添加
matterExtService
.
deleteByMatterId
(
matterEntity
.
getId
(),
null
);
matterExtService
.
save
(
matterExtEntities
,
null
);
}
...
...
@@ -1209,7 +1224,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
private
void
saveBllcInfo
(
MatterEntity
matterEntity
,
Context
context
,
Document
dom
)
{
List
<
Map
<
String
,
Object
>>
bllcMapList
=
MatterDetailHtmlParseUtil
.
getbllcMapByHtml
(
dom
);
matterFlowlimitService
.
deleteByMatterId
(
matterEntity
.
getId
(),
context
);
List
<
MatterFlowlimitEntity
>
flowlimitEntityArrayList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
bllcMap
:
bllcMapList
)
{
MatterFlowlimitEntity
matterFlowlimitEntity
=
new
MatterFlowlimitEntity
();
...
...
@@ -1238,7 +1253,12 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
});
flowlimitEntityArrayList
.
add
(
matterFlowlimitEntity
);
}
matterFlowlimitService
.
save
(
flowlimitEntityArrayList
);
if
(!
ObjectUtils
.
isEmpty
(
flowlimitEntityArrayList
))
{
matterFlowlimitService
.
deleteByMatterId
(
matterEntity
.
getId
(),
context
);
matterFlowlimitService
.
save
(
flowlimitEntityArrayList
);
}
}
private
void
saveSltjInfo
(
MatterEntity
matterEntity
,
Context
context
,
Document
dom
)
{
...
...
base-manager/src/main/java/com/mortals/xhx/module/site/service/SiteMatterService.java
View file @
25a92094
package
com.mortals.xhx.module.site.service
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.site.dao.SiteMatterDao
;
import
com.mortals.xhx.module.site.model.SiteEntity
;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
/**
...
...
@@ -17,5 +19,8 @@ public interface SiteMatterService extends ICRUDService<SiteMatterEntity, Long>
SiteMatterDao
getDao
();
Rest
<
String
>
doSyncSiteMatter
(
SiteEntity
siteEntity
,
Context
context
);
void
deleteBysiteIdAndSource
(
Long
siteId
,
Integer
source
,
Context
context
);
}
\ No newline at end of file
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteMatterServiceImpl.java
View file @
25a92094
package
com.mortals.xhx.module.site.service.impl
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.xhx.common.code.SourceEnum
;
import
com.mortals.xhx.module.matter.model.MatterEntity
;
import
com.mortals.xhx.module.matter.model.MatterQuery
;
import
com.mortals.xhx.module.matter.service.MatterService
;
import
com.mortals.xhx.module.site.model.
SiteThemeMatterEntity
;
import
com.mortals.xhx.module.site.
model.SiteThemeMatterQuery
;
import
com.mortals.xhx.module.site.model.
*
;
import
com.mortals.xhx.module.site.
service.SiteService
;
import
com.mortals.xhx.module.site.service.SiteThemeMatterService
;
import
com.mortals.xhx.module.site.service.SiteThemeService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.xhx.module.site.dao.SiteMatterDao
;
import
com.mortals.xhx.module.site.model.SiteMatterEntity
;
import
com.mortals.xhx.module.site.service.SiteMatterService
;
import
org.springframework.util.ObjectUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -31,12 +34,15 @@ import java.util.stream.Collectors;
* @date 2022-01-12
*/
@Service
(
"siteMatterService"
)
@Slf4j
public
class
SiteMatterServiceImpl
extends
AbstractCRUDServiceImpl
<
SiteMatterDao
,
SiteMatterEntity
,
Long
>
implements
SiteMatterService
{
@Autowired
private
MatterService
matterService
;
@Autowired
private
SiteThemeMatterService
siteThemeMatterService
;
@Autowired
private
SiteService
siteService
;
@Override
protected
void
findAfter
(
SiteMatterEntity
params
,
PageInfo
pageInfo
,
Context
context
,
List
<
SiteMatterEntity
>
list
)
throws
AppException
{
...
...
@@ -109,4 +115,54 @@ public class SiteMatterServiceImpl extends AbstractCRUDServiceImpl<SiteMatterDao
condition
.
put
(
"source"
,
source
);
this
.
dao
.
delete
(
condition
);
}
/**
* @param siteEntity
* @param context
* @return
*/
@Override
public
Rest
<
String
>
doSyncSiteMatter
(
SiteEntity
siteEntity
,
Context
context
)
{
List
<
MatterEntity
>
matterList
=
matterService
.
getDao
().
getMatterListByAreaCode
(
new
MatterQuery
().
areaCode
(
siteEntity
.
getAreaCode
()).
source
(
SourceEnum
.
政务网
.
getValue
()));
//查询站点事项相关
SiteEntity
site
=
siteService
.
selectOne
(
new
SiteQuery
().
areaCode
(
siteEntity
.
getAreaCode
()));
if
(!
ObjectUtils
.
isEmpty
(
site
))
{
log
.
info
(
"同步站点事项到站点....."
);
SiteMatterQuery
siteMatterQuery
=
new
SiteMatterQuery
();
siteMatterQuery
.
setSiteId
(
site
.
getId
());
siteMatterQuery
.
setSource
(
SourceEnum
.
政务网
.
getValue
());
List
<
SiteMatterEntity
>
localList
=
this
.
getDao
().
getList
(
siteMatterQuery
);
log
.
info
(
"本地站点事项数量.....{}"
,
localList
.
size
());
//找到差集 然后添加
Set
<
Long
>
existSiteMatterIdSet
=
localList
.
parallelStream
().
map
(
i
->
i
.
getMatterId
()).
collect
(
Collectors
.
toSet
());
List
<
MatterEntity
>
subList
=
matterList
.
parallelStream
().
filter
(
f
->
!
existSiteMatterIdSet
.
contains
(
f
.
getId
())).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
subList
)){
//需要新增的站点事项
log
.
info
(
"需要新增的站点事项数量.....{}"
,
subList
.
size
());
List
<
SiteMatterEntity
>
siteMatterList
=
subList
.
parallelStream
()
.
map
(
item
->
matterService
.
switchMatterToSiteMatter
(
item
,
site
,
null
).
getData
())
.
filter
(
f
->
f
!=
null
)
.
collect
(
Collectors
.
toList
());
this
.
save
(
siteMatterList
);
}
/*
//判断是否已经有站点事项,如果有则不添加
Boolean bool = checkSiteMatter(site);
if (!bool) {
//添加站点事项 批量添加
List<SiteMatterEntity> siteMatterList = matterList.stream().map(item -> {
return matterService.switchMatterToSiteMatter(item, site, null).getData();
}).filter(f -> f != null).collect(Collectors.toList());
this.save(siteMatterList);
}
*/
log
.
info
(
"同步站点事项到站点完成....."
);
}
return
Rest
.
ok
();
}
}
\ No newline at end of file
base-manager/src/main/resources/sqlmap/module/matter/MatterMapperExt.xml
View file @
25a92094
...
...
@@ -65,9 +65,37 @@
</trim>
</select>
<select
id=
"getMatterListByAreaCodeCount"
parameterType=
"paramDto"
resultType=
"int"
>
select
count( 1 )
FROM
mortals_sys_matter AS a
where
<trim
prefixOverrides=
"and"
prefix=
""
>
<if
test=
"condition.areaCode!=null and condition.areaCode!=''"
>
and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
</if>
</trim>
<if
test=
"condition.source!=null and condition.source!=''"
>
and a.source = #{condition.source,jdbcType=INTEGER}
</if>
</select>
<select
id=
"getMatterListByAreaCode"
parameterType=
"paramDto"
resultMap=
"MatterEntity-Map"
>
select
a.matterNo
a.id,
a.matterNo,
a.matterName,
a.deptCode,
a.source,
a.url,
a.matterEdition,
a.eventTypeShow
FROM
mortals_sys_matter AS a
where
...
...
@@ -76,6 +104,11 @@
and a.areaCode = #{condition.areaCode,jdbcType=VARCHAR}
</if>
</trim>
<if
test=
"condition.source!=null and condition.source!=''"
>
and a.source = #{condition.source,jdbcType=INTEGER}
</if>
</select>
</mapper>
\ No newline at end of file
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