package com.changhong.epc.count.service.system.func.set;
|
|
import com.changhong.epc.bean.count.func.FunNameKey;
|
import com.changhong.epc.count.service.count.model.UnitInfo;
|
import com.changhong.epc.bean.count.MeInfo;
|
import com.changhong.epc.count.service.system.model.SystemFunContextType;
|
import com.googlecode.aviator.runtime.function.AbstractFunction;
|
import com.googlecode.aviator.runtime.function.FunctionUtils;
|
import com.googlecode.aviator.runtime.type.AviatorLong;
|
import com.googlecode.aviator.runtime.type.AviatorObject;
|
import com.googlecode.aviator.runtime.type.AviatorString;
|
import com.iemsoft.framework.cloud.core.tools.DateTool;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import org.apache.commons.lang3.StringUtils;
|
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
|
public abstract class AbsFuncSupper extends AbstractFunction implements FunNameKey{
|
public static final AviatorString fun_empty = new AviatorString("");
|
|
protected String format(String dateStr, String pattern){
|
Date date = DateTool.stringToDate(dateStr);
|
if(date == null){
|
return "";
|
}
|
return DateTool.dateToString(date, pattern);
|
}
|
|
/**
|
* 获取所有行程
|
* @param env
|
* @return
|
*/
|
protected List<UnitInfo> getJourneyList(Map<String, Object> env){
|
List<UnitInfo> jList = (List<UnitInfo>) env.get(SystemFunContextType.ALL_JOURNEY.toString());
|
return jList;
|
}
|
|
protected boolean isNotEmpty(List<MeInfo> params){
|
if(ObjectUtil.empty(params)){
|
return true;
|
}
|
for (MeInfo meInfo : params) {
|
if(StringUtils.isBlank(meInfo.getMeValue())){
|
return false;
|
}
|
}
|
return true;
|
}
|
/**
|
* 安全获得参数
|
* @param env
|
* @param arg
|
* @return
|
*/
|
protected Object getParameter(Map<String, Object> env, AviatorObject arg) {
|
try {
|
return FunctionUtils.getJavaObject(arg, env);
|
} catch (Exception e) {
|
return arg.getValue(env);
|
}
|
}
|
|
protected AviatorLong getAviatorLong(Object data){
|
return new AviatorLong (new Long(data.toString()));
|
}
|
|
public AviatorObject call(Map<String, Object> env, AviatorObject arg1) {
|
return this.throwArity(1);
|
}
|
}
|