Commit 2770af398da08b3b938726ef5e26cdbabbc9ae13
1 parent
bde82a60
fix: 新增导出功能
Showing
14 changed files
with
346 additions
and
6 deletions
ruoyi-admin/src/main/java/com/ruoyi/common/SignInEnum.java
| @@ -9,4 +9,24 @@ public interface SignInEnum { | @@ -9,4 +9,24 @@ public interface SignInEnum { | ||
| 9 | * 签退 | 9 | * 签退 |
| 10 | */ | 10 | */ |
| 11 | Integer SIGNIN_OUT = 2; | 11 | Integer SIGNIN_OUT = 2; |
| 12 | + | ||
| 13 | + String SIGN_IN_STRING = "签到"; | ||
| 14 | + String SIGN_IN_OUT_STRING = "签退"; | ||
| 15 | + String FACE_SIGN_IN = "人脸"; | ||
| 16 | + String CARD_SIGN_IN = "刷卡"; | ||
| 17 | + String OTHER_SIGN_IN = "其他"; | ||
| 18 | + String ALCOHOL_SIGN_IN = "酒精"; | ||
| 19 | + | ||
| 20 | + String SIGN_IN_SUCCESS_STRING = "签到成功"; | ||
| 21 | + Integer SIGN_IN_SUCCESS = 1; | ||
| 22 | + String SIGN_IN_FAIL_STRING = "签到失败"; | ||
| 23 | + Integer SIGN_IN_FAIL = 2; | ||
| 24 | + | ||
| 25 | + Integer ALCOHOL_FLAG_YES = 1; | ||
| 26 | + String ALCOHOL_FLAG_YES_STRING = "已测试"; | ||
| 27 | + Integer ALCOHOL_FLAG_NO = 2; | ||
| 28 | + String ALCOHOL_FLAG_NO_STRING = "未测试"; | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 12 | } | 32 | } |
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
| 1 | package com.ruoyi.controller; | 1 | package com.ruoyi.controller; |
| 2 | 2 | ||
| 3 | import com.ruoyi.common.core.domain.AjaxResult; | 3 | import com.ruoyi.common.core.domain.AjaxResult; |
| 4 | +import com.ruoyi.common.utils.poi.ExcelUtil; | ||
| 4 | import com.ruoyi.pojo.request.ReportViewRequestVo; | 5 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| 5 | import com.ruoyi.pojo.request.ReportErrorRequestVo; | 6 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| 7 | +import com.ruoyi.pojo.response.ReportErrorResponseVo; | ||
| 8 | +import com.ruoyi.pojo.response.ReportViewResponseVo; | ||
| 6 | import com.ruoyi.service.ReportService; | 9 | import com.ruoyi.service.ReportService; |
| 7 | import io.swagger.annotations.Api; | 10 | import io.swagger.annotations.Api; |
| 8 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; |
| @@ -10,6 +13,8 @@ import io.swagger.annotations.ApiParam; | @@ -10,6 +13,8 @@ import io.swagger.annotations.ApiParam; | ||
| 10 | import org.springframework.web.bind.annotation.*; | 13 | import org.springframework.web.bind.annotation.*; |
| 11 | 14 | ||
| 12 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 16 | +import javax.servlet.http.HttpServletResponse; | ||
| 17 | +import java.util.List; | ||
| 13 | 18 | ||
| 14 | /** | 19 | /** |
| 15 | * @author 20412 | 20 | * @author 20412 |
| @@ -33,4 +38,20 @@ public class ReportController { | @@ -33,4 +38,20 @@ public class ReportController { | ||
| 33 | public AjaxResult getErrorList(@ApiParam @ModelAttribute ReportErrorRequestVo request) { | 38 | public AjaxResult getErrorList(@ApiParam @ModelAttribute ReportErrorRequestVo request) { |
| 34 | return AjaxResult.success(reportService.getErrorReportList(request)); | 39 | return AjaxResult.success(reportService.getErrorReportList(request)); |
| 35 | } | 40 | } |
| 41 | + | ||
| 42 | + @ApiOperation("签到报表导出") | ||
| 43 | + @PostMapping("/export") | ||
| 44 | + public void exportReport(@ApiParam ReportViewRequestVo requestVo, HttpServletResponse response){ | ||
| 45 | + List<ReportViewResponseVo> list = reportService.getReportScrollViewTable(requestVo); | ||
| 46 | + ExcelUtil<ReportViewResponseVo> util = new ExcelUtil<ReportViewResponseVo>(ReportViewResponseVo.class); | ||
| 47 | + util.exportEasyExcel(response, list, "操作日志"); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @ApiOperation("异常报表导出") | ||
| 51 | + @PostMapping("/error/export") | ||
| 52 | + public void exportErrorReport(@ApiParam ReportErrorRequestVo requestVo,HttpServletResponse response){ | ||
| 53 | + List<ReportErrorResponseVo> list = reportService.getErrorReportList(requestVo); | ||
| 54 | + ExcelUtil<ReportErrorResponseVo> util = new ExcelUtil<ReportErrorResponseVo>(ReportErrorResponseVo.class); | ||
| 55 | + util.exportEasyExcel(response, list, "操作日志"); | ||
| 56 | + } | ||
| 36 | } | 57 | } |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/AlcoholFlagConverter.java
0 → 100644
| 1 | +package com.ruoyi.pojo.converter; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.converters.Converter; | ||
| 4 | +import com.alibaba.excel.enums.CellDataTypeEnum; | ||
| 5 | +import com.alibaba.excel.metadata.CellData; | ||
| 6 | +import com.alibaba.excel.metadata.GlobalConfiguration; | ||
| 7 | +import com.alibaba.excel.metadata.property.ExcelContentProperty; | ||
| 8 | + | ||
| 9 | +import static com.ruoyi.common.SignInEnum.*; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 酒精测试 | ||
| 13 | + * @author 20412 | ||
| 14 | + */ | ||
| 15 | +@SuppressWarnings(value = {"unchecked", "rawtypes"}) | ||
| 16 | +public class AlcoholFlagConverter implements Converter<Integer> { | ||
| 17 | + @Override | ||
| 18 | + public Class supportJavaTypeKey() { | ||
| 19 | + return Integer.class; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public CellDataTypeEnum supportExcelTypeKey() { | ||
| 24 | + return CellDataTypeEnum.STRING; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 29 | + return null; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 34 | + String str = ""; | ||
| 35 | + if (ALCOHOL_FLAG_YES.equals(integer)){ | ||
| 36 | + str = ALCOHOL_FLAG_NO_STRING; | ||
| 37 | + } | ||
| 38 | + if (ALCOHOL_FLAG_NO.equals(integer)){ | ||
| 39 | + str = ALCOHOL_FLAG_NO_STRING; | ||
| 40 | + } | ||
| 41 | + return new CellData(str); | ||
| 42 | + } | ||
| 43 | +} |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInConvert.java
0 → 100644
| 1 | +package com.ruoyi.pojo.converter; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.converters.Converter; | ||
| 4 | +import com.alibaba.excel.enums.CellDataTypeEnum; | ||
| 5 | +import com.alibaba.excel.metadata.CellData; | ||
| 6 | +import com.alibaba.excel.metadata.GlobalConfiguration; | ||
| 7 | +import com.alibaba.excel.metadata.property.ExcelContentProperty; | ||
| 8 | + | ||
| 9 | +import static com.ruoyi.common.SignInEnum.*; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 签到类型 | ||
| 13 | + * @author 20412 | ||
| 14 | + */ | ||
| 15 | +@SuppressWarnings(value = {"unchecked", "rawtypes"}) | ||
| 16 | +public class SignInConvert implements Converter<Integer> { | ||
| 17 | + @Override | ||
| 18 | + public Class supportJavaTypeKey() { | ||
| 19 | + return Integer.class; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public CellDataTypeEnum supportExcelTypeKey() { | ||
| 24 | + return CellDataTypeEnum.STRING; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 29 | + return null; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 34 | + String str = ""; | ||
| 35 | + if (SIGN_IN.equals(integer)){ | ||
| 36 | + str = SIGN_IN_STRING; | ||
| 37 | + } | ||
| 38 | + if (SIGNIN_OUT.equals(integer)){ | ||
| 39 | + str = SIGN_IN_OUT_STRING; | ||
| 40 | + } | ||
| 41 | + return new CellData(str); | ||
| 42 | + } | ||
| 43 | +} |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInStatusConverter.java
0 → 100644
| 1 | +package com.ruoyi.pojo.converter; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.converters.Converter; | ||
| 4 | +import com.alibaba.excel.enums.CellDataTypeEnum; | ||
| 5 | +import com.alibaba.excel.metadata.CellData; | ||
| 6 | +import com.alibaba.excel.metadata.GlobalConfiguration; | ||
| 7 | +import com.alibaba.excel.metadata.property.ExcelContentProperty; | ||
| 8 | + | ||
| 9 | +import static com.ruoyi.common.SignInEnum.*; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * @author 20412 | ||
| 13 | + * 签到成功还是失败转换 | ||
| 14 | + */ | ||
| 15 | +@SuppressWarnings(value = {"unchecked", "rawtypes"}) | ||
| 16 | +public class SignInStatusConverter implements Converter<Integer> { | ||
| 17 | + @Override | ||
| 18 | + public Class supportJavaTypeKey() { | ||
| 19 | + return Integer.class; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + @Override | ||
| 23 | + public CellDataTypeEnum supportExcelTypeKey() { | ||
| 24 | + return CellDataTypeEnum.STRING; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @Override | ||
| 28 | + public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 29 | + String value = cellData.getStringValue(); | ||
| 30 | + if (SIGN_IN_SUCCESS_STRING.equals(value)){ | ||
| 31 | + return 1; | ||
| 32 | + } | ||
| 33 | + if (SIGN_IN_FAIL_STRING.equals(value)){ | ||
| 34 | + return 2; | ||
| 35 | + } | ||
| 36 | + return Integer.parseInt(value); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 41 | + String str = ""; | ||
| 42 | + if (SIGN_IN_SUCCESS.equals(integer)){ | ||
| 43 | + str = SIGN_IN_SUCCESS_STRING; | ||
| 44 | + } | ||
| 45 | + if (SIGN_IN_FAIL.equals(integer)){ | ||
| 46 | + str = SIGN_IN_FAIL_STRING; | ||
| 47 | + } | ||
| 48 | + return new CellData(str); | ||
| 49 | + } | ||
| 50 | +} |
ruoyi-admin/src/main/java/com/ruoyi/pojo/converter/SignInTypeConverter.java
0 → 100644
| 1 | +package com.ruoyi.pojo.converter; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.converters.Converter; | ||
| 4 | +import com.alibaba.excel.enums.CellDataTypeEnum; | ||
| 5 | +import com.alibaba.excel.metadata.CellData; | ||
| 6 | +import com.alibaba.excel.metadata.GlobalConfiguration; | ||
| 7 | +import com.alibaba.excel.metadata.property.ExcelContentProperty; | ||
| 8 | + | ||
| 9 | +import static com.ruoyi.common.SignInEnum.*; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * @author 20412 | ||
| 13 | + * 签到类型 | ||
| 14 | + */ | ||
| 15 | +// 取消显示的警告 | ||
| 16 | +@SuppressWarnings(value = {"unchecked", "rawtypes"}) | ||
| 17 | +public class SignInTypeConverter implements Converter<String> { | ||
| 18 | + | ||
| 19 | + @Override | ||
| 20 | + public Class supportJavaTypeKey() { | ||
| 21 | + return String.class; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public CellDataTypeEnum supportExcelTypeKey() { | ||
| 26 | + return CellDataTypeEnum.STRING; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 导入功能 保留 | ||
| 31 | + * @param cellData | ||
| 32 | + * @param excelContentProperty | ||
| 33 | + * @param globalConfiguration | ||
| 34 | + * @return | ||
| 35 | + * @throws Exception | ||
| 36 | + */ | ||
| 37 | + @Override | ||
| 38 | + public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 39 | + return null; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 导出转换 | ||
| 44 | + * @param value | ||
| 45 | + * @param excelContentProperty | ||
| 46 | + * @param globalConfiguration | ||
| 47 | + * @return | ||
| 48 | + * @throws Exception | ||
| 49 | + */ | ||
| 50 | + @Override | ||
| 51 | + public CellData convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception { | ||
| 52 | + String str = ""; | ||
| 53 | + String[] values = value.split(","); | ||
| 54 | + for (String s : values) { | ||
| 55 | + switch (s){ | ||
| 56 | + case "0": str = str + FACE_SIGN_IN + ",";break; | ||
| 57 | + case "1": str = str + CARD_SIGN_IN + ",";break; | ||
| 58 | + case "2": str = str + OTHER_SIGN_IN + ",";break; | ||
| 59 | + case "3": str = str + ALCOHOL_SIGN_IN + ",";break; | ||
| 60 | + default: break; | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + return new CellData(str); | ||
| 64 | + } | ||
| 65 | +} |
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/ReportErrorRequestVo.java
| @@ -7,6 +7,7 @@ import lombok.Data; | @@ -7,6 +7,7 @@ import lombok.Data; | ||
| 7 | import org.springframework.format.annotation.DateTimeFormat; | 7 | import org.springframework.format.annotation.DateTimeFormat; |
| 8 | 8 | ||
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | +import java.util.List; | ||
| 10 | 11 | ||
| 11 | /** | 12 | /** |
| 12 | * 异常报表请求 | 13 | * 异常报表请求 |
| @@ -30,4 +31,5 @@ public class ReportErrorRequestVo { | @@ -30,4 +31,5 @@ public class ReportErrorRequestVo { | ||
| 30 | */ | 31 | */ |
| 31 | @ApiModelProperty("结束时间") | 32 | @ApiModelProperty("结束时间") |
| 32 | private String endTime; | 33 | private String endTime; |
| 34 | + | ||
| 33 | } | 35 | } |
ruoyi-admin/src/main/java/com/ruoyi/pojo/request/ReportViewRequestVo.java
| @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; | @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; | ||
| 4 | import io.swagger.annotations.ApiModelProperty; | 4 | import io.swagger.annotations.ApiModelProperty; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 7 | /** | 9 | /** |
| 8 | * 接收前端查询vo | 10 | * 接收前端查询vo |
| 9 | * | 11 | * |
| @@ -12,6 +14,8 @@ import lombok.Data; | @@ -12,6 +14,8 @@ import lombok.Data; | ||
| 12 | @ApiModel("可视化大屏请求对象") | 14 | @ApiModel("可视化大屏请求对象") |
| 13 | @Data | 15 | @Data |
| 14 | public class ReportViewRequestVo { | 16 | public class ReportViewRequestVo { |
| 17 | + | ||
| 18 | + private List<String> ids; | ||
| 15 | /** | 19 | /** |
| 16 | * 员工工号 | 20 | * 员工工号 |
| 17 | */ | 21 | */ |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportErrorResponseVo.java
| 1 | package com.ruoyi.pojo.response; | 1 | package com.ruoyi.pojo.response; |
| 2 | 2 | ||
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonFormat; | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 5 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| @@ -14,22 +15,29 @@ import java.util.Date; | @@ -14,22 +15,29 @@ import java.util.Date; | ||
| 14 | */ | 15 | */ |
| 15 | @Data | 16 | @Data |
| 16 | @ApiModel("异常报表对象") | 17 | @ApiModel("异常报表对象") |
| 17 | -public class ReportErrorResponseVo { | 18 | +public class ReportErrorResponseVo {; |
| 18 | @ApiModelProperty("异常类型") | 19 | @ApiModelProperty("异常类型") |
| 20 | + @ExcelProperty(value = "异常类型") | ||
| 19 | private String errorType; | 21 | private String errorType; |
| 20 | @ApiModelProperty("姓名") | 22 | @ApiModelProperty("姓名") |
| 23 | + @ExcelProperty(value = "姓名") | ||
| 21 | private String name; | 24 | private String name; |
| 22 | @ApiModelProperty("工号") | 25 | @ApiModelProperty("工号") |
| 26 | + @ExcelProperty(value = "工号") | ||
| 23 | private String jobCode; | 27 | private String jobCode; |
| 24 | @ApiModelProperty("图片") | 28 | @ApiModelProperty("图片") |
| 29 | + @ExcelProperty(value = "图片") | ||
| 25 | private String image; | 30 | private String image; |
| 26 | @ApiModelProperty("设备id") | 31 | @ApiModelProperty("设备id") |
| 32 | + @ExcelProperty(value = "设备id") | ||
| 27 | private String deviceId; | 33 | private String deviceId; |
| 28 | @ApiModelProperty("时间") | 34 | @ApiModelProperty("时间") |
| 35 | + @ExcelProperty(value = "时间") | ||
| 29 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") | 36 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| 30 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss" , timezone = "GMT+8") | 37 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss" , timezone = "GMT+8") |
| 31 | private Date createTime; | 38 | private Date createTime; |
| 32 | @ApiModelProperty("备注") | 39 | @ApiModelProperty("备注") |
| 40 | + @ExcelProperty(value = "备注") | ||
| 33 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") | 41 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| 34 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss" , timezone = "GMT+8") | 42 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss" , timezone = "GMT+8") |
| 35 | private String remark; | 43 | private String remark; |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ReportViewResponseVo.java
| 1 | package com.ruoyi.pojo.response; | 1 | package com.ruoyi.pojo.response; |
| 2 | 2 | ||
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 3 | import com.fasterxml.jackson.annotation.JsonFormat; | 4 | import com.fasterxml.jackson.annotation.JsonFormat; |
| 4 | -import com.ruoyi.common.annotation.Excel; | 5 | +import com.ruoyi.pojo.converter.AlcoholFlagConverter; |
| 6 | +import com.ruoyi.pojo.converter.SignInConvert; | ||
| 7 | +import com.ruoyi.pojo.converter.SignInStatusConverter; | ||
| 8 | +import com.ruoyi.pojo.converter.SignInTypeConverter; | ||
| 5 | import io.swagger.annotations.ApiModel; | 9 | import io.swagger.annotations.ApiModel; |
| 6 | import io.swagger.annotations.ApiModelProperty; | 10 | import io.swagger.annotations.ApiModelProperty; |
| 7 | import lombok.Data; | 11 | import lombok.Data; |
| @@ -18,35 +22,52 @@ import java.util.Date; | @@ -18,35 +22,52 @@ import java.util.Date; | ||
| 18 | public class ReportViewResponseVo { | 22 | public class ReportViewResponseVo { |
| 19 | @ApiModelProperty("id") | 23 | @ApiModelProperty("id") |
| 20 | private Long id; | 24 | private Long id; |
| 25 | + | ||
| 26 | + @ExcelProperty(value = "工号") | ||
| 21 | @ApiModelProperty("工号") | 27 | @ApiModelProperty("工号") |
| 22 | private String jobCode; | 28 | private String jobCode; |
| 23 | - @ApiModelProperty("签到类型") | 29 | + |
| 30 | + @ExcelProperty(value = "签到类型" ,converter = SignInTypeConverter.class) | ||
| 31 | + @ApiModelProperty("签到类型" ) | ||
| 24 | private String singnIn; | 32 | private String singnIn; |
| 33 | + | ||
| 34 | + @ExcelProperty(value = "姓名") | ||
| 25 | @ApiModelProperty("姓名") | 35 | @ApiModelProperty("姓名") |
| 26 | private String name; | 36 | private String name; |
| 37 | + | ||
| 38 | + @ExcelProperty(value = "签到时间") | ||
| 27 | @ApiModelProperty("签到时间") | 39 | @ApiModelProperty("签到时间") |
| 28 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") | 40 | @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| 29 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") | 41 | @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss") |
| 30 | private Date createTime; | 42 | private Date createTime; |
| 43 | + | ||
| 44 | + @ExcelProperty(value = "签到状态",converter = SignInStatusConverter.class) | ||
| 31 | @ApiModelProperty("签到状态1 成功2 异常") | 45 | @ApiModelProperty("签到状态1 成功2 异常") |
| 32 | private Integer status; | 46 | private Integer status; |
| 33 | /** | 47 | /** |
| 34 | * 签到签退 | 48 | * 签到签退 |
| 35 | */ | 49 | */ |
| 36 | @ApiModelProperty("签到签退") | 50 | @ApiModelProperty("签到签退") |
| 51 | + @ExcelProperty(value = "签到签退",converter = SignInConvert.class) | ||
| 37 | private Integer type; | 52 | private Integer type; |
| 38 | /** | 53 | /** |
| 39 | * 是否酒精检测 1 检查 2 未检 | 54 | * 是否酒精检测 1 检查 2 未检 |
| 40 | */ | 55 | */ |
| 41 | @ApiModelProperty("是否酒精检测 1 检查 2 未检") | 56 | @ApiModelProperty("是否酒精检测 1 检查 2 未检") |
| 57 | + @ExcelProperty(value = "酒精检测",converter = AlcoholFlagConverter.class) | ||
| 42 | private Integer alcoholFlag; | 58 | private Integer alcoholFlag; |
| 43 | /** | 59 | /** |
| 44 | * 酒精含量 | 60 | * 酒精含量 |
| 45 | */ | 61 | */ |
| 62 | + @ExcelProperty(value = "酒精含量") | ||
| 46 | @ApiModelProperty("酒精含量") | 63 | @ApiModelProperty("酒精含量") |
| 47 | private BigDecimal alcoholIntake; | 64 | private BigDecimal alcoholIntake; |
| 65 | + | ||
| 66 | + @ExcelProperty(value = "头像") | ||
| 48 | @ApiModelProperty("头像") | 67 | @ApiModelProperty("头像") |
| 49 | private String image; | 68 | private String image; |
| 69 | + | ||
| 70 | + @ExcelProperty(value = "备注") | ||
| 50 | @ApiModelProperty("备注") | 71 | @ApiModelProperty("备注") |
| 51 | private String remark; | 72 | private String remark; |
| 52 | } | 73 | } |
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
| @@ -91,13 +91,15 @@ | @@ -91,13 +91,15 @@ | ||
| 91 | <select id="getNameByJobCode" resultMap="DriverResult"> | 91 | <select id="getNameByJobCode" resultMap="DriverResult"> |
| 92 | select personnel_name,job_code | 92 | select personnel_name,job_code |
| 93 | from driver | 93 | from driver |
| 94 | + | ||
| 95 | + <if test="jobCodes != null and jobCodes.size() > 0"> | ||
| 94 | <where> | 96 | <where> |
| 95 | job_code IN | 97 | job_code IN |
| 96 | <foreach collection="jobCodes" item="item" open="(" separator="," close=")" > | 98 | <foreach collection="jobCodes" item="item" open="(" separator="," close=")" > |
| 97 | #{item} | 99 | #{item} |
| 98 | </foreach> | 100 | </foreach> |
| 99 | - | ||
| 100 | </where> | 101 | </where> |
| 102 | + </if> | ||
| 101 | </select> | 103 | </select> |
| 102 | <select id="jobCodeIsEmpty" resultType="java.lang.Integer"> | 104 | <select id="jobCodeIsEmpty" resultType="java.lang.Integer"> |
| 103 | select count(*) | 105 | select count(*) |
ruoyi-admin/src/main/resources/mapper/in/SignInMapper.xml
| @@ -75,6 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -75,6 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 75 | <if test="name != '' and name != null"> | 75 | <if test="name != '' and name != null"> |
| 76 | and driver.personnel_name = #{name} | 76 | and driver.personnel_name = #{name} |
| 77 | </if> | 77 | </if> |
| 78 | + <if test="ids != null and ids.size() > 0"> | ||
| 79 | + and sign_in.id in | ||
| 80 | + <foreach collection="ids" item="id" open="(" close=")" separator=","> | ||
| 81 | + #{id} | ||
| 82 | + </foreach> | ||
| 83 | + </if> | ||
| 78 | order by sign_in.create_time desc | 84 | order by sign_in.create_time desc |
| 79 | </select> | 85 | </select> |
| 80 | <select id="getSignErrorList" resultType="com.ruoyi.in.domain.SignIn"> | 86 | <select id="getSignErrorList" resultType="com.ruoyi.in.domain.SignIn"> |
ruoyi-common/pom.xml
| @@ -16,7 +16,30 @@ | @@ -16,7 +16,30 @@ | ||
| 16 | </description> | 16 | </description> |
| 17 | 17 | ||
| 18 | <dependencies> | 18 | <dependencies> |
| 19 | - | 19 | + <!-- easyexcel --> |
| 20 | + <dependency> | ||
| 21 | + <groupId>com.alibaba</groupId> | ||
| 22 | + <artifactId>easyexcel</artifactId> | ||
| 23 | + <version>2.2.6</version> | ||
| 24 | + <exclusions> | ||
| 25 | + <exclusion> | ||
| 26 | + <groupId>javax.servlet</groupId> | ||
| 27 | + <artifactId>servlet-api</artifactId> | ||
| 28 | + </exclusion> | ||
| 29 | + <exclusion> | ||
| 30 | + <groupId>org.apache.poi</groupId> | ||
| 31 | + <artifactId>poi</artifactId> | ||
| 32 | + </exclusion> | ||
| 33 | + <exclusion> | ||
| 34 | + <groupId>org.apache.poi</groupId> | ||
| 35 | + <artifactId>poi-ooxml</artifactId> | ||
| 36 | + </exclusion> | ||
| 37 | + <exclusion> | ||
| 38 | + <groupId>org.apache.poi</groupId> | ||
| 39 | + <artifactId>poi-ooxml-schemas</artifactId> | ||
| 40 | + </exclusion> | ||
| 41 | + </exclusions> | ||
| 42 | + </dependency> | ||
| 20 | <!-- Spring框架基本的核心工具 --> | 43 | <!-- Spring框架基本的核心工具 --> |
| 21 | <dependency> | 44 | <dependency> |
| 22 | <groupId>org.springframework</groupId> | 45 | <groupId>org.springframework</groupId> |
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
| 1 | package com.ruoyi.common.utils.poi; | 1 | package com.ruoyi.common.utils.poi; |
| 2 | - | 2 | +import com.alibaba.excel.EasyExcel; |
| 3 | import java.io.File; | 3 | import java.io.File; |
| 4 | import java.io.FileOutputStream; | 4 | import java.io.FileOutputStream; |
| 5 | import java.io.IOException; | 5 | import java.io.IOException; |
| @@ -1742,4 +1742,36 @@ public class ExcelUtil<T> | @@ -1742,4 +1742,36 @@ public class ExcelUtil<T> | ||
| 1742 | } | 1742 | } |
| 1743 | return method; | 1743 | return method; |
| 1744 | } | 1744 | } |
| 1745 | + | ||
| 1746 | + | ||
| 1747 | + | ||
| 1748 | + /** | ||
| 1749 | + * 对excel表单默认第一个索引名转换成list(EasyExcel) | ||
| 1750 | + * | ||
| 1751 | + * @param is 输入流 | ||
| 1752 | + * @return 转换后集合 | ||
| 1753 | + */ | ||
| 1754 | + public List<T> importEasyExcel(InputStream is) throws Exception | ||
| 1755 | + { | ||
| 1756 | + return EasyExcel.read(is).head(clazz).sheet().doReadSync(); | ||
| 1757 | + } | ||
| 1758 | + | ||
| 1759 | + /** | ||
| 1760 | + * 对list数据源将其里面的数据导入到excel表单(EasyExcel) | ||
| 1761 | + * | ||
| 1762 | + * @param list 导出数据集合 | ||
| 1763 | + * @param sheetName 工作表的名称 | ||
| 1764 | + * @return 结果 | ||
| 1765 | + */ | ||
| 1766 | + public void exportEasyExcel(HttpServletResponse response, List<T> list, String sheetName) | ||
| 1767 | + { | ||
| 1768 | + try | ||
| 1769 | + { | ||
| 1770 | + EasyExcel.write(response.getOutputStream(), clazz).sheet(sheetName).doWrite(list); | ||
| 1771 | + } | ||
| 1772 | + catch (IOException e) | ||
| 1773 | + { | ||
| 1774 | + log.error("导出EasyExcel异常{}", e.getMessage()); | ||
| 1775 | + } | ||
| 1776 | + } | ||
| 1745 | } | 1777 | } |