diff --git a/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java b/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java index 660db92..3fc29d4 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/AssessTaskController.java @@ -9,8 +9,10 @@ import com.gunshi.project.xyt.service.AssessTaskService; import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Update; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -103,6 +105,12 @@ public class AssessTaskController extends AbstractCommonFileController{ return R.ok(service.result(id)); } + @Operation(summary = "考核结果导出") + @GetMapping("/result/export") + public void resultExport(@RequestParam("id") @Parameter(description = "考核任务id") Long id, HttpServletResponse response) { + service.resultExport(id,response); + } + @Override public String getGroupId() { return "assessTask"; diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java index 911208d..5665a0b 100644 --- a/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/AssessResultVo.java @@ -19,15 +19,18 @@ public class AssessResultVo { private String objectUserName; @ExcelProperty({"考核类目"}) + @ColumnWidth(15) private String categoryName; @ExcelProperty({"指标名称"}) + @ColumnWidth(15) private String indicatorName; @ExcelProperty({"扣分"}) private BigDecimal deductScore; @ExcelProperty({"考核得分"}) + @ColumnWidth(15) private BigDecimal resScore; diff --git a/src/main/java/com/gunshi/project/xyt/model/AssessTeamRating.java b/src/main/java/com/gunshi/project/xyt/model/AssessTeamRating.java index 49dad53..2664b34 100644 --- a/src/main/java/com/gunshi/project/xyt/model/AssessTeamRating.java +++ b/src/main/java/com/gunshi/project/xyt/model/AssessTeamRating.java @@ -108,4 +108,27 @@ public class AssessTeamRating implements Serializable { @Schema(description = "现场图片") private List files; + /** + * 整改状态(0未整改 1已整改) + */ + @TableField(value="rectify_status") + @Schema(description="整改状态(0未整改 1已整改)") + private Integer rectifyStatus; + + /** + * 完成日期 + */ + @TableField(value="finish_date") + @Schema(description="完成日期") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8") + private Date finishDate; + + /** + * 整改说明 + */ + @TableField(value="rectify_desc") + @Schema(description="整改说明") + @Size(max = 500,message = "整改说明最大长度要小于 500") + private String rectifyDesc; + } \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/AssessTaskService.java b/src/main/java/com/gunshi/project/xyt/service/AssessTaskService.java index e5e1d58..7e676a7 100644 --- a/src/main/java/com/gunshi/project/xyt/service/AssessTaskService.java +++ b/src/main/java/com/gunshi/project/xyt/service/AssessTaskService.java @@ -14,6 +14,8 @@ import com.gunshi.project.xyt.model.AssessObject; import com.gunshi.project.xyt.model.AssessTask; import com.gunshi.project.xyt.model.AssessTeam; import com.gunshi.project.xyt.model.AssessTemplate; +import com.gunshi.project.xyt.util.ExcelUtil; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -188,6 +190,11 @@ public class AssessTaskService extends ServiceImpl list.stream().forEach(o->o.setDeductScore(new BigDecimal(o.getStandardScore()).subtract(o.getAssessScore()))); return list.stream().filter(o->o.getDeductScore().compareTo(new BigDecimal(0)) > 0).collect(Collectors.toList()); } + + public void resultExport(Long id, HttpServletResponse response) { + List list = this.result(id); + ExcelUtil.exportExcel(list,"考核结果",AssessResultVo.class,1,new int[]{0,4},response,"考核结果"); + } } diff --git a/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java b/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java index 8801ed2..fe3fdda 100644 --- a/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java +++ b/src/main/java/com/gunshi/project/xyt/service/AssessTeamRatingService.java @@ -171,10 +171,12 @@ public class AssessTeamRatingService extends ServiceImpl> scoreDetail(Long objectId) { diff --git a/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java b/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java index 22b57f3..c2b9aeb 100644 --- a/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java +++ b/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java @@ -55,6 +55,29 @@ public class ExcelUtil { } } + public static void exportExcel(List list, String filename, Class clazz,int mergeRowIndex, int[] mergeColumnIndex, HttpServletResponse response, String sheetName) { + OutputStream out = null; + try { + out = getOutputStream(filename, response); + ExcelWriterSheetBuilder builder = EasyExcel.write(out, clazz) + //是否自动关闭流 + .autoCloseStream(Boolean.FALSE) + //自动列宽(不太精确) + .registerWriteHandler(new ExcelFillCellMergeStrategy(mergeRowIndex, mergeColumnIndex)) + .sheet(sheetName); + builder.doWrite(list); + } finally { + try { + if (out != null) { + out.flush(); + out.close(); + } + } catch (IOException e) { + throw new RuntimeException("导出Excel异常"); + } + } + } + /** * 导出excel,合并指定单元格 *