You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
262 lines
11 KiB
262 lines
11 KiB
<?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="org.springblade.modules.nh.mapper.PowerStationMapper">
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="powerStationResultMap" type="org.springblade.modules.nh.pojo.vo.PowerStationVO">
|
|
<result column="id" property="id"/>
|
|
<result column="inner_station_id" property="innerStationId"/>
|
|
<result column="out_station_id" property="outStationId"/>
|
|
<result column="station_code" property="stationCode"/>
|
|
<result column="station_name" property="stationName"/>
|
|
<result column="images" property="images"/>
|
|
<result column="capital_code" property="capitalCode"/>
|
|
<result column="capital_name" property="capitalName"/>
|
|
<result column="project_id" property="projectId"/>
|
|
<result column="project_code" property="projectCode"/>
|
|
<result column="project_name" property="projectName"/>
|
|
<result column="project_company_id" property="projectCompanyId"/>
|
|
<result column="project_company_name" property="projectCompanyName"/>
|
|
<result column="install_type" property="installType"/>
|
|
<result column="brand" property="brand"/>
|
|
<result column="filing_type" property="filingType"/>
|
|
<result column="customer_type" property="customerType"/>
|
|
<result column="agent_id" property="agentId"/>
|
|
<result column="agent_name" property="agentName"/>
|
|
<result column="agent_phone" property="agentPhone"/>
|
|
<result column="owner_id" property="ownerId"/>
|
|
<result column="owner_name" property="ownerName"/>
|
|
<result column="owner_phone" property="ownerPhone"/>
|
|
<result column="sn" property="sn"/>
|
|
<result column="province" property="province"/>
|
|
<result column="city" property="city"/>
|
|
<result column="district" property="district"/>
|
|
<result column="address" property="address"/>
|
|
<result column="latitude" property="latitude"/>
|
|
<result column="longitude" property="longitude"/>
|
|
<result column="actual_capacity" property="actualCapacity"/>
|
|
<result column="install_accept_time" property="installAcceptTime"/>
|
|
<result column="start_gen_date" property="startGenDate"/>
|
|
<result column="apply_no" property="applyNo"/>
|
|
<result column="apply_status" property="applyStatus"/>
|
|
<result column="is_follow" property="isFollow"/>
|
|
<result column="om_provider_id" property="omProviderId"/>
|
|
<result column="om_provider_name" property="omProviderName"/>
|
|
<result column="etd" property="etd"/>
|
|
<result column="eto" property="eto"/>
|
|
<result column="etdc" property="etdc"/>
|
|
<result column="merge_time" property="mergeTime"/>
|
|
<result column="created_time" property="createdTime"/>
|
|
<result column="create_user" property="createUser"/>
|
|
<result column="create_dept" property="createDept"/>
|
|
<result column="created_time" property="createdTime"/>
|
|
<result column="update_user" property="updateUser"/>
|
|
<result column="updated_time" property="updatedTime"/>
|
|
<result column="status" property="status"/>
|
|
<result column="is_deleted" property="isDeleted"/>
|
|
<result column="payment_time" property="paymentTime"/>
|
|
<result column="warranty_expires_time" property="warrantyExpiresTime"/>
|
|
</resultMap>
|
|
|
|
|
|
<select id="selectPowerStationPage" resultMap="powerStationResultMap">
|
|
select s.* from nh_power_station s
|
|
where s.is_deleted = 0
|
|
<include refid="commonCondition"/>
|
|
order by s.create_time desc
|
|
</select>
|
|
|
|
<select id="selectPowerStationListEx" resultMap="powerStationResultMap">
|
|
select s.* from nh_power_station s
|
|
where s.is_deleted = 0
|
|
<include refid="commonCondition"/>
|
|
order by s.create_time desc
|
|
</select>
|
|
|
|
<select id="selectPowerStationList" resultMap="powerStationResultMap">
|
|
select s.* from nh_power_station s
|
|
where s.is_deleted = 0 and s.capital_name='广州越秀融资租赁有限公司'
|
|
<include refid="commonCondition"/>
|
|
|
|
</select>
|
|
|
|
<sql id="commonCondition">
|
|
<if test="e.status!=null and e.status != ''">
|
|
and s.status = #{e.status}
|
|
</if>
|
|
<if test="e.sn!=null and e.sn != ''">
|
|
and s.sn = #{e.sn}
|
|
</if>
|
|
<if test="e.applyStatus!=null">
|
|
and s.apply_status = #{e.applyStatus}
|
|
</if>
|
|
<if test="e.brand!=null">
|
|
and s.brand = #{e.brand}
|
|
</if>
|
|
<if test="e.offlineDuring!=null">
|
|
and ((s.last_status = 3 and s.status=1 and s.during_seconds is not null and s.during_seconds > #{e.offlineDuring}*3600)
|
|
or ( s.status=3 and s.last_status_start is not null and s.last_status_start < DATE_SUB(NOW(), INTERVAL #{e.offlineDuring} HOUR)))
|
|
</if>
|
|
<if test="e.errorDuring!=null">
|
|
and ((s.last_status = 2 and s.status=1 and s.during_seconds is not null and s.during_seconds > #{e.errorDuring}*3600)
|
|
or (s.status=2 and s.last_status_start is not null and s.last_status_start < DATE_SUB(NOW(), INTERVAL #{e.errorDuring} HOUR)))
|
|
</if>
|
|
<if test="e.omProviderName!=null and e.omProviderName != ''">
|
|
and s.om_provider_name = #{e.omProviderName}
|
|
</if>
|
|
|
|
<if test="e.agentName!=null and e.agentName != ''">
|
|
and s.agent_name like CONCAT('%', #{e.agentName}, '%')
|
|
</if>
|
|
<if test="e.capitalName!=null and e.capitalName != ''">
|
|
and s.capital_name in
|
|
<foreach collection="e.capitalName.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="e.orderNumber!=null and e.orderNumber != ''">
|
|
and s.order_number like CONCAT('%', #{e.orderNumber}, '%')
|
|
</if>
|
|
<if test="e.stationCode!=null and e.stationCode != ''">
|
|
and s.station_code = #{e.stationCode}
|
|
</if>
|
|
<if test="e.source!=null and e.source != ''">
|
|
and s.source = #{e.source}
|
|
</if>
|
|
<if test="e.ownerName!=null and e.ownerName != ''">
|
|
and s.owner_name like CONCAT('%', #{e.ownerName}, '%')
|
|
</if>
|
|
<if test="e.address!=null and e.address != ''">
|
|
and s.address like CONCAT('%', #{e.address}, '%')
|
|
</if>
|
|
<if test="e.applyNo!=null and e.applyNo != ''">
|
|
and s.apply_no like CONCAT('%', #{e.applyNo}, '%')
|
|
</if>
|
|
<if test="e.omProviderId!=null and e.omProviderId != ''">
|
|
and s.om_provider_id = #{e.omProviderId}
|
|
</if>
|
|
<if test="e.province !=null and e.province !='' ">
|
|
and s.province in
|
|
<foreach collection="e.province.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="e.city !=null and e.city !='' ">
|
|
and s.city in
|
|
<foreach collection="e.city.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="e.district !=null and e.district !='' ">
|
|
and s.district in
|
|
<foreach collection="e.district.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="e.entryIds !=null and e.entryIds !='' ">
|
|
and s.id in
|
|
<foreach collection="e.entryIds.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
|
|
<if test="e.siteIds !=null and e.siteIds !='' ">
|
|
and s.om_provider_id in
|
|
<foreach collection="e.siteIds.split(',')" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
|
|
</sql>
|
|
|
|
<select id="getSelectPowerStaion" resultType="org.springblade.modules.nh.pojo.dto.StationDTO">
|
|
select e.id,e.station_code as powerStationCode from nh_power_station e
|
|
where e.is_deleted = 0
|
|
</select>
|
|
|
|
|
|
<select id="exportPowerStation" resultType="org.springblade.modules.nh.excel.PowerStationExcel">
|
|
SELECT * FROM nh_power_station ${ew.customSqlSegment}
|
|
</select>
|
|
|
|
<select id="staticsStatus" resultType="org.springblade.modules.nh.pojo.vo.StaticsStatusVO">
|
|
SELECT s.status,COUNT(1) num FROM nh_power_station s where s.is_deleted = 0
|
|
<include refid="commonCondition"/>
|
|
GROUP BY s.`status`
|
|
</select>
|
|
|
|
<select id="groupProjectCompany" resultMap="powerStationResultMap">
|
|
SELECT project_company_id,project_company_name FROM nh_power_station GROUP BY project_company_id
|
|
</select>
|
|
|
|
<select id="getOutStationIds" resultType="java.lang.String">
|
|
SELECT out_station_id FROM nh_power_station WHERE out_station_id is not null
|
|
</select>
|
|
|
|
<select id="getStatusByProvince" resultType="org.springblade.modules.nh.pojo.vo.StaticsStatusVO">
|
|
SELECT
|
|
province as name,
|
|
`status` as status,
|
|
COUNT(1) AS num
|
|
FROM
|
|
nh_power_station
|
|
WHERE
|
|
is_deleted = 0 AND province != '' AND province is NOT NULL
|
|
<if test="omProviderId!=null and omProviderId != ''">
|
|
and om_provider_id = #{omProviderId}
|
|
</if>
|
|
GROUP BY
|
|
province,
|
|
`status`
|
|
ORDER BY
|
|
province
|
|
</select>
|
|
|
|
<select id="getStationDetailByPowCode" resultType="org.springblade.modules.nh.pojo.entity.PowerStationEntity">
|
|
select * from nh_power_station where station_code = #{powCode} and is_deleted=0
|
|
</select>
|
|
|
|
<update id="updatePowerStationBrand">
|
|
UPDATE
|
|
nh_power_station a
|
|
LEFT JOIN nh_device b on b.station_id=a.id
|
|
SET
|
|
a.brand = b.brand
|
|
WHERE
|
|
a.brand is NULL
|
|
</update>
|
|
|
|
<select id="findMyPowerStation" resultType="org.springblade.modules.nh.pojo.entity.PowerStationEntity">
|
|
select p.* from nh_power_station p
|
|
left join sf_operation_order o on o.entry_id = p.inner_station_id
|
|
where p.is_deleted=0 and FIND_IN_SET(#{empId}, o.employe_id) and o.site_id=#{siteId}
|
|
<if test="condition != null and condition!=''">
|
|
and (p.station_code like concat('%',#{condition},'%') or p.owner_phone like concat('%',#{condition},'%') or p.owner_name like concat('%',#{condition},'%'))
|
|
</if>
|
|
</select>
|
|
|
|
<update id="updateStatusByOutIds">
|
|
UPDATE nh_power_station
|
|
SET last_status=`status`,
|
|
`status` = #{status},
|
|
last_status_start = last_status_end,
|
|
last_status_end = SYSDATE(),
|
|
during_seconds=TIMESTAMPDIFF(SECOND, last_status_start, last_status_end)
|
|
WHERE
|
|
`status`!= #{status}
|
|
and out_station_id IN
|
|
<foreach collection="outStationIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="getStationListByPowCode" resultType="org.springblade.modules.nh.pojo.dto.PowerStationDTO">
|
|
select * from nh_power_station where station_code like CONCAT('%', #{powCode}, '%') and is_deleted=0
|
|
<if test="siteId != null and siteId!=''">
|
|
and om_provider_id=#{siteId}
|
|
</if>
|
|
</select>
|
|
|
|
</mapper>
|