| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | |
| | | /** |
| | | * éä»¶è®°å½ç±»åæä¸¾ |
| | | * |
| | | */ |
| | | @AllArgsConstructor |
| | | public enum StaffLeaveReason { |
| | | StaffLeaveReasonSalary("salary","èªèµå¾
é"), |
| | | StaffLeaveReasonCareerDevelopment("career_development","èä¸åå±"), |
| | | StaffLeaveReasonWorkEnvironment("work_environment","å·¥ä½ç¯å¢"), |
| | | StaffLeaveReasonPersonalReason("personal_reason","个人åå "), |
| | | StaffLeaveReasonOther("other","å
¶ä»åå "); |
| | | |
| | | |
| | | private final String code; |
| | | private final String info; |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() { |
| | | return info; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.staff.controller; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.staff.dto.StaffLeaveDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.service.StaffLeaveService; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å工离è |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/staff/staffLeave") |
| | | @Api(tags = "å工离è") |
| | | public class StaffLeaveController { |
| | | @Resource |
| | | private StaffLeaveService staffLeaveService; |
| | | /** |
| | | * æ°å¢ç¦»èå页æ¥è¯¢ |
| | | * @param page |
| | | * @param staffLeaveDto |
| | | * @return |
| | | */ |
| | | @GetMapping("/listPage") |
| | | public AjaxResult staffLeaveListPage(Page page, StaffLeaveDto staffLeaveDto) { |
| | | return AjaxResult.success(staffLeaveService.staffLeaveListPage(page, staffLeaveDto)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ç¦»è |
| | | * @param staffLeaveDto |
| | | * @return |
| | | */ |
| | | @PostMapping("") |
| | | public AjaxResult add(@RequestBody StaffLeaveDto staffLeaveDto) { |
| | | return AjaxResult.success(staffLeaveService.add(staffLeaveDto)); |
| | | } |
| | | |
| | | /** |
| | | * æ´æ°ç¦»èä¿¡æ¯ |
| | | * @param id |
| | | * @param staffLeaveDto |
| | | * @return |
| | | */ |
| | | @PutMapping("/{id}") |
| | | public AjaxResult update(@PathVariable("id") Long id, @RequestBody StaffLeaveDto staffLeaveDto) { |
| | | return AjaxResult.success(staffLeaveService.update(id, staffLeaveDto)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤å
¥è |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/del") |
| | | public AjaxResult del(@RequestBody List<Integer> ids) { |
| | | if(CollectionUtils.isEmpty(ids)){ |
| | | return AjaxResult.error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | return AjaxResult.success(staffLeaveService.del(ids)); |
| | | } |
| | | |
| | | /** |
| | | * 离èå¯¼åº |
| | | * @param staffLeaveDto |
| | | */ |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, StaffLeaveDto staffLeaveDto) { |
| | | staffLeaveService.export(response, staffLeaveDto); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/staff/staffOnJob") |
| | | @Api(tags = "åå·¥å°è´¦/åå管ç") |
| | | @Api(tags = "åå·¥å°è´¦") |
| | | public class StaffOnJobController { |
| | | |
| | | @Resource |
| | |
| | | * @return |
| | | */ |
| | | @GetMapping("/{id}") |
| | | public AjaxResult staffJoinLeaveRecordDetail(@PathVariable("id") Long id) { |
| | | public AjaxResult staffOnJobDetail(@PathVariable("id") Long id) { |
| | | return AjaxResult.success(staffOnJobService.staffOnJobDetail(id)); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.staff.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.staff.pojo.StaffLeave; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | public class StaffLeaveDto extends StaffLeave { |
| | | @Excel(name = "ç¶æ", readConverterExp = "0=离è,1=å¨è", sort = 1) |
| | | private Integer staffState; |
| | | |
| | | /** |
| | | * åå·¥ç¼å· |
| | | */ |
| | | @Excel(name = "åå·¥ç¼å·", type = Excel.Type.EXPORT, cellType = Excel.ColumnType.STRING, sort = 2) |
| | | private String staffNo; |
| | | |
| | | /** |
| | | * åå·¥å§å |
| | | */ |
| | | @Excel(name = "åå·¥å§å", sort = 3) |
| | | private String staffName; |
| | | |
| | | /** |
| | | * æ§å« |
| | | */ |
| | | @Excel(name = "æ§å«", sort = 4) |
| | | private String sex; |
| | | |
| | | /** |
| | | * ç±è´¯ |
| | | */ |
| | | @Excel(name = "ç±è´¯", sort = 5) |
| | | private String nativePlace; |
| | | |
| | | /** |
| | | * å®¶åºä½å |
| | | */ |
| | | @Excel(name = "å®¶åºä½å", sort = 6) |
| | | private String adress; |
| | | |
| | | /** |
| | | * å²ä½ |
| | | */ |
| | | @Excel(name = "å²ä½",sort = 7) |
| | | private String postName; |
| | | |
| | | /** |
| | | * 第ä¸å¦å |
| | | */ |
| | | @Excel(name = "第ä¸å¦å", sort = 8) |
| | | private String firstStudy; |
| | | |
| | | /** |
| | | * ä¸ä¸ |
| | | */ |
| | | @Excel(name = "ä¸ä¸", sort = 9) |
| | | private String profession; |
| | | |
| | | /** |
| | | * 身份è¯å·ç |
| | | */ |
| | | @Excel(name = "身份è¯å·ç ", sort = 10) |
| | | private String identityCard; |
| | | |
| | | /** |
| | | * å¹´é¾ |
| | | */ |
| | | @Excel(name = "å¹´é¾", sort = 11) |
| | | private String age; |
| | | |
| | | /** |
| | | * èç³»çµè¯ |
| | | */ |
| | | @Excel(name = "èç³»çµè¯", sort = 12) |
| | | private String phone; |
| | | |
| | | /** |
| | | * ç´§æ¥è系人 |
| | | */ |
| | | @Excel(name = "ç´§æ¥è系人", sort = 13) |
| | | private String emergencyContact; |
| | | |
| | | /** |
| | | * ç´§æ¥è系人çµè¯ |
| | | */ |
| | | @Excel(name = "ç´§æ¥è系人çµè¯", sort = 14) |
| | | private String emergencyContactPhone; |
| | | } |
| | |
| | | package com.ruoyi.staff.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.staff.dto.StaffLeaveDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.pojo.StaffLeave; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @Mapper |
| | | public interface StaffLeaveMapper extends BaseMapper<StaffLeave> { |
| | | IPage<StaffLeaveDto> staffLeaveListPage(Page page, @Param("c") StaffLeaveDto staffLeaveDto); |
| | | |
| | | List<StaffLeaveDto> staffLeaveList(@Param("c") StaffLeaveDto staffLeaveDto); |
| | | } |
| | |
| | | @ApiModelProperty(value = "å¨èåå·¥ID") |
| | | private Long staffOnJobId; |
| | | |
| | | @ApiModelProperty(value = "离èåå ") |
| | | private String reason; |
| | | |
| | | @ApiModelProperty(value = "离è夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Long tenantId; |
| | |
| | | package com.ruoyi.staff.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.staff.dto.StaffLeaveDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffLeave; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | public interface StaffLeaveService extends IService<StaffLeave> { |
| | | IPage<StaffLeaveDto> staffLeaveListPage(Page page, StaffLeaveDto staffLeaveDto); |
| | | /** |
| | | * æ°å¢ç¦»è |
| | | * @param staffLeaveDto |
| | | * @return |
| | | */ |
| | | int add(StaffLeaveDto staffLeaveDto); |
| | | |
| | | /** |
| | | * æ´æ°ç¦»èä¿¡æ¯ |
| | | * @param id |
| | | * @param staffLeaveDto |
| | | * @return |
| | | */ |
| | | int update(Long id, StaffLeaveDto staffLeaveDto); |
| | | |
| | | int del(List<Integer> ids); |
| | | |
| | | void export(HttpServletResponse response, StaffLeaveDto staffLeaveDto); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | |
| | | import static com.ruoyi.common.enums.StaffJoinLeaveRecordDimissionReason.StaffJoinLeaveRecordDimissionReasonOther; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | } |
| | | if (staffJoinLeaveRecord.getDimissionReason()==null){ |
| | | throw new BaseException("离èåå ä¸è½ä¸ºç©º!!!"); |
| | | } |
| | | if (!StaffJoinLeaveRecordDimissionReasonOther.getCode().equals(staffJoinLeaveRecord.getDimissionReason())){ |
| | | staffJoinLeaveRecord.setDimissionRemark(""); |
| | | } |
| | | } |
| | | return staffJoinLeaveRecordMapper.insert(staffJoinLeaveRecord); |
| | |
| | | //离èçç¼è¾ä¸ä¼å½±åå¨è表 |
| | | if (staffJoinLeaveRecord.getDimissionReason()==null){ |
| | | throw new BaseException("离èåå ä¸è½ä¸ºç©º!!!"); |
| | | } |
| | | if (!StaffJoinLeaveRecordDimissionReasonOther.getCode().equals(staffJoinLeaveRecord.getDimissionReason())){ |
| | | staffJoinLeaveRecord.setDimissionRemark(""); |
| | | } |
| | | } |
| | | return staffJoinLeaveRecordMapper.updateById(staffJoinLeaveRecord); |
| | |
| | | package com.ruoyi.staff.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.staff.dto.StaffLeaveDto; |
| | | import com.ruoyi.staff.dto.StaffOnJobDto; |
| | | import com.ruoyi.staff.mapper.StaffLeaveMapper; |
| | | import com.ruoyi.staff.mapper.StaffOnJobMapper; |
| | | import com.ruoyi.staff.pojo.StaffContract; |
| | | import com.ruoyi.staff.pojo.StaffJoinLeaveRecord; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.staff.service.StaffLeaveService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.staff.pojo.StaffLeave; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | import static com.ruoyi.common.enums.StaffLeaveReason.StaffLeaveReasonOther; |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | | public class StaffLeaveServiceImpl extends ServiceImpl<StaffLeaveMapper, StaffLeave> implements StaffLeaveService { |
| | | private StaffLeaveMapper staffLeaveMapper; |
| | | |
| | | private StaffOnJobMapper staffOnJobMapper; |
| | | |
| | | //æ°å¢ç¦»èå表å页æ¥è¯¢ |
| | | @Override |
| | | public IPage<StaffLeaveDto> staffLeaveListPage(Page page, StaffLeaveDto staffLeaveDto) { |
| | | return staffLeaveMapper.staffLeaveListPage(page,staffLeaveDto); |
| | | } |
| | | |
| | | //æ°å¢ç¦»è |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int add(StaffLeaveDto staffLeaveDto) { |
| | | // æ ¡éªå¨èåå·¥æ¯å¦åå¨ |
| | | StaffOnJob staffOnJob = staffOnJobMapper.selectById(staffLeaveDto.getStaffOnJobId()); |
| | | if (staffOnJob == null) { |
| | | throw new IllegalArgumentException("åå·¥ä¸åå¨"); |
| | | } |
| | | |
| | | // æ ¡éªåå·¥æ¯å¦ç¦»è |
| | | if (staffOnJob.getStaffState() == 0) { |
| | | throw new IllegalArgumentException("å工已离è"); |
| | | } |
| | | |
| | | // æ°å¢ç¦»èè®°å½ |
| | | StaffLeave staffLeave = new StaffLeave(); |
| | | staffLeave.setStaffOnJobId(staffLeaveDto.getStaffOnJobId()); |
| | | String reason = staffLeaveDto.getReason(); |
| | | if (!StaffLeaveReasonOther.getCode().equals(reason)){ |
| | | staffLeave.setRemark(""); |
| | | } |
| | | staffLeaveMapper.insert(staffLeave); |
| | | |
| | | // æ´æ°ç¦»èç¶æä¸ºç¦»è |
| | | staffOnJob.setStaffState(0); |
| | | return staffOnJobMapper.updateById(staffOnJob); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int update(Long id, StaffLeaveDto staffLeaveDto) { |
| | | // å¤æå¯¹è±¡æ¯å¦åå¨ |
| | | StaffLeave leave = staffLeaveMapper.selectById(id); |
| | | if (leave == null){ |
| | | throw new BaseException("该离èè®°å½ä¸åå¨,æ æ³æ´æ°!!!"); |
| | | } |
| | | |
| | | String reason = staffLeaveDto.getReason(); |
| | | leave.setReason(reason); |
| | | // æ ¡éªç¦»èåå æ¯å¦ä¸ºå
¶ä»ï¼å¦ææ¯å
¶ä»ï¼å¤æ³¨èµå¼ |
| | | if (StaffLeaveReasonOther.getCode().equals(reason)){ |
| | | leave.setRemark(staffLeaveDto.getRemark()); |
| | | } else { |
| | | leave.setRemark(""); |
| | | } |
| | | return staffLeaveMapper.updateById(leave); |
| | | } |
| | | |
| | | //å é¤ç¦»è |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int del(List<Integer> ids) { |
| | | // å é¤ç¦»èæ°æ® |
| | | return staffLeaveMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | //å¯¼åº |
| | | @Override |
| | | public void export(HttpServletResponse response, StaffLeaveDto staffLeaveDto) { |
| | | List<StaffLeaveDto> staffLeaves =staffLeaveMapper.staffLeaveList(staffLeaveDto); |
| | | ExcelUtil<StaffLeaveDto> util = new ExcelUtil<StaffLeaveDto>(StaffLeaveDto.class); |
| | | util.exportExcel(response, staffLeaves, "å工离è导åº"); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | |
| | | import static com.ruoyi.common.enums.StaffJoinLeaveRecordDimissionReason.StaffJoinLeaveRecordDimissionReasonOther; |
| | | |
| | | @AllArgsConstructor |
| | | @Service |
| | | public class StaffOnJobServiceImpl extends ServiceImpl<StaffOnJobMapper, StaffOnJob> implements IStaffOnJobService { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| | | <mapper namespace="com.ruoyi.staff.mapper.StaffLeaveMapper"> |
| | | <select id="staffLeaveListPage" resultType="com.ruoyi.staff.dto.StaffLeaveDto"> |
| | | SELECT |
| | | staff_leave.*, |
| | | soj.staff_name as staffName, |
| | | soj.staff_state as staffState, |
| | | soj.staff_no as staffNo, |
| | | soj.sex as sex, |
| | | soj.native_place as nativePlace, |
| | | soj.adress as adress, |
| | | soj.first_study as firstStudy, |
| | | soj.profession as profession, |
| | | soj.identity_card as identityCard, |
| | | soj.age as age, |
| | | soj.phone as phone, |
| | | soj.emergency_contact as emergencyContact, |
| | | soj.emergency_contact_phone as emergencyContactPhone, |
| | | sp.post_name as postName |
| | | FROM staff_leave |
| | | LEFT JOIN |
| | | staff_on_job soj ON soj.id = staff_leave.staff_on_job_id |
| | | LEFT JOIN |
| | | sys_post sp ON sp.post_id = soj.sys_post_id |
| | | where 1=1 |
| | | <if test="c.staffName != null and c.staffName != '' "> |
| | | AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%') |
| | | </if> |
| | | </select> |
| | | <select id="staffLeaveList" resultType="com.ruoyi.staff.dto.StaffLeaveDto"> |
| | | SELECT |
| | | staff_leave.*, |
| | | soj.staff_name as staffName, |
| | | soj.staff_state as staffState, |
| | | soj.staff_no as staffNo, |
| | | soj.sex as sex, |
| | | soj.native_place as nativePlace, |
| | | soj.adress as adress, |
| | | soj.first_study as firstStudy, |
| | | soj.profession as profession, |
| | | soj.identity_card as identityCard, |
| | | soj.age as age, |
| | | soj.phone as phone, |
| | | soj.emergency_contact as emergencyContact, |
| | | soj.emergency_contact_phone as emergencyContactPhone, |
| | | sp.post_name as postName |
| | | FROM staff_leave |
| | | LEFT JOIN |
| | | staff_on_job soj ON soj.id = staff_leave.staff_on_job_id |
| | | LEFT JOIN |
| | | sys_post sp ON sp.post_id = soj.sys_post_id |
| | | where 1=1 |
| | | <if test="c.staffName != null and c.staffName != '' "> |
| | | AND soj.staff_name LIKE CONCAT('%',#{c.staffName},'%') |
| | | </if> |
| | | </select> |
| | | </mapper> |