mybatis xml中的 注意小事情:

123 阅读1分钟
		SELECT  d.depart_name AS groupName,
                p.problem_belong problemBelong,
                COUNT(p.id) questionCount,
                COUNT(CASE WHEN rectification_status =1 THEN p.id ELSE NULL END ) rectified,
                COUNT(CASE WHEN rectification_status =2 THEN p.id ELSE NULL END ) notRectify,
                COUNT(CASE WHEN rectification_status =3 THEN p.id ELSE NULL END ) rectifying,
                COUNT(CASE WHEN rectification_able =1 THEN p.id ELSE NULL END ) canRectify,
                COUNT(CASE WHEN rectification_able =2 THEN p.id ELSE NULL END ) cannotRectified
            FROM
                tbl_net_safety_problem p
            LEFT JOIN
                tbl_sys_depart d
              ON p.dept = d.id
            WHERE 1 = 1
                <if test="entity.problemBelong!=null and entity.problemBelong!=''">
                    AND p.problem_belong = #{entity.problemBelong}
                </if>
                  AND p.enter_time &lt;= #{entity.endTime}
                  AND p.enter_time >= #{entity.startTime}
                  AND (d.parent_id = '' OR d.parent_id IS NULL)
            GROUP BY p.dept

mybatis xml中的 注意小事情:

&lt;=   小于等于    
if 中 没有"",只有'' !!!   
并且 是 
entity.problemBelong!=null and entity.problemBelong!=''
d.parent_id = '' OR d.parent_id IS NULL