ProblemsMapper.xml 3.06 KB
<?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.zteits.urbanops.module.gloabl.dal.mapper.problems.ProblemsMapper">
    <resultMap id="BaseResultMap" type="com.zteits.urbanops.module.gloabl.dal.dataobject.problems.ProblemsDO">
        <result column="problem_no" jdbcType="VARCHAR" property="problemNo"/>
        <result column="problem_name" jdbcType="VARCHAR" property="problemName"/>
        <result column="problem_source_id" jdbcType="VARCHAR" property="problemSourceId"/>
        <result column="user_confrim_remark" jdbcType="VARCHAR" property="userConfrimRemark"/>
        <result column="user_confrim_time" jdbcType="TIMESTAMP" property="userConfrimTime"/>
        <result column="user_confrim_imgs" jdbcType="VARCHAR" property="userConfrimImgs" typeHandler="com.zteits.urbanops.module.gloabl.dal.StringArrayTypeHandler"/>
        <result column="user_confrim_lat" jdbcType="DECIMAL" property="userConfrimLat"/>
        <result column="user_confrim_lon" jdbcType="DECIMAL" property="userConfrimLon"/>
        <result column="user_confrim_addr" jdbcType="VARCHAR" property="userConfrimAddr"/>
        <result column="problem_status" jdbcType="VARCHAR" property="problemStatus"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <select id="selectProblemsByCondition"
            parameterType="com.zteits.urbanops.module.gloabl.dal.dataobject.problems.ProblemsDO"
            resultMap="BaseResultMap">
        select * from global_problems
        <where>
            <if test="problemNo != null  and problemNo != ''">
                and problem_no = #{problemNo}
            </if>
        </where>
    </select>
    <select id="countProblems"
            parameterType="com.zteits.urbanops.module.gloabl.controller.admin.problems.vo.ProblemsReqVO"
            resultType="java.util.Map">
        SELECT
        COUNT(1) AS totalCount,
        IFNULL(SUM(CASE WHEN problem_status = 1 THEN 1 ELSE 0 end), 0) AS pendingCount,
        IFNULL(SUM(CASE WHEN problem_status = 2 THEN 1 ELSE 0 end), 0) AS processingCount,
        IFNULL(SUM(CASE WHEN problem_status = 4 THEN 1 ELSE 0 end), 0) AS completedCount,
        IFNULL(SUM(CASE WHEN problem_status = 5 THEN 1 ELSE 0 end), 0) AS cancelledCount,
        IFNULL(SUM(CASE WHEN problem_status = 3 THEN 1 ELSE 0 end), 0) AS pendingReviewCount
        FROM global_problems
        <where>
            <if test="createBy != null and createBy != ''">
                and create_by = #{createBy}
            </if>
            <if test="startTime != null">
                AND create_time >= #{startTime}
            </if>
            <if test="endTime != null">
                AND create_time &lt;= #{endTime}
            </if>
        </where>
    </select>
</mapper>