| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 增加员工后同步增加入职记录 |
| | | * |
| | | * <p> |
| | | * date 2021-07-30 09:12 |
| | | * @author: luoyibo |
| | | * |
| | | * @param empBaseInfo 员工信息 |
| | | * @param operatorId 操作员Id |
| | | * @param empId 员工Id |
| | | * @param operatorId 操作员Id |
| | | * @param empId 员工Id |
| | | * @return void |
| | | * @author: luoyibo |
| | | */ |
| | | private void addEmpDimissLog(EmpBaseInfo empBaseInfo, String operatorId, Long empId) { |
| | | EmpDimissionLog dimissionLog = new EmpDimissionLog(); |
| | |
| | | dimissionLog.setEntryDate(empBaseInfo.getEntryDate()); |
| | | dimissionLog.setDimissionType("20"); |
| | | dimissionLog.setRemark(empBaseInfo.getRemark()); |
| | | dimissionLog.setDeptName(empBaseInfo.getAllDeptName()); |
| | | dimissionLog.setCreator(operatorId); |
| | | dimissionLog.setModifier(operatorId); |
| | | |
| | |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = ids.split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | // for (int i = 0, j = str.length; i < j; i++) { |
| | | // EmpBaseInfo emp = this.getById(str[i]); |
| | | // addEmpDimissLog(emp, operatorId, Long.valueOf(str[i])); |
| | | // } |
| | | return empBaseInfoMapper.momentToNormal(list, operatorId) > 0; |
| | | } |
| | | |
| | |
| | | public boolean closeEmpArchives(EmpDimissionLog empDimissionLog) { |
| | | String operatorId = Optional.of(FebsUtil.getUserId()).orElse("1"); |
| | | String[] str = empDimissionLog.getEmpIds().split(","); |
| | | String[] empDeptNames = empDimissionLog.getDeptNames().split(","); |
| | | List<String> list = new ArrayList<>(Arrays.asList(str)); |
| | | String[] strDate = empDimissionLog.getEntryDates().split(","); |
| | | |
| | |
| | | dimissionLog.setReporter(empDimissionLog.getReporter()); |
| | | dimissionLog.setCreator(operatorId); |
| | | dimissionLog.setModifier(operatorId); |
| | | dimissionLog.setDeptName(empDeptNames[i]); |
| | | dimissionLogService.save(dimissionLog); |
| | | } |
| | | |
| | |
| | | empBaseInfo.setArchivesStatus(dicItem.getDicItemCode()); |
| | | } |
| | | empBaseInfo.setEmpStatus("0"); |
| | | this.save(empBaseInfo); |
| | | boolean saveResult = this.save(empBaseInfo); |
| | | //新入职员工需要增加一条入职记录 |
| | | this.addEmpDimissLog(empBaseInfo,"2",empBaseInfo.getEmpId()); |
| | | 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())) { |
| | |
| | | public void accept(QueryWrapper<EmpBaseInfo> wrapper) { |
| | | for (int i = 0; i < certificates.length; i++) { |
| | | String ageBtn = "|" + certificates[i] + "|"; |
| | | wrapper.gt("LOCATE('"+ageBtn+"',CONCAT('|',replace( certificateList, ',', '|,|'),'|'))",0); |
| | | wrapper.gt("LOCATE('" + ageBtn + "',CONCAT('|',replace( certificateList, ',', '|,|'),'|'))", 0); |
| | | } |
| | | } |
| | | }; |
| | |
| | | @Override |
| | | public boolean updateEmpAge(String userId) { |
| | | List<EmpBaseInfo> empBaseInfoList = new ArrayList<>(); |
| | | if(StringUtils.isNotBlank(userId)){ |
| | | if (StringUtils.isNotBlank(userId)) { |
| | | EmpBaseInfo empBaseInfo = this.getById(userId); |
| | | empBaseInfoList.add(empBaseInfo); |
| | | } 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())); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<EmpBaseInfo> findInsuranceEmpBaseInfos(QueryRequest request, EmpBaseInfo empBaseInfo) { |
| | | Page<EmpBaseInfo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | SortUtil.handlePageSort(request, page, "entryDate", FebsConstant.ORDER_ASC, true); |
| | | IPage<EmpBaseInfo> iPage = empBaseInfoMapper.selectPageVo(page, createInsuranceAlertQueryWrapper(empBaseInfo)); |
| | | List<EmpBaseInfo> list = iPage.getRecords(); |
| | | List<DicItem> dicItems = CastUtil.castList(redisService.get("dicItems"), DicItem.class); |
| | | list.forEach(item -> { |
| | | item.setInsuranceTypeName(dicItems.stream() |
| | | .filter(k -> DicCode.INSURANCETYPE.equals(k.getDicCode()) && k.getDicItemCode().equals(item.getInsuranceType())) |
| | | .findFirst() |
| | | .map(DicItem::getDicItemName) |
| | | .orElse("未知")); |
| | | }); |
| | | iPage.setRecords(list); |
| | | return iPage; |
| | | } |
| | | |
| | | /** |
| | | * 根据设置的参数计算员工的年假 |
| | | * |
| | | * @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); |
| | | } |
| | | |
| | | private QueryWrapper<EmpBaseInfo> createInsuranceAlertQueryWrapper(EmpBaseInfo empBaseInfo) { |
| | | QueryWrapper<EmpBaseInfo> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("a.DelFlag", 0); |
| | | //人员的状态,0-在职 1-离职 2-退休 |
| | | queryWrapper.eq("a.empStatus", "0"); |
| | | if (StringUtils.isNotBlank(empBaseInfo.getSex())) { |
| | | queryWrapper.in("a.sex", empBaseInfo.getSex()); |
| | | } |
| | | //男,1 女,2 (非深户)四险二档,6(非深户)四险一档,7 |
| | | int four_one_woman = Integer.parseInt(redisService.get("four_one_woman").toString()); |
| | | int four_one_man = Integer.parseInt(redisService.get("four_one_man").toString()); |
| | | int four_two_woman = Integer.parseInt(redisService.get("four_two_woman").toString()); |
| | | int four_two_man = Integer.parseInt(redisService.get("four_two_man").toString()); |
| | | |
| | | if (StringUtils.isBlank(empBaseInfo.getInsuranceType())) { |
| | | queryWrapper.and(wrapper -> wrapper |
| | | .nested(inner -> inner |
| | | .eq("a.insuranceType", "6") // insuranceType = '6' |
| | | .and(nestedInner -> nestedInner |
| | | .nested(ageSexWrapper -> ageSexWrapper |
| | | .gt("a.age", four_two_man) // age > 55 |
| | | .eq("a.sex", "1") // sex = '1' |
| | | ).or().nested(ageSexWrapper -> ageSexWrapper |
| | | .gt("a.age", four_two_woman) // age > 46 |
| | | .eq("a.sex", "2") // sex = '2' |
| | | ) |
| | | ) |
| | | ).or().nested(inner -> inner |
| | | .eq("a.insuranceType", "7") // insuranceType = '7' |
| | | .and(nestedInner -> nestedInner |
| | | .nested(ageSexWrapper -> ageSexWrapper |
| | | .gt("a.age", four_one_man) // age > 45 |
| | | .eq("a.sex", "1") // sex = '1' |
| | | ).or().nested(ageSexWrapper -> ageSexWrapper |
| | | .gt("a.age", four_one_woman) // age > 39 |
| | | .eq("a.sex", "2") // sex = '2' |
| | | ) |
| | | ) |
| | | ) |
| | | ); |
| | | } else { |
| | | queryWrapper.eq("a.insuranceType", empBaseInfo.getInsuranceType()); |
| | | if (empBaseInfo.getInsuranceType().equals("7")) { |
| | | queryWrapper.and(wrapper -> wrapper.nested(inner -> inner |
| | | .gt("a.age", four_one_man) // age > 45 |
| | | .eq("a.sex", "1") // sex='1' |
| | | ).or().nested(inner -> inner |
| | | .gt("a.age", four_one_woman) // age > 39 |
| | | .eq("a.sex", "2") // sex='2' |
| | | )); |
| | | } else if (empBaseInfo.getInsuranceType().equals("6")) { |
| | | queryWrapper.and(wrapper -> wrapper.nested(inner -> inner |
| | | .gt("a.age", four_two_man) // age > 55 |
| | | .eq("a.sex", "1") // sex='1' |
| | | ).or().nested(inner -> inner |
| | | .gt("a.age", four_two_woman) // age > 46 |
| | | .eq("a.sex", "2") // sex='2' |
| | | )); |
| | | } |
| | | |
| | | } |
| | | //queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA)); |
| | | return queryWrapper; |
| | | } |
| | | } |