| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | empBaseInfo.setArchivesStatus(dicItem.getDicItemCode()); |
| | | } |
| | | empBaseInfo.setEmpStatus("0"); |
| | | this.save(empBaseInfo); |
| | | boolean saveResult = this.save(empBaseInfo); |
| | | //新入职员工需要增加一条入职记录 |
| | | this.addEmpDimissLog(empBaseInfo, "2", empBaseInfo.getEmpId()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | // @Override |
| | | public void getImage(String empId, HttpServletResponse response) throws Exception { |
| | | EmpBaseInfo empBaseInfo = this.getById(empId); |
| | | if (StrUtil.isBlank(empBaseInfo.getImagePath())) { |
| | |
| | | } else { |
| | | empBaseInfoList = this.list(); |
| | | } |
| | | if (empBaseInfoList.size() > 0) { |
| | | empBaseInfoList.forEach(p -> { |
| | | if (!empBaseInfoList.isEmpty()) { |
| | | empBaseInfoList.parallelStream().forEach(p -> { |
| | | p.setAge(DateUtil.ageOfNow(p.getBirthdate())); |
| | | this.saveOrUpdate(p); |
| | | }); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void updateAnnualLeave(String userId) { |
| | | EmpBaseInfo empBaseInfo = this.getById(userId); |
| | | int holiday = calculateHoliday(empBaseInfo.getEntryDate()); |
| | | empBaseInfo.setAnnualLeave(holiday); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | | .set(EmpBaseInfo::getAnnualLeave, holiday) |
| | | .eq(EmpBaseInfo::getEmpId, empBaseInfo.getEmpId())); |
| | | } |
| | | |
| | | @Override |
| | | public void updateAnnualLeave() { |
| | | List<EmpBaseInfo> list = this.list(); |
| | | list.parallelStream().forEach(p -> { |
| | | int holiday = calculateHoliday(p.getEntryDate()); |
| | | p.setAnnualLeave(holiday); |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | | .set(EmpBaseInfo::getAnnualLeave, holiday) |
| | | .eq(EmpBaseInfo::getEmpId, p.getEmpId())); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void updateEmpBaseKeyInfo() { |
| | | List<EmpBaseInfo> list = this.list(); |
| | | list.parallelStream().forEach(p -> { |
| | | int holiday = calculateHoliday(p.getEntryDate()); |
| | | int age = calculateAge(p.getBirthdate()); |
| | | |
| | | baseMapper.update(null, new LambdaUpdateWrapper<EmpBaseInfo>() |
| | | .set(EmpBaseInfo::getAnnualLeave, holiday) |
| | | .set(EmpBaseInfo::getAge, age) |
| | | .eq(EmpBaseInfo::getEmpId, p.getEmpId())); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 根据设置的参数计算员工的年假 |
| | | * @param date 入职日期 |
| | | * @return 年假天数 |
| | | */ |
| | | private int calculateHoliday(Date date) { |
| | | int holiday = 0; |
| | | int joinYear = DateUtil.ageOfNow(date); |
| | | String configValue = redisService.get("annual_leave").toString(); |
| | | String[] values = StrUtil.split(configValue, "|"); |
| | | String[] condition = StrUtil.split(values[0], ","); |
| | | String[] days = StrUtil.split(values[1], ","); |
| | | if (condition.length == 2) { |
| | | int one = Integer.parseInt(condition[0]); |
| | | int two = Integer.parseInt(condition[1]); |
| | | if (joinYear >= one && joinYear < two) { |
| | | holiday = Integer.parseInt(days[0]); |
| | | } else if (joinYear >= two) { |
| | | holiday = Integer.parseInt(days[1]); |
| | | } |
| | | } |
| | | return holiday; |
| | | } |
| | | private int calculateAge(Date date){ |
| | | return DateUtil.ageOfNow(date); |
| | | } |
| | | } |