weicd
2023-01-12 15d0cca4b8ce2221e6b917b3d4f90db2563307ad
Merge branch 'master' of http://192.168.1.110:5678/r/pms-upgrade into weicd
1 files added
33 files modified
2589 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceQueryCriteria.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java 230 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/rest/ProjectCostController.java 3 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/ProjectCostService.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/dto/ProjectCostQueryCriteria.java 5 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/impl/ProjectCostServiceImpl.java 447 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/SalaryTask.java 421 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/domain/Salary.java 12 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/repository/SalaryRepository.java 22 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/rest/SalaryController.java 18 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/SalaryService.java 18 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/dto/SalaryDto.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/dto/SalaryQueryCriteria.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/SalaryServiceImpl.java 92 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysConfigIndividualIncomeTax.java 13 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysConfigIndividualIncomeTaxRepository.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelWageRepository.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysConfigIndividualIncomeTaxDto.java 7 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysConfigIndividualIncomeTaxQueryCriteria.java 6 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysConfigIndividualIncomeTaxServiceImpl.java 29 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java 4 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/utils/DateUtil.java 58 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/salary/salary.js 18 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/components/Crud/crud.js 14 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/utils/constant.js 12 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/project/projectCost/index.vue 80 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/project/projectTask/index.vue 2 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/salary/salary/index.vue 924 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/system/configIndividualIncomeTax/index.vue 90 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java
@@ -42,4 +42,12 @@
    @Query
    private String travelEndTime;
    /* 模糊 */
    @Query(propName = "travelStartTime", type = Query.Type.INNER_LIKE)
    private String travelStartTimeLike;
    /* 模糊 */
    @Query(propName = "travelEndTime", type = Query.Type.INNER_LIKE)
    private String travelEndTimeLike;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java
@@ -46,4 +46,12 @@
    @Query(type = Query.Type.BETWEEN, propName = "outEndTime")
    private List<Timestamp> outEndTime;
    /* 模糊 */
    @Query(propName = "outStartTime", type = Query.Type.INNER_LIKE)
    private String outStartTimeLike;
    /* 模糊 */
    @Query(propName = "outEndTime", type = Query.Type.INNER_LIKE)
    private String outEndTimeLike;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java
@@ -46,4 +46,12 @@
    @Query(type = Query.Type.BETWEEN, propName = "leaveEndTime")
    private List<Timestamp> leaveEndTime;
    /* 模糊 */
    @Query(propName = "leaveStartTime", type = Query.Type.INNER_LIKE)
    private String leaveStartTimeLike;
    /* 模糊 */
    @Query(propName = "leaveEndTime", type = Query.Type.INNER_LIKE)
    private String leaveEndTimeLike;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceQueryCriteria.java
@@ -53,7 +53,7 @@
    @Query(type = Query.Type.EQUAL, propName = "endClockResults")
    private String endClockResults;
    /* 两者之间 */
    /* 模糊 */
    @Query(propName = "attendanceDate", type = Query.Type.INNER_LIKE)
    private String attendanceDateLike;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -16,9 +16,11 @@
package me.zhengjie.modules.attendance.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.attendance.domain.Attendance;
import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
import me.zhengjie.modules.attendance.domain.Calculate;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository;
import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository;
import me.zhengjie.modules.attendance.service.dto.*;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.system.repository.DictDetailRepository;
@@ -29,8 +31,6 @@
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.attendance.repository.AttendanceRepository;
import me.zhengjie.modules.attendance.service.AttendanceService;
import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
@@ -62,6 +62,9 @@
    private final UserRepository userRepository;
    private final DictDetailRepository dictDetailRepository;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceLeaveRepository attendanceLeaveRepository;
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    @Override
    public Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable){
@@ -295,18 +298,48 @@
    public Double queryAttendanceHours(AttendanceQueryCriteria criteria){
        // 出勤小时数
        Double attendanceHours = 0D;
        // 国际时间转中国时间
        String targetYearMonth = DateUtil.internationalTimeToChinaTime(criteria.getTargetYearMonth());
        // 节日检索类
        SysConfigHolidayQueryCriteria sysConfigHolidayQueryCriteria = new SysConfigHolidayQueryCriteria();
        sysConfigHolidayQueryCriteria.setHolidayDateLike(targetYearMonth.substring(0,7));
        // 获取本月节日列表
        List<SysConfigHoliday> sysConfigHolidayMonthList = sysConfigHolidayRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,sysConfigHolidayQueryCriteria,criteriaBuilder));
        // 考勤检索类
        criteria.setAttendanceDateLike(targetYearMonth.substring(0,7));
        // 获取本月考勤列表
        List<Attendance> attendanceMonthList = attendanceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
        // 请假检索类
        AttendanceLeaveQueryCriteria attendanceLeaveQueryCriteria = new AttendanceLeaveQueryCriteria();
        attendanceLeaveQueryCriteria.setUserId(criteria.getUserId());
        attendanceLeaveQueryCriteria.setLeaveType(Constant.LEAVE_TYPE_ANNUAL_LEAVE);
        attendanceLeaveQueryCriteria.setLeaveStartTimeLike(targetYearMonth.substring(0,7));
        attendanceLeaveQueryCriteria.setLeaveEndTimeLike(targetYearMonth.substring(0,7));
        attendanceLeaveQueryCriteria.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
        // 获取本月请假列表
        List<AttendanceLeave> attendanceLeaveMonthList = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,attendanceLeaveQueryCriteria,criteriaBuilder));
        // 出差检索类
        AttendanceBusinessTravelQueryCriteria attendanceBusinessTravelQueryCriteria = new AttendanceBusinessTravelQueryCriteria();
        attendanceBusinessTravelQueryCriteria.setUserId(criteria.getUserId());
        attendanceBusinessTravelQueryCriteria.setTravelStartTimeLike(targetYearMonth.substring(0,7));
        attendanceBusinessTravelQueryCriteria.setTravelEndTimeLike(targetYearMonth.substring(0,7));
        attendanceBusinessTravelQueryCriteria.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
        // 获取本月出差列表
        List<AttendanceBusinessTravel> attendanceBusinessTravelMonthList = attendanceBusinessTravelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,attendanceBusinessTravelQueryCriteria,criteriaBuilder));
        // 外出检索类
        AttendanceGoOutQueryCriteria attendanceGoOutQueryCriteria = new AttendanceGoOutQueryCriteria();
        attendanceGoOutQueryCriteria.setUserId(criteria.getUserId());
        attendanceGoOutQueryCriteria.setOutStartTimeLike(targetYearMonth.substring(0,7));
        attendanceGoOutQueryCriteria.setOutEndTimeLike(targetYearMonth.substring(0,7));
        attendanceGoOutQueryCriteria.setApprovalStatus(Constant.APPROVAL_STATUS_PASSED);
        // 获取本月外出列表
        List<AttendanceGoOut> attendanceGoOutMonthList = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,attendanceGoOutQueryCriteria,criteriaBuilder));
        // 日历类
        Calendar cal = setUpCalendar(targetYearMonth);
