MQpxxMapper.xml 9.28 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.hotent.lpg.manage.dao.MQpxxDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.lpg.common.model.WQpxx">
        <id column="ID_" property="id" />
        <result column="REF_ID_" property="refId" />
        <result column="F_qpbh" property="fQpbh" />
        <result column="F_ftbm" property="fFtbm" />
        <result column="F_qpgg" property="fQpgg" />
        <result column="F_czgg" property="fCzgg" />
        <result column="F_czjz" property="fCzjz" />
        <result column="F_zt" property="fZt" />
        <result column="F_zzdw" property="fZzdw" />
        <result column="F_xcjysj" property="fXcjysj" />
        <result column="F_bfrq" property="fBfrq" />
        <result column="F_cjr" property="fCjr" />
        <result column="F_cjsj" property="fCjsj" />
        <result column="F_gxr" property="fGxr" />
        <result column="F_gxsj" property="fGxsj" />
        <result column="F_ssqyID" property="fSsqyid" />
        <result column="F_ssqymc" property="fSsqymc" />
        <result column="F_ssczID" property="fSsczid" />
        <result column="F_ssczmc" property="fSsczmc" />
        <result column="F_hyyhID" property="fHyyhid" />
        <result column="F_hyxm" property="fHyxm" />
        <result column="F_qpgslx" property="fQpgslx" />
        <result column="F_form_data_rev_" property="fFormDataRev" />
        <result column="F_qptm" property="fQptm" />
        <result column="F_zzrq" property="fZzrq" />
        <result column="zhlzsj" property="zhlzsj" />

        <result column="F_jd" property="fJd" />
        <result column="F_wd" property="fWd" />
    </resultMap>

    <resultMap id="qpxxVoMap" type="com.hotent.lpg.manage.vo.QpxxVo">
        <id column="ID_" property="id" />
        <result column="REF_ID_" property="refId" />
        <result column="F_qpbh" property="fQpbh" />
        <result column="F_ftbm" property="fFtbm" />
        <result column="F_qpgg" property="fQpgg" />
        <result column="F_czgg" property="fCzgg" />
        <result column="F_czjz" property="fCzjz" />
        <result column="F_zt" property="fZt" />
        <result column="F_zzdw" property="fZzdw" />
        <result column="F_xcjysj" property="fXcjysj" />
        <result column="F_bfrq" property="fBfrq" />
        <result column="F_cjr" property="fCjr" />
        <result column="F_cjsj" property="fCjsj" />
        <result column="F_gxr" property="fGxr" />
        <result column="F_gxsj" property="fGxsj" />
        <result column="F_ssqyID" property="fSsqyid" />
        <result column="F_ssqymc" property="fSsqymc" />
        <result column="F_ssczID" property="fSsczid" />
        <result column="F_ssczmc" property="fSsczmc" />
        <result column="F_hyyhID" property="fHyyhid" />
        <result column="F_hyxm" property="fHyxm" />
        <result column="F_qpgslx" property="fQpgslx" />
        <result column="F_form_data_rev_" property="fFormDataRev" />
        <result column="F_qptm" property="fQptm" />
        <result column="F_zzrq" property="fZzrq" />
        <result column="F_qpzl" property="fZzrq" />
        <result column="F_qpjz" property="fZzrq" />
        <result column="F_qprj" property="fZzrq" />
        <result column="F_ssyyl" property="fZzrq" />
        <result column="F_gcgzyl" property="fZzrq" />
        <result column="F_sjbh" property="fZzrq" />
        <result column="F_ccbh" property="fZzrq" />
        <result column="F_zybh" property="fZzrq" />
        <result column="F_jchbh" property="fZzrq" />
        <result column="F_sjrq" property="fZzrq" />
        <result column="F_bcjyrq" property="fZzrq" />
        <result column="F_sjsynx" property="fZzrq" />
        <result column="F_jzrq" property="fZzrq" />
        <result column="F_bz" property="fZzrq" />
        <result column="F_qptp" property="fZzrq" />
        <result column="fDsfurl" property="fDsfurl" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
           ID_,
           REF_ID_,
           F_qpbh,
           F_ftbm,
           F_qpgg,
           F_czgg,
           F_czjz,
           F_zt,
           F_zzdw,
           F_xcjysj,
           F_bfrq,
           F_cjr,
           F_cjsj,
           F_gxr,
           F_gxsj,
           F_ssqyID,
           F_ssqymc,
           F_ssczID,
           F_ssczmc,
           F_hyyhID,
           F_hyxm,
           F_qpgslx,
           F_form_data_rev_,
           F_qptm,
           F_zzrq,
          F_qpzl,
          F_qpjz,
          F_qprj,
          F_ssyyl,
          F_gcgzyl,
          F_sjbh,
          F_ccbh,
          F_zybh,
          F_jchbh,
          F_sjrq,
          F_bcjyrq,
          F_sjsynx,
          F_jzrq,
          F_bz,
          F_qptp,
          F_dsfurl
    </sql>

    <select id="selectPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_qpxx
        ${ew.customSqlSegment}
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_qpxx
        ${ew.customSqlSegment}
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_qpxx
        where
        ID_ = #{id}
    </select>

    <select id="qpMap" resultType="com.hotent.lpg.manage.vo.QpdtVo">
        select
            wq.id_ AS id,
            wq.f_qptm AS fQptm,
            wq.F_qpgslx AS fQpgslx,
            wq.F_ssqyID AS fSsqyID,
            wq.f_ssczid AS fSsczid,
            wq.F_ssqymc AS fSsqymc,
            wq.F_ssczmc AS fSsczmc,
            wq2.F_cyzlx AS fCyzlx,
            wq2.F_cyyhID AS fCyyhID,
            wq2.F_cyczID AS fCyczID,
            wq2.F_jd AS fJd,
            wq2.F_wd AS fWd,
            concat (F_dqsf,F_dqs,F_dqq,F_dqjd,F_dqxxdz) as fDz,
            wc.F_czmc as fXzczmc,
            wq2.F_qplzID as fQplzId
                from w_qpxx wq
                inner join w_qpssxx wq2 on wq.ID_  = wq2.F_qpID
                left join w_czxx wc on wc.ID_ = wq2.F_cyczID and wq2.F_cyzlx = '厂站'
            <where>
                <if test="qyId != null and qyId != ''">
                    and wq.F_ssqyID = #{qyId}
                </if>
                <if test="qzId != null and qzId != ''">
                    and wq.F_ssczID = #{qzId}
                </if>
            </where>
    </select>

    <select id="qzqpxxPage" resultMap='BaseResultMap'>
        select
        w_qpxx.*,
        w_qpssxx.F_gxsj as zhlzsj
        from w_qpxx w_qpxx
        left join w_qpssxx w_qpssxx on w_qpxx.id_ = w_qpssxx.F_qpID
        <where>
            w_qpxx.F_ssczID = #{qzId}
            <if test="lx == 'wrk'.toString()">
                and (w_qpssxx.F_cyzlx != '厂站' or (w_qpssxx.F_cyzlx = '厂站' and w_qpssxx.F_cyczID != #{qzId}))
            </if>
            <if test="lx == 'mp'.toString()">
                and w_qpssxx.F_ctzt = '满瓶'
            </if>
            <if test="lx == 'kp'.toString()">
                and w_qpssxx.F_ctzt = '空瓶'
            </if>
            <if test="lx == 'gqp'.toString()">
                and w_qpxx.F_zt = '已报废'
            </if>
        </where>
        order by w_qpssxx.F_gxsj desc
    </select>

    <select id="listScrapQp" resultMap="BaseResultMap">
        SELECT
        *
        FROM
        w_qpxx w_qpxx
        WHERE
        DATE_FORMAT( w_qpxx.F_bfrq, '%Y-%m-%d' ) &lt;= DATE_SUB( CURDATE(), INTERVAL 1 DAY )
        AND w_qpxx.F_zt != '报废'
    </select>

    <update id="overdueInspection">
        UPDATE w_qpxx
        SET f_zt = '超期未检'
        WHERE
        f_zt = '正常'
        AND DATE_FORMAT( w_qpxx.F_xcjysj, '%Y-%m-%d' ) &lt;= DATE_SUB( CURDATE(), INTERVAL 1 DAY )
    </update>

    <select id="bottleNumber" resultType="java.lang.Integer">
        select count(*) from w_qpxx where F_ssczID = #{czId}
        <if test="type != null and type != ''">
            <if test="type == '1'.toString()">
                and year(F_sjrq) = year(SYSDATE())
            </if>
        </if>
    </select>

    <select id="bottleTrackByCzId" resultType="java.util.HashMap">
        SELECT
            CONCAT( '【气瓶#', w_qpxx.F_qptm, '】' ) AS field1,
        CASE
                WHEN w_qpssxx.F_cyzlx = '厂站' THEN
                CONCAT( '当前位于', w_czxx.f_czmc, '扫码' )
                WHEN w_qpssxx.F_cyzlx = '员工' THEN
                CONCAT( '当前位于', w_czxx.f_czmc, '扫码' )
                WHEN w_qpssxx.F_cyzlx = '会员' THEN
                CONCAT( '当前位于用户', w_hyxx.F_xm, '扫码' )
            END AS field2,
            DATE_FORMAT(w_qpssxx.F_gxsj,'%Y年%m月%d日%H:%m:%s') AS field3
        FROM
            w_qpxx
            INNER JOIN w_qpssxx ON w_qpxx.id_ = w_qpssxx.F_qpID
            LEFT JOIN w_czxx ON w_qpssxx.F_cyczID = w_czxx.ID_
            LEFT JOIN w_hyxx ON w_hyxx.F_userID = w_qpssxx.F_cyyhID
            where w_qpxx.F_ssczID = #{czId}
    </select>

    <select id="listByCzId" resultMap="BaseResultMap">
        select
        w_qpxx.*,
        w_qpssxx.F_jd,
        w_qpssxx.F_wd
        from w_qpxx
        inner join w_qpssxx ON w_qpxx.id_ = w_qpssxx.F_qpID
        where w_qpxx.F_ssczID = #{czId}
    </select>
</mapper>