|
|
@@ -14,13 +14,12 @@ import java.lang.reflect.Field;
|
|
14
|
14
|
import java.math.BigDecimal;
|
|
15
|
15
|
import java.text.SimpleDateFormat;
|
|
16
|
16
|
import java.time.format.DateTimeFormatter;
|
|
17
|
|
-import java.util.ArrayList;
|
|
18
|
|
-import java.util.List;
|
|
|
17
|
+import java.util.*;
|
|
19
|
18
|
|
|
20
|
19
|
public class ExcelExporter {
|
|
21
|
20
|
|
|
22
|
21
|
|
|
23
|
|
- public static void exportToExcel(List<GrainSituationCardVO> data, List<GrainSituationCardWarehouseRecord> records,List<BusinessQcQualityInspection> bq, String fileName) throws IOException{
|
|
|
22
|
+ public static void exportToExcel(List<GrainSituationCardVO> data, List<GrainSituationCardWarehouseRecord> records, List<BusinessQcQualityInspection> bq, Map<Integer, List<String>> jsonData, String fileName) throws IOException{
|
|
24
|
23
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
|
25
|
24
|
XSSFSheet sheet = workbook.createSheet("原粮专卡");
|
|
26
|
25
|
|
|
|
@@ -148,33 +147,42 @@ public class ExcelExporter {
|
|
148
|
147
|
|
|
149
|
148
|
|
|
150
|
149
|
rowIndex++; // 新增一行作为质量检验的表头行
|
|
|
150
|
+ headerRow.createCell(0).setCellValue("质检报告单号");
|
|
|
151
|
+ headerRow.createCell(1).setCellValue("检验时间");
|
|
151
|
152
|
columnIndex = 0; // 重置列索引
|
|
152
|
153
|
for (String field : getFieldss()) {
|
|
153
|
154
|
Cell cell = sheet.createRow(rowIndex).createCell(columnIndex++);
|
|
154
|
155
|
cell.setCellValue(field);
|
|
155
|
156
|
cell.setCellStyle(headerCellStyle);
|
|
156
|
157
|
}
|
|
157
|
|
- // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
158
|
+// // 填充数据
|
|
|
159
|
+// int rowNum = 1;
|
|
|
160
|
+// for (Map<String, Object> record : jsonData) {
|
|
|
161
|
+// Row row = sheet.createRow(rowNum++);
|
|
|
162
|
+// row.createCell(0).setCellValue((String) record.get("zjbgdh"));
|
|
|
163
|
+// row.createCell(1).setCellValue((String) record.get("jysj"));
|
|
|
164
|
+//
|
|
|
165
|
+// // 填充动态检验项目值
|
|
|
166
|
+// Map<String, Object> maps = (Map<String, Object>) record.get("maps");
|
|
|
167
|
+// if (maps != null) {
|
|
|
168
|
+// List<String> items = (List<String>) maps.get(record.get("id").toString());
|
|
|
169
|
+// if (items != null) {
|
|
|
170
|
+// int col = 2; // 从第2列开始填充动态数据
|
|
|
171
|
+// for (String item : allInspectionItems) {
|
|
|
172
|
+// String value = "";
|
|
|
173
|
+// for (String checkItem : items) {
|
|
|
174
|
+// if (checkItem.startsWith(item + ":")) {
|
|
|
175
|
+// value = checkItem.split(": ")[1];
|
|
|
176
|
+// break;
|
|
|
177
|
+// }
|
|
|
178
|
+// }
|
|
|
179
|
+// }
|
|
|
180
|
+// row.createCell(col++).setCellValue(value);
|
|
|
181
|
+// }
|
|
|
182
|
+// }
|
|
|
183
|
+// }
|
|
|
184
|
+// }
|
|
158
|
185
|
|
|
159
|
|
- for (BusinessQcQualityInspection bqq : bq) {
|
|
160
|
|
- if (bqq == null) {
|
|
161
|
|
- continue; // 如果bqq是null,直接跳过当前循环迭代
|
|
162
|
|
- }
|
|
163
|
|
- rowIndex++; // 新增一行作为质量检验的表头行
|
|
164
|
|
- columnIndex = 0;
|
|
165
|
|
- Row row = sheet.createRow(rowIndex++);
|
|
166
|
|
-
|
|
167
|
|
- for (String field : getFieldss()) {
|
|
168
|
|
- Cell cell = row.createCell(columnIndex++);
|
|
169
|
|
- if ("检验类型".equals(field)){
|
|
170
|
|
- cell.setCellValue(bqq.getJylb() != null ? bqq.getJylb() : "无");
|
|
171
|
|
- } else if(("质检报告单号".equals(field))){
|
|
172
|
|
- cell.setCellValue(bqq.getZbjgpd()!= null ? bqq.getZbjgpd() : "无");
|
|
173
|
|
- } else if (bqq.getInspectionItemName().equals(field)) {
|
|
174
|
|
- cell.setCellValue(bqq.getInspectionValue() != null ? bqq.getInspectionValue() : "无");
|
|
175
|
|
- }
|
|
176
|
|
- }
|
|
177
|
|
- }
|
|
178
|
186
|
|
|
179
|
187
|
|
|
180
|
188
|
|