3 天以前 f350465db70d6f9db9494483ee0cec7793a9007b
src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml
@@ -22,7 +22,7 @@
        FROM
        sales_ledger_production_accounting t4
        LEFT JOIN sales_ledger T1 ON T1.id = t4.sales_ledger_id
        left join sales_ledger_product t3 on t4.sales_ledger_product_id = t3.id and slp.type = 1
        left join sales_ledger_product t3 on t4.sales_ledger_product_id = t3.id and t3.type = 1
        <where>
            t3.type = 1
            <if test="salesLedgerDto.schedulingUserName != null and salesLedgerDto.schedulingUserName != '' ">
@@ -50,17 +50,11 @@
        group by t4.id
        order by t4.scheduling_date desc
    </select>
    <select id="pageProductionAccounting"
            resultType="com.ruoyi.production.dto.SalesLedgerProductionAccountingDto">
    <select id="pageProductionAccounting" resultType="com.ruoyi.production.dto.SalesLedgerProductionAccountingDto">
        SELECT
        slpa.scheduling_user_id,
        MIN(slpa.scheduling_user_name) AS scheduling_user_name,
        SUM(ppout.quantity) AS output_num,
        SUM(slpa.finished_num * slpa.work_hours) AS wages,
        slpa.scheduling_user_name,
        SUM(COALESCE(prp.quantity, slpa.finished_num)) AS output_num,
        CONCAT(
        ROUND(
        CASE
@@ -69,28 +63,23 @@
        END, 2
        ),
        '%'
        ) AS output_rate,
        GROUP_CONCAT(
        ) AS output_rate, GROUP_CONCAT(
        CONCAT(
        IFNULL(
        TIMESTAMPDIFF(MINUTE, ppm.start_time, ppm.end_time),
        0
        ),
        IFNULL(slpa.work_hour, 0),
        '|$|',
        IFNULL(ppm.device_name, '未知机台')
        IFNULL(dl.device_name, '未知机台')
        )
        ORDER BY ppm.start_time
        ORDER BY slpa.create_time
        SEPARATOR '>>>'
        ) AS device_work_info
        FROM sales_ledger_production_accounting slpa
        LEFT JOIN production_product_main ppm
        ON slpa.product_main_id = ppm.id
        LEFT JOIN production_report_person prp
        ON prp.product_main_id = ppm.id AND prp.user_id = slpa.scheduling_user_id
        LEFT JOIN production_product_output ppout
        ON ppm.id = ppout.product_main_id
        left join device_ledger dl on dl.id = slpa.device_id
        <where>
            <if test="ew.schedulingUserName != null and ew.schedulingUserName !=''">
                and slpa.scheduling_user_name = #{ew.schedulingUserName}
@@ -103,18 +92,16 @@
                and slpa.scheduling_date >= #{ew.entryDateStart}
                and slpa.scheduling_date &lt; DATE_ADD(DATE(#{ew.entryDateEnd}), INTERVAL 1 DAY)
            </if>
        </where>
        GROUP BY slpa.scheduling_user_id
        GROUP BY slpa.scheduling_user_name
    </select>
    <select id="selectDailyWagesStats" resultType="java.util.Map">
        SELECT DATE(ppout.create_time)                                                         AS dateStr,
               SUM(ppout.quantity - IFNULL(ppout.scrap_qty, 0))                                AS numberOfCompleted,
               SUM((ppout.quantity - IFNULL(ppout.scrap_qty, 0)) * IFNULL(pp.salary_quota, 0)) AS amount,
               SUM(ppout.quantity + IFNULL(ppout.add_qty, 0) - IFNULL(ppout.scrap_qty, 0))                                AS numberOfCompleted,
               SUM((ppout.quantity + IFNULL(ppout.add_qty, 0) - IFNULL(ppout.scrap_qty, 0)) * IFNULL(pp.salary_quota, 0)) AS amount,
               ROUND(
                       SUM(ppout.quantity - IFNULL(ppout.scrap_qty, 0)) * 100 / NULLIF(SUM(ppout.quantity), 0),
                       SUM(ppout.quantity + IFNULL(ppout.add_qty, 0) - IFNULL(ppout.scrap_qty, 0)) * 100 / NULLIF(SUM(ppout.quantity), 0),
                       2
               )                                                                               AS passRate
        FROM production_product_output ppout