@@ -316,34 +349,59 @@
        for (int i = 1; i <= lastDay; i ++) {
            // 设置天数
            cal.set(Calendar.DAY_OF_MONTH, i);
            // 本日星期几
            int week = cal.get(Calendar.DAY_OF_WEEK);
            // 设置本日初时间
            Calendar startCal = DateUtil.setDayStartTime(cal);
            // 设置本日末时间
            Calendar endCal = DateUtil.setDayEndTime(cal);
            // 出勤毫秒数
            Long attendanceTimes = 0L;
            // 获取本日节日列表
            List<SysConfigHoliday> sysConfigHolidayDayList = sysConfigHolidayMonthList.stream().filter(item -> item.getHolidayDate().getTime() == cal.getTime().getTime()).collect(Collectors.toList());
            List<SysConfigHoliday> sysConfigHolidayDayList = sysConfigHolidayMonthList.stream().filter(item -> item.getHolidayDate().getTime() == startCal.getTime().getTime()).collect(Collectors.toList());
            // 判断本日节日列表数量
            if (sysConfigHolidayDayList.size() > 1) {
                throw new BadRequestException("相同日期存在多条节日记录!");
            } else if (sysConfigHolidayDayList.size() == 1) {
                // 本日节日
                SysConfigHoliday sysConfigHolidayDay = sysConfigHolidayDayList.get(0);
                // 判断本日节日日期类型是否为工作日
                if (!Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDay.getDateType())) {
            }
            // 判断本日是否为周末
            if (week == Calendar.SUNDAY || week == Calendar.SATURDAY) {
                // 判断本日节日列表数量
                if (sysConfigHolidayDayList.size() == 1) {
                    // 本日节日
                    SysConfigHoliday sysConfigHolidayDay = sysConfigHolidayDayList.get(0);
                    // 判断本日节日日期类型是否为工作日
                    if (!Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDay.getDateType())) {
                        // 跳过本次循环
                        continue;
                    }
                } else {
                    // 跳过本次循环
                    continue;
                }
            } else {
                // 判断本日节日列表数量
                if (sysConfigHolidayDayList.size() == 1) {
                    // 本日节日
                    SysConfigHoliday sysConfigHolidayDay = sysConfigHolidayDayList.get(0);
                    // 判断本日节日日期类型是否为工作日
                    if (!Constant.DATE_TYPE_WEEKDAY.equals(sysConfigHolidayDay.getDateType())) {
                        // 跳过本次循环
                        continue;
                    }
                }
            }
            // 获取本日考勤列表
            List<Attendance> attendanceDayList = attendanceMonthList.stream().filter(item -> item.getAttendanceDate().getTime() == cal.getTime().getTime()).collect(Collectors.toList());
            List<Attendance> attendanceDayList = attendanceMonthList.stream().filter(item -> item.getAttendanceDate().getTime() == startCal.getTime().getTime()).collect(Collectors.toList());
            // 本日考勤
            Attendance attendanceDay = null;
            // 判断本日考勤列表数量
            if (attendanceDayList.size() > 1) {
                throw new BadRequestException("相同日期存在多条考勤记录!");
            } else if (attendanceDayList.size() == 1) {
                // 本日考勤
                Attendance attendanceDay = attendanceDayList.get(0);
                attendanceDay = attendanceDayList.get(0);
                // 判断本日考勤排班信息是否完整
                if (attendanceDay.getRosteringWorkStartTime() == null || "".equals(attendanceDay.getRosteringWorkStartTime()) ||
                        attendanceDay.getRosteringLunchStartTime() == null || "".equals(attendanceDay.getRosteringLunchStartTime()) ||
@@ -351,34 +409,53 @@
                        attendanceDay.getRosteringWorkEndTime() == null || "".equals(attendanceDay.getRosteringWorkEndTime())) {
                    throw new BadRequestException("考勤记录排班信息缺失!");
                }
                // 判断本日考勤是否有实际工作开始时间且开始打卡结果为正常
                if (attendanceDay.getActualWorkStartTime() != null && !"".equals(attendanceDay.getActualWorkStartTime()) && Constant.ATTENDANCE_STATE_NORMAL.equals(attendanceDay.getStartClockResults())) {
                    // 判断实际工作开始时间与排班工作开始时间
                    if (attendanceDay.getActualWorkStartTime().getTime() > attendanceDay.getRosteringWorkStartTime().getTime()) {
                        // 出勤毫秒数 += 排班午休开始时间 - 实际工作开始时间
                        attendanceTimes += attendanceDay.getRosteringLunchStartTime().getTime() - attendanceDay.getActualWorkStartTime().getTime();
                    } else {
                        // 出勤毫秒数 += 排班工作开始时间 - 实际工作开始时间
                        attendanceTimes += attendanceDay.getRosteringLunchStartTime().getTime() - attendanceDay.getRosteringWorkStartTime().getTime();
                    }
                }
                // 判断本日考勤是否有实际工作结束时间且结束打卡结果为正常
                if (attendanceDay.getActualWorkEndTime() != null && !"".equals(attendanceDay.getActualWorkEndTime()) && Constant.ATTENDANCE_STATE_NORMAL.equals(attendanceDay.getEndClockResults())) {
                    // 判断实际工作结束时间与排班工作结束时间
                    if (attendanceDay.getActualWorkEndTime().getTime() > attendanceDay.getRosteringWorkEndTime().getTime()) {
                        // 出勤毫秒数 += 排班工作结束时间 - 排班午休结束时间
                        attendanceTimes += attendanceDay.getRosteringWorkEndTime().getTime() - attendanceDay.getRosteringLunchEndTime().getTime();
                    } else {
                        // 出勤毫秒数 += 实际工作结束时间 - 排班午休结束时间
                        attendanceTimes += attendanceDay.getActualWorkEndTime().getTime() - attendanceDay.getRosteringLunchEndTime().getTime();
                    }
                // 判断本日考勤是否有实际工作开始时间、实际工作结束时间
                if (attendanceDay.getActualWorkStartTime() != null && !"".equals(attendanceDay.getActualWorkStartTime()) && attendanceDay.getActualWorkEndTime() != null && !"".equals(attendanceDay.getActualWorkEndTime())) {
                    // 获取有效时长
                    attendanceTimes += getValidDuration(attendanceDay, attendanceDay.getActualWorkStartTime(), attendanceDay.getActualWorkEndTime());
                }
            } else {
                // 跳过本次循环
                continue;
            }
            // 获取本日请假列表
            List<AttendanceLeave> attendanceLeaveDayList = attendanceLeaveMonthList.stream().filter(item ->
                    item.getLeaveStartTime().getTime() >= startCal.getTime().getTime() && item.getLeaveStartTime().getTime() <= endCal.getTime().getTime() &&
                    item.getLeaveEndTime().getTime() >= startCal.getTime().getTime() && item.getLeaveEndTime().getTime() <= endCal.getTime().getTime()
            ).collect(Collectors.toList());
            // 循环本日请假列表
            for (int j = 0; j < attendanceLeaveDayList.size(); j ++) {
                // 本日请假
                AttendanceLeave attendanceLeaveDay = attendanceLeaveDayList.get(j);
                // 获取有效时长
                attendanceTimes += getValidDuration(attendanceDay, attendanceLeaveDay.getLeaveStartTime(), attendanceLeaveDay.getLeaveEndTime());
            }
            // 获取本日出差列表
            List<AttendanceBusinessTravel> attendanceBusinessTravelDayList = attendanceBusinessTravelMonthList.stream().filter(item ->
                    item.getTravelStartTime().getTime() == startCal.getTime().getTime() && item.getTravelEndTime().getTime() == startCal.getTime().getTime()
            ).collect(Collectors.toList());
            //  循环本日出差列表
            for (int j = 0; j < attendanceBusinessTravelDayList.size(); j ++) {
                // 本日出差
                AttendanceBusinessTravel attendanceBusinessTravelDay = attendanceBusinessTravelDayList.get(j);
                // 获取有效时长
                attendanceTimes += getValidDuration(attendanceDay, attendanceBusinessTravelDay.getTravelStartTime(), attendanceBusinessTravelDay.getTravelEndTime());
            }
            // 获取本日外出列表
            List<AttendanceGoOut> attendanceGoOutDayList = attendanceGoOutMonthList.stream().filter(item ->
                    item.getOutStartTime().getTime() >= startCal.getTime().getTime() && item.getOutStartTime().getTime() <= endCal.getTime().getTime() &&
                    item.getOutEndTime().getTime() >= startCal.getTime().getTime() && item.getOutEndTime().getTime() <= endCal.getTime().getTime()
            ).collect(Collectors.toList());
            // 循环本日外出列表
            for (int j = 0; j < attendanceGoOutDayList.size(); j ++) {
                // 本日外出
                AttendanceGoOut attendanceGoOutDay = attendanceGoOutDayList.get(j);
                // 获取有效时长
                attendanceTimes += getValidDuration(attendanceDay, attendanceGoOutDay.getOutStartTime(), attendanceGoOutDay.getOutEndTime());
            }
            // 出勤小时数
            attendanceHours += attendanceTimes / (60 * 60 * 1000);
@@ -398,15 +475,80 @@
        cal.set(Calendar.YEAR, Integer.valueOf(targetYearMonth.substring(0,4)));
        // 设置月份
        cal.set(Calendar.MONTH, Integer.valueOf(targetYearMonth.substring(5,7)) - 1);
        // 设置时数
        cal.set(Calendar.HOUR_OF_DAY, 0);
        // 设置分数
        cal.set(Calendar.MINUTE, 0);
        // 设置秒数
        cal.set(Calendar.SECOND, 0);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 0);
        // 日历类
        return cal;
    }
    /**
     * 获取有效时长
     * @param attendanceDay
     * @param startTime
     * @param endTime
     * @return
     */
    private Long getValidDuration(Attendance attendanceDay, Timestamp startTime, Timestamp endTime) {
        // 判断开始时间与结束时间
        if (endTime.getTime() < startTime.getTime()) {
            throw new BadRequestException("结束时间应大于开始时间!");
        }
        // 判断开始时间
        if (startTime.getTime() < attendanceDay.getRosteringWorkStartTime().getTime()) {
            // 判断结束时间
            if (endTime.getTime() < attendanceDay.getRosteringWorkStartTime().getTime()) {
                // 返回有效时长 = 0
                return 0L;
            } else if (endTime.getTime() < attendanceDay.getRosteringLunchStartTime().getTime()) {
                // 返回有效时长 = 结束时间 - 排班工作开始时间
                return endTime.getTime() - attendanceDay.getRosteringWorkStartTime().getTime();
            } else if (endTime.getTime() < attendanceDay.getRosteringLunchEndTime().getTime()) {
                // 返回有效时长 = 排班午休开始时间 - 排班工作开始时间
                return attendanceDay.getRosteringLunchStartTime().getTime() - attendanceDay.getRosteringWorkStartTime().getTime();
            } else if (endTime.getTime() < attendanceDay.getRosteringWorkEndTime().getTime()) {
                // 返回有效时长 = (排班午休开始时间 - 排班工作开始时间) + (结束时间 - 排班午休结束时间)
                return (attendanceDay.getRosteringLunchStartTime().getTime() - attendanceDay.getRosteringWorkStartTime().getTime()) + (endTime.getTime() - attendanceDay.getRosteringLunchEndTime().getTime());
            } else {
                // 返回有效时长 = (排班午休开始时间 - 排班工作开始时间) + (排班工作结束时间 - 排班午休结束时间)
                return (attendanceDay.getRosteringLunchStartTime().getTime() - attendanceDay.getRosteringWorkStartTime().getTime()) + (attendanceDay.getRosteringWorkEndTime().getTime() - attendanceDay.getRosteringLunchEndTime().getTime());
            }
        } else if (startTime.getTime() < attendanceDay.getRosteringLunchStartTime().getTime()) {
            // 判断结束时间
            if (endTime.getTime() < attendanceDay.getRosteringLunchStartTime().getTime()) {
                // 返回有效时长 = 结束时间 - 开始时间
                return endTime.getTime() - startTime.getTime();
            } else if (endTime.getTime() < attendanceDay.getRosteringLunchEndTime().getTime()) {
                // 返回有效时长 = 排班午休开始时间 - 开始时间
                return attendanceDay.getRosteringLunchStartTime().getTime() - startTime.getTime();
            } else if (endTime.getTime() < attendanceDay.getRosteringWorkEndTime().getTime()) {
                // 返回有效时长 = (排班午休开始时间 - 开始时间) + (结束时间 - 排班午休结束时间)
                return (attendanceDay.getRosteringLunchStartTime().getTime() - startTime.getTime()) + (endTime.getTime() - attendanceDay.getRosteringLunchEndTime().getTime());
            } else {
                // 返回有效时长 = (排班午休开始时间 - 开始时间) + (排班工作结束时间 - 排班午休结束时间)
                return (attendanceDay.getRosteringLunchStartTime().getTime() - startTime.getTime()) + (attendanceDay.getRosteringWorkEndTime().getTime() - attendanceDay.getRosteringLunchEndTime().getTime());
            }
        } else if (startTime.getTime() < attendanceDay.getRosteringLunchEndTime().getTime()) {
            // 判断结束时间
            if (endTime.getTime() < attendanceDay.getRosteringLunchEndTime().getTime()) {
                // 返回有效时长 = 0
                return 0L;
            } else if (endTime.getTime() < attendanceDay.getRosteringWorkEndTime().getTime()) {
                // 返回有效时长 = 结束时间 - 排班午休结束时间
                return endTime.getTime() - attendanceDay.getRosteringLunchEndTime().getTime();
            } else {
                // 返回有效时长 = 排班工作结束时间 - 排班午休结束时间
                return attendanceDay.getRosteringWorkEndTime().getTime() - attendanceDay.getRosteringLunchEndTime().getTime();
            }
        } else if (startTime.getTime() < attendanceDay.getRosteringWorkEndTime().getTime()) {
            // 判断结束时间
            if (endTime.getTime() < attendanceDay.getRosteringWorkEndTime().getTime()) {
                // 返回有效时长 = 结束时间 - 开始时间
                return endTime.getTime() - startTime.getTime();
            } else {
                // 返回有效时长 = 排班工作结束时间 - 开始时间
                return attendanceDay.getRosteringWorkEndTime().getTime() - startTime.getTime();
            }
        } else {
            // 返回有效时长 = 0
            return 0L;
        }
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -216,4 +216,10 @@
    // 审批状态:已拒绝
    public static final String BUSSINESS_APPROVE_STATUS_REFUSE = "business_approve_status_refuse";
    // 公示状态
    public static final String PUBLICITY_STATUS = "publicity_status";
    // 公示状态:未公示
    public static final String PUBLICITY_STATUS_NOT = "publicity_status_not";
    // 公示状态:已公示
    public static final String PUBLICITY_STATUS_YES = "publicity_status_yes";
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/rest/ProjectCostController.java
@@ -28,6 +28,7 @@
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.text.ParseException;
import javax.servlet.http.HttpServletResponse;
/**
@@ -97,7 +98,7 @@
    @Log("查询项目成本")
    @ApiOperation("查询项目成本")
    @PreAuthorize("@el.check('projectCost:list')")
    public ResponseEntity<Object> getProjectCost(ProjectCostQueryCriteria criteria){
    public ResponseEntity<Object> getProjectCost(ProjectCostQueryCriteria criteria) throws ParseException {
        return new ResponseEntity<>(projectCostService.getCost(criteria),HttpStatus.OK);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/ProjectCostService.java
@@ -19,6 +19,8 @@
import me.zhengjie.modules.project.service.dto.ProjectCostDto;
import me.zhengjie.modules.project.service.dto.ProjectCostQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.text.ParseException;
import java.util.Map;
import java.util.List;
import java.io.IOException;
@@ -73,7 +75,7 @@
    */
    void deleteAll(Long[] ids);
    ProjectCost getCost(ProjectCostQueryCriteria criteria);
    ProjectCost getCost(ProjectCostQueryCriteria criteria) throws ParseException;
    /**
    * 导出数据
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/dto/ProjectCostQueryCriteria.java
@@ -17,7 +17,6 @@
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
@@ -38,9 +37,9 @@
    /** 精确 */
    @Query
    private Timestamp enterProjectTime;
    private String enterProjectTime;
    /** 精确 */
    @Query
    private Timestamp exitProjectTime;
    private String exitProjectTime;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/impl/ProjectCostServiceImpl.java
@@ -15,7 +15,9 @@
*/
package me.zhengjie.modules.project.service.impl;
import lombok.Data;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.attendance.domain.Calculate;
import me.zhengjie.modules.attendance.service.AttendanceService;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.project.domain.Project;
import me.zhengjie.modules.project.domain.ProjectCost;
@@ -28,6 +30,8 @@
import me.zhengjie.modules.system.repository.SysUserLevelInsuranceRepository;
import me.zhengjie.modules.system.repository.SysUserLevelWageRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.utils.FileUtil;
import lombok.RequiredArgsConstructor;
@@ -36,7 +40,6 @@
import me.zhengjie.modules.project.service.dto.ProjectCostDto;
import me.zhengjie.modules.project.service.dto.ProjectCostQueryCriteria;
import me.zhengjie.modules.project.service.mapstruct.ProjectCostMapper;
import org.apache.tomcat.util.bcel.Const;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@@ -44,7 +47,10 @@
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.math.BigDecimal;
import java.text.*;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
@@ -67,6 +73,8 @@
    private final SysUserLevelWageRepository sysUserLevelWageRepository;
    private final SysUserLevelInsuranceRepository sysUserLevelInsuranceRepository;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final UserService userService;
    private final AttendanceService attendanceService;
    @Override
    public Map<String,Object> queryAll(ProjectCostQueryCriteria criteria, Pageable pageable){
@@ -127,124 +135,237 @@
    }
    @Override
    public ProjectCost getCost(ProjectCostQueryCriteria criteria){
    public ProjectCost getCost(ProjectCostQueryCriteria criteria) throws ParseException {
        ProjectCost projectCost = new ProjectCost();
        // 创建Calendar类实例
        Calendar instance = Calendar.getInstance();
        // 工资
        BigDecimal wageCost = BigDecimal.valueOf(0);
        // 保险
        BigDecimal insurancesCost = BigDecimal.valueOf(0);
        Date date = new Date();
//        BigDecimal d = BigDecimal.valueOf(20);
        int workDays = 0;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        List<SysUserLevelWage> sysUserLevelWage = sysUserLevelWageRepository.findByUserId(criteria.getUserId());
        List<SysUserLevelInsurance> sysUserLevelInsurances = sysUserLevelInsuranceRepository.findByUserId(criteria.getUserId());
//        for(int i=0; i<=sysUserLevelWage.size();i++ ){
            // 判断项目开始时间是否小于级别结束时间
            if(criteria.getEnterProjectTime().before(sysUserLevelWage.get(0).getEndDate())){
                // 判断项目结束时间是否小于级别结束时间
                if(criteria.getExitProjectTime().before(sysUserLevelWage.get(0).getEndDate())){
                    // 项目总用时
                    for(int i = 1;i<= (criteria.getExitProjectTime().getTime() - criteria.getEnterProjectTime().getTime())/(1000 * 60 * 60 * 24);i++){
//                        sysUserLevelWage.get(0).getLevelWage().divide(d,2,BigDecimal.ROUND_CEILING);
//                        BigDecimal multiply = sysUserLevelInsurances.get(0).getAccumulationRadix().multiply(sysUserLevelInsurances.get(0).getAccumulationCompanyProportion());
                        // 增加天数
                        String res = simpleDateFormat.format(criteria.getEnterProjectTime().getTime() + (i * 24 * 60 * 60 * 1000));
                        try {
                            date = simpleDateFormat.parse(res);
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
//                        System.out.println(date);
                        instance.setTime(date);
                        // 判断周六周日
                        if(instance.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY || instance.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周六周日是否为工作日 是工作日工作天数加一天
                            if(sysConfigHoliday != null){
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_WEEKEND || sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        } else {
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周一到周五是否为节假日 不是节假日工作天数加一天
                            if(sysConfigHoliday == null){
                                workDays++;
                            } else {
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        }
                    }
                } else {
                    // 用户在第一个级别时所在的项目时间
                    for(int i = 1;i<= (sysUserLevelWage.get(0).getEndDate().getTime() - criteria.getEnterProjectTime().getTime())/(1000 * 60 * 60 * 24);i++){
                        String res = simpleDateFormat.format(criteria.getEnterProjectTime().getTime() + (i *( 24 * 60 * 60 * 1000)));
                        try {
                            date = simpleDateFormat.parse(res);
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
//                        System.out.println(date);
                        instance.setTime(date);
                        // 判断周六周日
                        if(instance.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY || instance.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周六周日是否为工作日 是工作日工作天数加一天
                            if(sysConfigHoliday != null){
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_WEEKEND || sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        } else {
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周一到周五是否为节假日 不是节假日工作天数加一天
                            if(sysConfigHoliday == null){
                                workDays++;
                            } else {
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        }
                    }
                    // 项目在第二个级别时所在项目的时间
                    for(int f = 1; f<= (criteria.getExitProjectTime().getTime()- sysUserLevelWage.get(1).getStartDate().getTime())/(1000 * 60 * 60 * 24);f++){
                        String res = simpleDateFormat.format(sysUserLevelWage.get(1).getStartDate().getTime()+ (f * 24 * 60 * 60 * 1000));
                        try {
                            date = simpleDateFormat.parse(res);
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                        instance.setTime(date);
                        // 判断周六周日
                        if(instance.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY || instance.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周六周日是否为工作日 是工作日工作天数加一天
                            if(sysConfigHoliday != null){
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_WEEKEND || sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        } else {
                            SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
                            // 判断周一到周五是否为节假日 不是节假日工作天数加一天
                            if(sysConfigHoliday == null){
                                workDays++;
                            } else {
                                if(sysConfigHoliday.getDateType()!= Constant.DATE_TYPE_LEGAL_HOLIDAYS){
                                    workDays++;
                                }
                            }
                        }
                    }
                }
            } else {
        Date dateExit = new Date();
        // 工作天数
        Calculate calculate=new Calculate();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date enterProjectTimeOne = simpleDateFormat.parse(criteria.getEnterProjectTime());
        Date exitProjectTimeOne = simpleDateFormat.parse(criteria.getExitProjectTime());
        Set<String> availableZoneIds = ZoneOffset.getAvailableZoneIds();
        LocalDateTime enterProject = LocalDateTime.ofInstant(enterProjectTimeOne.toInstant(),ZoneOffset.UTC);
        LocalDateTime exitProject = LocalDateTime.ofInstant(exitProjectTimeOne.toInstant(),ZoneOffset.UTC);
        calculate.setStart(enterProject);
        calculate.setEnd(exitProject);
        // 通过id获取用户级别工资
        List<SysUserLevelWage> sysUserLevelWages = sysUserLevelWageRepository.findByUserId(criteria.getUserId());
        // 通过id获取用户级别保险
        List<SysUserLevelInsurance> sysUserLevelInsurances = sysUserLevelInsuranceRepository.findByUserId(criteria.getUserId());
        // 通过id获取用户信息
        UserDto user = userService.findById(criteria.getUserId());
        // 判断是否有用户级别工资
        if(sysUserLevelWages.size() <= 0){
            throw new BadRequestException("此用户暂无级别工资");
        }
        // 判断是否有用户级别保险
        if(sysUserLevelInsurances.size() <= 0){
            throw new BadRequestException("此用户暂无级别保险");
        }
        for (SysUserLevelInsurance sysUserLevelInsurance : sysUserLevelInsurances) {
            Date enterProjectTime = simpleDateFormat.parse(criteria.getEnterProjectTime());
            Date exitProjectTime = simpleDateFormat.parse(criteria.getExitProjectTime());
            if (exitProjectTime.before(sysUserLevelInsurance.getStartDate())) {
                // nothing to do
            } else if (sysUserLevelInsurance.getEndDate() !=null && enterProjectTime.after(sysUserLevelInsurance.getEndDate())) {
                // nothing to do
            } else {
                if (enterProjectTime.before(sysUserLevelInsurance.getStartDate())) {
                    enterProjectTime = sysUserLevelInsurance.getStartDate();
                }
                if (sysUserLevelInsurance.getEndDate() !=null && exitProjectTime.after(sysUserLevelInsurance.getEndDate())) {
                    exitProjectTime = sysUserLevelInsurance.getEndDate();
                }
                int workDays = 0;
//               Integer a= attendanceService.calculateDays(exitProjectTime);
                for(long x = 0; x<= calculateDays(calculate);x++){
                    // 增加天数
                    String res = simpleDateFormat.format(enterProjectTime.getTime() + (x * 24 * 60 * 60 * 1000));
                    String resExit = simpleDateFormat.format(exitProjectTime.getTime() + (x * 24 * 60 * 60 * 1000));
                    try {
                        date = simpleDateFormat.parse(res);
                        dateExit = simpleDateFormat.parse(resExit);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if(enterProjectTimeOne.equals(date)){
                        int workHours = 0;
                        LocalTime parse = LocalTime.parse(res.substring(11));
                        // 判断是否是工作日
                        workHours=checkSun(res,date,workHours);
                        if(workHours > 0){
                            // 是工作日与用户排班下的工作开始时间,工作结束时间,午休结束时间进行比较
                            if(parse.isBefore(user.getSysRostering().getWorkStartTime()) || parse.equals(user.getSysRostering().getWorkStartTime())){
                                workHours = 8;
//                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                            } else if (parse.isBefore(user.getSysRostering().getLunchStartTime())){
                                workHours = user.getSysRostering().getLunchStartTime().getHour() - parse.getHour() +5;
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getLunchEndTime()) || parse.equals(user.getSysRostering().getLunchEndTime())){
                                workHours = 5;
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getWorkEndTime())){
                                workHours =  user.getSysRostering().getWorkEndTime().getHour() - parse.getHour();
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else {
                                // nothing to do
                                workHours = 0;
                            }
                            // 计算小时的花费
                            continue;
                        } else{
                            // 不是工作日 nothing to do
                            continue;
                        }
                    }
                    if(x+1 == (exitProjectTime.getTime() - enterProjectTime.getTime())/(1000 * 60 * 60 * 24)){
                        int workHours = 0;
                        LocalTime parse = LocalTime.parse(res.substring(11));
                        // 判断是否是工作日
                        workHours=checkSun(res,dateExit,workHours);
                        if(workHours > 0){
                            // 是工作日与用户排班下的工作开始时间,工作结束时间,午休结束时间进行比较
                            if(parse.isBefore(user.getSysRostering().getWorkStartTime()) || parse.equals(user.getSysRostering().getWorkStartTime())){
                               // 不工作 nothing to do
                                workHours = 0;
                            } else if (parse.isBefore(user.getSysRostering().getLunchStartTime())){
                                workHours = parse.getHour() - user.getSysRostering().getWorkStartTime().getHour();
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getLunchEndTime()) || parse.equals(user.getSysRostering().getLunchStartTime())){
                                workHours = 3;
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getWorkEndTime())){
                                workHours =  parse.getHour() - user.getSysRostering().getLunchEndTime().getHour() + 3;
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            } else if (parse.isAfter(user.getSysRostering().getWorkEndTime()) || parse.equals(user.getSysRostering().getWorkEndTime())){
                                workHours = 8;
                                insurancesCost = insurancesCost.add(costInsurancesCalcuHour(sysUserLevelInsurance,workHours));
                                continue;
                            }
                            // 计算小时的花费
                            continue;
                        } else{
                            // 不是工作日 nothing to do
                            continue;
                        }
                    }
                    workDays=calculateDays(calculate)-1;
                }
                insurancesCost = insurancesCost.add(costInsurancesCalcu(sysUserLevelInsurance, workDays));
            }
//        }
//        BigDecimal d = BigDecimal.valueOf(20);
//        sysUserLevelWage.get(0).getLevelWage().divide(d,2,BigDecimal.ROUND_CEILING);
        }
        for (SysUserLevelWage sysUserLevelWage : sysUserLevelWages) {
            Date enterProjectTime = simpleDateFormat.parse(criteria.getEnterProjectTime());
            Date exitProjectTime = simpleDateFormat.parse(criteria.getExitProjectTime());
            if (exitProjectTime.before(sysUserLevelWage.getStartDate())) {
                // nothing to do
            } else if (sysUserLevelWage.getEndDate() !=null && enterProjectTime.after(sysUserLevelWage.getEndDate())) {
                // nothing to do
            } else {
                if (enterProjectTime.before(sysUserLevelWage.getStartDate())) {
                    enterProjectTime = sysUserLevelWage.getStartDate();
                }
                if ( sysUserLevelWage.getEndDate() != null && exitProjectTime.after(sysUserLevelWage.getEndDate())) {
                    exitProjectTime = sysUserLevelWage.getEndDate();
                }
                int workDays = 0;
                // 项目总用时 项目的出去时间减去项目的进入时间
                for ( long x = 0;x <= calculateDays(calculate); x++ ) {
                    // 增加天数
                    String res = simpleDateFormat.format(enterProjectTime.getTime() + (x * 24 * 60 * 60 * 1000));
                    String resExit = simpleDateFormat.format(exitProjectTime.getTime() + (x * 24 * 60 * 60 * 1000));
                    try {
                        date = simpleDateFormat.parse(res);
                        dateExit = simpleDateFormat.parse(resExit);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if(enterProjectTimeOne.equals(date)){
                        int workHours = 0;
                        LocalTime parse = LocalTime.parse(res.substring(11));
                        // 判断是否是工作日
                        workHours=checkSun(res,date,workHours);
                        if(workHours > 0){
                            // 是工作日与用户排班下的工作开始时间,工作结束时间,午休结束时间进行比较
                            if(parse.isBefore(user.getSysRostering().getWorkStartTime()) || parse.equals(user.getSysRostering().getWorkStartTime())){
                                workHours = 8;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getLunchStartTime())){
                                workHours = user.getSysRostering().getLunchStartTime().getHour() - parse.getHour() +5;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getLunchEndTime()) || parse.equals(user.getSysRostering().getLunchEndTime())){
                                workHours = 5;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                                continue;
                            } else if (parse.isBefore(user.getSysRostering().getWorkEndTime())){
                                workHours =  user.getSysRostering().getWorkEndTime().getHour() - parse.getHour();
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                                continue;
                            } else {
                                workHours = 0;
                            }
                            // 计算小时的花费
                            continue;
                        } else{
                            // 不是工作日 nothing to do
                            continue;
                        }
                    }
                    if(x+1 == (exitProjectTime.getTime() - enterProjectTime.getTime())/(1000 * 60 * 60 * 24)){
                        int workHours = 0;
                        LocalTime parse = LocalTime.parse(resExit.substring(11));
                        // 判断是否是工作日
                        workHours=checkSun(res,dateExit,workHours);
                        if(workHours > 0){
                            // 是工作日与用户排班下的工作开始时间,工作结束时间,午休结束时间进行比较
                            if(parse.isBefore(user.getSysRostering().getWorkStartTime()) || parse.equals(user.getSysRostering().getWorkStartTime())){
                                // 不工作
                                workHours = 0;
                            } else if (parse.isBefore(user.getSysRostering().getLunchStartTime())){
                                // 上午工作
                                workHours = parse.getHour() - user.getSysRostering().getWorkStartTime().getHour();
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                            } else if (parse.isBefore(user.getSysRostering().getLunchEndTime()) || parse.equals(user.getSysRostering().getLunchStartTime()) || parse.equals(user.getSysRostering().getLunchEndTime())){
                                // 工作一上午
                                workHours = 3;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                            } else if (parse.isBefore(user.getSysRostering().getWorkEndTime())){
                                // 下午工作
                                workHours =  parse.getHour() - user.getSysRostering().getLunchEndTime().getHour() + 3;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                            } else if (parse.isAfter(user.getSysRostering().getWorkEndTime()) || parse.equals(user.getSysRostering().getWorkEndTime())){
                                // 工作一天
                                workHours = 8;
                                wageCost = wageCost.add(costWageCalcuHour(sysUserLevelWage,workHours));
                            }
                            // 计算小时的花费
                            continue;
                        } else{
                            // 不是工作日 nothing to do
                            continue;
                        }
                    }
                    workDays=calculateDays(calculate)-1;
                }
                wageCost = wageCost.add(costWageCalcu( sysUserLevelWage, workDays));
            }
        }
        projectCost.setProjectCost(wageCost.add(insurancesCost));
        return projectCost;
    }
@@ -269,4 +390,98 @@
        }
        FileUtil.downloadExcel(list, response);
    }
    // 获取工作天数
    public int checkSun(String res, Date date, int workDays) {
        // 创建Calendar类实例
        Calendar instance = Calendar.getInstance();
        instance.setTime(date);
        SysConfigHoliday sysConfigHoliday = sysConfigHolidayRepository.findByHolidayDate(res);
        // 判断周六周日
        if(instance.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY || instance.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
            // 判断周六周日是否为工作日 是工作日工作天数加一天
            if(sysConfigHoliday != null){
                if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY) || sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_HOLIDAYS)){
                    workDays++;
                }
            }
        } else {
            // 判断周一到周五是否为节假日 不是节假日工作天数加一天
            if(sysConfigHoliday == null){
                workDays++;
            } else {
                if(!sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_LEGAL_HOLIDAYS)){
                    workDays++;
                }
            }
        }
        return workDays;
    }
    // 计算工资成本
    public BigDecimal costWageCalcu(SysUserLevelWage sysUserLevelWage,int workDays){
        BigDecimal average = BigDecimal.valueOf(21.75);
        BigDecimal wage = sysUserLevelWage.getLevelWage().divide(average,2,BigDecimal.ROUND_CEILING);
        return wage.multiply(BigDecimal.valueOf(workDays));
    }
    // 计算小时工资成本
    public BigDecimal costWageCalcuHour(SysUserLevelWage sysUserLevelWage,int workDays){
        // 每个月的平均工时
        BigDecimal average = BigDecimal.valueOf(21.75);
        // 每天的工时
        BigDecimal averHour = BigDecimal.valueOf(8);
        BigDecimal wage = (sysUserLevelWage.getLevelWage().divide(average,2,BigDecimal.ROUND_CEILING)).divide(averHour,2,BigDecimal.ROUND_CEILING);
//        System.out.println("wage:" +wage.multiply(BigDecimal.valueOf(workDays)));
        return wage.multiply(BigDecimal.valueOf(workDays));
    }
    // 计算小时保险成本
    public BigDecimal costInsurancesCalcuHour(SysUserLevelInsurance sysUserLevelInsurance,int workDays){
        BigDecimal average = BigDecimal.valueOf(21.75);
        BigDecimal avarHour = BigDecimal.valueOf(8);
        BigDecimal accumulationRadix = (sysUserLevelInsurance.getAccumulationRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getAccumulationCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
        BigDecimal pensionRadix = (sysUserLevelInsurance.getPensionRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getPensionCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
        BigDecimal medicalRadix = (sysUserLevelInsurance.getMedicalRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getMedicalCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
        BigDecimal unemploymentRadix = (sysUserLevelInsurance.getUnemploymentRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getUnemploymentCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
        BigDecimal maternityRadix = (sysUserLevelInsurance.getMaternityRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getMaternityCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
        BigDecimal industrialInjuryRadix = (sysUserLevelInsurance.getIndustrialInjuryRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getIndustrialInjuryCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING)).divide(avarHour,2,BigDecimal.ROUND_CEILING);
//        System.out.println("calcuhour:" + accumulationRadix.add(pensionRadix.add(medicalRadix.add(unemploymentRadix.add(maternityRadix.add(industrialInjuryRadix))))).multiply(BigDecimal.valueOf(workDays)));
        return accumulationRadix.add(pensionRadix.add(medicalRadix.add(unemploymentRadix.add(maternityRadix.add(industrialInjuryRadix))))).multiply(BigDecimal.valueOf(workDays));
    }
    // 计算保险成本
    public BigDecimal costInsurancesCalcu(SysUserLevelInsurance sysUserLevelInsurance,int workDays){
        BigDecimal average = BigDecimal.valueOf(21.75);
        BigDecimal accumulationRadix = sysUserLevelInsurance.getAccumulationRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getAccumulationCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        BigDecimal pensionRadix = sysUserLevelInsurance.getPensionRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getPensionCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        BigDecimal medicalRadix = sysUserLevelInsurance.getMedicalRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getMedicalCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        BigDecimal unemploymentRadix = sysUserLevelInsurance.getUnemploymentRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getUnemploymentCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        BigDecimal maternityRadix = sysUserLevelInsurance.getMaternityRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getMaternityCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        BigDecimal industrialInjuryRadix = sysUserLevelInsurance.getIndustrialInjuryRadix().multiply(BigDecimal.valueOf(sysUserLevelInsurance.getIndustrialInjuryCompanyProportion()/100)).divide(average,2,BigDecimal.ROUND_CEILING);
        return accumulationRadix.add(pensionRadix.add(medicalRadix.add(unemploymentRadix.add(maternityRadix.add(industrialInjuryRadix))))).multiply(BigDecimal.valueOf(workDays));
    }
    public Integer calculateDays(Calculate calculate) {
        List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
        //查询节假日表
        List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
        for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
            if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
                //工作日
                isWork.add(sysConfigHoliday.getHolidayDate().toString());
            }else{
                holiday.add(sysConfigHoliday.getHolidayDate().toString());
            }
        }
        Long chronoUnit =  ChronoUnit.DAYS.between(calculate.getStart().toLocalDate(), calculate.getEnd().toLocalDate());
        Integer count = 0;
        for (Integer i = 0; i <= chronoUnit; i++) {
            LocalDate date = calculate.getStart().toLocalDate().plusDays(i);
            Boolean isWeekend = date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
            if ((!isWeekend && !holiday.contains(date.toString())) || (isWeekend && isWork.contains(date.toString()))) {
                count++;
            }
        }
        return count;
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/SalaryTask.java
New file
@@ -0,0 +1,421 @@
package me.zhengjie.modules.quartz.task;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.attendance.service.AttendanceService;
import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.salary.domain.Salary;
import me.zhengjie.modules.salary.service.SalaryService;
import me.zhengjie.modules.salary.service.dto.SalaryQueryCriteria;
import me.zhengjie.modules.system.service.*;
import me.zhengjie.modules.system.service.dto.*;
import me.zhengjie.modules.task.service.TaskDaliyService;
import me.zhengjie.modules.task.service.dto.TaskDaliyQueryCriteria;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
 * 工资管理相关任务
 * @author 赵士淞
 * @date 2023-01-10
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class SalaryTask {
    private final UserService userService;
    private final SysUserLevelWageService sysUserLevelWageService;
    private final SysUserLevelInsuranceService sysUserLevelInsuranceService;
    private final SysUserLevelOtherService sysUserLevelOtherService;
    private final SalaryService salaryService;
    private final AttendanceService attendanceService;
    private final TaskDaliyService taskDaliyService;
    private final SysConfigIndividualIncomeTaxService sysConfigIndividualIncomeTaxService;
    // 工资结算
    public void salarySettlement() {
        // 日历类
        Calendar cal = Calendar.getInstance();
        // 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        // 目标年月
        String targetYearMonth = sdf.format(cal.getTime());
        // 用户工资结算
        userSalarySettlement(null, targetYearMonth);
    }
    // 用户工资结算
    public void userSalarySettlement(Long userId, String targetYearMonth) {
        // 判断用户ID是否为空
        if (userId != null && !"".equals(userId)) {
            // 单个用户工资结算
            singleUserSalarySettlement(userId, targetYearMonth);
        } else {
            // 用户检索类
            UserQueryCriteria userQueryCriteria = new UserQueryCriteria();
            userQueryCriteria.setEnabled(true);
            // 获取用户列表
            List<UserDto> userDtoList = userService.queryAll(userQueryCriteria);
            // 循环用户列表
            for (int i = 0; i < userDtoList.size(); i ++) {
                try {
                    // 单个用户工资结算
                    singleUserSalarySettlement(userDtoList.get(i).getId(), targetYearMonth);
                } catch (Exception e) {
                    // 跳过本次循环
                    continue;
                }
            }
        }
    }
    // 单个用户工资结算
    private void singleUserSalarySettlement(Long userId, String targetYearMonth) {
        // 日历类
        Calendar cal = Calendar.getInstance();
        // 设置年份
        cal.set(Calendar.YEAR, Integer.valueOf(targetYearMonth.substring(0,4)));
        // 设置月份
        cal.set(Calendar.MONTH, Integer.valueOf(targetYearMonth.substring(5,7)) - 1);
        // 设置日份
        cal.set(Calendar.DAY_OF_MONTH, 1);
        // 设置时数
        cal.set(Calendar.HOUR_OF_DAY, 0);
        // 设置分数
        cal.set(Calendar.MINUTE, 0);
        // 设置秒数
        cal.set(Calendar.SECOND, 0);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 0);
        // 工资实体类
        Salary salary = new Salary();
        salary.setUserId(userId);
        salary.setSalaryYearMonth(new Timestamp(cal.getTime().getTime()));
        salary.setPublicityStatus(Constant.PUBLICITY_STATUS_NOT);
        salary.setApproveStatus(Constant.APPROVE_STATUS_UNRECOGNIZED);
        // 获取用户级别工资
        salary = getUserLevelWage(userId, targetYearMonth, salary);
        // 获取用户级别保险
        salary = getUserLevelInsurance(userId, targetYearMonth, salary);
        // 获取用户级别其他
        salary = getUserLevelOther(userId, targetYearMonth, salary);
        // 获取工作天数
        salary = getWorkDays(targetYearMonth, salary);
        // 获取出勤小时数
        salary = getAttendanceHours(userId, targetYearMonth, salary);
        // 获取达标工时
        salary = getComplianceWork(userId, targetYearMonth, salary);
        // 获取已完成工时
        salary = getCompletedWork(userId, targetYearMonth, salary);
        try {
            // 保存
            salaryService.create(salary);
        } catch (Exception e) {
            // 删除
            salaryService.deleteByUserIdAndSalaryYearMonthAndCreateNew(salary);
        }
    }
    // 获取用户级别工资
    private Salary getUserLevelWage(Long userId, String targetYearMonth, Salary salary) {
        // 用户级别工资检索类
        SysUserLevelWageQueryCriteria sysUserLevelWageQueryCriteria = new SysUserLevelWageQueryCriteria();
        sysUserLevelWageQueryCriteria.setUserId(userId);
        sysUserLevelWageQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询指定年月用户级别工资
        SysUserLevelWageDto sysUserLevelWageDto = sysUserLevelWageService.queryTargetYearMonth(sysUserLevelWageQueryCriteria);
        // 级别工资
        salary.setLevelWage(sysUserLevelWageDto.getLevelWage());
        // 基本工资比例
        salary.setBasicWageProportion(sysUserLevelWageDto.getBasicWageProportion());
        // 预计基本工资
        salary.setBasicWage(sysUserLevelWageDto.getLevelWage().multiply(new BigDecimal(sysUserLevelWageDto.getBasicWageProportion() / 100)));
        // 绩效工资比例
        salary.setAchievementsWageProportion(sysUserLevelWageDto.getAchievementsWageProportion());
        // 预计绩效工资
        salary.setAchievementsWage(sysUserLevelWageDto.getLevelWage().multiply(new BigDecimal(sysUserLevelWageDto.getAchievementsWageProportion() / 100)));
        // 业绩工资比例
        salary.setPerformanceWageProportion(sysUserLevelWageDto.getPerformanceWageProportion());
        // 预计业绩工资
        salary.setPerformanceWage(sysUserLevelWageDto.getLevelWage().multiply(new BigDecimal(sysUserLevelWageDto.getPerformanceWageProportion() / 100)));
        // 团队工资比例
        salary.setTeamWageProportion(sysUserLevelWageDto.getTeamWageProportion());
        // 预计团队工资
        salary.setTeamWage(sysUserLevelWageDto.getLevelWage().multiply(new BigDecimal(sysUserLevelWageDto.getTeamWageProportion() / 100)));
        // 返回
        return salary;
    }
    // 获取用户级别保险
    private Salary getUserLevelInsurance(Long userId, String targetYearMonth, Salary salary) {
        // 用户级别保险查询类
        SysUserLevelInsuranceQueryCriteria sysUserLevelInsuranceQueryCriteria = new SysUserLevelInsuranceQueryCriteria();
        sysUserLevelInsuranceQueryCriteria.setUserId(userId);
        sysUserLevelInsuranceQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询指定年月用户级别保险
        SysUserLevelInsuranceDto sysUserLevelInsuranceDto = sysUserLevelInsuranceService.queryTargetYearMonth(sysUserLevelInsuranceQueryCriteria);
        // 公积金基数
        salary.setAccumulationRadix(sysUserLevelInsuranceDto.getAccumulationRadix());
        // 公积金个人缴纳比例
        salary.setAccumulationPersonalProportion(sysUserLevelInsuranceDto.getAccumulationPersonalProportion());
        // 公积金个人缴纳金额
        salary.setAccumulationPersonalAmount(sysUserLevelInsuranceDto.getAccumulationRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getAccumulationPersonalProportion() / 100)));
        // 公积金公司缴纳比例
        salary.setAccumulationCompanyProportion(sysUserLevelInsuranceDto.getAccumulationCompanyProportion());
        // 公积金公司缴纳金额
        salary.setAccumulationCompanyAmount(sysUserLevelInsuranceDto.getAccumulationRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getAccumulationCompanyProportion() / 100)));
        // 养老险基数
        salary.setPensionRadix(sysUserLevelInsuranceDto.getPensionRadix());
        // 养老险个人缴纳比例
        salary.setPensionPersonalProportion(sysUserLevelInsuranceDto.getPensionPersonalProportion());
        // 养老险个人缴纳金额
        salary.setPensionPersonalAmount(sysUserLevelInsuranceDto.getPensionRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getPensionPersonalProportion() / 100)));
        // 养老险公司缴纳比例
        salary.setPensionCompanyProportion(sysUserLevelInsuranceDto.getPensionCompanyProportion());
        // 养老险公司缴纳金额
        salary.setPensionCompanyAmount(sysUserLevelInsuranceDto.getPensionRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getPensionCompanyProportion() / 100)));
        // 医疗险基数
        salary.setMedicalRadix(sysUserLevelInsuranceDto.getMedicalRadix());
        // 医疗险个人缴纳比例
        salary.setMedicalPersonalProportion(sysUserLevelInsuranceDto.getMedicalPersonalProportion());
        // 医疗险个人缴纳金额
        salary.setMedicalPersonalAmount(sysUserLevelInsuranceDto.getMedicalRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getMedicalPersonalProportion() / 100)));
        // 医疗险公司缴纳比例
        salary.setMedicalCompanyProportion(sysUserLevelInsuranceDto.getMedicalCompanyProportion());
        // 医疗险公司缴纳金额
        salary.setMedicalCompanyAmount(sysUserLevelInsuranceDto.getMedicalRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getMedicalCompanyProportion() / 100)));
        // 失业险基数
        salary.setUnemploymentRadix(sysUserLevelInsuranceDto.getUnemploymentRadix());
        // 失业险个人缴纳比例
        salary.setUnemploymentPersonalProportion(sysUserLevelInsuranceDto.getUnemploymentPersonalProportion());
        // 失业险个人缴纳金额
        salary.setUnemploymentPersonalAmount(sysUserLevelInsuranceDto.getUnemploymentRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getUnemploymentPersonalProportion() / 100)));
        // 失业险公司缴纳比例
        salary.setUnemploymentCompanyProportion(sysUserLevelInsuranceDto.getUnemploymentCompanyProportion());
        // 失业险公司缴纳金额
        salary.setUnemploymentCompanyAmount(sysUserLevelInsuranceDto.getUnemploymentRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getUnemploymentCompanyProportion() / 100)));
        // 生育险基数
        salary.setMaternityRadix(sysUserLevelInsuranceDto.getMaternityRadix());
        // 生育险个人缴纳比例
        salary.setMaternityPersonalProportion(sysUserLevelInsuranceDto.getMaternityPersonalProportion());
        // 生育险个人缴纳金额
        salary.setMaternityPersonalAmount(sysUserLevelInsuranceDto.getMaternityRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getMaternityPersonalProportion() / 100)));
        // 生育险公司缴纳比例
        salary.setMaternityCompanyProportion(sysUserLevelInsuranceDto.getMaternityCompanyProportion());
        // 生育险公司缴纳金额
        salary.setMaternityCompanyAmount(sysUserLevelInsuranceDto.getMaternityRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getMaternityCompanyProportion() / 100)));
        // 工伤险基数
        salary.setIndustrialInjuryRadix(sysUserLevelInsuranceDto.getIndustrialInjuryRadix());
        // 工伤险个人缴纳比例
        salary.setIndustrialInjuryPersonalProportion(sysUserLevelInsuranceDto.getIndustrialInjuryPersonalProportion());
        // 工伤险个人缴纳金额
        salary.setIndustrialInjuryPersonalAmount(sysUserLevelInsuranceDto.getIndustrialInjuryRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getIndustrialInjuryPersonalProportion() / 100)));
        // 工伤险公司缴纳比例
        salary.setIndustrialInjuryCompanyProportion(sysUserLevelInsuranceDto.getIndustrialInjuryCompanyProportion());
        // 工伤险公司缴纳金额
        salary.setIndustrialInjuryCompanyAmount(sysUserLevelInsuranceDto.getIndustrialInjuryRadix().multiply(new BigDecimal(sysUserLevelInsuranceDto.getIndustrialInjuryCompanyProportion() / 100)));
        // 返回
        return salary;
    }
    // 获取用户级别其他
    private Salary getUserLevelOther(Long userId, String targetYearMonth, Salary salary) {
        // 用户级别其他查询类
        SysUserLevelOtherQueryCriteria sysUserLevelOtherQueryCriteria = new SysUserLevelOtherQueryCriteria();
        sysUserLevelOtherQueryCriteria.setUserId(userId);
        sysUserLevelOtherQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询指定年月用户级别其他
        SysUserLevelOtherDto sysUserLevelOtherDto = sysUserLevelOtherService.queryTargetYearMonth(sysUserLevelOtherQueryCriteria);
        // 个人业绩比例
        salary.setPersonalPerformanceProportion(sysUserLevelOtherDto.getPersonalPerformanceProportion());
        // 返回
        return salary;
    }
    // 获取工作天数
    private Salary getWorkDays(String targetYearMonth, Salary salary) {
        // 工资查询类
        SalaryQueryCriteria salaryQueryCriteria = new SalaryQueryCriteria();
        salaryQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询某月工作天数
        Integer workDays = salaryService.queryWorkDays(salaryQueryCriteria);
        // 全勤小时数
        salary.setFullDays(Double.valueOf(workDays * 8));
        // 应完成绩效工时
        salary.setNeedCompletedAchievementsHours(Double.valueOf(workDays * 8));
        // 定时器
        while (true) {
            // 判断个人业绩比例是否为空
            if (salary.getPersonalPerformanceProportion() != null && !"".equals(salary.getPersonalPerformanceProportion())) {
                // 应完成业绩工时
                salary.setNeedCompletedPerformanceHours(Double.valueOf(workDays * 8 * (1 + salary.getPersonalPerformanceProportion() / 100)));
                // 清空定时器
                break;
            }
        }
        // 返回
        return salary;
    }
    // 获取出勤小时数
    private Salary getAttendanceHours(Long userId, String targetYearMonth, Salary salary) {
        // 考勤查询类
        AttendanceQueryCriteria attendanceQueryCriteria = new AttendanceQueryCriteria();
        attendanceQueryCriteria.setUserId(userId);
        attendanceQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询某月出勤小时数
        Double attendanceHours = attendanceService.queryAttendanceHours(attendanceQueryCriteria);
        // 定时器
        while (true) {
            // 判断预计基础工资、全勤小时数是否为空
            if (salary.getBasicWage() != null && !"".equals(salary.getBasicWage()) && salary.getFullDays() != null && !"".equals(salary.getFullDays())) {
                // 缺勤小时数
                salary.setAbsenceDays(Double.valueOf(salary.getFullDays() - attendanceHours));
                // 小时工资
                BigDecimal hourWage = salary.getBasicWage().divide(new BigDecimal(salary.getFullDays()), 2);
                // 缺勤小时数
                BigDecimal absenceDays = new BigDecimal(salary.getFullDays() - attendanceHours);
                // 实际基础工资
                salary.setActualBasicWage(salary.getBasicWage().subtract(hourWage.multiply(absenceDays)));
                // 清空定时器
                break;
            }
        }
        // 返回
        return salary;
    }
    // 获取达标工时
    private Salary getComplianceWork(Long userId, String targetYearMonth, Salary salary) {
        // 任务日报查询类
        TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria();
        taskDaliyQueryCriteria.setUserId(userId);
        taskDaliyQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询某月已达标工时
        Double complianceWork = taskDaliyService.queryComplianceWork(taskDaliyQueryCriteria);
        // 实达标团队工时
        salary.setActualComplianceTeamHours(complianceWork);
        // 返回
        return salary;
    }
    // 获取已完成工时
    private Salary getCompletedWork(Long userId, String targetYearMonth, Salary salary) {
        // 任务日报查询类
        TaskDaliyQueryCriteria taskDaliyQueryCriteria = new TaskDaliyQueryCriteria();
        taskDaliyQueryCriteria.setUserId(userId);
        taskDaliyQueryCriteria.setTargetYearMonth(targetYearMonth);
        // 查询某月已完成工时
        Double completedWork = taskDaliyService.queryCompletedWork(taskDaliyQueryCriteria);
        // 已完成绩效工时
        salary.setAlreadyCompletedAchievementsHours(completedWork);
        // 已完成业绩工时
        salary.setAlreadyCompletedPerformanceHours(completedWork);
        // 已完成团队工时
        salary.setAlreadyCompletedTeamHours(completedWork);
        // 绩效定时器
        while (true) {
            // 判断预计绩效工资、应完成绩效工时是否为空
            if (salary.getAchievementsWage() != null && !"".equals(salary.getAchievementsWage()) && salary.getNeedCompletedAchievementsHours() != null && !"".equals(salary.getNeedCompletedAchievementsHours())) {
                // 实际绩效工资
                salary.setActualAchievementsWage(salary.getAchievementsWage().multiply(new BigDecimal(completedWork / salary.getNeedCompletedAchievementsHours())));
                // 清空绩效定时器
                break;
            }
        }
        // 业绩定时器
        while (true) {
            // 判断预计业绩工资、应完成业绩工时是否为空
            if (salary.getPerformanceWage() != null && !"".equals(salary.getPerformanceWage()) && salary.getNeedCompletedPerformanceHours() != null && !"".equals(salary.getNeedCompletedPerformanceHours())) {
                // 实际业绩工资
                salary.setActualPerformanceWage(completedWork >= salary.getNeedCompletedPerformanceHours() ? salary.getPerformanceWage() : new BigDecimal(0));
                // 清空业绩定时器
                break;
            }
        }
        // 团队定时器
        while (true) {
            // 判断预计团队工资、实达标团队工时是否为空
            if (salary.getTeamWage() != null && !"".equals(salary.getTeamWage()) && salary.getActualComplianceTeamHours() != null && !"".equals(salary.getActualComplianceTeamHours())) {
                // 实际团队工资
                salary.setActualTeamWage(salary.getActualComplianceTeamHours() != 0 ? salary.getTeamWage().multiply(new BigDecimal(salary.getActualComplianceTeamHours() / completedWork)) : new BigDecimal(0));
                // 清空团队定时器
                break;
            }
        }
        // 统计定时器
        while (true) {
            // 判断 实际基础工资、实际绩效工资、实际业绩工资、实际团队工资、公积金个人缴纳金额、养老险个人缴纳金额、
            // 医疗险个人缴纳金额、失业险个人缴纳金额、生育险个人缴纳金额、工伤险个人缴纳金额 是否为空
            if (
                    salary.getActualBasicWage() != null && !"".equals(salary.getActualBasicWage()) &&
                    salary.getActualAchievementsWage() != null && !"".equals(salary.getActualAchievementsWage()) &&
                    salary.getActualPerformanceWage() != null && !"".equals(salary.getActualPerformanceWage()) &&
                    salary.getActualTeamWage() != null && !"".equals(salary.getActualTeamWage()) &&
                    salary.getAccumulationPersonalAmount() != null && !"".equals(salary.getAccumulationPersonalAmount()) &&
                    salary.getPensionPersonalAmount() != null && !"".equals(salary.getPensionPersonalAmount()) &&
                    salary.getMedicalPersonalAmount() != null && !"".equals(salary.getMedicalPersonalAmount()) &&
                    salary.getUnemploymentPersonalAmount() != null && !"".equals(salary.getUnemploymentPersonalAmount()) &&
                    salary.getMaternityPersonalAmount() != null && !"".equals(salary.getMaternityPersonalAmount()) &&
                    salary.getIndustrialInjuryPersonalAmount() != null && !"".equals(salary.getIndustrialInjuryPersonalAmount())
            ) {
                // 税前金额
                salary.setPreTaxAmount(salary.getActualBasicWage().add(salary.getActualAchievementsWage()).add(salary.getActualPerformanceWage()).add(salary.getActualTeamWage()));
                // 查询个人所得税列表
                List<SysConfigIndividualIncomeTaxDto> sysConfigIndividualIncomeTaxDtoList = sysConfigIndividualIncomeTaxService.queryAll(new SysConfigIndividualIncomeTaxQueryCriteria());
                // 税额
                BigDecimal taxAmount = new BigDecimal(0);
                // 计税金额
                BigDecimal taxableAmount = salary.getPreTaxAmount().subtract(salary.getAccumulationPersonalAmount()).subtract(salary.getPensionPersonalAmount())
                        .subtract(salary.getMedicalPersonalAmount()).subtract(salary.getUnemploymentPersonalAmount()).subtract(salary.getMaternityPersonalAmount())
                        .subtract(salary.getIndustrialInjuryPersonalAmount());
                // 循环个人所得税列表
                for (int i = 0; i < sysConfigIndividualIncomeTaxDtoList.size(); i ++) {
                    // 判断计税金额所在个人所得税范围
                    if (sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd() != null && !"".equals(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd()) &&
                            taxableAmount.compareTo(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd()) == 1) {
                        // 税额
                        taxAmount.add(
                                (sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd().subtract(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountStart()))
                                        .multiply(new BigDecimal(sysConfigIndividualIncomeTaxDtoList.get(i).getTaxRate()).divide(new BigDecimal(100), 2))
                        );
                    } else if (
                            (taxableAmount.compareTo(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountStart()) == 1 ||
                                    taxableAmount.compareTo(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountStart()) == 0) &&
                            (sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd() == null || "".equals(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd()) ||
                                    taxableAmount.compareTo(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd()) == -1 ||
                                    taxableAmount.compareTo(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountEnd()) == 0)
                    ) {
                        // 税额
                        taxAmount.add(
                                (taxableAmount.subtract(sysConfigIndividualIncomeTaxDtoList.get(i).getGearAmountStart()))
                                        .multiply(new BigDecimal(sysConfigIndividualIncomeTaxDtoList.get(i).getTaxRate()).divide(new BigDecimal(100), 2))
                        );
                    }
                    // 判断循环是否结束
                    if (i == sysConfigIndividualIncomeTaxDtoList.size() - 1) {
                        // 个人所得税
                        salary.setIndividualIncomeTax(taxAmount);
                        // 税后金额
                        salary.setAfterTaxAmount(taxableAmount.subtract(taxAmount).compareTo(new BigDecimal(0)) == -1 ? new BigDecimal(0) : taxableAmount.subtract(taxAmount));
                    }
                }
                // 清空统计定时器
                break;
            }
        }
        // 返回
        return salary;
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/domain/Salary.java
@@ -52,7 +52,7 @@
    @Column(name = "`salary_year_month`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "工资年月")
    private String salaryYearMonth;
    private Timestamp salaryYearMonth;
    @Column(name = "`level_wage`",nullable = false)
    @NotNull
@@ -333,6 +333,16 @@
    @ApiModelProperty(value = "备注")
    private String remarks;
    @Column(name = "`publicity_status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "公示状态")
    private String publicityStatus;
    @Column(name = "`approve_status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "承认状态")
    private String approveStatus;
    public void copy(Salary source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/repository/SalaryRepository.java
@@ -18,6 +18,11 @@
import me.zhengjie.modules.salary.domain.Salary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
import java.util.List;
/**
* @website https://eladmin.vip
@@ -25,4 +30,21 @@
* @date 2023-01-03
**/
public interface SalaryRepository extends JpaRepository<Salary, Long>, JpaSpecificationExecutor<Salary> {
    /**
     * 根据用户ID和工资年月查询
     * @param userId
     * @param salaryYearMonth
     * @return
     */
    List<Salary> findByUserIdAndSalaryYearMonth(Long userId, Timestamp salaryYearMonth);
    /**
     * 根据用户ID和工资年月删除
     * @param userId
     * @param salaryYearMonth
     */
    @Modifying
    @Query(value = "DELETE FROM salary WHERE user_id = ?1 AND salary_year_month LIKE CONCAT(?2, '%')",nativeQuery = true)
    void deleteByUserIdAndSalaryYearMonth(Long userId, String salaryYearMonth);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/rest/SalaryController.java
@@ -100,4 +100,22 @@
    public ResponseEntity<Object> queryWorkDays(SalaryQueryCriteria criteria){
        return new ResponseEntity<>(salaryService.queryWorkDays(criteria),HttpStatus.OK);
    }
    @PutMapping(value = "/publicity")
    @Log("公示工资记录")
    @ApiOperation("公示工资记录")
    @PreAuthorize("@el.check('salary:publicity')")
    public ResponseEntity<Object> publicitySalary(@RequestBody Long[] ids){
        salaryService.publicity(ids);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @PutMapping(value = "/approve")
    @Log("承认工资记录")
    @ApiOperation("承认工资记录")
    @PreAuthorize("@el.check('salary:approve')")
    public ResponseEntity<Object> approveSalary(@RequestBody Long[] ids){
        salaryService.approve(ids);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/SalaryService.java
@@ -87,4 +87,22 @@
     * @return List<SalaryDto>
     */
    Integer queryWorkDays(SalaryQueryCriteria criteria);
    /**
     * 根据用户ID和工资年月删除
     * @param resources
     */
    void deleteByUserIdAndSalaryYearMonthAndCreateNew(Salary resources);
    /**
     * 公示工资记录
     * @param ids /
     */
    void publicity(Long[] ids);
    /**
     * 承认工资记录
     * @param ids /
     */
    void approve(Long[] ids);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/dto/SalaryDto.java
@@ -38,7 +38,7 @@
    private Long userId;
    /** 工资年月 */
    private String salaryYearMonth;
    private Timestamp salaryYearMonth;
    /** 级别工资 */
    private BigDecimal levelWage;
@@ -208,6 +208,12 @@
    /** 备注 */
    private String remarks;
    /** 公示状态 */
    private String publicityStatus;
    /** 承认状态 */
    private String approveStatus;
    /** 用户昵称 */
    private String userNickName;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/dto/SalaryQueryCriteria.java
@@ -35,5 +35,13 @@
    @Query(type = Query.Type.INNER_LIKE)
    private String salaryYearMonth;
    /** 精确 */
    @Query
    private String publicityStatus;
    /** 精确 */
    @Query
    private String approveStatus;
    private String targetYearMonth;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/salary/service/impl/SalaryServiceImpl.java
@@ -15,11 +15,16 @@
*/
package me.zhengjie.modules.salary.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.salary.domain.Salary;
import me.zhengjie.modules.system.domain.SysConfigHoliday;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleSmallDto;
import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
@@ -33,13 +38,11 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
@@ -55,9 +58,26 @@
    private final SalaryMapper salaryMapper;
    private final UserRepository userRepository;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final RoleService roleService;
    private final DictDetailRepository dictDetailRepository;
    @Override
    public Map<String,Object> queryAll(SalaryQueryCriteria criteria, Pageable pageable){
        // 判断工资查询类工资年月是否为空
        if (criteria.getSalaryYearMonth() != null && !"".equals(criteria.getSalaryYearMonth())) {
            // 工资年月:国际时间转中国时间
            criteria.setSalaryYearMonth(DateUtil.internationalTimeToChinaTime(criteria.getSalaryYearMonth()));
        }
        // 获取登录用户角色等级
        List<Integer> levels = roleService.findByUsersId(SecurityUtils.getCurrentUserId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList());
        // 登录用户最大角色等级
        int min = Collections.min(levels);
        // 判断角色等级
        if (min == Constant.ROLE_LEVEL_MANAGER || min == Constant.ROLE_LEVEL_LEADER || min == Constant.ROLE_LEVEL_ORDINARY) {
            // 工资查询类
            criteria.setUserId(SecurityUtils.getCurrentUserId());
            criteria.setPublicityStatus(Constant.PUBLICITY_STATUS_YES);
        }
        Page<Salary> page = salaryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        // 将实体类转换为DTO(重写)
        Function<Salary, SalaryDto> func = new Function<Salary, SalaryDto>(){
@@ -93,13 +113,34 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public SalaryDto create(Salary resources) {
        // 根据用户ID和工资年月查询
        List<Salary> salaryList = salaryRepository.findByUserIdAndSalaryYearMonth(resources.getUserId(), resources.getSalaryYearMonth());
        // 判断列表长度
        if (salaryList.size() > 0) {
            throw new BadRequestException("找到相同用户相同年月的工资记录!");
        }
        return salaryMapper.toDto(salaryRepository.save(resources));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(Salary resources) {
        // 根据用户ID和工资年月查询
        List<Salary> salaryList = salaryRepository.findByUserIdAndSalaryYearMonth(resources.getUserId(), resources.getSalaryYearMonth());
        // 判断列表长度
        if (salaryList.size() > 1) {
            throw new BadRequestException("找到相同用户相同年月的工资记录!");
        } else if (salaryList.size() == 1) {
            // 判断是否是同一条记录
            if (salaryList.get(0).getId() != resources.getId()) {
                throw new BadRequestException("找到相同用户相同年月的工资记录!");
            }
        }
        Salary salary = salaryRepository.findById(resources.getId()).orElseGet(Salary::new);
        // 判断承认状态
        if (Constant.APPROVE_STATUS_ACKNOWLEDGED.equals(salary.getApproveStatus())) {
            throw new BadRequestException("已承认的工资记录无法进行修改!");
        }
        ValidationUtil.isNull( salary.getId(),"Salary","id",resources.getId());
        salary.copy(resources);
        salaryRepository.save(salary);
@@ -117,6 +158,8 @@
        List<Map<String, Object>> list = new ArrayList<>();
        for (SalaryDto salary : all) {
            String userNickName = salary.getUserId() != null ? userRepository.findById(salary.getUserId()).orElseGet(User::new).getNickName() : "";
            String publicityStatus = salary.getPublicityStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.PUBLICITY_STATUS, salary.getPublicityStatus()).getLabel() : "";
            String approveStatus = salary.getApproveStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.APPROVE_STATUS, salary.getApproveStatus()).getLabel() : "";
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("员工姓名", userNickName);
            map.put("工资年月", salary.getSalaryYearMonth());
@@ -176,6 +219,8 @@
            map.put("个人所得税", salary.getIndividualIncomeTax());
            map.put("税后金额", salary.getAfterTaxAmount());
            map.put("备注", salary.getRemarks());
            map.put("公示状态", publicityStatus);
            map.put("承认状态", approveStatus);
            map.put("创建者", salary.getCreateBy());
            map.put("创建时间", salary.getCreateTime());
            map.put("更新者", salary.getUpdateBy());
@@ -197,4 +242,43 @@
        // 查询某月工作天数
        return DateUtil.getWorkDayOfMonth(sysConfigHolidayList, targetYearMonth);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteByUserIdAndSalaryYearMonthAndCreateNew(Salary resources) {
        // 根据用户ID和工资年月删除
        salaryRepository.deleteByUserIdAndSalaryYearMonth(resources.getUserId(), resources.getSalaryYearMonth().toString().substring(0,7));
        // 保存
        salaryRepository.save(resources);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void publicity(Long[] ids) {
        // 循环ID列表
        for (Long id : ids) {
            // 查询工资
            Salary salary = salaryRepository.findById(id).orElseGet(Salary::new);
            ValidationUtil.isNull( salary.getId(),"Salary","id",id);
            // 公示状态
            salary.setPublicityStatus(Constant.PUBLICITY_STATUS_YES);
            // 保存
            salaryRepository.save(salary);
        }
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void approve(Long[] ids) {
        // 循环ID列表
        for (Long id : ids) {
            // 查询工资
            Salary salary = salaryRepository.findById(id).orElseGet(Salary::new);
            ValidationUtil.isNull( salary.getId(),"Salary","id",id);
            // 承认状态
            salary.setApproveStatus(Constant.APPROVE_STATUS_ACKNOWLEDGED);
            // 保存
            salaryRepository.save(salary);
        }
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysConfigIndividualIncomeTax.java
@@ -44,12 +44,17 @@
    @ApiModelProperty(value = "ID")
    private Long id;
    @Column(name = "`gear_amount`",nullable = false)
    @Column(name = "`gear_amount_start`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "档位金额")
    private BigDecimal gearAmount;
    @ApiModelProperty(value = "档位起始金额")
    private BigDecimal gearAmountStart;
    @Column(name = "`tax_rate`")
    @Column(name = "`gear_amount_end`")
    @ApiModelProperty(value = "档位截止金额")
    private BigDecimal gearAmountEnd;
    @Column(name = "`tax_rate`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "税率")
    private Double taxRate;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysConfigIndividualIncomeTaxRepository.java
@@ -21,6 +21,8 @@
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.math.BigDecimal;
/**
* @website https://eladmin.vip
* @author wcd
@@ -28,7 +30,7 @@
**/
public interface SysConfigIndividualIncomeTaxRepository extends JpaRepository<SysConfigIndividualIncomeTax, Long>, JpaSpecificationExecutor<SysConfigIndividualIncomeTax> {
    /** 根据金额查询个人所得税表 */
    @Query(value = "SELECT * FROM `sys_config_individual_income_tax` WHERE gear_amount = ?", nativeQuery = true)
    SysConfigIndividualIncomeTax findByGearAmount(String gearAmount);
    /** 根据档位起始金额或档位截止金额查询个人所得税表 */
    @Query(value = "SELECT * FROM `sys_config_individual_income_tax` WHERE gear_amount_start = ?1 OR gear_amount_end = ?1", nativeQuery = true)
    SysConfigIndividualIncomeTax findByGearAmountStartOrGearAmountEnd(BigDecimal gearAmount);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelInsuranceRepository.java
@@ -42,7 +42,7 @@
     * @param userId /
     * @return /
     */
    @Query(value = "SELECT * FROM sys_user_level_insurance WHERE user_id = ?1", nativeQuery = true)
    @Query(value = "SELECT * FROM sys_user_level_insurance WHERE user_id = ?1 ORDER BY start_date", nativeQuery = true)
    List<SysUserLevelInsurance> findByUserId(Long userId);
    /**
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelWageRepository.java
@@ -51,7 +51,7 @@
     * @param userId /
     * @return /
     */
    @Query(value = "SELECT * FROM sys_user_level_wage WHERE user_id = ?1", nativeQuery = true)
    @Query(value = "SELECT * FROM sys_user_level_wage WHERE user_id = ?1 ORDER BY start_date", nativeQuery = true)
    List<SysUserLevelWage> findByUserId(Long userId);
    /**
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysConfigIndividualIncomeTaxDto.java
@@ -34,8 +34,11 @@
    /** ID */
    private Long id;
    /** 档位金额 */
    private BigDecimal gearAmount;
    /** 档位起始金额 */
    private BigDecimal gearAmountStart;
    /** 档位截止金额 */
    private BigDecimal gearAmountEnd;
    /** 税率 */
    private Double taxRate;
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysConfigIndividualIncomeTaxQueryCriteria.java
@@ -31,5 +31,9 @@
    /** 精确 */
    @Query
    private BigDecimal gearAmount;
    private BigDecimal gearAmountStart;
    /** 精确 */
    @Query
    private BigDecimal gearAmountEnd;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysConfigIndividualIncomeTaxServiceImpl.java
@@ -94,16 +94,28 @@
     * 重名验证
     */
    public void getInfo(SysConfigIndividualIncomeTax resources,SysConfigIndividualIncomeTax sysConfigIndividualIncomeTax){
        // 根据金额查询
        SysConfigIndividualIncomeTax configIndividualIncomeTax = sysConfigIndividualIncomeTaxRepository.findByGearAmount(resources.getGearAmount().toString());
        //id不是空就是添加,否则就是修改验证
        // 根据档位起始金额或档位截止金额查询
        SysConfigIndividualIncomeTax configIndividualIncomeTaxStart = sysConfigIndividualIncomeTaxRepository.findByGearAmountStartOrGearAmountEnd(resources.getGearAmountStart());
        // id不是空就是添加,否则就是修改验证
        if(ObjectUtils.isNotEmpty(resources.getId())){
            if(configIndividualIncomeTax != null && configIndividualIncomeTax.getId() != sysConfigIndividualIncomeTax.getId()){
                throw new BadRequestException("档位金额已存在");
            if(configIndividualIncomeTaxStart != null && configIndividualIncomeTaxStart.getId() != sysConfigIndividualIncomeTax.getId()){
                throw new BadRequestException("档位起始金额已存在");
            }
        }else{
            if(configIndividualIncomeTax != null){
                throw new BadRequestException("档位金额已存在");
            if(configIndividualIncomeTaxStart != null){
                throw new BadRequestException("档位起始金额已存在");
            }
        }
        // 根据档位起始金额或档位截止金额查询
        SysConfigIndividualIncomeTax configIndividualIncomeTaxEnd = sysConfigIndividualIncomeTaxRepository.findByGearAmountStartOrGearAmountEnd(resources.getGearAmountEnd());
        // id不是空就是添加,否则就是修改验证
        if(ObjectUtils.isNotEmpty(resources.getId())){
            if(configIndividualIncomeTaxEnd != null && configIndividualIncomeTaxEnd.getId() != sysConfigIndividualIncomeTax.getId()){
                throw new BadRequestException("档位截止金额已存在");
            }
        }else{
            if(configIndividualIncomeTaxEnd != null){
                throw new BadRequestException("档位截止金额已存在");
            }
        }
    }
@@ -120,7 +132,8 @@
        List<Map<String, Object>> list = new ArrayList<>();
        for (SysConfigIndividualIncomeTaxDto sysConfigIndividualIncomeTax : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("档位金额", sysConfigIndividualIncomeTax.getGearAmount());
            map.put("档位起始金额", sysConfigIndividualIncomeTax.getGearAmountStart());
            map.put("档位截止金额", sysConfigIndividualIncomeTax.getGearAmountEnd());
            map.put("税率", sysConfigIndividualIncomeTax.getTaxRate());
            map.put("备注", sysConfigIndividualIncomeTax.getRemarks());
            map.put("创建者", sysConfigIndividualIncomeTax.getCreateBy());
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskDaliyServiceImpl.java
@@ -268,6 +268,10 @@
                    }
                    // 已完成工时
                    completedWork += taskUserDay.getTaskHours() * (taskDaliyDayProgress / 100);
                    // 本日任务日报
                    taskDaliyDay.setSettlementStatus(Constant.SETTLEMENT_STATUS_SETTLED);
                    // 保存本日任务日报
                    taskDaliyRepository.save(taskDaliyDay);
                }
            }
        }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/utils/DateUtil.java
@@ -2,9 +2,7 @@
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.system.domain.SysConfigHoliday;
import me.zhengjie.modules.system.service.dto.SysConfigHolidayQueryCriteria;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -110,7 +108,7 @@
                    // 判断循环是否结束
                    if (j == holidayList.size() - 1) {
                        // 判断本日是否不为周末
                        if (week != 1 && week != 7) {
                        if (week != Calendar.SUNDAY && week != Calendar.SATURDAY) {
                            // 工作天数
                            workDays ++;
                        }
@@ -118,7 +116,7 @@
                }
            } else {
                // 判断本日是否不为周末
                if (week != 1 && week != 7) {
                if (week != Calendar.SUNDAY && week != Calendar.SATURDAY) {
                    // 工作天数
                    workDays ++;
                }
@@ -127,4 +125,56 @@
        // 工作天数
        return workDays;
    }
    /**
     * 设置日初时间
     * @param dayCal
     * @return
     */
    public static Calendar setDayStartTime(Calendar dayCal) {
        // 日历类
        Calendar cal = Calendar.getInstance();
        // 设置年份
        cal.set(Calendar.YEAR, dayCal.get(Calendar.YEAR));
        // 设置月份
        cal.set(Calendar.MONTH, dayCal.get(Calendar.MONTH));
        // 设置天数
        cal.set(Calendar.DAY_OF_MONTH, dayCal.get(Calendar.DAY_OF_MONTH));
        // 设置时数
        cal.set(Calendar.HOUR_OF_DAY, 0);
        // 设置分数
        cal.set(Calendar.MINUTE, 0);
        // 设置秒数
        cal.set(Calendar.SECOND, 0);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 0);
        // 日历类
        return cal;
    }
    /**
     * 设置日末时间
     * @param dayCal
     * @return
     */
    public static Calendar setDayEndTime(Calendar dayCal) {
        // 日历类
        Calendar cal = Calendar.getInstance();
        // 设置年份
        cal.set(Calendar.YEAR, dayCal.get(Calendar.YEAR));
        // 设置月份
        cal.set(Calendar.MONTH, dayCal.get(Calendar.MONTH));
        // 设置天数
        cal.set(Calendar.DAY_OF_MONTH, dayCal.get(Calendar.DAY_OF_MONTH));
        // 设置时数
        cal.set(Calendar.HOUR_OF_DAY, 23);
        // 设置分数
        cal.set(Calendar.MINUTE, 59);
        // 设置秒数
        cal.set(Calendar.SECOND, 59);
        // 设置毫秒数
        cal.set(Calendar.MILLISECOND, 999);
        // 日历类
        return cal;
    }
}
eladmin-web-master/src/api/salary/salary.js
@@ -40,4 +40,20 @@
  })
}
export default { getAll, add, edit, del, workDays }
export function publicity(ids) {
  return request({
    url: 'api/salary/publicity/',
    method: 'put',
    data: ids
  })
}
export function approve(ids) {
  return request({
    url: 'api/salary/approve/',
    method: 'put',
    data: ids
  })
}
export default { getAll, add, edit, del, workDays, publicity, approve }
eladmin-web-master/src/components/Crud/crud.js
@@ -531,6 +531,20 @@
      })
    },
    /**
     * 年月格式化
     * @param {Object} timestamp 时间戳
     */
    toMonth(timestamp) {
      if (timestamp == null) {
        return
      } else {
        const system = new Date(timestamp)
        const year = system.getFullYear()
        const month = system.getMonth() + 1 < 10 ? '0' + (system.getMonth() + 1) : system.getMonth() + 1
        return year + '-' + month
      }
    },
    /**
     * 日期格式化
     * @param {Object} timestamp 时间戳
     */
eladmin-web-master/src/utils/constant.js
@@ -253,6 +253,13 @@
// 出差审批状态:已退回
export const BUSSINESS_APPROVE_STATUS_REFUSE = 'business_approve_status_refuse'
// 公示状态
export const PUBLICITY_STATUS = 'publicity_status'
// 公示状态:未公示
export const PUBLICITY_STATUS_NOT = 'publicity_status_not'
// 公示状态:已公示
export const PUBLICITY_STATUS_YES = 'publicity_status_yes'
export default {
  ROLE_LEVEL_SUPER,
  ROLE_LEVEL_GENERAL,
@@ -369,5 +376,8 @@
  BUSSINESS_APPROVE_STATUS,
  BUSSINESS_APPROVE_STATUS_REVIEWED,
  BUSSINESS_APPROVE_STATUS_AGREE,
  BUSSINESS_APPROVE_STATUS_REFUSE
  BUSSINESS_APPROVE_STATUS_REFUSE,
  PUBLICITY_STATUS,
  PUBLICITY_STATUS_NOT,
  PUBLICITY_STATUS_YES
}
eladmin-web-master/src/views/project/projectCost/index.vue
@@ -38,7 +38,7 @@
            </el-select>
          </el-form-item>
          <el-form-item label="用户" prop="userId">
            <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" @change="getProjectCost">
            <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" @change="timeChange">
              <el-option
                v-for="item in userList"
                :key="item.id"
@@ -48,13 +48,14 @@
            </el-select>
          </el-form-item>
          <el-form-item label="进入项目时间" prop="enterProjectTime">
            <el-date-picker v-model="form.enterProjectTime" type="datetime" style="width: 340px;" @change="timeChange" />
            <el-date-picker v-model="form.enterProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" />
          </el-form-item>
          <el-form-item label="退出项目时间" prop="exitProjectTime">
            <el-date-picker v-model="form.exitProjectTime" type="datetime" style="width: 340px;" @change="timeChange" />
            <el-date-picker v-model="form.exitProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" />
          </el-form-item>
          <el-form-item label="项目成本" prop="projectCost">
            <el-input v-model="form.projectCost" style="width: 340px;" />
            <!-- <el-input v-model="form.projectCost" style="width: 340px;" /> -->
            <money-input :key="random" v-model="form.projectCost" :width="340" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" />
@@ -80,7 +81,11 @@
        </el-table-column>
        <el-table-column prop="enterProjectTime" label="进入项目时间" />
        <el-table-column prop="exitProjectTime" label="退出项目时间" />
        <el-table-column prop="projectCost" label="项目成本" />
        <el-table-column prop="projectCost" label="项目成本">
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.projectCost) }}
          </template>
        </el-table-column>
        <el-table-column prop="remarks" label="备注" />
        <el-table-column v-if="checkPer(['admin','projectCost:edit','projectCost:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
@@ -106,11 +111,12 @@
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import moneyInput from '../../assembly/moneyInput/index.vue'
const defaultForm = { id: null, projectId: null, userId: null, enterProjectTime: null, exitProjectTime: null, projectCost: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'ProjectCost',
  components: { pagination, crudOperation, rrOperation, udOperation },
  components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '项目成本', url: 'api/projectCost', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectCost }})
@@ -125,10 +131,10 @@
      },
      rules: {
        projectId: [
          { required: true, message: '项目ID不能为空', trigger: 'blur' }
          { required: true, message: '项目不能为空', trigger: 'blur' }
        ],
        userId: [
          { required: true, message: '用户ID不能为空', trigger: 'blur' }
          { required: true, message: '用户不能为空', trigger: 'blur' }
        ],
        enterProjectTime: [
          { required: true, message: '进入项目时间不能为空', trigger: 'blur' }
@@ -141,15 +147,29 @@
        ]
      },
      queryTypeOptions: [
        { key: 'projectId', display_name: '项目ID' },
        { key: 'userId', display_name: '用户ID' },
        { key: 'projectId', display_name: '项目' },
        { key: 'userId', display_name: '用户' },
        { key: 'enterProjectTime', display_name: '进入项目时间' },
        { key: 'exitProjectTime', display_name: '退出项目时间' }
      ],
      // 用户列表
      userList: [],
      // 项目列表
      projectList: []
      projectList: [],
      // 随机数
      random: 0,
      pickerOptionsStart: {
        disabledDate: (time) => {
          if (this.form.exitProjectTime) {
            return time.getTime() > this.form.exitProjectTime
          }
        }
      },
      pickerOptionsEnd: {
        disabledDate: (time) => {
          return time.getTime() < this.form.enterProjectTime
        }
      }
    }
  },
  methods: {
@@ -158,6 +178,11 @@
      this.getUserList()
      this.getProjectList()
      return true
    },
    // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
      // 随机数
      this.random = Math.random()
    },
    getUserList() {
      crudUser.getAll().then(res => {
@@ -170,23 +195,24 @@
      crudProject.getAll().then(res => {
        this.projectList = res
      })
    },
    timeChange() {
      if (this.form.enterProjectTime != null && this.form.exitProjectTime != null) {
        this.getProjectCost()
      }
    },
    getProjectCost() {
      if (this.form.userId != null) {
        crudProjectCost.getCost({
          userId: this.form.userId,
          enterProjectTime: this.form.enterProjectTime,
          exitProjectTime: this.form.exitProjectTime
        }).then(res => {
          this.form.projectCost = res.projectCost
          this.random = Math.random()
        })
      }
    }
    // timeChange(){
    //   if(this.form.enterProjectTime != null && this.form.exitProjectTime != null){
    //     this.getProjectCost()
    //   }
    // },
    // getProjectCost() {
    //   if (this.form.userId != null) {
    //     crudProjectCost.getCost({
    //       userId: this.form.userId,
    //       enterProjectTime: this.form.enterProjectTime,
    //       exitProjectTime: this.form.exitProjectTime,
    //       }).then(res => {
    //     })
    //   }
    // }
  }
}
</script>
eladmin-web-master/src/views/project/projectTask/index.vue
@@ -207,7 +207,7 @@
      pickerOptionsStart: {
        disabledDate: (time) => {
          if (this.form.planEndTime) {
            return time.getTime() > Date.now() || time.getTime() > this.form.planEndTime
            return time.getTime() > this.form.planEndTime
          }
        }
      },
