YYC
2023-10-19 6bd36a38fc587ba39bd50e26257ed6ece71363e7
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
/**
 * 根据气体信息生成打印模版
 * 
 * @param depotData
 *            仓库基本信息
 * @param grainData
 *            粮情数据信息
 */
builderModel = function(curData,dept) {
    var depotData = curData.depotData;
    var listPoint = curData.listPoint;
 
    var model = "<!DOCTYPE html><html lang=\"zh-cn\">\n"
            + "<head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"><title>气体报表模版</title>"
            + "    <style>\n"
            + "        table,table tr th,table tr td{border:1px solid #0d1021}table{width:100%;line-height:23px;text-align:center;font-size:14px}.table-2{border-top:0px solid #0d1021 !important}.table-2 tr{border-top:0px solid #0d1021 !important}.table-2 td{border-top:0px solid #0d1021 !important}.table-row-tr{border-left:0px !important;border-right:0px !important;border-top:0px !important}.table-row-fz{border:0px !important}.link-top{width:100%;border-top:solid #0d1021 1px}</style>\n"
            + "</head><body>";
 
    model += "<div style=\"text-align: center\">\n"
            + "<span style=\"font-size: 26px; font-weight: bold;\">\n";
    if(dept){
        model += dept.name;
    }else{
        model += "--XXX--粮库"
    }
    model += "</span><div class=\"link-top\"></div><div class=\"link-top\"></div>\n";
    model += "<span style=\"font-size: 18px; \">";
    model += depotData.name;
    model += "&nbsp;&nbsp;&nbsp;&nbsp;气体报表</span>\n";
    model += "</div><div style=\"margin-top: 5px;\"><span style=\"float: left;\">";
    model += "&nbsp;&nbsp;方向:东</span><span style=\"float: right;\">检测时间:";
    model += curData.receiveDate;
    model += "</span></div>";
 
    // 动态配置
    model += "<table cellspacing=\"0\" cellpadding=\"0\">";
    model += "<tr><td>采集位</td><td>CO2</td><td>O2</td><td>PH3</td><td>N2</td><td>采集位</td><td>CO2</td><td>O2</td><td>PH3</td><td>N2</td></tr>";
 
    var num = Math.ceil(listPoint.length / 2);
    var index = 1;
    var point;
    for (var i = 0; i < num; i++) {
        point = listPoint[index - 1];
        model += "<tr>";
 
        model += "<td class=\"table-row-fz\">采集位 " + point.passCode + "</td>";
        model += "<td class=\"table-row-fz\">"
                + attrPoint(point, curData, "CO2") + "</td>";
        model += "<td class=\"table-row-fz\">"
                + attrPoint(point, curData, "O2") + "</td>";
        model += "<td class=\"table-row-fz\">"
                + attrPoint(point, curData, "PH3") + "</td>";
        model += "<td class=\"table-row-fz\">"
                + attrPoint(point, curData, "N2") + "</td>";
 
        index++;
 
        if (index > listPoint.length) {
            model += "<td class=\"table-row-fz\"></td>";
            model += "<td class=\"table-row-fz\"></td>";
            model += "<td class=\"table-row-fz\"></td>";
            model += "<td class=\"table-row-fz\"></td>";
            model += "<td class=\"table-row-fz\"></td>";
        } else {
            point = listPoint[index - 1];
            model += "<td class=\"table-row-fz\">采集位 " + point.passCode + "</td>";
            model += "<td class=\"table-row-fz\">"
                    + attrPoint(point, curData, "CO2") + "</td>";
            model += "<td class=\"table-row-fz\">"
                    + attrPoint(point, curData, "O2") + "</td>";
            model += "<td class=\"table-row-fz\">"
                    + attrPoint(point, curData, "PH3") + "</td>";
            model += "<td class=\"table-row-fz\">"
                    + attrPoint(point, curData, "N2") + "</td>";
 
            index++;
        }
        model += "</tr>";
    }
    model += "</table>";
    // <!--下面表格开始-->
    model += "<table cellspacing=\"0\" cellpadding=\"0\" class=\"table-2\">";
    model += "<tr><td width=\"20%\">检测分析:</td>";
    model += "<td colspan=4>" + curData.remark + "</td></tr>";
    model += "<tr><td width=\"20%\"></td><td width=\"20%\">最高</td><td width=\"20%\">最低</td><td width=\"20%\">平均</td><td width=\"20%\">备注</td></tr>";
 
    // 气体整体信息
    model += "<tr> <td>CO2(PPM)</td><td>" + curData.perCo2Max + "</td>";
    model += "<td>" + curData.perCo2Min + "</td>";
    model += "<td>" + curData.perCo2 + "</td>";
    model += "<td></td></tr>";
 
    model += "<tr> <td>O2(%)</td><td>" + curData.perO2Max + "</td>";
    model += "<td>" + curData.perO2Min + "</td>";
    model += "<td>" + curData.perO2 + "</td>";
    model += "<td></td></tr>";
 
    model += "<tr> <td>PH3(PPM)</td><td>" + curData.perPh3Max + "</td>";
    model += "<td>" + curData.perPh3Min + "</td>";
    model += "<td>" + curData.perPh3 + "</td>";
    model += "<td></td></tr>";
 
    model += "<tr> <td>N2(%)</td><td>" + curData.perN2Max + "</td>";
    model += "<td>" + curData.perN2Min + "</td>";
    model += "<td>" + curData.perN2 + "</td>";
    model += "<td></td></tr>";
 
    // 仓库信息
    model += "<tr><td>仓房类型</td><td>" + depotData.depotTypeName + "</td>";
    model += "<td>入仓日期</td><td>" + depotData.storeDate + "</td><td ></td></tr>";
 
    model += "<tr><td>粮食品种</td><td>" + depotData.foodVarietyName + "</td>";
    model += "<td>实际储量(吨)</td><td>" + depotData.storageReal
            + "</td><td ></td></tr>";
 
    model += "<tr><td>入仓水分(%)</td><td>" + depotData.perWet + "</td>";
    model += "<td>当前水分(%)</td><td>" + depotData.perWet + "</td><td ></td></tr>";
 
    model += "<tr><td>出糙率(%)</td><td>" + depotData.rough + "</td>";
    model += "<td>粮食产地</td><td>" + depotData.foodLocation
            + "</td><td ></td></tr>";
 
    model += "<tr><td>容重(kg/m3)</td><td>" + depotData.bulkWeight + "</td>";
    model += "<td>面筋持水率(%)</td><td>" + depotData.waterGluten + "</td><td></td></tr>";
 
    model += "<tr><td>杂质(%)</td><td>" + depotData.perImpurity + "</td>";
    model += "<td>不完善粒(%)</td><td>" + depotData.broken + "</td><td ></td></tr>";
 
    model += "<tr><td>检测人</td><td>" + curData.checkUser + "</td>";
    model += "<td>保管员</td><td>" + depotData.storeKeeperName
            + "</td><td ></td></tr>";
 
    model += "</table>";
 
    // 添加尾部信息
    model += "<div style=\"margin-top: 5px;\">";
    model += "<span style=\"float: left;\">注:#表示最低&nbsp;&nbsp;*表示最高</span>";
    model += "<span style=\"float: right;\">制表时间:" + curData.sysDate
            + "</span></div>";
    model += "</div></body></html>";
 
    return model;
};
 
