Browse Source

手机2260label

吕宣芝 1 year ago
parent
commit
35adfba8e7

+ 12 - 26
src/main/java/com/sooka/sponest/mobile/comprehensive/personBasicInfoController/AppPersonBasicInfoController.java

@@ -2,18 +2,15 @@ package com.sooka.sponest.mobile.comprehensive.personBasicInfoController;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.ruoyi.common.core.constant.HttpStatus;
-import com.ruoyi.common.core.utils.SpringUtils;
+import com.ruoyi.common.core.domain.DictKeys;
 import com.ruoyi.common.core.web.domain.AjaxResult;
 import com.ruoyi.common.core.web.page.PageDomain;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.common.core.web.page.TableSupport;
-import com.ruoyi.common.redis.service.RedisService;
 import com.ruoyi.common.security.utils.DictUtils;
 import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.domain.OtherPersonInfo;
 import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.domain.PersonBasicInfo;
 import com.sooka.sponest.comprehensive.api.comprehensivePersonBasicInfo.service.RemotePersonBasicInfoService;
-import com.ruoyi.common.core.domain.DictKeys;
 import com.sooka.sponest.data.api.digitalenvironment.domain.EnvironmentBiggas;
 import org.springframework.web.bind.annotation.*;
 
@@ -307,20 +304,12 @@ public class AppPersonBasicInfoController {
         Integer delFlag = personBasicInfo.getDelFlag();
         Integer personType = personBasicInfo.getPersonType();
         TableDataInfo list = personBasicInfoService.getOtherList(pageNum, pageSize, delFlag, personType);
-        RedisService redisService = SpringUtils.getBean(RedisService.class);
-        List<Map<String,Object>> cacheObject = redisService.getCacheObject("sys_dict:" + DictKeys.COMPREHENSIVE_CITY_CODE);//2260
+        Map<String, Object> comprehensiveDictCacheToMap = DictUtils.getComprehensiveDictCacheToMap(DictKeys.COMPREHENSIVE_CITY_CODE);// 2260
         if(!"".equals(list) && null != list){
             for (Object row : list.getRows()) {
                 HashMap r = (HashMap) row;
-                for (Map<String, Object> map : cacheObject) {
-                    if (map.containsKey("id") && (map.get("id")).toString().equals(r.get("householdRegistration"))) {
-                        Object value = map.get("label"); // 获取householdRegistration的id的值
-                        // 执行您需要的操作
-                        r.put("householdRegistrationLabel", value);//户籍地 2260
-                        r.put("nativePlaceLabel", value);//籍贯 2260
-                        break;
-                    }
-                }
+                r.put("householdRegistrationLabel", comprehensiveDictCacheToMap.get(r.get("householdRegistration")));//户籍地 2260
+                r.put("nativePlaceLabel", comprehensiveDictCacheToMap.get(r.get("nativePlace")));//籍贯 2260
             }
             return AjaxResult.success(list);
         }else{
@@ -332,17 +321,14 @@ public class AppPersonBasicInfoController {
     public AjaxResult getOtherEdit(OtherPersonInfo otherPersonInfo){
         AjaxResult otherEdit = personBasicInfoService.getOtherEdit(otherPersonInfo.getBasicId(), otherPersonInfo.getPersonType());
         if ("200".equals(otherEdit.get("code").toString())){
-            RedisService redisService = SpringUtils.getBean(RedisService.class);
-            List<Map<String,Object>> cacheObject = redisService.getCacheObject(DictKeys.COMPREHENSIVE_CITY_CODE_ALL);//2260
-            HashMap<String,HashMap<String,Object>> data = (HashMap<String,HashMap<String,Object>>) otherEdit.get("data");
-            for (Map<String, Object> map : cacheObject) {
-                if (map.containsKey("id") && (map.get("id")).toString().equals(data.get("basicInfo").get("householdRegistration"))) {
-                    Object value = map.get("label"); // 获取householdRegistration的id的值
-                    // 执行您需要的操作
-                    data.get("basicInfo").put("householdRegistrationLabel", value);//户籍地 2260
-                    data.get("basicInfo").put("nativePlaceLabel", value);//籍贯 2260
-                    break;
-                }
+            Map<String, Object> comprehensiveDictCacheToMap = DictUtils.getComprehensiveDictCacheToMap(DictKeys.COMPREHENSIVE_CITY_CODE);// 2260
+            Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) otherEdit.get("data");
+            if (!comprehensiveDictCacheToMap.isEmpty()) {
+                data.computeIfPresent("basicInfo", (key, basicInfo) -> {
+                    basicInfo.put("householdRegistrationLabel", comprehensiveDictCacheToMap.get(basicInfo.get("householdRegistration")));// 户籍地 2260
+                    basicInfo.put("nativePlaceLabel", comprehensiveDictCacheToMap.get(basicInfo.get("nativePlace")));// 籍贯 2260
+                    return basicInfo;
+                });
             }
         }
         return AjaxResult.success(otherEdit);