eladmin-web-master/src/views/salary/salary/index.vue
@@ -12,16 +12,38 @@
            :value="item.id"
          />
        </el-select>
        <el-input v-model="query.salaryYearMonth" clearable placeholder="工资年月" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-date-picker v-model="query.salaryYearMonth" type="month" clearable placeholder="工资年月" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <crudOperation :permission="permission">
        <el-button
          slot="right"
          v-permission="permission.publicity"
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-share"
          :disabled="crud.selections.length === 0"
          style="margin-right: 6px;"
          @click="multiplePublicity(crud.selections)"
        >公示</el-button>
        <el-button
          slot="right"
          v-permission="permission.approve"
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-share"
          :disabled="crud.selections.length === 0"
          @click="multipleApprove(crud.selections)"
        >承认</el-button>
      </crudOperation>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="690px">
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="所属员工" prop="userId">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 523px;" @change="getUserLevel">
            <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 523px;" :disabled="disabledFlagByApprove" @change="getUserLevel">
              <el-option
                v-for="item in users"
                :key="item.id"
@@ -37,237 +59,238 @@
              type="month"
              style="width: 200px;"
              placeholder="请选择"
              :disabled="disabledFlagByApprove"
              @change="getUserLevel"
            />
          </el-form-item>
          <el-form-item label="级别工资" prop="levelWage">
            <money-input :key="random" v-model="form.levelWage" :width="200" />
            <money-input :key="random" v-model="form.levelWage" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>基本工资</el-divider>
          <el-form-item label="工资比例" prop="basicWageProportion">
            <el-input v-model="form.basicWageProportion" style="width: 200px;">
            <el-input v-model="form.basicWageProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="预计工资" prop="basicWage">
            <money-input :key="random" v-model="form.basicWage" :width="200" />
            <money-input :key="random" v-model="form.basicWage" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="全勤小时数" prop="fullDays">
            <el-input v-model="form.fullDays" style="width: 200px;">
            <el-input v-model="form.fullDays" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="缺勤小时数" prop="absenceDays">
            <el-input v-model="form.absenceDays" style="width: 200px;">
            <el-input v-model="form.absenceDays" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="实际工资" prop="actualBasicWage">
            <money-input :key="random" v-model="form.actualBasicWage" :width="523" />
            <money-input :key="random" v-model="form.actualBasicWage" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>绩效工资</el-divider>
          <el-form-item label="工资比例" prop="achievementsWageProportion">
            <el-input v-model="form.achievementsWageProportion" style="width: 200px;">
            <el-input v-model="form.achievementsWageProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="预计工资" prop="achievementsWage">
            <money-input :key="random" v-model="form.achievementsWage" :width="200" />
            <money-input :key="random" v-model="form.achievementsWage" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="应完成工时" prop="needCompletedAchievementsHours">
            <el-input v-model="form.needCompletedAchievementsHours" style="width: 200px;">
            <el-input v-model="form.needCompletedAchievementsHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="已完成工时" prop="alreadyCompletedAchievementsHours">
            <el-input v-model="form.alreadyCompletedAchievementsHours" style="width: 200px;">
            <el-input v-model="form.alreadyCompletedAchievementsHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="实际工资" prop="actualAchievementsWage">
            <money-input :key="random" v-model="form.actualAchievementsWage" :width="523" />
            <money-input :key="random" v-model="form.actualAchievementsWage" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>业绩工资</el-divider>
          <el-form-item label="工资比例" prop="performanceWageProportion">
            <el-input v-model="form.performanceWageProportion" style="width: 200px;">
            <el-input v-model="form.performanceWageProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="预计工资" prop="performanceWage">
            <money-input :key="random" v-model="form.performanceWage" :width="200" />
            <money-input :key="random" v-model="form.performanceWage" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人业绩比例" prop="personalPerformanceProportion">
            <el-input v-model="form.personalPerformanceProportion" style="width: 523px;">
            <el-input v-model="form.personalPerformanceProportion" style="width: 523px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="应完成工时" prop="needCompletedPerformanceHours">
            <el-input v-model="form.needCompletedPerformanceHours" style="width: 200px;">
            <el-input v-model="form.needCompletedPerformanceHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="已完成工时" prop="alreadyCompletedPerformanceHours">
            <el-input v-model="form.alreadyCompletedPerformanceHours" style="width: 200px;">
            <el-input v-model="form.alreadyCompletedPerformanceHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="实际工资" prop="actualPerformanceWage">
            <money-input :key="random" v-model="form.actualPerformanceWage" :width="523" />
            <money-input :key="random" v-model="form.actualPerformanceWage" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>团队工资</el-divider>
          <el-form-item label="工资比例" prop="teamWageProportion">
            <el-input v-model="form.teamWageProportion" style="width: 200px;">
            <el-input v-model="form.teamWageProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="预计工资" prop="teamWage">
            <money-input :key="random" v-model="form.teamWage" :width="200" />
            <money-input :key="random" v-model="form.teamWage" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="实达标工时" prop="actualComplianceTeamHours">
            <el-input v-model="form.actualComplianceTeamHours" style="width: 200px;">
            <el-input v-model="form.actualComplianceTeamHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="已完成工时" prop="alreadyCompletedTeamHours">
            <el-input v-model="form.alreadyCompletedTeamHours" style="width: 200px;">
            <el-input v-model="form.alreadyCompletedTeamHours" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">小时</template>
            </el-input>
          </el-form-item>
          <el-form-item label="实际工资" prop="actualTeamWage">
            <money-input :key="random" v-model="form.actualTeamWage" :width="523" />
            <money-input :key="random" v-model="form.actualTeamWage" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>公积金</el-divider>
          <el-form-item label="基数" prop="accumulationRadix">
            <money-input :key="random" v-model="form.accumulationRadix" :width="523" />
            <money-input :key="random" v-model="form.accumulationRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="accumulationPersonalProportion">
            <el-input v-model="form.accumulationPersonalProportion" style="width: 200px;">
            <el-input v-model="form.accumulationPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="accumulationPersonalAmount">
            <money-input :key="random" v-model="form.accumulationPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.accumulationPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="accumulationCompanyProportion">
            <el-input v-model="form.accumulationCompanyProportion" style="width: 200px;">
            <el-input v-model="form.accumulationCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="accumulationCompanyAmount">
            <money-input :key="random" v-model="form.accumulationCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.accumulationCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>养老险</el-divider>
          <el-form-item label="基数" prop="pensionRadix">
            <money-input :key="random" v-model="form.pensionRadix" :width="523" />
            <money-input :key="random" v-model="form.pensionRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="pensionPersonalProportion">
            <el-input v-model="form.pensionPersonalProportion" style="width: 200px;">
            <el-input v-model="form.pensionPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="pensionPersonalAmount">
            <money-input :key="random" v-model="form.pensionPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.pensionPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="pensionCompanyProportion">
            <el-input v-model="form.pensionCompanyProportion" style="width: 200px;">
            <el-input v-model="form.pensionCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="pensionCompanyAmount">
            <money-input :key="random" v-model="form.pensionCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.pensionCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>医疗险</el-divider>
          <el-form-item label="基数" prop="medicalRadix">
            <money-input :key="random" v-model="form.medicalRadix" :width="523" />
            <money-input :key="random" v-model="form.medicalRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="medicalPersonalProportion">
            <el-input v-model="form.medicalPersonalProportion" style="width: 200px;">
            <el-input v-model="form.medicalPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="medicalPersonalAmount">
            <money-input :key="random" v-model="form.medicalPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.medicalPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="medicalCompanyProportion">
            <el-input v-model="form.medicalCompanyProportion" style="width: 200px;">
            <el-input v-model="form.medicalCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="medicalCompanyAmount">
            <money-input :key="random" v-model="form.medicalCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.medicalCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>失业险</el-divider>
          <el-form-item label="基数" prop="unemploymentRadix">
            <money-input :key="random" v-model="form.unemploymentRadix" :width="523" />
            <money-input :key="random" v-model="form.unemploymentRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="unemploymentPersonalProportion">
            <el-input v-model="form.unemploymentPersonalProportion" style="width: 200px;">
            <el-input v-model="form.unemploymentPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="unemploymentPersonalAmount">
            <money-input :key="random" v-model="form.unemploymentPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.unemploymentPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="unemploymentCompanyProportion">
            <el-input v-model="form.unemploymentCompanyProportion" style="width: 200px;">
            <el-input v-model="form.unemploymentCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="unemploymentCompanyAmount">
            <money-input :key="random" v-model="form.unemploymentCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.unemploymentCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>生育险</el-divider>
          <el-form-item label="基数" prop="maternityRadix">
            <money-input :key="random" v-model="form.maternityRadix" :width="523" />
            <money-input :key="random" v-model="form.maternityRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="maternityPersonalProportion">
            <el-input v-model="form.maternityPersonalProportion" style="width: 200px;">
            <el-input v-model="form.maternityPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="maternityPersonalAmount">
            <money-input :key="random" v-model="form.maternityPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.maternityPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="maternityCompanyProportion">
            <el-input v-model="form.maternityCompanyProportion" style="width: 200px;">
            <el-input v-model="form.maternityCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="maternityCompanyAmount">
            <money-input :key="random" v-model="form.maternityCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.maternityCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>工伤险</el-divider>
          <el-form-item label="基数" prop="industrialInjuryRadix">
            <money-input :key="random" v-model="form.industrialInjuryRadix" :width="523" />
            <money-input :key="random" v-model="form.industrialInjuryRadix" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人缴纳比例" prop="industrialInjuryPersonalProportion">
            <el-input v-model="form.industrialInjuryPersonalProportion" style="width: 200px;">
            <el-input v-model="form.industrialInjuryPersonalProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="个人缴纳金额" prop="industrialInjuryPersonalAmount">
            <money-input :key="random" v-model="form.industrialInjuryPersonalAmount" :width="200" />
            <money-input :key="random" v-model="form.industrialInjuryPersonalAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="公司缴纳比例" prop="industrialInjuryCompanyProportion">
            <el-input v-model="form.industrialInjuryCompanyProportion" style="width: 200px;">
            <el-input v-model="form.industrialInjuryCompanyProportion" style="width: 200px;" :disabled="disabledFlagByApprove">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="公司缴纳金额" prop="industrialInjuryCompanyAmount">
            <money-input :key="random" v-model="form.industrialInjuryCompanyAmount" :width="200" />
            <money-input :key="random" v-model="form.industrialInjuryCompanyAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-divider>统计</el-divider>
          <el-form-item label="税前金额" prop="preTaxAmount">
            <money-input :key="random" v-model="form.preTaxAmount" :width="200" />
            <money-input :key="random" v-model="form.preTaxAmount" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="个人所得税" prop="individualIncomeTax">
            <money-input :key="random" v-model="form.individualIncomeTax" :width="200" />
            <money-input :key="random" v-model="form.individualIncomeTax" :width="200" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="税后金额" prop="afterTaxAmount">
            <money-input :key="random" v-model="form.afterTaxAmount" :width="523" />
            <money-input :key="random" v-model="form.afterTaxAmount" :width="523" :disabled="disabledFlagByApprove" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 523px;" />
            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 523px;" :disabled="disabledFlagByApprove" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -278,71 +301,346 @@
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="userId" label="员工ID" />
        <el-table-column prop="salaryYearMonth" label="工资年月" />
        <el-table-column prop="levelWage" label="级别工资" />
        <el-table-column prop="basicWageProportion" label="基本工资比例" />
        <el-table-column prop="basicWage" label="基本工资" />
        <el-table-column prop="fullDays" label="全勤小时数" />
        <el-table-column prop="absenceDays" label="缺勤小时数" />
        <el-table-column prop="actualBasicWage" label="实际基础工资" />
        <el-table-column prop="achievementsWageProportion" label="绩效工资比例" />
        <el-table-column prop="achievementsWage" label="绩效工资" />
        <el-table-column prop="needCompletedAchievementsHours" label="应完成绩效工时" />
        <el-table-column prop="alreadyCompletedAchievementsHours" label="已完成绩效工时" />
        <el-table-column prop="actualAchievementsWage" label="实际绩效工资" />
        <el-table-column prop="performanceWageProportion" label="业绩工资比例" />
        <el-table-column prop="performanceWage" label="业绩工资" />
        <el-table-column prop="personalPerformanceProportion" label="个人业绩比例" />
        <el-table-column prop="needCompletedPerformanceHours" label="应完成业绩工时" />
        <el-table-column prop="alreadyCompletedPerformanceHours" label="已完成业绩工时" />
        <el-table-column prop="actualPerformanceWage" label="实际业绩工资" />
        <el-table-column prop="teamWageProportion" label="团队工资比例" />
        <el-table-column prop="teamWage" label="团队工资" />
        <el-table-column prop="actualComplianceTeamHours" label="实达标团队工时" />
        <el-table-column prop="alreadyCompletedTeamHours" label="已完成团队工时" />
        <el-table-column prop="actualTeamWage" label="实际团队工资" />
        <el-table-column prop="accumulationRadix" label="公积金基数" />
        <el-table-column prop="accumulationPersonalProportion" label="公积金个人缴纳比例" />
        <el-table-column prop="accumulationPersonalAmount" label="公积金个人缴纳金额" />
        <el-table-column prop="accumulationCompanyProportion" label="公积金公司缴纳比例" />
        <el-table-column prop="accumulationCompanyAmount" label="公积金公司缴纳金额" />
        <el-table-column prop="pensionRadix" label="养老险基数" />
        <el-table-column prop="pensionPersonalProportion" label="养老险个人缴纳比例" />
        <el-table-column prop="pensionPersonalAmount" label="养老险个人缴纳金额" />
        <el-table-column prop="pensionCompanyProportion" label="养老险公司缴纳比例" />
        <el-table-column prop="pensionCompanyAmount" label="养老险公司缴纳金额" />
        <el-table-column prop="medicalRadix" label="医疗险基数" />
        <el-table-column prop="medicalPersonalProportion" label="医疗险个人缴纳比例" />
        <el-table-column prop="medicalPersonalAmount" label="医疗险个人缴纳金额" />
        <el-table-column prop="medicalCompanyProportion" label="医疗险公司缴纳比例" />
        <el-table-column prop="medicalCompanyAmount" label="医疗险公司缴纳金额" />
        <el-table-column prop="unemploymentRadix" label="失业险基数" />
        <el-table-column prop="unemploymentPersonalProportion" label="失业险个人缴纳比例" />
        <el-table-column prop="unemploymentPersonalAmount" label="失业险个人缴纳金额" />
        <el-table-column prop="unemploymentCompanyProportion" label="失业险公司缴纳比例" />
        <el-table-column prop="unemploymentCompanyAmount" label="失业险公司缴纳金额" />
        <el-table-column prop="maternityRadix" label="生育险基数" />
        <el-table-column prop="maternityPersonalProportion" label="生育险个人缴纳比例" />
        <el-table-column prop="maternityPersonalAmount" label="生育险个人缴纳金额" />
        <el-table-column prop="maternityCompanyProportion" label="生育险公司缴纳比例" />
        <el-table-column prop="maternityCompanyAmount" label="生育险公司缴纳金额" />
        <el-table-column prop="industrialInjuryRadix" label="工伤险基数" />
        <el-table-column prop="industrialInjuryPersonalProportion" label="工伤险个人缴纳比例" />
        <el-table-column prop="industrialInjuryPersonalAmount" label="工伤险个人缴纳金额" />
        <el-table-column prop="industrialInjuryCompanyProportion" label="工伤险公司缴纳比例" />
        <el-table-column prop="industrialInjuryCompanyAmount" label="工伤险公司缴纳金额" />
        <el-table-column prop="preTaxAmount" label="税前金额" />
        <el-table-column prop="individualIncomeTax" label="个人所得税" />
        <el-table-column prop="afterTaxAmount" label="税后金额" />
        <el-table-column prop="remarks" label="备注" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column v-if="checkPer(['admin','salary:edit','salary:del'])" label="操作" width="150px" align="center">
        <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" fixed="left" width="100">
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userNickName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="salaryYearMonth" label="工资年月" fixed="left" width="100">
          <template slot-scope="scope">
            {{ crud.toMonth(scope.row.salaryYearMonth) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="levelWage" label="级别工资" width="100">
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.levelWage) }}
          </template>
        </el-table-column>
        <el-table-column label="基础工资">
          <el-table-column :show-overflow-tooltip="true" prop="basicWageProportion" label="工资比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.basicWageProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="basicWage" label="预计工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.basicWage) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="fullDays" label="全勤小时数" width="100">
            <template slot-scope="scope">
              {{ scope.row.fullDays }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="absenceDays" label="缺勤小时数" width="100">
            <template slot-scope="scope">
              {{ scope.row.absenceDays }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="actualBasicWage" label="实际工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.actualBasicWage) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="绩效工资">
          <el-table-column :show-overflow-tooltip="true" prop="achievementsWageProportion" label="工资比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.achievementsWageProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="achievementsWage" label="预计工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.achievementsWage) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="needCompletedAchievementsHours" label="应完成工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.needCompletedAchievementsHours }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="alreadyCompletedAchievementsHours" label="已完成工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.alreadyCompletedAchievementsHours }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="actualAchievementsWage" label="实际工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.actualAchievementsWage) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="业绩工资">
          <el-table-column :show-overflow-tooltip="true" prop="performanceWageProportion" label="工资比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.performanceWageProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="performanceWage" label="预计工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.performanceWage) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="personalPerformanceProportion" label="个人业绩比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.personalPerformanceProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="needCompletedPerformanceHours" label="应完成工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.needCompletedPerformanceHours }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="alreadyCompletedPerformanceHours" label="已完成工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.alreadyCompletedPerformanceHours }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="actualPerformanceWage" label="实际工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.actualPerformanceWage) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="团队工资">
          <el-table-column :show-overflow-tooltip="true" prop="teamWageProportion" label="工资比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.teamWageProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="teamWage" label="预计工资" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.teamWage) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="actualComplianceTeamHours" label="实达标工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.actualComplianceTeamHours }}小时
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="alreadyCompletedTeamHours" label="已完成工时" width="100">
            <template slot-scope="scope">
              {{ scope.row.alreadyCompletedTeamHours }}小时
            </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>
        <el-table-column label="公积金">
          <el-table-column :show-overflow-tooltip="true" prop="accumulationRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.accumulationRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="accumulationPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.accumulationPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="accumulationPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.accumulationPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="accumulationCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.accumulationCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="accumulationCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.accumulationCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="养老险">
          <el-table-column :show-overflow-tooltip="true" prop="pensionRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.pensionRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="pensionPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.pensionPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="pensionPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.pensionPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="pensionCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.pensionCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="pensionCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.pensionCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="医疗险">
          <el-table-column :show-overflow-tooltip="true" prop="medicalRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.medicalRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="medicalPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.medicalPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="medicalPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.medicalPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="medicalCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.medicalCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="medicalCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.medicalCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="失业险">
          <el-table-column :show-overflow-tooltip="true" prop="unemploymentRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.unemploymentRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="unemploymentPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.unemploymentPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="unemploymentPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.unemploymentPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="unemploymentCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.unemploymentCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="unemploymentCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.unemploymentCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="生育险">
          <el-table-column :show-overflow-tooltip="true" prop="maternityRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.maternityRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="maternityPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.maternityPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="maternityPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.maternityPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="maternityCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.maternityCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="maternityCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.maternityCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="工伤险">
          <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryRadix" label="基数" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.industrialInjuryRadix) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryPersonalProportion" label="个人缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.industrialInjuryPersonalProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryPersonalAmount" label="个人缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.industrialInjuryPersonalAmount) }}
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryCompanyProportion" label="公司缴纳比例" width="100">
            <template slot-scope="scope">
              {{ scope.row.industrialInjuryCompanyProportion }}%
            </template>
          </el-table-column>
          <el-table-column :show-overflow-tooltip="true" prop="industrialInjuryCompanyAmount" label="公司缴纳金额" width="100">
            <template slot-scope="scope">
              {{ crud.toMoney(scope.row.industrialInjuryCompanyAmount) }}
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="preTaxAmount" label="税前金额" width="100">
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.preTaxAmount) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="individualIncomeTax" label="个人所得税" width="100">
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.individualIncomeTax) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="afterTaxAmount" label="税后金额" width="100">
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.afterTaxAmount) }}
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" />
        <el-table-column :show-overflow-tooltip="true" prop="publicityStatus" label="公示状态" width="80" fixed="right">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[publicityStatus][scope.row.publicityStatus] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :show-overflow-tooltip="true" prop="approveStatus" label="承认状态" width="80" fixed="right">
          <template slot-scope="scope">
            <el-tag>{{ dict.label[approveStatus][scope.row.approveStatus] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','salary:edit','salary:del','salary:publicity','salary:approve'])" label="操作" width="210px" align="center" fixed="right">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
            >
              <el-popover slot="left" :ref="`publicity_${scope.row.id}`" v-permission="permission.publicity" placement="top" width="180">
                <p>确定公示本条数据吗?</p>
                <div style="text-align: right; margin: 0">
                  <el-button size="mini" type="text" @click="publicityCancel(scope.row)">取消</el-button>
                  <el-button :loading="publicityLoading" type="primary" size="mini" @click="doPublicity(scope.row)">确定</el-button>
                </div>
                <el-button slot="reference" type="primary" icon="el-icon-share" size="mini" />
              </el-popover>
              <el-popover slot="left" :ref="`approve_${scope.row.id}`" v-permission="permission.approve" placement="top" width="180">
                <p>确定承认本条数据吗?</p>
                <div style="text-align: right; margin: 0">
                  <el-button size="mini" type="text" @click="approveCancel(scope.row)">取消</el-button>
                  <el-button :loading="approveLoading" type="primary" size="mini" @click="doApprove(scope.row)">确定</el-button>
                </div>
                <el-button slot="reference" type="primary" icon="el-icon-share" size="mini" style="margin-left: 3px;" />
              </el-popover>
            </udOperation>
          </template>
        </el-table-column>
      </el-table>
@@ -360,18 +658,21 @@
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import moneyInput from '../../assembly/moneyInput/index.vue'
import constant from '../../../utils/constant'
import crudUser from '@/api/system/user'
import crudUserLevelWage from '@/api/system/userLevelWage'
import crudUserLevelInsurance from '@/api/system/userLevelInsurance'
import crudUserLevelOther from '@/api/system/userLevelOther'
import crudAttendance from '@/api/attendance/attendance'
import crudTaskDaliy from '@/api/task/taskDaliy'
import crudSysConfigIndividualIncomeTax from '@/api/system/configIndividualIncomeTax'
const defaultForm = { id: null, userId: null, salaryYearMonth: null, levelWage: null, basicWageProportion: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWageProportion: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: null, actualAchievementsWage: null, performanceWageProportion: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWageProportion: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, accumulationRadix: null, accumulationPersonalProportion: null, accumulationPersonalAmount: null, accumulationCompanyProportion: null, accumulationCompanyAmount: null, pensionRadix: null, pensionPersonalProportion: null, pensionPersonalAmount: null, pensionCompanyProportion: null, pensionCompanyAmount: null, medicalRadix: null, medicalPersonalProportion: null, medicalPersonalAmount: null, medicalCompanyProportion: null, medicalCompanyAmount: null, unemploymentRadix: null, unemploymentPersonalProportion: null, unemploymentPersonalAmount: null, unemploymentCompanyProportion: null, unemploymentCompanyAmount: null, maternityRadix: null, maternityPersonalProportion: null, maternityPersonalAmount: null, maternityCompanyProportion: null, maternityCompanyAmount: null, industrialInjuryRadix: null, industrialInjuryPersonalProportion: null, industrialInjuryPersonalAmount: null, industrialInjuryCompanyProportion: null, industrialInjuryCompanyAmount: null, preTaxAmount: null, individualIncomeTax: null, afterTaxAmount: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, userId: null, salaryYearMonth: null, levelWage: null, basicWageProportion: null, basicWage: null, fullDays: null, absenceDays: null, actualBasicWage: null, achievementsWageProportion: null, achievementsWage: null, needCompletedAchievementsHours: null, alreadyCompletedAchievementsHours: null, actualAchievementsWage: null, performanceWageProportion: null, performanceWage: null, personalPerformanceProportion: null, needCompletedPerformanceHours: null, alreadyCompletedPerformanceHours: null, actualPerformanceWage: null, teamWageProportion: null, teamWage: null, actualComplianceTeamHours: null, alreadyCompletedTeamHours: null, actualTeamWage: null, accumulationRadix: null, accumulationPersonalProportion: null, accumulationPersonalAmount: null, accumulationCompanyProportion: null, accumulationCompanyAmount: null, pensionRadix: null, pensionPersonalProportion: null, pensionPersonalAmount: null, pensionCompanyProportion: null, pensionCompanyAmount: null, medicalRadix: null, medicalPersonalProportion: null, medicalPersonalAmount: null, medicalCompanyProportion: null, medicalCompanyAmount: null, unemploymentRadix: null, unemploymentPersonalProportion: null, unemploymentPersonalAmount: null, unemploymentCompanyProportion: null, unemploymentCompanyAmount: null, maternityRadix: null, maternityPersonalProportion: null, maternityPersonalAmount: null, maternityCompanyProportion: null, maternityCompanyAmount: null, industrialInjuryRadix: null, industrialInjuryPersonalProportion: null, industrialInjuryPersonalAmount: null, industrialInjuryCompanyProportion: null, industrialInjuryCompanyAmount: 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: 'Salary',
  components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: [constant.PUBLICITY_STATUS, constant.APPROVE_STATUS],
  cruds() {
    return CRUD({ title: '工资记录', url: 'api/salary', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSalary }})
  },
@@ -407,7 +708,9 @@
        add: ['admin', 'salary:add'],
        edit: ['admin', 'salary:edit'],
        del: ['admin', 'salary:del'],
        download: ['admin', 'salary:download']
        download: ['admin', 'salary:download'],
        publicity: ['admin', 'salary:publicity'],
        approve: ['admin', 'salary:approve']
      },
      rules: {
        userId: [
@@ -641,10 +944,20 @@
        { key: 'userId', display_name: '所属员工' },
        { key: 'salaryYearMonth', display_name: '工资年月' }
      ],
      // 字典:公示状态
      publicityStatus: constant.PUBLICITY_STATUS,
      // 字典:承认状态
      approveStatus: constant.APPROVE_STATUS,
      // 用户列表
      users: [],
      // 随机数
      random: 0
      random: 0,
      // 公示弹窗加载
      publicityLoading: false,
      // 承认弹窗加载
      approveLoading: false,
      // 表单禁用标记(承认状态)
      disabledFlagByApprove: false
    }
  },
  methods: {
@@ -664,6 +977,14 @@
    },
    // 钩子: 开始 "新建/编辑" - 之前
    [CRUD.HOOK.beforeToCU]() {
      // 判断表单承认状态
      if (this.form.approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) {
        // 表单禁用标记(承认状态)
        this.disabledFlagByApprove = true
      } else {
        // 表单禁用标记(承认状态)
        this.disabledFlagByApprove = false
      }
      // 随机数
      this.random = Math.random()
    },
