| | |
| | | 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; |
| | |
| | | @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); |
| | | } |
| | | } |
| | |
| | | |
| | | 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; |
| | | |
| | | } |
| | |
| | | |
| | | @Data |
| | | public class PersonRewardPunishmentRecordExcel { |
| | | |
| | | @ExcelProperty("åå·¥ç¼å·") |
| | | private String account; |
| | | |
| | | @ExcelProperty("å§å") |
| | | @ExcelProperty("åå·¥å§å") |
| | | private String userName; |
| | | |
| | | @ExcelProperty("奿©çº§å«") |
| | | private String rewardPunishLevel; |
| | | |
| | | @ExcelProperty("奿©åç§°") |
| | | private String rewardPunishName; |
| | |
| | | @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; |
| | | } |
| | |
| | | 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; |
| | |
| | | */ |
| | | 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); |
| | | } |
| | |
| | | import lombok.Setter; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty("奿©çº§å«") |
| | | private String rewardPunishLevel; |
| | | @ApiModelProperty("ç¨æ·id") |
| | | private Integer userId; |
| | | |
| | | @ApiModelProperty("奿©åç§°") |
| | | private String rewardPunishName; |
| | |
| | | @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; |
| | | } |
| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | |
| | | 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("奿©è®°å½å¯¼åºå¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | } |
| | |
| | | <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> |
| | |
| | | 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> |