廖井涛
2025-05-26 3a975df5b368bc68ee7a81d34920b209f2ff607b
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<%@page import="com.northglass.Globel.mes"%>
<%@page import="com.northglass.SqlHelper.*"%>
<%@page import="org.json.*"%>
<%@ page contentType="text/json;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    //String yemian = request.getParameter("gongyi");
    String line = request.getParameter("line");
    String caozuo = request.getParameter("caozuo");
    String leixing = request.getParameter("leixing");
    String Id = request.getParameter("Id");
    String gongyi = request.getParameter("gongyi");
    String lckh = request.getParameter("lckh");
    DBSession sn = null;
    boolean ok = false;
    //System.out.println("操作类型:" + leixing + ";工艺:" + gongyi+";操作:"+caozuo);
    try {
 
        sn = mes.getMesDBHelper().createSession(false);
        String strSQL = "";
        if ("查询".equals(caozuo)) {
            if ("磨边开合查询".equals(leixing)) {
                String stime = request.getParameter("stime");
                String etime = request.getParameter("etime");
                String trigger = request.getParameter("trigger");
                String Edg = request.getParameter("Edg");
                String banzu = request.getParameter("banzu");
                String gby="";
                //String isdb = request.getParameter("isdb");
                System.out.println(etime);
                /* if("".equals(etime)||etime==null){
                    etime="Now()";
                }else{
                    etime="'"+etime+"'";
                } */
                if("".equals(Edg)||Edg==null||"0".equals(Edg)){
                    Edg="width,height,SendTime,Line,count(*) as piece,ifnull(banzu,'')";
                    gby="Recordsid";
                }else if("1".equals(Edg)){
                    Edg="width,SendTime,Line,ifnull(banzu,''),count(*) as piece";
                    gby="RecordsidW";
                }else if("2".equals(Edg)){
                    Edg="height,SendTime,Line,ifnull(banzu,''),count(*) as piece";
                    gby="RecordsidH";
                }
                
                if("".equals(banzu)||banzu==null||"0".equals(banzu)){
                    banzu="";
                }else{
                    banzu=" banzu='"+banzu+"' and";
                }
                if("1".equals(trigger)){//查询
                    strSQL = "select "+Edg+" from Y_Edg_Statistics"+
                             " where Line="+line+" and "+banzu+" SendTime>='"+stime+"' and SendTime<='"+etime+"'"+
                             " GROUP BY "+gby;
                }else{//默认
                    strSQL ="select width,height,SendTime,Line,count(*) as piece,ifnull(banzu,'') from Y_Edg_Statistics"+
                             " where Line="+line+" and SendTime>=CONCAT(DATE_FORMAT(Now(),'%Y-%m-%d'),' 00:00:00') and SendTime<=CONCAT(DATE_FORMAT(Now(),'%Y-%m-%d'),' 23:59:59')"+
                             " GROUP BY Recordsid";
                }
                System.out.println(strSQL);
                
            }
            if ("次破类型".equals(leixing)) {
                strSQL = "select id,cipoleixing from cipoleixing";
            }
            if ("次破原因".equals(leixing)) {
                strSQL = "select xuhao,cipoyuanyin,cipoleixing from cipoyuanyin";
            }
            if ("班组列表".equals(leixing)) {
                String gy = gongyi.contains("钢化") ? "钢化" : gongyi;
                strSQL = "select banzumingcheng from banzu where gongyi='" + gongyi + "'";
            }
            if ("当前班组".equals(leixing)) {
                gongyi = gongyi.contains("钢化") ? "钢化" : gongyi;
                strSQL = "select banzu,isPaused from gmms_user_current where gongyi= '" + gongyi + "' and chanxian = "
                        + line;
            }
            if ("流程卡详情".equals(leixing)) {
 
                if ("钢化".equals(gongyi)) {
                    strSQL = "select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_2 where  processcard_id = '"
                            + lckh + "' order by stop_rank";
                }else if("磨边".equals(gongyi)){
                    strSQL="SELECT a.processcard_id,b.stop_rank,a.id,a.edg_width,a.edg_height,concat( a.thickness, 'mm ', a.color ) moxi, b.work_procedure,"+
                             "if((select count(1) from e_pierceds where glass_id = a.id)>0 ,'破损',b.work_state) as state,a.Id,if((select count(1) from e_record_stock where glass_id = a.id)>0 ,1,0) as isReport FROM gmms_galss_task_buffer a LEFT JOIN gmms_galss_task_details b ON a.id = b.id"+ 
                             " WHERE a.processcard_id = '"+lckh+"' ORDER BY b.stop_rank desc;";        
                }else if("仓储".equals(gongyi)){
                    strSQL="select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_shelf where  processcard_id = '"
                            + lckh + "' order by stop_rank";        
                }else if("仓储配对".equals(gongyi)){
                    strSQL="select gb.processcard_id,count(gb.id) as pricesz,count(gs.id) as prices,gb.edg_width,gb.edg_height,concat(gb.thickness,'mm ',gb.color) as moxi from gmms_galss_task_buffer as gb"  
                            +" left join gmms_galss_task_shelf as gs on gs.id=gb.id"
                            +" where  gb.processcard_id = '"+lckh+"' group by gb.edg_width,gb.edg_height,gb.thickness,gb.color order by gb.edg_width";        
                } else {
                    strSQL = "select processcard_id,stop_rank,galss_id,edg_width,edg_height,concat(thickness,'mm ',color) moxi,work_procedure,work_state,Id from gmms_galss_task_shelf where  processcard_id = '"
                            + lckh + "' order by stop_rank";
                }
                
            }
            if("全部班组".equals(leixing)){
                strSQL="select gongxu,banzumingcheng from banzu group by gongxu,banzumingcheng order by gongxu desc";
            }
            if("报工详情".equals(leixing)){
                //strSQL="select null, processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id ) as '破损数',count(1) as '完成数' ,concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间' from e_record_stock s where is_report = 0 and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)";
                /* strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id ) as '破损数', "+
                "(select IFNULL(sum(tb.edg_width*tb.edg_height),0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id) as '破损平方', "+
                "count(1) as '完成数' ,IFNULL(sum(bf.edg_width*bf.edg_height)/1000000,0) as '完成平方', "+
                "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间' from e_record_stock s  left join gmms_galss_task_buffer as bf on s.glass_id=bf.id where is_report = 0 and line = 3 group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)";
             */
                 strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id and process='磨边' and is_report!=-1) as '破损数', "+
                     "count(1) as '完成数' , "+
                     "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间', "+
                     "(select IFNULL(sum(tb.edg_width*tb.edg_height)/1000000,0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id and process='磨边' and is_report!=-1) as '破损平方',IFNULL(sum(bf.edg_width*bf.edg_height)/1000000,0) as '完成平方' from e_record_stock s  left join gmms_galss_task_buffer as bf on s.glass_id=bf.id where is_report = 0 and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color) ";
            
            }
            if("钢化报工详情".equals(leixing)){
                 strSQL="select null, s.processcard_id,(select count(1) from e_pierceds p where p.processcard_id =s.processcard_id and process='钢化' and is_report!=-1) as '破损数',  "+
                         "count(1) as '完成数' ,  "+
                         "concat(s.thinkess,s.color) as '膜系', max(s.create_time) as '完成时间', "+
                         "(select IFNULL(sum(tb.edg_width*tb.edg_height)/1000000,0) from e_pierceds p LEFT JOIN gmms_galss_task_buffer as tb on p.glass_id=tb.id where p.processcard_id =s.processcard_id and process='钢化' and is_report!=-1) as '破损平方',IFNULL(sum(s.width*s.height)/1000000,0) as '完成平方' from e_record_tempering s where is_report != 4 and report_time is null and line = "+line+" group by s.processcard_id,s.team_name,concat(s.thinkess,s.color)";        
            }
            if ("次破列表".equals(leixing)) {
                String info = request.getParameter("cpInfo");
                //System.out.println("传入数据:"+info);
                //工艺,班组
                String[] s = info.split("-");
                if("0".equals(s[2])){
                    strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1";
                }if("1".equals(s[2])){
                    strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report = 0";
                }if("2".equals(s[2])){
                    //strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and pierced_cause is null and is_report !=-1";    
                    strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1";
                }if("3".equals(s[2])){
                    strSQL = "select * from v_cipo where process = '"+s[0]+"' and team_name = '"+s[1]+"' and is_report !=-1";                    
                }
            }
            if("空架".equals(leixing)){
                
                strSQL="select r.id,f.rank from gmms_drop_frame_5 f left join gmms_shelf_rack_2 r on f.rank =r.id  where f.groups_ = 100 and f.stops <21 and f.rank is not null and r.processcard_id is null";
            }
            if("仓储配对信息".equals(leixing)){
                
                strSQL="select * from v_cc_cpinfo";
            }
            if("所有膜系".equals(leixing)){
                strSQL ="SELECT DISTINCT(glass_id) FROM `gmms_glass_number_color` ";
            }
            
            //System.out.println("信息查询:" + strSQL);
            if("切割工位模式".equals(leixing)){
                
                strSQL="select gongwei_mode from gmms_prod_line_state where line ="+line;
            }
            if("可钢化膜系".equals(leixing)){
                strSQL ="select moxi from v_ghq_liuchengka group by moxi order by count(1) desc";
                
            }
            if("切割原片详情".equals(leixing)){
                strSQL ="select null,width,height,thickness,color,batch_id,sum(pieces),dengluname from gmms_cutmanage where groups ="+line+" and BgTime is null "+
                        "group by width,height,thickness,color,batch_id,dengluname";
                
            }
            if ("理片笼单双片模式".equals(leixing)) {
                strSQL = "select lipianlong_mode from gmms_prod_line_state where line =" + line;
            }
            if ("原片库存图".equals(leixing)) {
                strSQL = "select sr.id,sr.create_time,sr.mod_time,rp.pieces,rp.left_pieces,rp.create_time, "+
                         "(CASE WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<3 THEN  "+
                         "            0  "+
                         "        WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<5 THEN  "+
                         "          1  "+
                         "        WHEN TO_DAYS(NOW())-TO_DAYS(rp.create_time)<8 THEN  "+
                         "          2  "+
                         "        ELSE  "+
                         "            3  "+
                         "    END) as datetype,CONCAT(IFNULL(rp.raw_width,0),'mm'),CONCAT(IFNULL(rp.raw_height,0),'mm'),CONCAT(IFNULL(rp.raw_thickness,0),'mm'),rp.color,rp.batch_id from gmms_shelf_rack as sr left join gmms_raw_package as rp on sr.raw_package_id1=rp.id where sr.raw_package_id1 is not null";
            }
            if ("切裁率图-原片使用".equals(leixing)) {
                strSQL = "select IFNULL(SUM(gc.width*gc.height)/1000000,0) from "+
                         "(SELECT DATE_FORMAT(DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL (CAST(help_topic_id AS SIGNED INTEGER)) DAY),'%Y-%m-%d') month "+
                         "FROM mysql.help_topic WHERE help_topic_id < 14 ORDER BY month ASC) as d "+
                         "left JOIN gmms_cutmanage as gc on d.month=DATE_FORMAT(gc.BgTime,'%Y-%m-%d') group by d.month;";
            }
            if ("切裁率图-原片使用当月".equals(leixing)) {
                strSQL = "select IFNULL(SUM(width*height)/1000000,0),IFNULL(DATE_FORMAT(BgTime,'%Y-%m'),DATE_FORMAT(NOW(),'%Y-%m-01')) from gmms_cutmanage where BgTime>DATE_FORMAT(NOW(),'%Y-%m-01');";
            }
            if ("单炉最大装载率-面积最大比例差".equals(leixing)) {
                strSQL = "select IFNULL(maxLoadingRate,0),IFNULL(maxTolerance,0) from gmms_furnace where id="
                        + line;
            }
            if ("单炉最大面积比例差".equals(leixing)) {
                strSQL = "select IFNULL(maxTolerance,0) from gmms_furnace where id="
                        + line;
            }
            sn.createSql(strSQL);
            JSONArray a = sn.query().resultToJson(false);
            if (a != null) {
                out.print(a.toString());
            } else {
                out.print("[]");
            }
        }
 
        if ("修改".equals(caozuo)) {
            if ("变更班组".equals(leixing)) {
                String bzinfo = request.getParameter("info");
                strSQL = "update gmms_user_current set banzu = '" + bzinfo + "',isPaused=null where gongyi = '" + gongyi
                        + "' and chanxian = " + line;
            }
            if("次破".equals(leixing)){
                String info = request.getParameter("cpInfo");
                //次破类型,次破原因
                String[] s = info.split("-");
                strSQL="Update e_pierceds set pierced_type = '"+s[0]+"',pierced_cause = '"+s[1]+"' where glass_id = "+Id;
            }
            if("提交报工".equals(leixing)){
                String info = request.getParameter("cpInfo");
                //次破类型,次破原因
                String[] s = info.split("-");
                strSQL="Update e_pierceds set is_report = 1 where process = '"+s[0]+"' and team_name = '"+s[1]+"' and  pierced_type is not null and is_report=0";
                
            }
            if("班组下班".equals(leixing)){
                strSQL = "update gmms_user_current set banzu = null where gongyi = '" + gongyi+ "' and chanxian = " + line;
            }            
            //System.out.println("修改:" + strSQL);
            if("变更切割工位模式".equals(leixing)){
                strSQL="update gmms_prod_line_state set gongwei_mode= if(gongwei_mode=1,2,1) where line ="+line;
            }
            if ("变更理片笼单双片模式".equals(leixing)) {
                strSQL = "update gmms_prod_line_state set lipianlong_mode= if(lipianlong_mode=1,2,1) where line ="
                        + line;
            }
            if ("单炉最大装载率".equals(leixing)) {
                String value = request.getParameter("value");
                strSQL = "update gmms_furnace set maxLoadingRate='"+value+"' where id="
                        + line;
            }
            if ("单炉最大面积比例差".equals(leixing)) {
                String value = request.getParameter("value");
                strSQL = "update gmms_furnace set maxTolerance='"+value+"' where id="
                        + line;
            }
            sn.createSql(strSQL);
            int s = sn.update();
            //System.out.println(s);
            out.print(s);
 
        }
        
 
        if ("次破".equals(caozuo)) {
            //gongyi = gongyi.contains("钢化") ? "钢化" : gongyi;
            if ("钢化".equals(gongyi)) {
                String info = request.getParameter("cpInfo");
                //System.out.println("传入信息:" + info);
                String[] s = info.split("-");
                sn.createStdCall("proc_ePiercedsByGlassIdSave", 5);
                DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]);
                int rC = scr.ResultCode;
                String rM = scr.ResultMessage;
                if (rC == 1) {
                    out.print("OK");
                } else {
                    out.print(rC + "_" + rM);
                }
            }
 
            if ("中空".equals(gongyi)) {
                String info = request.getParameter("cpInfo");
                //System.out.println("中空传入信息:" + info);
                String[] s = info.split("-");
                sn.createStdCall("proc_ePiercedsByGlassIdSave", 5);
                DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]);
                int rC = scr.ResultCode;
                String rM = scr.ResultMessage;
                if (rC == 1) {
                    out.print("OK");
                } else {
                    out.print(rC + "_" + rM);
                }
            }
            
            if ("仓储".equals(gongyi)) {
                String info = request.getParameter("cpInfo");
                //System.out.println("仓储传入信息:" + info);
                String[] s = info.split("-");
                sn.createStdCall("proc_ePiercedsByGlassIdSave", 5);
                DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]);
                int rC = scr.ResultCode;
                String rM = scr.ResultMessage;
                if (rC == 1) {
                    out.print("OK");
                } else {
                    out.print(rC + "_" + rM);
                }
            }
            if ("磨边".equals(gongyi)) {
                String info = request.getParameter("cpInfo");
                //System.out.println("磨边传入信息:" + info);
                String[] s = info.split("-");
                sn.createStdCall("proc_ePiercedsByGlassIdSave", 5);
                DBSession.StdCallResult scr = sn.stdCall(s[0], s[1], s[2], s[3], s[4]);
                int rC = scr.ResultCode;
                String rM = scr.ResultMessage;
                if (rC == 1) {
                    out.print("OK");
                } else {
                    out.print(rC + "_" + rM);
                }
            }
        }
        if("取消破损".equals(caozuo)){
            
            strSQL ="INSERT INTO e_record_tempering(processcard_id, glass_id, width, height, thinkess, color, sequence, create_time, line, team_name, type_num, is_report,rank) "+
                    "select gt.processcard_id,gt.id,gt.edg_width,gt.edg_height,gt.thickness,gt.color,gt.stop_rank,NOW(),ep.line,ep.team_name,gt.edg_speed2,1,0 from gmms_galss_task_buffer as gt "+ 
                    "left join e_record_tempering as et on gt.id=et.glass_id "+
                    "left join e_pierceds as ep on ep.glass_id=gt.id  "+
                    "where et.glass_id is null and ep.glass_id is not null and gt.id='"+Id+"'";
            //System.out.println("修改:" + strSQL);
            sn.createSql(strSQL);
            int qx = sn.update();
            //System.out.println(s);
            out.print(qx);
            String strquxiao="Update e_pierceds set is_report=-1 where glass_id = "+Id;
            sn.createSql(strquxiao);
            int qxposun = sn.update();
        }
        if("报工确认".equals(caozuo)){
            //System.out.println("报工确认数据:" + lckh + ";产线:" + line);
            sn.createStdCall("proc_eRecordStockByGlassIdSave", 2);
            DBSession.StdCallResult scr = sn.stdCall(lckh, line);
            int rC = scr.ResultCode;
            String rM = scr.ResultMessage;
            if (rC == 1) {
                out.print("OK");
            } else {
                out.print(rC + "_" + rM);
            }
        }
        if("报工提交".equals(caozuo)){
            sn.createStdCall("proc_eRecordStockByLineUpdata", 1);
            DBSession.StdCallResult scr = sn.stdCall(line);
            int rC = scr.ResultCode;
            String rM = scr.ResultMessage;
            if (rC == 1) {
                out.print("OK");
            } else {
                out.print(rC + "_" + rM);
            }
            
        }
        if("钢化报工提交".equals(caozuo)){
            
            strSQL = "update e_record_tempering set report_time = now() where is_report != 4 and report_time is null and line = " + line;
 
            sn.createSql(strSQL);
            int s = sn.update();
            //out.print(s);        
            String postrSQL="update e_pierceds set report_time = now() where is_report != -1 and is_report != 4 and report_time is null and line = "+line+" and process = '钢化'";
            sn.createSql(postrSQL);
            int ps = sn.update();
            out.print(ps);
        }
        if("切割提交".equals(caozuo)){
            
            strSQL = "update gmms_cutmanage set BgTime=now() where BgTime is null and groups=" + line;
            System.out.println(strSQL);
            sn.createSql(strSQL);
            int s = sn.update();
            out.print(s);
            
            String bzSQL = "update gmms_user_current set isPaused='暂停' where gongyi = '磨边' and chanxian = " + line;
            sn.createSql(bzSQL);
            int ps = sn.update();
        }
 
 
    } catch (Exception e) {
        e.printStackTrace();
 
    } finally {
        if (sn != null)
            sn.close();
    }
%>