package com.yem.wm.fm.lettercredit.convert;

import kd.bos.dataentity.OperateOption;
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
import kd.bos.entity.botp.plugin.args.AfterBuildDrawFilterEventArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;

import java.util.HashSet;
import java.util.Set;

public class SaleOrderToLetterCreditConvertPlugin extends AbstractConvertPlugIn {
    @Override
    public void afterBuildDrawFilter(AfterBuildDrawFilterEventArgs e) {
        super.afterBuildDrawFilter(e);
        OperateOption option = this.getOption();
        Long org = Long.valueOf(option.getVariableValue("org"));
        Long customer = Long.valueOf(option.getVariableValue("customer"));
        //仅允许过滤出相同组织+客户的外贸整机和外贸配件合同
        Set<String> strArray = new HashSet<>();
        strArray.add("yem_es_salesorder_ZJ");
        strArray.add("yem_es_salesorder_PJ");
        QFilter qFilter = new QFilter("org.id", QCP.equals, org).and(new QFilter("yem_customer.id", QCP.equals, customer)).and(new QFilter("yem_billtype.number", QCP.in, strArray)).and(new QFilter("billstatus", QCP.equals, "C"));
        e.setPlugFilter(qFilter);
    }
}
