<?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="api.dao.PhotovoltaicEntityDao">
|
|
<resultMap type="api.bean.PhotovoltaicEntity" id="PhotovoltaicEntityMap">
|
<result property="photovoltaicId" column="photovoltaic_id" jdbcType="INTEGER"/>
|
<result property="photovoltaicName" column="photovoltaic_name" jdbcType="VARCHAR"/>
|
<result property="photovoltaicMac" column="photovoltaic_mac" jdbcType="VARCHAR"/>
|
<result property="photovoltaicWorkPattern" column="photovoltaic_work_pattern" jdbcType="INTEGER"/>
|
<result property="photovoltaicWorkWaring" column="photovoltaic_work_waring" jdbcType="VARCHAR"/>
|
<result property="bindPoleStreelightId" column="bind_pole_streelight_id" jdbcType="INTEGER"/>
|
<result property="hardwareVersion" column="hardware_version" jdbcType="VARCHAR"/>
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
<result property="createUserId" column="create_user_id" jdbcType="INTEGER"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="softwareVersion" column="software_version" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<!-- 批量插入 -->
|
<insert id="insertBatch" keyProperty="photovoltaicId" useGeneratedKeys="true">
|
insert into machine.photovoltaic_entity(photovoltaic_name, photovoltaic_mac, photovoltaic_work_pattern, photovoltaic_work_waring, bind_pole_streelight_id, hardware_version, update_time, create_user_id, create_time, software_version)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.photovoltaicName}, #{entity.photovoltaicMac}, #{entity.photovoltaicWorkPattern}, #{entity.photovoltaicWorkWaring}, #{entity.bindPoleStreelightId}, #{entity.hardwareVersion}, #{entity.updateTime}, #{entity.createUserId}, #{entity.createTime}, #{entity.softwareVersion})
|
</foreach>
|
</insert>
|
<!-- 批量插入或按主键更新 -->
|
<insert id="insertOrUpdateBatch" keyProperty="photovoltaicId" useGeneratedKeys="true">
|
insert into machine.photovoltaic_entity(photovoltaic_name, photovoltaic_mac, photovoltaic_work_pattern, photovoltaic_work_waring, bind_pole_streelight_id, hardware_version, update_time, create_user_id, create_time, software_version)
|
values
|
<foreach collection="entities" item="entity" separator=",">
|
(#{entity.photovoltaicName}, #{entity.photovoltaicMac}, #{entity.photovoltaicWorkPattern}, #{entity.photovoltaicWorkWaring}, #{entity.bindPoleStreelightId}, #{entity.hardwareVersion}, #{entity.updateTime}, #{entity.createUserId}, #{entity.createTime}, #{entity.softwareVersion})
|
</foreach>
|
on duplicate key update
|
photovoltaic_name = values(photovoltaic_name) , photovoltaic_mac = values(photovoltaic_mac) , photovoltaic_work_pattern = values(photovoltaic_work_pattern) , photovoltaic_work_waring = values(photovoltaic_work_waring) , bind_pole_streelight_id = values(bind_pole_streelight_id) , hardware_version = values(hardware_version) , update_time = values(update_time) , create_user_id = values(create_user_id) , create_time = values(create_time) , software_version = values(software_version) </insert>
|
|
<select id="listAll" resultType="api.bean.PhotovoltaicEntity">
|
select
|
a.*,
|
b.streetlight_id,b.streetlight_name,b.code_number
|
from photovoltaic_entity a
|
join pole_streetlight b on a.bind_pole_streelight_id = b.streetlight_id
|
<if test="key != null and key != ''">
|
where
|
(a.bind_pole_streelight_id like '%${key}%'
|
or a.photovoltaic_id like '%${key}%'
|
or a.photovoltaic_name like '%${key}%'
|
or b.streetlight_name like '%${key}%')
|
</if>
|
|
</select>
|
|
<select id="listByCompanyId" resultType="api.bean.PhotovoltaicEntity">
|
|
select
|
a.*,
|
b.streetlight_id,b.streetlight_name,b.code_number
|
from
|
photovoltaic_entity a
|
inner join (
|
select
|
streetlight_id,streetlight_name,code_number
|
from
|
pole_streetlight
|
where
|
streetlight_id in
|
( SELECT streetlight_id FROM pole_user_streetlight WHERE user_id IN
|
( SELECT user_id FROM sys_user_company WHERE company_id = #{companyId})
|
)
|
) b on a.bind_pole_streelight_id = b.streetlight_id
|
|
<if test="key != null and key != ''">
|
where
|
(a.bind_pole_streelight_id like '%${key}%'
|
or a.photovoltaic_id like '%${key}%'
|
or a.photovoltaic_name like '%${key}%'
|
or b.streetlight_name like '%${key}%')
|
</if>
|
|
</select>
|
|
<select id="listByUserId" resultType="api.bean.PhotovoltaicEntity">
|
|
|
select
|
a.*,
|
b.streetlight_id,b.streetlight_name,b.code_number
|
from
|
photovoltaic_entity a
|
inner join (
|
select
|
streetlight_id,streetlight_name,code_number
|
from
|
pole_streetlight
|
where
|
streetlight_id in
|
( SELECT streetlight_id FROM pole_user_streetlight WHERE user_id = #{userId} )
|
) b on a.bind_pole_streelight_id = b.streetlight_id
|
<if test="key != null and key != ''">
|
where
|
(a.bind_pole_streelight_id like '%${key}%'
|
or a.photovoltaic_id like '%${key}%'
|
or a.photovoltaic_name like '%${key}%'
|
or b.streetlight_name like '%${key}%')
|
</if>
|
|
</select>
|
</mapper>
|