Commit 72160dbd authored by YIyiyi's avatar YIyiyi
parents ebcb3902 155702e0
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
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.SourceEnum; import com.mortals.xhx.common.code.SourceEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
...@@ -11,18 +14,16 @@ import com.mortals.xhx.module.matter.model.MatterEntity; ...@@ -11,18 +14,16 @@ 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.MatterService; import com.mortals.xhx.module.matter.service.MatterService;
import com.mortals.xhx.module.matters.service.MattersService; import com.mortals.xhx.module.matters.service.MattersService;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.*;
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.SiteThemeService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
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 java.util.Arrays; import java.util.*;
import java.util.Date; import java.util.stream.Collectors;
import java.util.List;
/** /**
* 统计站点部门事项 * 统计站点部门事项
...@@ -37,6 +38,12 @@ public class StatSiteDeptMatterTaskImpl implements ITaskExcuteService { ...@@ -37,6 +38,12 @@ public class StatSiteDeptMatterTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private SiteService siteService; private SiteService siteService;
@Autowired
private ICacheService cacheService;
@Autowired
private SiteThemeService siteThemeService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
...@@ -61,7 +68,33 @@ public class StatSiteDeptMatterTaskImpl implements ITaskExcuteService { ...@@ -61,7 +68,33 @@ public class StatSiteDeptMatterTaskImpl implements ITaskExcuteService {
} }
} }
//分组暂存 站点 个人企业 主题
Map<String, List<SiteThemeEntity>> collect = siteThemeService.find(new SiteThemeQuery())
.parallelStream()
.collect(Collectors.groupingBy(x -> x.getSiteId() + "_" + x.getUserType() + "_" + x.getThemeCode()
));
Iterator<Map.Entry<String, List<SiteThemeEntity>>> iterator = collect.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, List<SiteThemeEntity>> next = iterator.next();
if (next.getValue().size() == 0) {
iterator.remove();
}
}
//重新 构建redis siteId+userType= >themeCodelist
List<SiteThemeEntity> themeEntities = collect.values().stream().flatMap(i -> i.stream()).collect(Collectors.toList());
themeEntities.stream()
.collect(Collectors.groupingBy(x -> x.getSiteId() + "_" + x.getUserType()))
.entrySet()
.stream()
.forEach(item -> {
String key = item.getKey();
List<SiteThemeEntity> values = item.getValue();
String[] split = key.split("_");
String siteId = split[0];
String userType = split[1];
cacheService.hset(RedisCacheKeys.getSiteUserTypeThemeCodeKey() + siteId, userType, JSONObject.toJSONString(values));
});
} }
@Override @Override
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
and a.siteId = #{condition.siteId} and a.siteId = #{condition.siteId}
</if> </if>
</trim> </trim>
</select> </select>
<!-- 获取事项差集列表列表 --> <!-- 获取事项差集列表列表 -->
......
...@@ -50,4 +50,9 @@ public final class RedisCacheKeys { ...@@ -50,4 +50,9 @@ public final class RedisCacheKeys {
return "workflow:sub:key:"; return "workflow:sub:key:";
} }
public static String getSiteUserTypeThemeCodeKey() {
return "site:usertype:themecode:";
}
} }
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