TpPInspectRecordSMapper.xml 10.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.TpPInspectRecordSMapper">
  <resultMap id="BaseResultMap" type="com.zteits.park.domain.TpPInspectRecord">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="inspect_record_no" jdbcType="VARCHAR" property="inspectRecordNo" />
    <result column="inspect_type" jdbcType="INTEGER" property="inspectType" />
    <result column="inspect_eqp_no" jdbcType="VARCHAR" property="inspectEqpNo" />
    <result column="inspect_eqp_name" jdbcType="VARCHAR" property="inspectEqpName" />
    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
    <result column="pl_name" jdbcType="VARCHAR" property="plName" />
    <result column="park_area_code" jdbcType="VARCHAR" property="parkAreaCode" />
    <result column="park_area_name" jdbcType="VARCHAR" property="parkAreaName" />
    <result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
    <result column="eqp_no" jdbcType="VARCHAR" property="eqpNo" />
    <result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
    <result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
    <result column="inspect_code" jdbcType="VARCHAR" property="inspectCode" />
    <result column="inspect_name" jdbcType="VARCHAR" property="inspectName" />
    <result column="handler_code" jdbcType="VARCHAR" property="handlerCode" />
    <result column="handler_name" jdbcType="VARCHAR" property="handlerName" />
    <result column="trace_id" jdbcType="BIGINT" property="traceId" />
    <result column="accept_time" jdbcType="TIMESTAMP" property="acceptTime" />
    <result column="inspect_img_url1" jdbcType="VARCHAR" property="inspectImgUrl1" />
    <result column="inspect_img_url2" jdbcType="VARCHAR" property="inspectImgUrl2" />
    <result column="inspect_img_url3" jdbcType="VARCHAR" property="inspectImgUrl3" />
    <result column="inspect_time" jdbcType="TIMESTAMP" property="inspectTime" />
    <result column="inspect_level" jdbcType="INTEGER" property="inspectLevel" />
    <result column="inspect_address" jdbcType="VARCHAR" property="inspectAddress" />
    <result column="inspect_extra_remark" jdbcType="VARCHAR" property="inspectExtraRemark" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="deal_state" jdbcType="INTEGER" property="dealState" />
    <result column="data_state" jdbcType="INTEGER" property="dataState" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="create_op" jdbcType="VARCHAR" property="createOp" />
    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
    <result column="modify_op" jdbcType="VARCHAR" property="modifyOp" />
    <result column="org_id" jdbcType="BIGINT" property="orgId" />
  </resultMap>

  <sql id="Base_Column_List">
    id, inspect_record_no, inspect_type, inspect_eqp_no, inspect_eqp_name, pl_no, pl_name,
    park_area_code, park_area_name, berth_no, eqp_no, charger_code, charger_name, inspect_code,
    inspect_name, handler_code, handler_name, trace_id, accept_time, inspect_img_url1,
    inspect_img_url2, inspect_img_url3, inspect_time, inspect_level, inspect_address,
    inspect_extra_remark, remark, deal_state, data_state, create_time, create_op, modify_time,
    modify_op, org_id
  </sql>

  <select id="queryInspectRecordListStatic" parameterType="com.zteits.clouds.api.dto.park.param.TpPInspectRecordRequest"
          resultType="com.zteits.park.domain.TpPInspectRecord">
    select
    inspect_eqp_no inspectEqpNo,inspect_eqp_name inspectEqpName,deal_state dealState
    from tp_p_inspect_record
    where inspect_type = #{inspectType,jdbcType=INTEGER}
    and deal_state = 0
    and data_state = 1
    AND org_id = #{orgId}
    group by inspect_eqp_no,inspect_eqp_name
    order by inspect_eqp_no
  </select>


  <select id="queryTpPInspectRecord" parameterType="com.zteits.clouds.api.dto.park.param.TpPInspectRecordRequest"
          resultMap="BaseResultMap">

    select
    <include refid="Base_Column_List" />
    from tp_p_inspect_record
    where
    data_state = 1
    <if test="inspectType != null and inspectType != ''">
      AND inspect_type = #{inspectType}
    </if>

    <if test="inspectEqpNo != null and inspectEqpNo != ''">
      AND inspect_eqp_no = #{inspectEqpNo}
    </if>

    <!--<if test="handlerCode != null and handlerCode != ''">-->
      <!--AND handler_code = #{handlerCode}-->
    <!--</if>-->
    AND org_id = #{orgId}
    <if test="plNo != null and plNo != ''">
      AND pl_no = #{plNo}
    </if>
    <if test="dealStates !=null and dealStates.size > 0 ">
      and deal_state in
      <foreach collection="dealStates" item="state" separator="," open="(" close=")">
        ${state}
      </foreach>
    </if>
    <if test="dealState != null">
      and deal_state = #{dealState}
    </if>

    <if test="beginTime != null">
      and accept_time >= #{beginTime}
    </if>

    <if test="handleDuration != null">
      and DATE_ADD(accept_time,INTERVAL #{handleDuration}  SECOND) &lt;= now()
    </if>

    <if test="endTime != null">
      and accept_time &lt;= #{endTime}
    </if>

    <if test="handlerCode != null and handlerCode != ''">
     and inspect_record_no in (
      SELECT
        DISTINCT rlt_inspect_record_no
      FROM tp_p_inspect_record_trace
      WHERE data_state = 1
        AND accept_op = #{handlerCode}

      )
    </if>

    <if test="beginTime != null">
      and accept_time >= #{beginTime}
    </if>

    <if test="endTime != null">
      and accept_time &lt;= #{endTime}
    </if>

    <if test="handlerCode != null and handlerCode != ''">
     and inspect_record_no in (
      SELECT
        DISTINCT rlt_inspect_record_no
      FROM tp_p_inspect_record_trace
      WHERE data_state = 1
        AND accept_op = #{handlerCode}

      )
    </if>

  </select>


  <select id="getInspectRecordMsg" parameterType="com.zteits.clouds.api.dto.park.param.TpPInspectRecordRequest"
          resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from tp_p_inspect_record
    where  inspect_record_no = #{inspectRecordNo,jdbcType=VARCHAR}
    and data_state = 1
  </select>
  <select id="queryTpPInspectRecordCount" resultType="java.util.Map">

    select
      deal_state dealState,count(*) num
    from tp_p_inspect_record
    where
    data_state = 1
    <if test="inspectType != null and inspectType != ''">
      AND inspect_type = #{inspectType}
    </if>

    <if test="inspectEqpNo != null and inspectEqpNo != ''">
      AND inspect_eqp_no = #{inspectEqpNo}
    </if>

    <!--<if test="handlerCode != null and handlerCode != ''">-->
      <!--AND handler_code = #{handlerCode}-->
    <!--</if>-->
    AND org_id = #{orgId}
    <if test="plNo != null and plNo != ''">
      AND pl_no = #{plNo}
    </if>
    <if test="dealStates !=null and dealStates.size > 0 ">
      and deal_state in
      <foreach collection="dealStates" item="state" separator="," open="(" close=")">
        ${state}
      </foreach>
    </if>
    <if test="dealState != null">
      and deal_state = #{dealState}
    </if>
    <if test="handlerCode != null and handlerCode != ''">
    and inspect_record_no in (
    SELECT
    DISTINCT rlt_inspect_record_no
    FROM tp_p_inspect_record_trace
    WHERE data_state = 1
    AND accept_op = #{handlerCode}

    )
    </if>
    GROUP BY deal_state

  </select>

  <!--  修改 -->
  <update id="updateByInspectRecordNo" parameterType="com.zteits.park.domain.TpPInspectRecord">
    update tp_p_inspect_record
    <set>
      <if test="inspectType != null">
        inspect_type = #{inspectType,jdbcType=INTEGER},
      </if>
      <if test="inspectEqpNo != null">
        inspect_eqp_no = #{inspectEqpNo,jdbcType=VARCHAR},
      </if>
      <if test="inspectEqpName != null">
        inspect_eqp_name = #{inspectEqpName,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="parkAreaCode != null">
        park_area_code = #{parkAreaCode,jdbcType=VARCHAR},
      </if>
      <if test="parkAreaName != null">
        park_area_name = #{parkAreaName,jdbcType=VARCHAR},
      </if>
      <if test="berthNo != null">
        berth_no = #{berthNo,jdbcType=VARCHAR},
      </if>
      <if test="eqpNo != null">
        eqp_no = #{eqpNo,jdbcType=VARCHAR},
      </if>
      <if test="chargerCode != null">
        charger_code = #{chargerCode,jdbcType=VARCHAR},
      </if>
      <if test="chargerName != null">
        charger_name = #{chargerName,jdbcType=VARCHAR},
      </if>
      <if test="inspectCode != null">
        inspect_code = #{inspectCode,jdbcType=VARCHAR},
      </if>
      <if test="inspectName != null">
        inspect_name = #{inspectName,jdbcType=VARCHAR},
      </if>
      <if test="inspectImgUrl1 != null">
        inspect_img_url1 = #{inspectImgUrl1,jdbcType=VARCHAR},
      </if>
      <if test="inspectImgUrl2 != null">
        inspect_img_url2 = #{inspectImgUrl2,jdbcType=VARCHAR},
      </if>
      <if test="inspectImgUrl3 != null">
        inspect_img_url3 = #{inspectImgUrl3,jdbcType=VARCHAR},
      </if>
      <if test="inspectTime != null">
        inspect_time = #{inspectTime,jdbcType=TIMESTAMP},
      </if>
      <if test="inspectAddress != null">
        inspect_address = #{inspectAddress,jdbcType=VARCHAR},
      </if>
      <if test="inspectExtraRemark != null">
        inspect_extra_remark = #{inspectExtraRemark,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="dealState != null">
        deal_state = #{dealState,jdbcType=INTEGER},
      </if>
      <if test="dataState != null">
        data_state = #{dataState,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createOp != null">
        create_op = #{createOp,jdbcType=VARCHAR},
      </if>
      <if test="modifyTime != null">
        modify_time = #{modifyTime,jdbcType=TIMESTAMP},
      </if>
      <if test="modifyOp != null">
        modify_op = #{modifyOp,jdbcType=VARCHAR},
      </if>
    </set>
    where inspect_record_no = #{inspectRecordNo,jdbcType=VARCHAR}
  </update>

</mapper>