| | |
| | | ip.cable_tag |
| | | </sql> |
| | | |
| | | <!-- ç´ç»è®¢åææ¨¡æ¿ç»è®ºç»è®¡ï¼ä¼ ç»è®¢åæææä¸éç»å®çæ£éªé¡¹ç®ç»è®¡ã --> |
| | | <sql id="inspectionProgressColumn"> |
| | | CONCAT(COALESCE(ROUND( |
| | | CASE WHEN template_progress.total_count > 0 |
| | | THEN template_progress.completed_count * 100.0 / template_progress.total_count |
| | | ELSE product_progress.completed_count * 100.0 / NULLIF(product_progress.total_count, 0) |
| | | END, 2), 0), '%') AS insProgress |
| | | </sql> |
| | | |
| | | <sql id="inspectionProgressJoins"> |
| | | LEFT JOIN ( |
| | | SELECT s.ins_order_id, COUNT(*) AS total_count, |
| | | SUM(CASE WHEN p.ins_result IN (0, 1, 3) THEN 1 ELSE 0 END) AS completed_count |
| | | FROM ins_product p |
| | | JOIN ins_sample s ON p.ins_sample_id = s.id |
| | | WHERE p.state = 1 AND (p.is_binding IS NULL OR p.is_binding != 1) |
| | | GROUP BY s.ins_order_id |
| | | ) product_progress ON io.id = product_progress.ins_order_id |
| | | LEFT JOIN ( |
| | | SELECT t.ins_order_id, COUNT(*) AS total_count, |
| | | SUM(CASE WHEN t.ins_result IN (0, 1) THEN 1 ELSE 0 END) AS completed_count |
| | | FROM ins_order_standard_template t |
| | | JOIN ins_order template_order ON template_order.id = t.ins_order_id |
| | | WHERE EXISTS ( |
| | | SELECT 1 |
| | | FROM ins_sample s |
| | | LEFT JOIN ins_product p ON p.ins_sample_id = s.id |
| | | WHERE s.ins_order_id = t.ins_order_id |
| | | AND (p.template_row_index IS NOT NULL |
| | | OR (s.standard_method_list_id IS NULL |
| | | AND COALESCE(TRIM(s.factory), '') = '' |
| | | AND COALESCE(TRIM(s.sample_type), '') = '' |
| | | AND COALESCE(TRIM(s.model), '') = '' |
| | | AND COALESCE(TRIM(template_order.factory), '') = '' |
| | | AND COALESCE(TRIM(template_order.sample_type), '') = '')) |
| | | ) |
| | | GROUP BY t.ins_order_id |
| | | ) template_progress ON io.id = template_progress.ins_order_id |
| | | </sql> |
| | | |
| | | <sql id="selectInsOrderExport"> |
| | | SELECT |
| | | io.*, |
| | |
| | | ir.url, |
| | | ir.url_s, |
| | | sample_counts.sample_num, |
| | | CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS insProgress, |
| | | <include refid="inspectionProgressColumn"/>, |
| | | io.sample_view AS sample_name, |
| | | GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, |
| | | u.name, |
| | |
| | | FROM ins_sample |
| | | WHERE id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) |
| | | GROUP BY ins_order_id) sample_counts ON io.id = sample_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS total_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 |
| | | GROUP BY ins_sample.ins_order_id) total_product_counts ON io.id = total_product_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS approved_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 AND ins_product.ins_result IS NOT NULL |
| | | GROUP BY ins_sample.ins_order_id) approved_product_counts ON io.id = approved_product_counts.ins_order_id |
| | | <include refid="inspectionProgressJoins"/> |
| | | LEFT JOIN (SELECT ins_sample_id, GROUP_CONCAT(DISTINCT uu.name SEPARATOR ',') AS testing_name |
| | | FROM ins_sample_user u |
| | | LEFT JOIN user uu ON u.user_id = uu.id |
| | |
| | | ir.url, |
| | | ir.url_s, |
| | | sample_counts.sample_num, |
| | | CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS insProgress, |
| | | <include refid="inspectionProgressColumn"/>, |
| | | io.sample_view AS sample_name, |
| | | GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, |
| | | u.name, |
| | |
| | | FROM ins_sample |
| | | WHERE id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = ip.ins_sample_id where ip.id is not null)s ) |
| | | GROUP BY ins_order_id) sample_counts ON io.id = sample_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS total_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 and is_binding !=1 |
| | | GROUP BY ins_sample.ins_order_id) total_product_counts ON io.id = total_product_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS approved_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 and is_binding !=1 AND ins_product.ins_result IS NOT NULL |
| | | GROUP BY ins_sample.ins_order_id) approved_product_counts ON io.id = approved_product_counts.ins_order_id |
| | | <include refid="inspectionProgressJoins"/> |
| | | LEFT JOIN (SELECT ins_sample_id, GROUP_CONCAT(DISTINCT uu.name SEPARATOR ',') AS testing_name |
| | | FROM ins_sample_user u |
| | | LEFT JOIN user uu ON u.user_id = uu.id |