// 根据采集点赋值,注意数据库生成的坐标是从0开始的
attrPoint = function(point, curData, type) {
    if (type == "CO2") {
        if (-100.0 == point.perCo2) {
            return "备用";
        }
        if (curData.perCo2Max == point.perCo2) {
            return point.perCo2 + "*";
        }
        if (curData.perCo2Min == point.perCo2) {
            return point.perCo2 + "#";
        }
    }
 
    if (type == "O2") {
        if (-100.0 == point.perO2) {
            return "备用";
        }
        if (curData.perO2Max == point.perO2) {
            return point.perO2 + "*";
        }
        if (curData.perO2Min == point.perO2) {
            return point.perO2 + "#";
        }
    }
 
    if (type == "PH3") {
        if (-100.0 == point.perPh3) {
            return "备用";
        }
        if (curData.perPh3Max == point.perPh3) {
            return point.perPh3 + "*";
        }
        if (curData.perPh3Min == point.perPh3) {
            return point.perPh3 + "#";
        }
    }
 
    if (type == "N2") {
        if (-100.0 == point.perN2) {
            return "备用";
        }
        if (curData.perN2Max == point.perN2) {
            return point.perN2 + "*";
        }
        if (curData.perN2Min == point.perN2) {
            return point.perN2 + "#";
        }
    }
 
    return "";
};
 
/**
 * 根据HTML模版打印为A4
 * 
 * @param strHtml
 */
previewA4 = function(strHtml) {
    var LODOP = getLodop();
    LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");
    LODOP.PRINT_INIT("气体报表");
    LODOP.ADD_PRINT_HTM(30, 40, "180mm", "100%", strHtml);
    LODOP.PREVIEW();
};