7 changed files with 102 additions and 13 deletions
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.system.dal.mysql.bigviewdata; |
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO; |
||||
import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface BigViewDataMapper { |
||||
|
||||
List<NameCountVO> enterpriseCountGroup(HomeSelectVO homeSelectVO); |
||||
|
||||
} |
@ -1,15 +1,43 @@
|
||||
package cn.iocoder.yudao.module.system.service.bigviewdata; |
||||
|
||||
import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewEnterpriseCountGroup; |
||||
import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO; |
||||
import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; |
||||
import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; |
||||
import cn.iocoder.yudao.module.system.dal.mysql.bigviewdata.BigViewDataMapper; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class BigViewDataServiceImpl implements BigViewDataService { |
||||
|
||||
@Resource |
||||
private BigViewDataMapper bigViewDataMapper; |
||||
|
||||
@Override |
||||
public BigViewEnterpriseCountGroup getLeftSecond(HomeSelectVO homeSelectVO) { |
||||
BigViewEnterpriseCountGroup enterpriseCountGroup = new BigViewEnterpriseCountGroup(); |
||||
final List<NameCountVO> nameCountVOS = bigViewDataMapper.enterpriseCountGroup(homeSelectVO); |
||||
enterpriseCountGroup.setEnterpriseCountGroup(nameCountVOS); |
||||
List<Integer> countList = new ArrayList<>(); |
||||
if (nameCountVOS != null) { |
||||
nameCountVOS.forEach(item->{ |
||||
countList.add(item.getCount()); |
||||
}); |
||||
} |
||||
final Integer count = countList.stream().reduce(Integer::sum).orElse(0); |
||||
enterpriseCountGroup.setEnterpriseCount(count); |
||||
|
||||
return enterpriseCountGroup; |
||||
} |
||||
|
||||
@Override |
||||
public List<BigViewEnterpriseCountGroup> getLeftSecond(HomeSelectVO homeSelectVO) { |
||||
public List<String> getLeftThird(HomeSelectVO homeSelectVO) { |
||||
return null; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.bigviewdata.BigViewDataMapper"> |
||||
|
||||
<!-- |
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 |
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 |
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ |
||||
--> |
||||
|
||||
|
||||
<select id="enterpriseCountGroup" |
||||
resultType="cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO"> |
||||
select |
||||
sd.name as name, |
||||
count(e.id) as count |
||||
from |
||||
enterprises e |
||||
left join system_dept sd on e.department_id = sd.id |
||||
group by |
||||
e.department_id |
||||
</select> |
||||
</mapper> |
Loading…
Reference in new issue