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

优化站点同步事项

parent 16bad86e
......@@ -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()
......
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
......@@ -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);
......@@ -286,7 +286,8 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
public Result<MatterEntity> findSubList(MatterEntity matterQuery, PageInfo pageInfo, Context context) throws AppException {
// 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,9 +1240,14 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
});
flowlimitEntityArrayList.add(matterFlowlimitEntity);
}
if (!ObjectUtils.isEmpty(flowlimitEntityArrayList)) {
matterFlowlimitService.deleteByMatterId(matterEntity.getId(), context);
matterFlowlimitService.save(flowlimitEntityArrayList);
}
}
private void saveSltjInfo(MatterEntity matterEntity, Context context, Document dom) {
matterAcceptService.deleteByMatterId(matterEntity.getId(), context);
Map<String, String> sltjMap = MatterDetailHtmlParseUtil.getSltjMapByHtml(dom);
......
......@@ -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
......
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