101 lines
3.0 KiB
Java
101 lines
3.0 KiB
Java
package com.engine.kq.biz;
|
||
|
||
import com.engine.kq.bean.KQRepeatBean;
|
||
import com.google.common.collect.Lists;
|
||
import com.google.common.collect.Maps;
|
||
import org.apache.commons.lang.StringUtils;
|
||
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
public class KQRepeatLengthContext {
|
||
|
||
/**
|
||
* 需要进行哺乳假处理的
|
||
*/
|
||
public static final ThreadLocal<KQRepeatBean> ATTEND_REPEAT_BEAN_LOCAL = new ThreadLocal<>();
|
||
|
||
|
||
/**
|
||
* 哺乳假是控制每天的异常时长,需要记录每一天的KQRepeatBean
|
||
*/
|
||
public static final ThreadLocal<Map<String, List<KQRepeatBean>>> ATTEND_REPEAT_LOCAL = new ThreadLocal<>();
|
||
|
||
/**
|
||
* 针对当天哺乳假流程抵扣异常时长的部分
|
||
*/
|
||
public static final ThreadLocal<KQRepeatBean> ATTEND_REPEAT_LINK_DETAIL_LOCAL = new ThreadLocal<>();
|
||
|
||
/**
|
||
* 针对当天每一个时段哺乳假流程抵扣异常时长的部分
|
||
*/
|
||
public static final ThreadLocal<KQRepeatBean> ATTEND_REPEAT_LINK_RANGE_LOCAL = new ThreadLocal<>();
|
||
|
||
public static KQRepeatBean getRepeatBean() {
|
||
return ATTEND_REPEAT_BEAN_LOCAL.get();
|
||
}
|
||
|
||
public static void setRepeatBean(KQRepeatBean repeatBean) {
|
||
ATTEND_REPEAT_BEAN_LOCAL.set(repeatBean);
|
||
}
|
||
|
||
|
||
public static void removeRepeatBean() {
|
||
ATTEND_REPEAT_BEAN_LOCAL.remove();
|
||
}
|
||
|
||
|
||
public static void clear() {
|
||
ATTEND_REPEAT_LOCAL.remove();
|
||
}
|
||
|
||
public static List<KQRepeatBean> getKQRepeatBean(String key) {
|
||
Map<String, List<KQRepeatBean>> attendRepeatBeanMap = ATTEND_REPEAT_LOCAL.get();
|
||
return attendRepeatBeanMap != null && StringUtils.isNotEmpty(key) ? attendRepeatBeanMap.get(key) : null;
|
||
}
|
||
|
||
public static void setKQRepeatBean(String key,KQRepeatBean attendRepeatBean) {
|
||
Map<String, List<KQRepeatBean>> attendRepeatBeanMap = ATTEND_REPEAT_LOCAL.get();
|
||
if (attendRepeatBeanMap == null) {
|
||
attendRepeatBeanMap = Maps.newHashMap();
|
||
ATTEND_REPEAT_LOCAL.set(attendRepeatBeanMap);
|
||
}
|
||
if(attendRepeatBeanMap.containsKey(key)){
|
||
List<KQRepeatBean> tmp = attendRepeatBeanMap.get(key);
|
||
tmp.add(attendRepeatBean);
|
||
}else{
|
||
List<KQRepeatBean> tmp = Lists.newArrayList();
|
||
tmp.add(attendRepeatBean);
|
||
attendRepeatBeanMap.put(key,tmp);
|
||
}
|
||
}
|
||
|
||
public static KQRepeatBean getRepeatBeanLinkRange() {
|
||
return ATTEND_REPEAT_LINK_RANGE_LOCAL.get();
|
||
}
|
||
|
||
public static void setRepeatBeanLinkRange(KQRepeatBean repeatBean) {
|
||
ATTEND_REPEAT_LINK_RANGE_LOCAL.set(repeatBean);
|
||
}
|
||
|
||
|
||
public static void removeRepeatBeanLinkRange() {
|
||
ATTEND_REPEAT_LINK_RANGE_LOCAL.remove();
|
||
}
|
||
|
||
|
||
|
||
public static KQRepeatBean getRepeatBeanLink() {
|
||
return ATTEND_REPEAT_LINK_DETAIL_LOCAL.get();
|
||
}
|
||
|
||
public static void setRepeatBeanLink(KQRepeatBean repeatBean) {
|
||
ATTEND_REPEAT_LINK_DETAIL_LOCAL.set(repeatBean);
|
||
}
|
||
|
||
|
||
public static void removeRepeatBeanLink() {
|
||
ATTEND_REPEAT_LINK_DETAIL_LOCAL.remove();
|
||
}
|
||
}
|