left join hygf_peasant_household hph ON hph.sequence_nbr = hps.peasant_household_id
left join hygf_peasant_household hph ON hph.sequence_nbr = hps.peasant_household_id
<iftest="map.status != null and map.status != ''">
LEFT JOIN (
SELECT peasant_household_id, initiate_status, contract_lock_id, stamp_status, status FROM ( SELECT hhc.*, ROW_NUMBER() OVER (PARTITION BY peasant_household_id ORDER BY sequence_nbr DESC) AS rn FROM hygf_household_contract hhc ) subq WHERE subq.rn = 1 ) lc
ON lc.peasant_household_id = hps.peasant_household_id
</if>
where hps.is_delete=0
where hps.is_delete=0
<iftest="map.powerStationCode!=null and map.powerStationCode!=''">
<iftest="map.powerStationCode!=null and map.powerStationCode!=''">
and hps.power_station_code like concat(concat('%',#{map.powerStationCode}),'%')
and hps.power_station_code like concat(concat('%',#{map.powerStationCode}),'%')
...
@@ -29,6 +34,15 @@
...
@@ -29,6 +34,15 @@
<iftest="map.province != null and map.province != ''">
<iftest="map.province != null and map.province != ''">
and hph.project_address like concat(concat('%',#{map.province}),'%')
and hph.project_address like concat(concat('%',#{map.province}),'%')
</if>
</if>
<iftest="map.status != null and map.status != ''">
AND lc.status = #{map.status}
</if>
<iftest="map.startTime != null and map.startTime != ''">
AND hps.kc_create_time >= #{map.startTime}
</if>
<iftest="map.endTime != null and map.endTime != ''">