huang
2024-11-26 45f64d8b130c57ff2b8e8442d65ab7a490e915e3
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?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.GlassOptimizeMapper">
    <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="founder" property="founder"/>
        <result column="create_time" property="createTime"/>
        <!--接收其他外键实体类数据-->
        <result column="batch" property="order.batch"/>
        <result column="order_type" property="order.orderType"/>
        <result column="project" property="order.project"/>
        <result column="area" property="order.area"/>
        <result column="creator" property="order.creator"/>
        <result column="customer_name" property="order.customerName"/>
        <result column="processing_note" property="order.processingNote"/>
        <!--        <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="orderDetail.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"/>-->
        <result column="gross_area" property="orderDetail.grossArea"/>
 
        <!--        </association>-->
 
    </resultMap>
    
    <resultMap id="optimizeProjectMangeMap" type="com.example.erp.entity.pp.OptimizeProjectMange">
        <result property="id" column="id"/>
        <result property="projectNumber" column="project Number"/>
        <result property="projectName" column="project Name"/>
        <result property="glassType" column="glass Type"/>
        <result property="thickness" column="thickness"/>
        <result property="type" column="type"/>
        <result property="state" column="state"/>
        <result property="quantity" column="quantity"/>
        <result property="area" column="area"/>
        <result property="processCardQuantity" column="process Card Quantity"/>
        <result property="usingQuantity" column="using Quantity"/>
        <result property="temperedLoadingRate" column="tempered loading rate"/>
        <result property="numberOfTemperingFurnaces" column="number of tempering furnaces"/>
        <result property="averageCuttingRate" column="average cutting rate"/>
        <result property="effectiveCuttingRate" column="effective cutting rate"/>
        <result property="residueGlassCuttingRate" column="residue glass cutting rate"/>
        <result property="processCardCollection" column="process card collection"/>
        <result property="averageCuttingRate1" column="average cutting rate1"/>
        <result property="notes" column="notes"/>
        <result property="creator" column="creator"/>
        <result property="createTime" column="create time"/>
        <result property="modifyTime" column="modify time"/>
    </resultMap>
 
    <select id="selectWordOrder" resultMap="wordOrderMap">
        select
        o.order_id,
        o.batch,
        o.project,
        o.order_type,
        o.area as gross_area,
        o.quantity as quantity,
        o.creator,
        o.customer_name,
        o.processing_note
        from sd.order_detail as od
        left join `order` as o
        on o.order_id=od.order_id
        where o.production_order!=2 and o.order_review=2
 
        <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
            and o.order_id regexp #{orderGlassDetail.orderId}
        </if>
 
        <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
            and o.batch regexp #{orderGlassDetail.order.batch}
        </if>
        <if test="orderGlassDetail.order.project != null and orderGlassDetail.order.project!= ''">
            and o.project regexp #{orderGlassDetail.order.project}
        </if>
        <if test="orderGlassDetail.order.orderType != null and orderGlassDetail.order.orderType!= ''">
            and o.order_type regexp #{orderGlassDetail.order.orderType}
        </if>
        <if test="orderGlassDetail.order.customerName != null and orderGlassDetail.order.customerName!= ''">
            and o.customer_name regexp #{orderGlassDetail.order.customerName}
        </if>
        <if test="orderGlassDetail.order.processingNote != null and orderGlassDetail.order.processingNote!= ''">
            and o.processing_note regexp #{orderGlassDetail.order.processingNote}
        </if>
 
        <if test="orderGlassDetail.createTime != ''">
            and DATE_FORMAT((o.create_time),'%Y-%m-%d') BETWEEN #{ selectTime1 } AND #{ selectTime2 }
        </if>
 
        group by o.order_id
        order by o.id desc
 
 
        ;
    </select>
 
    <select id="getFlowCardListMp">
        select fc.process_id,
               fc.technology_number,
               fcss.TotalFloors,
               COUNT(fc.order_number)                                      as TotalNumber,
               SUM(fc.quantity)                                            as quantity,
               ROUND(SUM(od.width * od.height * fc.quantity / 1000000), 2) as area,
               o.project,
               ogd.glass_child,
               od.shape
 
        from pp.flow_card as fc
                 left join sd.`order` as o on fc.order_id = o.order_id
                 left join sd.order_detail as od on od.order_id = fc.order_id and od.order_number = fc.order_number
                 left join sd.order_glass_detail as ogd
                           on ogd.order_id = fc.order_id and ogd.order_number = fc.order_number and
                              ogd.technology_number = fc.technology_number
                 left join (select fcs.process_id,
                                   fcs.order_number,
                                   COUNT(DISTINCT fcs.technology_number) as TotalFloors
                            from pp.flow_card as fcs
                            GROUP BY fcs.process_id, fcs.order_number) as fcss
                           on fcss.process_id = fc.process_id and fcss.order_number = fc.order_number
        where position(#{optionVal} in ogd.glass_child)
        GROUP BY fc.process_id, fc.technology_number
        ORDER BY fc.process_id, fc.technology_number
    </select>
 
    <select id="optimizeProjectMangeMp"  resultMap="optimizeProjectMangeMap">
        select p.`id`                                AS `id`,
               p.`project_no`                        AS `Project Number`,
               p.`project_name`                      AS `Project Name`,
               p.`glass_type`                        AS `Glass Type`,
               p.`glass_thickness`                   AS `Thickness`,
               p.`type`                              AS `Type`,
               p.`state`                             AS `State`,
               p.`glass_total`                       AS `Quantity`,
               p.`glass_total_area`                  AS `Area`,
               p.`process_qty`                       AS `Process Card Quantity`,
               p.`raw_stock_qty`                     AS `Using Quantity`,
               concat((`p`.`load_rate` * 100), ' %') AS `Tempered loading rate`,
               `p`.`furnaces_qty`                    AS `Number of tempering furnaces`,
               concat(`p`.`avg_cut_pct`, ' %')       AS `Average cutting rate`,
               concat(`p`.`valid_cut_pct`, ' %')     AS `Effective cutting rate`,
               concat(`p`.`last_cut_pct`, ' %')      AS `Residue glass cutting rate`,
               `p`.`process_cards`                   AS `Process card collection`,
               `p`.`frist_stock_qty`                 AS `Amount of original glass usage 1`,
               concat(`p`.`frist_cut_pct`, ' %')     AS `Average cutting rate 1`,
               `p`.`remark`                          AS `Notes`,
               `a`.`name`                            AS `Creator`,
               `p`.`create_time`                     AS `Create time`,
               `p`.`update_time`                     AS `Modify time`
        from pp.optimize_project as p
                 left join pp.optimize_admin as a on p.creater = a.Id
        where (`p`.`state` > -(1))
            and DATE (`p`.`create_time`) BETWEEN #{startSelectTime} AND #{endSelectTime}
        <if test="optimizeProjectMange.projectNumber != null and optimizeProjectMange.projectNumber != ''">
            and p.project_no regexp #{optimizeProjectMange.projectNumber}
        </if>
        <if test="optimizeProjectMange.state!= null">
            and p.state = #{optimizeProjectMange.state}
        </if>
        order by `p`.`create_time` desc, `p`.`project_no`
    </select>
    <!--修改工程状态-->
    <update id="updateProjectStateMp">
        update pp.optimize_project as p
        set p.state = #{state}
        where p.project_no = #{projectNumber}
    </update>
 
    <!--删除工程-->
    <delete id="deleteProjectMp">
        delete from pp.optimize_project
        where project_no = #{projectNumber}
    </delete>
 
    <select id="getProjectListMp">
        SELECT
            p.id,
            p.project_no,
            p.project_name,
            p.glass_type,
            p.glass_thickness,
            p.type,
            p.state,
            p.glass_total,
            p.glass_total_area,
            p.process_qty,
            p.process_cards,
            p.remark,
            a.name,
            p.create_time,
            p.update_time
        FROM
            (
                pp.optimize_project p
                    LEFT JOIN pp.optimize_admin a ON ((
                    p.creater = a.Id
                    )))
        WHERE
            ( p.state = 1 )
        ORDER BY
            p.create_time DESC,
            p.project_no
    </select>
 
</mapper>