|
@@ -95,7 +95,7 @@ public class KYServiceImpl implements KYService {
|
|
//查询接口body添加参数
|
|
//查询接口body添加参数
|
|
//field_filter_list:要查询字段(花名册字段信息参考:https://open.dingtalk.com/document/orgapp/roster-custom-field-business-code)
|
|
//field_filter_list:要查询字段(花名册字段信息参考:https://open.dingtalk.com/document/orgapp/roster-custom-field-business-code)
|
|
//agentid:企业内部应用AgentId
|
|
//agentid:企业内部应用AgentId
|
|
- map.put("field_filter_list","sys00-name,sys01-positionLevel,sys00-confirmJoinTime,sys02-joinWorkingTime,sys05-contractRenewCount");
|
|
|
|
|
|
+ map.put("field_filter_list","sys00-name,sys01-positionLevel,2a8b3a12-5102-4e60-b5d2-5f3bca0f0b7c,sys00-confirmJoinTime,sys02-joinWorkingTime,sys05-contractRenewCount");
|
|
map.put("agentid",agentId);
|
|
map.put("agentid",agentId);
|
|
|
|
|
|
List<String> result = new ArrayList<>();
|
|
List<String> result = new ArrayList<>();
|
|
@@ -113,6 +113,8 @@ public class KYServiceImpl implements KYService {
|
|
String confirmJoinTime = "";
|
|
String confirmJoinTime = "";
|
|
//职级
|
|
//职级
|
|
String positionLevel = "";
|
|
String positionLevel = "";
|
|
|
|
+ //原职级
|
|
|
|
+ String oldPositionLevel = "";
|
|
//姓名
|
|
//姓名
|
|
String name = "";
|
|
String name = "";
|
|
//合同续签次数
|
|
//合同续签次数
|
|
@@ -127,6 +129,7 @@ public class KYServiceImpl implements KYService {
|
|
case "sys02-joinWorkingTime": joinWorkingTime = value;break;
|
|
case "sys02-joinWorkingTime": joinWorkingTime = value;break;
|
|
case "sys00-confirmJoinTime": confirmJoinTime = value;break;
|
|
case "sys00-confirmJoinTime": confirmJoinTime = value;break;
|
|
case "sys01-positionLevel": positionLevel = value;break;
|
|
case "sys01-positionLevel": positionLevel = value;break;
|
|
|
|
+ case "2a8b3a12-5102-4e60-b5d2-5f3bca0f0b7c": oldPositionLevel = value;break;
|
|
case "sys00-name": name = value;break;
|
|
case "sys00-name": name = value;break;
|
|
case "sys05-contractRenewCount": contractRenewCount = Integer.valueOf(value);break;
|
|
case "sys05-contractRenewCount": contractRenewCount = Integer.valueOf(value);break;
|
|
default:break;
|
|
default:break;
|
|
@@ -137,10 +140,18 @@ public class KYServiceImpl implements KYService {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ //若没有原职级 则默认原职级是现职级
|
|
|
|
+ if ("".equals(oldPositionLevel)){
|
|
|
|
+ oldPositionLevel = positionLevel;
|
|
|
|
+ }
|
|
|
|
+
|
|
//假期有效开始日期为当年1月1日
|
|
//假期有效开始日期为当年1月1日
|
|
DateTime beginDate = DateUtil.beginOfYear(new Date());
|
|
DateTime beginDate = DateUtil.beginOfYear(new Date());
|
|
//假期有效截至日期为当年12月31日
|
|
//假期有效截至日期为当年12月31日
|
|
DateTime endDate = DateUtil.endOfYear(new Date());
|
|
DateTime endDate = DateUtil.endOfYear(new Date());
|
|
|
|
+ //当年天数
|
|
|
|
+ int yearDays = DateUtil.dayOfYear(endDate);
|
|
|
|
+
|
|
//工龄(年) 计算规则:首次工作时间至当年一月一日 数值向下取整
|
|
//工龄(年) 计算规则:首次工作时间至当年一月一日 数值向下取整
|
|
int workAge =(int) (DateUtil.betweenYear(DateUtil.parse(joinWorkingTime), beginDate, true));
|
|
int workAge =(int) (DateUtil.betweenYear(DateUtil.parse(joinWorkingTime), beginDate, true));
|
|
if (DateUtil.dayOfYear(DateUtil.parse(joinWorkingTime)) != 1){
|
|
if (DateUtil.dayOfYear(DateUtil.parse(joinWorkingTime)) != 1){
|
|
@@ -148,79 +159,35 @@ public class KYServiceImpl implements KYService {
|
|
}
|
|
}
|
|
|
|
|
|
System.out.println("截至今年1月1日,工龄为:"+workAge + "年");
|
|
System.out.println("截至今年1月1日,工龄为:"+workAge + "年");
|
|
- //法定年假
|
|
|
|
- int legalAnnualLeave = 0;
|
|
|
|
- //福利年假
|
|
|
|
- int welfareAnnualLeave = 0;
|
|
|
|
- //根据职级、工龄和合同续签数计算年假基数
|
|
|
|
- if (positionLevel.equals("5") || positionLevel.equals("副主任医师")){
|
|
|
|
- if (workAge < 10){
|
|
|
|
- legalAnnualLeave = 5;
|
|
|
|
- welfareAnnualLeave = 15;
|
|
|
|
- }else if (workAge >= 10 && workAge < 20){
|
|
|
|
- legalAnnualLeave = 10;
|
|
|
|
- welfareAnnualLeave = 10;
|
|
|
|
- }else if (workAge >= 20){
|
|
|
|
- legalAnnualLeave = 15;
|
|
|
|
- welfareAnnualLeave = 5;
|
|
|
|
- }
|
|
|
|
- }else if (positionLevel.equals("4") || positionLevel.equals("3") || positionLevel.equals("技术专员")){
|
|
|
|
- if (workAge < 10){
|
|
|
|
- legalAnnualLeave = 5;
|
|
|
|
- welfareAnnualLeave = 7 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
- }else if (workAge >= 10 && workAge < 20){
|
|
|
|
- legalAnnualLeave = 10;
|
|
|
|
- welfareAnnualLeave = 2 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
- }else if (workAge >= 20){
|
|
|
|
- legalAnnualLeave = 15;
|
|
|
|
- welfareAnnualLeave = 1;
|
|
|
|
- }
|
|
|
|
- }else if (positionLevel.equals("2") || positionLevel.equals("高级管理员")){
|
|
|
|
- if (workAge < 10){
|
|
|
|
- legalAnnualLeave = 5;
|
|
|
|
- welfareAnnualLeave = 5 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
- }else if (workAge >= 10 && workAge < 20){
|
|
|
|
- legalAnnualLeave = 10;
|
|
|
|
- welfareAnnualLeave = 0 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
- }else if (workAge >= 20){
|
|
|
|
- legalAnnualLeave = 15;
|
|
|
|
- welfareAnnualLeave = 0;
|
|
|
|
- }
|
|
|
|
- }else if (positionLevel.equals("1") || positionLevel.equals("技术专家")){
|
|
|
|
- if (workAge < 10){
|
|
|
|
- legalAnnualLeave = 5;
|
|
|
|
- welfareAnnualLeave = 3 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
- }else if (workAge >= 10 && workAge < 20){
|
|
|
|
- legalAnnualLeave = 10;
|
|
|
|
- welfareAnnualLeave = 0 + 2 * (Math.min(contractRenewCount, 1));
|
|
|
|
- }else if (workAge >= 20){
|
|
|
|
- legalAnnualLeave = 15;
|
|
|
|
- welfareAnnualLeave = 0;
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
- legalAnnualLeave = 0;
|
|
|
|
- welfareAnnualLeave = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ //年假基数
|
|
|
|
+ double yearLeave = 0.0;
|
|
|
|
+ //预支年假
|
|
|
|
+ double advanceLeave = 8.0;
|
|
|
|
|
|
- //当年天数
|
|
|
|
- int yearDays = DateUtil.dayOfYear(endDate);
|
|
|
|
|
|
+ int yearLeaveBaseNum = getAnnualLeaveBaseNum(positionLevel,workAge,contractRenewCount);
|
|
|
|
+ int oldYearLeaveBaseNum = getAnnualLeaveBaseNum(oldPositionLevel,workAge,contractRenewCount);
|
|
|
|
+ long day1 = 0;
|
|
|
|
+ long day2 = 0;
|
|
|
|
|
|
- result.add("姓名:"+name+",职级:"+positionLevel+",工龄:"+workAge+"年,合同续签数"+contractRenewCount+",法定年假:" + legalAnnualLeave + "天,福利年假:" + welfareAnnualLeave + "天"+",截止日期:"+endDate);
|
|
|
|
- //年假基数
|
|
|
|
- double yearLeave = legalAnnualLeave + welfareAnnualLeave;
|
|
|
|
- double yearLeaveDecimalPart = 0;
|
|
|
|
//判断员工是否当年新入职
|
|
//判断员工是否当年新入职
|
|
if (DateUtil.year(DateUtil.parse(confirmJoinTime)) == DateUtil.year(new Date())){
|
|
if (DateUtil.year(DateUtil.parse(confirmJoinTime)) == DateUtil.year(new Date())){
|
|
- int workDay = (int) DateUtil.betweenDay(DateUtil.parse(confirmJoinTime),endDate,true) + 1;
|
|
|
|
- yearLeave = workDay * yearLeave / yearDays;
|
|
|
|
- yearLeaveDecimalPart = yearLeave - (int) yearLeave;
|
|
|
|
- if (yearLeaveDecimalPart < 0.25){
|
|
|
|
- yearLeave = (int) yearLeave;
|
|
|
|
- }else if (yearLeaveDecimalPart < 0.75){
|
|
|
|
- yearLeave = (int) yearLeave + 0.5;
|
|
|
|
- }else if (yearLeaveDecimalPart < 1){
|
|
|
|
- yearLeave = (int) yearLeave + 1;
|
|
|
|
- }
|
|
|
|
|
|
+ day1 = DateUtil.betweenDay(DateUtil.parse(confirmJoinTime),new Date(),true);
|
|
|
|
+ day2 = DateUtil.betweenDay(new Date(),endDate,true);
|
|
|
|
+ }else {
|
|
|
|
+ day1 = DateUtil.betweenDay(beginDate,new Date(),true);
|
|
|
|
+ day2 = DateUtil.betweenDay(new Date(),endDate,true);
|
|
|
|
+ }
|
|
|
|
+ yearLeave = (double) (day1 * oldYearLeaveBaseNum + day2 * yearLeaveBaseNum) / yearDays;
|
|
|
|
+ double yearLeaveDecimalPart = yearLeave - (int) yearLeave;
|
|
|
|
+
|
|
|
|
+ result.add("姓名:"+name+",职级:"+positionLevel+",工龄:"+workAge+"年,合同续签数"+contractRenewCount+",年假数:" + yearLeave + "天"+",截止日期:"+endDate);
|
|
|
|
+
|
|
|
|
+ if (yearLeaveDecimalPart < 0.25){
|
|
|
|
+ yearLeave = (int) yearLeave;
|
|
|
|
+ }else if (yearLeaveDecimalPart < 0.75){
|
|
|
|
+ yearLeave = (int) yearLeave + 0.5;
|
|
|
|
+ }else if (yearLeaveDecimalPart < 1){
|
|
|
|
+ yearLeave = (int) yearLeave + 1;
|
|
}
|
|
}
|
|
|
|
|
|
//查询出用户消费年假记录 当返回leaveRecords中calType为null或不返回该字段则为请假消耗 将计算出的年假数减去请假消耗的数量
|
|
//查询出用户消费年假记录 当返回leaveRecords中calType为null或不返回该字段则为请假消耗 将计算出的年假数减去请假消耗的数量
|
|
@@ -248,12 +215,20 @@ public class KYServiceImpl implements KYService {
|
|
//注:若是管理员手动增加 则假期余额会多出一个BCXsunNm记录增加的假期天数 最终会在设置的假期余额的基础上加上这些天数
|
|
//注:若是管理员手动增加 则假期余额会多出一个BCXsunNm记录增加的假期天数 最终会在设置的假期余额的基础上加上这些天数
|
|
//故此处手动新增的假期余额不做处理
|
|
//故此处手动新增的假期余额不做处理
|
|
}
|
|
}
|
|
|
|
+ }else if (DateUtil.year(gmtCreate) == (DateUtil.year(new Date()) - 1)){
|
|
|
|
+ //获取去年预支年假使用情况
|
|
|
|
+ if ("预支年假".equals(use.get("leaveReason").toString())){
|
|
|
|
+ //若去年预支过则在今年预支年假数中相应减少
|
|
|
|
+ if (!use.containsKey("calType") || Objects.isNull(use.get("calType")) || "delete".equals(use.get("calType").toString())){
|
|
|
|
+ advanceLeave -= (int) use.get("recordNumPerDay") / 100;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//实际年假数
|
|
//实际年假数
|
|
- double realYearLeave = (yearLeave - useLeaveNum) < 0 ? 0 : (yearLeave - useLeaveNum);
|
|
|
|
|
|
+ double realYearLeave = (yearLeave - useLeaveNum + advanceLeave) < 0 ? 0 : (yearLeave - useLeaveNum + advanceLeave);
|
|
|
|
|
|
//更新假期余额接口的body
|
|
//更新假期余额接口的body
|
|
Map<String,Object> updateBody = new HashMap<>();
|
|
Map<String,Object> updateBody = new HashMap<>();
|
|
@@ -300,6 +275,64 @@ public class KYServiceImpl implements KYService {
|
|
return McR.success(result);
|
|
return McR.success(result);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private int getAnnualLeaveBaseNum(String positionLevel, int workAge, int contractRenewCount) {
|
|
|
|
+ //法定年假
|
|
|
|
+ int legalAnnualLeave = 0;
|
|
|
|
+ //福利年假
|
|
|
|
+ int welfareAnnualLeave = 0;
|
|
|
|
+ //根据职级、工龄和合同续签数计算年假基数
|
|
|
|
+ if (positionLevel.equals("5") || positionLevel.equals("副主任医师")){
|
|
|
|
+ if (workAge < 10){
|
|
|
|
+ legalAnnualLeave = 5;
|
|
|
|
+ welfareAnnualLeave = 15;
|
|
|
|
+ }else if (workAge >= 10 && workAge < 20){
|
|
|
|
+ legalAnnualLeave = 10;
|
|
|
|
+ welfareAnnualLeave = 10;
|
|
|
|
+ }else if (workAge >= 20){
|
|
|
|
+ legalAnnualLeave = 15;
|
|
|
|
+ welfareAnnualLeave = 5;
|
|
|
|
+ }
|
|
|
|
+ }else if (positionLevel.equals("4") || positionLevel.equals("3") || positionLevel.equals("技术专员")){
|
|
|
|
+ if (workAge < 10){
|
|
|
|
+ legalAnnualLeave = 5;
|
|
|
|
+ welfareAnnualLeave = 7 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
+ }else if (workAge >= 10 && workAge < 20){
|
|
|
|
+ legalAnnualLeave = 10;
|
|
|
|
+ welfareAnnualLeave = 2 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
+ }else if (workAge >= 20){
|
|
|
|
+ legalAnnualLeave = 15;
|
|
|
|
+ welfareAnnualLeave = 1;
|
|
|
|
+ }
|
|
|
|
+ }else if (positionLevel.equals("2") || positionLevel.equals("高级管理员")){
|
|
|
|
+ if (workAge < 10){
|
|
|
|
+ legalAnnualLeave = 5;
|
|
|
|
+ welfareAnnualLeave = 5 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
+ }else if (workAge >= 10 && workAge < 20){
|
|
|
|
+ legalAnnualLeave = 10;
|
|
|
|
+ welfareAnnualLeave = 0 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
+ }else if (workAge >= 20){
|
|
|
|
+ legalAnnualLeave = 15;
|
|
|
|
+ welfareAnnualLeave = 0;
|
|
|
|
+ }
|
|
|
|
+ }else if (positionLevel.equals("1") || positionLevel.equals("技术专家")){
|
|
|
|
+ if (workAge < 10){
|
|
|
|
+ legalAnnualLeave = 5;
|
|
|
|
+ welfareAnnualLeave = 3 + 2 * (Math.min(contractRenewCount, 2));
|
|
|
|
+ }else if (workAge >= 10 && workAge < 20){
|
|
|
|
+ legalAnnualLeave = 10;
|
|
|
|
+ welfareAnnualLeave = 0 + 2 * (Math.min(contractRenewCount, 1));
|
|
|
|
+ }else if (workAge >= 20){
|
|
|
|
+ legalAnnualLeave = 15;
|
|
|
|
+ welfareAnnualLeave = 0;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ legalAnnualLeave = 0;
|
|
|
|
+ welfareAnnualLeave = 0;
|
|
|
|
+ }
|
|
|
|
+ int annualLeave = legalAnnualLeave + welfareAnnualLeave;
|
|
|
|
+ return annualLeave;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public McR updateEmployeeAnnualLeaveNum() {
|
|
public McR updateEmployeeAnnualLeaveNum() {
|
|
//获取员工userId集合
|
|
//获取员工userId集合
|