@@ -692,23 +1013,44 @@
      // 获取用户级别工资
      crudUserLevelWage.getTargetYearMonth({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 级别工资
        this.form.levelWage = Number(res.levelWage)
        this.form.levelWage = Number(res.levelWage.toFixed(2))
        // 基本工资比例
        this.form.basicWageProportion = Number(res.basicWageProportion)
        this.form.basicWageProportion = Number(res.basicWageProportion.toFixed(2))
        // 预计基本工资
        this.form.basicWage = Number((res.levelWage * (res.basicWageProportion / 100)).toFixed(2))
        // 绩效工资比例
        this.form.achievementsWageProportion = Number(res.achievementsWageProportion)
        this.form.achievementsWageProportion = Number(res.achievementsWageProportion.toFixed(2))
        // 预计绩效工资
        this.form.achievementsWage = Number((res.levelWage * (res.achievementsWageProportion / 100)).toFixed(2))
        // 业绩工资比例
        this.form.performanceWageProportion = Number(res.performanceWageProportion)
        this.form.performanceWageProportion = Number(res.performanceWageProportion.toFixed(2))
        // 预计业绩工资
        this.form.performanceWage = Number((res.levelWage * (res.performanceWageProportion / 100)).toFixed(2))
        // 团队工资比例
        this.form.teamWageProportion = Number(res.teamWageProportion)
        this.form.teamWageProportion = Number(res.teamWageProportion.toFixed(2))
        // 预计团队工资
        this.form.teamWage = Number((res.levelWage * (res.teamWageProportion / 100)).toFixed(2))
        // 随机数
        this.random = Math.random()
      }).catch(() => {
        // 级别工资
        this.form.levelWage = 0
        // 基本工资比例
        this.form.basicWageProportion = 0
        // 预计基本工资
        this.form.basicWage = 0
        // 绩效工资比例
        this.form.achievementsWageProportion = 0
        // 预计绩效工资
        this.form.achievementsWage = 0
        // 业绩工资比例
        this.form.performanceWageProportion = 0
        // 预计业绩工资
        this.form.performanceWage = 0
        // 团队工资比例
        this.form.teamWageProportion = 0
        // 预计团队工资
        this.form.teamWage = 0
        // 随机数
        this.random = Math.random()
      })
