|
|
@@ -9,7 +9,9 @@ import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.*;
|
|
|
+import com.sckw.system.api.model.pojo.DeptInfoPojo;
|
|
|
import com.sckw.system.dao.SysDictDao;
|
|
|
+import com.sckw.system.model.KwsEnterprise;
|
|
|
import com.sckw.system.model.KwsUser;
|
|
|
import com.sckw.system.model.SysDict;
|
|
|
import com.sckw.system.service.KwsUserService;
|
|
|
@@ -71,7 +73,7 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
|
|
|
*/
|
|
|
@Override
|
|
|
public SysDictResDto queryDictByTypeAndValue(String type, String value) {
|
|
|
- String key = Global.REDIS_SYS_DICT_PREFIX + type + "#" + value;
|
|
|
+ String key = Global.REDIS_SYS_DICT_PREFIX + type + Global.POUND + value;
|
|
|
String dictCache = RedissonUtils.getString(key);
|
|
|
//从redis查,查不到从数据库查,并写入redis
|
|
|
if (StringUtils.isBlank(dictCache)) {
|
|
|
@@ -87,6 +89,37 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
|
|
|
return JSONObject.parseObject(dictCache, SysDictResDto.class);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param type 字典类型
|
|
|
+ * @return SysDictResDto
|
|
|
+ * @desc: 根据字典类型和key查字典
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/7/7
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SysDictGroupResDto> queryDictGroupByType(String type) {
|
|
|
+ List<SysDict> sysDicts = sysDictDao.queryByType(type);
|
|
|
+ if (CollectionUtils.isEmpty(sysDicts)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ //取最顶层去递归
|
|
|
+ List<SysDictGroupResDto> list = new ArrayList<>();
|
|
|
+ sysDicts = sysDicts.stream().filter(item -> item.getParentId().equals(String.valueOf(Global.NO))).toList();
|
|
|
+ if (CollectionUtils.isEmpty(sysDicts)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ sysDicts.forEach(item -> {
|
|
|
+ SysDictGroupResDto sysDictGroupResDto = queryDictGroupByTypeAndValue(type, item.getValue());
|
|
|
+ if (!Objects.isNull(sysDictGroupResDto)) {
|
|
|
+ list.add(sysDictGroupResDto);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param type 字典类型,value key
|
|
|
* @return SysDictGroupResDto
|
|
|
@@ -96,7 +129,7 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
|
|
|
*/
|
|
|
@Override
|
|
|
public SysDictGroupResDto queryDictGroupByTypeAndValue(String type, String value) {
|
|
|
- String key = Global.REDIS_SYS_DICT_GROUP_PREFIX + type + "#" + value;
|
|
|
+ String key = Global.REDIS_SYS_DICT_GROUP_PREFIX + type + Global.POUND + value;
|
|
|
String dictCache = RedissonUtils.getString(key);
|
|
|
//从redis查,查不到从数据库查,并写入redis
|
|
|
if (StringUtils.isBlank(dictCache)) {
|
|
|
@@ -148,6 +181,45 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
|
|
|
return JSONObject.parseObject(dictCache, EntCacheResDto.class);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param entName 企业名
|
|
|
+ * @return EntCacheResDto
|
|
|
+ * @desc: 从缓存查企业信息 模糊匹配
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/7/7
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<EntCacheResDto> queryEntCacheByName(String entName) {
|
|
|
+ List<KwsEnterprise> kwsEnterprises = remoteBaseService.queryEntByName(entName);
|
|
|
+ if (CollectionUtils.isEmpty(kwsEnterprises)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<EntCacheResDto> list = new ArrayList();
|
|
|
+ for (KwsEnterprise kwsEnterprise : kwsEnterprises) {
|
|
|
+ EntCacheResDto entCacheResDto = queryEntCacheById(kwsEnterprise.getId());
|
|
|
+ if (!Objects.isNull(entCacheResDto)) {
|
|
|
+ list.add(entCacheResDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<EntCacheResDto> queryEntCacheByIds(List<Long> entIds) {
|
|
|
+ if (CollectionUtils.isEmpty(entIds)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<EntCacheResDto> list = new ArrayList<>();
|
|
|
+ entIds.forEach(entId -> {
|
|
|
+ EntCacheResDto entCacheResDto = queryEntCacheById(entId);
|
|
|
+ if (Objects.nonNull(entCacheResDto)) {
|
|
|
+ list.add(entCacheResDto);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public UserCacheResDto queryUserCacheById(Long userId) {
|
|
|
String key = Global.REDIS_USER_PREFIX + userId;
|
|
|
@@ -164,12 +236,32 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
|
|
|
userCacheResDto.setRoleInfo(remoteBaseService.queryRoleInfoByUserId(userId));
|
|
|
|
|
|
List<KwsUserDeptResDto> kwsUserDeptResDtos = remoteBaseService.queryUserDeptByUserId(userId);
|
|
|
- if (!CollectionUtils.isEmpty(kwsUserDeptResDtos)) {
|
|
|
+ if (CollectionUtils.isEmpty(kwsUserDeptResDtos)) {
|
|
|
+ return userCacheResDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> deptIds = kwsUserDeptResDtos.stream().map(KwsUserDeptResDto::getDeptId).toList();
|
|
|
+ List<KwsDeptResDto> kwsDeptResDtos = remoteBaseService.queryDeptByIds(deptIds);
|
|
|
+ if (CollectionUtils.isEmpty(kwsDeptResDtos)) {
|
|
|
+ return userCacheResDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ Long entId = kwsDeptResDtos.get(0).getEntId();
|
|
|
+ KwsEnterpriseResDto kwsEnterpriseResDto = remoteBaseService.queryEnterpriseById(entId);
|
|
|
+ if (Objects.isNull(kwsEnterpriseResDto)) {
|
|
|
+ return userCacheResDto;
|
|
|
}
|
|
|
|
|
|
+ EntCacheResDto entCacheResDto = new EntCacheResDto();
|
|
|
+ BeanUtils.copyProperties(kwsEnterpriseResDto, entCacheResDto);
|
|
|
+ entCacheResDto.setDeptInfo(BeanUtils.copyToList(kwsDeptResDtos, DeptInfoPojo.class));
|
|
|
+ entCacheResDto.setCertificateInfo(remoteBaseService.queryCertificateByEntId(entId));
|
|
|
+ userCacheResDto.setEntInfo(entCacheResDto);
|
|
|
+ RedissonUtils.putString(key, JSON.toJSONString(userCacheResDto), Global.COMMON_EXPIRE);
|
|
|
+ return userCacheResDto;
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ return JSONObject.parseObject(dictCache, UserCacheResDto.class);
|
|
|
}
|
|
|
|
|
|
/**
|