| | |
| | | CONCAT(ROUND(TRUNCATE(rw.completedQuantity/(rw.completedQuantity + IFNULL(dd.breakageArea,0)),2)*100), '%') as finished |
| | | from |
| | | ( |
| | | select rw.this_process,SUM(rwd.completed_quantity) as completedQuantity |
| | | ,ROUND(SUM((rwd.child_width) * (rwd.child_height) * rwd.completed_quantity / 1000000), 2) as completedArea |
| | | from reporting_work rw |
| | | LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = rw.reporting_work_id |
| | | select |
| | | tb.process as this_process, |
| | | SUM(tb.completedQuantity) as completedQuantity, |
| | | ROUND(SUM(completedArea),2) as completedArea |
| | | from ( |
| | | SELECT |
| | | rw.process_id, |
| | | rw.this_process AS process, |
| | | rw.teams_groups_name AS teamsGroupsName, |
| | | rwd.order_number AS orderNumber, |
| | | MAX(bd.nickname) AS nickname, |
| | | /* 仅当 nickname 为空时才显示 technology_number,否则为 NULL */ |
| | | MIN(CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END) AS technologyNumber, |
| | | COALESCE((rwd.completed_quantity), 0) AS completedQuantity, |
| | | ROUND(COALESCE((rwd.child_width * rwd.child_height * rwd.completed_quantity),0)/1000000, 2) |
| | | AS completedArea |
| | | FROM reporting_work rw |
| | | LEFT JOIN reporting_work_detail rwd |
| | | ON rwd.reporting_work_id = rw.reporting_work_id |
| | | LEFT JOIN sd.basic_data bd |
| | | ON bd.basic_name = rw.this_process |
| | | |
| | | where rw.reporting_work_time >= #{selectTime1} |
| | | AND rw.reporting_work_time < #{selectTime2} |
| | | AND rw.reviewed_state >= 0 |
| | | GROUP BY rw.this_process |
| | | WHERE rw.reporting_work_time >= #{selectTime1} |
| | | AND rw.reporting_work_time < #{selectTime2} |
| | | AND rw.reviewed_state >= 0 |
| | | GROUP BY |
| | | rw.reporting_work_id, |
| | | rw.process_id, |
| | | rw.this_process, |
| | | rw.teams_groups_name, |
| | | rwd.order_number, |
| | | CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END |
| | | ORDER BY rw.process_id, |
| | | rw.this_process, rw.teams_groups_name, rwd.order_number, |
| | | CASE WHEN bd.nickname IS NULL THEN rwd.technology_number ELSE NULL END |
| | | ) as tb |
| | | GROUP BY tb.process |
| | | ) as rw |
| | | left join |
| | | ( |
| | | select dd.responsible_process,sum(dd.breakage_quantity) as breakageQuantity |
| | | ,ROUND(SUM((rwd.child_width) * (rwd.child_height) * dd.breakage_quantity / 1000000), 2) as breakageArea |
| | | from reporting_work rw left join damage_details dd on dd.reporting_work_id = rw.reporting_work_id |
| | | LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = dd.reporting_work_id |
| | | and rwd.order_number = dd.order_number and rwd.technology_number = dd.technology_number |
| | | LEFT JOIN reporting_work_detail rwd on rwd.reporting_work_id = dd.reporting_work_id and rwd.order_number = dd.order_number and rwd.technology_number = dd.technology_number |
| | | where rw.reporting_work_time >= #{selectTime1} |
| | | AND rw.reporting_work_time < #{selectTime2} |
| | | AND rw.reviewed_state >= 0 and dd.available =0 |
| | | AND rw.reviewed_state >= 0 and dd.available =0 |
| | | GROUP BY dd.responsible_process |
| | | ) as dd on rw.this_process = dd.responsible_process |
| | | |
| | | |
| | | </select> |
| | | </mapper> |