package com.wd.workoffice.ui.activity.mes.order;

import android.os.Bundle;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseMesBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.mesBean.MesOrderDetailBean;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;

import butterknife.BindView;
import butterknife.ButterKnife;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import io.reactivex.disposables.Disposable;

/**
 * 订单追踪 详情
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class MesOrderDetailActivity extends WorkToolBarActivity {

    @BindView(R.id.tv_content1)
    TextView tvContent1;
    @BindView(R.id.tv_content2)
    TextView tvContent2;
    @BindView(R.id.tv_content3)
    TextView tvContent3;
    @BindView(R.id.tv_content4)
    TextView tvContent4;
    @BindView(R.id.tv_content5)
    TextView tvContent5;
    @BindView(R.id.tv_content6)
    TextView tvContent6;
    @BindView(R.id.tv_content7)
    TextView tvContent7;
    @BindView(R.id.tv_content8)
    TextView tvContent8;
    @BindView(R.id.tv_content9)
    TextView tvContent9;
    @BindView(R.id.tv_content10)
    TextView tvContent10;
    @BindView(R.id.tv_content11)
    TextView tvContent11;
    @BindView(R.id.tv_content12)
    TextView tvContent12;
    @BindView(R.id.tv_content14)
    TextView tvContent14;
    @BindView(R.id.tv_content15)
    TextView tvContent15;
    @BindView(R.id.tv_content16)
    TextView tvContent16;
    @BindView(R.id.tv_content17)
    TextView tvContent17;
    @BindView(R.id.tv_content18)
    TextView tvContent18;
    @BindView(R.id.tv_content19)
    TextView tvContent19;
    @BindView(R.id.tv_content20)
    TextView tvContent20;
    @BindView(R.id.tv_content21)
    TextView tvContent21;
    @BindView(R.id.tv_content22)
    TextView tvContent22;
    @BindView(R.id.tv_content23)
    TextView tvContent23;
    @BindView(R.id.tv_content13)
    TextView tvContent13;
    @BindView(R.id.tv_content24)
    TextView tvContent24;
    @BindView(R.id.tv_content25)
    TextView tvContent25;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
    }

    @Override
    protected void initData() {
        getData();
    }

    @Override
    protected void initEvent() {
    }

    private void getData() {
        RtfUtils.getMesRtf().orderDetail(getIntent().getStringExtra("id")).compose(Transformer.schedule()).subscribe(new WorkObserver<BaseMesBean>() {
            @Override
            public void doOnSubscribe(Disposable d) {
            }

            @Override
            public void onFail(String errorMsg) {
                hideLoading();
                toast(errorMsg);
            }

            @Override
            public void onSuccess(BaseMesBean data) {
                hideLoading();
                if (!data.isSuccess()) {
                    toast(data.getMessage());
                    return;
                }
                MesOrderDetailBean mesOrderDetailBean = JSON.parseObject(data.getData().toString(), MesOrderDetailBean.class);
                tvContent1.setText(mesOrderDetailBean.getCustomerName());
                tvContent2.setText(mesOrderDetailBean.getManufactureOrderNumber());
                tvContent3.setText(mesOrderDetailBean.getDrawingNumber());
                tvContent4.setText(mesOrderDetailBean.getProcessCode());
                tvContent5.setText(mesOrderDetailBean.getOrderNumber());
                tvContent6.setText(mesOrderDetailBean.getWeight());
                tvContent7.setText(mesOrderDetailBean.getActualUnitWeight());
                tvContent8.setText(mesOrderDetailBean.getPlanCount());
                tvContent9.setText(mesOrderDetailBean.getDeliveryDate());
                tvContent10.setText(mesOrderDetailBean.getOpComDate());


                tvContent11.setText(mesOrderDetailBean.getCxNum());

                tvContent12.setText(mesOrderDetailBean.getGhNum());
                tvContent13.setText(mesOrderDetailBean.getJgNum());
                tvContent14.setText(mesOrderDetailBean.getPtNum());
                tvContent15.setText(mesOrderDetailBean.getScNum());
                tvContent16.setText(mesOrderDetailBean.getTsNum());
                tvContent17.setText(mesOrderDetailBean.getFjNum());
                tvContent18.setText(mesOrderDetailBean.getWasteCount());
                tvContent19.setText(mesOrderDetailBean.getActualQuantity());
                tvContent20.setText(mesOrderDetailBean.getEndTime());
                tvContent21.setText(mesOrderDetailBean.getDifferenceNum());
                tvContent22.setText(mesOrderDetailBean.getPeriodDays());
                tvContent23.setText(mesOrderDetailBean.getNoOperateNum());
                tvContent24.setText(mesOrderDetailBean.getNoWarehouseNum());
                tvContent25.setText(mesOrderDetailBean.getOnLineNum());

            }
        });
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_mes_order_detail;
    }

}
