Browse Source

值周排班模块导出调整

dzx 1 year ago
parent
commit
41dbe2d9bf

+ 13 - 2
src/main/java/com/xjrsoft/module/weekly/controller/WeeklyDutyScheduleController.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.weekly.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -12,6 +13,7 @@ import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.weekly.dto.WeeklyDutySchedulePageDto;
 import com.xjrsoft.module.weekly.entity.WeeklyDutySchedule;
 import com.xjrsoft.module.weekly.service.IWeeklyDutyScheduleService;
+import com.xjrsoft.module.weekly.vo.WeeklyDutyScheduleListVo;
 import com.xjrsoft.module.weekly.vo.WeeklyDutySchedulePageVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -27,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -75,9 +78,17 @@ public class WeeklyDutyScheduleController {
     @GetMapping("/export")
     @ApiOperation(value = "导出")
     public ResponseEntity<byte[]> exportData(@Valid WeeklyDutySchedulePageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
-        List<WeeklyDutySchedulePageVo> customerList = isTemplate != null && isTemplate ? new ArrayList<>() : ((PageOutput<WeeklyDutySchedulePageVo>) page(dto).getData()).getList();
+        List<WeeklyDutySchedule> list = weeklyDutyScheduleService.list();
+        List<WeeklyDutyScheduleListVo> customerList = new ArrayList<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+        for (WeeklyDutySchedule vo : list) {
+            WeeklyDutyScheduleListVo listVo = BeanUtil.toBean(vo, WeeklyDutyScheduleListVo.class);
+            listVo.setDateBirth(sdf.format(vo.getDateBirth()));
+
+            customerList.add(listVo);
+        }
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
-        EasyExcel.write(bot, WeeklyDutySchedulePageVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
+        EasyExcel.write(bot, WeeklyDutyScheduleListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(customerList);
 
         return RT.fileStream(bot.toByteArray(), "WeeklyDutySchedule" + ExcelTypeEnum.XLSX.getValue());
     }

+ 3 - 7
src/main/java/com/xjrsoft/module/weekly/entity/WeeklyDutySchedule.java

@@ -2,18 +2,14 @@ package com.xjrsoft.module.weekly.entity;
 
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.github.yulichang.annotation.EntityMapping;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
 import java.io.Serializable;
-import java.time.LocalTime;
-import java.time.LocalDateTime;
-import java.math.BigDecimal;
-import java.util.List;
 import java.util.Date;
 
 
@@ -102,7 +98,7 @@ public class WeeklyDutySchedule implements Serializable {
     * 出生日期
     */
     @ApiModelProperty("出生日期")
-    private Date dateBirth;
+    private java.sql.Timestamp dateBirth;
     /**
     * 年龄
     */

+ 2 - 1
src/main/java/com/xjrsoft/module/weekly/service/impl/WeeklyDutyScheduleServiceImpl.java

@@ -15,6 +15,7 @@ import com.xjrsoft.module.weekly.vo.WeeklyDutySchedulePageVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.sql.Timestamp;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -55,7 +56,7 @@ public class WeeklyDutyScheduleServiceImpl extends MPJBaseServiceImpl<WeeklyDuty
             schedule.setCredentialNumber(ScheduleVo.get(3).toString());
             if(ObjectUtil.isNotNull(ScheduleVo.get(4))){
                 try {
-                    schedule.setDateBirth(sdf.parse(ScheduleVo.get(4).toString()));
+                    schedule.setDateBirth(new Timestamp(sdf.parse(ScheduleVo.get(4).toString()).getTime()));
                 } catch (ParseException e) {
                     throw new MyException("出生日期格式错误" );
                 }

+ 72 - 0
src/main/java/com/xjrsoft/module/weekly/vo/WeeklyDutyScheduleListVo.java

@@ -0,0 +1,72 @@
+package com.xjrsoft.module.weekly.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+* @title: 值周排班分页列表出参
+* @Author dzx
+* @Date: 2023-12-30
+* @Version 1.0
+*/
+@Data
+public class WeeklyDutyScheduleListVo {
+
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("序号")
+    @ApiModelProperty("序号")
+    private Integer sortCode;
+
+    /**
+    * 学号/工号
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("工号")
+    @ApiModelProperty("工号")
+    private String userNumber;
+    /**
+    * 姓名
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("姓名")
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+    * 性别
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("性别")
+    @ApiModelProperty("性别")
+    private String gender;
+    /**
+    * 证件号码
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("证件号码")
+    @ApiModelProperty("证件号码")
+    private String credentialNumber;
+    /**
+    * 年龄
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("年龄")
+    @ApiModelProperty("年龄")
+    private Integer age;
+    /**
+    * 备注
+    */
+    @ContentStyle(dataFormat = 49)
+    @ExcelProperty("值周情况")
+    @ApiModelProperty("值周情况")
+    private String remark;
+
+    /**
+     * 出生日期
+     */
+    @ApiModelProperty("出生日期")
+    @ExcelProperty("出生日期")
+    private String dateBirth;
+
+}

+ 7 - 0
src/main/java/com/xjrsoft/module/weekly/vo/WeeklyDutySchedulePageVo.java

@@ -115,4 +115,11 @@ public class WeeklyDutySchedulePageVo {
     @ApiModelProperty("值周情况")
     private String remark;
 
+    /**
+     * 出生日期
+     */
+    @ApiModelProperty("出生日期")
+    @ExcelProperty("出生日期")
+    private Date dateBirth;
+
 }