weicd
2023-12-20 4e7355035b4b43860f4a664db1b622affb1375a1
级别,工资条相关修改
17 files modified
356 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java 22 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rabbit/BusinessExpenseRabbit.java 54 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/NewSalaryServiceImpl.java 34 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java 15 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java 1 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java 26 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java 35 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserLevelWageRepository.java 16 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/rest/UserInsuranceController.java 10 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/rest/UserLevelWageController.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/UserInsuranceService.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/UserLevelWageService.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserInsuranceServiceImpl.java 51 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java 52 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/treatment/userInsurance.js 10 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/salary/newSalary/index.vue 19 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -450,26 +450,26 @@
//            }
//        }
        //获取年假剩余(新)
        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;
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/business/rabbit/BusinessExpenseRabbit.java
@@ -1,27 +1,27 @@
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);
//    }
//}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/NewSalaryServiceImpl.java
@@ -273,10 +273,13 @@
        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());
@@ -332,16 +335,20 @@
//    @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);
        }
        // 在循环结束后处理错误
@@ -430,7 +437,7 @@
            newSalary = getUserLevelWage(userId, targetYearMonth, newSalary, errors);
            // 获取用户级别保险
            newSalary = getUserLevelInsurance(userId, targetYearMonth, newSalary);
            // 获取用户级别其他
            // 获取用户级别其他(旧版,新版无个人业绩比例字段)
            newSalary = getUserLevelOther(userId, targetYearMonth, newSalary);
            // 获取工作天数
            newSalary = getWorkDays(targetYearMonth, newSalary);
@@ -444,6 +451,7 @@
            errors.add(e.getMessage());
            return;
        }
//        create(newSalary);
        try {
            // 保存
            create(newSalary);
@@ -476,7 +484,7 @@
            newSalary.setPerformanceWage(BigDecimal.ZERO);
            // 设置工资条的基本工资
            newSalary.setTeamWage(BigDecimal.ZERO);
        } catch (RuntimeException e) {
        } catch (RuntimeException | ParseException e) {
            errors.add(e.getMessage());
            return null;
        }
@@ -511,7 +519,7 @@
    }
    // 获取用户级别保险
    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);
@@ -588,9 +596,9 @@
        SysUserLevelOtherQueryCriteria sysUserLevelOtherQueryCriteria = new SysUserLevelOtherQueryCriteria();
        sysUserLevelOtherQueryCriteria.setUserId(userId);
        sysUserLevelOtherQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询指定年月用户级别其他
        // 查询指定年月用户级别其他(旧版,新版无个人业绩比例字段)
        SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherService.queryTargetYearMonth(sysUserLevelOtherQueryCriteria);
        // 个人业绩比例
        // 个人业绩比例(旧版,新版无个人业绩比例字段)
//        newSalary.setPersonalPerformanceProportion(sysUserLevelOtherDto.getPersonalPerformanceProportion());
        // 返回
        return newSalary;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java
@@ -46,7 +46,7 @@
    List<SysUserLevelOther> findByUserId(Long userId);
    /**
     * 根据用户ID、指定年月查询
     * 根据用户ID、指定年月查询(旧)
     * @param userId
     * @param targetDate
     * @return
@@ -70,10 +70,13 @@
    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);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
@@ -38,6 +38,7 @@
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;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysUserLevelOtherServiceImpl.java
@@ -41,9 +41,9 @@
import java.util.function.Function;
/**
 * @author 赵士淞
* @website https://eladmin.vip
* @description 服务实现
* @author 赵士淞
* @date 2022-12-26
**/
@Service
@@ -88,21 +88,20 @@
    @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);
    }
@@ -155,8 +154,6 @@
            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));
