Commit fd8c3278 authored by 赵啸非's avatar 赵啸非

优化站点同步事项

parent 16bad86e
...@@ -17,6 +17,7 @@ import com.mortals.xhx.module.area.service.AreaService; ...@@ -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.dept.service.DeptService;
import com.mortals.xhx.module.matter.model.MatterEntity; import com.mortals.xhx.module.matter.model.MatterEntity;
import com.mortals.xhx.module.matter.model.MatterQuery; 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.matter.service.MatterService;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import com.mortals.xhx.module.site.model.SiteMatterEntity; import com.mortals.xhx.module.site.model.SiteMatterEntity;
...@@ -64,13 +65,17 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -64,13 +65,17 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired
private MatterExtService matterExtService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("开始同步事项!"); log.info("开始同步事项!");
List<SiteEntity> siteEntities = siteService.find(new SiteEntity()); List<SiteEntity> siteEntities = siteService.find(new SiteEntity());
for (SiteEntity siteEntity : siteEntities) { for (SiteEntity siteEntity : siteEntities) {
syncMatter(siteEntity); matterExtService.doMatterThemeBySiteId(siteEntity,null);
// syncMatter(siteEntity);
} }
// syncDevice(); // syncDevice();
log.info("结束同步事项!"); log.info("结束同步事项!");
...@@ -82,8 +87,11 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -82,8 +87,11 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, null); Rest<String> deptRest = deptService.syncDeptBySiteId(siteEntity, null);
log.info("同步站点部门结果:" + JSON.toJSONString(deptRest)); log.info("同步站点部门结果:" + JSON.toJSONString(deptRest));
Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, null); Rest<String> rest = siteService.syncMatterBySiteId(siteEntity, null);
log.info("同步事项列表:" + JSON.toJSONString(rest)); //log.info("同步事项列表:" + JSON.toJSONString(rest));
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
//分页获取事项列表
List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue())); List<MatterEntity> matterEntityList = matterService.find(new MatterQuery().areaCode(siteEntity.getAreaCode()).source(SourceEnum.政务网.getValue()));
log.info("查询本地事项列表,size:{}",matterEntityList.size()); log.info("查询本地事项列表,size:{}",matterEntityList.size());
List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream() List<MatterEntity> unSyncDetailMatterList = matterEntityList.stream()
......
package com.mortals.xhx.module.matter.service; 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.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.dao.MatterExtDao; import com.mortals.xhx.module.matter.dao.MatterExtDao;
import com.mortals.xhx.module.matter.model.MatterExtEntity; import com.mortals.xhx.module.matter.model.MatterExtEntity;
import com.mortals.xhx.module.site.model.SiteEntity;
/** /**
* MatterExtService * MatterExtService
* *
...@@ -12,5 +16,12 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity; ...@@ -12,5 +16,12 @@ import com.mortals.xhx.module.matter.model.MatterExtEntity;
*/ */
public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{ 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
...@@ -267,11 +267,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -267,11 +267,11 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
siteMatterEntity.setMatterId(item.getId()); siteMatterEntity.setMatterId(item.getId());
siteMatterEntity.setMatterCode(item.getMatterNo()); siteMatterEntity.setMatterCode(item.getMatterNo());
siteMatterEntity.setMatterName(item.getMatterName()); siteMatterEntity.setMatterName(item.getMatterName());
siteMatterEntity.setDeptCode(item.getDeptCode());
siteMatterEntity.setSource(item.getSource()); siteMatterEntity.setSource(item.getSource());
siteMatterEntity.setEventTypeShow(item.getEventTypeShow()); siteMatterEntity.setEventTypeShow(item.getEventTypeShow());
siteMatterEntity.setDeptName(deptEntity == null ? "" : deptEntity.getName()); siteMatterEntity.setDeptName(deptEntity == null ? "" : deptEntity.getName());
siteMatterEntity.setDeptId(deptEntity == null ? -1L : deptEntity.getId()); 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.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
siteMatterEntity.setCreateTime(new Date()); siteMatterEntity.setCreateTime(new Date());
return Rest.ok(siteMatterEntity); return Rest.ok(siteMatterEntity);
...@@ -284,9 +284,10 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -284,9 +284,10 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
@Override @Override
public Result<MatterEntity> findSubList(MatterEntity matterQuery, PageInfo pageInfo, Context context) throws AppException { 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()); 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())) { if (ObjectUtils.isEmpty(matterQuery.getAreaCode())) {
matterQuery.setAreaCode(siteCache == null ? null : siteCache.getAreaCode()); matterQuery.setAreaCode(siteCache == null ? null : siteCache.getAreaCode());
} }
...@@ -1021,7 +1022,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1021,7 +1022,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
//根据事项url 获取事项详细信息,构建相关详细信息 //根据事项url 获取事项详细信息,构建相关详细信息
String html = null; String html = null;
try { 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 = Jsoup.connect(matterEntity.getUrl()).get().body().html();
// html = HttpUtil.get(matterEntity.getUrl()); // html = HttpUtil.get(matterEntity.getUrl());
//System.out.println(html); //System.out.println(html);
...@@ -1202,6 +1203,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1202,6 +1203,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
if (!ObjectUtils.isEmpty(matterExtEntities)) { if (!ObjectUtils.isEmpty(matterExtEntities)) {
//先删除后添加 //先删除后添加
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), null);
matterExtService.save(matterExtEntities, null); matterExtService.save(matterExtEntities, null);
} }
...@@ -1209,7 +1211,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1209,7 +1211,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
private void saveBllcInfo(MatterEntity matterEntity, Context context, Document dom) { private void saveBllcInfo(MatterEntity matterEntity, Context context, Document dom) {
List<Map<String, Object>> bllcMapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom); List<Map<String, Object>> bllcMapList = MatterDetailHtmlParseUtil.getbllcMapByHtml(dom);
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), context);
List<MatterFlowlimitEntity> flowlimitEntityArrayList = new ArrayList<>(); List<MatterFlowlimitEntity> flowlimitEntityArrayList = new ArrayList<>();
for (Map<String, Object> bllcMap : bllcMapList) { for (Map<String, Object> bllcMap : bllcMapList) {
MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity(); MatterFlowlimitEntity matterFlowlimitEntity = new MatterFlowlimitEntity();
...@@ -1238,7 +1240,12 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1238,7 +1240,12 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
}); });
flowlimitEntityArrayList.add(matterFlowlimitEntity); 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) { private void saveSltjInfo(MatterEntity matterEntity, Context context, Document dom) {
......
...@@ -67,7 +67,11 @@ ...@@ -67,7 +67,11 @@
<select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map"> <select id="getMatterListByAreaCode" parameterType="paramDto" resultMap="MatterEntity-Map">
select select
a.matterNo a.id,
a.matterNo,
a.matterName,
a.source,
a.eventTypeShow
FROM FROM
mortals_sys_matter AS a mortals_sys_matter AS a
where where
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment