严智鑫
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
<%@page
    import="com.northglass.GlassLayout.Algorithm.AlgorithmDBInterface"%>
<%@page import="com.northglass.GlassLayout.Tempering.RackComboInfo"%>
<%@page
    import="com.northglass.GlassLayout.Tempering.RackComboInfo.RackInfo"%>
<%@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"%>
 
<%
    //System.out.println("获取");
    String line = request.getParameter("line");
    String strMx = request.getParameter("moxi");//膜系
    String strHd = request.getParameter("houdu");//厚度
    //System.out.print(line == null);
    String caozuo = request.getParameter("caozuo");
    String num = request.getParameter("Num");
    double ratioLimit=Double.valueOf(request.getParameter("ratioLimit")) ;
    double mixedLimit=Double.valueOf(request.getParameter("mixedLimit")); 
    
    int l = Integer.valueOf(line);
    System.out.println("[线路:"+line+"][膜系:"+strMx+"][厚度:"+strHd+"][单炉最大装载率:"+ratioLimit+"][混排面积最大允许相差比例:"+mixedLimit+"]");
    
    if ("上架推荐".equals(caozuo)) {
        DBSession sn = null;
        boolean ok = false;
        int LckCount=0;
        try{
            String sqlcount="Select * from v_ghq_liuchengka where moxi='"+strMx+"' and houdu='"+strHd+"'";
            sn = mes.getMesDBHelper().createSession(false);
            sn.createSql(sqlcount);
            JSONArray a = sn.query().resultToJson(false);
            if (a != null) {
                LckCount=a.length();
                //out.print(a.toString());
            } else {
                //out.print("[]");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (sn != null) {
                sn.close();
            }
        }                
        System.out.println("流程卡数量:"+LckCount);
        if(LckCount<3){
            out.println(LckCount);
        }else{
            String sql = "select `gs`.`id` AS `id`,`gs`.`processcard_id` AS `processcard`,lk.position,"
                    + "100 AS `front`,`gs`.`width` AS `width`,`gs`.`height` AS `height`,"
                    + "`gs`.`stop_rank` AS `glass_idx`,`gs`.`thickness` AS `thickness`,"
                    + "`gs`.`color` AS `color`,100 AS `work_id`," + "0 AS `layout_mode`,"
                    + "(select w from gmms_galss_task_buffer where id=gs.id) as w,"
                    + "(select h from gmms_galss_task_buffer where id=gs.id) as h from  "
                    + "(select @rows:=@rows+1 as position,liuchengka from gmms_liuchengka,(select @rows:=0) as b where isgang='冷加工下片完成' and is_single=1 and gy_gang=1 and piece_count>10 and minArea>0.7) as lk "
                    + "left join gmms_galss_task_stock as gs on lk.liuchengka=gs.processcard_id where gs.thickness ='"+strHd+"' and gs.color = '"+strMx+"'";
            
            //System.out.println(sql);
            //得到推荐结果    f(线路,sql)
            RackComboInfo[] resultratio =com.northglass.GlassLayout.Algorithm.AlgorithmDBInterface.f(l, sql,ratioLimit,mixedLimit);
            if(resultratio.length>0){
                    //一组结果   RackComboInfo类      :
                    //RackComboInfo.RackInfos   表示结果中的  流程卡数组      
                    //RackComboInfo.RackInfo    表示流程卡信息
                    //RackComboInfo.ratioResult 表示这一组流程卡的优化率
 
                    String tj_lck ="";
                    int r_row = 0;
                    String result_ ="";
                    //for (RackInfo d : resultratio[0].rackinfos) {
                    for (RackComboInfo RackComboInfo : resultratio) {
                        result_+="【"+r_row+"】流程卡号:";
                        for (RackInfo d : RackComboInfo.rackinfos) {
                            //System.out.println("  id:" + d.id + "  needed:" + d.needed + "  level:" + d.level);
                            if(r_row==0){
                                tj_lck+=d.id+"_";
                            }
                            result_+=d.id+"、";
                        }
                        result_+="(炉数、装载率:";
                        for (double d : RackComboInfo.ratioResult) {
                            if(r_row==0){
                                tj_lck+=d+"_";
                            }
                            result_+=d+"、";
                        }
                        result_+=")";
                        
                        
                        r_row++;
                    }
 
                    System.out.println("钢化前上架推荐:"+tj_lck);
                    out.println(tj_lck);
                                        
                    try{
                        String param = "[膜系:"+strMx+"][厚度:"+strHd+"][玻璃架数:"+LckCount+"][单炉最大装载率:"+ratioLimit+"][混排面积最大允许相差比例:"+mixedLimit;
 
                        String sqlcount="Insert gmms_ganghuatuijian_log (result,Parameter,strremark,intremark)values('"+result_+"','"+param+"','',0)";
                        sn = mes.getMesDBHelper().createSession(false);
                        sn.createSql(sqlcount);
 
                        int a = sn.update();
                        
                    } catch (Exception e) {
                        e.printStackTrace();
                        out.println("0");
                    } finally {
                        if (sn != null) {
                            sn.close();
                        }                        
                    }                        
            }else{
                
                System.out.println("ERROR:钢化推荐部分:116行");                
                out.println("0");
            }
        }
        
        
        
        /* //遍历 每一组结果   id:流程卡号       needed:默认FALSE   level:等级
        for (RackComboInfo RackComboInfo : resultratio) {
            //一组结果   RackComboInfo类      :
            //RackComboInfo.RackInfos   表示结果中的  流程卡数组      
            //RackComboInfo.RackInfo    表示流程卡信息
            //RackComboInfo.ratioResult 表示这一组流程卡的优化率
            for (RackInfo d : RackComboInfo.rackinfos) {
                System.out.println("  id:" + d.id + "  needed:" + d.needed + "  level:" + d.level);
            }
            for (double d : RackComboInfo.ratioResult) {
                System.out.println(d);
            }
        } */
    }
    //out.print("{result:\"ok\"}");
%>