package com.yem.tws.chart;
import kd.bos.algo.DataSet;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.orm.ORM;
import kd.bos.servicehelper.QueryServiceHelper;
import java.util.*;
/**
 * 查数据
 */
public class Widget extends AbstractBillPlugIn {
    @Override
    public void afterCreateNewData(EventObject e) {
        String selectFiles = "billno yem_text,"
                + "yem_ca_cdstatusentry.yem_channel yem_cusdecstatusname,"
                + "yem_fddatets yem_fddatets,"
                + " yem_cusdecstatusname yem_channelname";
        DataSet queryDataSet = ORM.create().queryDataSet(this.getClass().getName(), "yem_ca_cusdec", selectFiles, null)
                .select(new String[] {"yem_text","yem_cusdecstatusname","yem_fddatets","yem_channelname"})
                .orderBy(new String[] {"yem_fddatets desc"});
        DynamicObjectCollection dc = ORM.create().toPlainDynamicObjectCollection(queryDataSet);
        DynamicObjectCollection dynamic = QueryServiceHelper.query("yem_ca_cusdec", "yem_cusdecstatusname", null);
        for (DynamicObject temp : dc) {
            int newEntryRow = this.getModel().createNewEntryRow("yem_entryentity");
            String text = (String) temp.get(0);
            String channel = (String) temp.get(1);
            Date fddatets = (Date) temp.get(2);
            String cusdecstatusname = (String) temp.get(3);
            this.getModel().setValue("yem_text", text,newEntryRow);
            if("7".equals(channel)){
                this.getModel().setValue("yem_cusdecstatusname", "申报成功", newEntryRow);
            }else if("L".equals(channel)){
                this.getModel().setValue("yem_cusdecstatusname", "海关入库", newEntryRow);
            }else if("J".equals(channel)){
                this.getModel().setValue("yem_cusdecstatusname", "审结", newEntryRow);
            }else if("P".equals(channel)){
                this.getModel().setValue("yem_cusdecstatusname", "放行", newEntryRow);
            }else if("R".equals(channel)){
                this.getModel().setValue("yem_cusdecstatusname", "结关", newEntryRow);
            }
            this.getModel().setValue("yem_fddatets", fddatets, newEntryRow);
            this.getModel().setValue("yem_channelname", cusdecstatusname, newEntryRow);
        }
        this.getModel().setValue("yem_textfield3",dc.size());
        this.getModel().setValue("yem_textfield1",dynamic.size());
    }
}