@@ -718,65 +1060,128 @@
      // 获取用户级别保险
      crudUserLevelInsurance.getTargetYearMonth({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 公积金基数
        this.form.accumulationRadix = Number(res.accumulationRadix)
        this.form.accumulationRadix = Number(res.accumulationRadix.toFixed(2))
        // 公积金个人缴纳比例
        this.form.accumulationPersonalProportion = Number(res.accumulationPersonalProportion)
        this.form.accumulationPersonalProportion = Number(res.accumulationPersonalProportion.toFixed(2))
        // 公积金个人缴纳金额
        this.form.accumulationPersonalAmount = Number((res.accumulationRadix * (res.accumulationPersonalProportion / 100)).toFixed(2))
        // 公积金公司缴纳比例
        this.form.accumulationCompanyProportion = Number(res.accumulationCompanyProportion)
        this.form.accumulationCompanyProportion = Number(res.accumulationCompanyProportion.toFixed(2))
        // 公积金公司缴纳金额
        this.form.accumulationCompanyAmount = Number((res.accumulationRadix * (res.accumulationCompanyProportion / 100)).toFixed(2))
        // 养老险基数
        this.form.pensionRadix = Number(res.pensionRadix)
        this.form.pensionRadix = Number(res.pensionRadix.toFixed(2))
        // 养老险个人缴纳比例
        this.form.pensionPersonalProportion = Number(res.pensionPersonalProportion)
        this.form.pensionPersonalProportion = Number(res.pensionPersonalProportion.toFixed(2))
        // 养老险个人缴纳金额
        this.form.pensionPersonalAmount = Number((res.pensionRadix * (res.pensionPersonalProportion / 100)).toFixed(2))
        // 养老险公司缴纳比例
        this.form.pensionCompanyProportion = Number(res.pensionCompanyProportion)
        this.form.pensionCompanyProportion = Number(res.pensionCompanyProportion.toFixed(2))
        // 养老险公司缴纳金额
        this.form.pensionCompanyAmount = Number((res.pensionRadix * (res.pensionCompanyProportion / 100)).toFixed(2))
        // 医疗险基数
        this.form.medicalRadix = Number(res.medicalRadix)
        this.form.medicalRadix = Number(res.medicalRadix.toFixed(2))
        // 医疗险个人缴纳比例
        this.form.medicalPersonalProportion = Number(res.medicalPersonalProportion)
        this.form.medicalPersonalProportion = Number(res.medicalPersonalProportion.toFixed(2))
        // 医疗险个人缴纳金额
        this.form.medicalPersonalAmount = Number((res.medicalRadix * (res.medicalPersonalProportion / 100)).toFixed(2))
        // 医疗险公司缴纳比例
        this.form.medicalCompanyProportion = Number(res.medicalCompanyProportion)
        this.form.medicalCompanyProportion = Number(res.medicalCompanyProportion.toFixed(2))
        // 医疗险公司缴纳金额
        this.form.medicalCompanyAmount = Number((res.medicalRadix * (res.medicalCompanyProportion / 100)).toFixed(2))
        // 失业险基数
        this.form.unemploymentRadix = Number(res.unemploymentRadix)
        this.form.unemploymentRadix = Number(res.unemploymentRadix.toFixed(2))
        // 失业险个人缴纳比例
        this.form.unemploymentPersonalProportion = Number(res.unemploymentPersonalProportion)
        this.form.unemploymentPersonalProportion = Number(res.unemploymentPersonalProportion.toFixed(2))
        // 失业险个人缴纳金额
        this.form.unemploymentPersonalAmount = Number((res.unemploymentRadix * (res.unemploymentPersonalProportion / 100)).toFixed(2))
        // 失业险公司缴纳比例
        this.form.unemploymentCompanyProportion = Number(res.unemploymentCompanyProportion)
        this.form.unemploymentCompanyProportion = Number(res.unemploymentCompanyProportion.toFixed(2))
        // 失业险公司缴纳金额
        this.form.unemploymentCompanyAmount = Number((res.unemploymentRadix * (res.unemploymentCompanyProportion / 100)).toFixed(2))
        // 生育险基数
        this.form.maternityRadix = Number(res.maternityRadix)
        this.form.maternityRadix = Number(res.maternityRadix.toFixed(2))
        // 生育险个人缴纳比例
        this.form.maternityPersonalProportion = Number(res.maternityPersonalProportion)
        this.form.maternityPersonalProportion = Number(res.maternityPersonalProportion.toFixed(2))
        // 生育险个人缴纳金额
        this.form.maternityPersonalAmount = Number((res.maternityRadix * (res.maternityPersonalProportion / 100)).toFixed(2))
        // 生育险公司缴纳比例
        this.form.maternityCompanyProportion = Number(res.maternityCompanyProportion)
        this.form.maternityCompanyProportion = Number(res.maternityCompanyProportion.toFixed(2))
        // 生育险公司缴纳金额
        this.form.maternityCompanyAmount = Number((res.maternityRadix * (res.maternityCompanyProportion / 100)).toFixed(2))
        // 工伤险基数
        this.form.industrialInjuryRadix = Number(res.industrialInjuryRadix)
        this.form.industrialInjuryRadix = Number(res.industrialInjuryRadix.toFixed(2))
        // 工伤险个人缴纳比例
        this.form.industrialInjuryPersonalProportion = Number(res.industrialInjuryPersonalProportion)
        this.form.industrialInjuryPersonalProportion = Number(res.industrialInjuryPersonalProportion.toFixed(2))
        // 工伤险个人缴纳金额
        this.form.industrialInjuryPersonalAmount = Number((res.industrialInjuryRadix * (res.industrialInjuryPersonalProportion / 100)).toFixed(2))
        // 工伤险公司缴纳比例
        this.form.industrialInjuryCompanyProportion = Number(res.industrialInjuryCompanyProportion)
        this.form.industrialInjuryCompanyProportion = Number(res.industrialInjuryCompanyProportion.toFixed(2))
        // 工伤险公司缴纳金额
        this.form.industrialInjuryCompanyAmount = Number((res.industrialInjuryRadix * (res.industrialInjuryCompanyProportion / 100)).toFixed(2))
        // 随机数
        this.random = Math.random()
      }).catch(() => {
        // 公积金基数
        this.form.accumulationRadix = 0
        // 公积金个人缴纳比例
        this.form.accumulationPersonalProportion = 0
        // 公积金个人缴纳金额
        this.form.accumulationPersonalAmount = 0
        // 公积金公司缴纳比例
        this.form.accumulationCompanyProportion = 0
        // 公积金公司缴纳金额
        this.form.accumulationCompanyAmount = 0
        // 养老险基数
        this.form.pensionRadix = 0
        // 养老险个人缴纳比例
        this.form.pensionPersonalProportion = 0
        // 养老险个人缴纳金额
        this.form.pensionPersonalAmount = 0
        // 养老险公司缴纳比例
        this.form.pensionCompanyProportion = 0
        // 养老险公司缴纳金额
        this.form.pensionCompanyAmount = 0
        // 医疗险基数
        this.form.medicalRadix = 0
        // 医疗险个人缴纳比例
        this.form.medicalPersonalProportion = 0
        // 医疗险个人缴纳金额
        this.form.medicalPersonalAmount = 0
        // 医疗险公司缴纳比例
        this.form.medicalCompanyProportion = 0
        // 医疗险公司缴纳金额
        this.form.medicalCompanyAmount = 0
        // 失业险基数
        this.form.unemploymentRadix = 0
        // 失业险个人缴纳比例
        this.form.unemploymentPersonalProportion = 0
        // 失业险个人缴纳金额
        this.form.unemploymentPersonalAmount = 0
        // 失业险公司缴纳比例
        this.form.unemploymentCompanyProportion = 0
        // 失业险公司缴纳金额
        this.form.unemploymentCompanyAmount = 0
        // 生育险基数
        this.form.maternityRadix = 0
        // 生育险个人缴纳比例
        this.form.maternityPersonalProportion = 0
        // 生育险个人缴纳金额
        this.form.maternityPersonalAmount = 0
        // 生育险公司缴纳比例
        this.form.maternityCompanyProportion = 0
        // 生育险公司缴纳金额
        this.form.maternityCompanyAmount = 0
        // 工伤险基数
        this.form.industrialInjuryRadix = 0
        // 工伤险个人缴纳比例
        this.form.industrialInjuryPersonalProportion = 0
        // 工伤险个人缴纳金额
        this.form.industrialInjuryPersonalAmount = 0
        // 工伤险公司缴纳比例
        this.form.industrialInjuryCompanyProportion = 0
        // 工伤险公司缴纳金额
        this.form.industrialInjuryCompanyAmount = 0
        // 随机数
        this.random = Math.random()
      })
