tuqin
9 小时以前 2c4bc1808f272b7d7282d1b8ba416d606ebc7df5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.production.mapper.ProductionCostingMapper">
 
    <select id="selectCostingRows" resultType="com.ruoyi.production.bean.vo.ProductionCostingRawVo">
        select
            ppm.user_id                              as staffId,
            ppm.user_name                            as staffName,
            date_format(ppm.create_time, '%Y-%m')    as yearMonth,
            too.id                                   as processId,
            too.name                                 as processName,
            cp.dept_type                             as deptType,
            ppo.product_model_id                     as productModelId,
            p.product_name                           as productName,
            pm.model                                 as modelName,
            sum(ifnull(ppo.quantity, 0))             as quantity
        from production_product_main ppm
        inner join production_operation_task pot on pot.id = ppm.production_operation_task_id
        inner join production_order_routing_operation poro on poro.id = pot.production_order_routing_operation_id
        inner join technology_operation too on too.id = poro.technology_operation_id
        inner join production_costing_process cp on cp.process_id = too.id
        inner join production_product_output ppo on ppo.production_product_main_id = ppm.id
        left join product_model pm on pm.id = ppo.product_model_id
        left join product p on p.id = pm.product_id
        <where>
            ppm.audit_status = 1
            and ppm.report_type in (0, 1)
            <if test="c != null">
                <if test="c.deptType != null">
                    and cp.dept_type = #{c.deptType}
                </if>
                <if test="c.yearMonth != null and c.yearMonth != ''">
                    and date_format(ppm.create_time, '%Y-%m') = #{c.yearMonth}
                </if>
                <if test="c.staffName != null and c.staffName != ''">
                    and ppm.user_name like concat('%', #{c.staffName}, '%')
                </if>
                <if test="c.processId != null">
                    and too.id = #{c.processId}
                </if>
            </if>
        </where>
        group by ppm.user_id, ppm.user_name, yearMonth, too.id, too.name, cp.dept_type, ppo.product_model_id, p.product_name, pm.model
        order by yearMonth desc, ppm.user_id, too.id
    </select>
 
</mapper>