Commit 7e80949f authored by “yiyousong”'s avatar “yiyousong”
parents 28f86b73 67c1a627
......@@ -4,10 +4,12 @@ import cn.hutool.core.collection.ListUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.ManagerBaseApplication;
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;
......@@ -52,6 +54,8 @@ public class SyncGovMatterDetailThread implements Runnable {
private Context context;
private ICacheService cacheService;
public SyncGovMatterDetailThread(SiteEntity siteEntity, Context context) {
this.siteEntity = siteEntity;
......@@ -63,6 +67,7 @@ public class SyncGovMatterDetailThread implements Runnable {
this.siteMatterService = SpringUtils.getBean(SiteMatterService.class);
this.siteThemeService = SpringUtils.getBean(SiteThemeService.class);
this.siteThemeMatterService = SpringUtils.getBean(SiteThemeMatterService.class);
this.cacheService = SpringUtils.getBean(ICacheService.class);
}
@Override
......@@ -120,13 +125,18 @@ public class SyncGovMatterDetailThread implements Runnable {
//街道,镇,乡
Rest<String> themeTownRest = siteThemeService.syncTownThemeBySiteId(siteEntity, context);
log.info("同步乡镇站点主题:" + JSON.toJSONString(themeTownRest));
siteThemeMatterService.deleteGovBySiteId(siteEntity.getId(), context);
String dxType = DxTypeEnum.街道镇服务.getValue();
if (areaEntity.getAreaLevel() == 5) {
dxType = DxTypeEnum.乡村服务.getValue();
if (themeTownRest.getCode() == YesNoEnum.YES.getValue()) {
siteThemeMatterService.deleteGovBySiteId(siteEntity.getId(), context);
String dxType = DxTypeEnum.街道镇服务.getValue();
if (areaEntity.getAreaLevel() == 5) {
dxType = DxTypeEnum.乡村服务.getValue();
}
Rest<String> townThemeRest = siteThemeMatterService.syncTownThemeMatterBySiteId(siteEntity, dxType, context);
log.info("同步站点乡镇主题事项:" + JSON.toJSONString(townThemeRest));
} else {
cacheService.hdel(RedisCacheKeys.getSyncMatterLockKey() + siteEntity.getAreaCode(), siteEntity.getAreaCode());
log.info("同步站点乡镇主题事项失败:" + themeTownRest.getData());
}
Rest<String> townThemeRest = siteThemeMatterService.syncTownThemeMatterBySiteId(siteEntity, dxType, context);
log.info("同步站点乡镇主题事项:" + JSON.toJSONString(townThemeRest));
}
log.info("同步站点事项结束.....");
}
......
......@@ -138,6 +138,7 @@ public class SiteThemeMatterServiceImpl extends AbstractCRUDServiceImpl<SiteThem
params.put("dxType", dxType);
params.put("areaCode", siteEntity.getAreaCode());
List<SiteThemeEntity> siteThemeEntities = siteThemeService.find(new SiteThemeQuery().siteId(siteEntity.getId()));
int sum=0;
for (SiteThemeEntity item : siteThemeEntities) {
params.put("theme", item.getThemeCode());
params.put("userType", item.getUserType());
......@@ -160,9 +161,35 @@ public class SiteThemeMatterServiceImpl extends AbstractCRUDServiceImpl<SiteThem
if (count != total) {
log.info(String.format("获取数量异常,count:%s,total:%s,theme:%s", count, total, item.getThemeName()));
}
sum+=count;
}
if (!ObjectUtils.isEmpty(allList)) {
//当前主题列表 查找站点事项id列表,保存站点主题事项
List<String> matterCodeList = allList.stream().map(m -> m.getMatterNo()).collect(Collectors.toList());
SiteMatterQuery siteMatterQuery = new SiteMatterQuery();
siteMatterQuery.setSiteId(siteEntity.getId());
siteMatterQuery.setMatterCodeList(matterCodeList);
List<SiteMatterEntity> siteMatterEntities = siteMatterService.find(siteMatterQuery, context);
log.info(String.format("size1:%d,size2:%d", allList.size(), siteMatterEntities.size()));
if (!ObjectUtils.isEmpty(siteMatterEntities)) {
List<SiteThemeMatterEntity> collect = siteMatterEntities.stream().map(siteMatterEntity -> {
SiteThemeMatterEntity siteThemeMatterEntity = new SiteThemeMatterEntity();
siteThemeMatterEntity.initAttrValue();
BeanUtils.copyProperties(siteMatterEntity, siteThemeMatterEntity, BeanUtil.getNullPropertyNames(siteMatterEntity));
siteThemeMatterEntity.setThemeCode(item.getThemeCode());
siteThemeMatterEntity.setThemeName(item.getThemeName());
siteThemeMatterEntity.setUserType(item.getUserType());
return siteThemeMatterEntity;
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
this.save(collect, context);
}
}
}
}
return Rest.ok("乡镇主题更新完成");
return Rest.ok("乡镇主题更新完成","更新条数:"+sum);
}
@Override
......
......@@ -86,7 +86,7 @@ Authorization: {{authToken}}
Content-Type: application/json
{
"id":7
"id":26
}
......
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