增加 - 绑定查询物料名称

master
wangh 12 months ago
parent 48c3b9619d
commit 2f266b78f3

@ -47,5 +47,8 @@ dependencies {
implementation 'com.lzy.net:okgo:3.0.4' implementation 'com.lzy.net:okgo:3.0.4'
// https://mvnrepository.com/artifact/com.google.code.gson/gson // https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.google.code.gson:gson:2.10.1'
// https://mvnrepository.com/artifact/com.contrarywind/Android-PickerView
implementation 'com.contrarywind:Android-PickerView:4.1.9'
} }

@ -20,8 +20,7 @@
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".BindingActivity" android:name=".BindingActivity"
android:exported="false" android:exported="false" />
android:label="箱壳内胆绑定" />
<activity <activity
android:name=".RepairActivity" android:name=".RepairActivity"
android:exported="false" android:exported="false"
@ -35,7 +34,6 @@
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>

@ -11,6 +11,7 @@ import android.widget.Toast;
import com.example.aucma_mes.base.BaseActivity; import com.example.aucma_mes.base.BaseActivity;
import com.example.aucma_mes.databinding.ActivityBindingBinding; import com.example.aucma_mes.databinding.ActivityBindingBinding;
import com.example.aucma_mes.entity.Result; import com.example.aucma_mes.entity.Result;
import com.example.aucma_mes.utils.MyRecultCall;
import com.example.aucma_mes.utils.SharedPreferencesUtils; import com.example.aucma_mes.utils.SharedPreferencesUtils;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
@ -19,14 +20,20 @@ import com.lzy.okgo.model.Response;
public class BindingActivity extends BaseActivity { public class BindingActivity extends BaseActivity {
public ObservableField<String> boxCode; public ObservableField<String> boxCode;
public ObservableField<String> materialName;
public ObservableField<String> innerCode; public ObservableField<String> innerCode;
public String title;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getSupportActionBar().hide();
ActivityBindingBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_binding); ActivityBindingBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_binding);
boxCode = new ObservableField<>(); boxCode = new ObservableField<>();
materialName = new ObservableField<>();
innerCode = new ObservableField<>(); innerCode = new ObservableField<>();
title = getIntent().getStringExtra("title");
binding.setTitle(title);
binding.setTest(this); binding.setTest(this);
binding.button2.setOnClickListener(t -> { binding.button2.setOnClickListener(t -> {
boxCode.set(null); boxCode.set(null);
@ -38,11 +45,24 @@ public class BindingActivity extends BaseActivity {
@Override @Override
protected void sanInfo(String code) { protected void sanInfo(String code) {
Log.e("TAG", "sanInfo:" + code);
if (boxCode.get() == null) { char c = code.charAt(0);
boxCode.set(code); if (title.equals("壳胆绑定")) {
if (c == 'B') {
boxCode.set(code);
selectGoodsName(code);
} else if (c == 'L') {
innerCode.set(code);
} else {
Toast.makeText(this, "条码格式不对", Toast.LENGTH_SHORT).show();
}
} else { } else {
innerCode.set(code); if (c == 'B') {
boxCode.set(code);
selectGoodsName(code);
} else {
innerCode.set(code);
}
} }
@ -53,33 +73,28 @@ public class BindingActivity extends BaseActivity {
if (boxCode.get() == null || innerCode.get() == null) return; if (boxCode.get() == null || innerCode.get() == null) return;
dialog.show(); dialog.show();
OkGo.<String>post(url + "/api/boxBanding") String s = title.equals("壳胆绑定") ? "/api/boxBanding" : "/api/barCodeBanding";
.tag(this) OkGo.<String>post(url + s).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).params("boxCode", boxCode.get()).params("innerCode", innerCode.get()).params("loginName", SharedPreferencesUtils.getstring("loginName", "")).execute(new StringCallback() {
.headers("Authorization",SharedPreferencesUtils.getstring("token","")) @Override
.params("boxCode", boxCode.get()) public void onSuccess(Response<String> response) {
.params("innerCode", innerCode.get()) dialog.dismiss();
.params("loginName", SharedPreferencesUtils.getstring("loginName", ""))
.execute(new StringCallback() { Result result = gson.fromJson(response.body(), Result.class);
@Override if (result.getCode() == 200) {
public void onSuccess(Response<String> response) { Toast.makeText(BindingActivity.this, "绑定成功", Toast.LENGTH_SHORT).show();
dialog.dismiss(); boxCode.set("");
innerCode.set("");
Result result = gson.fromJson(response.body(), Result.class); } else {
if (result.getCode() == 200) { Toast.makeText(BindingActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
Toast.makeText(BindingActivity.this, "绑定成功", Toast.LENGTH_SHORT).show(); }
boxCode.set(""); }
innerCode.set("");
} else { @Override
Toast.makeText(BindingActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); public void onError(Response<String> response) {
} super.onError(response);
} Toast.makeText(BindingActivity.this, "网路连接错误", Toast.LENGTH_SHORT).show();
}
@Override });
public void onError(Response<String> response) {
super.onError(response);
Toast.makeText(BindingActivity.this, "网路连接错误", Toast.LENGTH_SHORT).show();
}
});
} }
public void click2(View view) { public void click2(View view) {
@ -87,4 +102,28 @@ public class BindingActivity extends BaseActivity {
boxCode.set(null); boxCode.set(null);
innerCode.set(null); innerCode.set(null);
} }
private String codeTag = "";
private void selectGoodsName(String code) {
if (codeTag.equals(code)) return;
codeTag = code;
OkGo.<Result>post(url + "/api/selectGoodsName")
.tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.params("code", code)
.execute(new MyRecultCall(dialog,this){
@Override
public void onSuccess(Response<Result> response) {
super.onSuccess(response);
Result result = response.body();
if (result.getCode()==200){
Toast.makeText(BindingActivity.this, "查询成功", Toast.LENGTH_SHORT).show();
materialName.set(result.getData().toString());
}else {
Toast.makeText(BindingActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
}
}
});
}
} }

@ -3,6 +3,7 @@ package com.example.aucma_mes;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -12,6 +13,9 @@ import android.widget.ListPopupWindow;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.Toast; import android.widget.Toast;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.example.aucma_mes.adapter.CheckAdapter; import com.example.aucma_mes.adapter.CheckAdapter;
import com.example.aucma_mes.base.BaseActivity; import com.example.aucma_mes.base.BaseActivity;
import com.example.aucma_mes.databinding.ActivityCheckBinding; import com.example.aucma_mes.databinding.ActivityCheckBinding;
@ -32,15 +36,20 @@ import java.util.List;
import okhttp3.RequestBody; import okhttp3.RequestBody;
public class CheckActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall, AdapterView.OnItemClickListener { public class CheckActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall/*, AdapterView.OnItemClickListener*/, OnOptionsSelectListener {
private ActivityCheckBinding binding; private ActivityCheckBinding binding;
private CheckViewModel checkViewModel; private CheckViewModel checkViewModel;
private ListPopupWindow listPopupWindow; // private ListPopupWindow listPopupWindow;
private CheckAdapter checkAdapter; private CheckAdapter checkAdapter;
private List<DefectBeen> list; private List<DefectBeen> list;
private List<DefectBeen> submitList; private List<DefectBeen> submitList;
private List<String> defectBeens; private OptionsPickerView opv;
private List<String> options1;
private List<List<String>> options2;
private List<List<List<String>>> options3;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -48,15 +57,14 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
binding = DataBindingUtil.setContentView(this, R.layout.activity_check); binding = DataBindingUtil.setContentView(this, R.layout.activity_check);
checkViewModel = new CheckViewModel(); checkViewModel = new CheckViewModel();
binding.setVm(checkViewModel); binding.setVm(checkViewModel);
checkAdapter = new CheckAdapter(this, this); checkAdapter = new CheckAdapter(this, this);
submitList = new ArrayList<>(); submitList = new ArrayList<>();
checkAdapter.setList(submitList); checkAdapter.setList(submitList);
binding.recyclerView.setAdapter(checkAdapter); binding.recyclerView.setAdapter(checkAdapter);
listPopupWindow = new ListPopupWindow(this);
listPopupWindow.setAnchorView(binding.selectDefect);
listPopupWindow.setOnItemClickListener(this);
String stationCode = getIntent().getStringExtra("stationCode"); String stationCode = getIntent().getStringExtra("stationCode");
// 三联
opv = new OptionsPickerBuilder(this, this).build();
OkGo.<Result>get(url + "/base/qualityInspectionItem/getQualityDefects/" + stationCode).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) { OkGo.<Result>get(url + "/base/qualityInspectionItem/getQualityDefects/" + stationCode).tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).execute(new MyRecultCall(dialog, this) {
@Override @Override
public void onSuccess(Response<Result> response) { public void onSuccess(Response<Result> response) {
@ -67,31 +75,50 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
Toast.makeText(CheckActivity.this, "请求成功", Toast.LENGTH_SHORT).show(); Toast.makeText(CheckActivity.this, "请求成功", Toast.LENGTH_SHORT).show();
list = gson.fromJson(body.getData().toString(), new TypeToken<List<DefectBeen>>() { list = gson.fromJson(body.getData().toString(), new TypeToken<List<DefectBeen>>() {
}.getType()); }.getType());
defectBeens = new ArrayList<>(list.size()); if (list == null || list.isEmpty()) {
Toast.makeText(CheckActivity.this, "缺陷列表没有维护", Toast.LENGTH_SHORT).show();
list.stream().forEach(t -> defectBeens.add(t.qualityDefectName)); return;
listPopupWindow.setAdapter(new ArrayAdapter<String>(CheckActivity.this, androidx.appcompat.R.layout.support_simple_spinner_dropdown_item, defectBeens)); }
options1 = new ArrayList<>();
options2 = new ArrayList<>();
options3 = new ArrayList<>();
list.forEach(defect -> {
String materialCategories = defect.getMaterialCategories();
String materialSubclass = defect.getMaterialSubclass();
String qualityDefectName = defect.getQualityDefectName();
if (!options1.contains(materialCategories)) {
options1.add(materialCategories);
}
int index1 = options1.indexOf(materialCategories);
if (options2.size() <= index1) {
options2.add(new ArrayList<>());
}
if (!options2.get(index1).contains(materialSubclass)) {
options2.get(index1).add(materialSubclass);
}
int index2 = options2.get(index1).indexOf(materialSubclass);
if (options3.size() <= index1) {
options3.add(new ArrayList<>());
}
if (options3.get(index1).size() <= index2) {
options3.get(index1).add(new ArrayList<>());
}
if (!options3.get(index1).get(index2).contains(qualityDefectName)) {
options3.get(index1).get(index2).add(qualityDefectName);
}
});
// Log.e("TAG", "options1:" + options1.toString());
// Log.e("TAG", "options2:" + options2.toString());
// Log.e("TAG", "options3:" + options3.toString());
opv.setPicker(options1, options2, options3);
} else { } else {
Toast.makeText(CheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show(); Toast.makeText(CheckActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
} }
} }
}); });
OkGo.<Result>get(url + "/system/dict/data/type/treatment_measures").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<Result> response) {
super.onSuccess(response);
Result body = response.body();
List<DictBeen> dictBeenList = gson.fromJson(gson.toJson(body.getData()),
new TypeToken<List<DictBeen>>() {
}.getType());
checkViewModel.setDictBeenList(dictBeenList);
}
});
} }
@Override @Override
@ -99,40 +126,34 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
checkViewModel.setCode(code); checkViewModel.setCode(code);
} }
//弹出框
public void checkSelect(View view) { public void checkSelect(View view) {
listPopupWindow.show(); opv.show();
} }
//提交
public void checkSubmint(View view) { public void checkSubmint(View view) {
String s = binding.checkSpinner1.getSelectedItem().toString();
if (s.equals("返修") && submitList.isEmpty()) {
return;
}
checkViewModel.setMeasure(s);
String s1 = binding.checkSpinner2.getSelectedItem().toString();
checkViewModel.setOffline(s1);
checkViewModel.setList(submitList); checkViewModel.setList(submitList);
checkViewModel.setUserName(SharedPreferencesUtils.getstring("userName", "pda01")); checkViewModel.setUserName(SharedPreferencesUtils.getstring("userName", "pda01"));
OkGo.<Result>post(url + "/api/checkSubmit").tag(this) OkGo.<Result>post(url + "/api/checkSubmit").tag(this).headers("Authorization", SharedPreferencesUtils.getstring("token", "")).upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel))).execute(new MyRecultCall(dialog, this) {
.headers("Authorization", SharedPreferencesUtils.getstring("token", "")) @Override
.upRequestBody(RequestBody.create(JSON, gson.toJson(checkViewModel))) public void onSuccess(Response<Result> response) {
.execute(new MyRecultCall(dialog, this) { super.onSuccess(response);
@Override Result result = response.body();
public void onSuccess(Response<Result> response) { if (result.getCode() == 200) {
super.onSuccess(response); Toast.makeText(CheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show();
Result result = response.body(); checkViewModel.setCode(null);
if (result.getCode() == 200) { submitList.clear();
Toast.makeText(CheckActivity.this, "提交成功", Toast.LENGTH_SHORT).show(); checkAdapter.notifyDataSetChanged();
checkViewModel.setCode(null); } else {
submitList.clear(); Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
checkAdapter.notifyDataSetChanged(); }
} else { }
Toast.makeText(CheckActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show(); });
}
}
});
} }
// 删除缺陷
@Override @Override
public void onClick(int positon) { public void onClick(int positon) {
Log.e("TAG", "列表点击:" + positon); Log.e("TAG", "列表点击:" + positon);
@ -140,16 +161,22 @@ public class CheckActivity extends BaseActivity implements CheckAdapter.CheckIte
checkAdapter.notifyDataSetChanged(); checkAdapter.notifyDataSetChanged();
} }
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onOptionsSelect(int options1, int options2, int options3, View v) {
checkViewModel.setDefect(defectBeens.get(position));
DefectBeen defectBeen = list.get(position); String defectName = this.options3.get(options1).get(options2).get(options3);
if (submitList.contains(defectBeen)) { checkViewModel.setDefect(defectName);
DefectBeen defectBeen = new DefectBeen();
defectBeen.setQualityDefectName(defectName);
DefectBeen defectBeen1 = list.get(list.indexOf(defectBeen));
if (submitList.contains(defectBeen1)) {
Toast.makeText(this, "已经添加了", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "已经添加了", Toast.LENGTH_SHORT).show();
return; return;
} }
submitList.add(defectBeen); submitList.add(defectBeen1);
checkAdapter.notifyDataSetChanged(); checkAdapter.notifyDataSetChanged();
listPopupWindow.dismiss();
} }
} }

