|
@@ -1,6 +1,8 @@
|
|
|
package com.szwl.controller;
|
|
|
|
|
|
|
|
|
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
|
|
+import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
|
import cn.com.crbank.ommo.bean.ResultMessage;
|
|
|
import cn.com.crbank.ommo.esUtil.BeanUtils;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
@@ -28,6 +30,7 @@ import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.bo.UserDetailBO;
|
|
|
import com.szwl.model.entity.*;
|
|
|
+import com.szwl.model.param.EquipmentParam;
|
|
|
import com.szwl.model.param.PasswordParam;
|
|
|
import com.szwl.model.query.StatisticsParam;
|
|
|
import com.szwl.model.utils.DateUtils;
|
|
@@ -38,6 +41,7 @@ import com.szwl.util.DownloadUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -45,8 +49,10 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.net.URL;
|
|
|
import java.net.URLConnection;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -1842,5 +1848,48 @@ public class TEquipmentController {
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("获取设备总数")
|
|
|
+ @GetMapping("/getEquipmentTotal")
|
|
|
+ public ResponseModel<String> getEquipmentTotal(String adminId) {
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TEquipment::getAdminId, adminId);
|
|
|
+ List<TEquipment> list = tEquipmentService.list(query);
|
|
|
+ return R.ok(String.valueOf(list.size()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("导出设备列表")
|
|
|
+ @GetMapping("/exportEquipment")
|
|
|
+ public void exportEquipment(HttpServletResponse response) {
|
|
|
+ LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
|
|
|
+ query.between(TEquipment::getLastUpdateTime, "2024-10-01", "2024-11-08");
|
|
|
+ List<TEquipment> list = tEquipmentService.list(query);
|
|
|
+ ExportParams exportParams = new ExportParams("设备列表", "sheet1");
|
|
|
+ List<EquipmentParam> orderByAdminTargetList = list.stream().map(tEquipment -> {
|
|
|
+ EquipmentParam equipmentParam = new EquipmentParam();
|
|
|
+ equipmentParam.setEquipmentName(tEquipment.getName());
|
|
|
+ equipmentParam.setAreaName(tEquipment.getFullName());
|
|
|
+ equipmentParam.setClientId(tEquipment.getClientId());
|
|
|
+ return equipmentParam;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, EquipmentParam.class, orderByAdminTargetList);
|
|
|
+ if (workbook != null) {
|
|
|
+ OutputStream os = null;
|
|
|
+ try {
|
|
|
+ os = response.getOutputStream();
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("设备列表" + ".xls", "UTF-8"));
|
|
|
+ workbook.write(os);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ os.close();
|
|
|
+ workbook.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|