增加 - 提交产量和时间

master
wanghao 1 week ago
parent 109ad55e4b
commit 2589c43234

@ -19,6 +19,9 @@
android:theme="@style/Theme.Aucmames"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".run_state.SubInfoActivity"
android:exported="false" />
<activity
android:name=".run_state.DeviceStopRecordActivity"
android:exported="false" />
@ -90,7 +93,6 @@
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

@ -15,6 +15,7 @@ import com.example.aucma_mes.dialog.InfoDialog;
import com.example.aucma_mes.entity.LoginInfoBeen;
import com.example.aucma_mes.run_state.DeviceStopActivity;
import com.example.aucma_mes.run_state.DeviceStopRecordActivity;
import com.example.aucma_mes.run_state.SubInfoActivity;
import com.example.aucma_mes.service.MyService;
import com.example.aucma_mes.utils.SharedPreferencesUtils;
import com.example.aucma_mes.vm.User;
@ -162,11 +163,17 @@ public class HomePageActivity extends AppCompatActivity {
startActivity(intent);
});
// binding.homeButton15.setOnClickListener(v -> {
// intent = new Intent(this, LubricationActivity.class);
// startActivity(intent);
//
// });
Intent intent2 = new Intent(this, SubInfoActivity.class);
binding.homeButton15.setOnClickListener(v -> {
intent2.putExtra("type", true);
startActivity(intent2);
});
binding.homeButton16.setOnClickListener(v -> {
intent2.putExtra("type", false);
startActivity(intent2);
});
} catch (Exception e) {

@ -45,9 +45,9 @@ import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity {
private MyBroad receiver;
// public static String url="http://10.11.187.161:6061";
public static String url="http://10.11.187.161:6061";
// public static String url = "http://10.100.72.10:8080";//河南现场IP
public static String url = "http://10.100.70.50:8080";//黄岛现场IP
// public static String url = "http://10.100.70.50:8080";//黄岛现场IP
public ProgressDialog dialog;
public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");

@ -14,6 +14,15 @@ public class DeviceBeen {
private Long deviceTypeId;
private String deviceSpec;
private int deviceStatus;
private String paramValue;
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public Long getDeviceId() {
return deviceId;

@ -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();
}
});
}
}

@ -37,7 +37,7 @@
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:columnCount="2"
app:columnCount="3"
app:rowCount="2">
<RadioButton
@ -141,6 +141,20 @@
android:text="停机记录"
app:layout_columnWeight="1" />
<RadioButton
android:id="@+id/home_button15"
style="@style/radio_button_style"
android:drawableTop="@mipmap/icon_sub"
android:text="提交产量"
app:layout_columnWeight="1" />
<RadioButton
android:id="@+id/home_button16"
style="@style/radio_button_style"
android:drawableTop="@mipmap/icon_sub"
android:text="提交运行时间"
app:layout_columnWeight="1" />
<!-- <RadioButton
android:id="@+id/home_button14"
style="@style/radio_button_style"

@ -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…
Cancel
Save