增加 交接班
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue