package com.example.administrator.zhapp.activity.ydckgl;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.BaseActivity;
import com.example.administrator.zhapp.entity.WebServiceResult;
import com.example.administrator.zhapp.utils.GsonUtils;
import com.example.administrator.zhapp.utils.KsoapUtils;
import com.example.administrator.zhapp.utils.UiUtlis;
import com.example.administrator.zhapp.weight.WaitDialog;
import java.util.ArrayList;
import java.util.List;


public class ServiceTestActivity extends BaseActivity {
    Button button2;
    TextView textView6;

    @Override
    public int getContentViewID() {
        return R.layout.activity_servicetest;
    }

    @Override
    protected void initView() {
        button2 = findViewById(R.id.button2);
        textView6 = findViewById(R.id.textView6);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                matrRec();
            }
        });

    }

    @Override
    protected void initData() {

    }

    private void matrRec() {

        List<String> properties = new ArrayList<>();
        properties.add("A011016");//采购单号
        properties.add("100003");//物资编码
        properties.add("");//目标货柜
        properties.add("1");//检验数量
        properties.add("maxadmin");
        properties.add("1");

        final WaitDialog dialog = new WaitDialog(context, "保存中...");
        dialog.show();

        KsoapUtils.callWebService("http://121.196.186.144:7001/eamwebservice/services/MatrSer", "matrRec", properties, result -> {
            dialog.dismiss();
            if (result != null) {
                WebServiceResult webServiceResult = GsonUtils.GsonToBean(result.getProperty(0).toString(), WebServiceResult.class);
                if (webServiceResult.getStatus().equals("success")) {
                    showToast("保存成功");
                } else {
                    showToast("保存失败");
                }
                textView6.setText(webServiceResult.toString());
            } else {
                showToast(UiUtlis.getString(context, R.string.data_error));
            }
        });
    }
}
