|
|
|
@ -9,72 +9,94 @@ import androidx.databinding.DataBindingUtil;
|
|
|
|
|
|
|
|
|
|
import com.example.haiwei_mom.R;
|
|
|
|
|
import com.example.haiwei_mom.adapter.check.CheckWorkAdapter;
|
|
|
|
|
import com.example.haiwei_mom.adapter.check.DisposalFileAdapter;
|
|
|
|
|
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.check.CheckInstanceFiles;
|
|
|
|
|
import com.example.haiwei_mom.data.check.CheckResult;
|
|
|
|
|
import com.example.haiwei_mom.data.check.CheckResultDetal;
|
|
|
|
|
|
|
|
|
|
import com.example.haiwei_mom.data.check.QcInspectionMain;
|
|
|
|
|
import com.example.haiwei_mom.data.check.QcInspectionResult;
|
|
|
|
|
import com.example.haiwei_mom.databinding.ActivityCheckBinding;
|
|
|
|
|
import com.example.haiwei_mom.dialog.ImgDialog;
|
|
|
|
|
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.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
|
|
|
|
|
public class CheckActivity extends BaseActivity {
|
|
|
|
|
public class CheckActivity extends BaseActivity implements DisposalFileAdapter.ItemClickCall {
|
|
|
|
|
private CheckWorkAdapter adapter;
|
|
|
|
|
private ActivityCheckBinding binding;
|
|
|
|
|
private CheckResult checkResult;
|
|
|
|
|
|
|
|
|
|
private QcInspectionMain checkResult;
|
|
|
|
|
private DisposalFileAdapter adapter1;
|
|
|
|
|
private List<CheckInstanceFiles> filesList;
|
|
|
|
|
private List<File> files;
|
|
|
|
|
private ImgDialog imgDialog;
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_check);
|
|
|
|
|
adapter = new CheckWorkAdapter(this);
|
|
|
|
|
adapter.setEnabledState(true);
|
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
|
var intent = getIntent();
|
|
|
|
|
var id = intent.getStringExtra("id");
|
|
|
|
|
if (id != null) {
|
|
|
|
|
var visble = intent.getBooleanExtra("visble", true);
|
|
|
|
|
binding.checkSearchLinear.setVisibility(View.GONE);
|
|
|
|
|
Log.e("TAG", "传值:" + visble);
|
|
|
|
|
searchRequest(null, id, visble);
|
|
|
|
|
}
|
|
|
|
|
checkResult= (QcInspectionMain) intent.getSerializableExtra("checkResult");
|
|
|
|
|
binding.setVm(checkResult);
|
|
|
|
|
searchRequest(checkResult.getInspectionId());
|
|
|
|
|
|
|
|
|
|
adapter1 = new DisposalFileAdapter(this, this);
|
|
|
|
|
filesList = new ArrayList<>();
|
|
|
|
|
files = new ArrayList<>();
|
|
|
|
|
adapter1.setList(filesList);
|
|
|
|
|
binding.setAdapter1(adapter1);
|
|
|
|
|
imgDialog = new ImgDialog(this);
|
|
|
|
|
|
|
|
|
|
// var id = intent.getStringExtra("id");
|
|
|
|
|
// if (id != null) {
|
|
|
|
|
// var visble = intent.getBooleanExtra("visble", true);
|
|
|
|
|
// binding.checkSearchLinear.setVisibility(View.GONE);
|
|
|
|
|
// Log.e("TAG", "传值:" + visble);
|
|
|
|
|
// searchRequest(null, id, visble);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// 提交
|
|
|
|
|
public void checkSubmit(View view) {
|
|
|
|
|
checkResult.setMaterialBarcode(binding.checkSearchText.getText().toString());
|
|
|
|
|
OkGo.<MyResult>post(url + "/qms/mobile/saveCheckResultDetail")
|
|
|
|
|
.headers("Authorization", SharedPreferencesUtils.getstring("access_token", ""))
|
|
|
|
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(checkResult)))
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getCode() == 200) {
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myToastUitls.show( body.getMsg());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// checkResult.setMaterialBarcode(binding.checkSearchText.getText().toString());
|
|
|
|
|
// OkGo.<MyResult>post(url + "/qms/mobile/saveCheckResultDetail")
|
|
|
|
|
// .headers("Authorization", SharedPreferencesUtils.getstring("access_token", ""))
|
|
|
|
|
// .upRequestBody(RequestBody.create(JSON, gson.toJson(checkResult)))
|
|
|
|
|
// .execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
// super.onSuccess(response);
|
|
|
|
|
// var body = response.body();
|
|
|
|
|
// if (body.getCode() == 200) {
|
|
|
|
|
// finish();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// myToastUitls.show( body.getMsg());
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void checkSearch(View view) {
|
|
|
|
|
var serchText = binding.checkSearchText.getText().toString();
|
|
|
|
|
searchRequest(serchText, null, true);
|
|
|
|
|
// var serchText = binding.checkSearchText.getText().toString();
|
|
|
|
|
// searchRequest(serchText, null, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void searchRequest(String serchText, String id, boolean status) {
|
|
|
|
|
OkGo.<MyResult>get(url + "/qms/mobile/getCheckResultDetail")
|
|
|
|
|
.headers("Authorization", SharedPreferencesUtils.getstring("access_token", ""))
|
|
|
|
|
.params("materialBarcode", serchText)
|
|
|
|
|
.params("checkResultDetailId", id)
|
|
|
|
|
private void searchRequest( Long id) {
|
|
|
|
|
OkGo.<MyResult>get(url + "/qms/qcMobile/getResultList")
|
|
|
|
|
.params("inspectionId", id)
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
@ -82,29 +104,61 @@ public class CheckActivity extends BaseActivity {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getCode() == 200) {
|
|
|
|
|
checkResult = gson.fromJson(body.getData().toString(), CheckResult.class);
|
|
|
|
|
checkResult.setVisbleStatus(status);
|
|
|
|
|
binding.setVm(checkResult);
|
|
|
|
|
List<CheckResultDetal> qmsCheckResultDetailProjectList;
|
|
|
|
|
|
|
|
|
|
qmsCheckResultDetailProjectList = checkResult.getQmsCheckResultDetailProjectList();
|
|
|
|
|
if (qmsCheckResultDetailProjectList == null || qmsCheckResultDetailProjectList.isEmpty()) {
|
|
|
|
|
qmsCheckResultDetailProjectList = new ArrayList<>();
|
|
|
|
|
var qmsCheckRuleProjectList = checkResult.getQmsCheckRuleProjectList();
|
|
|
|
|
qmsCheckResultDetailProjectList.addAll(qmsCheckRuleProjectList);
|
|
|
|
|
checkResult.setQmsCheckResultDetailProjectList(qmsCheckResultDetailProjectList);
|
|
|
|
|
}
|
|
|
|
|
adapter.setEnabledState(status);
|
|
|
|
|
adapter.setList(qmsCheckResultDetailProjectList);
|
|
|
|
|
List<QcInspectionResult> list=gson.fromJson(body.getDataJson(),new TypeToken<List<QcInspectionResult>>(){}.getType());
|
|
|
|
|
// checkResult = gson.fromJson(body.getData().toString(), CheckResult.class);
|
|
|
|
|
// checkResult.setVisbleStatus(status);
|
|
|
|
|
// binding.setVm(checkResult);
|
|
|
|
|
// List<CheckResultDetal> qmsCheckResultDetailProjectList;
|
|
|
|
|
//
|
|
|
|
|
// qmsCheckResultDetailProjectList = checkResult.getQmsCheckResultDetailProjectList();
|
|
|
|
|
// if (qmsCheckResultDetailProjectList == null || qmsCheckResultDetailProjectList.isEmpty()) {
|
|
|
|
|
// qmsCheckResultDetailProjectList = new ArrayList<>();
|
|
|
|
|
// var qmsCheckRuleProjectList = checkResult.getQmsCheckRuleProjectList();
|
|
|
|
|
// qmsCheckResultDetailProjectList.addAll(qmsCheckRuleProjectList);
|
|
|
|
|
// checkResult.setQmsCheckResultDetailProjectList(qmsCheckResultDetailProjectList);
|
|
|
|
|
// }
|
|
|
|
|
// adapter.setEnabledState(status);
|
|
|
|
|
adapter.setList(list);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
} else {
|
|
|
|
|
binding.setVm(null);
|
|
|
|
|
adapter.setList(null);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
myToastUitls.show( body.getMsg());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// binding.setVm(null);
|
|
|
|
|
// adapter.setList(null);
|
|
|
|
|
// adapter.notifyDataSetChanged();
|
|
|
|
|
myToastUitls.show( body.getMsg());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
public void tackphoto(View view) {
|
|
|
|
|
try {
|
|
|
|
|
teke_photo();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void tekePhotoResult(String fileUrl, File file) {
|
|
|
|
|
super.tekePhotoResult(fileUrl, file);
|
|
|
|
|
CheckInstanceFiles checkInstanceFiles = new CheckInstanceFiles();
|
|
|
|
|
checkInstanceFiles.setFaultFile(fileUrl);
|
|
|
|
|
checkInstanceFiles.setState(true);
|
|
|
|
|
filesList.add(checkInstanceFiles);
|
|
|
|
|
adapter1.notifyDataSetChanged();
|
|
|
|
|
files.add(file);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(int position, boolean type) {
|
|
|
|
|
if (type) {
|
|
|
|
|
imgDialog.setRawReturn(filesList.get(position).getFaultFile());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
filesList.remove(position);
|
|
|
|
|
files.remove(position);
|
|
|
|
|
adapter1.notifyDataSetChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|