严智鑫
2025-08-18 3b65a5dc04be7cdac460c84ebaa38bf009405128
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
<%@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 caozuoName = request.getParameter("name");
    String pLine = request.getParameter("line");
    String moshi = request.getParameter("moshi");
 
    //System.out.println("操作时间:" + new java.util.Date() + "  当前操作:" + caozuoName + ";  当前生产线:" + pLine + ";模式:" + moshi);
 
    //查询
    if ("1".equals(moshi)) {
        DBSession sn = null;
        boolean ok = false;
        try {
            sn = mes.getMesDBHelper().createSession(false);
            String qSQL = "";
            if ("上片位信息".equals(caozuoName)) {
                qSQL = "select id,stops,processcard_id,state,zongshu,posunshu,yiyouhua,wanchengshu,shengyushu,shangpianshengyushu,noodles,flag,weizhi from v_gh_shangpianwei where groups = "
                        + pLine;
            }
 
            if ("优化模式".equals(caozuoName)) {
 
            }
 
            //38 2号线机械手 63 1号线机械手
            if ("吸片模式".equals(caozuoName)) {
 
                String mId = "1".equals(pLine) ? "63" : "38";
                qSQL = "select remarks from gmms_machine where id = " + mId;
            }
 
            if ("获取流程卡".equals(caozuoName)) {
                qSQL = "Select * from v_ghq_liuchengka";
            }
 
            if ("换架判断".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                qSQL = "select count(*) from gmms_galss_task_2 where processcard_id = (select processcard_id from gmms_drop_frame_2 where Id ="
                        + Id + ") and work_state <> '破损' and work_state <> '未优化' ";
            }
            if ("查询流程卡详情".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                qSQL = "select processcard_id,stop_rank,galss_id,thickness,color,edg_width,edg_height,work_state,work_procedure,Id from gmms_galss_task_2 where  processcard_id = (select processcard_id from gmms_drop_frame_2 where Id ="
                        + Id + ") order by stop_rank";
            }
            if ("工位信息".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                qSQL = "Select stops,processcard_id,zongshu,posunshu,shengyushu,noodles from v_gh_shangpianwei where id ="+Id;
            }
 
            if ("当前摆片".equals(caozuoName)) {
                qSQL = "Select width,length,xinterval,yinterval from gmms_furnace where Id ="+pLine;
            }
            
            if("摆片规则".equals(caozuoName)){
                qSQL = "Select id,width,length,xinterval,yinterval,description,line from gmms_furnace_config";
                
            }
            if("进炉时间".equals(caozuoName)){
                if("1".equals(pLine)){
                    qSQL ="Select time_out from gmms_timer where timer_name = 'ganghua_1'";
                    
                }else if("2".equals(pLine)){
                    qSQL ="Select time_out from gmms_timer where timer_name = 'ganghua_2'";
                }                
            }
            sn.createSql(qSQL);
 
            //sn.createStdCall("aaa",3);
            //String s= sn.stdCall(1,2,3).ResultMessage;
            JSONArray a = sn.query().resultToJson(false);
            if (a != null) {
                out.print(a.toString());
            } else {
                out.print("[]");
            }
            //out.print(pLine);
            ok = true;
        } catch (Exception e) {
            System.out.println("操作时间:" + new java.util.Date() + "     出现错误!!!:" + "  当前操作:" + caozuoName
                    + ";  当前生产线:" + pLine + ";模式:" + moshi);
            e.printStackTrace();
 
        } finally {
 
            if (sn != null) {
                sn.close();
            }
        }
 
    } else {
 
 
    }
 
    //修改
    if ("2".equals(moshi)) {
        DBSession sn = null;
        boolean ok = false;
 
        try {
            sn = mes.getMesDBHelper().createSession(false);
            String qSQL = "";
            if ("设置使用面".equals(caozuoName)) {
                String sId = request.getParameter("Id");
                qSQL = "update gmms_drop_frame_2 set flag =  if(flag=1,0,1)  where stops = " + sId
                        + " and groups = " + pLine;
            }
 
            //2 不吸片 1吸片
            if ("吸片模式切换".equals(caozuoName)) {
 
                String mId = "1".equals(pLine) ? "63" : "38";
 
                qSQL = "update gmms_machine set remarks = if(remarks=1,2,1) where Id=" + mId;
            }
 
            if ("设置破损".equals(caozuoName)) {
                String gId = request.getParameter("Id");
                qSQL = "update gmms_galss_task_2 set work_state = '破损' where Id = " + gId;
 
            }
 
            if ("删除上片位信息".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                qSQL = "update gmms_drop_frame_2 set processcard_Id = null ,state='" + "空闲"
                        + "',processcard_count =0 ,surplus_count = 0 where Id=" + Id;
 
            }
            if("修改数量".equals(caozuoName)){
                String Id = request.getParameter("Id");
                String u_num = request.getParameter("U_Num");
                qSQL = "update gmms_drop_frame_2 set surplus_count = "+u_num +" where Id = "+Id;
            }
            
 
            if("摆片新增".equals(caozuoName)){
                String ms = request.getParameter("bpms");
                String[] m = ms.split("_");
                // n + "_" + w + "_" + l + "_" + x + "_" + y
                qSQL = "insert into gmms_furnace_config(width,length,xinterval,yinterval,description) values ("+m[1]+","+m[2]+","+m[3]+","+m[4]+",'"+m[0]+"')";
            }
 
            if("删除摆片规则".equals(caozuoName)){
                String Id = request.getParameter("Id");
                qSQL = "Delete from gmms_furnace_config where id = "+Id;
                
            }
            if("标记钢化完成".equals(caozuoName)){
                String lck = request.getParameter("lck_num");
                qSQL ="update gmms_liuchengka set isgang='手动钢化' where liuchengka='"+lck+"'"; 
                
            }
            System.out.println("操作时间:" + new java.util.Date() + "  当前操作:钢化前上片位-" + caozuoName + ";SQL:" + qSQL);
            sn.createSql(qSQL);
            int s = sn.update();
            out.print(s);
 
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (sn != null) {
                sn.close();
            }
        }
    }
    //存储过程
    if ("3".equals(moshi)) {
        DBSession sn = null;
        boolean ok = false;
        try {
            sn = mes.getMesDBHelper().createSession(false);
            if ("上架确认".equals(caozuoName)) {
                sn.createStdCall("GlassTask_ganghuaqian", 1);
                int s = sn.stdCall(pLine).ResultCode;
                out.print(s);
            }if("绑定流程卡".equals(caozuoName)){
                //GlassTask_ghq_BindRack
                String Id = request.getParameter("Id");
                String lckNum = request.getParameter("lckNum");
                sn.createStdCall("GlassTask_ghq_BindRack", 2);
                DBSession.StdCallResult scr = sn.stdCall(Id,lckNum);
                int s = scr.ResultCode;
                String rM = scr.ResultMessage;
                out.print(s+"_"+rM);
            }if("摆片修改".equals(caozuoName)){
                String Id =request.getParameter("Id");
                sn.createStdCall("GlassTask_furnace", 2);
                DBSession.StdCallResult scr = sn.stdCall(Id,pLine);
                int s = scr.ResultCode;
                String rM = scr.ResultMessage;
                out.print(s+"_"+rM);
            }
 
        } catch (Exception e) {
            e.printStackTrace();
 
        } finally {
 
            if (sn != null) {
 
                sn.close();
            }
        }
 
    }
 
    //需要修改多条数据
    if ("4".equals(moshi)) {
        DBSession sn = null;
        boolean ok = false;
        try {
            sn = mes.getMesDBHelper().createSession(false);
            String qSQL = "";
 
            //弃用
            if ("绑定流程卡".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                String lckNum = request.getParameter("lckNum");
 
                qSQL = "update gmms_drop_frame_2 set processcard_Id ='" + lckNum + "' ,state='" + "使用中"
                        + "',processcard_count =(SELECT count(1) FROM gmms_galss_task_stock WHERE processcard_id = '"
                        + lckNum
                        + "') ,surplus_count = (SELECT count(1) FROM gmms_galss_task_stock WHERE processcard_id = '"
                        + lckNum + "') where Id=" + Id;
                sn.createSql(qSQL);
                int s = sn.update();
                if (s == 1) {
                    qSQL = "update gmms_liuchengka set Occupied = " + Id + " where liuchengka = '" + lckNum
                            + "';";
                    sn.createSql(qSQL);
                    int t = sn.update();
                    if (t == 1) {
                        out.print(t);
 
                    } else {
                        out.print("上片位信息修改成功,流程卡占用标记失败");
                    }
                } else {
                    out.print("上片位信息修改失败,流程卡绑定失败");
                }
            }
 
            if ("清空信息".equals(caozuoName)) {
                String Id = request.getParameter("Id");
                qSQL = "delete from  gmms_galss_task_2 where processcard_id = (select processcard_id from gmms_drop_frame_2 where id="
                        + Id + ")";
                sn.createSql(qSQL);
                sn.update();
                qSQL = "update gmms_drop_frame_2 set processcard_Id = null ,state='" + "空闲"
                        + "',processcard_count =0 ,surplus_count = 0 where Id=" + Id;
 
                sn.createSql(qSQL);
                int r = sn.update();
                if (r == 1) {
                    out.print(r);
 
                } else {
                    out.print("收影响行数大于1条,清空信息可能存在异常!");
                }
            }
 
            if ("删除上片位信息".equals(caozuoName)) {
                String Id = request.getParameter("Id");
 
                qSQL = "update gmms_liuchengka set Occupied = 0 where liuchengka =(select processcard_id from gmms_drop_frame_2 where id="
                        + Id + ")";
                sn.createSql(qSQL);
                sn.update();
                qSQL = "update gmms_drop_frame_2 set processcard_Id = null ,state='" + "空闲"
                        + "',processcard_count =0 ,surplus_count = 0 where Id=" + Id;
                sn.createSql(qSQL);
                int t = sn.update();
                if (t == 1) {
                    out.print(t);
                } else {
                    out.print("上片位信息修改失败!");
                }
            }
 
        } catch (Exception e) {
            e.printStackTrace();
 
        } finally {
 
            if (sn != null) {
 
                sn.close();
            }
        }
 
    }
 
    //System.out.println("操作时间:"+new java.util.Date()+"  操作结束");
%>