zouyu
2026-04-21 b5d5b7676c92eee961ca34259848bfcb97115c7b
奖惩记录迁移到绩效模块
已添加1个文件
已修改8个文件
232 ■■■■■ 文件已修改
cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/dto/PersonRewardPunishmentRecordDto.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/excel/PersonRewardPunishmentRecordExcel.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/mapper/PersonRewardPunishmentRecordMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/pojo/PersonRewardPunishmentRecord.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/service/PersonRewardPunishmentRecordService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonRewardPunishmentRecordServiceImpl.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/vo/PersonRewardPunishmentRecordVO.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/resources/mapper/PersonRewardPunishmentRecordMapper.xml 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-personnel/src/main/java/com/ruoyi/personnel/controller/PersonRewardPunishmentRecordController.java
@@ -10,6 +10,7 @@
import com.ruoyi.personnel.excel.PersonRewardPunishmentRecordExcel;
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import com.ruoyi.personnel.service.PersonRewardPunishmentRecordService;
import com.ruoyi.personnel.vo.PersonRewardPunishmentRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
@@ -40,61 +41,25 @@
    @ApiOperation(value = "新增/更新 å¥–惩记录")
    @PostMapping("/addOrUpdateRewardPunishment")
    public Result<?> PersonTrainingSave(@RequestBody PersonRewardPunishmentRecord personRewardPunishmentRecord) {
        personRewardPunishmentRecordService.saveOrUpdate(personRewardPunishmentRecord);
        return Result.success();
        return Result.success(personRewardPunishmentRecordService.saveOrUpdate(personRewardPunishmentRecord));
    }
    @ApiOperation(value = "删除奖惩记录")
    @DeleteMapping("/deleteRewardPunishment")
    public Result<?> deleteRewardPunishment(@RequestParam("id") Integer id) {
        personRewardPunishmentRecordService.removeById(id);
        return Result.success();
        return Result.success(personRewardPunishmentRecordService.removeById(id));
    }
    @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));
    public Result<IPage<PersonRewardPunishmentRecordVO>> rewardPunishmentPage(Page page,PersonRewardPunishmentRecordDto punishmentRecordDto) {
        return Result.success(personRewardPunishmentRecordService.rewardPunishmentPage(page, punishmentRecordDto));
    }
    @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");
        // è®¾ç½®å•元格样式
        // ä¿å­˜åˆ°ç¬¬ä¸€ä¸ªsheet中
        EasyExcel.write(response.getOutputStream())
                .head(PersonRewardPunishmentRecordExcel.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // è‡ªé€‚应列宽
                .sheet()
                .doWrite(data);
    public void rewardPunishmentExport(PersonRewardPunishmentRecordDto punishmentRecordDto,HttpServletResponse response) {
        personRewardPunishmentRecordService.exportExcel(punishmentRecordDto,response);
    }
}
cnas-personnel/src/main/java/com/ruoyi/personnel/dto/PersonRewardPunishmentRecordDto.java
@@ -2,13 +2,19 @@
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Data
public class PersonRewardPunishmentRecordDto extends PersonRewardPunishmentRecord {
    private String userName;
    private String account;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    private String createUserName;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
}
cnas-personnel/src/main/java/com/ruoyi/personnel/excel/PersonRewardPunishmentRecordExcel.java
@@ -5,14 +5,12 @@
@Data
public class PersonRewardPunishmentRecordExcel {
    @ExcelProperty("员工编号")
    private String account;
    @ExcelProperty("姓名")
    @ExcelProperty("员工姓名")
    private String userName;
    @ExcelProperty("奖惩级别")
    private String rewardPunishLevel;
    @ExcelProperty("奖惩名称")
    private String rewardPunishName;
@@ -20,15 +18,15 @@
    @ExcelProperty("奖惩时间")
    private String rewardPunishTime;
    @ExcelProperty("奖惩单位")
    private String rewardPunishWorkUnit;
    @ExcelProperty("奖惩计分")
    private String rewardPunishScore;
    @ExcelProperty("奖惩内容")
    private String rewardPunishContent;
    @ExcelProperty("创建时间")
    private String createTime;
    @ExcelProperty("奖惩金额")
    private String rewardPunishSum;
    @ExcelProperty("创建人")
    private String createUserName;
    @ExcelProperty("创建时间")
    private String createTime;
}
cnas-personnel/src/main/java/com/ruoyi/personnel/mapper/PersonRewardPunishmentRecordMapper.java
@@ -6,6 +6,7 @@
import com.ruoyi.personnel.dto.PersonRewardPunishmentRecordDto;
import com.ruoyi.personnel.excel.PersonRewardPunishmentRecordExcel;
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import com.ruoyi.personnel.vo.PersonRewardPunishmentRecordVO;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -21,7 +22,7 @@
 */
