严智鑫
2024-05-13 cedce4883f0d204f5bf7bf87c0bf4858dabb0c23
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
<%@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 line = request.getParameter("line");
    String gongyi = request.getParameter("gongyi");
    String banzu = request.getParameter("banzu");
    String sTime = request.getParameter("startTime");
    String eTime = request.getParameter("endTime");
    DBSession sn = null;
    boolean ok = false;
    //System.out.println("工艺:" + gongyi + ";参数:" + line + "," + banzu + "," + sTime + "," + eTime);
    try {
        sn = mes.getMesDBHelper().createSession(false);
        String strSQL = "";
        if (gongyi.equals("钢化")) {
            strSQL = "SELECT NULL,team_name,line,processcard_id,"
                    + "(select count(1) from e_pierceds e LEFT JOIN gmms_galss_task_buffer b on e.glass_id = b.id where e.processcard_id = t.processcard_id and e.team_name = t.team_name and e.line = t.line group by e.processcard_id ) as '破损数',"
                    + "(select sum(edg_width*edg_height) from e_pierceds e LEFT JOIN gmms_galss_task_buffer b on e.glass_id = b.id where e.processcard_id = t.processcard_id and e.team_name = t.team_name and e.line = t.line group by e.processcard_id ) as '破损面积',"
                    + "count( 1 ) as '完成数量'," + "sum( width * height ) as '完成面积',"
                    + "concat(thinkess, '', color ) as '膜系',"
                    + "max(create_time) as '完成时间'    FROM `e_record_tempering`  t ";
            String strPara = "where create_time >'" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and create_time <'" + eTime + "'";
            }
            if (!line.equals("0")) {
                strPara += " and line = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and team_name = '" + banzu + "'";
            }
            String strGy = " GROUP BY processcard_id,team_name,line  order by  team_name,line, max(create_time)";
            strSQL = strSQL.concat(strPara).concat(strGy);
        }
 
        if (gongyi.equals("磨边")) {
            strSQL = "SELECT NULL,team_name,line,processcard_id,"
                    + "(select count(1) from e_pierceds e LEFT JOIN gmms_galss_task_buffer b on e.glass_id = b.id where e.processcard_id = t.processcard_id and e.team_name = t.team_name and e.line = t.line group by e.processcard_id ) as '破损数',"
                    + "(select sum(edg_width*edg_height) from e_pierceds e LEFT JOIN gmms_galss_task_buffer b on e.glass_id = b.id where e.processcard_id = t.processcard_id and e.team_name = t.team_name and e.line = t.line group by e.processcard_id ) as '破损面积',"
                    + "count( 1 ) as '完成数量'," + "sum( width * height ) as '完成面积',"
                    + "concat(thinkess, '', color ) as '膜系',"
                    + "max(create_time) as '完成时间'    FROM `e_record_stock`  t ";
            String strPara = "where create_time >'" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and create_time <'" + eTime + "'";
            }
            if (!line.equals("0")) {
                strPara += " and line = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and team_name = '" + banzu + "'";
            }
            String strGy = " GROUP BY processcard_id,team_name,line order by  team_name,line, max(create_time)";
            strSQL = strSQL.concat(strPara).concat(strGy);
        }
 
        if (gongyi.equals("钢化装载")) {
            strSQL = "select count(1) from (SELECT count(1),furnace FROM `e_record_tempering` ";
            String strPara = "where create_time >'" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and create_time <'" + eTime + "'";
            }
            if (!line.equals("0")) {
                strPara += " and line = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and team_name = '" + banzu + "'";
            }
 
            strPara += "  and furnace is not null ";
            strSQL += strPara;
            strSQL += " group by furnace) as s";
        }
 
        if (gongyi.equals("切割明细")) {
            strSQL = "select null,width,height,thickness,color,batch_id,sum(pieces),null,groups,dengluname,DATE_FORMAT(BgTime,'%Y-%m-%d') from gmms_cutmanage ";
            String strPara = "where BgTime >='" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and BgTime <='" + eTime + "  23:59:59'";
            }
            if (!line.equals("0")) {
                strPara += " and groups = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and dengluname = '" + banzu + "'";
            }
            strSQL += strPara;
            strSQL += " group by width,height,thickness,color,batch_id,dengluname,DATE_FORMAT(BgTime,'%Y-%m-%d') ";
            strSQL += " order by DATE_FORMAT(BgTime,'%Y-%m-%d'),color,thickness";
            //System.out.println(strSQL);
        }
 
        if (gongyi.equals("切割总览")) {
            strSQL = "select null,width,height,thickness,color,sum(pieces),null,groups,dengluname,DATE_FORMAT(BgTime,'%Y-%m-%d') from gmms_cutmanage ";
            String strPara = "where BgTime >='" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and BgTime <='" + eTime + "  23:59:59'";
            }
            if (!line.equals("0")) {
                strPara += " and groups = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and dengluname = '" + banzu + "'";
            }
            strSQL += strPara;
            strSQL += " group by groups,dengluname,width,height,thickness,color,DATE_FORMAT(BgTime,'%Y-%m-%d') ";
            strSQL += " order by DATE_FORMAT(BgTime,'%Y-%m-%d'),color,thickness";
        }
        //2023-12-4 新增    【切割明细,切割总览】按时间/尺寸分组
        if (gongyi.equals("切割明细-分组")) {
            strSQL = "select null,width,height,thickness,color,null,sum(pieces),null,null,null,DATE_FORMAT(BgTime,'%Y-%m-%d') from gmms_cutmanage ";
            String strPara = "where BgTime >='" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and BgTime <='" + eTime + "  23:59:59'";
            }
            if (!line.equals("0")) {
                strPara += " and groups = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and dengluname = '" + banzu + "'";
            }
            strSQL += strPara;
            strSQL += " group by width,height,thickness,color,DATE_FORMAT(BgTime,'%Y-%m-%d') ";
            strSQL += " order by DATE_FORMAT(BgTime,'%Y-%m-%d'),color,thickness";
            //System.out.println(strSQL);
        }
        if (gongyi.equals("切割总览-分组")) {
            strSQL = "select null,width,height,thickness,color,sum(pieces),null,null,null,DATE_FORMAT(BgTime,'%Y-%m-%d') from gmms_cutmanage ";
            String strPara = "where BgTime >='" + sTime + "'";
            if (!eTime.isEmpty()) {
                strPara += "and BgTime <='" + eTime + "  23:59:59'";
            }
            if (!line.equals("0")) {
                strPara += " and groups = " + line;
            }
            if (!banzu.equals("0")) {
                strPara += " and dengluname = '" + banzu + "'";
            }
            strSQL += strPara;
            strSQL += " group by width,height,thickness,color,DATE_FORMAT(BgTime,'%Y-%m-%d') ";
            strSQL += " order by DATE_FORMAT(BgTime,'%Y-%m-%d'),color,thickness";
        }
 
        if (gongyi.equals("切割单片")) {
 
        }
        //2023-09-19 新增 开始
        //System.out.println("报表SQL参数:" + gongyi+":"+sTime+":"+eTime);
        if (gongyi.equals("切割率明细")) {
            String gcNo = request.getParameter("gongchenghao");
            //strSQL="select * from v_rf_qiecailv where 完成时间  Between '"+sTime+"' and '"+eTime+"'";
            strSQL = "select * from v_rf_qiecailv where ";
 
            if (!gcNo.isEmpty()) {
                strSQL += " 工程号 ='" + gcNo + "'";
            } else {
                if (!sTime.isEmpty() && !eTime.isEmpty()) {
                    strSQL += "(完成时间  >= '" + sTime + "' and 完成时间  <'" + eTime + "')";
                } else if (!sTime.isEmpty()) {
                    strSQL += " 完成时间  >= '" + sTime + "' ";
                } else {
 
                }
            }
        }
 
        if (gongyi.equals("流程卡切裁率")) {
            String lckNo = request.getParameter("liuchengkahao");
            String gcNo = request.getParameter("gongchenghao");
            strSQL = "";
            strSQL = " select null,f.file_name,b.processcard_id,b.thickness,b.color,count(1),round(sum(b.width*b.height)/1000000,2),f.cutting_rate,f.receive_time "
                    + "from gmms_raw_file f left join gmms_galss_task_buffer b on f.file_name = b.engineering_id "
                    + "where f.file_Name like 'P%' ";
            if (!lckNo.isEmpty() || !gcNo.isEmpty()) {
                if (!lckNo.isEmpty()) {
                    strSQL += " and(b.processcard_id like '%" + lckNo + "%')";
                }
                if (!gcNo.isEmpty()) {
                    strSQL += " and(f.file_Name like '%" + gcNo + "%')";
                }
                //strSQL+=" and(f.file_Name like '%"+gcNo+"%' or b.processcard_id like '%"+lckNo+"%')";
            } else {
                if (!sTime.isEmpty()) {
                    strSQL += " and f.receive_time >= '" + sTime + "'";
                }
                if (!eTime.isEmpty()) {
                    strSQL += " and f.receive_time <= '" + eTime + "'";
                }
            }
            strSQL += " group by f.file_name,b.processcard_id order by f.receive_time desc";
        }
 
        if (gongyi.equals("总切裁率")) {
            strSQL = "select operator as 线路, count(1) as 工程数量,ROUND(sum(galssmeasure),2) as 小片面积 ,ROUND(sum(patternmeasure),2) as 原片面积,"
                    + " ROUND(sum(galssmeasure)/sum(patternmeasure)*100,2) as 平均切裁率"
                    + " from gmms_raw_file where state like '%完成%' and file_name like 'P%'";
            if (!sTime.isEmpty()) {
                strSQL += " and receive_time >= '" + sTime + "'";
            }
            if (!eTime.isEmpty()) {
                strSQL += " and receive_time <= '" + eTime + "'";
            }
            strSQL += " group by operator";
        }
        //2023-09-19 新增 结束
        //System.out.println("报表SQL:" + strSQL);
        sn.createSql(strSQL);
        JSONArray a = sn.query().resultToJson(false);
        if (a != null) {
            out.print(a.toString());
        } else {
            out.print("[]");
        }
    } catch (Exception e) {
        e.printStackTrace();
 
    } finally {
        if (sn != null)
            sn.close();
    }
%>