@@ -786,7 +1191,10 @@
      // 获取用户级别其他
      crudUserLevelOther.getTargetYearMonth({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 个人业绩比例
        this.form.personalPerformanceProportion = Number(res.personalPerformanceProportion)
        this.form.personalPerformanceProportion = Number(res.personalPerformanceProportion.toFixed(2))
      }).catch(() => {
        // 个人业绩比例
        this.form.personalPerformanceProportion = 0
      })
    },
    // 获取工作天数
@@ -794,26 +1202,53 @@
      // 获取工作天数
      crudSalary.workDays({ targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 全勤小时数
        this.form.fullDays = Number(res * 8)
        this.form.fullDays = Number((res * 8).toFixed(2))
        // 应完成绩效工时
        this.form.needCompletedAchievementsHours = Number(res * 8)
        this.form.needCompletedAchievementsHours = Number((res * 8).toFixed(2))
        // 定时器
        const interval = setInterval(() => {
          // 判断个人业绩比例是否为空
          if (this.form.personalPerformanceProportion != null && this.form.personalPerformanceProportion !== '') {
            // 应完成业绩工时
            this.form.needCompletedPerformanceHours = Number(res * 8 * (1 + Number(this.form.personalPerformanceProportion) / 100))
            this.form.needCompletedPerformanceHours = Number((res * 8 * (1 + this.form.personalPerformanceProportion / 100)).toFixed(2))
            // 清空定时器
            clearInterval(interval)
          }
        }, 500)
      }).catch(() => {
        // 全勤小时数
        this.form.fullDays = 0
        // 应完成绩效工时
        this.form.needCompletedAchievementsHours = 0
        // 应完成业绩工时
        this.form.needCompletedPerformanceHours = 0
      })
    },
    // 获取出勤小时数
    getAttendanceHours() {
      // 获取出勤小时数
      crudAttendance.attendanceHours({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // console.log(res)
        // 定时器
        const interval = setInterval(() => {
          // 判断预计基础工资、全勤小时数是否为空
          if (this.form.basicWage != null && this.form.basicWage !== '' && this.form.fullDays != null && this.form.fullDays !== '') {
            // 缺勤小时数
            this.form.absenceDays = Number((this.form.fullDays - res).toFixed(2))
            // 实际基础工资
            this.form.actualBasicWage = Number((this.form.basicWage - (this.form.basicWage / this.form.fullDays) * (this.form.fullDays - res)).toFixed(2))
            // 随机数
            this.random = Math.random()
            // 清空定时器
            clearInterval(interval)
          }
        }, 500)
      }).catch(() => {
        // 缺勤小时数
        this.form.absenceDays = 0
        // 实际基础工资
        this.form.actualBasicWage = 0
        // 随机数
        this.random = Math.random()
      })
    },
    // 获取达标工时
