考勤定时计算薪资定时任务迁移

This commit is contained in:
weizhiqiang 2022-08-07 23:14:22 +08:00
parent bb9266e59f
commit b6acbd9d5d
17 changed files with 135 additions and 647 deletions

View file

@ -1,37 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.eve.entity.checkwork;
import com.skyeye.annotation.api.ApiModel;
import com.skyeye.annotation.api.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: CheckWorkMation
* @Description: 考勤打卡实体类
* @author: skyeye云系列--卫志强
* @date: 2022/3/26 21:30
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Data
@ApiModel("考勤打卡实体类")
public class CheckWorkMationRest implements Serializable {
@ApiModelProperty(value = "考勤id", required = "required")
private String id;
@ApiModelProperty(value = "状态", required = "required")
private String state;
@ApiModelProperty(value = "下班打卡状态", required = "required")
private String clockOutState;
@ApiModelProperty(value = "考勤工时", required = "required")
private String workHours;
}

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.eve.entity.wages;
import com.skyeye.annotation.api.ApiModel;
import com.skyeye.annotation.api.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @ClassName: WagesStaffWorkTimeMation
* @Description: 获取应出勤的班次以及小时的实体类
* @author: skyeye云系列--卫志强
* @date: 2022/7/17 18:21
* @Copyright: 2022 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Data
@ApiModel("获取应出勤的班次以及小时的实体类")
public class WagesStaffWorkTimeMation implements Serializable {
@ApiModelProperty(value = "员工对应的考勤班次")
private List<Map<String, Object>> staffWorkTime;
@ApiModelProperty(value = "指定年月格式为yyyy-MM", required = "required")
private String lastMonthDate;
}

View file

@ -1,34 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.eve.rest.checkwork;
import com.skyeye.common.client.ClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import java.util.Map;
/**
* @ClassName: CheckWorkLeaveService
* @Description:
* @author: skyeye云系列--卫志强
* @date: 2022/3/26 22:48
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@FeignClient(value = "${webroot.skyeye-flowable}", configuration = ClientConfiguration.class)
public interface CheckWorkLeaveService {
/**
* 修改加班电子流的结算状态
*
* @param params 入参
* @return
*/
@PostMapping("/queryCheckWorkLeaveByMation")
String queryCheckWorkLeaveByMation(Map<String, Object> params);
}

View file

@ -1,82 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.eve.rest.checkwork;
import com.skyeye.common.client.ClientConfiguration;
import com.skyeye.eve.entity.checkwork.CheckWorkMationRest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
/**
* @ClassName: CheckWorkService
* @Description: 考勤模块接口信息
* @author: skyeye云系列--卫志强
* @date: 2022/3/26 20:48
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@FeignClient(value = "${webroot.skyeye-flowable}", configuration = ClientConfiguration.class)
public interface CheckWorkService {
/**
* 获取所有昨天没有打卡的用户
*
* @param timeId 班次id
* @param yesterdayTime 日期信息,格式为yyyy-MM-dd
* @return 所有的考勤班次的信息以及工作日信息等
*/
@GetMapping("/queryNotCheckMember")
String queryNotCheckMember(@RequestParam("timeId") String timeId,
@RequestParam("yesterdayTime") String yesterdayTime);
/**
* 获取所有昨天没有打下班卡的用户
*
* @param timeId 班次id
* @param yesterdayTime 日期信息,格式为yyyy-MM-dd
* @return 所有的考勤班次的信息以及工作日信息等
*/
@GetMapping("/queryNotCheckEndWorkId")
String queryNotCheckEndWorkId(@RequestParam("timeId") String timeId,
@RequestParam("yesterdayTime") String yesterdayTime);
/**
* 填充下班卡信息
*
* @param checkWorkMation 入参信息
*/
@PostMapping("/editCheckWorkBySystem")
String editCheckWorkBySystem(CheckWorkMationRest checkWorkMation);
/**
* 获取所有待结算的加班数据
*/
@GetMapping("/queryCheckWorkOvertimeWaitSettlement")
String queryCheckWorkOvertimeWaitSettlement();
/**
* 修改加班电子流的结算状态
*
* @param params 入参
* @return
*/
@PutMapping("/updateOvertimeSettleState")
String updateOvertimeSettleState(Map<String, Object> params);
/**
* 新增打卡信息(用于新增旷工的考勤信息)
*
* @param jsonStr 打卡信息json字符串
* @return
*/
@PostMapping("/insertCheckWorkBySystem")
String insertCheckWorkBySystem(@RequestParam("jsonStr") String jsonStr);
}

