| | |
| | | <result column="dept_id" property="deptId" /> |
| | | </resultMap> |
| | | |
| | | <!-- 按生产订单分组的工单分页查询 --> |
| | | <select id="pageProductionOperationTask" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo"> |
| | | select pot.*, |
| | | po.nps_no as npsNo, |
| | | po.is_end_order as endOrder, |
| | | p.product_name as productName, |
| | | pm.model as model, |
| | | pm.unit as unit, |
| | | poro.operation_name as operationName, |
| | | poro.type as type, |
| | | IFNULL(scrapStat.scrapQty, 0) AS scrapQty, |
| | | ROUND(IFNULL(pot.complete_quantity, 0) / NULLIF(pot.plan_quantity, 0) * 100, 2) AS completionStatus, |
| | | CASE |
| | | WHEN pot.work_order_no LIKE 'FG%' THEN '返工返修' |
| | | ELSE '正常' |
| | | END AS work_order_type |
| | | from production_operation_task pot |
| | | left join production_order po on pot.production_order_id = po.id |
| | | left join production_order_routing_operation poro on pot.production_order_routing_operation_id = poro.id |
| | | left join product_model pm on pm.id = ifnull(poro.product_model_id, po.product_model_id) |
| | | left join product p on pm.product_id = p.id |
| | | left join ( |
| | | select ppm.production_operation_task_id as taskId, |
| | | sum(ifnull(ppo.scrap_qty, 0)) as scrapQty |
| | | from production_product_main ppm |
| | | left join production_product_output ppo on ppo.production_product_main_id = ppm.id |
| | | group by ppm.production_operation_task_id |
| | | ) scrapStat on scrapStat.taskId = pot.id |
| | | SELECT |
| | | po.id AS productionOrderId, |
| | | po.nps_no AS npsNo, |
| | | po.is_end_order AS endOrder, |
| | | p.product_name AS productName, |
| | | pm.model AS model, |
| | | pm.unit AS unit, |
| | | GROUP_CONCAT(DISTINCT poro.operation_name ORDER BY poro.drag_sort, poro.operation_name SEPARATOR ',') AS operationName, |
| | | COUNT(DISTINCT pot.id) AS productionTaskCount, |
| | | po.quantity AS planQuantity, |
| | | po.complete_quantity AS completeQuantity, |
| | | po.complete_quantity AS goodQuantity, |
| | | SUM(IFNULL(scrapStat.scrapQty, 0)) AS scrapQty, |
| | | ROUND(IFNULL(po.complete_quantity, 0) / NULLIF(po.quantity, 0) * 100, 2) AS completionStatus, |
| | | MAX(poro.type) AS type, |
| | | CASE WHEN SUM(CASE WHEN pot.work_order_no LIKE 'FG%' THEN 1 ELSE 0 END) > 0 |
| | | THEN '返工返修' ELSE '正常' END AS workOrderType, |
| | | GROUP_CONCAT(DISTINCT pot.work_order_no ORDER BY pot.work_order_no SEPARATOR ',') AS workOrderNo, |
| | | MIN(pot.plan_start_time) AS planStartTime, |
| | | MAX(pot.plan_end_time) AS planEndTime, |
| | | MIN(pot.actual_start_time) AS actualStartTime, |
| | | MAX(pot.actual_end_time) AS actualEndTime, |
| | | MAX(pot.status) AS status |
| | | FROM production_operation_task pot |
| | | LEFT JOIN production_order po ON pot.production_order_id = po.id |
| | | LEFT JOIN production_order_routing_operation poro ON pot.production_order_routing_operation_id = poro.id |
| | | LEFT JOIN product_model pm ON pm.id = po.product_model_id |
| | | LEFT JOIN product p ON pm.product_id = p.id |
| | | LEFT JOIN ( |
| | | SELECT ppm.production_operation_task_id AS taskId, |
| | | SUM(IFNULL(ppo.scrap_qty, 0)) AS scrapQty |
| | | FROM production_product_main ppm |
| | | LEFT JOIN production_product_output ppo ON ppo.production_product_main_id = ppm.id |
| | | GROUP BY ppm.production_operation_task_id |
| | | ) scrapStat ON scrapStat.taskId = pot.id |
| | | <where> |
| | | <if test="c != null and c.id != null"> |
| | | and pot.id = #{c.id} |
| | | </if> |
| | | <if test="c != null and c.npsNo != null"> |
| | | and po.nps_no like concat('%', #{c.npsNo}, '%') |
| | | <if test="c != null and c.npsNo != null and c.npsNo != ''"> |
| | | AND po.nps_no LIKE CONCAT('%', #{c.npsNo}, '%') |
| | | </if> |
| | | <if test="c != null and c.productionOrderId != null"> |
| | | and pot.production_order_id = #{c.productionOrderId} |
| | | </if> |
| | | <if test="c != null and c.productionOrderRoutingOperationId != null"> |
| | | and pot.production_order_routing_operation_id = #{c.productionOrderRoutingOperationId} |
| | | </if> |
| | | <if test="c != null and c.status != null"> |
| | | and pot.status = #{c.status} |
| | | </if> |
| | | <if test="c != null and c.isProduction != null"> |
| | | and poro.is_production = #{c.isProduction} |
| | | </if> |
| | | <if test="c != null and c.workOrderNo != null and c.workOrderNo != ''"> |
| | | and pot.work_order_no like concat('%', #{c.workOrderNo}, '%') |
| | | AND pot.production_order_id = #{c.productionOrderId} |
| | | </if> |
| | | </where> |
| | | order by pot.id desc |
| | | GROUP BY po.id |
| | | ORDER BY po.id DESC |
| | | </select> |
| | | |
| | | <!-- 根据订单ID查询工单列表 --> |
| | | <select id="listByOrderId" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo"> |
| | | SELECT |
| | | pot.id, |
| | | pot.work_order_no AS workOrderNo, |
| | | pot.plan_start_time AS planStartTime, |
| | | pot.plan_end_time AS planEndTime, |
| | | pot.actual_start_time AS actualStartTime, |
| | | pot.actual_end_time AS actualEndTime, |
| | | pot.status, |
| | | pot.production_order_id AS productionOrderId, |
| | | pot.plan_quantity AS planQuantity, |
| | | pot.complete_quantity AS completeQuantity, |
| | | po.nps_no AS npsNo, |
| | | po.is_end_order AS endOrder, |
| | | p.product_name AS productName, |
| | | pm.model AS model, |
| | | pm.unit AS unit, |
| | | poro.operation_name AS operationName, |
| | | poro.type AS type, |
| | | CASE WHEN pot.work_order_no LIKE 'FG%' THEN '返工返修' ELSE '正常' END AS workOrderType, |
| | | IFNULL(scrapStat.scrapQty, 0) AS scrapQty, |
| | | ROUND(IFNULL(pot.complete_quantity, 0) / NULLIF(pot.plan_quantity, 0) * 100, 2) AS completionStatus |
| | | FROM production_operation_task pot |
| | | LEFT JOIN production_order po ON pot.production_order_id = po.id |
| | | LEFT JOIN production_order_routing_operation poro ON pot.production_order_routing_operation_id = poro.id |
| | | LEFT JOIN product_model pm ON pm.id = IFNULL(poro.product_model_id, po.product_model_id) |
| | | LEFT JOIN product p ON pm.product_id = p.id |
| | | LEFT JOIN ( |
| | | SELECT ppm.production_operation_task_id AS taskId, |
| | | SUM(IFNULL(ppo.scrap_qty, 0)) AS scrapQty |
| | | FROM production_product_main ppm |
| | | LEFT JOIN production_product_output ppo ON ppo.production_product_main_id = ppm.id |
| | | GROUP BY ppm.production_operation_task_id |
| | | ) scrapStat ON scrapStat.taskId = pot.id |
| | | WHERE pot.production_order_id = #{orderId} |
| | | ORDER BY pot.id DESC |
| | | </select> |
| | | |
| | | <select id="selectTaskStatisticsByDate" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto"> |