@@ -821,7 +1256,10 @@
      // 获取达标工时
      crudTaskDaliy.complianceWork({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 实达标团队工时
        this.form.actualComplianceTeamHours = Number(res)
        this.form.actualComplianceTeamHours = Number(res.toFixed(2))
      }).catch(() => {
        // 实达标团队工时
        this.form.actualComplianceTeamHours = 0
      })
    },
    // 获取已完成工时
@@ -829,11 +1267,11 @@
      // 获取已完成工时
      crudTaskDaliy.completedWork({ userId: this.form.userId, targetYearMonth: this.form.salaryYearMonth }).then(res => {
        // 已完成绩效工时
        this.form.alreadyCompletedAchievementsHours = Number(res)
        this.form.alreadyCompletedAchievementsHours = Number(res.toFixed(2))
        // 已完成业绩工时
        this.form.alreadyCompletedPerformanceHours = Number(res)
        this.form.alreadyCompletedPerformanceHours = Number(res.toFixed(2))
        // 已完成团队工时
        this.form.alreadyCompletedTeamHours = Number(res)
        this.form.alreadyCompletedTeamHours = Number(res.toFixed(2))
        // 绩效定时器
        const achievementsInterval = setInterval(() => {
          // 判断预计绩效工资、应完成绩效工时是否为空
@@ -851,7 +1289,7 @@
          // 判断预计业绩工资、应完成业绩工时是否为空
          if (this.form.performanceWage != null && this.form.performanceWage !== '' && this.form.needCompletedPerformanceHours != null && this.form.needCompletedPerformanceHours !== '') {
            // 实际业绩工资
            this.form.actualPerformanceWage = Number(res >= this.form.needCompletedPerformanceHours ? this.form.performanceWage : 0)
            this.form.actualPerformanceWage = Number((res >= this.form.needCompletedPerformanceHours ? this.form.performanceWage : 0).toFixed(2))
            // 随机数
            this.random = Math.random()
            // 清空业绩定时器
@@ -863,13 +1301,185 @@
          // 判断预计团队工资、实达标团队工时是否为空
          if (this.form.teamWage != null && this.form.teamWage !== '' && this.form.actualComplianceTeamHours != null && this.form.actualComplianceTeamHours !== '') {
            // 实际团队工资
            this.form.actualTeamWage = Number((this.form.teamWage * (this.form.actualComplianceTeamHours / res)).toFixed(2))
            this.form.actualTeamWage = Number(this.form.actualComplianceTeamHours !== 0 ? (this.form.teamWage * (this.form.actualComplianceTeamHours / res)).toFixed(2) : 0)
            // 随机数
            this.random = Math.random()
            // 清空团队定时器
            clearInterval(teamInterval)
          }
        }, 500)
        // 统计定时器
        const statisticsInterval = setInterval(() => {
          // 判断 实际基础工资、实际绩效工资、实际业绩工资、实际团队工资、公积金个人缴纳金额、
          // 养老险个人缴纳金额、医疗险个人缴纳金额、失业险个人缴纳金额、生育险个人缴纳金额、工伤险个人缴纳金额 是否为空
          if (
            this.form.actualBasicWage != null && this.form.actualBasicWage !== '' &&
            this.form.actualAchievementsWage != null && this.form.actualAchievementsWage !== '' &&
            this.form.actualPerformanceWage != null && this.form.actualPerformanceWage !== '' &&
            this.form.actualTeamWage != null && this.form.actualTeamWage !== '' &&
            this.form.accumulationPersonalAmount != null && this.form.accumulationPersonalAmount !== '' &&
            this.form.pensionPersonalAmount != null && this.form.pensionPersonalAmount !== '' &&
            this.form.medicalPersonalAmount != null && this.form.medicalPersonalAmount !== '' &&
            this.form.unemploymentPersonalAmount != null && this.form.unemploymentPersonalAmount !== '' &&
            this.form.maternityPersonalAmount != null && this.form.maternityPersonalAmount !== '' &&
            this.form.industrialInjuryPersonalAmount != null && this.form.industrialInjuryPersonalAmount !== ''
          ) {
            // 税前金额
            this.form.preTaxAmount = this.form.actualBasicWage + this.form.actualAchievementsWage + this.form.actualPerformanceWage + this.form.actualTeamWage
            // 查询个人所得税列表
            crudSysConfigIndividualIncomeTax.getAll().then(taxRes => {
              // 税额
              let taxAmount = 0
              // 计税金额
              const taxableAmount = this.form.preTaxAmount - this.form.accumulationPersonalAmount - this.form.pensionPersonalAmount - this.form.medicalPersonalAmount - this.form.unemploymentPersonalAmount - this.form.maternityPersonalAmount - this.form.industrialInjuryPersonalAmount
              // 循环个人所得税列表
              for (let i = 0; i < taxRes.length; i++) {
                // 判断计税金额所在个人所得税范围
                if (taxRes[i].gearAmountEnd != null && taxRes[i].gearAmountEnd !== '' && taxableAmount > taxRes[i].gearAmountEnd) {
                  // 税额
                  taxAmount += (taxRes[i].gearAmountEnd - taxRes[i].gearAmountStart) * (taxRes[i].taxRate / 100)
                } else if (taxableAmount >= taxRes[i].gearAmountStart && (taxRes[i].gearAmountEnd == null || taxRes[i].gearAmountEnd === '' || taxableAmount <= taxRes[i].gearAmountEnd)) {
                  // 税额
                  taxAmount += (taxableAmount - taxRes[i].gearAmountStart) * (taxRes[i].taxRate / 100)
                }
                // 判断循环是否结束
                if (i === taxRes.length - 1) {
                  // 个人所得税
                  this.form.individualIncomeTax = taxAmount
                  // 税后金额
                  this.form.afterTaxAmount = (taxableAmount - taxAmount) < 0 ? 0 : taxableAmount - taxAmount
                  // 随机数
                  this.random = Math.random()
                }
              }
            })
            // 清空统计定时器
            clearInterval(statisticsInterval)
          }
        }, 500)
      }).catch(() => {
        // 已完成绩效工时
        this.form.alreadyCompletedAchievementsHours = 0
        // 已完成业绩工时
        this.form.alreadyCompletedPerformanceHours = 0
        // 已完成团队工时
        this.form.alreadyCompletedTeamHours = 0
        // 实际绩效工资
        this.form.actualAchievementsWage = 0
        // 实际业绩工资
        this.form.actualPerformanceWage = 0
        // 实际团队工资
        this.form.actualTeamWage = 0
        // 税前金额
        this.form.preTaxAmount = 0
        // 个人所得税
        this.form.individualIncomeTax = 0
        // 税后金额
        this.form.afterTaxAmount = 0
        // 随机数
        this.random = Math.random()
      })
    },
    // 公示弹窗关闭
    publicityCancel(data) {
      // 公示弹窗隐藏
      this.$refs[`publicity_${data.id}`].showPopper = false
    },
    // 公示弹窗确认
    doPublicity(data) {
      // 公示弹窗加载
      this.publicityLoading = true
      // 公示工资
      crudSalary.publicity([data.id]).then(res => {
        // 搜索:刷新表格
        this.crud.toQuery()
        // 消息提示
        this.crud.notify('公示成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
        // 公示弹窗加载
        this.publicityLoading = false
        // 公示弹窗隐藏
        this.$refs[`publicity_${data.id}`].showPopper = false
      }).catch(() => {
        // 公示弹窗加载
        this.publicityLoading = false
      })
    },
    // 多工资公示
    multiplePublicity(data) {
      // 确认框
      this.$confirm('此操作将公示 ' + data.length + ' 条工资, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'success'
      }).then(() => {
        // ID列表
        const ids = []
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          ids.push(data[i].id)
          // 判断循环是否结束
          if (i === data.length - 1) {
            // 公示工资
            crudSalary.publicity(ids).then(res => {
              // 搜索:刷新表格
              this.crud.toQuery()
              // 消息提示
              this.crud.notify('公示成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
            })
          }
        }
      })
    },
    // 承认弹窗关闭
    approveCancel(data) {
      // 承认弹窗隐藏
      this.$refs[`approve_${data.id}`].showPopper = false
    },
    // 承认弹窗确认
    doApprove(data) {
      // 承认弹窗加载
      this.approveLoading = true
      // 承认工资
      crudSalary.approve([data.id]).then(res => {
        // 搜索:刷新表格
        this.crud.toQuery()
        // 消息提示
        this.crud.notify('承认成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
        // 承认弹窗加载
        this.approveLoading = false
        // 承认弹窗隐藏
        this.$refs[`approve_${data.id}`].showPopper = false
      }).catch(() => {
        // 承认弹窗加载
        this.approveLoading = false
      })
    },
    // 多工资承认
    multipleApprove(data) {
      // 确认框
      this.$confirm('此操作将承认 ' + data.length + ' 条工资, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'success'
      }).then(() => {
        // ID列表
        const ids = []
        // 循环数据
        for (let i = 0; i < data.length; i++) {
          // ID列表
          ids.push(data[i].id)
          // 判断循环是否结束
          if (i === data.length - 1) {
            // 承认工资
            crudSalary.approve(ids).then(res => {
              // 搜索:刷新表格
              this.crud.toQuery()
              // 消息提示
              this.crud.notify('承认成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
            })
          }
        }
      })
    }
  }
