增加 - 提交产量和时间
parent
109ad55e4b
commit
2589c43234
@ -0,0 +1,99 @@
|
|||||||
|
package com.example.aucma_mes.run_state;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.databinding.DataBindingUtil;
|
||||||
|
|
||||||
|
import com.example.aucma_mes.R;
|
||||||
|
import com.example.aucma_mes.base.BaseActivity;
|
||||||
|
import com.example.aucma_mes.base.MyRecultCall;
|
||||||
|
import com.example.aucma_mes.base.MyResult;
|
||||||
|
import com.example.aucma_mes.databinding.ActivitySubInfoBinding;
|
||||||
|
import com.example.aucma_mes.entity.device.DeviceBeen;
|
||||||
|
import com.example.aucma_mes.utils.SharedPreferencesUtils;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.lzy.okgo.OkGo;
|
||||||
|
import com.lzy.okgo.model.Response;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
|
public class SubInfoActivity extends BaseActivity {
|
||||||
|
private ActivitySubInfoBinding binding;
|
||||||
|
private String uri;
|
||||||
|
private List<DeviceBeen> list;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_sub_info);
|
||||||
|
initSelect();
|
||||||
|
|
||||||
|
boolean type = getIntent().getBooleanExtra("type", true);
|
||||||
|
binding.setType(type);
|
||||||
|
if (type) {
|
||||||
|
binding.setTitle("提交产量");
|
||||||
|
uri = "/dms/mobile/device/updateDailyOutput";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
binding.setTitle("提交运行时间");
|
||||||
|
uri = "/dms/mobile/device/updateRunTime";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void sanInfo(String code) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSelect() {
|
||||||
|
OkGo.<MyResult>get(url + "/dms/mobile/device/getDevices").tag(this).execute(new MyRecultCall(dialog, this) {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Response<MyResult> response) {
|
||||||
|
super.onSuccess(response);
|
||||||
|
var body = response.body();
|
||||||
|
if (body.getCode() == 200) {
|
||||||
|
|
||||||
|
list = gson.fromJson(body.getDataJson(), new TypeToken<List<DeviceBeen>>() {
|
||||||
|
}.getType());
|
||||||
|
|
||||||
|
List<String> tagList = new ArrayList<>(list.size());
|
||||||
|
list.forEach(deviceBeen -> tagList.add(deviceBeen.getDeviceName()));
|
||||||
|
binding.setDeviceStringS(tagList);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void subSubmit(View view) {
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
Toast.makeText(context, "请先获取设备列表", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DeviceBeen deviceBeen = list.get((int) binding.subSelect.getSelectedItemId());
|
||||||
|
|
||||||
|
deviceBeen.setParamValue(binding.subParamValue.getText().toString());
|
||||||
|
|
||||||
|
OkGo.<MyResult>post(url + uri).tag(this)
|
||||||
|
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
|
||||||
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(deviceBeen)))
|
||||||
|
.execute(new MyRecultCall(dialog, this) {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Response<MyResult> response) {
|
||||||
|
super.onSuccess(response);
|
||||||
|
var body = response.body();
|
||||||
|
if (body.getCode() == 200) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
Toast.makeText(context, "提交成功", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<variable
|
||||||
|
name="title"
|
||||||
|
type="String" />
|
||||||
|
<variable
|
||||||
|
name="device"
|
||||||
|
type="com.example.aucma_mes.entity.device.DeviceBeen" />
|
||||||
|
<variable
|
||||||
|
name="type"
|
||||||
|
type="Boolean" />
|
||||||
|
<variable
|
||||||
|
name="deviceStringS"
|
||||||
|
type="java.util.List" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@color/activity_bg"
|
||||||
|
tools:context=".run_state.SubInfoActivity">
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/toolbar"
|
||||||
|
app:title='@{title}' />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
|
||||||
|
android:background="@drawable/text_bg">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_title"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/activity_bg"
|
||||||
|
android:text="选择设备:" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/sub_select"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:entries="@{deviceStringS}"
|
||||||
|
|
||||||
|
android:spinnerMode="dropdown"
|
||||||
|
android:textAlignment="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- <LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="4dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_title"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="设备编码:" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_info"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@{device.deviceCode}" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="4dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_title"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="设备名称:" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_info"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@{device.deviceName}" />
|
||||||
|
|
||||||
|
</LinearLayout>-->
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginEnd="4dp"
|
||||||
|
android:background="@drawable/text_bg">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
style="@style/text_title"
|
||||||
|
android:layout_width="90dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/activity_bg"
|
||||||
|
android:text='@{type? "输入产量:" : "输入时长:"}' />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/sub_paramValue"
|
||||||
|
style="@style/san_text_style"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@{device.paramValue}" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style="@style/button_style"
|
||||||
|
android:layout_width="380dp"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:onClick="subSubmit"
|
||||||
|
android:text="提交"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
Loading…
Reference in New Issue