| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import com.ruoyi.common.core.service.IUserExtInfoService; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.IvrLibaScriptAssort; |
| | | import com.smartor.domain.SvyLibScriptCategory; |
| | | import com.smartor.domain.SysUserOrg; |
| | | import com.smartor.mapper.IvrLibaScriptAssortMapper; |
| | | import com.smartor.mapper.SvyLibScriptCategoryMapper; |
| | | import com.smartor.mapper.SysUserOrgMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 用户扩展信息服务实现(smartor 模块) |
| | | * 供 ruoyi-system 通过 SpringUtils 调用 |
| | | * <p> |
| | | * 迁移说明:原 {@code getSatisfactionCategories}(含 Redis 缓存、语音/问卷分类查询) |
| | | * 属于满意度逻辑,已整段搬入 ruoyi-satisfaction 模块,由 |
| | | * {@code com.ruoyi.satisfaction.api.SatisfactionFacade} 实现 |
| | | * {@code com.ruoyi.common.core.service.ISatisfactionCategoryService}。 |
| | | * 本类因此不再依赖 {@code IvrLibaScriptAssortMapper} / {@code SvyLibScriptCategoryMapper} / {@code RedisCache}。 |
| | | */ |
| | | @Service |
| | | public class UserExtInfoServiceImpl implements IUserExtInfoService { |
| | | |
| | | private static final String SATISFACTION_CACHE_KEY = "satisfaction:categories:"; |
| | | private static final int SATISFACTION_CACHE_TTL = 30; |
| | | |
| | | @Autowired |
| | | private SysUserOrgMapper sysUserOrgMapper; |
| | | |
| | | @Autowired |
| | | private IvrLibaScriptAssortMapper ivrLibaScriptAssortMapper; |
| | | |
| | | @Autowired |
| | | private SvyLibScriptCategoryMapper svyLibScriptCategoryMapper; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | /** |
| | | * 获取用户机构/院区信息 |
| | |
| | | result.put("campusid", sysUserOrgs.get(0).getCampusid()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 获取满意度问题分类(语音 + 问卷),带Redis缓存 |
| | | */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public Map<String, Object> getSatisfactionCategories(String orgid) { |
| | | // 先查缓存 |
| | | String cacheKey = SATISFACTION_CACHE_KEY + orgid; |
| | | Map<String, Object> cached = redisCache.getCacheObject(cacheKey); |
| | | if (cached != null) { |
| | | return cached; |
| | | } |
| | | |
| | | Map<String, Object> satisfactionCategories = new HashMap<>(); |
| | | |
| | | // 获取语音问题分类 |
| | | IvrLibaScriptAssort ivrLibaScriptAssort = new IvrLibaScriptAssort(); |
| | | ivrLibaScriptAssort.setOrgid(orgid); |
| | | ivrLibaScriptAssort.setType("myd"); |
| | | List<IvrLibaScriptAssort> ivrLibaScriptAssorts = ivrLibaScriptAssortMapper.selectIvrLibaScriptAssortList(ivrLibaScriptAssort); |
| | | List<Map<String, Object>> categoryList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(ivrLibaScriptAssorts)) { |
| | | for (IvrLibaScriptAssort assort : ivrLibaScriptAssorts) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("categoryid", assort.getId()); |
| | | map.put("categoryName", assort.getIndexAssortName()); |
| | | categoryList.add(map); |
| | | } |
| | | } |
| | | satisfactionCategories.put("voiceCategories", categoryList); |
| | | |
| | | // 获取问卷问题分类 |
| | | SvyLibScriptCategory svyLibScriptCategory = new SvyLibScriptCategory(); |
| | | svyLibScriptCategory.setOrgid(orgid); |
| | | svyLibScriptCategory.setType("myd"); |
| | | List<SvyLibScriptCategory> svyLibScriptCategories = svyLibScriptCategoryMapper.selectSvyLibScriptCategoryList(svyLibScriptCategory); |
| | | List<Map<String, Object>> questionnaireCategorys = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(svyLibScriptCategories)) { |
| | | for (SvyLibScriptCategory scriptCategory : svyLibScriptCategories) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("categoryid", scriptCategory.getId()); |
| | | map.put("categoryName", scriptCategory.getName()); |
| | | questionnaireCategorys.add(map); |
| | | } |
| | | } |
| | | satisfactionCategories.put("questionnaireCategorys", questionnaireCategorys); |
| | | |
| | | // 写入缓存 |
| | | redisCache.setCacheObject(cacheKey, satisfactionCategories, SATISFACTION_CACHE_TTL, TimeUnit.MINUTES); |
| | | |
| | | return satisfactionCategories; |
| | | } |
| | | } |