@@ -268,6 +265,7 @@
    /**
     * 查询旧用户级别其他
     *
     * @param userId
     * @return
     */
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
@@ -49,7 +49,10 @@
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;
@@ -119,6 +122,9 @@
    private final MongoTemplate mongoTemplate;
    private final UserLevelWageRepository userLevelWageRepository;
    private final UserInsuranceRepository userInsuranceRepository;
    @Autowired
    private CacheManager cacheManager;
    @Override
    public Object queryAll(UserQueryCriteria criteria, Pageable pageable) {
@@ -528,6 +534,7 @@
            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());
@@ -586,6 +593,7 @@
        user.setLevelId(resources.getLevelId());
        // 临时新用户级别ID
        Long tempNewLevelId = user.getLevelId();
        redisUtils.del("user::AllUser");
        userRepository.save(user);
        // 判断用户级别变更
        checkUserLevel(user.getId(), tempOldLevelId, tempNewLevelId);
@@ -1298,6 +1306,33 @@
        // 获取当前年份
        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) {
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserInsuranceRepository.java
@@ -37,6 +37,9 @@
    @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);
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/repository/UserLevelWageRepository.java
@@ -40,9 +40,19 @@
    @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);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/rest/UserInsuranceController.java
@@ -16,6 +16,7 @@
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;
@@ -29,6 +30,7 @@
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;
@@ -96,4 +98,12 @@
        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);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/rest/UserLevelWageController.java
@@ -67,7 +67,7 @@
    @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);
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/UserInsuranceService.java
@@ -22,6 +22,8 @@
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;
@@ -55,7 +57,7 @@
     * @param criteria 条件参数
     * @return List<SysUserLevelInsuranceDto>
     */
    UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria);
    UserInsuranceDto queryTargetYearMonth(UserInsuranceQueryCriteria criteria) throws ParseException;
    /**
     * 根据ID查询
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/UserLevelWageService.java
@@ -56,7 +56,7 @@
     * @param criteria
     * @return
     */
    UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria);
    UserLevelWageDto queryTargetYearMonth(UserLevelWageQueryCriteria criteria) throws ParseException;
    /**
     * 查询指定用户的出差补助工资
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserInsuranceServiceImpl.java
@@ -16,11 +16,10 @@
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;
@@ -97,22 +96,42 @@
    }
    @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("没有获取到当前员工的级别信息!");
        }
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/treatment/service/impl/UserLevelWageServiceImpl.java
@@ -44,6 +44,7 @@
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;
@@ -96,17 +97,44 @@
    }
    @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("没有获取到当前员工的级别信息!");
        }
        // 返回
@@ -169,6 +197,11 @@
    @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));
    }
@@ -207,6 +240,11 @@
    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);
eladmin-web-master/src/api/treatment/userInsurance.js
@@ -32,4 +32,12 @@
  })
}
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 }
eladmin-web-master/src/views/salary/newSalary/index.vue
@@ -127,7 +127,7 @@
              <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>
@@ -329,11 +329,6 @@
            {{ 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) }}
@@ -381,7 +376,7 @@
        </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" />
@@ -479,7 +474,7 @@
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'
@@ -487,7 +482,7 @@
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 },
@@ -950,6 +945,7 @@
    // 获取用户级别数据
    getUserLevel() {
    console.log('12')
      // 判断所属员工、工资年月是否为空
      if (this.form.userId != null && this.form.userId !== '' && this.form.salaryYearMonth != null && this.form.salaryYearMonth !== '') {
        // 表单加载
@@ -1051,7 +1047,7 @@
    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))
          // 公积金基数随机数
@@ -1289,6 +1285,7 @@
          // 发请求获取当前这个用户当前的基本的当前的业绩完成比可以得到多少钱
          // 定时器
          const interval = setInterval(() => {
            console.log('personalPerformanceProportion: ' + this.form.personalPerformanceProportion)
            // 判断个人业绩比例是否为空
            if (this.form.personalPerformanceProportion != null && this.form.personalPerformanceProportion !== '') {
              // 应完成业绩工时
@@ -1386,6 +1383,7 @@
          }, 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 !== '') {
              // 实际业绩工资
@@ -1769,7 +1767,6 @@
    // 统计金额
    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()