chenhj
2026-04-22 2ab6b6860e4f7bee67a0f66831b9b1fb0f420710
src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
@@ -21,4 +21,68 @@
        <result column="dept_id" property="deptId" />
    </resultMap>
    <select id="selectTaskStatisticsByDate" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto">
        select pot.id,
               pot.work_order_no,
               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.plan_quantity as planQuantity,
               ifnull(pot.complete_quantity, 0) as completeQuantity,
               top2.name as processName,
               p.product_name as productName,
               pm.model,
               pm.unit,
               po.nps_no as productOrderNpsNo
        from production_operation_task pot
                 left join production_order po on pot.production_order_id = po.id
                 left join product_model pm on po.product_model_id = pm.id
                 left join product p on pm.product_id = p.id
                 left join technology_routing_operation tro on pot.technology_routing_operation_id = tro.id
                 left join technology_operation top2 on tro.technology_operation_id = top2.id
        where date(pot.create_time) between #{startDate} and #{endDate}
        order by pot.create_time desc
    </select>
    <select id="selectTaskStartStats" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto">
        select id,
               actual_start_time as actualStartTime,
               plan_quantity as planQuantity
        from production_operation_task
        where actual_start_time &gt;= #{startDateTime}
          and actual_start_time &lt;= #{endDateTime}
    </select>
    <select id="calculateProductionStatistics" resultType="com.ruoyi.home.dto.processDataProductionStatisticsDto">
        select top2.name as processName,
               sum(ifnull(ppi.input_quantity, 0)) as totalInput,
               sum(ifnull(ppo.scrap_qty, 0)) as totalScrap,
               sum(ifnull(ppo.quantity, 0) - ifnull(ppo.scrap_qty, 0)) as totalOutput
        from production_product_output ppo
                 inner join production_product_main ppm on ppo.production_product_main_id = ppm.id
                 inner join production_operation_task pot on ppm.production_operation_task_id = pot.id
                 inner join technology_routing_operation tro on pot.technology_routing_operation_id = tro.id
                 inner join technology_operation top2 on tro.technology_operation_id = top2.id
                 left join production_product_input ppi on ppi.production_product_main_id = ppm.id
        <where>
            <if test="startDateTime != null">
                and ppo.create_time &gt;= #{startDateTime}
            </if>
            <if test="endDateTime != null">
                and ppo.create_time &lt;= #{endDateTime}
            </if>
            <if test="userId != null">
                and ppm.create_user = #{userId}
            </if>
            <if test="processIds != null and processIds.size() > 0">
                and top2.id in
                <foreach collection="processIds" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        group by top2.id, top2.name
    </select>
</mapper>