248 lines
13 KiB
Plaintext
248 lines
13 KiB
Plaintext
|
|
package com.sercurityControl.proteam.dutyTask.controller;
|
||
|
|
|
||
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||
|
|
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
||
|
|
import com.github.pagehelper.PageHelper;
|
||
|
|
import com.github.pagehelper.PageInfo;
|
||
|
|
import com.securityControl.common.log.annotation.Log;
|
||
|
|
import com.securityControl.common.log.enums.BusinessType;
|
||
|
|
import com.securityControl.common.log.enums.OperationType;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.BallOnlineDetailEntity;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.BallOnlineStatisticEntity;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.BallStatusDetailEntity;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.BallStatusStatisticEntity;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.service.BallStatusStatisticService;
|
||
|
|
import com.sercurityControl.proteam.util.ExcelStyleUtil;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
||
|
|
import org.slf4j.Logger;
|
||
|
|
import org.slf4j.LoggerFactory;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import javax.annotation.Resource;
|
||
|
|
import javax.servlet.ServletOutputStream;
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
import java.net.URLEncoder;
|
||
|
|
import java.util.*;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 球机运行状态统计web层
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/pot/ballStatusStatistic/")
|
||
|
|
public class BallStatusStatisticWeb {
|
||
|
|
|
||
|
|
Logger logger = LoggerFactory.getLogger(BallStatusStatisticWeb.class);
|
||
|
|
|
||
|
|
@Resource(name = "BallStatusStatisticService")
|
||
|
|
private BallStatusStatisticService service;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
||
|
|
* @author cw chen
|
||
|
|
* @description 球机开机情况统计
|
||
|
|
* @Param entity
|
||
|
|
* @date 2023-04-21 16:25
|
||
|
|
*/
|
||
|
|
@ApiOperation(value = "值班任务-球机运行状态列表-球机开机情况统计")
|
||
|
|
@PostMapping(value = "getBallKjList")
|
||
|
|
@Log(title = "球机运行状态", menu = "值班任务->球机运行状态", businessType = BusinessType.QUERY, details = "球机运行状态-球机开机情况统计")
|
||
|
|
public Map<String, Object> getBallKjList(BallStatusStatisticEntity entity) {
|
||
|
|
PageHelper.startPage(Integer.parseInt(entity.getPage()), Integer.parseInt(entity.getLimit()));
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageInfo<BallStatusStatisticEntity> pageInfo = service.getBallKjList(entity);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "获取数据失败");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
logger.error("球机运行状态列表", e);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
||
|
|
* @author cw chen
|
||
|
|
* @description 球机运行状态-球机未开机详情
|
||
|
|
* @Param entity
|
||
|
|
* @date 2023-04-23 15:45
|
||
|
|
*/
|
||
|
|
@ApiOperation(value = "值班任务-球机运行状态列表-球机未开机详情")
|
||
|
|
@PostMapping(value = "getBallOffLineList")
|
||
|
|
@Log(title = "球机未开机详情", menu = "值班任务->球机未开机详情", businessType = BusinessType.QUERY, details = "球机运行状态-球机未开机详情")
|
||
|
|
public Map<String, Object> getBallOffLineList(BallStatusDetailEntity entity) {
|
||
|
|
PageHelper.startPage(Integer.parseInt(entity.getPage()), Integer.parseInt(entity.getLimit()));
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageInfo<BallStatusDetailEntity> pageInfo = service.getBallOffLineList(entity);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "获取数据失败");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
logger.error("球机运行状态列表", e);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return java.util.Map<java.lang.String, java.lang.Object>
|
||
|
|
* @author cw chen
|
||
|
|
* @description 球机在线时长情况统计
|
||
|
|
* @Param entity
|
||
|
|
* @date 2023-04-21 16:25
|
||
|
|
*/
|
||
|
|
@ApiOperation(value = "值班任务-球机运行状态列表-球机在线时长情况统计")
|
||
|
|
@PostMapping(value = "getBallHgList")
|
||
|
|
@Log(title = "球机在线时长情况统计", menu = "值班任务->球机在线时长情况统计", businessType = BusinessType.QUERY, details = "球机运行状态-球机在线时长情况统计")
|
||
|
|
public Map<String, Object> getBallHgList(BallOnlineStatisticEntity entity) {
|
||
|
|
PageHelper.startPage(Integer.parseInt(entity.getPage()), Integer.parseInt(entity.getLimit()));
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageInfo<BallOnlineStatisticEntity> pageInfo = service.getBallHgList(entity);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "获取数据失败");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
logger.error("球机在线时长情况统计", e);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation(value = "值班任务-球机运行状态列表-球机在线时长不合格详情")
|
||
|
|
@PostMapping(value = "getBallBhgDetailList")
|
||
|
|
@Log(title = "球机在线时长不合格详情", menu = "值班任务->球机在线时长不合格详情", businessType = BusinessType.QUERY, details = "球机运行状态-球机在线时长不合格详情")
|
||
|
|
public Map<String, Object> getBallBhgDetailList(BallOnlineDetailEntity entity) {
|
||
|
|
PageHelper.startPage(Integer.parseInt(entity.getPage()), Integer.parseInt(entity.getLimit()));
|
||
|
|
Map<String, Object> map = new HashMap<String, Object>(16);
|
||
|
|
try {
|
||
|
|
PageInfo<BallOnlineDetailEntity> pageInfo = service.getBallBhgDetailList(entity);
|
||
|
|
map.put("code", 200);
|
||
|
|
map.put("msg", "获取数据成功");
|
||
|
|
map.put("count", pageInfo.getTotal());
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", pageInfo.getList());
|
||
|
|
} catch (Exception e) {
|
||
|
|
map.put("code", 500);
|
||
|
|
map.put("msg", "获取数据失败");
|
||
|
|
map.put("count", 0);
|
||
|
|
map.put("curr", Integer.parseInt(entity.getPage()));
|
||
|
|
map.put("limit", Integer.parseInt(entity.getLimit()));
|
||
|
|
map.put("data", null);
|
||
|
|
logger.error("球机在线时长不合格详情", e);
|
||
|
|
}
|
||
|
|
return map;
|
||
|
|
}
|
||
|
|
|
||
|
|
@GetMapping(value = "exportData")
|
||
|
|
@Log(title = "球机运行情况导出", menu = "值班任务->球机运行情况导出", businessType = BusinessType.EXPORT, details = "球机运行情况导出", grade = OperationType.EXPORT_BUSINESS)
|
||
|
|
public void exportData(HttpServletRequest request, HttpServletResponse response, BallStatusDetailEntity entity, BallOnlineDetailEntity o) {
|
||
|
|
String titleName = "球机未开机详情";
|
||
|
|
if (Objects.equals("2", entity.getType())) {
|
||
|
|
titleName = "球机在线时长不合格详情";
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
List<BallStatusDetailEntity> list = new ArrayList<>();
|
||
|
|
List<BallOnlineDetailEntity> list2 = new ArrayList<>();
|
||
|
|
if (Objects.equals("1", entity.getType())) {
|
||
|
|
PageInfo<BallStatusDetailEntity> pageInfo = service.getBallOffLineList(entity);
|
||
|
|
list = pageInfo.getList();
|
||
|
|
for (int i = 0; i < list.size(); i++) {
|
||
|
|
list.get(i).setId((i + 1) + "");
|
||
|
|
list.get(i).setBallStatus("未开机");
|
||
|
|
list.get(i).setWorkManager(list.get(i).getWorkManager() + "\r\n" + list.get(i).getWorkManagerPhone());
|
||
|
|
}
|
||
|
|
} else if (Objects.equals("2", entity.getType())) {
|
||
|
|
PageInfo<BallOnlineDetailEntity> pageInfo2 = service.getBallBhgDetailList(o);
|
||
|
|
list2 = pageInfo2.getList();
|
||
|
|
for (int i = 0; i < list2.size(); i++) {
|
||
|
|
list2.get(i).setId((i + 1) + "");
|
||
|
|
list2.get(i).setWorkManager(list2.get(i).getWorkManager() + "\r\n" + list2.get(i).getWorkManagerPhone());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ExportParams exportParams = new ExportParams(titleName, titleName, ExcelType.XSSF);
|
||
|
|
exportParams.setStyle(ExcelStyleUtil.class);
|
||
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, Objects.equals("1", entity.getType()) ? BallStatusDetailEntity.class : BallOnlineDetailEntity.class, Objects.equals("1", entity.getType()) ? list : list2);
|
||
|
|
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode(titleName + ".xlsx", "UTF-8"));
|
||
|
|
response.reset();
|
||
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
||
|
|
workbook.write(outputStream);
|
||
|
|
outputStream.close();
|
||
|
|
workbook.close();
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("球机未开机详情导出/球机在线时长不合格详情", e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@GetMapping(value = "exportData2")
|
||
|
|
@Log(title = "球机运行情况导出", menu = "值班任务->球机运行情况导出", businessType = BusinessType.EXPORT, details = "球机运行情况导出", grade = OperationType.EXPORT_BUSINESS)
|
||
|
|
public void exportData2(HttpServletRequest request, HttpServletResponse response, BallStatusStatisticEntity entity, BallOnlineStatisticEntity o) {
|
||
|
|
String titleName = "当日球机开机情况统计";
|
||
|
|
if (Objects.equals("2", entity.getType())) {
|
||
|
|
titleName = "当日球机在线时长情况统计";
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
List<BallStatusStatisticEntity> list = new ArrayList<>();
|
||
|
|
List<BallOnlineStatisticEntity> list2 = new ArrayList<>();
|
||
|
|
if (Objects.equals("1", entity.getType())) {
|
||
|
|
PageInfo<BallStatusStatisticEntity> pageInfo = service.getBallKjList(entity);
|
||
|
|
list = pageInfo.getList();
|
||
|
|
for (int i = 0; i < list.size(); i++) {
|
||
|
|
list.get(i).setId((i + 1) + "");
|
||
|
|
}
|
||
|
|
} else if (Objects.equals("2", entity.getType())) {
|
||
|
|
PageInfo<BallOnlineStatisticEntity> pageInfo2 = service.getBallHgList(o);
|
||
|
|
list2 = pageInfo2.getList();
|
||
|
|
for (int i = 0; i < list2.size(); i++) {
|
||
|
|
list2.get(i).setId((i + 1) + "");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ExportParams exportParams = new ExportParams(titleName, titleName, ExcelType.XSSF);
|
||
|
|
exportParams.setStyle(ExcelStyleUtil.class);
|
||
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, Objects.equals("1", entity.getType()) ? BallStatusStatisticEntity.class : BallOnlineStatisticEntity.class, Objects.equals("1", entity.getType()) ? list : list2);
|
||
|
|
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode(titleName + ".xlsx", "UTF-8"));
|
||
|
|
response.reset();
|
||
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
||
|
|
workbook.write(outputStream);
|
||
|
|
outputStream.close();
|
||
|
|
workbook.close();
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("当日球机开机情况统计/当日球机在线时长情况统计", e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|