|
|
|
@ -1,19 +1,18 @@
|
|
|
|
|
package com.example.aucma_mes;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.databinding.DataBindingUtil;
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.example.aucma_mes.adapter.CheckAdapter;
|
|
|
|
|
import com.example.aucma_mes.adapter.RepairAdapter;
|
|
|
|
|
import com.example.aucma_mes.base.BaseActivity;
|
|
|
|
|
import com.example.aucma_mes.databinding.ActivityMainBinding;
|
|
|
|
|
import com.example.aucma_mes.databinding.ActivityRepairBinding;
|
|
|
|
|
import com.example.aucma_mes.entity.DefectBeen;
|
|
|
|
|
import com.example.aucma_mes.entity.RepairSubmitInfo;
|
|
|
|
|
import com.example.aucma_mes.entity.RepairMeasures;
|
|
|
|
|
import com.example.aucma_mes.entity.Result;
|
|
|
|
|
import com.example.aucma_mes.utils.MyRecultCall;
|
|
|
|
@ -26,12 +25,16 @@ import com.lzy.okgo.model.Response;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class RepairActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall {
|
|
|
|
|
import okhttp3.MediaType;
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
|
|
|
|
|
public class RepairActivity extends BaseActivity {
|
|
|
|
|
private ActivityRepairBinding binding;
|
|
|
|
|
private RepairVm repairVm;
|
|
|
|
|
private RepairAdapter adapter;
|
|
|
|
|
|
|
|
|
|
private List<DefectBeen> defectBeens;
|
|
|
|
|
private List<Integer> submitList;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -40,20 +43,21 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt
|
|
|
|
|
adapter = new RepairAdapter(this);
|
|
|
|
|
repairVm = new RepairVm();
|
|
|
|
|
binding.setVm(repairVm);
|
|
|
|
|
submitList = new ArrayList<>();
|
|
|
|
|
binding.recyclerView.setAdapter(adapter);
|
|
|
|
|
//查询返修措施
|
|
|
|
|
OkGo.<Result>get(url + "/report/repairMeasures/getRepairMeasures").tag(this)
|
|
|
|
|
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<Result> response) {
|
|
|
|
|
Result result = response.body();
|
|
|
|
|
if (result.getCode()==200){
|
|
|
|
|
Log.e("TAG", "真实类型:" + result.getData().getClass());
|
|
|
|
|
List<RepairMeasures> repairList=gson.fromJson(gson.toJson(result.getData())
|
|
|
|
|
,new TypeToken< List<RepairMeasures>>(){}.getType());
|
|
|
|
|
if (result.getCode() == 200) {
|
|
|
|
|
List<RepairMeasures> repairList = gson.fromJson(gson.toJson(result.getData())
|
|
|
|
|
, new TypeToken<List<RepairMeasures>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
repairVm.setRepairList(repairList);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -65,18 +69,21 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt
|
|
|
|
|
repairVm.setCode(code);
|
|
|
|
|
OkGo.<Result>post(url + "/api/findCheckInfoByCode").tag(this)
|
|
|
|
|
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
|
|
|
|
|
.params("code",code)
|
|
|
|
|
.params("code", code)
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<Result> response) {
|
|
|
|
|
Result result = response.body();
|
|
|
|
|
if (result.getCode()==200){
|
|
|
|
|
|
|
|
|
|
defectBeens = gson.fromJson(result.getData().toString()
|
|
|
|
|
,new TypeToken<List<DefectBeen>>(){}.getType());
|
|
|
|
|
if (result.getCode() == 200) {
|
|
|
|
|
defectBeens = gson.fromJson(result.getData().toString(), new TypeToken<List<DefectBeen>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
// Log.e("TAG", "onSuccess:" + defectBeens.toString());
|
|
|
|
|
defectBeens.forEach(t -> submitList.add(t.getObjId()));
|
|
|
|
|
adapter.setList(defectBeens);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
}else {
|
|
|
|
|
repairVm.setMaterialName(defectBeens.get(0).getMaterialName());
|
|
|
|
|
} else {
|
|
|
|
|
Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
repairSubmit(null);
|
|
|
|
|
}
|
|
|
|
@ -85,13 +92,31 @@ public class RepairActivity extends BaseActivity implements CheckAdapter.CheckIt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void repairSubmit(View view) {
|
|
|
|
|
if (submitList.isEmpty()) return;
|
|
|
|
|
RepairSubmitInfo repairSubmitInfo =new RepairSubmitInfo(submitList,
|
|
|
|
|
SharedPreferencesUtils.getstring("userName", "pda01")
|
|
|
|
|
,repairVm.getRepairName(),repairVm.getIsFlag());
|
|
|
|
|
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
|
RequestBody body = RequestBody.create(JSON,gson.toJson(repairSubmitInfo) );
|
|
|
|
|
OkGo.<Result>post(url + "/api/submitRepair")
|
|
|
|
|
.tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
|
|
|
|
|
.upRequestBody(body)
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<Result> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
Result result = response.body();
|
|
|
|
|
Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
if (result.getCode()==200){
|
|
|
|
|
defectBeens.clear();
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
repairVm.setCode(null);
|
|
|
|
|
repairVm.setMaterialName(null);
|
|
|
|
|
submitList.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(int positon) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|