diff --git a/src/main/java/com/ydool/boot/api/controller/ApiStatisticsOfficeController.java b/src/main/java/com/ydool/boot/api/controller/ApiStatisticsOfficeController.java index 0eb7c70..5157dbe 100644 --- a/src/main/java/com/ydool/boot/api/controller/ApiStatisticsOfficeController.java +++ b/src/main/java/com/ydool/boot/api/controller/ApiStatisticsOfficeController.java @@ -28,10 +28,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; @RestController @RequestMapping("/api/statistics/office") @@ -113,9 +111,27 @@ public class ApiStatisticsOfficeController extends ApiBaseController { String countryStr = config.getParamValue(); String countStr = config.getRemarks(); if (StrUtil.isNotBlank(countryStr) && StrUtil.isNotBlank(countStr)) { - String[] countryArr = countryStr.split(","); - String[] countArr = countStr.split(","); - Dict dict = Dict.create().set("countryArr", countryArr).set("countArr", countArr); + List list = new ArrayList<>(); + List regionList = Arrays.asList(config.getParamValue().split(",")); + List regionNumList = Arrays.asList(config.getRemarks().split(",")); + for (int i = 0; i < regionList.size(); i++) { + Map map = new HashMap<>(); + map.put("region", regionList.get(i)); + map.put("regionNum", regionNumList.get(i)); + list.add(map); + } + List sortedList = list.stream().sorted((t1, t2) -> { + int result = Convert.toInt(t2.get("regionNum")) - Convert.toInt(t1.get("regionNum")); + return result; + }).collect(Collectors.toList()); + + List sortedRegionList = new ArrayList<>(); + List sortedRegionNumList = new ArrayList<>(); + sortedList.forEach(item -> { + sortedRegionList.add(item.get("region")); + sortedRegionNumList.add(item.get("regionNum")); + }); + Dict dict = Dict.create().set("countryArr", sortedRegionList).set("countArr", sortedRegionNumList); render(Ret.ok().data(dict)); } } diff --git a/src/main/java/com/ydool/boot/modules/rddb/web/ShowController.java b/src/main/java/com/ydool/boot/modules/rddb/web/ShowController.java index 1cc7b97..af0e9c7 100644 --- a/src/main/java/com/ydool/boot/modules/rddb/web/ShowController.java +++ b/src/main/java/com/ydool/boot/modules/rddb/web/ShowController.java @@ -1,6 +1,7 @@ package com.ydool.boot.modules.rddb.web; +import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ydool.boot.common.cache.SysCacheName; import com.ydool.boot.common.result.Ret; @@ -20,6 +21,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import java.util.*; +import java.util.stream.Collectors; + /** *

* 文件审批 前端控制器 @@ -81,9 +85,30 @@ public class ShowController extends BaseAdminController { @GetMapping("office") public String office(Model model) { + List list = new ArrayList<>(); Config config = getConfigByCode("screen_office_country_rank"); - model.addAttribute("region", config.getParamValue().split(",")); - model.addAttribute("regionNum", config.getRemarks().split(",")); + List regionList = Arrays.asList(config.getParamValue().split(",")); + List regionNumList = Arrays.asList(config.getRemarks().split(",")); + for (int i = 0; i < regionList.size(); i++) { + Map map = new HashMap<>(); + map.put("region", regionList.get(i)); + map.put("regionNum", regionNumList.get(i)); + list.add(map); + } + List sortedList = list.stream().sorted((t1, t2) -> { + int result = Convert.toInt(t2.get("regionNum")) - Convert.toInt(t1.get("regionNum")); + return result; + }).collect(Collectors.toList()); + + List sortedRegionList = new ArrayList<>(); + List sortedRegionNumList = new ArrayList<>(); + sortedList.forEach(item->{ + sortedRegionList.add(item.get("region")); + sortedRegionNumList.add(item.get("regionNum")); + }); + + model.addAttribute("region", sortedRegionList); + model.addAttribute("regionNum", sortedRegionNumList); return "modules/rddb/show/office.html"; } @@ -108,7 +133,7 @@ public class ShowController extends BaseAdminController { boolean flag4 = configService.updateById(cycleRateConfig); boolean flag5 = configService.updateById(sameRateConfig); - CacheUtils.clear(SysCacheName.SYS_DICT_CACHE); + CacheUtils.clear(SysCacheName.SYS_CONFIG_CACHE); render((flag1 && flag2 && flag3 && flag4 && flag5) ? Ret.ok() : Ret.fail("操作失败")); } @@ -142,7 +167,7 @@ public class ShowController extends BaseAdminController { boolean flag7 = configService.updateById(handleAnalyzeConfig); boolean flag8 = configService.updateById(handleAnalyzeStatusConfig); - CacheUtils.clear(SysCacheName.SYS_DICT_CACHE); + CacheUtils.clear(SysCacheName.SYS_CONFIG_CACHE); render((flag1 && flag2 && flag3 && flag4 && flag5 && flag6 && flag7 && flag8) ? Ret.ok() : Ret.fail("操作失败")); } @@ -155,7 +180,7 @@ public class ShowController extends BaseAdminController { config.setRemarks(showOfficeBo.getRegionNum()); boolean flag = configService.updateById(config); - CacheUtils.clear(SysCacheName.SYS_DICT_CACHE); + CacheUtils.clear(SysCacheName.SYS_CONFIG_CACHE); render(flag ? Ret.ok() : Ret.fail("操作失败")); }