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

import android.text.TextUtils;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.mesBean.ServiceStandardBean;
import com.wd.workoffice.util.MathUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class ServiceStandardDetailActivity extends WorkToolBarActivity {

    @BindView(R.id.tv_process_standard)
    TextView tvProcessStandard;
    @BindView(R.id.tv_num_a)
    TextView tvNumA;
    @BindView(R.id.tv_num_b)
    TextView tvNumB;
    @BindView(R.id.tv_num_c)
    TextView tvNumC;
    @BindView(R.id.tv_measurement_unit)
    TextView tvMeasurementUnit;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.tv_failure_code)
    TextView tvFailureCode;
    @BindView(R.id.tv_desc)
    TextView tvDesc;
    @BindView(R.id.tv_remark)
    TextView tvRemark;
    private ServiceStandardBean.ListBean info;

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

    @Override
    protected void initData() {
        info = JSON.parseObject(getIntent().getStringExtra("info"), ServiceStandardBean.ListBean.class);
        changeView();

    }

    private void changeView() {
        if (TextUtils.isEmpty(getIntent().getStringExtra("type"))){
            tvDesc.setText(info.getDescription());
            tvFailureCode.setText(info.getFailureCode());
            tvMeasurementUnit.setText(info.getMeasurementUnit());
            tvNumA.setText(MathUtils.converData(info.getNumA(),3));
            tvNumB.setText(MathUtils.converData(info.getNumB(),3));
            tvNumC.setText(MathUtils.converData(info.getNumC(),3));
            tvProcessStandard.setText(info.getProcessStandard());
            tvStatus.setText(TextUtils.equals(info.getStatus(), "1") ? "异常" : "正常");//1 异常 0正常
            tvRemark.setText(info.getRemarks());
        }else {
            tvDesc.setText(info.getInspoProDescription());
            tvFailureCode.setText(info.getReportCode());
            tvMeasurementUnit.setText(info.getUint());
            tvNumA.setText(MathUtils.converData(info.getNumA(),3));
            tvNumB.setText(MathUtils.converData(info.getNumB(),3));
            tvNumC.setText(MathUtils.converData(info.getNumC(),3));
            tvProcessStandard.setText(info.getProcessStandard());
            tvStatus.setText(TextUtils.equals(info.getStatus(), "1") ? "异常" : "正常");//1 异常 0正常
            tvRemark.setText(info.getRemarks());
        }
    }


    @Override
    protected void initEvent() {
    }


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