| | |
| | | if (criteria.getUserId() == null) { |
| | | return 0; |
| | | } |
| | | List<User> user = userRepository.findByUserId(criteria.getUserId()); |
| | | String stTime = sdf.format(user.get(0).getCreateTime()).substring(0, 7); |
| | | |
| | | User user = userRepository.findById(criteria.getUserId()).orElseGet(User::new); |
| | | // 员工的创建时间 |
| | | String stTime = sdf.format(user.getCreateTime()).substring(0, 7); |
| | | |
| | | if (stTime.equals(criteria.getTargetYearMonth().substring(0, 7))) { |
| | | criteria.setTargetYearMonth(sdf.format(user.get(0).getCreateTime()).substring(0, 10)); |
| | | criteria.setTargetYearMonth(sdf.format(user.getCreateTime()).substring(0, 10)); |
| | | } |
| | | // 国际时间转中国时间 |
| | | String targetYearMonth = DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()); |
| | |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | public void generate(NewSalaryQueryCriteria criteria) { |
| | | List<String> errors = new ArrayList<>(); |
| | | for (Long id : criteria.getSelectedValue1()) { |
| | | // 用户工资结算 |
| | | // userSalarySettlement(id, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | try { |
| | | // 用户工资结算 |
| | | userSalarySettlement(id, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | } catch (Exception e) { |
| | | // 记录错误信息 |
| | | errors.add("ID " + id + ": " + e.getMessage()); |
| | | if (criteria.getSelectedValue1().size() > 0) { |
| | | for (Long userId : criteria.getSelectedValue1()) { |
| | | // // 用户工资结算 |
| | | // userSalarySettlement(userId, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | try { |
| | | // 用户工资结算 |
| | | userSalarySettlement(userId, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | } catch (Exception e) { |
| | | // 记录错误信息 |
| | | errors.add("ID " + userId + ": " + e.getMessage()); |
| | | } |
| | | } |
| | | } else { |
| | | userSalarySettlement(null, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | } |
| | | |
| | | // 在循环结束后处理错误 |
| | |
| | | newSalary = getUserLevelWage(userId, targetYearMonth, newSalary, errors); |
| | | // 获取用户级别保险 |
| | | newSalary = getUserLevelInsurance(userId, targetYearMonth, newSalary); |
| | | // 获取用户级别其他 |
| | | // 获取用户级别其他(旧版,新版无个人业绩比例字段) |
| | | newSalary = getUserLevelOther(userId, targetYearMonth, newSalary); |
| | | // 获取工作天数 |
| | | newSalary = getWorkDays(targetYearMonth, newSalary); |
| | |
| | | errors.add(e.getMessage()); |
| | | return; |
| | | } |
| | | // create(newSalary); |
| | | try { |
| | | // 保存 |
| | | create(newSalary); |
| | |
| | | newSalary.setPerformanceWage(BigDecimal.ZERO); |
| | | // 设置工资条的基本工资 |
| | | newSalary.setTeamWage(BigDecimal.ZERO); |
| | | } catch (RuntimeException e) { |
| | | } catch (RuntimeException | ParseException e) { |
| | | errors.add(e.getMessage()); |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | // 获取用户级别保险 |
| | | private NewSalary getUserLevelInsurance(Long userId, String targetYearMonth, NewSalary newSalary) { |
| | | private NewSalary getUserLevelInsurance(Long userId, String targetYearMonth, NewSalary newSalary) throws ParseException { |
| | | // 用户级别保险查询类 |
| | | UserInsuranceQueryCriteria criteria = new UserInsuranceQueryCriteria(); |
| | | criteria.setUserId(userId); |
| | |
| | | SysUserLevelOtherQueryCriteria sysUserLevelOtherQueryCriteria = new SysUserLevelOtherQueryCriteria(); |
| | | sysUserLevelOtherQueryCriteria.setUserId(userId); |
| | | sysUserLevelOtherQueryCriteria.setTargetYearMonth(targetYearMonth); |
| | | // 查询指定年月用户级别其他 |
| | | // 查询指定年月用户级别其他(旧版,新版无个人业绩比例字段) |
| | | SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherService.queryTargetYearMonth(sysUserLevelOtherQueryCriteria); |
| | | // 个人业绩比例 |
| | | // 个人业绩比例(旧版,新版无个人业绩比例字段) |
| | | // newSalary.setPersonalPerformanceProportion(sysUserLevelOtherDto.getPersonalPerformanceProportion()); |
| | | // 返回 |
| | | return newSalary; |