From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001 From: maven <2163098428@qq.com> Date: 星期五, 01 八月 2025 13:27:59 +0800 Subject: [PATCH] yys 密码已重置 --- cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 100 insertions(+), 0 deletions(-) diff --git a/cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java b/cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java new file mode 100644 index 0000000..a60c9ac --- /dev/null +++ b/cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java @@ -0,0 +1,100 @@ +package com.ruoyi.personnel.controller; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.personnel.dto.PersonRewardPunishmentRecordDto; +import com.ruoyi.personnel.excel.PersonRewardPunishmentRecordExcel; +import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord; +import com.ruoyi.personnel.service.PersonRewardPunishmentRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.SneakyThrows; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * <p> + * 濂栨儵璁板綍 鍓嶇鎺у埗鍣� + * </p> + * + * @author + * @since 2024-10-08 11:25:02 + */ +@Api(tags = "浜哄憳 - 濂栨儵璁板綍") +@RestController +@RequestMapping("/personRewardPunishmentRecord") +public class PersonRewardPunishmentRecordController { + + @Autowired + private PersonRewardPunishmentRecordService personRewardPunishmentRecordService; + + @ApiOperation(value = "鏂板/鏇存柊 濂栨儵璁板綍") + @PostMapping("/addOrUpdateRewardPunishment") + public Result<?> PersonTrainingSave(@RequestBody PersonRewardPunishmentRecord personRewardPunishmentRecord) { + personRewardPunishmentRecordService.saveOrUpdate(personRewardPunishmentRecord); + return Result.success(); + } + + @ApiOperation(value = "鍒犻櫎濂栨儵璁板綍") + @DeleteMapping("/deleteRewardPunishment") + public Result<?> deleteRewardPunishment(@RequestParam("id") Integer id) { + personRewardPunishmentRecordService.removeById(id); + return Result.success(); + } + + @ApiOperation(value = "鏌ヨ 濂栨儵璁板綍") + @GetMapping("/rewardPunishmentPage") + @SneakyThrows + public Result<IPage<PersonRewardPunishmentRecordDto>> rewardPunishmentPage(Page page, + Integer userId, + Integer departmentId, + String userName, + @RequestParam(value = "startTime",required = false) String startTimeStr, + @RequestParam(value = "endTime",required = false) String endTimeStr) { + Date startTime = null; + Date endTime = null; + if (StringUtils.isNotEmpty(startTimeStr) || StringUtils.isNotEmpty(endTimeStr)) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + startTime = formatter.parse(startTimeStr); + endTime = formatter.parse(endTimeStr); + } + return Result.success(personRewardPunishmentRecordService.rewardPunishmentPage(page, userId, userName, startTime, endTime, departmentId)); + } + + @ApiOperation(value = "濂栨儵璁板綍瀵煎嚭") + @GetMapping("/rewardPunishmentExport") + public void rewardPunishmentExport(Integer userId, + Integer departmentId, + String userName, + @RequestParam(value = "startTime",required = false) String startTimeStr, + @RequestParam(value = "endTime",required = false) String endTimeStr, + HttpServletResponse response) throws Exception { + Date startTime = null; + Date endTime = null; + if (StringUtils.isNotEmpty(startTimeStr) || StringUtils.isNotEmpty(endTimeStr)) { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + startTime = formatter.parse(startTimeStr); + endTime = formatter.parse(endTimeStr); + } + List<PersonRewardPunishmentRecordExcel> data = personRewardPunishmentRecordService.rewardPunishmentExport(userId, departmentId, userName, startTime, endTime); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("requestType", "excel"); + response.setHeader("Access-Control-Expose-Headers", "requestType"); + // 璁剧疆鍗曞厓鏍兼牱寮� + // 淇濆瓨鍒扮涓�涓猻heet涓� + EasyExcel.write(response.getOutputStream()) + .head(PersonRewardPunishmentRecordExcel.class) + .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 鑷�傚簲鍒楀 + .sheet() + .doWrite(data); + } +} -- Gitblit v1.9.3