hsi.*,hph.peasant_household_no,hph.owners_name,hph.telephone,hph.project_address_name,hph.project_address_detail,hph.permanent_address_name,hph.permanent_address_detail,hph.sequence_nbr AS stationId
FROM
hygf_survey_information hsi
LEFT JOIN hygf_peasant_household hph ON hph.survey_information_id=hsi.sequence_nbr
hpsei.*,hwops.peasant_household_id AS stationId,hpsc.construction_component_info,hpsc.construction_inverter_info,hpsc.construction_collector_box_info,hpsc.construction_grid_box_info
FROM
hygf_power_station_engineering_info hpsei
LEFT JOIN hygf_work_order_power_station hwops ON hwops.sequence_nbr=hpsei.work_order_power_station_id
LEFT JOIN hygf_power_station_construction_data hpsc on hpsc.work_order_power_station_id=hpsei.work_order_power_station_id
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 ( '未通过', '已完工', '待审核', '待整改', '整改中','整改待审核' )
</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}
</if>
<iftest="dto.province != null and dto.province != ''">
and hygf_peasant_household.project_address like concat(concat('%',#{dto.province}),'%')
hygf_document_station.preparation_money_id as preparationMoneyId,
hygf_preparation_money.delivery_time as deliveryTime,
hygf_preparation_money.arrival_time as arrivalTime,
(select instance_id from hygf_preparation_money_auditing where hygf_document_station.preparation_money_id = hygf_preparation_money_auditing.preparation_money_id limit 1) as instanceId from
hygf_peasant_household
LEFT JOIN hygf_document_station on hygf_peasant_household.sequence_nbr = hygf_document_station.station_id
LEFT JOIN hygf_power_station on hygf_peasant_household.sequence_nbr = hygf_power_station.peasant_household_id
LEFT JOIN hygf_preparation_money on hygf_preparation_money.sequence_nbr = hygf_document_station.preparation_money_id
<where>
<iftest=" map.preparationMoneyState == 0 ">
and hygf_peasant_household.preparation_money_state in ('待发货','待补货','暂存发货')
</if>
<iftest="map.regionalCompaniesSeq!=null and map.regionalCompaniesSeq !='' ">
and hygf_peasant_household.regional_companies_code like concat('%',#{map.regionalCompaniesSeq},'%')
</if>
<iftest="map.developerId!=null and map.developerId !=''">
and hygf_peasant_household.developer_code like concat('%',#{map.developerId},'%')
</if>
<iftest="map.state!=null and map.state !=''">
and hygf_peasant_household.preparation_money_state = #{map.state}
</if>
<iftest="map.ownersName!=null and map.ownersName !=''">
and hygf_peasant_household.owners_name like concat ('%',#{map.ownersName},'%')
</if>
<iftest=" map.preparationMoneyState == 1 ">
and hygf_peasant_household.preparation_money_state not in ('待发货','待补货','暂存发货') and preparation_money_state is not null and preparation_money_state != ''
</if>
<iftest="map.province != null and map.province != ''">
and hygf_peasant_household.project_address like concat(concat('%',#{map.province}),'%')
</if>
</where>
<iftest=" map.preparationMoneyState == 1 ">
order by hygf_preparation_money.delivery_time DESC