liyong
2026-04-29 844cae1a3be7bd2fbf8803a7ee33b0622208de05
fix(production): 修复生产报表数据查询问题

- 修改SQL映射文件中的字段引用,使用正确的设备表关联
- 将work_hours字段改为work_hour并重命名为work_minutes
- 添加totalWorkMinutes字段到SalesLedgerProductionAccountingDto
- 修复设备名称查询逻辑,从device_ledger表获取正确数据
- 调整分组条件从scheduling_user_id改为scheduling_user_name
- 优化设备工作信息排序逻辑,使用create_time替代start_time
已修改3个文件
38 ■■■■■ 文件已修改
src/main/java/com/ruoyi/production/dto/SalesLedgerProductionAccountingDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionProductMainMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/SalesLedgerProductionAccountingDto.java
@@ -83,6 +83,8 @@
    private String outputRate;
    private Long totalWorkMinutes;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate entryDate;
src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -78,8 +78,8 @@
        ppo.quantity,
        slpa.work_hours,
        slpa.work_hours * slpa.finished_num AS wages,
        ppm.device_name,
        ppm.device_id,
        dl.device_name,
        slpa.work_hour as work_minutes,
        IFNULL(
        TIMESTAMPDIFF(MINUTE, ppm.start_time, ppm.end_time),
        0
@@ -94,6 +94,7 @@
        LEFT JOIN product_model pm ON po.product_model_id = pm.id
        LEFT JOIN product p ON p.id = pm.product_id
        LEFT JOIN sales_ledger sl ON po.sales_ledger_id = sl.id
        left join device_ledger dl ON dl.id = slpa.device_id
        where ppm.audit_status = 1
            <if test="ew.schedulingUserName != null and ew.schedulingUserName !=''">
                and slpa.scheduling_user_name = #{ew.schedulingUserName}
src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml
@@ -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,
        slpa.scheduling_user_name,
        SUM(ppout.quantity) AS output_num,
        SUM(slpa.finished_num * slpa.work_hours) AS wages,
        CONCAT(
        ROUND(
        CASE
@@ -69,28 +63,21 @@
        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_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,10 +90,8 @@
                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">