eladmin-web-master/src/views/system/configIndividualIncomeTax/index.vue
@@ -4,9 +4,17 @@
    <div class="head-container">
      <div>
        <el-input
          v-model="query.gearAmount"
          v-model="query.gearAmountStart"
          clearable
          placeholder="请输入档位金额"
          placeholder="请输入档位起始金额"
          style="width: 185px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-input
          v-model="query.gearAmountEnd"
          clearable
          placeholder="请输入截止金额"
          style="width: 185px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
@@ -17,17 +25,20 @@
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="档位金额" prop="gearAmount">
            <money-input :key="random" v-model="form.gearAmount" :width="370" />
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="档位起始金额" prop="gearAmountStart">
            <money-input :key="random" v-model="form.gearAmountStart" :width="340" />
          </el-form-item>
          <el-form-item label="档位截止金额" prop="gearAmountEnd">
            <money-input :key="random" v-model="form.gearAmountEnd" :width="340" />
          </el-form-item>
          <el-form-item label="税率" prop="taxRate">
            <el-input v-model="form.taxRate" style="width: 370px;">
            <el-input v-model="form.taxRate" style="width: 340px;">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
          <el-form-item label="备注" prop="remarks">
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" />
            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 340px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
@@ -38,9 +49,14 @@
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="gearAmount" label="档位金额(元)" show-overflow-tooltip>
        <el-table-column prop="gearAmountStart" label="档位起始金额(元)" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ crud.toMoney(scope.row.gearAmount) }}
            {{ crud.toMoney(scope.row.gearAmountStart) }}
          </template>
        </el-table-column>
        <el-table-column prop="gearAmountEnd" label="档位截止金额(元)" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.gearAmountEnd != null && scope.row.gearAmountEnd !== '' ? crud.toMoney(scope.row.gearAmountEnd) : '' }}
          </template>
        </el-table-column>
        <el-table-column prop="taxRate" label="税率" show-overflow-tooltip>
@@ -74,7 +90,7 @@
import pagination from '@crud/Pagination'
import moneyInput from '../../assembly/moneyInput/index.vue'
const defaultForm = { id: null, gearAmount: null, taxRate: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
const defaultForm = { id: null, gearAmountStart: null, gearAmountEnd: null, taxRate: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'ConfigIndividualIncomeTax',
  components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
@@ -83,42 +99,21 @@
    return CRUD({ title: '个人所得税', url: 'api/sysConfigIndividualIncomeTax', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysConfigIndividualIncomeTax }})
  },
  data() {
    var checkGearAmount = (rule, value, callback) => {
      if (value !== null && value !== '') {
        if (isNaN(Number(value))) {
          callback(new Error('档位金额必须是数字'))
        } else {
          if (value < 0) {
            callback(new Error('档位金额必须大于等于0'))
          } else if (value > 1000000000) {
            callback(new Error('档位金额必须小于等于1000000000'))
          } else if ((!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(value))) {
            callback(new Error('档位金额最多两位小数'))
          } else {
            callback()
          }
        }
    // 工资(千万内)验证
    var wageValidate = (rule, value, callback) => {
      if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) {
        callback(new Error('请输入 一千万 以内的正整数或两位小数'))
      } else {
        callback(new Error('档位金额不能为空'))
        callback()
      }
    }
    var checkTaxRate = (rule, value, callback) => {
      if (value !== null && value !== '') {
        if (isNaN(Number(value))) {
          callback(new Error('税率必须是数字'))
        } else {
          if (value < 0) {
            callback(new Error('税率必须大于等于0'))
          } else if (value > 100) {
            callback(new Error('税率必须小于等于100'))
          } else if ((!/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(value))) {
            callback(new Error('税率最多两位小数'))
          } else {
            callback()
          }
        }
    // 比例(百内)验证
    var proportionValidate = (rule, value, callback) => {
      const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/
      if (value != null && value !== '' && !reg.test(value)) {
        callback(new Error('请输入 一百 以内的正整数或两位小数'))
      } else {
        callback(new Error('税率不能为空'))
        callback()
      }
    }
    return {
@@ -129,11 +124,16 @@
        download: ['admin', 'sysConfigIndividualIncomeTax:download']
      },
      rules: {
        gearAmount: [
          { required: true, validator: checkGearAmount, trigger: 'blur' }
        gearAmountStart: [
          { required: true, message: '档位起始金额不能为空', trigger: 'blur' },
          { validator: wageValidate, trigger: 'blur' }
        ],
        gearAmountEnd: [
          { validator: wageValidate, trigger: 'blur' }
        ],
        taxRate: [
          { required: true, validator: checkTaxRate, trigger: 'blur' }
          { required: true, message: '税率不能为空', trigger: 'blur' },
          { validator: proportionValidate, trigger: 'blur' }
        ]
      },
      // 随机数