ParkingLotEquipmentSMapper.xml 13.2 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.ParkingLotEquipmentSMapper">
  <resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkingLotEquipment">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
    <result column="node_type" jdbcType="VARCHAR" property="nodeType" />
    <result column="area_id" jdbcType="BIGINT" property="areaId" />
    <result column="channel_id" jdbcType="BIGINT" property="channelId" />
    <result column="parent_equipment_id" jdbcType="BIGINT" property="parentEquipmentId" />
    <result column="equipment_name" jdbcType="VARCHAR" property="equipmentName" />
    <result column="equipment_description" jdbcType="VARCHAR" property="equipmentDescription" />
    <result column="equipment_type" jdbcType="INTEGER" property="equipmentType" />
    <result column="equipment_use" jdbcType="INTEGER" property="equipmentUse" />
    <result column="equipment_driver" jdbcType="VARCHAR" property="equipmentDriver" />
    <result column="equipment_manufacturer" jdbcType="VARCHAR" property="equipmentManufacturer" />
    <result column="equipment_model" jdbcType="VARCHAR" property="equipmentModel" />
    <result column="equipment_serial_number" jdbcType="VARCHAR" property="equipmentSerialNumber" />
    <result column="equipment_level" jdbcType="INTEGER" property="equipmentLevel" />
    <result column="equipment_status" jdbcType="INTEGER" property="equipmentStatus" />
    <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
    <result column="area_name" jdbcType="VARCHAR" property="areaName" />
    <result column="screen_line_number" jdbcType="INTEGER" property="screenLineNumber" />
      <collection property="detailList"
                  select="com.zteits.park.mapper.ParkingLotEquipmentMapper.getEquipmentCongif"
                  column="id">
      </collection>
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, pl_no, node_type, area_id, channel_id, parent_equipment_id, equipment_name, equipment_description, 
    equipment_type, equipment_use, equipment_driver, equipment_manufacturer, equipment_model, 
    equipment_serial_number, equipment_level, equipment_status
  </sql>


    <select id="selectByEquipment" parameterType="com.zteits.clouds.api.dto.park.param.closecarpark.QueryEquipmentRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.ParkingEquipmentInfoDTO">
        select
        e.id,
        e.equipment_name as equipmentName,
        t.equipment_type_name as equipmentTypeName,
        a.area_name as areaName,
        c.channel_name as channelName,
        e.screen_line_number screenLineNumber
        from parking_lot_equipment e
        left join  parking_lot_areas a on e.area_id = a.id
        left join parking_lot_channel c on e.channel_id = c.id
        left join parking_lot_equipment_type t on e.equipment_type = t.equipment_type_code
        where 1=1
        <if test="plNo != null and plNo != ''">
            and e.pl_no = #{plNo}
        </if>
        <if test="equipmentType != null and equipmentType != ''">
            and e.equipment_type = #{equipmentType}
        </if>
        <if test="channelId != null and channelId != ''">
            and e.channel_id = #{channelId}
        </if>
    </select>



    <select id="selectTreeByExample" parameterType="com.zteits.clouds.api.dto.park.param.closecarpark.QueryEquipmentTreeListRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.ParkingTreeListDTO">
    SELECT
	a.id,
	a.id as treeId,
	a.parent_id as parentId,
	a.parent_id as treeParentId,
	a.area_name  as label,
	a.area_type as type,
	a.pl_no as plNo,
    t.pl_name as plName,
    null as isTideChannel
FROM
	parking_lot_areas a
    LEFT JOIN parking_lot t on
    a.pl_no = t.pl_no
    where a.data_status = 1
	<if test="parkCode != null and parkCode != ''">
	and a.pl_no = #{parkCode}
	</if>
	UNION ALL
	SELECT
	concat(c.id,'a') as id,
	c.id as treeId,
	c.area_id as parentId,
	c.area_id as treeParentId,
	c.channel_name  as label,
    '3' AS type,
	c.pl_no as plNo,
    t.pl_name as plName,
    c.is_tide_channel as isTideChannel
FROM
	parking_lot_channel c
    LEFT JOIN parking_lot t on
    c.pl_no = t.pl_no
    where c.data_status = 1
	<if test="parkCode != null and parkCode != ''">
	and c.pl_no = #{parkCode}
    </if>
	UNION ALL
	SELECT
	concat(e.id,'b') as id,
	e.id as treeId,
    if(e.channel_id = 0,e.area_id,if(e.parent_equipment_id = 0,concat(e.channel_id,'a'),concat(e.parent_equipment_id,'b'))) as parentId,
    if(e.channel_id = 0,e.area_id,if(e.parent_equipment_id = 0,e.channel_id,e.parent_equipment_id)) as treeParentId,
	e.equipment_name as label,
	'4' as type,
	e.pl_no as plNo,
    t.pl_name as plName,
    null as isTideChannel
