Commit 20389c03 authored by 赵啸非's avatar 赵啸非

修改重试机制

parent 6eede6d5
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
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.area.model.AreaEntity;
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.MatterQuery;
import com.mortals.xhx.module.matter.service.MatterExtService; 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.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.SiteMatterService;
import com.mortals.xhx.module.site.service.SiteService; 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 lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
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 org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 同步全部站点事项 * 同步全部站点事项
...@@ -75,7 +52,7 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -75,7 +52,7 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
log.info("开始同步事项==》{}", siteEntity.getSiteName()); log.info("开始同步事项==》{}", siteEntity.getSiteName());
stopWatch.start("开始同步事项方法"); stopWatch.start("开始同步事项方法");
matterExtService.doMatterBySiteId(siteEntity, null); matterExtService.syncMatterBySiteId(siteEntity, null);
stopWatch.stop(); stopWatch.stop();
log.info("同步事项完成,耗时:{}s", stopWatch.getLastTaskTimeMillis() / 1000); log.info("同步事项完成,耗时:{}s", stopWatch.getLastTaskTimeMillis() / 1000);
...@@ -87,7 +64,7 @@ public class SyncMatterTaskImpl implements ITaskExcuteService { ...@@ -87,7 +64,7 @@ public class SyncMatterTaskImpl implements ITaskExcuteService {
//同步主题 //同步主题
stopWatch.start("开始同步主题事项"); stopWatch.start("开始同步主题事项");
matterExtService.doMatterThemeBySiteId(siteEntity, null); matterExtService.syncMatterThemeBySiteId(siteEntity, null);
stopWatch.stop(); stopWatch.stop();
log.info("同步主题事项完成,耗时:{}s", stopWatch.getLastTaskTimeMillis() / 1000); log.info("同步主题事项完成,耗时:{}s", stopWatch.getLastTaskTimeMillis() / 1000);
} }
......
...@@ -2,7 +2,6 @@ package com.mortals.xhx.module.matter.service; ...@@ -2,7 +2,6 @@ package com.mortals.xhx.module.matter.service;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context; 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.model.MatterExtEntity; import com.mortals.xhx.module.matter.model.MatterExtEntity;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
...@@ -17,10 +16,10 @@ import com.mortals.xhx.module.site.model.SiteEntity; ...@@ -17,10 +16,10 @@ import com.mortals.xhx.module.site.model.SiteEntity;
public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{ public interface MatterExtService extends ICRUDService<MatterExtEntity,Long>{
Rest<String> doMatterBySiteId(SiteEntity siteEntity, Context context); Rest<String> syncMatterBySiteId(SiteEntity siteEntity, Context context);
Rest<String> doMatterThemeBySiteId(SiteEntity siteEntity, Context context); Rest<String> syncMatterThemeBySiteId(SiteEntity siteEntity, Context context);
void deleteByMatterId(Long matterId, Context context); void deleteByMatterId(Long matterId, Context context);
......
...@@ -75,7 +75,7 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao, ...@@ -75,7 +75,7 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
* @return * @return
*/ */
@Override @Override
public Rest<String> doMatterBySiteId(SiteEntity siteEntity, Context context) { public Rest<String> syncMatterBySiteId(SiteEntity siteEntity, Context context) {
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode()); AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(SourceEnum.政务网.getValue())); List<DeptEntity> deptEntities = deptService.find(new DeptQuery().siteId(siteEntity.getId()).source(SourceEnum.政务网.getValue()));
List<MatterEntity> govMatterList = deptEntities.parallelStream().flatMap(deptEntity -> { List<MatterEntity> govMatterList = deptEntities.parallelStream().flatMap(deptEntity -> {
...@@ -130,6 +130,8 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao, ...@@ -130,6 +130,8 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
for (MatterEntity matterEntity : matterList) { for (MatterEntity matterEntity : matterList) {
Rest<String> rest = matterService.buildMatterDetail(matterEntity, null); Rest<String> rest = matterService.buildMatterDetail(matterEntity, null);
if (rest.getCode() == YesNoEnum.YES.getValue()) { if (rest.getCode() == YesNoEnum.YES.getValue()) {
// log.info("更新详细事项==>{},id===>{},localVersion===>{}", matterEntity.getMatterName(),matterEntity.getId(),matterEntity.getMatterEdition());
//matterEntity.setUrl(null);
matterEntity.setUpdateTime(new Date()); matterEntity.setUpdateTime(new Date());
matterService.update(matterEntity, null); matterService.update(matterEntity, null);
} }
...@@ -145,7 +147,7 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao, ...@@ -145,7 +147,7 @@ public class MatterExtServiceImpl extends AbstractCRUDServiceImpl<MatterExtDao,
* @return * @return
*/ */
@Override @Override
public Rest<String> doMatterThemeBySiteId(SiteEntity siteEntity, Context context) { public Rest<String> syncMatterThemeBySiteId(SiteEntity siteEntity, Context context) {
AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode()); AreaEntity areaEntity = areaService.getCache(siteEntity.getAreaCode());
//判断站点区域乡镇情况 //判断站点区域乡镇情况
if (areaEntity.getAreaLevel() <= 3) { if (areaEntity.getAreaLevel() <= 3) {
......
...@@ -1067,7 +1067,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter ...@@ -1067,7 +1067,7 @@ public class MatterServiceImpl extends AbstractCRUDServiceImpl<MatterDao, Matter
// return Rest.fail("本地事项版本大于等于远端,不需要更新!"); // return Rest.fail("本地事项版本大于等于远端,不需要更新!");
} }
log.info("更新详细事项==>{},id===>{},localVersion===>{},newVersion==>{}", matterEntity.getMatterName(),matterEntity.getId(),matterEntity.getMatterEdition(), matterEditionRemote); // log.info("更新详细事项==>{},id===>{},localVersion===>{},newVersion==>{}", matterEntity.getMatterName(),matterEntity.getId(),matterEntity.getMatterEdition(), matterEditionRemote);
//更新部门信息 //更新部门信息
DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode()); DeptEntity extCache = deptService.getExtCache(matterEntity.getDeptCode());
matterEntity.setDeptName(extCache == null ? "" : extCache.getName()); matterEntity.setDeptName(extCache == null ? "" : extCache.getName());
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<property name="showSql" value="MySql" /> <property name="showSql" value="MySql" />
</plugin> </plugin>
<plugin interceptor="com.mortals.framework.thirty.mybatis.LogInterceptor"> <plugin interceptor="com.mortals.framework.thirty.mybatis.LogInterceptor">
<property name="enableExecutorTime" value="true" /> <property name="enableExecutorTime" value="false" />
<property name="showSql" value="false" /> <property name="showSql" value="false" />
</plugin> </plugin>
</plugins> </plugins>
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
<tx:method name="update*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="update*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="modify*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="modify*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="execute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="execute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="excute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <!--<tx:method name="excute*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="start*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> --><tx:method name="start*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="increment*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="increment*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="do*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="do*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
<tx:method name="audit*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" /> <tx:method name="audit*" propagation="REQUIRED" rollback-for="com.mortals.framework.exception.AppException" />
......
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