//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package nccloud.web.uapbd.ref.pub;

import nc.uap.utils.SQLHelper;
import nc.vo.bd.material.MaterialVO;
import nc.vo.bd.material.MaterialVersionVO;
import nc.vo.bd.material.marbasclass.MarBasClassVO;
import nc.vo.ml.MultiLangUtil;
import nccloud.framework.web.processor.IRefSqlBuilder;
import nccloud.framework.web.processor.refgrid.RefQueryInfo;
import nccloud.framework.web.ui.meta.RefMeta;
import nccloud.framework.web.ui.meta.TreeRefMeta;
import nccloud.web.refer.action.DefaultTreeGridRefAction;
import nccloud.web.refer.sqlbuilder.StrongDefaultTreeGridRefSqlBuilder;

public class MaterialGridRef extends DefaultTreeGridRefAction {
    public MaterialGridRef() {
        this.setClassPkFieldName("pk_marbasclass");
        this.setClassTableName((new MarBasClassVO()).getTableName());
        this.setClassIsShowDisableData(false);
        this.setClassMdClassId("c099f7d7-52a9-4b98-bee7-2e3a6c3ea263");
        this.setClassResourceCode("materialbasclass");
        this.setShowDisabledData(false);
        this.setUnitPkKey("pk_org");
        this.setMdClassId("c7dc0ccd-8872-4eee-8882-160e8f49dfad");
        this.setResourceCode("material_v");
        this.setUsualDataPkFieldName("pk_material");
        this.setUsualDataTableName(MaterialVO.getDefaultTableName());
    }

    public String getOrderSql(RefQueryInfo paramRefQueryInfo, RefMeta paramRefMeta) {
        return " order by code";
    }

    public RefMeta getRefMeta(RefQueryInfo refQueryInfo) {
        TreeRefMeta meta = new TreeRefMeta();
        meta.setCodeField("code");
        meta.setNameField("name");
        meta.setFullTxtNameField("name" + MultiLangUtil.getCurrentLangSeqSuffix());
        meta.setPkField("pk_source");
        meta.setPidField("pk_marbasclass");
        meta.setMutilLangNameRef(true);
        meta.setExtraFields(new String[]{"pk_org", "materialspec", "materialtype", "materialshortname",
                "materialmnecode", "graphid", "pk_measdoc", "measdoc_name", "org_name", "materialmgt", "pk_material", "memo"});
        String var10001 = SQLHelper.getMultiLangNameColumn("bd_material_v.name");
        meta.setTableName("(select bd_material_v.pk_material as pk_material, bd_material_v.pk_marbasclass as pk_marbasclass," +
                " bd_material_v.pk_org as pk_org,bd_material_v.dr as dr,bd_material_v.setpartsflag as setpartsflag,bd_material_v.code as code," +
                var10001 + " as name,bd_material_v.version as version,bd_material_v.enablestate as enablestate," +
                "bd_material_v.discountflag as discountflag,bd_material_v.fee as fee,bd_material_v.pk_group as pk_group," +
                "bd_material_v.materialspec as materialspec,bd_material_v.materialtype as materialtype,bd_material_v.materialshortname as materialshortname," +
                "bd_material_v.materialmgt as materialmgt,bd_material_v.materialmnecode as materialmnecode,bd_material_v.graphid as graphid," +
                "bd_material_v.pk_measdoc as pk_measdoc,bd_material_v.pk_source as pk_source,bd_material_v.memo as memo,bd_material_v.retail as retail, " +
                "bd_material_v.electronicsale as electronicsale, bd_material_v.isfeature as isfeature,bd_material_v.matchmode as matchmode, " +
                SQLHelper.getMultiLangNameColumn("org_orgs.name") + " as org_name," + SQLHelper.getMultiLangNameColumn("bd_measdoc.name") +
                " as measdoc_name,bd_material_v.name2 as name2,bd_material_v.name3 as name3,bd_material_v.name4 as name4,bd_material_v.name5 as name5," +
                "bd_material_v.name6 as name6  from bd_material_v left join org_orgs on bd_material_v.pk_org=org_orgs.pk_org " +
                "left join bd_measdoc on bd_material_v.pk_measdoc = bd_measdoc.pk_measdoc ) aa");
        meta.setDefaultTableName(MaterialVersionVO.getDefaultTableName());
        meta.setFullTxtTabName(MaterialVersionVO.getDefaultTableName());
        return meta;
    }

    protected IRefSqlBuilder getRefSqlBuilder(RefQueryInfo refQueryInfo) {
        return new StrongDefaultTreeGridRefSqlBuilder(this, this, refQueryInfo);
    }
}
