package com.changhong.epc.count.service.system.func.set.util;
|
|
import com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode;
|
import com.changhong.epc.count.service.system.func.set.AbsFuncSupper;
|
import com.changhong.epc.count.service.tool.SystemFunTool;
|
import com.changhong.epc.rely.api.epc.admin.CurrencyApi;
|
import com.changhong.epc.rely.api.tool.CurrencyTool;
|
import com.googlecode.aviator.runtime.type.AviatorObject;
|
import com.googlecode.aviator.runtime.type.AviatorString;
|
import com.googlecode.aviator.runtime.type.AviatorType;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import lombok.AllArgsConstructor;
|
import lombok.Data;
|
import lombok.NoArgsConstructor;
|
|
import java.util.Date;
|
import java.util.Map;
|
|
public class CurrencyAmount extends AbsFuncSupper implements BudgetBusinessMeaningCode {
|
|
@Override
|
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
|
String date = SystemFunTool.getStringVal(new AviatorString(BUDGET_START_DATE), env);
|
// 获得汇率
|
String exchangeRate = SpringUtil.getBean(CurrencyApi.class)
|
.exchangeRate(
|
SystemFunTool.getStringVal(arg1, env)
|
, SystemFunTool.getStringVal(new AviatorString(APPLYCATION_CURRENCY), env)
|
, ObjectUtil.empty(date) ? new Date() : date
|
);
|
return new AviatorString(CurrencyTool.valueOf(exchangeRate, SystemFunTool.getStringVal(arg2, env)));
|
}
|
|
@Override
|
public String getName() {
|
return "amount";
|
}
|
|
@Data
|
@AllArgsConstructor
|
@NoArgsConstructor
|
public class AviatorAmount extends AviatorObject{
|
|
private String currency;
|
|
private String amount;
|
|
@Override
|
public int compare(AviatorObject other, Map<String, Object> env) {
|
if(other instanceof AviatorAmount){
|
return other.hashCode() - this.hashCode();
|
}
|
return -1;
|
}
|
|
@Override
|
public AviatorType getAviatorType() {
|
return AviatorType.JavaType;
|
}
|
|
@Override
|
public AviatorAmount getValue(Map<String, Object> env) {
|
return this;
|
}
|
}
|
|
}
|