Browse Source

检查日志代码提交

jingyuanchao 1 year ago
parent
commit
8559eca749

+ 18 - 0
project_data/sql/0.1.1/soc/soc.sql

@@ -963,6 +963,7 @@ INSERT INTO `sys_menu` VALUES ('01806205680513429506', '升级包管理', '18062
 INSERT INTO `sys_menu` VALUES ('01806206030435823618', '升级状态查询', '1806204625679527938', '3', 'upgradeStatus', 'deploy/upgradeStatus/index', null, '1', '0', 'C', '0', '0', 'deploy:upgradeStatus:list', '1', 'documentation', null, '超级管理员', '2024-06-27 14:00:50', '', null, '');
 INSERT INTO `sys_menu` VALUES ('01806206236392927233', '白令海管理', '1806204625679527938', '4', 'bering', 'deploy/bering/index', null, '1', '0', 'C', '0', '0', 'deploy:bering:list', '1', 'component', null, '超级管理员', '2024-06-27 14:01:39', '', null, '');
 INSERT INTO `sys_menu` VALUES ('01808375108978040834', '日志', '1806204625679527938', '5', 'log', 'deploy/log/index', null, '1', '0', 'C', '0', '0', 'deploy:log:list', '1', 'log', null, '超级管理员', '2024-07-03 13:39:58', '', null, '');
+INSERT INTO sys_menu (id, menu_name, parent_id, order_num, path, component, query, is_frame, is_cache, menu_type, visible, status, perms, platform_type, icon, image_path, create_by, create_time, update_by, update_time, remark) VALUES (1831141820470513666, '自检日志', 1806204625679527938, 9, 'dailyCheck', 'deploy/dailycheck/index', null, 1, 0, 'C', '0', '0', '', '1', 'dashboard', null, '超级管理员', '2024-09-04 09:26:41', '景远超', '2024-09-04 09:30:01', '');
 
 -- 新增巡检主机接入服务菜单
 delete from sys_menu where  id in ('1810216137011572738');
@@ -1063,3 +1064,20 @@ INSERT INTO  `iot_alarm_system_field`(`id`, `source_type`, `source_type_des`, `s
 delete from sys_dict_data where dict_type = 'sensor_alarm_status' and dict_value='2';
 insert into sys_dict_data (dict_sort, dict_label, dict_value, dict_type, list_class, status, create_by, create_time) values (2, '未配置告警规则', '2', 'sensor_alarm_status', 'default', '0', '', sysdate());
 
+drop table if exists iot_daily_check_data;
+create table iot_daily_check_data
+(
+    id          bigint       not null comment 'id'
+        primary key,
+    org_id      bigint       null comment '机构id',
+    org_name    varchar(125) null comment '机构名称',
+    org_path    varchar(125) null comment '机构path',
+    iot_code    varchar(125) null comment '主机token',
+    file_name   varchar(225) null comment '文件名称',
+    user_name   varchar(255) null comment '执行人',
+    record_date datetime     null comment '自检时间',
+    data        text         null comment '自检结果,json形式',
+    create_time datetime     null comment '创建时间',
+    update_time datetime     null comment '修改时间'
+)
+    comment '网点日常自检日志表';

+ 5 - 0
soc-modules/soc-modules-deploy/src/main/java/com/xunmei/deploy/controller/IotDailyCheckDataController.java

@@ -55,5 +55,10 @@ public class IotDailyCheckDataController {
 
     }
 
+    @PostMapping("/export")
+    public void export(DailyCheckDataPageDto req, HttpServletResponse response) {
+        dailyCheckDataService.export(req, response);
+
+    }
 }
 

+ 2 - 0
soc-modules/soc-modules-deploy/src/main/java/com/xunmei/deploy/service/IotDailyCheckDataService.java

@@ -26,4 +26,6 @@ public interface IotDailyCheckDataService extends IService<IotDailyCheckData> {
     DailyCheckDataStatisticsData statistics(DailyCheckDataPageDto req);
 
     DailyCheckDataRateData rate(DailyCheckDataPageDto req);
+
+    void export(DailyCheckDataPageDto req, HttpServletResponse response);
 }

+ 26 - 0
soc-modules/soc-modules-deploy/src/main/java/com/xunmei/deploy/service/impl/IotDailyCheckDataServiceImpl.java

@@ -4,6 +4,8 @@ import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -292,4 +294,28 @@ public class IotDailyCheckDataServiceImpl extends ServiceImpl<IotDailyCheckDataM
         return headerStyle;
     }
 
+    @Override
+    public void export(DailyCheckDataPageDto req, HttpServletResponse response) {
+        req.setPageSize(Integer.MAX_VALUE);
+        TableDataInfo page = this.selectPage(req);
+        List<DailyCheckDataPageVo> rows = page.getRows();
+        if (ObjectUtil.isEmpty(rows)){
+            throw new RuntimeException("暂无可用数据导出");
+        }
+        List<DailyCheckDataPageVo> collect = rows.stream().peek(r -> r.setId((long) rows.indexOf(r) + 1)).collect(Collectors.toList());
+        try {
+            // 设置响应头
+            response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("自检日志", "utf-8"));
+            response.setContentType("application/octet-stream;charset=UTF-8");
+            response.setCharacterEncoding("utf-8");
+            // 数据导出
+            EasyExcel.write(response.getOutputStream(), DailyCheckDataPageVo.class)
+                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).sheet("演练任务").doWrite(collect);
+        } catch (Exception e) {
+            // 重置response
+            response.reset();
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+        }
+    }
 }

+ 10 - 0
soc-modules/soc-modules-deploy/src/main/java/com/xunmei/deploy/vo/DailyCheckDataPageVo.java

@@ -1,5 +1,7 @@
 package com.xunmei.deploy.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -9,28 +11,36 @@ import java.util.Date;
 @Data
 public class DailyCheckDataPageVo {
 
+    @ExcelProperty(value = "序号", index = 0)
     @ApiModelProperty("主键")
     private Long id;
 
+    @ExcelProperty(value = "地区", index = 1)
     @ApiModelProperty("地区")
     private String affiliatedArea;
 
+    @ExcelProperty(value = "行社", index = 2)
     @ApiModelProperty("行社")
     private String affiliatedBank;
 
+    @ExcelIgnore
     @ApiModelProperty("所属机构id")
     private Long orgId;
 
+    @ExcelProperty(value = "所属机构", index = 3)
     @ApiModelProperty("所属机构名称")
     private String orgName;
 
+    @ExcelProperty(value = "文件名称", index = 4)
     @ApiModelProperty("文件名称")
     private String fileName;
 
+    @ExcelProperty(value = "自检日期", index = 5)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty("自检日期")
     private Date recordDate;
 
+    @ExcelProperty(value = "执行人", index = 6)
     @ApiModelProperty("执行人")
     private String userName;