@ -53,29 +53,34 @@ public class HomePageActivity extends AppCompatActivity {
// return; // return;
// } // }
intent = new Intent(this, CheckActivity.class); intent = new Intent(this, CheckActivity.class);
intent.putExtra("stationCode", "1006"); intent.putExtra("stationCode", "2001");
startActivity(intent); startActivity(intent);
}); });
binding.homeButton2.setOnClickListener(v -> { binding.homeButton2.setOnClickListener(v -> {
if (!roles.contains("shell_bile_binding")) { // if (!roles.contains("shell_bile_binding")) {
Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show();
return; // return;
} // }
intent = new Intent(this, BindingActivity.class); intent = new Intent(this, BindingActivity.class);
intent.putExtra("title", "壳胆绑定"); intent.putExtra("title", "壳胆绑定");
startActivity(intent); startActivity(intent);
}); });
binding.homeButton3.setOnClickListener(v -> { binding.homeButton3.setOnClickListener(v -> {
if (!roles.contains("quality_repair")) { // if (!roles.contains("quality_repair")) {
Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show();
return; // return;
} // }
intent = new Intent(this, RepairActivity.class);
startActivity(intent);
}); });
binding.homeButton4.setOnClickListener(v -> { binding.homeButton4.setOnClickListener(v -> {
if (!roles.contains("barcode_binding")) { // if (!roles.contains("barcode_binding")) {
Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, "暂无权限", Toast.LENGTH_SHORT).show();
return; // return;
} // }
intent = new Intent(this, BindingActivity.class);
intent.putExtra("title", "条码绑定");
startActivity(intent);
}); });
binding.homeButton5.setOnClickListener(v -> { binding.homeButton5.setOnClickListener(v -> {
infoDialog.show(); infoDialog.show();

@ -48,8 +48,8 @@ private boolean loginState=false;
user.setPassword("aucma@123"); user.setPassword("aucma@123");
getSupportActionBar().hide(); // 隐藏原生标题栏 getSupportActionBar().hide(); // 隐藏原生标题栏
binding.setUser(user); binding.setUser(user);
Toast.makeText(this, getMacAddress()+"可以使用", Toast.LENGTH_SHORT).show(); // Toast.makeText(this, getMacAddress()+"可以使用", Toast.LENGTH_SHORT).show();
OkGo.<Result>get(url + "/system/dict/data/type/treatment_measures").tag(this) OkGo.<Result>get(url + "/report/pdaRecord/getPdaRecord").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", "")) .headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.execute(new MyRecultCall(dialog, this) { .execute(new MyRecultCall(dialog, this) {
@Override @Override
@ -58,6 +58,7 @@ private boolean loginState=false;
Result result = response.body(); Result result = response.body();
if (result.getCode()==200){ if (result.getCode()==200){
List<RegisterPda> pdaList=gson.fromJson(gson.toJson( result.getData()),new TypeToken< List<RegisterPda>>(){}.getType()); List<RegisterPda> pdaList=gson.fromJson(gson.toJson( result.getData()),new TypeToken< List<RegisterPda>>(){}.getType());
// Log.e("TAG", "onSuccess:" + pdaList.toString());
RegisterPda registerPda=new RegisterPda(); RegisterPda registerPda=new RegisterPda();
registerPda.setSerialCode(getMacAddress()); registerPda.setSerialCode(getMacAddress());
int index = pdaList.indexOf(registerPda); int index = pdaList.indexOf(registerPda);

@ -4,16 +4,94 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import android.os.Bundle; 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.ActivityMainBinding;
import com.example.aucma_mes.databinding.ActivityRepairBinding; import com.example.aucma_mes.databinding.ActivityRepairBinding;
import com.example.aucma_mes.entity.DefectBeen;
import com.example.aucma_mes.entity.RepairMeasures;
import com.example.aucma_mes.entity.Result;
import com.example.aucma_mes.utils.MyRecultCall;
import com.example.aucma_mes.utils.SharedPreferencesUtils;
import com.example.aucma_mes.vm.RepairVm;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
public class RepairActivity extends AppCompatActivity { import java.util.ArrayList;
import java.util.List;
public class RepairActivity extends BaseActivity implements CheckAdapter.CheckItemClickCall {
private ActivityRepairBinding binding;
private RepairVm repairVm;
private RepairAdapter adapter;
private List<DefectBeen> defectBeens;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ActivityRepairBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_repair); binding = DataBindingUtil.setContentView(this, R.layout.activity_repair);
adapter = new RepairAdapter(this);
repairVm = new RepairVm();
binding.setVm(repairVm);
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());
repairVm.setRepairList(repairList);
}else {
Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected void sanInfo(String code) {
repairVm.setCode(code);
OkGo.<Result>post(url + "/api/findCheckInfoByCode").tag(this)
.headers("Authorization", SharedPreferencesUtils.getstring("token", ""))
.params("code",code)
.execute(new MyRecultCall(dialog, this) {
@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());
adapter.setList(defectBeens);
adapter.notifyDataSetChanged();
}else {
Toast.makeText(RepairActivity.this, result.getMsg(), Toast.LENGTH_SHORT).show();
repairSubmit(null);
}
}
});
}
public void repairSubmit(View view) {
defectBeens.clear();
adapter.notifyDataSetChanged();
repairVm.setCode(null);
}
@Override
public void onClick(int positon) {
} }
} }

