package com.app.hxqh.assetdispo;

import psdi.mbo.MAXTableDomain;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.mbo.MboValue;
import psdi.server.MXServer;
import psdi.util.MXApplicationException;
import psdi.util.MXException;

import java.rmi.RemoteException;

/**
 * 选择EAM中设备台账的设备编号
 * createby liuxq 2024-3-8
 */
public class FldAssetNum extends MAXTableDomain {

    public FldAssetNum(MboValue mbv) throws MXException,RemoteException {
        super(mbv);
        String thisAttr = getMboValue().getAttributeName();
        setRelationship("ASSET", "");//从资产表弹出选择的表
        String[] FromStr = { "ASSETNUM" };//固定资产编号
        String[] ToStr = { thisAttr };
        setLookupKeyMapInOrder(ToStr, FromStr);
    }

    public void init() throws RemoteException, MXException {
        super.init();
    }
    public void action() throws RemoteException, MXException {
        super.action();
//        MboValue mbovalue = getMboValue();
//        MboRemote mbo = mbovalue.getMbo();//本应用的对象
//        String SITEID = mbo.getString("SITEID");
//        Integer ASSETNUM = mbo.getInt("ASSETNUM");
//        //查询台账中设备对应的固定资产
//        MboSetRemote assetSet = MXServer.getMXServer().getMboSet("ASSET",MXServer.getMXServer().getSystemUserInfo());
//        assetSet.setWhere("SITEID='"+SITEID+"' AND ASSETNUM="+ASSETNUM+"");
//        assetSet.reset();
//        if(assetSet!=null && !assetSet.isEmpty()){
//            MboRemote assetMbo = assetSet.getMbo(0);
//            if(null==assetMbo.getString("SDGDZCBM") || "".equalsIgnoreCase(assetMbo.getString("SDGDZCBM"))){
//                throw new MXApplicationException("assetdispo", "assetdispo_sap", new String[]{} );
//            }else{
//                String SDGDZCBM = assetMbo.getString("SDGDZCBM");
//                mbo.setValue("SDGDZCBM",SDGDZCBM);
//            }
//        }
    }

    public MboSetRemote getList() throws RemoteException, MXException {
        MboRemote mbo = getMboValue().getMbo();
        String sql = " SITEID='"+mbo.getString("SITEID")+"' AND SDGDZCBM='"+mbo.getString("SDGDZCBM")+"' ";
        setListCriteria(sql);
        return super.getList();
    }
}