严智鑫
2023-12-22 54fe125d1165783cc5bc401124fccf203dfe5814
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
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.northglass.Globel.mes"%>
<%@page import="com.northglass.SqlHelper.*"%>
<%@page import="org.json.*"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
        String ret="未知操作";
        int mdflag=0;
        String s1= request.getParameter("a");
        String s2 = request.getParameter("b");
        JSONObject obj=new JSONObject();
        if("update".equals(s1)){
            mdflag=1;
            DBSession sn=null;
            int flag=0;
                try{
                    sn=mes.getMesDBHelper().createSession(false);
                    if("1".equals(s2)){
                        sn.createSql("select glass_id as id,x as y,y as x,"+
                    "(case when rotate=true then width else height end) as  width,"+
                                "(case when rotate=false then width else height end) as height,"+
                                "layout_number  as number,(case when work_state='破损' then 1 else 0 end) as `status` from tempereworkgalsss1 ");
                        flag=1;
                    }
                    if("2".equals(s2)){
                        sn.createSql("select glass_id as id,x as y,y as x,"+
                    "(case when rotate=true then width else height end) as  width,"+
                                "(case when rotate=false then width else height end) as height,"+
                                "layout_number  as number,(case when work_state='破损' then 1 else 0 end) as `status` from tempereworkgalsss2 ");
                        flag=2;
                    }
                        if(flag!=0){
                        JSONArray arr= sn.query().resultToJson(true);
                        ret="ok";
                        int f=0;
                        if(arr.length()>0){
                            f=arr.getJSONObject(0).getInt("number");
                        }
                        JSONObject data=new JSONObject();
                        data.put("number",f);
                        obj.put("result","ok");
                        data.put("data",arr);
                        obj.put("data",data);
                        out.print(obj.toString());
                        }
                        else{
                            JSONObject data=new JSONObject();
                             obj.put("result","fail");
                                obj.put("message","错误的产线编号");
                                out.print(obj.toString());
                        }
                }
                catch(Exception e){
                
                     obj.put("result","fail");
                        obj.put("message","刷新失败");
                        out.print(obj.toString());
                }
                finally{
                    if(sn!=null)
                        sn.close();
                }
        }    
        if("comit".equals(s1)){
            mdflag=2;
             long[] ids=null;    
                DBSession sn=null;
            try{
                sn=mes.getMesDBHelper().createSession(false);
                String[] ss=s2.split(",");
                  ids=new long[ss.length];
                  for(int i=0;i<ids.length;i++){
                      ids[i]=Long.parseLong(ss[i]);
                  }
                 sn.createStdCall("TemperingDamaged",1);
                for(int i=0;i<ids.length;i++){
                    sn.stdCall(ids[i]);
                }
                
                obj.put("result","ok");
                out.print(obj.toString());
            }
            catch(Exception e){
                 obj.put("result","fail");
                    obj.put("message","提交失败");
                    out.print(obj.toString());
            }
            finally{
                if(sn!=null)
                    sn.close();
            }
        }
        
        
%>