You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
4.0 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import com.engine.jucailinkq.attendance.enums.ClockPointEnum;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TestRecordData {
public static void main(String[] args) {
List<Map<String,Map<String,Object>>> clcokInTimeData = Lists.newArrayList();
Map<String,Map<String,Object>> map1 = new HashMap(){{
put("2023-11-30 09:00|0|4",new HashMap(){{
put("signtime","08:38:00");
put("signdate","2023-11-30");
}});
}};
Map<String,Map<String,Object>> map2 = new HashMap(){{
put("2023-11-30 10:00|1|5|0",new HashMap(){{
put("signtime","10:29:00");
put("signdate","2023-11-30");
}});
}};
Map<String,Map<String,Object>> map3 = new HashMap(){{
put("2023-11-30 11:00|0|4|0",null);
}};
Map<String,Map<String,Object>> map4 = new HashMap(){{
put("2023-11-30 11:00|1|5|0",new HashMap(){{
put("signtime","11:38:00");
put("signdate","2023-11-30");
}});
}};
Map<String,Map<String,Object>> map5 = new HashMap(){{
put("2023-11-30 18:00|0|5|0",new HashMap(){{
put("signtime","18:29:00");
put("signdate","2023-11-30");
}});
}};
clcokInTimeData.add(map1);
clcokInTimeData.add(map2);
clcokInTimeData.add(map3);
clcokInTimeData.add(map4);
clcokInTimeData.add(map5);
System.out.println(getNeedRecordClockInTime(clcokInTimeData));
}
public static Map<String, Object> getNeedRecordClockInTime(List<Map<String,Map<String,Object>>> clcokInTimeData) {
Map<String, Object> resultMap = Maps.newHashMap();
int inIndex = 1;
int outIndex = 1;
int jcCloumns = 8;
for (Map<String,Map<String,Object>> clcokInTimeMap : clcokInTimeData){
//卡点
String point = "";
//当天打卡数据
Map<String,Object> clcokInTime = null;
for (Map.Entry<String,Map<String,Object>> entry :clcokInTimeMap.entrySet()){
point = entry.getKey();
clcokInTime = entry.getValue();
}
//需要计算的班次打卡时间点
String pointTime = point.split("\\|")[0];
//start开始打卡时间点end结束打卡时间点
String pointType = point.split("\\|")[1];
//empty:漏卡equal:打卡时间和班次时间相等before打卡时间在班次时间之前after打卡时间在班次时间之后
String timeType = point.split("\\|")[2];
if (ClockPointEnum.START.getKey().equals(pointType)){
//开始时间打卡
String key = "j"+inIndex;
if (!ClockPointEnum.EMPTY.getKey().equals(timeType) && clcokInTime != null){
String value = "'"+clcokInTime.get("signtime")+"'";
resultMap.put(key,value);
}else {
resultMap.put(key,"NULL");
}
inIndex++;
}else if (ClockPointEnum.END.getKey().equals(pointType)){
//结束时间打卡
String key = "c"+outIndex;
if (!ClockPointEnum.EMPTY.getKey().equals(timeType) && clcokInTime != null){
String value = "'"+clcokInTime.get("signtime")+"'";
resultMap.put(key,value);
}else {
resultMap.put(key,"NULL");
}
outIndex++;
}
}
for (int i=inIndex;i<jcCloumns;i++){
String key = "j"+i;
resultMap.put(key,"NULL");
}
for (int i=outIndex;i<jcCloumns;i++){
String key = "c"+i;
resultMap.put(key,"NULL");
}
return resultMap;
}
}