| | |
| | | // } |
| | | // } |
| | | //获取年假剩余(新) |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); |
| | | // 获取当前日期 |
| | | Date date = new Date(); |
| | | String nowTime = sdf.format(date); |
| | | //剩余年假 |
| | | Double surplusYearTime = new Double(0.00); |
| | | // 根据用户和时间 |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findYearMonth(userId, nowTime); |
| | | if (sysUserLevelOther != null) { |
| | | // 根据用户查询 |
| | | List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(userId); |
| | | if (sysUserLevelOtherList.size() > 0) { |
| | | for (SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList) { |
| | | // 获取今年 |
| | | int year = Calendar.getInstance().get(Calendar.YEAR); |
| | | String df = sysUserLevelOther.getYearMonth().substring(0,4); |
| | | if (sysUserLevelOther.getYearMonth().substring(0,4).equals(String.valueOf(year))) { |
| | | //年假总时长 |
| | | Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8); |
| | | //已使用年假时长 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | |
| | | String startTime = year + "-01-01 00:00:00"; |
| | | String endTime = year + "-12-31 23:59:59"; |
| | | Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(), startTime, endTime); |
| | | |
| | | surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime); |
| | | } |
| | | } |
| | | } |
| | | return surplusYearTime; |
| | | } |
| | | |
| | |
| | | package me.zhengjie.modules.business.rabbit; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import me.zhengjie.modules.business.service.BusinessExpenseService; |
| | | import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
| | | import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | @RabbitListener(queues = "business.businessExpenseApply") |
| | | public class BusinessExpenseRabbit { |
| | | |
| | | @Autowired |
| | | private BusinessExpenseService businessExpenseService; |
| | | |
| | | @RabbitHandler |
| | | public void process(Map<String, Object> message) { |
| | | // Map 转 实体类 |
| | | BusinessExpenseDto businessExpenseDto = JSON.parseObject(JSON.toJSONString(message), BusinessExpenseDto.class); |
| | | // 新增营业费用 |
| | | businessExpenseService.create(businessExpenseDto); |
| | | } |
| | | } |
| | | //package me.zhengjie.modules.business.rabbit; |
| | | // |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import me.zhengjie.modules.business.service.BusinessExpenseService; |
| | | //import me.zhengjie.modules.business.service.dto.BusinessExpenseDto; |
| | | //import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
| | | //import org.springframework.amqp.rabbit.annotation.RabbitListener; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import java.util.Map; |
| | | // |
| | | //@Component |
| | | //@RabbitListener(queues = "business.businessExpenseApply") |
| | | //public class BusinessExpenseRabbit { |
| | | // |
| | | // @Autowired |
| | | // private BusinessExpenseService businessExpenseService; |
| | | // |
| | | // @RabbitHandler |
| | | // public void process(Map<String, Object> message) { |
| | | // // Map 转 实体类 |
| | | // BusinessExpenseDto businessExpenseDto = JSON.parseObject(JSON.toJSONString(message), BusinessExpenseDto.class); |
| | | // // 新增营业费用 |
| | | // businessExpenseService.create(businessExpenseDto); |
| | | // } |
| | | //} |
| | |
| | | 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); |
| | | if (criteria.getSelectedValue1().size() > 0) { |
| | | for (Long userId : criteria.getSelectedValue1()) { |
| | | // // 用户工资结算 |
| | | // userSalarySettlement(userId, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | try { |
| | | // 用户工资结算 |
| | | userSalarySettlement(id, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | userSalarySettlement(userId, DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()), errors); |
| | | } catch (Exception e) { |
| | | // 记录错误信息 |
| | | errors.add("ID " + id + ": " + e.getMessage()); |
| | | 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; |
| | |
| | | List<SysUserLevelOther> findByUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID、指定年月查询 |
| | | * 根据用户ID、指定年月查询(旧) |
| | | * @param userId |
| | | * @param targetDate |
| | | * @return |
| | |
| | | SysUserLevelOther findByNewUserId(Long userId); |
| | | |
| | | /** |
| | | * 根据用户ID查询最早记录 |
| | | * @param userId / |
| | | * @return / |
| | | * 查询级别其他(新) |
| | | * @param userId |
| | | * @param targetDate |
| | | * @param nextYear |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT * FROM sys_user_level_other WHERE user_id = ?1 ORDER BY start_date ASC LIMIT 1", nativeQuery = true) |
| | | SysUserLevelOther findOldByUserId(Long userId); |
| | | @Query(value = "SELECT * FROM sys_user_level_other WHERE user_id = ?1 AND `year_month` >= ?2 AND `year_month` < ?3 ORDER BY `year_month` DESC LIMIT 1", nativeQuery = true) |
| | | SysUserLevelOther findByUserIdAndData(Long userId, String targetDate, String nextYear); |
| | | |
| | | } |
| | |
| | | import me.zhengjie.utils.*; |
| | | import me.zhengjie.modules.system.service.UserService; |
| | | import me.zhengjie.utils.enums.CodeEnum; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @author 赵士淞 |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author 赵士淞 |
| | | * @date 2022-12-26 |
| | | **/ |
| | | @Service |
| | |
| | | |
| | | @Override |
| | | public SysUserLevelOtherDto queryTargetYearMonth(SysUserLevelOtherQueryCriteria criteria){ |
| | | // 国际时间转中国时间 |
| | | String targetYearMonth = DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth()); |
| | | // 获取某年某月最后一天 |
| | | String lastDayOfTargetYearMonth = DateUtil.getLastDayOfMonth(targetYearMonth); |
| | | // // 根据用户ID、指定年月查询 |
| | | // SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findTargetYearMonth(criteria.getUserId(), lastDayOfTargetYearMonth); |
| | | |
| | | // 根据用户ID、指定年月查询(新) |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findYearMonth(criteria.getUserId(), lastDayOfTargetYearMonth); |
| | | |
| | | // 判断查询结果 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.YEAR, 1); |
| | | calendar.set(Calendar.MONTH, Calendar.JANUARY); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 明年月初 |
| | | String nextYearMonth = sdf.format(calendar.getTime()); |
| | | // 查询级别其他,year_month大于等于选中的日期小于明年月初的日期 |
| | | SysUserLevelOther sysUserLevelOther = sysUserLevelOtherRepository.findByUserIdAndData(criteria.getUserId(), criteria.getTargetYearMonth().substring(0,7), nextYearMonth); |
| | | if (sysUserLevelOther == null) { |
| | | throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | | } |
| | | // 返回 |
| | | |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOther); |
| | | } |
| | | |
| | |
| | | if (new SimpleDateFormat("yyyy-MM").parse(oldDateString).getTime() >= new SimpleDateFormat("yyyy-MM").parse(newDateString).getTime()) { |
| | | throw new BadRequestException("日期必须大于最新用户级别其他日期,请更换日期再试!"); |
| | | } |
| | | // 保存 |
| | | // sysUserLevelOtherRepository.save(oldSysUserLevelOther); |
| | | } |
| | | // 保存 |
| | | return sysUserLevelOtherMapper.toDto(sysUserLevelOtherRepository.save(resources)); |
| | |
| | | |
| | | /** |
| | | * 查询旧用户级别其他 |
| | | * |
| | | * @param userId |
| | | * @return |
| | | */ |
| | |
| | | import me.zhengjie.modules.treatment.rest.CmnInsuranceController; |
| | | import me.zhengjie.utils.*; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.CacheManager; |
| | | import org.springframework.cache.annotation.CacheConfig; |
| | | import org.springframework.cache.annotation.CacheEvict; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | |
| | | private final MongoTemplate mongoTemplate; |
| | | private final UserLevelWageRepository userLevelWageRepository; |
| | | private final UserInsuranceRepository userInsuranceRepository; |
| | | |
| | | @Autowired |
| | | private CacheManager cacheManager; |
| | | |
| | | @Override |
| | | public Object queryAll(UserQueryCriteria criteria, Pageable pageable) { |
| | |
| | | throw new EntityExistException(User.class, "phone", resources.getPhone()); |
| | | } |
| | | redisUtils.del(CacheKey.TOTAL_USER); |
| | | redisUtils.del("user::AllUser"); |
| | | userRepository.save(resources); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(resources.getId(), null, resources.getLevelId()); |
| | |
| | | user.setLevelId(resources.getLevelId()); |
| | | // 临时新用户级别ID |
| | | Long tempNewLevelId = user.getLevelId(); |
| | | redisUtils.del("user::AllUser"); |
| | | userRepository.save(user); |
| | | // 判断用户级别变更 |
| | | checkUserLevel(user.getId(), tempOldLevelId, tempNewLevelId); |
| | |
| | | // 获取当前年份 |
| | | int currentYear = Calendar.getInstance().get(Calendar.YEAR); |
| | | |
| | | // for (int i = 0; i < 2; i++) { |
| | | // // 第一条记录 |
| | | // SysUserLevelOther sysUserLevelOther = new SysUserLevelOther(); |
| | | // sysUserLevelOther.setUserId(resources.getId()); |
| | | // sysUserLevelOther.setLevelId(cmnLevel.getId()); |
| | | // sysUserLevelOther.setPersonalPerformanceProportion(Double.valueOf(0)); |
| | | // |
| | | // if (i == 1) { |
| | | // // 计算剩余年假 |
| | | // Double annualLeave = getAnnualLeave(calendar); |
| | | // sysUserLevelOther.setAnnualLeaveDays(annualLeave); |
| | | // } else { |
| | | // calendar.add(Calendar.YEAR, 1); |
| | | // // 设置月份为一月 |
| | | // calendar.set(Calendar.MONTH, Calendar.JANUARY); |
| | | // // 设置月份为一日 |
| | | // calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | // |
| | | // sysUserLevelOther.setAnnualLeaveDays(5.0); |
| | | // } |
| | | // // 年月 |
| | | // sysUserLevelOther.setYearMonth(sdf.format(calendar.getTime())); |
| | | // |
| | | // |
| | | // sysUserLevelOtherRepository.save(sysUserLevelOther); |
| | | // } |
| | | |
| | | // 添加两条数据 |
| | | for (int i = 0; i < 2; i++) { |
| | | if (i == 0) { |
| | |
| | | @Query(value = "SELECT * from new_user_insurance WHERE user_id = ?1 AND `year_month` = ?2 ORDER BY create_time DESC LIMIT 1",nativeQuery = true) |
| | | UserInsurance findbyUserIdAndDate(Long userId, String yearMonth); |
| | | |
| | | @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id = ?1 AND `year_month` != ?2",nativeQuery = true) |
| | | UserInsurance findbyUserIdAndNotEqualTo(Long userId, String yearMonth); |
| | | |
| | | @Query(value = "SELECT * FROM `new_user_insurance` WHERE user_id in (SELECT user_id FROM sys_user WHERE company_id = ?1 AND enabled is true)",nativeQuery = true) |
| | | List<UserInsurance> findbyCompanyId(Long companyId); |
| | | |
| | |
| | | @Query(value = "(select * from new_user_level_wage where user_id = ?1) order by `year_month` DESC",nativeQuery = true) |
| | | List<UserLevelWage> findUserLevelWageByUserId(Long userId); |
| | | |
| | | @Query(value = "SELECT * from new_user_level_wage WHERE user_id = ?1 AND `year_month` = ?2 ORDER BY create_time DESC LIMIT 1",nativeQuery = true) |
| | | UserLevelWage findbyUserIdAndDate(Long userId, String yearMonth); |
| | | |
| | | @Query(value = "select * from new_user_level_wage where level = ?1",nativeQuery = true) |
| | | List<UserLevelWage> findByLevel(Long level); |
| | | |
| | | /** 新增、修改时验证日期是否重复 **/ |
| | | @Query(value = "SELECT * from new_user_level_wage WHERE user_id = ?1 AND `year_month` = ?2",nativeQuery = true) |
| | | UserLevelWage findByUserAndDate(Long userId, String yearMonth); |
| | | |
| | | /** 查询没转正且年月最大的数据 **/ |
| | | @Query(value = "SELECT * from new_user_level_wage WHERE user_id = ?1 AND `year_month` < ?2 ORDER BY `year_month` DESC LIMIT 1",nativeQuery = true) |
| | | UserLevelWage findByUserIdAndNoWorker(Long userId, String yearMonth); |
| | | |
| | | /** 查询转正且日期最大的数据 **/ |
| | | @Query(value = "SELECT * from new_user_level_wage WHERE user_id = ?1 AND `year_month` >= ?2 ORDER BY `year_month` DESC LIMIT 1",nativeQuery = true) |
| | | UserLevelWage findByUserIdAndYesWorker(Long userId, String yearMonth); |
| | | |
| | | } |
| | |
| | | package me.zhengjie.modules.treatment.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.system.service.dto.SysUserLevelInsuranceQueryCriteria; |
| | | import me.zhengjie.modules.treatment.domain.UserInsurance; |
| | | import me.zhengjie.modules.treatment.service.UserInsuranceService; |
| | | import me.zhengjie.modules.treatment.service.dto.UserInsuranceGenerateParam; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | userInsuranceService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/targetYearMonth") |
| | | @Log("查询指定年月用户级别保险") |
| | | @ApiOperation("查询指定年月用户级别保险") |
| | | @PreAuthorize("@el.check('sysUserLevelInsurance:list')") |
| | | public ResponseEntity<Object> queryTargetYearMonth(UserInsuranceQueryCriteria criteria) throws ParseException { |
| | | return new ResponseEntity<>(userInsuranceService.queryTargetYearMonth(criteria),HttpStatus.OK); |
| | | } |
| | | } |
| | |
| | | @Log("查询指定年月用户级别工资") |
| | | @ApiOperation("查询指定年月用户级别工资") |
| | | @PreAuthorize("@el.check('userLevelWage:list')") |
| | | public ResponseEntity<Object> queryTargetYearMonth(UserLevelWageQueryCriteria criteria) { |
| | | public ResponseEntity<Object> queryTargetYearMonth(UserLevelWageQueryCriteria criteria) throws ParseException { |
| | | return new ResponseEntity<>(userLevelWageService.queryTargetYearMonth(criteria), HttpStatus.OK); |
| | | } |
| | | |
| | |
| | | import me.zhengjie.modules.treatment.service.dto.UserInsuranceGenerateParam; |
| | | import me.zhengjie.modules.treatment.service.dto.UserInsuranceQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | |
| | | * @param criteria 条件参数 |
| | | * @return List<SysUserLevelInsuranceDto> |
| | | */ |
| | | UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria); |
| | | UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria) throws ParseException; |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | |
| | | * @param criteria |
| | | * @return |
| | | */ |
| | | UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria); |
| | | UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria) throws ParseException; |
| | | |
| | | /** |
| | | * 查询指定用户的出差补助工资 |
| | |
| | | package me.zhengjie.modules.treatment.service.impl; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.sql.Timestamp; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria) { |
| | | // 国际时间转中国时间 |
| | | String targetYearMonth = criteria.getTargetYearMonth(); |
| | | // 获取某年某月最后一天 |
| | | String yearMonth = targetYearMonth.substring(0,7); |
| | | // 根据用户ID、指定年月查询 |
| | | // Optional<UserInsurance> userInsuranceOpt = userInsuranceRepository.findByUserIdAndYearMonth(criteria.getUserId(), yearMonth); |
| | | UserInsurance userInsuranceOpt = userInsuranceRepository.findbyUserIdAndDate(criteria.getUserId(), yearMonth); |
| | | public UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria) throws ParseException { |
| | | |
| | | // 获取前台传递的时间 |
| | | String yearMonth = criteria.getTargetYearMonth().substring(0,7); |
| | | // 查询用户 |
| | | User user = userRepository.findById(criteria.getUserId()).orElseGet(User::new); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 获取员工的添加时间 |
| | | calendar.setTime(user.getCreateTime()); |
| | | int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); |
| | | int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | if (dayOfMonth <= daysInMonth / 2) { |
| | | calendar.add(Calendar.MONTH, user.getInternshipTime() == null ? 3 : user.getInternshipTime()); |
| | | } else { |
| | | calendar.add(Calendar.MONTH, user.getInternshipTime() == null ? 4 : user.getInternshipTime() + 1); |
| | | } |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | // 获取转正时间 |
| | | String confirmationTime = new Timestamp(calendar.getTimeInMillis()).toString().substring(0, 7); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); |
| | | Date date1 = format.parse(yearMonth); |
| | | Date date2 = format.parse(confirmationTime); |
| | | UserInsurance userInsuranceOpt = null; |
| | | // 如果传递的时间在转正时间之前 |
| | | if(date1.before(date2)) { |
| | | // 查询没转正的日期数据 |
| | | userInsuranceOpt = userInsuranceRepository.findbyUserIdAndNotEqualTo(criteria.getUserId(), confirmationTime); |
| | | } else { |
| | | // 查询第二条转正后的数据 |
| | | userInsuranceOpt = userInsuranceRepository.findbyUserIdAndDate(criteria.getUserId(), confirmationTime); |
| | | } |
| | | // 判断查询结果 |
| | | // if (userInsuranceOpt.isPresent()) { |
| | | if (userInsuranceOpt != null) { |
| | | // UserInsurance userInsurance = userInsuranceOpt.get(); |
| | | // 返回 |
| | | return userInsuranceMapper.toDto(userInsuranceOpt); |
| | | } else { |
| | | // throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | | throw new RuntimeException("没有获取到当前员工的级别信息!"); |
| | | } |
| | | } |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.Timestamp; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria) { |
| | | // 国际时间转中国时间 |
| | | public UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria) throws ParseException { |
| | | |
| | | String targetYearMonth = criteria.getTargetYearMonth(); |
| | | // 获取某年某月最后一天 |
| | | String yearMonth = targetYearMonth.substring(0,7); |
| | | // 根据用户ID、指定年月查询 |
| | | // UserLevelWage userLevelWage = userLevelWageRepository.findByUserIdAndYearMonth(criteria.getUserId(), yearMonth); |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findbyUserIdAndDate(criteria.getUserId(), yearMonth); |
| | | |
| | | // 查询用户 |
| | | User user = userRepository.findById(criteria.getUserId()).orElseGet(User::new); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 获取员工的添加时间 |
| | | calendar.setTime(user.getCreateTime()); |
| | | int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); |
| | | int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); |
| | | if (dayOfMonth <= daysInMonth / 2) { |
| | | calendar.add(Calendar.MONTH, user.getInternshipTime() == null ? 3 : user.getInternshipTime()); |
| | | } else { |
| | | calendar.add(Calendar.MONTH, user.getInternshipTime() == null ? 4 : user.getInternshipTime() + 1); |
| | | } |
| | | calendar.set(Calendar.DAY_OF_MONTH, 1); |
| | | // 获取转正时间 |
| | | String confirmationTime = new Timestamp(calendar.getTimeInMillis()).toString().substring(0, 7); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); |
| | | Date date1 = format.parse(yearMonth); |
| | | Date date2 = format.parse(confirmationTime); |
| | | |
| | | UserLevelWage userLevelWage = null; |
| | | // 如果传递进来的日期在转正日期之前 |
| | | if(date1.before(date2)) { |
| | | // 查询没转正且年月最大的数据 |
| | | userLevelWage = userLevelWageRepository.findByUserIdAndNoWorker(criteria.getUserId(), confirmationTime); |
| | | } else { |
| | | // 查询第二条转正且日期最大的数据 |
| | | userLevelWage = userLevelWageRepository.findByUserIdAndYesWorker(criteria.getUserId(), confirmationTime); |
| | | } |
| | | |
| | | // UserLevelWage userLevelWage = userLevelWageRepository.findbyUserIdAndDate(criteria.getUserId(), yearMonth); |
| | | |
| | | // 判断查询结果 |
| | | if (userLevelWage == null) { |
| | | // throw new BadRequestException("没有获取到当前员工的级别信息!"); |
| | | throw new RuntimeException("没有获取到当前员工的级别信息!"); |
| | | } |
| | | // 返回 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserLevelWageDto create(UserLevelWage resources) { |
| | | // 根据日期查询个人级别工资表 |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findByUserAndDate(resources.getUserId(), resources.getYearMonth()); |
| | | if (userLevelWage != null) { |
| | | throw new BadRequestException("级别日期重复!"); |
| | | } |
| | | resources.setPerformanceCoefficient(calculatePerformanceCoefficient(resources)); |
| | | return userLevelWageMapper.toDto(userLevelWageRepository.save(resources)); |
| | | } |
| | |
| | | public void update(UserLevelWage resources) { |
| | | UserLevelWage userLevelWage = userLevelWageRepository.findById(resources.getId()).orElseGet(UserLevelWage::new); |
| | | ValidationUtil.isNull(userLevelWage.getId(), "UserLevelWage", "id", resources.getId()); |
| | | // 根据日期查询个人级别工资表 |
| | | UserLevelWage userLevelWage1 = userLevelWageRepository.findByUserAndDate(resources.getUserId(), resources.getYearMonth()); |
| | | if (userLevelWage1 != null) { |
| | | throw new BadRequestException("级别日期重复!"); |
| | | } |
| | | userLevelWage.copy(resources); |
| | | userLevelWage.setPerformanceCoefficient(calculatePerformanceCoefficient(userLevelWage)); |
| | | userLevelWageRepository.save(userLevelWage); |
| | |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, generate } |
| | | export function getTargetYearMonth(params) { |
| | | return request({ |
| | | url: 'api/userInsurance/targetYearMonth', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, generate, getTargetYearMonth } |
| | |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="业绩工资" prop="achievementsWage"> |
| | | <el-form-item label="业绩工资" prop="meritMoney"> |
| | | <el-input :key="form.meritMoney" v-model="form.meritMoney" style="width: 200px" :disabled="true" @blur="achievementsWageBlur"> |
| | | <template slot="append">元</template> |
| | | </el-input> |
| | |
| | | {{ crud.toMoney(scope.row.actualPerformanceWage) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="actualTeamWage" label="团队工资" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.actualTeamWage) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="accumulationFundPersonalAmount" label="公积金·个人缴纳金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.accumulationFundPersonalAmount) }} |
| | |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="pieceRate" label="其他金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{crud.toMoney((scope.row.pieceRate == null ? 0 : scope.row.pieceRate) + (scope.row.travelAllowance == null ? 0 : scope.row.travelAllowance)) }} |
| | | {{crud.toMoney((scope.row.pieceRate == null ? 0 : scope.row.pieceRate) + (scope.row.travelAllowance == null ? 0 : scope.row.travelAllowance) + (scope.row.overtimeAllowance == null ? 0 : scope.row.overtimeAllowance)) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" /> |
| | |
| | | import constant from '../../../utils/constant' |
| | | import crudUser from '@/api/system/user' |
| | | import crudUserLevelWage from '@/api/treatment/userLevelWage' |
| | | import crudUserLevelInsurance from '@/api/system/userLevelInsurance' |
| | | import crudUserInsurance from '@/api/treatment/userInsurance' |
| | | import crudUserLevelOther from '@/api/system/userLevelOther' |
| | | import crudAttendance from '@/api/attendance/attendance' |
| | | import crudTaskDaliy from '@/api/task/taskDaliy' |
| | |
| | | import crudSysConfigIndividualIncomeTax from '@/api/system/configIndividualIncomeTax' |
| | | // import { getMeritWage } from '../../../api/salary/newSalary' |
| | | |
| | | const defaultForm = { id: null, userId: null, salaryYearMonth: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: null, CompletedAchievementsRate: null, meritMoney: null, actualAchievementsWage: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, pieceRate: 0, travelAllowance: 0, overtimeAllowance: 0, accumulationFund: null, accumulationFundPersonal: null, accumulationFundPersonalAmount: null, accumulationFundCompany: null, accumulationFundCompanyAmount: null, retirementInsurance: null, retirementInsurancePersonal: null, retirementInsurancePersonalAmount: null, retirementInsuranceCompany: null, retirementInsuranceCompanyAmount: null, medicalInsurance: null, medicalInsurancePersonal: null, medicalInsurancePersonalAmount: null, medicalInsuranceCompany: null, medicalInsuranceCompanyAmount: null, unemploymentInsurance: null, unemploymentInsurancePersonal: null, unemploymentInsurancePersonalAmount: null, unemploymentInsuranceCompany: null, unemploymentInsuranceCompanyAmount: null, birthInsurance: null, birthInsurancePersonal: null, birthInsurancePersonalAmount: null, birthInsuranceCompany: null, birthInsuranceCompanyAmount: null, employmentInsurance: null, employmentInsurancePersonal: null, employmentInsurancePersonalAmount: null, employmentInsuranceCompany: null, employmentInsuranceCompanyAmount: null, preTaxAmount: null, individualIncomeTax: null, afterTaxAmount: null, remarks: null, publicityStatus: constant.PUBLICITY_STATUS_NOT, approveStatus: constant.APPROVE_STATUS_UNRECOGNIZED, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | const defaultForm = { id: null, userId: null, salaryYearMonth: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: 0, CompletedAchievementsRate: 0, meritMoney: 0, actualAchievementsWage: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, pieceRate: 0, travelAllowance: 0, overtimeAllowance: 0, accumulationFund: null, accumulationFundPersonal: null, accumulationFundPersonalAmount: null, accumulationFundCompany: null, accumulationFundCompanyAmount: null, retirementInsurance: null, retirementInsurancePersonal: null, retirementInsurancePersonalAmount: null, retirementInsuranceCompany: null, retirementInsuranceCompanyAmount: null, medicalInsurance: null, medicalInsurancePersonal: null, medicalInsurancePersonalAmount: null, medicalInsuranceCompany: null, medicalInsuranceCompanyAmount: null, unemploymentInsurance: null, unemploymentInsurancePersonal: null, unemploymentInsurancePersonalAmount: null, unemploymentInsuranceCompany: null, unemploymentInsuranceCompanyAmount: null, birthInsurance: null, birthInsurancePersonal: null, birthInsurancePersonalAmount: null, birthInsuranceCompany: null, birthInsuranceCompanyAmount: null, employmentInsurance: null, employmentInsurancePersonal: null, employmentInsurancePersonalAmount: null, employmentInsuranceCompany: null, employmentInsuranceCompanyAmount: null, preTaxAmount: null, individualIncomeTax: null, afterTaxAmount: null, remarks: null, publicityStatus: constant.PUBLICITY_STATUS_NOT, approveStatus: constant.APPROVE_STATUS_UNRECOGNIZED, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'NewSalary', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput }, |
| | |
| | | |
| | | // 获取用户级别数据 |
| | | getUserLevel() { |
| | | console.log('12') |
| | | // 判断所属员工、工资年月是否为空 |
| | | if (this.form.userId != null && this.form.userId !== '' && this.form.salaryYearMonth != null && this.form.salaryYearMonth !== '') { |
| | | // 表单加载 |
| | |
| | | getUserLevelInsurance() { |
| | | return new Promise((resolve, reject) => { |
| | | // 获取用户级别保险 |
| | | crudUserLevelInsurance.getTargetYearMonth({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => { |
| | | crudUserInsurance.getTargetYearMonth({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => { |
| | | // 公积金基数 |
| | | this.form.accumulationFund = Number(res.accumulationRadix.toFixed(2)) |
| | | // 公积金基数随机数 |
| | |
| | | // 发请求获取当前这个用户当前的基本的当前的业绩完成比可以得到多少钱 |
| | | // 定时器 |
| | | const interval = setInterval(() => { |
| | | console.log('personalPerformanceProportion: ' + this.form.personalPerformanceProportion) |
| | | // 判断个人业绩比例是否为空 |
| | | if (this.form.personalPerformanceProportion != null && this.form.personalPerformanceProportion !== '') { |
| | | // 应完成业绩工时 |
| | |
| | | }, 500) |
| | | // 业绩定时器 |
| | | const performanceInterval = setInterval(() => { |
| | | console.log('performanceWage:' + this.form.performanceWage + 'needCompletedPerformanceHours:' + this.form.needCompletedPerformanceHours) |
| | | // 判断预计业绩工资、应完成业绩工时是否为空 |
| | | if (this.form.performanceWage != null && this.form.performanceWage !== '' && this.form.needCompletedPerformanceHours != null && this.form.needCompletedPerformanceHours !== '') { |
| | | // 实际业绩工资 |
| | |
| | | // 统计金额 |
| | | statisticalAmount() { |
| | | // 税前金额 |
| | | // this.form.preTaxAmount = this.form.actualBasicWage + this.form.actualAchievementsWage + this.form.actualPerformanceWage + this.form.actualTeamWage + this.form.pieceRate + this.form.travelAllowance + this.form.meritMoney |
| | | this.form.preTaxAmount = this.form.actualBasicWage + this.form.actualAchievementsWage + this.form.actualPerformanceWage + this.form.actualTeamWage + this.form.pieceRate + this.form.travelAllowance + this.form.meritMoney + this.form.overtimeAllowance |
| | | // 税前金额随机数 |
| | | this.preTaxAmountRandom = Math.random() |