substring_index ( hygf_peasant_household.project_address_name, '/', 1 ) AS province,
ps.business_status,
b.stamp_status,
ps.technology_status,
b.status
ps.process_instance_id,
from hygf_power_station LEFT JOIN ( SELECT bb.peasant_household_id, initiate_status, contract_lock_id, stamp_status, status FROM (SELECT peasant_household_id,MAX(sequence_nbr) AS sequence_nbr from hygf_household_contract GROUP BY peasant_household_id ) aa INNER JOIN hygf_household_contract bb ON aa.sequence_nbr=bb.sequence_nbr) b on b.peasant_household_id=hygf_power_station.peasant_household_id
ps.peasant_household_id,
LEFT JOIN hygf_peasant_household on hygf_peasant_household.sequence_nbr=hygf_power_station.peasant_household_id
ps.task_id,
where hygf_power_station.is_delete=0
ps.node_routing,
ps.process_definition_id,
<iftest="powerStationCode!=null and powerStationCode!=''">
ps.node_role,
and hygf_power_station.power_station_code like concat(concat('%',#{powerStationCode}),'%')
ps.next_process_node,
ps.flow_task_id,
ps.plan_instance_id,
ps.drawing_review,
ps.next_node_name,
ps.next_execute_user_ids,
lc.initiate_status,
lc.contract_lock_id,
ph.regional_companies_code,
ph.regional_companies_name,
ph.developer_code,
ph.developer_user_id,
ph.project_address_detail,
SUBSTRING_INDEX(ph.project_address_name, '/', 1) AS province,
lc.stamp_status,
lc.status
FROM
hygf_power_station ps
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 = ps.peasant_household_id
LEFT JOIN hygf_peasant_household ph
ON ph.sequence_nbr = ps.peasant_household_id
WHERE
ps.is_delete = 0
<iftest="powerStationCode != null and powerStationCode != ''">
AND ps.power_station_code LIKE CONCAT('%', #{powerStationCode}, '%')
</if>
</if>
<iftest="ownersName!=null and ownersName!=''">
<iftest="ownersName != null and ownersName != ''">
and hygf_power_station.owners_name like concat(concat('%',#{ownersName}),'%')
AND ps.owners_name LIKE CONCAT('%', #{ownersName}, '%')
</if>
</if>
<iftest="serviceAgent!=null and serviceAgent!=''">
<iftest="serviceAgent != null and serviceAgent != ''">
and hygf_power_station.service_agent like concat(concat('%',#{serviceAgent}),'%')
AND ps.service_agent LIKE CONCAT('%', #{serviceAgent}, '%')
</if>
</if>
<iftest="regionalCompaniesName!=null and regionalCompaniesName!=''">
<iftest="regionalCompaniesName != null and regionalCompaniesName != ''">
and hygf_peasant_household.regional_companies_name like concat(concat('%',#{regionalCompaniesName}),'%')
AND ph.regional_companies_name LIKE CONCAT('%', #{regionalCompaniesName}, '%')
</if>
</if>
<iftest="processStatus != null and processStatus != ''">
<iftest="processStatus != null and processStatus != ''">
and hygf_power_station.process_status = #{processStatus}
AND ps.process_status = #{processStatus}
</if>
</if>
<iftest="province != null and province != ''">
<iftest="province != null and province != ''">
and hygf_peasant_household.project_address like concat(concat('%',#{province}),'%')
AND ph.project_address_name LIKE CONCAT('%', #{province}, '%')
</if>
</if>
<!-- GROUP BY hygf_peasant_household.sequence_nbr-->
hygf_peasant_household ON hygf_power_station.peasant_household_id = hygf_peasant_household.sequence_nbr
hygf_peasant_household ON hygf_power_station.peasant_household_id = hygf_peasant_household.sequence_nbr
<where>
<where>
next_node_name IN ( '经销商设计人员上传设计图', '设计上传典型图库' )
AND process_status = '进行中'
<iftest="developerCode != null and developerCode != ''">
<iftest="developerCode != null and developerCode != ''">
AND hygf_peasant_household.developer_code = #{developerCode}
AND hygf_peasant_household.developer_code = #{developerCode}
</if>
</if>
...
@@ -391,9 +389,9 @@
...
@@ -391,9 +389,9 @@
'' AS kcywcrl,
'' AS kcywcrl,
SUM(CASE WHEN ph.preparation_money_state = '备货完成' THEN 1 ELSE 0 END) AS bhywc,
SUM(CASE WHEN ph.preparation_money_state = '备货完成' THEN 1 ELSE 0 END) AS bhywc,
'' AS bhywcrl,
'' AS bhywcrl,
SUM(CASE WHEN ph.preparation_money_state = '待收货' THEN 1 ELSE 0 END) AS bhjxz,
SUM(CASE WHEN ph.preparation_money_state = '待发货' or ph.preparation_money_state = '暂存发货'or ph.preparation_money_state = '待补货' THEN 1 ELSE 0 END ) AS bhwtg,
'' AS bhjxzrl,
'' AS bhjxzrl,
SUM(CASE WHEN ph.preparation_money_state = '待补货' THEN 1 ELSE 0 END) AS bhwtg,
SUM(CASE WHEN ph.preparation_money_state = '待收货' THEN 1 ELSE 0 END) AS bhjxz,
'' AS bhwtgrl,
'' AS bhwtgrl,
SUM(CASE WHEN wops.power_station_construction_status = '未通过' THEN 1 ELSE 0 END) AS sgwtg,
SUM(CASE WHEN wops.power_station_construction_status = '未通过' THEN 1 ELSE 0 END) AS sgwtg,
SUM(CASE WHEN wops.power_station_construction_status = '未通过' THEN ROUND(COALESCE(ei.real_scale/1000, 0), 2) ELSE 0 END) AS sgwtgrl,
SUM(CASE WHEN wops.power_station_construction_status = '未通过' THEN ROUND(COALESCE(ei.real_scale/1000, 0), 2) ELSE 0 END) AS sgwtgrl,
...
@@ -427,7 +425,7 @@
...
@@ -427,7 +425,7 @@
LEFT JOIN hygf_basic_grid_record br ON br.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_basic_grid_record br ON br.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_financing_info fi ON fi.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_financing_info fi ON fi.peasant_household_id = ph.sequence_nbr
WHERE
WHERE
ps.is_delete = 0
ph.is_delete = 0
<iftest="developerCode != null and developerCode != ''">
<iftest="developerCode != null and developerCode != ''">
AND ph.developer_code = #{developerCode}
AND ph.developer_code = #{developerCode}
</if>
</if>
...
@@ -532,15 +530,25 @@
...
@@ -532,15 +530,25 @@
<selectid="getRent"resultType="map">
<selectid="getRent"resultType="map">
SELECT
SELECT
sum( CASE WHEN repay_state = '1' THEN rent ELSE 0 END ) yhk,
sum( CASE WHEN repay_state = '1' THEN rent ELSE 0 END ) yhk,
sum( CASE WHEN repay_state = '0' THEN rent ELSE 0 END ) sywhk,
sum( CASE WHEN repay_state = '0' THEN rent ELSE 0 END ) sywhk,
sum( CASE WHEN repay_state = '0' AND ( YEAR ( repay_date ) = YEAR ( CURDATE())) THEN rent ELSE 0 END ) jnwhk,
sum( CASE WHEN repay_state = '0' AND ( YEAR ( repay_date ) = YEAR ( CURDATE())) THEN rent ELSE 0 END ) jnwhk,