diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/MetaImpUserModelInfoController.java b/gather-app/src/main/java/com/ruoyi/database/controller/MetaImpUserModelInfoController.java index 0543526..014e4e7 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/MetaImpUserModelInfoController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/MetaImpUserModelInfoController.java @@ -273,15 +273,10 @@ public class MetaImpUserModelInfoController extends BaseController { map.put("铁路订票",tlCount); map.put("旅馆住宿",lgCount); - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.select("imp_user_sub_type", "COUNT(*) as count") - .groupBy("imp_user_sub_type"); - Map map1 = metaImpUserModelInfoService.getMap(queryWrapper); - - + Map maps = metaImpUserModelInfoService.groupAndCountByField(); HashMap> hashMap = new HashMap<>(); hashMap.put("预警类别",map); - hashMap.put("重点人类别",map1); + hashMap.put("重点人类别",maps); return AjaxResult.success(hashMap); } diff --git a/gather-app/src/main/java/com/ruoyi/database/service/MetaImpUserModelInfoService.java b/gather-app/src/main/java/com/ruoyi/database/service/MetaImpUserModelInfoService.java index 4c17840..0cf06b1 100644 --- a/gather-app/src/main/java/com/ruoyi/database/service/MetaImpUserModelInfoService.java +++ b/gather-app/src/main/java/com/ruoyi/database/service/MetaImpUserModelInfoService.java @@ -3,6 +3,9 @@ package com.ruoyi.database.service; import com.ruoyi.database.domain.MetaImpUserModelInfo; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; +import java.util.Map; + /** * @author 28758 * @description 针对表【meta_imp_user_model_info(?ص???Ԥ??ģ????Ϣ?)】的数据库操作Service @@ -10,4 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface MetaImpUserModelInfoService extends IService { + + Map groupAndCountByField(); + } diff --git a/gather-app/src/main/java/com/ruoyi/database/service/impl/MetaImpUserModelInfoServiceImpl.java b/gather-app/src/main/java/com/ruoyi/database/service/impl/MetaImpUserModelInfoServiceImpl.java index 2e948f3..f5bb3f8 100644 --- a/gather-app/src/main/java/com/ruoyi/database/service/impl/MetaImpUserModelInfoServiceImpl.java +++ b/gather-app/src/main/java/com/ruoyi/database/service/impl/MetaImpUserModelInfoServiceImpl.java @@ -1,11 +1,18 @@ package com.ruoyi.database.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.database.domain.MetaImpUserModelInfo; import com.ruoyi.database.service.MetaImpUserModelInfoService; import com.ruoyi.database.mapper.MetaImpUserModelInfoMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * @author 28758 * @description 针对表【meta_imp_user_model_info(?ص???Ԥ??ģ????Ϣ?)】的数据库操作Service实现 @@ -15,6 +22,23 @@ import org.springframework.stereotype.Service; public class MetaImpUserModelInfoServiceImpl extends ServiceImpl implements MetaImpUserModelInfoService{ + + @Autowired + private MetaImpUserModelInfoMapper metaImpUserModelInfoMapper; + + public Map groupAndCountByField() { + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.groupBy("imp_user_sub_type"); + List metaImpUserModelInfos = metaImpUserModelInfoMapper.selectList(queryWrapper); + Map map = new HashMap<>(); + for (MetaImpUserModelInfo metaImpUserModelInfo:metaImpUserModelInfos){ + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("imp_user_sub_type",metaImpUserModelInfo.getImpUserSubType()); + Integer integer = metaImpUserModelInfoMapper.selectCount(wrapper); + map.put(metaImpUserModelInfo.getImpUserSubTypeCn(),integer); + } + return map; + } }