main
liuliang 7 months ago
parent cd27abbdd9
commit bb0b5f4961

@ -385,7 +385,7 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
String newClockTime = newClockTimeMap.get("signdate")+ " "+newClockTimeMap.get("signtime"); String newClockTime = newClockTimeMap.get("signdate")+ " "+newClockTimeMap.get("signtime");
int index = clcokInTimeData.indexOf(resetClcokDTO); int index = clcokInTimeData.indexOf(resetClcokDTO);
if (newtimeType.equals(ClockPointEnum.BEFORE)){ if (newtimeType.equals(ClockPointEnum.BEFORE)){
if (!getBeforeClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,time))) <= 0){ if (!getBeforeClockTime(needClockDateList,restTime).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,restTime))) <= 0){
newClockTimeMap = null; newClockTimeMap = null;
} }
@ -398,7 +398,7 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
} }
} }
}else if (newtimeType.equals(ClockPointEnum.AFTER)){ }else if (newtimeType.equals(ClockPointEnum.AFTER)){
if (!getNextClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,time))) >= 0){ if (!getNextClockTime(needClockDateList,restTime).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,restTime))) >= 0){
newClockTimeMap = null; newClockTimeMap = null;
} }
} }
@ -507,7 +507,7 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
} }
} }
if (!getBeforeClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,time))) <= 0){ if (!getBeforeClockTime(needClockDateList,restTime).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getBeforeClockTime(needClockDateList,restTime))) <= 0){
newClockTimeMap = null; newClockTimeMap = null;
} }
@ -544,7 +544,7 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
newClockTimeMap = null; newClockTimeMap = null;
} }
} }
if (!getNextClockTime(needClockDateList,time).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,time))) >= 0){ if (!getNextClockTime(needClockDateList,restTime).equals("") && DateUtil.getTime(newClockTime).compareTo(DateUtil.getTime(getNextClockTime(needClockDateList,restTime))) >= 0){
newClockTimeMap = null; newClockTimeMap = null;
} }
} }
@ -818,7 +818,7 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
/** /**
* *
*/ */
if (toRestClockPointDTO != null && endRestClockPointDTO != null && toRestClockPointDTO.getClockTime() != null && endRestClockPointDTO.getClockTime() != null){ if (toRestClockPointDTO != null && endRestClockPointDTO != null && toRestClockPointDTO.getClockTime() != null){
String toRestClassTime = toRestClockPointDTO.getClassTime(); String toRestClassTime = toRestClockPointDTO.getClassTime();
String endRestClassTime = endRestClockPointDTO.getClassTime(); String endRestClassTime = endRestClockPointDTO.getClassTime();
Map<ClockPointEnum, Map<String, Object>> toRestNearestClcokInTime = Utils.getNearestClcokInTimeCmd(DateUtil.beforeMinutes(dtkssj,dtzddxfz), clockInTimeList); Map<ClockPointEnum, Map<String, Object>> toRestNearestClcokInTime = Utils.getNearestClcokInTimeCmd(DateUtil.beforeMinutes(dtkssj,dtzddxfz), clockInTimeList);
@ -881,6 +881,34 @@ public class GetClockInPointCmd extends AbstractCommonCommand<Map<String, Object
ClockPointEnum endResttimeType = getStartClassTimeType(endRestSchedule.get(0),ksdkNearestClcokInTime,endRestClockPointDTO.getElasticTime(),endRestClockPointDTO.getElasticTime()); ClockPointEnum endResttimeType = getStartClassTimeType(endRestSchedule.get(0),ksdkNearestClcokInTime,endRestClockPointDTO.getElasticTime(),endRestClockPointDTO.getElasticTime());
endRestClockPointDTO.setClockTime(ksdkNearestClcokInTime.get(endResttimeType)); endRestClockPointDTO.setClockTime(ksdkNearestClcokInTime.get(endResttimeType));
endRestClockPointDTO.setTimeType(endResttimeType); endRestClockPointDTO.setTimeType(endResttimeType);
if (endRestClockPointDTO.getTimeType() == ClockPointEnum.EMPTY || endRestClockPointDTO.getClockTime() == null){
//当弹性结束未匹配到打卡,弹性失效,进行还原
restSchedule.put("dtkssj",toRestClockPointDTO.getClassTime().split(" ")[1]);
restSchedule.put("dtjssj",endRestClockPointDTO.getClassTime().split(" ")[1]);
//重新设置打卡时间
toRestIndex = needClockDateList.indexOf(toRestClockPointDTO.getElasticTime());
needClockDateList.remove(toRestIndex);
needClockDateList.add(toRestIndex,toRestClockPointDTO.getClassTime());
endRestIndex = needClockDateList.indexOf(endRestClockPointDTO.getElasticTime());
needClockDateList.remove(endRestIndex);
needClockDateList.add(endRestIndex,endRestClockPointDTO.getClassTime());
if (toRestClockPointDTO.getClockTime() != null){
String time = toRestClockPointDTO.getClockTime().get("signdate")+" "+toRestClockPointDTO.getClockTime().get("signtime");
if (DateUtil.getTime(time).compareTo(DateUtil.getTime(toRestClockPointDTO.getClassTime())) > 0){
toRestClockPointDTO.setTimeType(ClockPointEnum.AFTER);
}else if (DateUtil.getTime(time).compareTo(DateUtil.getTime(toRestClockPointDTO.getClassTime())) ==0){
toRestClockPointDTO.setTimeType(ClockPointEnum.EQUAL);
}else {
toRestClockPointDTO.setTimeType(ClockPointEnum.BEFORE);
}
}
toRestClockPointDTO.setElasticTime(null);
endRestClockPointDTO.setElasticTime(null);
}
} }
} }

