TpEEmployeeChargeSMapper.xml 16.3 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.park.mapper.smapper.TpEEmployeeChargeSMapper">
    <resultMap id="BaseResultGroupMap" type="com.zteits.clouds.api.dto.park.dto.TpEEmployeeChargeDTO">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
        <result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
        <result column="charger_nickname" jdbcType="VARCHAR" property="chargerNickname" />
        <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
        <result column="pl_name" jdbcType="VARCHAR" property="plName" />
        <result column="charger_pwd" jdbcType="VARCHAR" property="chargerPwd" />
        <result column="token" jdbcType="VARCHAR" property="token" />
        <result column="charger_type" jdbcType="CHAR" property="chargerType" />
        <result column="charger_sex" jdbcType="CHAR" property="chargerSex" />
        <result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
        <result column="addr" jdbcType="VARCHAR" property="addr" />
        <result column="card_id" jdbcType="VARCHAR" property="cardId" />
        <result column="status" jdbcType="CHAR" property="status" />
        <result column="sign_modify_time" jdbcType="TIMESTAMP" property="signModifyTime" />
        <result column="entry_time" jdbcType="DATE" property="entryTime" />
        <result column="entry_status" jdbcType="INTEGER" property="entryStatus" />
        <result column="account_status" jdbcType="INTEGER" property="accountStatus" />
        <result column="auth_status" jdbcType="INTEGER" property="authStatus" />
        <result column="data_status" jdbcType="INTEGER" property="dataStatus" />
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
        <result column="create_op" jdbcType="BIGINT" property="createOp" />
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
        <result column="modify_op" jdbcType="BIGINT" property="modifyOp" />
        <result column="org_id" jdbcType="BIGINT" property="orgId" />
    </resultMap>
	<resultMap id="BaseResultMap" type="com.zteits.park.domain.TpEEmployeeCharge">
	    <id column="id" jdbcType="BIGINT" property="id" />
	    <result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
	    <result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
	    <result column="charger_nickname" jdbcType="VARCHAR" property="chargerNickname" />
	    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
	    <result column="pl_name" jdbcType="VARCHAR" property="plName" />
	    <result column="charger_pwd" jdbcType="VARCHAR" property="chargerPwd" />
	    <result column="token" jdbcType="VARCHAR" property="token" />
	    <result column="charger_type" jdbcType="CHAR" property="chargerType" />
	    <result column="charger_sex" jdbcType="CHAR" property="chargerSex" />
	    <result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
	    <result column="addr" jdbcType="VARCHAR" property="addr" />
	    <result column="card_id" jdbcType="VARCHAR" property="cardId" />
	    <result column="status" jdbcType="CHAR" property="status" />
	    <result column="sign_modify_time" jdbcType="TIMESTAMP" property="signModifyTime" />
	    <result column="entry_time" jdbcType="DATE" property="entryTime" />
	    <result column="entry_status" jdbcType="INTEGER" property="entryStatus" />
	    <result column="account_status" jdbcType="INTEGER" property="accountStatus" />
	    <result column="auth_status" jdbcType="INTEGER" property="authStatus" />
	    <result column="data_status" jdbcType="INTEGER" property="dataStatus" />
	    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
	    <result column="create_op" jdbcType="BIGINT" property="createOp" />
	    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
	    <result column="modify_op" jdbcType="BIGINT" property="modifyOp" />
	    <result column="org_id" jdbcType="BIGINT" property="orgId" />
	  </resultMap>
    <!-- 根据收费员编号修改收费员信息 -->
    <update id="updateByChargerCode" parameterType="com.zteits.park.domain.TpEEmployeeCharge">
        update tp_e_employee_charge
        <set>
            <if test="chargerCode != null">
                charger_code = #{chargerCode,jdbcType=VARCHAR},
            </if>
            <if test="chargerName != null">
                charger_name = #{chargerName,jdbcType=VARCHAR},
            </if>
            <if test="chargerNickname != null">
                charger_nickname = #{chargerNickname,jdbcType=VARCHAR},
            </if>
            <if test="plNo != null">
                pl_no = #{plNo,jdbcType=VARCHAR},
            </if>
            <if test="plName != null">
                pl_name = #{plName,jdbcType=VARCHAR},
            </if>
            <if test="chargerPwd != null">
                charger_pwd = #{chargerPwd,jdbcType=VARCHAR},
            </if>
            <if test="token != null">
                token = #{token,jdbcType=VARCHAR},
            </if>
            <if test="eqpSn != null">
                eqp_sn = #{eqpSn,jdbcType=VARCHAR},
            </if>
            <if test="eqpUserName != null">
                eqp_user_name = #{eqpUserName,jdbcType=VARCHAR},
            </if>
            <if test="eqpName != null">
                eqp_name = #{eqpName,jdbcType=VARCHAR},
            </if>
            <if test="eqpCode != null">
                eqp_code = #{eqpCode,jdbcType=VARCHAR},
            </if>
            <if test="eqpToken != null">
                eqp_token = #{eqpToken,jdbcType=VARCHAR},
            </if>
            <if test="eqpUserPassword != null">
                eqp_user_password = #{eqpUserPassword,jdbcType=VARCHAR},
            </if>
            <if test="chargerType != null">
                charger_type = #{chargerType,jdbcType=CHAR},
            </if>
            <if test="chargerSex != null">
                charger_sex = #{chargerSex,jdbcType=CHAR},
            </if>
            <if test="phoneNo != null">
                phone_no = #{phoneNo,jdbcType=VARCHAR},
            </if>
            <if test="addr != null">
                addr = #{addr,jdbcType=VARCHAR},
            </if>
            <if test="cardId != null">
                card_id = #{cardId,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=CHAR},
            </if>
            <if test="signModifyTime != null">
                sign_modify_time = #{signModifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="entryTime != null">
                entry_time = #{entryTime,jdbcType=DATE},
            </if>
            <if test="entryStatus != null">
                entry_status = #{entryStatus,jdbcType=INTEGER},
            </if>
            <if test="accountStatus != null">
                account_status = #{accountStatus,jdbcType=INTEGER},
            </if>
            <if test="authStatus != null">
                auth_status = #{authStatus,jdbcType=INTEGER},
            </if>
            <if test="dataStatus != null">
                data_status = #{dataStatus,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createOp != null">
                create_op = #{createOp,jdbcType=BIGINT},
            </if>
            <if test="modifyTime != null">
                modify_time = #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyOp != null">
                modify_op = #{modifyOp,jdbcType=BIGINT},
            </if>
            <if test="orgId != null">
                org_id = #{orgId,jdbcType=BIGINT},
            </if>
        </set>
        where charger_code = #{chargerCode,jdbcType=VARCHAR}
    </update>

    <!-- 查询收费员信息 zhaowg 20171107 -->
    <select id="queryEmployeesForPage" resultMap="BaseResultGroupMap">
        SELECT
        e.id,
        e.charger_code,
        e.charger_name,
        e.pl_no,
        e.pl_name,
        e.charger_type,
        e.charger_sex,
        e.phone_no,
        e.addr,
        e.card_id,
        e.status,
        e.sign_modify_time,
        e.entry_status,
        e.entry_time,
        e.account_status,
        e.auth_status,
        e.org_id
        FROM
        tp_e_employee_charge e
        WHERE
        e.data_status = 1
        <if test="chargerType != null">
            and e.charger_type = #{chargerType}
        </if>

        <if test="chargerTypes != null and chargerTypes.size>0">
            and e.charger_type in
            <foreach collection="chargerTypes" index="index" item="chargerType" open="(" separator="," close=")">
                #{chargerType}
            </foreach>
        </if>
        <if test="status != null">
            and e.status = #{status}
        </if>
        <if test="orgId != null">
            and e.org_id =#{orgId}
        </if>
        <if test="chargerCodes != null and chargerCodes.size>0">
            and charger_code in
            <foreach collection="chargerCodes" index="index" item="chargerCode" open="(" separator="," close=")">
                #{chargerCode}
            </foreach>
        </if>

        <if test="nameOrNo != null and nameOrNo !=''">
            and (charger_name like concat('%',#{nameOrNo,jdbcType=VARCHAR},'%')
            or charger_code like concat('%',#{nameOrNo,jdbcType=VARCHAR},'%'))
        </if>
        <if test="plNo != null and plNo != ''">
            AND exists (select 1 from duty_roster r where r.charger_code = e.charger_code
            and r.pl_no = #{plNo,jdbcType=VARCHAR}
            <if test="parkAreaCode != null and parkAreaCode != ''">
                and r.berth_range_no = #{parkAreaCode,jdbcType=VARCHAR}
            </if>
            and data_status = 1 and duty_day = date(now())
            )
        </if>
        order by e.entry_status desc,e.entry_time desc,e.id
    </select>

    <!-- 根据停车场编号统计收费员人数 -->
    <select id="queryEmployeeNumByPlNo" resultType="java.lang.Integer">
        SELECT
        COUNT(e.id)
        FROM
        tp_e_employee_charge e
        WHERE
        e.data_status = 1
        <if test="status != null">
            and e.status = #{status}
        </if>
        <if test="entryStatus != null">
            and e.entry_status = #{entryStatus}
        </if>
        <if test="orgId != null">
            and e.org_id = #{orgId}
        </if>
        <if test="chargerCodes != null and chargerCodes.size >0">
            AND e.charger_code in
            <foreach collection="chargerCodes" index="index" item="chargerCode" open="(" separator="," close=")">
                #{chargerCode}
            </foreach>
        </if>
        <if test="plNos != null and plNos.size >0">
            and e.pl_no in
            <foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">#{plNo}</foreach>
        </if>
        <if test="chargerType != null">
            and e.charger_type = #{chargerType}
        </if>
    </select>


    <!-- 根据停车场编号统计收费员人数 -->
    <select id="queryParkSourceEmployeeSta"
            resultType="com.zteits.clouds.api.dto.park.dto.parksource.ParkSouceEmployeeStaDTO"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceRequest">
        SELECT
        e.pl_no as plNo,
        ifnull(COUNT(e.id),0) as allTollCollector,
        ifnull(count(case when e.status = 0 then e.id end),0) as signInTollCollector,
        ifnull(count(case when e.status != 0 then e.id end),0) as unSignInTollCollector
        FROM
        tp_e_employee_charge e

        WHERE
        e.data_status = 1 and e.entry_status = 1
        <if test="plNos != null and plNos.size >0">
            and e.pl_no in
            <foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">
                #{plNo}
            </foreach>
        </if>
        group by e.pl_no
    </select>
    <!-- 通过停车场外部编码查询停车场总车位数 -->
    <!-- 20211221 因为没有接口调用报错,注释
    <select id="getOrgIdsByCityIds" parameterType="com.zteits.clouds.api.dto.park.param.parklot.QueryOrgIdsByCityIdsRequest" resultType="java.lang.Long">
        select org_id from parking_lot
        where data_status = 1
        and pl_city_id in
        <foreach collection="cityIds" separator="," open="(" close=")" item="cityId" index="index">
            #{cityId}
        </foreach>
        group by org_id
    </select>-->
    <!-- 根据组织编号List统计收费员人数 -->
    <select id="queryEmployeeStaByOrgIds"
            resultType="com.zteits.clouds.api.dto.park.dto.parksource.ParkSouceEmployeeStaDTO"
            parameterType="com.zteits.clouds.api.dto.park.param.parksource.QueryParkSourceByOrgIdsRequest">
        SELECT
        ifnull(COUNT(e.id),0) as allTollCollector,
        ifnull(COUNT(case when e.status = 0 then e.id end),0) as signInTollCollector,
        ifnull(COUNT(case when e.status != 0 then e.id end),0) as unSignInTollCollector
        FROM
        tp_e_employee_charge e
        WHERE
        e.data_status = 1 and e.entry_status = 1 and charger_type = 0
        and e.org_id in
        <foreach collection="orgIds" separator="," open="(" close=")" item="orgId" index="index">
            #{orgId}
        </foreach>
    </select>


    <!-- 查询未排班的收费员信息  -->
    <select id="queryNotDutyChargerList" resultType="com.zteits.park.domain.TpEEmployeeCharge">
        SELECT
        e.id id,
        e.charger_code chargerCode,
        e.charger_name chargerName,
        e.pl_no plNo,
        e.pl_name plName,
        e.charger_sex chargerSex,
        e.phone_no phoneNo,
        e.addr addr,
        e.status status,
        e.sign_modify_time signModifyTime,
        e.entry_status entryStatus,
        e.entry_time entryTime
        FROM
		    tp_e_employee_charge e
		LEFT JOIN duty_roster_base b ON e.charger_code = b.charger_code
		WHERE
		    b.charger_code IS NULL
		    AND e.data_status = 1
            and e.charger_type = #{chargerType}
        <if test="plNos != null and plNos.size()>0">
            and e.pl_no in
            <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
                #{plNo}
            </foreach>
        </if>
        <if test="orgId != null">
            and e.org_id =#{orgId}
        </if>
    </select>

    <!-- 查询未排班和当前计划内的收费员/巡查员信息  -->
    <select id="queryNotDutyAndThisPlanChargerList" resultType="com.zteits.park.domain.TpEEmployeeCharge">
        SELECT
        e.id id,
        e.charger_code chargerCode,
        e.charger_name chargerName,
        e.pl_no plNo,
        e.pl_name plName,
        e.charger_sex chargerSex,
        e.phone_no phoneNo,
        e.addr addr,
        e.status status,
        e.sign_modify_time signModifyTime,
        e.entry_status entryStatus,
        e.entry_time entryTime
        FROM
        tp_e_employee_charge e
        WHERE charger_code
        IN (
        SELECT DISTINCT charger_code
        FROM
        duty_roster_base
        WHERE plan_id = #{planId}
        <if test="orgId != null">
            and e.org_id =#{orgId}
        </if>
        )
        AND e.data_status = 1
        and e.charger_type = #{chargerType}
        <if test="orgId != null">
            and e.org_id =#{orgId}
        </if>
    </select>

    <!-- 查询当前组织下最大的收费员编号(后四位) -->
    <select id="queryTheMaxChargerCodeNum" resultType="java.lang.Integer">
       SELECT IFNULL(RIGHT(MAX(charger_code),4),0)+0
            FROM `tp_e_employee_charge`
       WHERE `charger_code` LIKE concat(#{areaCode,jdbcType=VARCHAR},'%')
    </select>
    
    <select id="queryOnlineEmployeeChargeList" resultMap="BaseResultMap" parameterType="com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest">
	    SELECT c.* FROM tp_p_pda p
		LEFT JOIN tp_e_employee_charge c ON p.charger_code = c.charger_code
		WHERE p.online_flg = '0' AND p.data_state = 1 AND p.org_id = #{orgId} AND p.pda_type = #{chargerType}
     	AND  c.data_status = 1 AND c.org_id = #{orgId} AND c.charger_type = #{chargerType} AND token != '' and c.status = 0
    </select>
</mapper>