public interface PersonRewardPunishmentRecordMapper extends BaseMapper<PersonRewardPunishmentRecord> {
    IPage<PersonRewardPunishmentRecordDto> rewardPunishmentPage(Page page, @Param("userId") Integer userId, @Param("userName") String userName,@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("departmentId") Integer departmentId);
    IPage<PersonRewardPunishmentRecordVO> rewardPunishmentPage(Page page, @Param("dto") PersonRewardPunishmentRecordDto punishmentRecordDto);
    List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(@Param("userId") Integer userId, @Param("departmentId") Integer departmentId, @Param("userName") String userName, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
    List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(@Param("dto") PersonRewardPunishmentRecordDto punishmentRecordDto);
}
cnas-personnel/src/main/java/com/ruoyi/personnel/pojo/PersonRewardPunishmentRecord.java
@@ -7,6 +7,7 @@
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
@@ -29,8 +30,8 @@
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    @ApiModelProperty("奖惩级别")
    private String rewardPunishLevel;
    @ApiModelProperty("用户id")
    private Integer userId;
    @ApiModelProperty("奖惩名称")
    private String rewardPunishName;
@@ -38,24 +39,34 @@
    @ApiModelProperty("奖惩时间")
    private LocalDateTime rewardPunishTime;
    @ApiModelProperty("奖惩单位")
    private String rewardPunishWorkUnit;
    @ApiModelProperty("奖惩计分")
    private BigDecimal rewardPunishScore;
    @ApiModelProperty("奖惩金额")
    private BigDecimal rewardPunishSum;
    @ApiModelProperty("奖惩内容")
    private String rewardPunishContent;
    @ApiModelProperty("用户id")
    private Integer userId;
    @ApiModelProperty("奖惩级别")
    private String rewardPunishLevel;
    @ApiModelProperty("奖惩单位")
    private String rewardPunishWorkUnit;
    @ApiModelProperty(value = "创建时间", hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @ApiModelProperty(value = "更新时间", hidden = true)
    @TableField(fill = FieldFill.INSERT)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    @ApiModelProperty(value = "创建人", hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private Integer createUser;
    @ApiModelProperty(value = "更新人", hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateUser;
}
cnas-personnel/src/main/java/com/ruoyi/personnel/service/PersonRewardPunishmentRecordService.java
@@ -6,7 +6,9 @@
import com.ruoyi.personnel.dto.PersonRewardPunishmentRecordDto;
import com.ruoyi.personnel.excel.PersonRewardPunishmentRecordExcel;
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import com.ruoyi.personnel.vo.PersonRewardPunishmentRecordVO;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
@@ -20,12 +22,9 @@
 */
public interface PersonRewardPunishmentRecordService extends IService<PersonRewardPunishmentRecord> {
    IPage<PersonRewardPunishmentRecordDto> rewardPunishmentPage(Page page,
                                                                Integer userId,
                                                                String userName,
                                                                Date startTime,
                                                                Date endTime,
                                                                Integer departmentId);
    IPage<PersonRewardPunishmentRecordVO> rewardPunishmentPage(Page page,PersonRewardPunishmentRecordDto punishmentRecordDto);
    List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(Integer userId, Integer departmentId, String userName, Date startTime, Date endTime);
    List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(PersonRewardPunishmentRecordDto punishmentRecordDto);
    void exportExcel(PersonRewardPunishmentRecordDto punishmentRecordDto, HttpServletResponse response);
}
cnas-personnel/src/main/java/com/ruoyi/personnel/service/impl/PersonRewardPunishmentRecordServiceImpl.java
@@ -1,5 +1,8 @@
package com.ruoyi.personnel.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -8,8 +11,13 @@
import com.ruoyi.personnel.mapper.PersonRewardPunishmentRecordMapper;
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import com.ruoyi.personnel.service.PersonRewardPunishmentRecordService;
import com.ruoyi.personnel.vo.PersonRewardPunishmentRecordVO;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -25,12 +33,34 @@
public class PersonRewardPunishmentRecordServiceImpl extends ServiceImpl<PersonRewardPunishmentRecordMapper, PersonRewardPunishmentRecord> implements PersonRewardPunishmentRecordService {
    @Override
    public IPage<PersonRewardPunishmentRecordDto> rewardPunishmentPage(Page page, Integer userId, String userName, Date startTime, Date endTime, Integer departmentId) {
        return baseMapper.rewardPunishmentPage(page, userId, userName, startTime, endTime, departmentId);
    public IPage<PersonRewardPunishmentRecordVO> rewardPunishmentPage(Page page, PersonRewardPunishmentRecordDto punishmentRecordDto) {
        return baseMapper.rewardPunishmentPage(page, punishmentRecordDto);
    }
    @Override
    public List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(Integer userId, Integer departmentId, String userName, Date startTime, Date endTime) {
        return baseMapper.rewardPunishmentExport(userId, departmentId, userName, startTime, endTime);
    public List<PersonRewardPunishmentRecordExcel> rewardPunishmentExport(PersonRewardPunishmentRecordDto punishmentRecordDto) {
        return baseMapper.rewardPunishmentExport(punishmentRecordDto);
    }
    @Override
    public void exportExcel(PersonRewardPunishmentRecordDto punishmentRecordDto, HttpServletResponse response) {
        response.reset();
        try{
            List<PersonRewardPunishmentRecordExcel> data = rewardPunishmentExport(punishmentRecordDto);
            //导出
            String fileName = "中天耐丝质量部奖惩记录"+ ExcelTypeEnum.XLSX;
            fileName =  URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
            EasyExcel.write(response.getOutputStream())
                    .head(PersonRewardPunishmentRecordExcel.class)
                    .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // è‡ªé€‚应列宽
                    .sheet()
                    .doWrite(data);
        }catch (Exception e){
            throw new RuntimeException("奖惩记录导出失败");
        }
    }
}
cnas-personnel/src/main/java/com/ruoyi/personnel/vo/PersonRewardPunishmentRecordVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
package com.ruoyi.personnel.vo;
import com.ruoyi.personnel.pojo.PersonRewardPunishmentRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PersonRewardPunishmentRecordVO extends PersonRewardPunishmentRecord {
    /**
     * ç”¨æˆ·åç§°
     */
    @ApiModelProperty("用户名称")
    private String userName;
    /**
     * ç”¨æˆ·è´¦å·
     */
    @ApiModelProperty("用户账号")
    private String account;
    /**
     * åˆ›å»ºäºº
     */
    @ApiModelProperty("创建人")
    private String createUserName;
    /**
     * æ›´æ–°äºº
     */
    @ApiModelProperty("更新人")
    private String updateUserName;
}
cnas-personnel/src/main/resources/mapper/PersonRewardPunishmentRecordMapper.xml
@@ -3,23 +3,23 @@
<mapper namespace="com.ruoyi.personnel.mapper.PersonRewardPunishmentRecordMapper">
    <select id="rewardPunishmentPage" resultType="com.ruoyi.personnel.dto.PersonRewardPunishmentRecordDto">
        select cprpr.*, us.name create_user_name, u.account account, u.name user_name
    <select id="rewardPunishmentPage" resultType="com.ruoyi.personnel.vo.PersonRewardPunishmentRecordVO">
        select
            cprpr.*,
            us.name create_user_name,
            u.account account,
            u.name user_name,
            us2.name AS update_user_name
        from cnas_person_reward_punishment_record cprpr
        left join user u on cprpr.user_id = u.id
        left join user us on cprpr.create_user = us.id
        left join user us2 on cprpr.update_user = us2.id
        <where>
            <if test="userId != null and userId != ''">
                and cprpr.user_id = #{userId}
            <if test="dto.userName != null and dto.userName != ''">
                and u.name like concat('%', #{dto.userName}, '%')
            </if>
            <if test="userName != null and userName != ''">
                and u.name like concat('%', #{userName}, '%')
            </if>
            <if test="startTime != null and endTime != null">
                AND DATE(cprpr.reward_punish_time) BETWEEN #{startTime} AND #{endTime}
            </if>
            <if test="departmentId != null and departmentId != ''">
                and FIND_IN_SET(#{departmentId}, u.depart_lims_id)
            <if test="dto.startTime != null and dto.startTime != null">
                AND cprpr.reward_punish_time BETWEEN #{dto.startTime} AND #{dto.endTime}
            </if>
        </where>
    </select>
@@ -30,17 +30,11 @@
        left join user u on cprpr.user_id = u.id
        left join user us on cprpr.create_user = us.id
        <where>
            <if test="userId != null and userId != ''">
                and cprpr.user_id = #{userId}
            <if test="dto.userName != null and dto.userName != ''">
                and u.name like concat('%', #{dto.userName}, '%')
            </if>
            <if test="departmentId != null and departmentId != ''">
                and FIND_IN_SET(#{departmentId},u.depart_lims_id)
            </if>
            <if test="userName != null and userName != ''">
                and u.name like concat('%', #{userName}, '%')
            </if>
            <if test="startTime != null and endTime != null">
                AND DATE(cprpr.reward_punish_time) BETWEEN #{startTime} AND #{endTime}
            <if test="dto.startTime != null and dto.endTime != null">
                AND cprpr.reward_punish_time BETWEEN #{dto.startTime} AND #{dto.endTime}
            </if>
        </where>
    </select>