|
|
|
|
@ -1,37 +1,46 @@
|
|
|
|
|
package cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord;
|
|
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceOperationOverviewRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceOperationRateTrendRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceOperationRecordPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceOperationRecordRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceOperationRecordSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceTotalTimeRecordReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.DeviceTotalTimeRecordRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.service.deviceoperationrecord.DeviceOperationRecordService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.*;
|
|
|
|
|
import javax.validation.*;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.deviceoperationrecord.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.deviceoperationrecord.DeviceOperationRecordDO;
|
|
|
|
|
import cn.iocoder.yudao.module.iot.service.deviceoperationrecord.DeviceOperationRecordService;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "管理后台 - 运行记录")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/iot/device-operation-record")
|
|
|
|
|
@ -90,7 +99,6 @@ public class DeviceOperationRecordController {
|
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
List<DeviceOperationRecordDO> list = deviceOperationRecordService.getDeviceOperationRecordPage(pageReqVO).getList();
|
|
|
|
|
// 导出 Excel
|
|
|
|
|
ExcelUtils.write(response, "运行记录.xls", "数据", DeviceOperationRecordRespVO.class,
|
|
|
|
|
BeanUtils.toBean(list, DeviceOperationRecordRespVO.class));
|
|
|
|
|
}
|
|
|
|
|
@ -111,30 +119,31 @@ public class DeviceOperationRecordController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/deviceRateTrendByDeviceId")
|
|
|
|
|
@Operation(summary = "根据设备ID查询某个设备开机率和稼动率")
|
|
|
|
|
@Operation(summary = "根据设备 ID 查询单设备开机率和利用率趋势")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:query')")
|
|
|
|
|
public CommonResult<List<DeviceOperationRateTrendRespVO>> getDeviceRateTrendByDeviceId(@RequestParam("deviceId") Long deviceId,
|
|
|
|
|
public CommonResult<List<DeviceOperationRateTrendRespVO>> getDeviceRateTrendByDeviceId(
|
|
|
|
|
@RequestParam("deviceId") Long deviceId,
|
|
|
|
|
@RequestParam(value = "period", required = false) String period) {
|
|
|
|
|
return success(deviceOperationRecordService.getDeviceRateTrendByDeviceId(deviceId, period));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/deviceOperationList")
|
|
|
|
|
@Operation(summary = "产线设备运行开机率/稼动率-大屏")
|
|
|
|
|
@Operation(summary = "产线设备运行开机率/利用率大屏")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:query')")
|
|
|
|
|
public CommonResult<List<DeviceTotalTimeRecordRespVO>> deviceOperationList(@Valid DeviceTotalTimeRecordReqVO pageReqVO) {
|
|
|
|
|
List<DeviceTotalTimeRecordRespVO> deviceTotalTimeRecordRespVOList = deviceOperationRecordService.deviceOperationList(pageReqVO);
|
|
|
|
|
return success(deviceTotalTimeRecordRespVOList);
|
|
|
|
|
return success(deviceOperationRecordService.deviceOperationList(pageReqVO));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/runOverview")
|
|
|
|
|
@Operation(summary = "设备运行总览")
|
|
|
|
|
@Operation(
|
|
|
|
|
summary = "设备运行总览",
|
|
|
|
|
description = "根据设备 ID 集合、统计时间范围和时间轴分页参数,返回运行总览指标卡、按小时状态分布、状态汇总以及设备时间轴数据"
|
|
|
|
|
)
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:query')")
|
|
|
|
|
public CommonResult<DeviceOperationOverviewRespVO> runOverview(@Valid DeviceTotalTimeRecordReqVO pageReqVO) {
|
|
|
|
|
return success(deviceOperationRecordService.runOverview(pageReqVO));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export-device-operation-report")
|
|
|
|
|
@Operation(summary = "导出设备运行报表记录 Excel")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('iot:device-operation-record:export')")
|
|
|
|
|
@ -142,14 +151,12 @@ public class DeviceOperationRecordController {
|
|
|
|
|
public void exportDeviceOperationReport(@Valid DeviceTotalTimeRecordReqVO pageReqVO,
|
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
|
PageResult<DeviceTotalTimeRecordRespVO> pageResult = deviceOperationRecordService.deviceOperationPage(pageReqVO);
|
|
|
|
|
// 设置响应头
|
|
|
|
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
|
|
|
|
response.setHeader("Content-Disposition",
|
|
|
|
|
"attachment;filename=" + URLEncoder.encode("设备运行报表记录.xls", "UTF-8"));
|
|
|
|
|
response.setHeader("Content-Encoding", "identity");
|
|
|
|
|
// 导出Excel
|
|
|
|
|
String fileName = String.format("设备运行报表记录_%s.xls", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
|
|
// 导出 Excel
|
|
|
|
|
ExcelUtils.write(response, fileName, "数据", DeviceTotalTimeRecordRespVO.class,pageResult.getList());
|
|
|
|
|
String fileName = String.format("设备运行报表记录_%s.xls",
|
|
|
|
|
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
|
|
|
|
|
ExcelUtils.write(response, fileName, "数据", DeviceTotalTimeRecordRespVO.class, pageResult.getList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|