chenlu
2024-02-23 92f00c92b4e6c1c61ce8461d9b72fd2969e66802
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
<?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.WorkOrderMapper">
    <resultMap id="wordOrderMap" type="com.example.erp.entity.sd.OrderGlassDetail">
 
        <result column="order_id" property="orderId"/>
        <result column="production_id" property="productionId"/>
        <result column="splitting_status" property="splittingStatus"/>
        <result column="create_time" property="createTime"/>
        <!--接收其他外键实体类数据-->
        <association property="order" javaType="com.example.erp.entity.sd.Order">
            <result column="batch" property="batch"/>
        </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_area" property="computeArea"/>
            <result column="quantity" property="quantity"/>
            <result column="compute_gross_area" property="computeGrossArea"/>
            <result column="perimeter" property="perimeter"/>
            <result column="bend_radius" property="bendRadius"/>
            <result column="processing_note" property="processingNote"/>
        </association>
 
        <!--<result column="g_typeId" property="glassTypes.typeId"/>
        <result column="g_type" property="glassTypes.type"/>-->
 
    </resultMap>
    <select id="selectWordOrder" resultMap="wordOrderMap">
        select
        o.order_id,
        ogd.production_id,
        o.batch,
        od.product_name,
        od.compute_area,
        od.quantity,
        od.compute_gross_area,
        od.perimeter,
        od.bend_radius,
        od.processing_note
 
        from `order` as o left join order_detail as od on o.order_id=od.order_id
        left join order_glass_detail as ogd on o.order_id=ogd.order_id and ogd.order_number=od.order_number
        where isnull(ogd.production_id) and o.order_review=2 and o.production_order!=2
            <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
                and o.order_id regexp #{orderGlassDetail.orderId}
            </if>
            <if test="orderGlassDetail.productionId != null and orderGlassDetail.productionId != ''">
                and ogd.production_id regexp #{orderGlassDetail.productionId}
            </if>
            <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
                and o.batch regexp #{orderGlassDetail.order.batch}
            </if>
            <if test="orderGlassDetail.orderDetail.productName != null and orderGlassDetail.orderDetail.productName!= ''">
                and od.product_name regexp #{orderGlassDetail.orderDetail.productName}
            </if>
 
            <if test="orderGlassDetail.createTime != ''">
                and DATE_FORMAT((ogd.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
            </if>
 
        group by o.order_id
        order by o.id desc
 
 
        ;
    </select>
 
    <select id="selectWordOrderNo" resultMap="wordOrderMap">
        select
        o.order_id,
        ogd.production_id,
        o.batch,
        od.product_name,
        od.compute_area,
        od.quantity,
        od.compute_gross_area,
        od.perimeter,
        od.bend_radius,
        od.processing_note
 
        from `order` as o left join order_detail as od on o.order_id=od.order_id
        left join order_glass_detail as ogd on o.order_id=ogd.order_id and ogd.order_number=od.order_number
        where ogd.production_id IS NOT NULL
        <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
            and ogd.order_id regexp #{orderGlassDetail.orderId}
        </if>
        <if test="orderGlassDetail.productionId != null and orderGlassDetail.productionId != ''">
            and ogd.production_id regexp #{orderGlassDetail.productionId}
        </if>
        <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
            and o.batch regexp #{orderGlassDetail.order.batch}
        </if>
        <if test="orderGlassDetail.orderDetail.productName != null and orderGlassDetail.orderDetail.productName!= ''">
            and od.product_name regexp #{orderGlassDetail.orderDetail.productName}
        </if>
 
        <if test="orderGlassDetail.createTime != ''">
            and DATE_FORMAT((ogd.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
        </if>
 
        group by ogd.production_id,ogd.order_number
        order by ogd.id desc
 
 
        ;
    </select>
 
    <select id="addWordOrder" >
        select od.order_id,
        od.product_id,
        od.product_name,
        sum( od.quantity) as quantity,
        od.compute_gross_area,
        od.perimeter
        from sd.order_detail as od
        left join sd.order as o
        on od.order_id =o.order_id
        where od.order_id = #{orderId}  and  o.production_order!=2
        <if test="orderDetail.orderId != null and orderDetail.orderId != ''">
            and od.order_id regexp #{orderDetail.orderId}
        </if>
        <if test="orderDetail.productId != null and orderDetail.productId != ''">
            and od.product_id regexp #{orderDetail.productId}
        </if>
        <if test="orderDetail.productName != null and orderDetail.productName != ''">
            and od.product_name regexp #{orderDetail.productName}
        </if>
        group by od.order_id, od.product_id, od.product_name
        ;
    </select>
 
    <select id="SelectOrderNumber" >
        select ifnull(count(ogd.production_id),0)
        from sd.order_glass_detail as ogd
        where ogd.production_id = #{productIdVl}
    </select>
 
    <update id="AddOrderWorkMp" >
        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=#{productIdVl},
            ogd.production_time=NOW(),
            ogd.founder=#{userName}
 
        where od.order_id = #{orderId}
          and od.product_id =#{productId}
          and od.product_name = #{productName}
    </update>
 
<!--    删除工单-->
    <update id="DeleteOrderWorkMp">
        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>
 
    <select id="SelectWorkCount">
        select COUNT(distinct order_number)
        from order_glass_detail
        where ISNULL(production_id)
          and order_id = #{orderId}
    </select>
 
    <select id="SelectYesWorkCount">
        select COUNT(distinct order_number)
        from order_glass_detail
        where  order_id = #{orderId}
    </select>
 
    <update id="UpdateWorkType">
        update sd.order as o set o.production_order=#{state} where o.order_id=#{orderId}
    </update>
</mapper>