(select hygf_rectification_order.rectification_history from hygf_rectification_order
where hygf_rectification_order.peasant_househole_id = hygf_work_order_power_station.peasant_household_id
and hygf_rectification_order.rectification_status = '待整改' and hygf_rectification_order.rectification_source = hygf_work_order_power_station.work_order_power_station_node ) as auditIdea,
(select hygf_rectification_order.sequence_nbr from hygf_rectification_order
where hygf_rectification_order.peasant_househole_id = hygf_work_order_power_station.peasant_household_id
and hygf_rectification_order.rectification_status = '已作废' and hygf_rectification_order.rectification_source = hygf_work_order_power_station.work_order_power_station_node order by rec_date desc limit 1) as rollbackOrderId,
(select hygf_rectification_order.sequence_nbr from hygf_rectification_order
where hygf_rectification_order.peasant_househole_id = hygf_work_order_power_station.peasant_household_id
and hygf_rectification_order.rectification_status in ('待整改','待提交','整改中','整改待审核','待审核')) as rectificationNum
from hygf_work_order_power_station LEFT join hygf_work_order
on hygf_work_order.sequence_nbr=hygf_work_order_power_station.work_order_id
LEFT JOIN hygf_peasant_household on hygf_peasant_household.sequence_nbr=hygf_work_order_power_station.peasant_household_id
LEFT JOIN hygf_power_station_engineering_info on hygf_power_station_engineering_info.work_order_power_station_id=hygf_work_order_power_station.sequence_nbr
<where>
<iftest="dto.workOrderId!=null and dto.workOrderId!=''">
and hygf_work_order.sequence_nbr = #{dto.workOrderId}
</if>
<iftest=' dto.type!=null and dto.type == "1"'>
and hygf_work_order_power_station.power_station_construction_status in ('待登记','未通过','已完工','待审核')
</if>
<iftest=' dto.type !=null and dto.type == "2"'>
and hygf_work_order_power_station.power_station_construction_status in ('未通过','已完工','待审核')
and hygf_work_order_power_station.power_station_construction_status IN ( '未通过', '已完工', '待审核', '待整改', '整改中','整改待审核' )
</if>
<iftest=' dto.type !=null and dto.type == "3" and dto.workOrderPowerStationNodes !=null'>
and ( hygf_work_order_power_station.work_order_power_station_node is not null
or hygf_work_order_power_station.work_order_power_station_node = 'all'
or hygf_work_order_power_station.power_station_area_status is not null
or hygf_work_order_power_station.power_station_design_status is not null
or hygf_work_order_power_station.power_station_engineering_status is not null
)
</if>
<iftest="dto.projectAddressName!=null and dto.projectAddressName!=''">
and hygf_peasant_household.project_address_name like concat(concat('%',#{dto.projectAddressName}),'%')
</if>
<iftest="dto.peasantHouseholdNo!=null and dto.peasantHouseholdNo!=''">
and hygf_peasant_household.peasant_household_no like concat(concat('%',#{dto.peasantHouseholdNo}),'%')
</if>
<iftest="dto.ownersName!=null and dto.ownersName!=''">
and hygf_peasant_household.owners_name like concat(concat('%',#{dto.ownersName}),'%')
</if>
<iftest="dto.workOrderNum!=null and dto.workOrderNum!=''">
and hygf_work_order.work_order_num like concat(concat('%',#{dto.workOrderNum}),'%')
</if>
<iftest="dto.projectRegionManager!=null and dto.projectRegionManager!=''">
and hygf_work_order.project_region_manager like concat(concat('%',#{dto.projectRegionManager}),'%')
</if>
<iftest="dto.powerStationConstructionStatus!=null and dto.powerStationConstructionStatus!=''">
and hygf_work_order_power_station.power_station_construction_status=#{dto.powerStationConstructionStatus}
</if>
<iftest="dto.amosDealerId!=null and dto.amosDealerId!=''">
and hygf_work_order.amos_dealer_id = #{dto.amosDealerId}
</if>
<iftest="dto.regionCompanyId!=null and dto.regionCompanyId!=''">
and hygf_work_order.region_company_id =#{dto.regionCompanyId}