|
|
@@ -1,15 +1,14 @@
|
|
|
package com.template.controller;
|
|
|
|
|
|
|
|
|
+import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.template.api.SmartWarningControllerAPI;
|
|
|
import com.template.common.result.ResponseStatusEnum;
|
|
|
-import com.template.common.utils.ExcelUtils;
|
|
|
-import com.template.common.utils.ExcelUtils2;
|
|
|
-import com.template.common.utils.paramUtils;
|
|
|
+import com.template.common.utils.*;
|
|
|
import com.template.model.dto.OperationWarningDto;
|
|
|
import com.template.model.dto.WarningSavePushDto;
|
|
|
import com.template.model.pojo.SmartDepartment;
|
|
|
@@ -31,6 +30,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.yaml.snakeyaml.events.Event;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
@@ -144,10 +145,14 @@ public class SmartWarningController implements SmartWarningControllerAPI {
|
|
|
@Override
|
|
|
public void excelSmartWarning(HttpServletResponse response, String location, String state) {
|
|
|
// 表头数据
|
|
|
- List<Object> head = Arrays.asList("姓名", "事件", "地点", "时间", "备注", "状态", "图片");
|
|
|
+// List<Object> head = Arrays.asList("姓名","事件","地点","时间","备注","状态","图片");
|
|
|
+//
|
|
|
+// List<List<Object>> sheetDataList = new ArrayList<>();
|
|
|
+// sheetDataList.add(head);
|
|
|
|
|
|
- List<List<Object>> sheetDataList = new ArrayList<>();
|
|
|
- sheetDataList.add(head);
|
|
|
+
|
|
|
+ String fileName = "预警.xls";
|
|
|
+ List<WarningEntity> warningEntities = new ArrayList<>();
|
|
|
|
|
|
// 获取数据
|
|
|
LambdaQueryWrapper<SmartWarning> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -155,31 +160,44 @@ public class SmartWarningController implements SmartWarningControllerAPI {
|
|
|
.eq(ObjectUtils.isNotEmpty(state), SmartWarning::getStatu, state);
|
|
|
List<SmartWarning> list = smartWarningService.list(queryWrapper);
|
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(list) && list.size() > 0) {
|
|
|
- for (SmartWarning smartWarning : list) {
|
|
|
- List<Object> user = new ArrayList<>();
|
|
|
- user.add(smartWarning.getWarningName());
|
|
|
- user.add(smartWarning.getType());
|
|
|
- user.add(smartWarning.getLocation());
|
|
|
- user.add(smartWarning.getDateTime());
|
|
|
- user.add(smartWarning.getRemark());
|
|
|
- Integer statu = smartWarning.getStatu();
|
|
|
- String status = "";
|
|
|
- if (statu == 0) {
|
|
|
- status = "未处理";
|
|
|
- } else if (statu == 1) {
|
|
|
- status = "已处理";
|
|
|
- }
|
|
|
- user.add(status);
|
|
|
- user.add(smartWarning.getImage());
|
|
|
- // 将数据汇总
|
|
|
- sheetDataList.add(user);
|
|
|
+
|
|
|
+ for (SmartWarning smartWarning : list) {
|
|
|
+ WarningEntity warning = new WarningEntity();
|
|
|
+// if (ObjectUtils.isNotEmpty(smartWarning.getWarningName())) {
|
|
|
+ warning.setName(smartWarning.getWarningName());
|
|
|
+// }else {
|
|
|
+// user.add("无");
|
|
|
+// }
|
|
|
+
|
|
|
+ warning.setType(smartWarning.getType());
|
|
|
+
|
|
|
+ warning.setLocation(smartWarning.getLocation());
|
|
|
+
|
|
|
+ warning.setDateTime(smartWarning.getDateTime());
|
|
|
+
|
|
|
+ warning.setRemark(smartWarning.getRemark());
|
|
|
+
|
|
|
+ Integer statu = smartWarning.getStatu();
|
|
|
+ String status = "";
|
|
|
+ if (statu == 0) {
|
|
|
+ status = "未处理";
|
|
|
+ } else if (statu == 1) {
|
|
|
+ status = "已处理";
|
|
|
}
|
|
|
+ warning.setState(status);
|
|
|
+
|
|
|
+ warning.setImage(smartWarning.getImage());
|
|
|
|
|
|
+ // 将数据汇总
|
|
|
+ warningEntities.add(warning);
|
|
|
}
|
|
|
|
|
|
- // 导出数据
|
|
|
- ExcelUtils2.export(response, "预警表", sheetDataList);
|
|
|
+
|
|
|
+ try {
|
|
|
+ ExcelUtil3.process(fileName, warningEntities, WarningEntity.class, response);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|