View file

@ -29,21 +29,4 @@ public interface CheckWorkTimeService {
@GetMapping("/getAllCheckWorkTime")
String getAllCheckWorkTime(@RequestParam("pointMonthDate") String pointMonthDate);
/**
* 获取所有未删除的考勤班次
*
* @return 所有未删除的考勤班次
*/
@GetMapping("/queryAllStaffCheckWorkTime")
String queryAllStaffCheckWorkTime();
/**
* 获取指定考勤班次的工作日信息
*
* @param timeId 考勤班次id
* @return 指定考勤班次的工作日信息
*/
@GetMapping("/queryWeekDayByTimeId")
String queryWeekDayByTimeId(@RequestParam("timeId") String timeId);
}

View file

@ -4,6 +4,10 @@
package com.skyeye.eve.controller;
import com.skyeye.annotation.api.Api;
import com.skyeye.annotation.api.ApiImplicitParam;
import com.skyeye.annotation.api.ApiImplicitParams;
import com.skyeye.annotation.api.ApiOperation;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.eve.service.SysEveUserStaffCapitalService;
@ -20,11 +24,31 @@ import org.springframework.web.bind.annotation.RestController;
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@RestController
@Api(value = "未结算资金池相关接口", tags = "未结算资金池相关接口", modelName = "基础模块")
public class SysEveUserStaffCapitalController {
@Autowired
private SysEveUserStaffCapitalService sysEveUserStaffCapitalService;
/**
* 新增员工待结算资金池信息(用于定时任务)
*
* @param inputObject 入参以及用户信息等获取对象
* @param outputObject 出参以及提示信息的返回值对象
*/
@ApiOperation(id = "addMonthMoney2StaffCapital", value = "新增员工待结算资金池信息(用于定时任务)", method = "POST", allUse = "0")
@ApiImplicitParams({
@ApiImplicitParam(id = "staffId", name = "staffId", value = "员工id", required = "required"),
@ApiImplicitParam(id = "companyId", name = "companyId", value = "企业id", required = "required"),
@ApiImplicitParam(id = "departmentId", name = "departmentId", value = "部门id", required = "required"),
@ApiImplicitParam(id = "monthTime", name = "monthTime", value = "指定年月格式为yyyy-MM", required = "required"),
@ApiImplicitParam(id = "type", name = "type", value = "该资金来源类型", required = "required,num"),
@ApiImplicitParam(id = "money", name = "money", value = "金额", required = "required")})
@RequestMapping("/post/SysEveUserStaffCapitalController/addMonthMoney2StaffCapital")
public void addMonthMoney2StaffCapital(InputObject inputObject, OutputObject outputObject) {
sysEveUserStaffCapitalService.addMonthMoney2StaffCapital(inputObject, outputObject);
}
/**
* 根据月份以及部门查询未结算的额外资金
*

View file

@ -17,6 +17,8 @@ import com.skyeye.common.object.OutputObject;
*/
public interface SysEveUserStaffCapitalService {
void addMonthMoney2StaffCapital(InputObject inputObject, OutputObject outputObject);
/**
* 新增员工待结算资金池信息
*

View file

@ -34,6 +34,23 @@ public class SysEveUserStaffCapitalServiceImpl implements SysEveUserStaffCapital
@Autowired
private SysEveUserStaffCapitalDao sysEveUserStaffCapitalDao;
/**
* 新增员工待结算资金池信息(用于定时任务)
*
* @param inputObject 入参以及用户信息等获取对象
* @param outputObject 出参以及提示信息的返回值对象
*/
@Override
public void addMonthMoney2StaffCapital(InputObject inputObject, OutputObject outputObject) {
Map<String, Object> map = inputObject.getParams();
String staffId = map.get("staffId").toString();
String companyId = map.get("companyId").toString();
String departmentId = map.get("departmentId").toString();
String monthTime = map.get("monthTime").toString();
Integer type = Integer.parseInt(map.get("type").toString());
String money = map.get("money").toString();
this.addMonthMoney2StaffCapital(staffId, companyId, departmentId, monthTime, type, money);
}
/**
* 新增员工待结算资金池信息

View file

@ -4,14 +4,19 @@
package com.skyeye.eve.controller;
import com.skyeye.annotation.api.Api;
import com.skyeye.annotation.api.ApiImplicitParams;
import com.skyeye.annotation.api.ApiOperation;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.eve.entity.wages.WagesStaffWorkTimeMation;
import com.skyeye.eve.service.WagesStaffMationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(value = "员工薪资管理", tags = "员工薪资管理", modelName = "薪资模块")
public class WagesStaffMationController {
@Autowired
@ -72,4 +77,17 @@ public class WagesStaffMationController {
wagesStaffMationService.queryWagesStaffPaymentDetail(inputObject, outputObject);
}
/**
* 获取应出勤的班次以及小时
*
* @param inputObject 入参以及用户信息等获取对象
* @param outputObject 出参以及提示信息的返回值对象
*/
@ApiOperation(id = "setLastMonthBe", value = "获取应出勤的班次以及小时", method = "POST", allUse = "0")
@ApiImplicitParams(classBean = WagesStaffWorkTimeMation.class)
@RequestMapping("/post/WagesStaffMationController/setLastMonthBe")
public void setLastMonthBe(InputObject inputObject, OutputObject outputObject) {
wagesStaffMationService.setLastMonthBe(inputObject, outputObject);
}
}

View file

@ -22,13 +22,15 @@ public interface WagesStaffMationService {
void queryWagesStaffPaymentDetail(InputObject inputObject, OutputObject outputObject);
void setLastMonthBe(InputObject inputObject, OutputObject outputObject);
/**
* 设置应出勤的班次以及小时
*
* @param staffWorkTime 员工对应的考勤班次
* @param staffModelFieldMap 员工拥有的所有薪资要素字段以及对应的值
* @param lastMonthDate 指定年月格式为yyyy-MM
* @param staffWorkTime 员工对应的考勤班次
* @param lastMonthDate 指定年月格式为yyyy-MM
* @return 员工拥有的所有薪资要素字段以及对应的值
*/
void setLastMonthBe(List<Map<String, Object>> staffWorkTime, Map<String, String> staffModelFieldMap, String lastMonthDate);
Map<String, Object> setLastMonthBe(List<Map<String, Object>> staffWorkTime, String lastMonthDate);
}

View file

@ -6,13 +6,13 @@ package com.skyeye.eve.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.common.constans.WagesConstant;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.DataCommonUtil;
import com.skyeye.common.util.DateUtil;
import com.skyeye.eve.dao.WagesFieldTypeDao;
import com.skyeye.eve.service.WagesFieldTypeService;
import com.skyeye.wages.constant.WagesConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

View file

@ -7,6 +7,7 @@ package com.skyeye.eve.service.impl;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.common.constans.WagesConstant;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.DataCommonUtil;
@ -16,7 +17,6 @@ import com.skyeye.eve.dao.WagesModelApplicableObjectsDao;
import com.skyeye.eve.dao.WagesModelDao;
import com.skyeye.eve.dao.WagesModelFieldDao;
import com.skyeye.eve.service.WagesModelService;
import com.skyeye.wages.constant.WagesConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

View file

@ -7,6 +7,7 @@ package com.skyeye.eve.service.impl;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.common.constans.WagesConstant;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.CalculationUtil;
@ -14,19 +15,16 @@ import com.skyeye.common.util.DateUtil;
import com.skyeye.eve.dao.WagesModelDao;
import com.skyeye.eve.dao.WagesModelFieldDao;
import com.skyeye.eve.dao.WagesStaffMationDao;
import com.skyeye.eve.entity.wages.WagesStaffWorkTimeMation;
import com.skyeye.eve.service.IScheduleDayService;
import com.skyeye.eve.service.WagesStaffMationService;
import com.skyeye.wages.constant.WagesConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -57,13 +55,13 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService {
/**
* 计薪资字段状态
*/
public static enum STATE {
public enum State {
WAIT_DESIGN_WAGES(1, "待设定"),
TOO_DESIGN_WAGES(2, "已设定");
private int state;
private String name;
STATE(int state, String name) {
State(int state, String name) {
this.state = state;
this.name = name;
}
@ -146,7 +144,7 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService {
// 保存薪资要素字段信息
wagesStaffMationDao.saveStaffWagesModelFieldMation(wagesModelFieldMation);
// 保存员工月标准薪资信息以及设定状态
wagesStaffMationDao.editStaffDesignWagesByStaffId(staffId, STATE.TOO_DESIGN_WAGES.getState(), map.get("actMoney").toString());
wagesStaffMationDao.editStaffDesignWagesByStaffId(staffId, State.TOO_DESIGN_WAGES.getState(), map.get("actMoney").toString());
}
/**
@ -182,14 +180,28 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService {
}
/**
* 设置应出勤的班次以及小时
* 获取应出勤的班次以及小时
*
* @param staffWorkTime 员工对应的考勤班次
* @param staffModelFieldMap 员工拥有的所有薪资要素字段以及对应的值
* @param lastMonthDate 指定年月格式为yyyy-MM
* @param inputObject 入参以及用户信息等获取对象
* @param outputObject 出参以及提示信息的返回值对象
*/
@Override
public void setLastMonthBe(List<Map<String, Object>> staffWorkTime, Map<String, String> staffModelFieldMap, String lastMonthDate) {
public void setLastMonthBe(InputObject inputObject, OutputObject outputObject) {
WagesStaffWorkTimeMation wagesStaffWorkTimeMation = inputObject.getParams(WagesStaffWorkTimeMation.class);
Map<String, Object> staffModelFieldMap = this.setLastMonthBe(wagesStaffWorkTimeMation.getStaffWorkTime(),
wagesStaffWorkTimeMation.getLastMonthDate());
outputObject.setBean(staffModelFieldMap);
}
/**
* 设置应出勤的班次以及小时
*
* @param staffWorkTime 员工对应的考勤班次
* @param lastMonthDate 指定年月格式为yyyy-MM
* @return 员工拥有的所有薪资要素字段以及对应的值
*/
@Override
public Map<String, Object> setLastMonthBe(List<Map<String, Object>> staffWorkTime, String lastMonthDate) {
List<String> lastMonthDays = DateUtil.getMonthFullDay(Integer.parseInt(lastMonthDate.split("-")[0]), Integer.parseInt(lastMonthDate.split("-")[1]));
int lastMonthBeNum = 0;
String lastMonthBeHour = "0";
@ -224,8 +236,10 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService {
}
}
}
Map<String, Object> staffModelFieldMap = new HashMap<>();
staffModelFieldMap.put(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_NUM.getKey(), String.valueOf(lastMonthBeNum));
staffModelFieldMap.put(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey(), CalculationUtil.divide(lastMonthBeHour, "60", 2));
return staffModelFieldMap;
}
}

View file

@ -1,87 +0,0 @@
package com.skyeye.wages.constant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WagesConstant {
/**
* 系统默认的薪资字段
*/
public static enum DEFAULT_WAGES_FIELD_TYPE {
LAST_MONTH_BE_NUM("应出勤(班)", "Due attendance (shift)", "lastMonthBeNum", "上个月应出勤的班次数"),
LAST_MONTH_BE_HOUR("应出勤(小时)", "Due attendance (hours)", "lastMonthBeHour", "上个月应出勤的小时数"),
LAST_MONTH_REAL_NUM("实际出勤(班)", "Actual attendance (shift)", "lastMonthRealNum", "上个月实际出勤的班次数"),
LAST_MONTH_REAL_HOUR("实际出勤(小时)", "Actual attendance (hours)", "lastMonthRealHour", "上个月实际出勤的小时数"),
LAST_MONTH_BE_REAL_HOUR("应实际出勤(小时)", "Should actual attendance (hours)", "lastMonthBeRealHour", "上个月应该实际出勤的小时数"),
LAST_MONTH_LATE_NUM("迟到(次)", "Late (Times)", "lastMonthLateNum", "上个月迟到的次数"),
LAST_MONTH_EARLY_NUM("早退(次)", "Leave early (Times)", "lastMonthEarlyNum", "上个月早退的次数"),
LAST_MONTH_DUTY_NUM("缺勤(次)", "Absence (Times)", "lastMonthDutyNum", "上个月缺勤的次数"),
LAST_MONTH_HOLIDAY_HOUR("请假(小时)", "Leave (hours)", "lastMonthHolidayHour", "上个月请假的小时"),
ACCUMULATED_ANNUAL_LEAVE("累积年假(小时)", "Accumulated annual leave (hours)", "accumulatedAnnualLeave", "截至到目前为止累积的年假"),
MONTHLY_STANDARD_SALARY("月标准薪资", "Monthly standard salary", "monthlyStandardSalary", "员工的月标准薪资"),
MONTHLY_STANDARD_REAL_MONEY("实发薪资", "Actual salary", "monthlyStandardRealMoney", "员工上月实发薪资"),
MONTHLY_SOCIAL_SECURITY_FUND_INSURANCE("缴纳社保", "Social security payment", "monthlySocialSecurityFundInsurance", "员工上月缴纳社保"),
MONTHLY_SOCIAL_SECURITY_FUND_ACCUMULATION("缴纳公积金", "Payment of provident fund", "monthlySocialSecurityFundAccumulation", "员工上月缴纳公积金"),
LAST_MONTH_TAX_RATE_BY_PERSON("缴纳税额", "Tax payment", "lastMonthTaxRateByPerson", "员工上月缴纳的税额");
private String cnName;
private String enName;
private String key;
private String desc;
/**
* @param cnName
* @param key 薪资字段key
* @param desc 描述
*/
DEFAULT_WAGES_FIELD_TYPE(String cnName, String enName, String key, String desc) {
this.cnName = cnName;
this.enName = enName;
this.key = key;
this.desc = desc;
}
public static List<Map<String, Object>> getList() {
List<Map<String, Object>> beans = new ArrayList<>();
Map<String, Object> bean;
for (DEFAULT_WAGES_FIELD_TYPE q : DEFAULT_WAGES_FIELD_TYPE.values()) {
bean = new HashMap<>();
bean.put("nameCn", q.getCnName());
bean.put("nameEn", q.getEnName());
bean.put("key", q.getKey());
bean.put("desc", q.getDesc());
beans.add(bean);
}
return beans;
}
public static String getNameByKey(String key) {
for (DEFAULT_WAGES_FIELD_TYPE q : DEFAULT_WAGES_FIELD_TYPE.values()) {
if (key.equals(q.getKey())) {
return q.getCnName();
}
}
return "";
}
public String getCnName() {
return cnName;
}
public String getEnName() {
return enName;
}
public String getKey() {
return key;
}
public String getDesc() {
return desc;
}
}
}

View file

@ -1,161 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.sys.quartz;
import com.skyeye.common.client.ExecuteFeignClient;
import com.skyeye.common.util.CalculationUtil;
import com.skyeye.eve.dao.SysEveUserStaffDao;
import com.skyeye.eve.rest.checkwork.CheckWorkService;
import com.skyeye.eve.rest.checkwork.CheckWorkTimeService;
import com.skyeye.eve.service.SysEveUserStaffCapitalService;
import com.skyeye.eve.service.WagesStaffMationService;
import com.skyeye.wages.constant.WagesConstant;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName: CalcStaffWaitPayWages
* @Description: 定时统计员工待结算其他奖金的数据
* 1. 加班结算
* @author: skyeye云系列--卫志强
* @date: 2021/9/2 15:11
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Component
public class CalcStaffWaitPayWages {
private static Logger log = LoggerFactory.getLogger(CalcStaffWaitPayWages.class);
@Autowired
private CheckWorkService checkWorkService;
@Autowired
private CheckWorkTimeService checkWorkTimeService;
@Autowired
private SysEveUserStaffDao sysEveUserStaffDao;
@Autowired
private WagesStaffMationService wagesStaffMationService;
@Autowired
private SysEveUserStaffCapitalService sysEveUserStaffCapitalService;
/**
* 定时统计员工待结算其他奖金的数据 凌晨一点半执行
*/
@XxlJob("calcStaffWaitPayWages")
public void handler() {
log.info("定时统计员工待结算薪资的数据定时任务开始执行");
try {
calcWaitWages();
} catch (Exception e) {
log.warn("CalcStaffWaitPayWages error.", e);
}
log.info("定时统计员工待结算薪资的数据定时任务执行完成");
}
private void calcWaitWages() {
// 指定年月的考勤信息的缓存
Map<String, List<Map<String, Object>>> pointMonthCheckWorkTimeCache = new HashMap<>();
// 获取所有待结算的加班信息
List<Map<String, Object>> overTimeWaitSettlementList =
ExecuteFeignClient.get(() -> checkWorkService.queryCheckWorkOvertimeWaitSettlement()).getRows();
log.info("overTimeWaitSettlementList size is: {}", overTimeWaitSettlementList.size());
Map<String, List<Map<String, Object>>> overTimeWaitSettlementByStaffId = overTimeWaitSettlementList.stream()
.collect(Collectors.groupingBy(map -> map.get("staffId").toString() + map.get("overtimeMonth").toString()));
for (Map.Entry<String, List<Map<String, Object>>> entry : overTimeWaitSettlementByStaffId.entrySet()) {
List<Map<String, Object>> overTimeList = entry.getValue();
// 员工薪资
String actWages = overTimeList.get(0).get("actWages").toString();
String overtimeMonth = overTimeList.get(0).get("overtimeMonth").toString();
String staffId = overTimeList.get(0).get("staffId").toString();
String companyId = overTimeList.get(0).get("companyId").toString();
String departmentId = overTimeList.get(0).get("departmentId").toString();
String hourWages = getStaffHourWages(pointMonthCheckWorkTimeCache, actWages, overtimeMonth, staffId);
String resultMoney = getAllOverTimeMoneyThisMonth(overTimeList, hourWages);
sysEveUserStaffCapitalService.addMonthMoney2StaffCapital(staffId, companyId, departmentId, overtimeMonth, 1, resultMoney);
}
}
private String getAllOverTimeMoneyThisMonth(List<Map<String, Object>> overTimeList, String hourWages) {
String allOverTimeHourThisMonth = "0";
for (Map<String, Object> bean : overTimeList) {
// 加班工时
String overtimeHour = bean.get("overtimeHour").toString();
// 结算类型
int overtimeSettlementType = Integer.parseInt(bean.get("overtimeSettlementType").toString());
String money = "0";
if (overtimeSettlementType == 1) {
// 单倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "1");
} else if (overtimeSettlementType == 2) {
// 1.5倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "1.5");
} else if (overtimeSettlementType == 3) {
// 双倍薪资结算
money = CalculationUtil.multiply(2, overtimeHour, hourWages, "2");
}
allOverTimeHourThisMonth = CalculationUtil.add(allOverTimeHourThisMonth, money, 2);
// 修改加班电子流的结算状态为已计入统计
Map<String, Object> params = new HashMap<>();
params.put("overtimeSoltId", bean.get("id").toString());
params.put("settleState", 2);
ExecuteFeignClient.get(() -> checkWorkService.updateOvertimeSettleState(params));
}
return allOverTimeHourThisMonth;
}
/**
* 获取员工每小时的工资
*
* @param pointMonthCheckWorkTimeCache 指定年月的考勤信息的缓存
* @param actWages 员工信息
* @param overtimeMonth 加班年月格式为yyyy-MM
* @param staffId 员工id
* @return hourWages
*/
private String getStaffHourWages(Map<String, List<Map<String, Object>>> pointMonthCheckWorkTimeCache, String actWages,
String overtimeMonth, String staffId) {
// 考勤日期
List<Map<String, Object>> workTime = getPointMonthCheckWorkTime(pointMonthCheckWorkTimeCache, overtimeMonth);
// 1.获取该员工拥有的考勤班次id集合
List<Map<String, Object>> staffTimeIdMation = sysEveUserStaffDao
.queryStaffCheckWorkTimeRelationByStaffId(staffId);
List<String> userTimeIds = staffTimeIdMation.stream()
.map(p -> p.get("timeId").toString()).collect(Collectors.toList());
List<Map<String, Object>> staffWorkTime = workTime.stream()
.filter(bean -> userTimeIds.contains(bean.get("timeId").toString()))
.collect(Collectors.toList());
Map<String, String> staffModelFieldMap = new HashMap<>();
// 2.获取应出勤的班次以及小时
wagesStaffMationService.setLastMonthBe(staffWorkTime, staffModelFieldMap, overtimeMonth);
// 获取每小时的工资
String hourWages = CalculationUtil.divide(actWages,
staffModelFieldMap.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey()), 2);
return hourWages;
}
private List<Map<String, Object>> getPointMonthCheckWorkTime(Map<String, List<Map<String, Object>>> cache, String pointMonthDate) {
if (cache.containsKey(pointMonthDate)) {
return cache.get(pointMonthDate);
}
// 所有的考勤班次信息
List<Map<String, Object>> workTime =
ExecuteFeignClient.get(() -> checkWorkTimeService.getAllCheckWorkTime(pointMonthDate)).getRows();
cache.put(pointMonthDate, workTime);
return workTime;
}
}

View file

@ -1,208 +0,0 @@
/*******************************************************************************
* Copyright 卫志强 QQ598748873@qq.com Inc. All rights reserved. 开源地址https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.sys.quartz;
import cn.hutool.json.JSONUtil;
import com.skyeye.common.client.ExecuteFeignClient;
import com.skyeye.common.util.DateAfterSpacePointTime;
import com.skyeye.common.util.DateUtil;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.eve.entity.checkwork.CheckWorkMationRest;
import com.skyeye.eve.rest.checkwork.CheckWorkLeaveService;
import com.skyeye.eve.rest.checkwork.CheckWorkService;
import com.skyeye.eve.rest.checkwork.CheckWorkTimeService;
import com.skyeye.eve.service.IScheduleDayService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @ClassName: CheckWorkQuartz
* @Description: 定时器填充打卡信息, 每天凌晨一点执行一次
* @author: skyeye云系列--卫志强
* @date: 2021/4/25 21:15
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Component
public class CheckWorkQuartz {
private static Logger log = LoggerFactory.getLogger(CheckWorkQuartz.class);
@Autowired
private CheckWorkService checkWorkService;
@Autowired
private CheckWorkTimeService checkWorkTimeService;
@Autowired
private CheckWorkLeaveService checkWorkLeaveService;
@Autowired
private IScheduleDayService iScheduleDayService;
/**
* 定时器填充打卡信息,每天凌晨一点执行一次
*/
@XxlJob("checkWorkQuartz")
public void editCheckWorkMation() {
log.info("填充打卡信息定时任务执行");
try {
// 1.获取所有的考勤班次信息
List<Map<String, Object>> workTime = getAllCheckWorkTime();
// 得到昨天的时间
String yesterdayTime = DateAfterSpacePointTime.getSpecifiedTime(
DateAfterSpacePointTime.ONE_DAY.getType(), DateUtil.getTimeAndToString(), DateUtil.YYYY_MM_DD, DateAfterSpacePointTime.AroundType.BEFORE);
if (workTime != null && !workTime.isEmpty() && !iScheduleDayService.judgeISHoliday(yesterdayTime)) {
// 班次信息不为空并且昨天不是节假日
log.info("Fill in the clocking information for timing task execution time is {}", yesterdayTime);
// 判断昨天的日期是周几
int weekDay = DateUtil.getWeek(yesterdayTime);
// 判断昨天的日期是单周还是双周
int weekType = DateUtil.getWeekType(yesterdayTime);
// 2.获取昨天应该打卡的班次信息
List<Map<String, Object>> shouldCheckTime = getShouldCheckTime(weekDay, weekType, workTime);
if (!shouldCheckTime.isEmpty()) {
shouldCheckTime.forEach(bean -> {
try {
// 3.1 处理所有昨天只打早卡没有打晚卡的记录id
handleNotCheckWorkEndMember(yesterdayTime, bean.get("timeId").toString());
// 3.2 处理所有昨天没有打卡的用户
handleNotCheckWorkMember(yesterdayTime, bean.get("timeId").toString());
} catch (Exception e) {
log.info("Handling abnormal attendance information, message is {}.", e);
}
});
}
}
// 4 处理所有昨天加班只打早卡没有打晚卡的记录id
handleNotCheckWorkEndMember(yesterdayTime, "-");
} catch (Exception e) {
log.warn("CheckWorkQuartz error.", e);
}
log.info("填充打卡信息定时任务 end");
}
/**
* 获取昨天应该打卡的班次信息
*
* @param weekDay 周几
* @param weekType 1是双周0是单周
* @param workTime 考勤班次
* @return
*/
private List<Map<String, Object>> getShouldCheckTime(int weekDay, int weekType, List<Map<String, Object>> workTime) {
List<Map<String, Object>> shouldCheckTime = new ArrayList<>();
for (Map<String, Object> bean : workTime) {
// 该班次中上班的天数
List<Map<String, Object>> days = (List<Map<String, Object>>) bean.get("days");
List<Map<String, Object>> simpleDay = days.stream().filter(item -> Integer.parseInt(item.get("day").toString()) == weekDay).collect(Collectors.toList());
if (simpleDay != null && !simpleDay.isEmpty()) {
// 在该班次中找到了指定日期的上班时间
int datType = Integer.parseInt(simpleDay.get(0).get("type").toString());
if (weekType == 0 && datType == 2) {
// 单周
shouldCheckTime.add(bean);
} else {
shouldCheckTime.add(bean);
}
}
}
log.info("shouldCheckTime is {}", JSONUtil.toJsonStr(shouldCheckTime));
return shouldCheckTime;
}
/**
* 获取所有的考勤班次信息
*
* @return
*/
private List<Map<String, Object>> getAllCheckWorkTime() {
List<Map<String, Object>> workTime =
ExecuteFeignClient.get(() -> checkWorkTimeService.queryAllStaffCheckWorkTime()).getRows();
for (Map<String, Object> bean : workTime) {
List<Map<String, Object>> days =
ExecuteFeignClient.get(() -> checkWorkTimeService.queryWeekDayByTimeId(bean.get("timeId").toString())).getRows();
bean.put("days", days);
}
return workTime;
}
/**
* 处理所有昨天只打早卡没有打晚卡的记录id
*
* @param yesterdayTime
* @param timeId
*/
private void handleNotCheckWorkEndMember(String yesterdayTime, String timeId) {
List<Map<String, Object>> beans =
ExecuteFeignClient.get(() -> checkWorkService.queryNotCheckEndWorkId(timeId, yesterdayTime)).getRows();
if (!beans.isEmpty()) {
for (Map<String, Object> b : beans) {
CheckWorkMationRest checkWorkMation = new CheckWorkMationRest();
checkWorkMation.setId(b.get("id").toString());
checkWorkMation.setState("5");
checkWorkMation.setClockOutState("3");
checkWorkMation.setWorkHours("0:0:0");
// 填充打晚卡信息
ExecuteFeignClient.get(() -> checkWorkService.editCheckWorkBySystem(checkWorkMation));
}
}
}
/**
* 处理所有昨天没有打卡的用户
*
* @param yesterdayTime 昨天的日期,格式为yyyy-MM-dd
* @param timeId 班次id
*/
private void handleNotCheckWorkMember(String yesterdayTime, String timeId) {
// 获取所有昨天没有打卡的用户
List<Map<String, Object>> beans =
ExecuteFeignClient.get(() -> checkWorkService.queryNotCheckMember(timeId, yesterdayTime)).getRows();
if (!beans.isEmpty()) {
List<Map<String, Object>> listBeans = new ArrayList<>();
for (Map<String, Object> b : beans) {
String createId = b.get("createId").toString();
// 判断昨天是否有请假记录,如果有则不填充这条记录
Map<String, Object> params = new HashMap<>();
params.put("timeId", timeId);
params.put("createId", createId);
params.put("leaveDay", yesterdayTime);
Map<String, Object> leaveMation =
ExecuteFeignClient.get(() -> checkWorkLeaveService.queryCheckWorkLeaveByMation(params)).getBean();
if (leaveMation == null || leaveMation.isEmpty()) {
// 找不到该员工这个班次在这一天的请假记录则记为旷工
listBeans.add(getNoCheckWorkObject(timeId, createId, yesterdayTime));
}
}
if (!listBeans.isEmpty()) {
ExecuteFeignClient.get(() -> checkWorkService.insertCheckWorkBySystem(JSONUtil.toJsonStr(listBeans)));
}
}
}
private Map<String, Object> getNoCheckWorkObject(String timeId, String createId, String yesterdayTime) {
Map<String, Object> item = new HashMap<>();
item.put("id", ToolUtil.getSurFaceId());
item.put("createId", createId);
item.put("checkDate", yesterdayTime);
item.put("state", "2");
item.put("clockInState", "3");
item.put("clockOutState", "3");
item.put("timeId", timeId);
item.put("workHours", "0:0:0");
return item;
}
}

View file

@ -7,6 +7,7 @@ package com.skyeye.sys.quartz;
import cn.hutool.json.JSONUtil;
import com.skyeye.cache.local.LocalCacheMap;
import com.skyeye.common.client.ExecuteFeignClient;
import com.skyeye.common.constans.WagesConstant;
import com.skyeye.common.util.*;
import com.skyeye.eve.dao.*;
import com.skyeye.eve.rest.checkwork.CheckWorkTimeService;
@ -14,7 +15,6 @@ import com.skyeye.eve.service.SystemFoundationSettingsService;
import com.skyeye.eve.service.WagesModelService;
import com.skyeye.eve.service.WagesStaffMationService;
import com.skyeye.jedis.JedisClientService;
import com.skyeye.wages.constant.WagesConstant;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -467,7 +467,11 @@ public class StaffWagesQuartz {
// 2.获取上个月指定员工的所有考勤记录信息
List<Map<String, Object>> lastMonthCheckWork = wagesStaffMationDao.queryLastMonthCheckWork(staffId, lastMonthDate);
// 3.设置应出勤的班次以及小时
wagesStaffMationService.setLastMonthBe(staffWorkTime, staffModelFieldMap, lastMonthDate);
Map<String, Object> monthBe = wagesStaffMationService.setLastMonthBe(staffWorkTime, lastMonthDate);
staffModelFieldMap.put(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_NUM.getKey(),
monthBe.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_NUM.getKey()).toString());
staffModelFieldMap.put(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey(),
monthBe.get(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey()).toString());
// 上个月迟到的分钟集合
List<String> lateMinute = new ArrayList<>();
// 上个月早退的分钟集合