增加 交接班

master
wanghao 4 months ago
parent c5e5c3fd22
commit f17efc3484

@ -1,14 +1,92 @@
package com.example.haiwei_mom;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;
public class ClassItemActivity extends AppCompatActivity {
import com.example.haiwei_mom.base.BaseActivity;
import com.example.haiwei_mom.base.MyRecultCall;
import com.example.haiwei_mom.base.MyResult;
import com.example.haiwei_mom.data.TeamInfoVo;
import com.example.haiwei_mom.databinding.ActivityClassItemBinding;
import com.example.haiwei_mom.uitls.SharedPreferencesUtils;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import okhttp3.RequestBody;
public class ClassItemActivity extends BaseActivity {
private List<String> classList;
private List<String> shiftList;
private ActivityClassItemBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_class_item);
binding = DataBindingUtil.setContentView(this, R.layout.activity_class_item);
binding.setDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
selectShiftInfo();
}
private List<TeamInfoVo> list;
// 获取班次
private void selectShiftInfo() {
OkGo.<MyResult>post(url + "/wms/pda/selectTeams").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<TeamInfoVo>>() {
}.getType());
classList = new ArrayList<>();
shiftList = new ArrayList<>();
list.forEach(teamInfoVo -> {
if (teamInfoVo.getType().equals("班组")) {
classList.add(teamInfoVo.getTeamName());
} else {
shiftList.add(teamInfoVo.getTeamName());
}
});
binding.setList1(classList);
binding.setList2(shiftList);
}
}
});
}
public void classSubmit(View view) {
String shiftText = binding.spinner2.getSelectedItem().toString();
String classText = binding.spinner1.getSelectedItem().toString();
Optional<Long> shiftId = list.stream().filter(t -> t.getTeamName().equals(shiftText)).map(TeamInfoVo::getTeamId).findFirst();
Optional<Long> classTeamId = list.stream().filter(t -> t.getTeamName().equals(classText)).map(TeamInfoVo::getTeamId).findFirst();
OkGo.<MyResult>post(url + "/wms/pda/shiftChangeSubmit")
.params("shiftId", shiftId.get())
.params("classTeamId",classTeamId.get() )
.params("userName", SharedPreferencesUtils.getstring("nickname", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 200) {
finish();
return;
}
myToastUitls.show(body.getMsg());
}
});
}
}

@ -83,13 +83,16 @@ public class MainActivity extends BaseActivity {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 200) {
String accessToken = JSONObject.parseObject(body.getDataJson()).get("access_token").toString();
JSONObject jsonObject = JSONObject.parseObject(body.getDataJson());
String accessToken = jsonObject.get("access_token").toString();
MyApplication.getApplication().setAccessToken("Bearer "+accessToken);
boolean remember = loginVm.isRemember();
if (remember) {
SharedPreferencesUtils.putboolean("isRemember", remember);
SharedPreferencesUtils.putstring("user", name);
SharedPreferencesUtils.putstring("pass", pass);
SharedPreferencesUtils.putstring("nickname", jsonObject.get("nickname").toString());
}
Intent intent = new Intent(MainActivity.this, HomePageActivity.class);
startActivity(intent);

@ -50,6 +50,7 @@ public class BaseActivity extends AppCompatActivity implements MyScannerCall {
public MyToastUitls myToastUitls;
@SuppressLint("SimpleDateFormat")
public SimpleDateFormat format= new SimpleDateFormat( "yyyyMMdd_HHmmss");
// public SimpleDateFormat dateFormat= new SimpleDateFormat( "yyyy-MM-dd");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

@ -0,0 +1,33 @@
package com.example.haiwei_mom.data;
public class TeamInfoVo {
private Long teamId;
private String teamName;
private String type;
public Long getTeamId() {
return teamId;
}
public void setTeamId(Long teamId) {
this.teamId = teamId;
}
public String getTeamName() {
return teamName;
}
public void setTeamName(String teamName) {
this.teamName = teamName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

@ -1,131 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ClassItemActivity">
xmlns:tools="http://schemas.android.com/tools">
<include layout="@layout/toolbar"
app:title='@{title??"班组"}'/>
<data>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="45dp"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginEnd="4dp">-->
<variable
name="title"
type="String" />
<!-- <TextView-->
<!-- style="@style/text_title"-->
<!-- android:layout_width="100dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="公司编号:" />-->
<variable
name="date"
type="String" />
<!-- <TextView-->
<!-- style="@style/text_info"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="@{been.companyCode}" />-->
<!-- </LinearLayout>-->
<import type="com.example.haiwei_mom.uitls.SharedPreferencesUtils" />
<variable
name="list1"
type="java.util.List" />
<variable
name="list2"
type="java.util.List" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ClassItemActivity">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="公司名称:" />
<include
layout="@layout/toolbar"
app:title='@{title??"班组管理"}' />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{been.companyName}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="工厂编号:" />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{been.factoryCode}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="工厂名称:" />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{been.factoryName}" />
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="45dp"-->
<!-- android:layout_marginTop="8dp"-->
<!-- android:layout_marginEnd="4dp"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent">-->
<!-- <TextView-->
<!-- style="@style/text_title"-->
<!-- android:layout_width="100dp"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="班组编号:" />-->
<!-- <TextView-->
<!-- style="@style/text_info"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="@{user.teamCode}" />-->
<!-- </LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="班组名称:" />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{user.teamName}" />
</LinearLayout>
<LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
@ -135,56 +46,100 @@
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="用户号:" />
android:text="用户号:" />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{user.username}" />
android:text='@{SharedPreferencesUtils.getstring("user","")}' />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="用户名称:" />
<TextView
style="@style/text_info"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{user.nickName}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="选择班组:" />
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="用户名称:" />
<Spinner
style="@style/spinner_style"
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text='@{SharedPreferencesUtils.getstring("nickname","")}' />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{user.nickName}"
android:entries="@array/class_item"/>
</LinearLayout>
android:layout_height="45dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<Button
style="@style/button_submit"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:text="接班" />
</LinearLayout>
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="日期:" />
<TextView
style="@style/text_info"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@{date}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="选择班组:" />
<Spinner
android:id="@+id/spinner1"
style="@style/spinner_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@{list1}" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_title"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="选择班次:" />
<Spinner
android:id="@+id/spinner2"
style="@style/spinner_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@{list2}" />
</LinearLayout>
<Button
style="@style/button_submit"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center"
android:onClick="classSubmit"
android:text="接班" />
</LinearLayout>
</layout>
Loading…
Cancel
Save