FROM
	parking_lot_equipment e
    LEFT JOIN parking_lot t on
    e.pl_no = t.pl_no
	<if test="parkCode != null and parkCode != ''">
	where e.pl_no = #{parkCode}
    </if>
    </select>

    <select id="QueryEquipmentDetail" parameterType="com.zteits.clouds.api.dto.park.param.closecarpark.QueryEquipmentDetailRequest"
            resultMap="BaseResultMap">
        select
        e.id,
        e.pl_no,
        e.node_type,
        e.area_id,
        e.channel_id,
        e.parent_equipment_id,
        e.equipment_name,
        e.equipment_description,
        e.equipment_type,
        e.equipment_use,
        e.equipment_driver,
        e.equipment_manufacturer,
        e.equipment_model,
        e.equipment_serial_number,
        e.equipment_level,
        e.equipment_status,
        e.screen_line_number,
        a.area_name,
        c.channel_name
        from parking_lot_equipment e
        left join parking_lot_areas a on e.area_id = a.id
        left join parking_lot_channel c on e.channel_id = c.id
        where e.id = #{id,jdbcType=BIGINT}
    </select>

    <select id="getEquipmentCongif" parameterType="com.zteits.clouds.api.dto.park.param.closecarpark.QueryEquipmentDetailRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.ParkingEquipmentConfigInfoDTO">
        select
         config_key as configKey,
         config_value as configValue,
         config_description as configDescription
        from parking_lot_equipment_config_detail
        where equipment_id = #{id,jdbcType=BIGINT}
    </select>




  <delete id="deleteByEquipmentId" parameterType="java.lang.Long">
    delete from parking_lot_equipment_config_detail
    where equipment_id = #{equipmentId,jdbcType=BIGINT}
  </delete>

  <insert id="insertDetailInfo" parameterType="java.util.List">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into parking_lot_equipment_config_detail ( equipment_id,config_key, config_value,
       config_description)
    values
       <foreach collection="list" item="item"  separator=",">
       ( #{item.equipmentId,jdbcType=BIGINT},#{item.configKey,jdbcType=VARCHAR},
      #{item.configValue,jdbcType=VARCHAR}, #{item.configDescription,jdbcType=VARCHAR})
       </foreach>
  </insert>




    <!--<insert id="insertSelectiveDto" parameterType="com.zteits.park.domain.ParkingLotEquipment" useGeneratedKeys="true"  keyProperty="id"  keyColumn="id">
        <selectKey keyProperty="id"  order="AFTER" resultType="java.lang.Long">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into parking_lot_equipment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="plNo != null">
                pl_no,
            </if>
            <if test="nodeType != null">
                node_type,
            </if>
            <if test="areaId != null">
                area_id,
            </if>
            <if test="channelId != null">
                channel_id,
            </if>
            <if test="parentEquipmentId != null">
                parent_equipment_id,
            </if>
            <if test="equipmentName != null">
                equipment_name,
            </if>
            <if test="equipmentDescription != null">
                equipment_description,
            </if>
            <if test="equipmentType != null">
                equipment_type,
            </if>
            <if test="equipmentUse != null">
                equipment_use,
            </if>
            <if test="equipmentDriver != null">
                equipment_driver,
            </if>
            <if test="equipmentManufacturer != null">
                equipment_manufacturer,
            </if>
            <if test="equipmentModel != null">
                equipment_model,
            </if>
            <if test="equipmentSerialNumber != null">
                equipment_serial_number,
            </if>
            <if test="equipmentLevel != null">
                equipment_level,
            </if>
            <if test="equipmentStatus != null">
                equipment_status,
            </if>
            <if test="screenLineNumber != null">
                screen_line_number,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="plNo != null">
                #{plNo,jdbcType=VARCHAR},
            </if>
            <if test="nodeType != null">
                #{nodeType,jdbcType=VARCHAR},
            </if>
            <if test="areaId != null">
                #{areaId,jdbcType=BIGINT},
            </if>
            <if test="channelId != null">
                #{channelId,jdbcType=BIGINT},
            </if>
            <if test="parentEquipmentId != null">
                #{parentEquipmentId,jdbcType=BIGINT},
            </if>
            <if test="equipmentName != null">
                #{equipmentName,jdbcType=VARCHAR},
            </if>
            <if test="equipmentDescription != null">
                #{equipmentDescription,jdbcType=VARCHAR},
            </if>
            <if test="equipmentType != null">
                #{equipmentType,jdbcType=INTEGER},
            </if>
            <if test="equipmentUse != null">
                #{equipmentUse,jdbcType=INTEGER},
            </if>
            <if test="equipmentDriver != null">
                #{equipmentDriver,jdbcType=VARCHAR},
            </if>
            <if test="equipmentManufacturer != null">
                #{equipmentManufacturer,jdbcType=VARCHAR},
            </if>
            <if test="equipmentModel != null">
                #{equipmentModel,jdbcType=VARCHAR},
            </if>
            <if test="equipmentSerialNumber != null">
                #{equipmentSerialNumber,jdbcType=VARCHAR},
            </if>
            <if test="equipmentLevel != null">
                #{equipmentLevel,jdbcType=INTEGER},
            </if>
            <if test="equipmentStatus != null">
                #{equipmentStatus,jdbcType=INTEGER},
            </if>
            <if test="screenLineNumber != null">
                #{screenLineNumber,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>-->





</mapper>