2026-06-08 d40729db21c37c342bc938d2aff8947d118a535f
feat(production): 添加生产作业任务分页查询功能

- 新增 pageProductionOperationTask 查询方法支持分页功能
- 实现生产订单、产品信息、工艺路线等多表关联查询
- 添加良品数量、完成率统计及报废数量汇总计算
- 支持按 NPS 编号和生产订单 ID 过滤查询条件
- 完善 groupedProductionOperationTask 查询的条件筛选逻辑
- 优化数据聚合分组和排序规则配置
已修改1个文件
50 ■■■■ 文件已修改
src/main/resources/mapper/production/ProductionOperationTaskMapper.xml 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
@@ -58,7 +58,41 @@
        ) scrapStat on scrapStat.taskId = pot.id
    </sql>
    <sql id="groupedProductionOperationTaskWhere">
    <select id="pageProductionOperationTask" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo">
        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.npsNo != null and c.npsNo != ''">
                and po.nps_no like concat('%', #{c.npsNo}, '%')
@@ -67,18 +101,20 @@
                and pot.production_order_id = #{c.productionOrderId}
            </if>
        </where>
    </sql>
    <select id="pageProductionOperationTask" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo">
        <include refid="groupedProductionOperationTaskSelect"/>
        <include refid="groupedProductionOperationTaskWhere"/>
        group by po.id
        order by po.id desc
    </select>
    <select id="listGroupedProductionOperationTask" resultType="com.ruoyi.production.bean.vo.ProductionOperationTaskVo">
        <include refid="groupedProductionOperationTaskSelect"/>
        <include refid="groupedProductionOperationTaskWhere"/>
        <where>
            <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>
        </where>
        group by po.id, po.nps_no, po.is_end_order, p.product_name, pm.model, pm.unit
        order by po.id desc
    </select>