@ -0,0 +1,78 @@
package com.example.aucma_mes.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.example.aucma_mes.BR;
import com.example.aucma_mes.R;
import com.example.aucma_mes.databinding.ItemLayoutBinding;
import com.example.aucma_mes.databinding.ItemRepairBinding;
import com.example.aucma_mes.entity.DefectBeen;
import java.util.List;
/**
* @author wanghao
* @date 2023/11/17 17:15
*/
public class RepairAdapter extends RecyclerView.Adapter<RepairAdapter.CheckAdapterVH> {
private Context context;
private List<DefectBeen> list;
private LayoutInflater from;
public RepairAdapter(Context context) {
this.context = context;
from = LayoutInflater.from(context);
}
public void setList(List<DefectBeen> list) {
this.list = list;
}
@NonNull
@Override
public CheckAdapterVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ItemRepairBinding inflate1 = DataBindingUtil.inflate(from, R.layout.item_repair, parent, false);
return new CheckAdapterVH(inflate1);
}
@Override
public void onBindViewHolder(@NonNull CheckAdapterVH holder, int position) {
DefectBeen defectBeen = list.get(position);
defectBeen.setIndex(position + 1);
ItemRepairBinding databing = holder.getInflate1();
databing.setVariable(BR.item, defectBeen);
databing.executePendingBindings();
}
@Override
public int getItemCount() {
return list == null ? 0 : list.size();
}
static class CheckAdapterVH extends RecyclerView.ViewHolder {
private ItemRepairBinding inflate1;
public ItemRepairBinding getInflate1() {
return inflate1;
}
public CheckAdapterVH(ItemRepairBinding inflate1) {
super(inflate1.getRoot());
this.inflate1 = inflate1;
}
}
public interface CheckItemClickCall {
void onClick(int positon);
}
}

