1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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="com.testor.module.partner.dao.TJobAccountingDao">
<!-- 开启二级缓存 -->
<!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.testor.module.partner.model.domain.TJobAccounting">
<id column="id" property="id"/>
<id column="ref_id" property="refId"/>
<id column="parent_id" property="parentId"/>
<id column="tenant_id" property="tenantId"/>
<id column="process_id" property="processId"/>
<id column="process_status" property="processStatus"/>
<id column="org_id" property="orgId"/>
<id column="acc_start_date" property="accStartDate"/>
<id column="partner_population" property="partnerPopulation"/>
<id column="acc_type" property="accType"/>
<id column="lease_name" property="leaseName"/>
<id column="lease" property="lease"/>
</resultMap>
<select id="dangerousTimes" resultType="com.testor.module.partner.model.vo.TJobAccountingStatisticsVO">
SELECT org_name as name,COUNT(acc_type) num
FROM t_job_accounting
GROUP BY org_name;
</select>
<select id="dangerousDistributed" resultType="com.testor.module.partner.model.vo.TJobAccountingStatisticsVO">
SELECT acc_type as name,COUNT(acc_type) num
FROM t_job_accounting
GROUP BY acc_type
</select>
<select id="partnerPeopleNum" resultType="com.testor.module.partner.model.vo.TJobAccountingStatisticsVO">
SELECT org_name as name,SUM(partner_population) num
FROM t_job_accounting
GROUP BY org_name
</select>
<select id="sum" resultType="com.testor.module.partner.model.vo.TJobAccountingSumVO">
SELECT
b.org_name as name,
c.count AS acc_type_count,
b.count AS partner_population_count
FROM
( SELECT org_name, SUM( partner_population ) count FROM t_job_accounting GROUP BY org_name ) AS b
LEFT JOIN ( SELECT org_name, COUNT( acc_type ) count FROM t_job_accounting GROUP BY org_name ) AS c ON b.org_name = c.org_name
</select>
</mapper>