@ -42,21 +42,23 @@ public class AttendanceAnalysisJob extends BaseCronJob {
public void execute() { public void execute() {
log.info("********AttendanceAnalysisJob start********"); log.info("********AttendanceAnalysisJob start********");
String useDate = com.time.util.DateUtil.getCurrentTime("yyyy-MM-dd"); String useDate = DateUtil.getCurrentDate();
// if (executeDate != null && !"".equals(executeDate)){ // if (executeDate != null && !"".equals(executeDate)){
// useDate = executeDate; // useDate = executeDate;
// } // }
log.info("********AttendanceAnalysisJob executeDate :[{}]********",useDate); log.info("********AttendanceAnalysisJob executeDate :[{}]********",useDate);
//查询所有在职人员
String queryUserSql = "select id,departmentid,subcompanyid1,companystartdate from hrmresource where status <> '5' and status <> '4' and status <> '7'";
List<Map<String,Object>> userList = DbTools.getSqlToList(queryUserSql);
String queryDepartEmployeeSql = "select resourceid ,changedate from HRMSTATUSHISTORY where type_n = 5 and changedate='"+DateUtil.beforeDay(useDate,1)+"'"; String queryDepartEmployeeSql = "select resourceid ,changedate from HRMSTATUSHISTORY where type_n = 5 and changedate='"+DateUtil.beforeDay(useDate,1)+"'";
List<String> departEmployeeList = Lists.newArrayList(DbTools.getSqlToList(queryDepartEmployeeSql).stream().map(e->e.get("resourceid").toString()).collect(Collectors.toSet())); List<String> departEmployeeList = Lists.newArrayList(DbTools.getSqlToList(queryDepartEmployeeSql).stream().map(e->e.get("resourceid").toString()).collect(Collectors.toSet()));
List<List<String>> departEmployeePartition = Lists.partition(departEmployeeList,200); List<List<String>> departEmployeePartition = Lists.partition(departEmployeeList,200);
String queryUserSql = "select id,departmentid,subcompanyid1,companystartdate from hrmresource where status <> '5' and status <> '4' and status <> '7'";
List<Map<String,Object>> userList = DbTools.getSqlToList(queryUserSql);
for (List<String> userIdPartition :departEmployeePartition){ for (List<String> userIdPartition :departEmployeePartition){
String sql = "select id,departmentid,subcompanyid1,companystartdate from hrmresource where id ("+String.join(",",userIdPartition)+")"; String sql = "select id,departmentid,subcompanyid1,companystartdate from hrmresource where id in ("+String.join(",",userIdPartition)+")";
userList.addAll(DbTools.getSqlToList(sql)); userList.addAll(DbTools.getSqlToList(sql));
} }

@ -349,7 +349,9 @@ public class ShiftServiceImpl extends Service implements ShiftService {
Map<String,Object> newMap = Maps.newHashMap(); Map<String,Object> newMap = Maps.newHashMap();
newMap.putAll(map); newMap.putAll(map);
newMap.put("rqlx",dateType); newMap.put("rqlx",dateType);
if (!newMap.get("sfxx").equals(CheckBoxEnum.CHECKED.getKey())){
newMap.put("sfxx",restSign); newMap.put("sfxx",restSign);
}
classs.add(newMap); classs.add(newMap);
} }
resultMap.put(punchDate,classs); resultMap.put(punchDate,classs);

@ -47,11 +47,11 @@ public class AttendanceanalysisAction {
public String getSchedulingData(@Context HttpServletRequest request, @Context HttpServletResponse response) { public String getSchedulingData(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try { try {
log.info("********AttendanceAnalysisJob start********"); log.info("********AttendanceAnalysisJob start********");
Map<String,Object> paramMap = ParamUtil.request2Map(request); // Map<String,Object> paramMap = ParamUtil.request2Map(request);
// Map<String,Object> paramMap = Maps.newHashMap(); Map<String,Object> paramMap = Maps.newHashMap();
// paramMap.put("startDate","2024-08-16"); paramMap.put("startDate","2024-08-12");
// paramMap.put("endDate","2024-08-16"); paramMap.put("endDate","2024-08-12");
// paramMap.put("userIds","81"); paramMap.put("userIds","31");
String startDate = Util.null2String(paramMap.get("startDate")); String startDate = Util.null2String(paramMap.get("startDate"));
String startBeforeDate = DateUtil.beforeDay(startDate,2); String startBeforeDate = DateUtil.beforeDay(startDate,2);
@ -59,10 +59,10 @@ public class AttendanceanalysisAction {
String endAfterDate = DateUtil.AfterDay(endDate,2); String endAfterDate = DateUtil.AfterDay(endDate,2);
String userIds = Util.null2String(paramMap.get("userIds")); String userIds = Util.null2String(paramMap.get("userIds"));
int betweenDays = DateUtil.getBetWeenDays(startDate,endDate); int betweenDays = DateUtil.getBetWeenDays(startDate,endDate);
String queryDepartEmployeeSql = "select resourceid id,changedate name from HRMSTATUSHISTORY where type_n = 5"; String queryDepartEmployeeSql = "select resourceid ,changedate,type_n from HRMSTATUSHISTORY where type_n = 5 or type_n = 7";
//获取离职日期 //获取离职日期
Map<String,Object> departEmployeeMap = DbTools.getSqlToMapList(queryDepartEmployeeSql); List<Map<String,Object>> departEmployeeList = DbTools.getSqlToList(queryDepartEmployeeSql);
Map<String,Object> departEmployeeMap = CommonUtil.getDepartEmployeeMap(departEmployeeList);
//初始化扩展类 //初始化扩展类
CommonUtil.initExtensionClassHolder(); CommonUtil.initExtensionClassHolder();
@ -207,10 +207,12 @@ public class AttendanceanalysisAction {
if (attendaceGroupById.get(userId) != null && attendaceGroupById.get(userId).size() > 0) { if (attendaceGroupById.get(userId) != null && attendaceGroupById.get(userId).size() > 0) {
attendaceResultMap = attendaceGroupById.get(userId).stream().collect(Collectors.groupingBy(e -> e.get("rq").toString())); attendaceResultMap = attendaceGroupById.get(userId).stream().collect(Collectors.groupingBy(e -> e.get("rq").toString()));
} }
for (int i=0; i<=betweenDays;i++){ for (int i=0; i<=betweenDays;i++){
String date = DateUtil.AfterDay(startDate,i); String date = DateUtil.AfterDay(startDate,i);
if (("".equals(companystartDate) || DateUtil.getTime(date).compareTo(DateUtil.getTime(companystartDate))>=0) if (("".equals(companystartDate) || DateUtil.getTime(date).compareTo(DateUtil.getTime(companystartDate))>=0)
&& ("".equals(terminationDate) || DateUtil.getTime(date).compareTo(DateUtil.getTime(terminationDate)) <=0)){ && ("".equals(terminationDate) || DateUtil.getTime(date).compareTo(DateUtil.getTime(terminationDate)) <=0)){
log.info("***********analysis userId:{},analysisDate:{} start***********", userId, date);
attendanceAnalysisService.attendanceAnalysisForApi(userId,date,collect.get(userId),attendanceItems,schedulMap,workHourItems,clockInTimeMap,attendaceResultMap.get(date)); attendanceAnalysisService.attendanceAnalysisForApi(userId,date,collect.get(userId),attendanceItems,schedulMap,workHourItems,clockInTimeMap,attendaceResultMap.get(date));
} }
@ -219,7 +221,7 @@ public class AttendanceanalysisAction {
paramMap.put("empIds",paramMap.get("userIds")); paramMap.put("empIds",paramMap.get("userIds"));
allowanceService.addAllowanceRecords(paramMap); allowanceService.addAllowanceRecords(paramMap);
} }
log.info("********AttendanceAnalysisJob start********"); log.info("********AttendanceAnalysisJob end********");
return null; return null;
}catch (Exception e){ }catch (Exception e){
log.error("execute fail,catch error: [{}]",e); log.error("execute fail,catch error: [{}]",e);

@ -15,6 +15,7 @@ import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.DepartmentComInfo;
import weaver.soa.workflow.request.*; import weaver.soa.workflow.request.*;
import java.time.ZoneOffset;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -954,4 +955,26 @@ public class CommonUtil {
} }
return errorMessage; return errorMessage;
} }
/**
*
* @param departEmployeeList
* @return
*/
public static Map<String,Object> getDepartEmployeeMap(List<Map<String,Object>> departEmployeeList){
Map<String,List<Map<String,Object>>> group = departEmployeeList.stream().collect(Collectors.groupingBy(e -> Util.null2String(e.get("resourceid"))));
Map<String,Object> resultMap = Maps.newHashMap();
for (Map.Entry<String,List<Map<String,Object>>> entry: group.entrySet()){
String userid = entry.getKey();
List<Map<String,Object>> list = entry.getValue();
if (list.size() > 1){
list = list.stream().sorted(Comparator.comparing(e->DateUtil.getTime(e.get("changedate").toString()).toInstant(ZoneOffset.of("+8")).toEpochMilli())).collect(Collectors.toList());
}
if (list.size() > 0 && Util.null2String(list.get(list.size()-1).get("type_n")).equals("5")){
resultMap.put(userid,list.get(list.size()-1).get("changedate"));
}
}
return resultMap;
}
} }

Loading…
Cancel
Save