廖井涛
2024-03-15 5a5e59f8aaa2a030511ef245886bf6d1db9bf774
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?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.example.erp.mapper.sd.OrderProcessDetailMapper">
 
    <insert id="insertOrderProcessDetail" >
        insert into
            order_process_detail(
                order_id,
                order_number,
                technology_number,
                process,
                process_id
            )
        values
        <foreach collection ="processDetailList" item="processDetail" separator =",">
            (
             #{processDetail.orderId},
             #{processDetail.orderNumber},
             #{processDetail.technologyNumber},
             #{processDetail.process},
              #{processDetail.processId}
             )
        </foreach>
 
 
    </insert>
    <update id="updateQuantity">
        update sd.order_process_detail as a
        inner join
        (select
             rwd.completed_quantity,
             rwd.breakage_quantity,
             rw.process_id,
             rwd.order_number,
             rwd.technology_number
              from pp.reporting_work_detail as rwd
            left join pp.reporting_work as rw
                on rwd.reporting_work_id =  rw.reporting_work_id
            where rwd.reporting_work_id =#{reportingWorkId} )  as b
        on a.process_id = b.process_id
        and a.order_number = b.order_number
        and a.technology_number = b.technology_number
 
        <if test="type == 'delete'">
            set a.reporting_work_num_count
                = a.reporting_work_num_count-b.completed_quantity,
 
            a.reporting_work_num
                = a.reporting_work_num-b.completed_quantity,
 
            a.broken_num
                = a.broken_num-b.breakage_quantity
        </if>
 
        <if test="type == 'add'">
            set a.reporting_work_num_count
            = a.reporting_work_num_count+b.completed_quantity,
 
            a.reporting_work_num
            = a.reporting_work_num+b.completed_quantity,
 
            a.broken_num
            = a.broken_num+b.breakage_quantity
        </if>
 
        where a.process = #{process}
 
    </update>
 
</mapper>