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
fd8c3278
Commit
fd8c3278
authored
Mar 05, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化站点同步事项
parent
16bad86e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
17 deletions
+263
-17
base-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
.../java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
+10
-2
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
+223
-7
base-manager/src/main/java/com/mortals/xhx/module/matter/service/impl/MatterServiceImpl.java
...als/xhx/module/matter/service/impl/MatterServiceImpl.java
+13
-6
base-manager/src/main/resources/sqlmap/module/matter/MatterMapperExt.xml
...c/main/resources/sqlmap/module/matter/MatterMapperExt.xml
+5
-1
No files found.
base-manager/src/main/java/com/mortals/xhx/daemon/task/SyncMatterTaskImpl.java
View file @
fd8c3278
...
...
@@ -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
;
...
...
@@ -64,13 +65,17 @@ 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
);
matterExtService
.
doMatterThemeBySiteId
(
siteEntity
,
null
);
// syncMatter(siteEntity);
}
// syncDevice();
log
.
info
(
"结束同步事项!"
);
...
...
@@ -82,8 +87,11 @@ 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/service/MatterExtService.java
View file @
fd8c3278
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 @
fd8c3278
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
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 +33,203 @@ 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"
)
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
()));
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
);
}
}
//当前本地区域事项全部事项
List
<
MatterEntity
>
matterList
=
matterService
.
getDao
().
getMatterListByAreaCode
(
new
MatterQuery
().
areaCode
(
siteEntity
.
getAreaCode
()));
//全部编码
Set
<
String
>
matterNoSet
=
matterList
.
parallelStream
().
map
(
i
->
i
.
getMatterNo
()).
collect
(
Collectors
.
toSet
());
//查询站点事项相关
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
(
"同步站点事项到站点完成....."
);
}
log
.
info
(
"同步站点事项详细条数....."
+
matterList
.
size
());
matterList
.
parallelStream
().
forEach
(
matterEntity
->
{
matterService
.
buildMatterDetail
(
matterEntity
,
null
);
matterEntity
.
setUpdateTime
(
new
Date
());
matterService
.
update
(
matterEntity
,
null
);
});
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
;
}
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 @
fd8c3278
...
...
@@ -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,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//根据事项url 获取事项详细信息,构建相关详细信息
String
html
=
null
;
try
{
Document
dom
=
Jsoup
.
connect
(
matterEntity
.
getUrl
()).
timeout
(
30
*
1000
).
get
();
Document
dom
=
Jsoup
.
connect
(
matterEntity
.
getUrl
()).
timeout
(
30
*
1000
).
get
();
// html = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html);
...
...
@@ -1202,6 +1203,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
if
(!
ObjectUtils
.
isEmpty
(
matterExtEntities
))
{
//先删除后添加
matterFlowlimitService
.
deleteByMatterId
(
matterEntity
.
getId
(),
null
);
matterExtService
.
save
(
matterExtEntities
,
null
);
}
...
...
@@ -1209,7 +1211,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 +1240,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/resources/sqlmap/module/matter/MatterMapperExt.xml
View file @
fd8c3278
...
...
@@ -67,7 +67,11 @@
<select
id=
"getMatterListByAreaCode"
parameterType=
"paramDto"
resultMap=
"MatterEntity-Map"
>
select
a.matterNo
a.id,
a.matterNo,
a.matterName,
a.source,
a.eventTypeShow
FROM
mortals_sys_matter AS a
where
...
...
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