guoyuji
2024-02-22 7b8cc84950a3caeb8cae5e99a7aa99c1aafa6ac7
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?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.pp.FlowCardMapper">
    <resultMap id="flowCardMap" type="com.example.erp.entity.pp.FlowCard">
        <result column="order_id" property="orderId"/>
        <result column="process_Id" property="processId"/>
        <result column="binning_quantity" property="binningQuantity"/>
        <result column="founder" property="founder"/>
        <result column="create_time" property="createTime"/>
        <!--接收其他外键实体类数据-->
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result column="project" property="project"/>
            <result column="order_id" property="orderId"/>
            <result column="customer_name" property="customerName"/>
            <result column="batch" property="batch"/>
            <result column="other_remarks" property="otherRemarks"/>
            <result column="icon" property="icon"/>
            <result column="order_type" property="orderType"/>
            <result column="salesman" property="salesman"/>
            <result column="processing_note" property="processingNote"/>
            <result column="delivery_address" property="deliveryAddress"/>
        </association>
        <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
            <result column="product_id" property="productId"/>
            <result column="product_name" property="productName"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="processing_note" property="processingNote"/>
            <result column="quantity" property="quantity"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="perimeter" property="perimeter"/>
            <result column="order_number" property="orderNumber"/>
            <result column="width" property="width"/>
            <result column="height" property="height"/>
            <result column="shape" property="shape"/>
            <result column="weight" property="weight"/>
        </association>
        <association property="orderGlassDetail" javaType="com.example.erp.entity.sd.OrderGlassDetail">
            <result column="production_id" property="productionId"/>
        </association>
        <association property="product" javaType="com.example.erp.entity.sd.Product">
            <result column="total_thickness" property="totalThickness"/>
            <result column="thickness" property="thickness"/>
        </association>
 
        <!--<result column="g_typeId" property="glassTypes.typeId"/>
        <result column="g_type" property="glassTypes.type"/>-->
 
    </resultMap>
    <select id="selectFlowCard" resultMap="flowCardMap">
        select
        a.order_Id,
        a.process_Id,
        c.product_id,
        c.product_name,
        b.project,
        a.binning_quantity,
        c.compute_gross_area,
        a.founder,
        c.processing_note
        from flow_card as a left join sd.`order` as b on a.order_Id=b.order_id
        left join sd.order_detail as c on a.order_Id=c.order_id and a.order_Number=c.order_number
        where a.create_time between #{selectTime1} and #{selectTime2}
        <!--        <where>-->
        <!--            <if test="flowCard.orderId != null and flowCard.orderId != ''">-->
        <!--                and a.order_id regexp #{flowCard.orderId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.productionId != null and flowCard.productionId != ''">-->
        <!--                and a.process_Id regexp #{flowCard.productionId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">-->
        <!--                and c.product_id regexp #{flowCard.orderDetail.productId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName!= ''">-->
        <!--                and c.product_name regexp #{flowCard.orderDetail.productName}-->
        <!--            </if>-->
 
        <!--            <if test="flowCard.order.project != null and flowCard.order.project!= ''">-->
        <!--                and b.project regexp #{flowCard.order.project}-->
        <!--            </if>-->
 
 
        <!--            <if test="flowCard.createTime != null and flowCard.createTime != ''">-->
        <!--                and DATE_FORMAT((a.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }-->
        <!--            </if>-->
 
        <!--        </where>-->
        group by a.process_Id;
    </select>
 
 
    <select id="selectFlowCardMp" resultMap="flowCardMap">
        select o.order_id,
        o.customer_name,
        o.project,
        o.batch,
        o.other_remarks,
        o.icon,
        o.order_type,
        o.salesman,
        o.processing_note,
        o.delivery_address
        from sd.`order` as o
        where o.production_order=2 and o.create_time between #{selectTime1} and #{selectTime2}
        <!--        <where>-->
        <!--            <if test="flowCard.orderId != null and flowCard.orderId != ''">-->
        <!--                and a.order_id regexp #{flowCard.orderId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.productionId != null and flowCard.productionId != ''">-->
        <!--                and a.process_Id regexp #{flowCard.productionId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">-->
        <!--                and c.product_id regexp #{flowCard.orderDetail.productId}-->
        <!--            </if>-->
        <!--            <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName!= ''">-->
        <!--                and c.product_name regexp #{flowCard.orderDetail.productName}-->
        <!--            </if>-->
 
        <!--            <if test="flowCard.order.project != null and flowCard.order.project!= ''">-->
        <!--                and b.project regexp #{flowCard.order.project}-->
        <!--            </if>-->
 
 
        <!--        </where>-->
        ;
    </select>
 
    <select id="DetailsSelectMp" resultMap="flowCardMap">
        select od.order_id,
               ogd.production_id,
               od.product_id,
               od.product_name,
               od.quantity,
               od.compute_gross_area,
               od.perimeter
        from sd.order_detail as od
                 left join sd.order_glass_detail as ogd
                           on od.order_id = ogd.order_id
        where od.order_id = #{orderId}
        group by od.order_id, ogd.production_id
    </select>
 
 
    <update id="DeleteFlowCardMp">
        update sd.order_detail as od left join sd.order_glass_detail as ogd
            on od.order_id = ogd.order_id and od.order_number = ogd.order_number
        set ogd.production_id=null,
            ogd.production_time=null,
            ogd.founder=null
        where od.order_id = #{orderId}
          and od.product_name = #{productName}
    </update>
<!--resultMap="flowCardMap"-->
    <select id="SelectNoCardMp" >
        select
        od.order_number AS 'orderNumber',
        od.width,
        od.height,
        od.shape,
        od.quantity,
        od.quantity as baiscQuantity,
        od.compute_gross_area as 'computeGrossArea',
        p.total_thickness AS 'totalThickness',
        p.thickness,
        od.weight
        from
        sd.order_detail as od
        left join sd.order_glass_detail as ogd on od.order_id=ogd.order_id
        left join sd.product as p on od.product_name=p.product_name
        where od.order_id=#{orderId}and ogd.production_id=#{productionId}
        <if test="flowCard.orderDetail.orderNumber != null and flowCard.orderDetail.orderNumber != ''">
            and od.order_number regexp #{flowCard.orderDetail.orderNumber}
        </if>
        <if test="flowCard.orderDetail.width != null and flowCard.orderDetail.width != ''">
            and od.width regexp #{flowCard.orderDetail.width}
        </if>
        <if test="flowCard.orderDetail.height != null and flowCard.orderDetail.height != ''">
            and od.height regexp #{flowCard.orderDetail.height}
        </if>
        <if test="flowCard.orderDetail.shape != null and flowCard.orderDetail.shape != ''">
            and od.shape regexp #{flowCard.orderDetail.shape}
 
        </if>
        GROUP BY od.order_number;
 
 
    </select>
 
</mapper>