严智鑫
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
<%@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("yemian");
    
    if ("半成品仓储".equals(yemian)) {
        String caozuo = request.getParameter("caozuo");
        String leixing = request.getParameter("leixing");
        String pLine = request.getParameter("line");
        DBSession sn = null;
        boolean ok = false;
        
        try {
            
            sn = mes.getMesDBHelper().createSession(false);
            String qSQL = "";
 
            if ("获取列表".equals(caozuo)) {
                
                qSQL = "select  stop_rank,ifnull(rank,''),ifnull(processcard_id,''),processcardcount,ifnull(RankOrientation,''),if(sign=0,'','占用'),if(flag=0,'禁用','启用'),null,id from y_station_shelf";
            }
            //System.out.println("0-1"+caozuo);
            /* if("获取料架".equals(caozuo)){
                //System.out.println("0-1-1");
                qSQL = "select number,processcard_id,orientation,falg from gmms_shelf_rack_2 where Id<42";
                //System.out.println("1-1");
            } */
            
            if("获取料架".equals(caozuo)){
                
                qSQL="select id,orientation,processcard_id from gmms_shelf_rack_2 where id<42 and id not in(select rank from gmms_drop_frame_5 where rank is not null) and"
                        +" id not in (select rackid from gmms_shelf_tasks2 where taskstatus!='已完成' and isrepeal='正常');";
            }
            
            if("获取流程卡".equals(caozuo)){
                qSQL = "select processcard_id,shu from (select processcard_id,count(*) as shu from gmms_galss_task_shelf where work_state='已完成' and work_procedure='钢化后下片' group by processcard_id) as a where a.processcard_id not in(select processcard_id from gmms_shelf_rack_2 where processcard_id is not null)";
                
            }
            
            //System.out.print(qSQL);
            if ("修改".equals(leixing)) {
                
                if ("人工拿走".equals(caozuo)) {
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_drop_frame_5 as dr left join gmms_shelf_rack_2 as sr on dr.rank=sr.id set sr.processcard_id=null where sr.id is not null and dr.id='"+Id+"' and dr.sign=0";
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
                if ("启用".equals(caozuo)) {
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_drop_frame_5 set flag='0' where id='"+Id+"'";
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
                if ("禁用".equals(caozuo)) {
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_drop_frame_5 set flag='1' where id='"+Id+"'";
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
                if ("A".equals(caozuo)) {
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_shelf_rack_2 set orientation='B' where id ='"+Id+"'";
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
                if ("B".equals(caozuo)) {
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_shelf_rack_2 set orientation='A' where id ='"+Id+"'";
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
                if("绑定料架".equals(caozuo)){
                    String Id = request.getParameter("Id");
                    String ljh = request.getParameter("LiaoJiaHao");
                    
                    //如果当前料架已经在工位上存在了,则先赋空再修改,避免一个料架存在两个工位的情况
                    //禁用才可以绑料架,flag=0意思未知
                    qSQL = "update gmms_drop_frame_5 set rank=null where rank="+ljh+" and groups_=100 and flag=0";
                    //System.out.println(qSQL);
                    sn.createSql(qSQL);
                    sn.update();
                    //
                    qSQL = "update gmms_drop_frame_5 set rank="+ljh+" where id="+Id+" and groups_=100 and flag=0";
                    sn.createSql(qSQL);
                    int s=sn.update();
                    out.print(s);
                }
                if("绑定流程卡".equals(caozuo)){
                    String Id = request.getParameter("Id");
                    String lckh = request.getParameter("LCKNo");
                    qSQL = "update gmms_drop_frame_5 as dr left join gmms_shelf_rack_2 as sr on dr.rank=sr.id set sr.processcard_id='"+lckh+"' where sr.id is not null and dr.id="+Id+" and dr.sign=0 and dr.flag=0";
                    
                    
                    sn.createSql(qSQL);
                    int s=sn.update();
                    out.print(s);
                }
                if ("去除架子".equals(caozuo)) {
                    System.out.println("11231");
                    String Id = request.getParameter("Id");
                    qSQL="update gmms_drop_frame_5 set rank=null where id='"+Id+"'";
                    System.out.println(qSQL);
                    sn.createSql(qSQL);
                    int s=sn.update();//括号内是参数,没有参数不输入
                    out.print(s);
                }
            }
            
            if ("查询".equals(leixing)) {
                sn.createSql(qSQL);
                JSONArray a = sn.query().resultToJson(false);
                if (a != null) {
                    out.print(a.toString());
                } else {
                    out.print("[]");
                }
            }
            //sn.createStdCall("aaa",3);
            //String s= sn.stdCall(1,2,3).ResultMessage;
 
        } catch (Exception e) {
            e.printStackTrace();
 
        } finally {
            if (sn != null)
                sn.close();
        }
    }
 
    
%>