@ -19,6 +19,7 @@ import okhttp3.MediaType;
public abstract class BaseActivity extends AppCompatActivity { public abstract class BaseActivity extends AppCompatActivity {
private MyBroad receiver; private MyBroad receiver;
// public static String url="http://192.168.137.1:8080";
public static String url="http://172.20.10.2:8080"; public static String url="http://172.20.10.2:8080";
public ProgressDialog dialog; public ProgressDialog dialog;
public Gson gson; public Gson gson;

@ -9,22 +9,22 @@ import java.util.Objects;
* @date 2023/11/17 17:00 * @date 2023/11/17 17:00
*/ */
public class DefectBeen extends BaseObservable { public class DefectBeen extends BaseObservable {
public int index; public int index;
public int objId;
private String materialCategories;
private String materialSubclass;
public String qualityDefectCode; public String qualityDefectCode;
public String qualityDefectName; public String qualityDefectName;
private String stationCode;//检测项编号 TEST_ITEM_CODE
public void setIndex(int index) { public void setIndex(int index) {
this.index = index; this.index = index;
} }
public String getStationCode() {
return stationCode;
}
public void setStationCode(String stationCode) {
this.stationCode = stationCode;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
@ -40,4 +40,49 @@ public class DefectBeen extends BaseObservable {
public int hashCode() { public int hashCode() {
return qualityDefectName != null ? qualityDefectName.hashCode() : 0; return qualityDefectName != null ? qualityDefectName.hashCode() : 0;
} }
public int getObjId() {
return objId;
}
public void setObjId(int objId) {
this.objId = objId;
}
public int getIndex() {
return index;
}
public String getMaterialCategories() {
return materialCategories;
}
public void setMaterialCategories(String materialCategories) {
this.materialCategories = materialCategories;
}
public String getMaterialSubclass() {
return materialSubclass;
}
public void setMaterialSubclass(String materialSubclass) {
this.materialSubclass = materialSubclass;
}
public String getQualityDefectCode() {
return qualityDefectCode;
}
public void setQualityDefectCode(String qualityDefectCode) {
this.qualityDefectCode = qualityDefectCode;
}
public String getQualityDefectName() {
return qualityDefectName;
}
public void setQualityDefectName(String qualityDefectName) {
this.qualityDefectName = qualityDefectName;
}
} }

@ -42,4 +42,12 @@ public class RegisterPda {
public int hashCode() { public int hashCode() {
return serialCode != null ? serialCode.hashCode() : 0; return serialCode != null ? serialCode.hashCode() : 0;
} }
@Override
public String toString() {
return "RegisterPda{" +
"pdaName='" + pdaName + '\'' +
", serialCode='" + serialCode + '\'' +
'}';
}
} }

@ -0,0 +1,38 @@
package com.example.aucma_mes.entity;
import java.util.Objects;
/**
* @author wanghao
* @date 2023/11/23 9:57
*/
public class RepairMeasures {
// "repairCode": "6001",
//"repairName": "返回生产线"
private String repairCode;
private String repairName;
public String getRepairCode() {
return repairCode;
}
public void setRepairCode(String repairCode) {
this.repairCode = repairCode;
}
public String getRepairName() {
return repairName;
}
public void setRepairName(String repairName) {
this.repairName = repairName;
}
@Override
public String toString() {
return "RepairMeasures{" +
"repairCode='" + repairCode + '\'' +
", repairName='" + repairName + '\'' +
'}';
}
}

@ -2,6 +2,8 @@ package com.example.aucma_mes.utils;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.util.Log;
import android.widget.Toast;
import com.example.aucma_mes.entity.Result; import com.example.aucma_mes.entity.Result;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -36,17 +38,28 @@ public class MyRecultCall extends AbsCallback<Result> {
@Override @Override
public void onSuccess(Response<Result> response) { public void onSuccess(Response<Result> response) {
dialog.dismiss(); dialog.dismiss();
Log.e("网络请求情况", "onSuccess:");
} }
@Override @Override
public void onError(Response<Result> response) { public void onError(Response<Result> response) {
super.onError(response); super.onError(response);
dialog.dismiss(); dialog.dismiss();
Log.e("网络请求情况", "onError:" );
Toast.makeText(context, "网络连接错误", Toast.LENGTH_SHORT).show();
} }
@Override @Override
public void onStart(Request<Result, ? extends Request> request) { public void onStart(Request<Result, ? extends Request> request) {
super.onStart(request); super.onStart(request);
dialog.show(); dialog.show();
Log.e("网络请求情况", "onStart:" );
}
@Override
public void onFinish() {
super.onFinish();
dialog.dismiss();
Log.e("网络请求情况", "onFinish:" );
} }
} }

@ -18,31 +18,18 @@ import java.util.List;
*/ */
public class CheckViewModel extends BaseObservable { public class CheckViewModel extends BaseObservable {
public String code;//产品条码 public String code;//产品条码
public String name;//产品型号
public String defect; public String defect;
public List<String> stringList;
private List<DefectBeen> list;//缺陷列表 private List<DefectBeen> list;//缺陷列表
private String measure;//处理措施TREATMENT_MEASURE private String measure;//处理措施TREATMENT_MEASURE
private String measureName;//处理措施TREATMENT_MEASURE
private String offline;
private String processCode; private String processCode;
private String userName; private String userName;
public List<DictBeen> dictBeenList;
public List<DictBeen> getDictBeenList() {
return dictBeenList;
}
public void setDictBeenList(List<DictBeen> dictBeenList) {
this.dictBeenList = dictBeenList;
stringList=new ArrayList<>(dictBeenList.size());
dictBeenList.forEach(t->stringList.add(t.getDictLabel()));
notifyChange();
}
public String getProcessCode() { public String getProcessCode() {
return processCode; return processCode;
@ -65,22 +52,6 @@ public class CheckViewModel extends BaseObservable {
return measure; return measure;
} }
public void setMeasure(String measure) {
this.measure =dictBeenList.get(stringList.indexOf(measure)).getDictValue() ;
}
public String getOffline() {
return offline;
}
public void setOffline(String offline) {
if (offline.equals("是")) {
this.offline = "Y";
} else {
this.offline = "N";
}
}
public String getCode() { public String getCode() {
return code; return code;

@ -0,0 +1,55 @@
package com.example.aucma_mes.vm;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import androidx.databinding.BaseObservable;
import com.example.aucma_mes.adapter.CheckAdapter;
import com.example.aucma_mes.entity.RepairMeasures;
import java.util.ArrayList;
import java.util.List;
/**
* @author wanghao
* @date 2023/11/23 10:01
*/
public class RepairVm extends BaseObservable {
public String code;//扫描条码
private String repairCode;//处理措施
public List<String> stringList;
private List<RepairMeasures> repairList;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("TAG", "返修选中措施:" + position);
this.repairCode = repairList.get(position).getRepairCode();
}
public void setRepairList(List<RepairMeasures> repairList) {
this.repairList = repairList;
stringList = new ArrayList<>(repairList.size());
repairList.forEach(t -> stringList.add(t.getRepairName()));
notifyChange();
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
notifyChange();
}
public String getRepairCode() {
return repairCode;
}
public void setRepairCode(String name) {
int i = stringList.indexOf(name);
this.repairCode = repairList.get(i).getRepairCode();
}
}

@ -10,24 +10,35 @@
name="test" name="test"
type="com.example.aucma_mes.BindingActivity" /> type="com.example.aucma_mes.BindingActivity" />
<variable
name="title"
type="String" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".BindingActivity"> tools:context=".BindingActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@color/blue"
android:gravity="center|left"
android:paddingStart="12dp"
android:text="@{title}"
android:textColor="@color/white"
android:textSize="20sp" />
<LinearLayout <LinearLayout
android:id="@+id/linearLayout7"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp">
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView <TextView
style="@style/text_style1" style="@style/text_style1"
@ -44,20 +55,39 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/linearLayout8" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="4dp">
<TextView
style="@style/text_style1"
android:layout_width="90dp"
android:layout_height="match_parent"
android:text="物料名称:" />
<!-- -->
<TextView
style="@style/san_text_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="45dp"
android:text="@={test.materialName}"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp">
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout7">
<TextView <TextView
style="@style/text_style1" style="@style/text_style1"
android:layout_width="90dp" android:layout_width="90dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="内胆条码:" /> android:text='@{(title.equals("壳胆绑定"))? "内胆码:":"SN 码:"}' />
<TextView <TextView
style="@style/san_text_style" style="@style/san_text_style"
@ -70,9 +100,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="55dp"
android:layout_margin="20dp" android:layout_margin="20dp">
app:layout_constraintTop_toBottomOf="@+id/linearLayout8"
tools:layout_editor_absoluteX="20dp">
<Button <Button
android:id="@+id/button2" android:id="@+id/button2"
@ -95,5 +123,5 @@
android:text="提交" /> android:text="提交" />
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>
</layout> </layout>

@ -35,6 +35,30 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@={vm.code}" /> android:text="@={vm.code}" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="4dp"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/text_style1"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/grey"
android:text="产品型号:" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/text_style1_1"
android:text="@{vm.name}"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -71,69 +95,22 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="150dp" android:layout_height="224dp"
android:background="@color/white" android:background="@color/white"
android:padding="5dp" android:padding="5dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="4dp"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/text_style1"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/grey"
android:text="处置措施:" />
<Spinner
android:id="@+id/check_spinner1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:spinnerMode="dropdown"
android:textAlignment="center"
android:entries="@{vm.stringList}" />
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="4dp"
android:background="@color/white"
android:orientation="horizontal">
<TextView
style="@style/text_style1"
android:layout_width="90dp"
android:layout_height="match_parent"
android:background="@color/grey"
android:text="下静态线:" />
<Spinner
android:id="@+id/check_spinner2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/yn"
android:spinnerMode="dropdown"
android:textAlignment="center" />
</LinearLayout>
<Button <Button
android:id="@+id/button" android:id="@+id/button"
style="@style/button_true_style" style="@style/button_true_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="45dp" android:layout_height="45dp"
android:layout_margin="16dp" android:layout_margin="10dp"
android:onClick="checkSubmint" android:onClick="checkSubmint"
android:text="提交" /> android:text="提交" />
</LinearLayout> </LinearLayout>

@ -3,10 +3,17 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="vm"
type="com.example.aucma_mes.vm.RepairVm" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/grey"
tools:context=".RepairActivity"> tools:context=".RepairActivity">
<LinearLayout <LinearLayout
@ -29,7 +36,8 @@
android:id="@+id/san_text" android:id="@+id/san_text"
style="@style/san_text_style" style="@style/san_text_style"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:text="@={vm.code}" />
</LinearLayout> </LinearLayout>
@ -44,8 +52,10 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="409dp" android:layout_width="match_parent"
android:layout_height="315dp" android:layout_height="255dp"
android:background="@color/white"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" /> app:layout_constraintTop_toBottomOf="@+id/textView" />
@ -54,7 +64,7 @@
android:id="@+id/linearLayout2" android:id="@+id/linearLayout2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_marginTop="12dp" android:layout_marginTop="8dp"
android:layout_marginEnd="4dp" android:layout_marginEnd="4dp"
android:background="@color/white" android:background="@color/white"
android:orientation="horizontal" android:orientation="horizontal"
@ -67,43 +77,33 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/grey" android:background="@color/grey"
android:text="处置措施:" /> android:text="处置措施:" />
<!-- "-->
<Spinner <Spinner
android:id="@+id/check_spinner1" android:id="@+id/check_spinner1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:entries="@array/eg" android:entries="@{vm.stringList}"
android:onItemSelected="@{vm.onItemClick}"
android:spinnerMode="dropdown" android:spinnerMode="dropdown"
android:textAlignment="center" /> android:textAlignment="center" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="20dp"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
<Button
android:id="@+id/button2"
style="@style/button_true_style"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:text="提交" />
<Button
android:id="@+id/button"
style="@style/button_true_style"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="提交" />
</LinearLayout>
<Button
android:id="@+id/button"
style="@style/button_true_style"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="25dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="25dp"
android:layout_weight="1"
android:onClick="repairSubmit"
android:text="提交"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.example.aucma_mes.entity.DefectBeen" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginTop="2dp"
android:background="#DEE3E6"
android:orientation="horizontal">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="51dp"
android:layout_height="match_parent"
android:text='@{item.index+""}' />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="80dp"
android:layout_height="match_parent"
android:text="@{item.qualityDefectCode}" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@{item.qualityDefectName}" />
</LinearLayout>
</layout>
Loading…
Cancel
Save