package com.app.hxqh.udoutser;

import psdi.mbo.MAXTableDomain;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.util.MXException;

import java.rmi.RemoteException;

/**
 * 委外服务-选择货币
 * createby liuxq 2023-8-17
 */
public class FldCoinNum extends MAXTableDomain {

    public FldCoinNum(MboValue mbv) throws MXException,RemoteException {
        super(mbv);
        String thisAttr = getMboValue().getAttributeName();
        setRelationship("COINRATE", "");//从资产表弹出选择的表
        String[] FromStr = { "COINNUM" };
        String[] ToStr = { thisAttr };
        setLookupKeyMapInOrder(ToStr, FromStr);
    }

    public void init() throws RemoteException, MXException {
        super.init();
    }
    public void action() throws RemoteException, MXException {
        super.action();
    }

    public MboSetRemote getList() throws RemoteException, MXException {
        MboRemote mbo = getMboValue().getMbo();
        String siteid=mbo.getString("SITEID");
        String COINNUM="";
        if("GF08".equalsIgnoreCase(siteid) || "GF02".equalsIgnoreCase(siteid) || "GF51".equalsIgnoreCase(siteid) || "GF03".equalsIgnoreCase(siteid)){
            COINNUM="GHS";
        } else if("KF61".equalsIgnoreCase(siteid) || "KF51".equalsIgnoreCase(siteid)){
            COINNUM="KES";
        } else if("TF51".equalsIgnoreCase(siteid) || "TF01".equalsIgnoreCase(siteid)){
            COINNUM="TZS";
        }
//        String sql = " COINRATEID=(SELECT MAX(COINRATEID) FROM COINRATE WHERE DHDMLX='TORMB' AND COINNUM='"+COINNUM+"')  ";
        String sql="COINRATEID in(SELECT MAX(COINRATEID) FROM COINRATE WHERE DHDMLX='TORMB' GROUP BY COINNUM ) ";
        setListCriteria(sql);
        return super.getList();
    }
}