|
|
|
|
@ -8,11 +8,7 @@ import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.media.AudioManager;
|
|
|
|
|
import android.media.SoundPool;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Message;
|
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
import android.text.Html;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
@ -25,15 +21,14 @@ import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
|
|
|
|
import com.android.hdhe.uhf.reader.UhfReader;
|
|
|
|
|
import com.android.hdhe.uhf.readerInterface.TagModel;
|
|
|
|
|
import com.example.tyre.entity.AjaxResult;
|
|
|
|
|
import com.example.tyre.databinding.ActivityTyresearchBinding;
|
|
|
|
|
import com.example.tyre.entity.BaseTyre;
|
|
|
|
|
import com.example.tyre.entity.EPC;
|
|
|
|
|
import com.example.tyre.entity.Tyre;
|
|
|
|
|
import com.example.tyre.util.CommonDialog;
|
|
|
|
|
import com.example.tyre.util.MyUrl;
|
|
|
|
|
import com.example.tyre.util.PlayMusic;
|
|
|
|
|
import com.example.tyre.util.Util;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.JsonArray;
|
|
|
|
|
@ -45,20 +40,13 @@ import com.lzy.okgo.OkGo;
|
|
|
|
|
import com.lzy.okgo.callback.StringCallback;
|
|
|
|
|
import com.lzy.okgo.model.Response;
|
|
|
|
|
|
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import cn.pda.serialport.Tools;
|
|
|
|
|
import com.example.tyre.databinding.ActivityTyresearchBinding;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
private ActivityTyresearchBinding binding;
|
|
|
|
|
|
|
|
|
|
EditText inSantext;
|
|
|
|
|
Button basemessage;
|
|
|
|
|
Button button;
|
|
|
|
|
@ -71,11 +59,13 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
TextView shengyuhuawen;
|
|
|
|
|
TextView zhuangtai;
|
|
|
|
|
TextView qiya;
|
|
|
|
|
long lastTime;
|
|
|
|
|
long nextTime;
|
|
|
|
|
private ActivityTyresearchBinding binding;
|
|
|
|
|
private int power = 0;
|
|
|
|
|
private int area = 0;
|
|
|
|
|
private SharedPreferences shared;
|
|
|
|
|
private EditText textVersion;
|
|
|
|
|
|
|
|
|
|
private boolean runFlag = true;
|
|
|
|
|
private boolean startFlag = false;
|
|
|
|
|
private UhfReader manager;
|
|
|
|
|
@ -83,6 +73,11 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
private ArrayList<String> listepc = new ArrayList<String>();
|
|
|
|
|
private ProgressDialog progressDialog;
|
|
|
|
|
private LinearLayout llTimelineContainer;
|
|
|
|
|
private long exitTime = 0;
|
|
|
|
|
private Toast mToast;
|
|
|
|
|
private Toast toast;
|
|
|
|
|
private KeyReceiver keyReceiver;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
@ -95,11 +90,12 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
Thread thread = new InventoryThread();
|
|
|
|
|
thread.start();
|
|
|
|
|
com.example.tyre.util.Util.initSoundPool(this);
|
|
|
|
|
Log.e("onCreate", "onCreate:+ " );
|
|
|
|
|
Log.e("onCreate", "onCreate:+ ");
|
|
|
|
|
llTimelineContainer = findViewById(R.id.ll_timeline_container);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void renderTimeline(List<TimelineItem> data) {
|
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(this);
|
|
|
|
|
llTimelineContainer.removeAllViews();
|
|
|
|
|
@ -128,6 +124,7 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
llTimelineContainer.addView(itemView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bindViews() {
|
|
|
|
|
inSantext = binding.inSantext;
|
|
|
|
|
// basemessage = binding.basemessage;
|
|
|
|
|
@ -150,14 +147,12 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
finish();
|
|
|
|
|
});
|
|
|
|
|
binding.button.setOnClickListener(v -> {
|
|
|
|
|
Intent intent = new Intent(this, HomePageActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
Intent intent = new Intent(this, HomePageActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
finish();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
@ -168,26 +163,14 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
registerReceiver();
|
|
|
|
|
}
|
|
|
|
|
// TyreSearchActivity.java (内部类或单独文件)
|
|
|
|
|
public class TimelineItem {
|
|
|
|
|
public String time;
|
|
|
|
|
public String title;
|
|
|
|
|
public CharSequence content;
|
|
|
|
|
|
|
|
|
|
public TimelineItem(String time, String title, CharSequence content) {
|
|
|
|
|
this.time = time;
|
|
|
|
|
this.title = title;
|
|
|
|
|
this.content = content;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPause() {
|
|
|
|
|
startFlag = false;
|
|
|
|
|
binding.scanButton.setText("搜索");
|
|
|
|
|
// manager.close();
|
|
|
|
|
// manager.close();
|
|
|
|
|
unregisterReceiver();
|
|
|
|
|
Log.e("onPause", "onPause:+ " );
|
|
|
|
|
Log.e("onPause", "onPause:+ ");
|
|
|
|
|
super.onPause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -195,7 +178,7 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
startFlag = false;
|
|
|
|
|
runFlag = false;
|
|
|
|
|
Log.e("onDestroy", "onDestroy:+ " );
|
|
|
|
|
Log.e("onDestroy", "onDestroy:+ ");
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -211,46 +194,7 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
qiya = binding.qiya;
|
|
|
|
|
listEPC = new ArrayList<EPC>();
|
|
|
|
|
}
|
|
|
|
|
private long exitTime = 0;
|
|
|
|
|
|
|
|
|
|
private Toast mToast;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Toast toast;
|
|
|
|
|
|
|
|
|
|
class InventoryThread extends Thread {
|
|
|
|
|
private List<TagModel> tagList;
|
|
|
|
|
byte[] accessPassword = Tools.HexString2Bytes("00000000");
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
super.run();
|
|
|
|
|
while (runFlag) {
|
|
|
|
|
if (startFlag) {
|
|
|
|
|
tagList = manager.inventoryRealTime();
|
|
|
|
|
if (tagList != null && !tagList.isEmpty()) {
|
|
|
|
|
Util.play(1, 0);
|
|
|
|
|
for (TagModel tag : tagList) {
|
|
|
|
|
if (tag == null) {
|
|
|
|
|
String epcStr = "";
|
|
|
|
|
addToList(listEPC, epcStr, (byte) -1);
|
|
|
|
|
} else {
|
|
|
|
|
String epcStr = Tools.Bytes2HexString(tag.getmEpcBytes(), tag.getmEpcBytes().length);
|
|
|
|
|
byte rssi = tag.getmRssi();
|
|
|
|
|
addToList(listEPC, epcStr, rssi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tagList = null;
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(20);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void addToList(final List<EPC> list, final String epc, final byte rssi) {
|
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
@ -263,7 +207,7 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
list.add(epcTag);
|
|
|
|
|
listepc.add(epc);
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
EPC mEPC = list.get(i);
|
|
|
|
|
if (epc.equals(mEPC.getEpc())) {
|
|
|
|
|
@ -282,7 +226,7 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastTime = SystemClock.elapsedRealtime();
|
|
|
|
|
lastTime = SystemClock.elapsedRealtime();
|
|
|
|
|
long time = lastTime - nextTime;
|
|
|
|
|
if (time >= 60) {
|
|
|
|
|
Util.play(1, 0);
|
|
|
|
|
@ -292,16 +236,15 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Log.e("EPC", "listepc:+ " + listepc);
|
|
|
|
|
if (listepc != null && !listepc.isEmpty()){
|
|
|
|
|
if (listepc != null && !listepc.isEmpty()) {
|
|
|
|
|
startFlag = false;
|
|
|
|
|
//binding.scanButton.setText("扫 描");
|
|
|
|
|
// binding.scanButton.setText("扫 描");
|
|
|
|
|
textVersion.setText(listepc.get(0).toString());
|
|
|
|
|
find(listepc.get(0).toString());
|
|
|
|
|
}
|
|
|
|
|
clearData();
|
|
|
|
|
}
|
|
|
|
|
long lastTime;
|
|
|
|
|
long nextTime;
|
|
|
|
|
|
|
|
|
|
private void setButtonClickable(Button button, boolean flag) {
|
|
|
|
|
button.setClickable(flag);
|
|
|
|
|
if (flag) {
|
|
|
|
|
@ -311,7 +254,6 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void showToast(String message) {
|
|
|
|
|
if (mToast == null) {
|
|
|
|
|
mToast = Toast.makeText(TyreSearchActivity.this, message, Toast.LENGTH_SHORT);
|
|
|
|
|
@ -321,12 +263,12 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
mToast.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void clearData() {
|
|
|
|
|
listEPC.removeAll(listEPC);
|
|
|
|
|
listepc.removeAll(listepc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private KeyReceiver keyReceiver;
|
|
|
|
|
private void registerReceiver() {
|
|
|
|
|
keyReceiver = new KeyReceiver();
|
|
|
|
|
IntentFilter filter = new IntentFilter();
|
|
|
|
|
@ -339,6 +281,350 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
unregisterReceiver(keyReceiver);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void find(String epc) {
|
|
|
|
|
OkGo.<String>post(MyUrl.url + "/tyre/tyre/pdaQueryTyreTimeLine").tag(this)
|
|
|
|
|
.params("keyParam", epc)
|
|
|
|
|
.execute(new StringCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<String> response) {
|
|
|
|
|
hideLoadingDialog();
|
|
|
|
|
String body = response.body();
|
|
|
|
|
try {
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
JsonElement rootElement = JsonParser.parseString(body);
|
|
|
|
|
JsonObject rootObject = rootElement.getAsJsonObject();
|
|
|
|
|
BaseTyre baseTyre = new BaseTyre();
|
|
|
|
|
// 3. 获取 "data" 节点 (注意判空,防止空指针异常)
|
|
|
|
|
if (rootObject.has("data") && !rootObject.get("data").isJsonNull()) {
|
|
|
|
|
JsonObject dataObject = rootObject.getAsJsonObject("data");
|
|
|
|
|
// 4. 获取 "resultBase" 节点
|
|
|
|
|
String team = "";
|
|
|
|
|
String TYREPYTE = "";
|
|
|
|
|
String patternDepth = "";
|
|
|
|
|
if (dataObject.has("resultBase") && !dataObject.get("resultBase").isJsonNull()) {
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("resultBase");
|
|
|
|
|
// 5. 【关键步骤】将 resultBase 节点直接转换为 BaseTyre 对象
|
|
|
|
|
baseTyre = gson.fromJson(resultBaseElement, BaseTyre.class);
|
|
|
|
|
if (baseTyre != null) {
|
|
|
|
|
String brand = safeGetString(baseTyre.getTyreBrand());
|
|
|
|
|
String model = safeGetString(baseTyre.getTyreModel());
|
|
|
|
|
String level = safeGetString(baseTyre.getTyreLevel());
|
|
|
|
|
String pattern = safeGetString(baseTyre.getTyrePattern());
|
|
|
|
|
String patternDeepth = safeGetString(baseTyre.getPatternDepth());
|
|
|
|
|
String pressure = safeGetString(baseTyre.getPressure());
|
|
|
|
|
team = safeGetString(baseTyre.getTeam());
|
|
|
|
|
TYREPYTE = "new".equals(TYREPYTE) ? "全新胎" : TYREPYTE;
|
|
|
|
|
patternDepth = safeGetString(baseTyre.getPatternDepth());
|
|
|
|
|
pinpai.setText(brand);
|
|
|
|
|
xinghao.setText(model);
|
|
|
|
|
cengji.setText(level);
|
|
|
|
|
huawen.setText(pattern);
|
|
|
|
|
huawendepth.setText(patternDeepth);
|
|
|
|
|
shengyuhuawen.setText(patternDeepth);
|
|
|
|
|
qiya.setText(pressure);
|
|
|
|
|
String carNo = baseTyre.getCarNo();
|
|
|
|
|
if (carNo == null || "".equals(carNo)) {
|
|
|
|
|
zhuangtai.setText("未装车");
|
|
|
|
|
} else {
|
|
|
|
|
zhuangtai.setText("已装车|车牌号:" + carNo);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
pinpai.setText("");
|
|
|
|
|
xinghao.setText("");
|
|
|
|
|
cengji.setText("");
|
|
|
|
|
huawen.setText("");
|
|
|
|
|
huawendepth.setText("");
|
|
|
|
|
qiya.setText("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<TimelineItem> data = new ArrayList<>();
|
|
|
|
|
if (dataObject.has("bizMaintenanceOrder") && !dataObject.get("bizMaintenanceOrder").isJsonNull()) {
|
|
|
|
|
JsonObject maintenanceOrderObj =
|
|
|
|
|
dataObject.get("bizMaintenanceOrder").getAsJsonObject();
|
|
|
|
|
if (maintenanceOrderObj.has("bizOrderTireDetailList") && !maintenanceOrderObj.get("bizOrderTireDetailList").isJsonNull()) {
|
|
|
|
|
JsonArray detailListArray =
|
|
|
|
|
maintenanceOrderObj.get("bizOrderTireDetailList").getAsJsonArray();
|
|
|
|
|
String mileage = "0";
|
|
|
|
|
String inputmileage = "0";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
mileage =
|
|
|
|
|
maintenanceOrderObj.has("lastMileage") ? maintenanceOrderObj.get("lastMileage").getAsString() : "";
|
|
|
|
|
|
|
|
|
|
inputmileage =
|
|
|
|
|
maintenanceOrderObj.has("inputMileage") ? maintenanceOrderObj.get("inputMileage").getAsString() : "";
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String type =
|
|
|
|
|
maintenanceOrderObj.has("typeCode") ? maintenanceOrderObj.get("typeCode").getAsString() : "";
|
|
|
|
|
String teams =
|
|
|
|
|
maintenanceOrderObj.has("factoryName") ? maintenanceOrderObj.get("factoryName").getAsString() : "";
|
|
|
|
|
String plateNumber =
|
|
|
|
|
maintenanceOrderObj.has("plateNumber") ? maintenanceOrderObj.get("plateNumber").getAsString() : "";
|
|
|
|
|
for (JsonElement element : detailListArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo =
|
|
|
|
|
itemObject.has("tireCode") ? itemObject.get("tireCode").getAsString() : "";
|
|
|
|
|
String time =
|
|
|
|
|
itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user =
|
|
|
|
|
itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
String wheel =
|
|
|
|
|
itemObject.has("positionName") ? itemObject.get("positionName").getAsString() : "";
|
|
|
|
|
String tirePress =
|
|
|
|
|
itemObject.has("tirePress") ? itemObject.get("tirePress").getAsString() : "";
|
|
|
|
|
// 直接获取,如果为 null 或不存在,自动返回 ""
|
|
|
|
|
String depth =
|
|
|
|
|
itemObject.has("treadDepth") && !itemObject.get("treadDepth").isJsonNull()
|
|
|
|
|
? itemObject.get("treadDepth").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
if (type.equals("1")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
|
|
|
|
|
} else if (type.equals("2")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("3")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("4")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("5")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("6")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("7")) {
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:" + user + "<br>场站: " + teams +
|
|
|
|
|
"<br>车辆信息: " + plateNumber +
|
|
|
|
|
"<br>当前车辆里程: " + mileage + " KM" +
|
|
|
|
|
"<br>上次车辆里程: " + inputmileage + "KM" +
|
|
|
|
|
"<br>轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>胎压: " + tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (dataObject.has("recordTyreInstallList") && !dataObject.get("recordTyreInstallList").isJsonNull()) {
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("recordTyreInstallList");
|
|
|
|
|
JsonArray jsonArray = resultBaseElement.getAsJsonArray();
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo =
|
|
|
|
|
itemObject.has("tyreNo") ? itemObject.get("tyreNo").getAsString() : "";
|
|
|
|
|
String type =
|
|
|
|
|
itemObject.has("type") ? itemObject.get("type").getAsString() : "";
|
|
|
|
|
String time =
|
|
|
|
|
itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user =
|
|
|
|
|
itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
String wheel =
|
|
|
|
|
itemObject.has("wheelPostion") ? itemObject.get("wheelPostion").getAsString() : "";
|
|
|
|
|
String mileage =
|
|
|
|
|
itemObject.has("mileage") ? itemObject.get("mileage").getAsString() : "";
|
|
|
|
|
String carNo =
|
|
|
|
|
itemObject.has("carNo") ? itemObject.get("carNo").getAsString() : "";
|
|
|
|
|
// 直接获取,如果为 null 或不存在,自动返回 ""
|
|
|
|
|
String depth =
|
|
|
|
|
itemObject.has("patternDepth") && !itemObject.get("patternDepth").isJsonNull()
|
|
|
|
|
? itemObject.get("patternDepth").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
String stageMileage =
|
|
|
|
|
itemObject.has("stageMileage") && !itemObject.get("stageMileage").isJsonNull()
|
|
|
|
|
? itemObject.get("stageMileage").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
if (type.equals("0")) {
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎装车", Html.fromHtml("操作人:" + user + "<br>场站: " + team +
|
|
|
|
|
"<br>车牌号: " + carNo +
|
|
|
|
|
"<br>安装轮位: " + wheel +
|
|
|
|
|
"<br>装车里程: " + mileage + " KM" +
|
|
|
|
|
"<br>花纹深度: " + depth + "mm")));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
} else if (type.equals("1")) {
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎卸车", Html.fromHtml("操作人:" + user + "<br>场站: " + team +
|
|
|
|
|
"<br>车牌号: " + carNo +
|
|
|
|
|
"<br>卸下轮位: " + wheel +
|
|
|
|
|
"<br>剩余花纹深度: " + depth + "mm" +
|
|
|
|
|
"<br>卸车里程: " + mileage + "KM" +
|
|
|
|
|
"<br>行驶里程: " + stageMileage + "KM")));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 出入库数据
|
|
|
|
|
|
|
|
|
|
if (dataObject.has("recordWarehousingList") && !dataObject.get("recordWarehousingList").isJsonNull()) {
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("recordWarehousingList");
|
|
|
|
|
JsonArray jsonArray = resultBaseElement.getAsJsonArray();
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo =
|
|
|
|
|
itemObject.has("tyreNo") ? itemObject.get("tyreNo").getAsString() : "";
|
|
|
|
|
String type =
|
|
|
|
|
itemObject.has("type") ? itemObject.get("type").getAsString() : "";
|
|
|
|
|
String time =
|
|
|
|
|
itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user =
|
|
|
|
|
itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
// 打印或处理你的数据
|
|
|
|
|
if (type.equals("0")) {
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎入库", Html.fromHtml("操作人:" + user + "<br>场站: " + team +
|
|
|
|
|
"<br>轮胎类型: " + TYREPYTE +
|
|
|
|
|
"<br>剩余花纹深度: " + patternDepth + "mm")));
|
|
|
|
|
} else if (type.equals("1")) {
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎出库", Html.fromHtml("操作人:" + user + "<br>场站: " + team +
|
|
|
|
|
"<br>轮胎类型: " + TYREPYTE +
|
|
|
|
|
"<br>剩余花纹深度: " + patternDepth + "mm")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderTimeline(data);
|
|
|
|
|
data.clear();
|
|
|
|
|
}
|
|
|
|
|
} catch (JsonSyntaxException e) {
|
|
|
|
|
pinpai.setText("");
|
|
|
|
|
xinghao.setText("");
|
|
|
|
|
cengji.setText("");
|
|
|
|
|
huawen.setText("");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(Response<String> response) {
|
|
|
|
|
super.onError(response);
|
|
|
|
|
// ✅ 修改点 3:网络请求失败也要关闭弹窗
|
|
|
|
|
Toast.makeText(TyreSearchActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String safeGetString(String value) {
|
|
|
|
|
return value == null || "null".equals(value) ? "" : value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showLoadingDialog() {
|
|
|
|
|
if (progressDialog == null) {
|
|
|
|
|
progressDialog = new ProgressDialog(this);
|
|
|
|
|
progressDialog.setMessage("数据加载中...");
|
|
|
|
|
progressDialog.setCancelable(false);
|
|
|
|
|
}
|
|
|
|
|
if (!progressDialog.isShowing()) {
|
|
|
|
|
progressDialog.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void hideLoadingDialog() {
|
|
|
|
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
|
|
progressDialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TyreSearchActivity.java (内部类或单独文件)
|
|
|
|
|
public class TimelineItem {
|
|
|
|
|
public String time;
|
|
|
|
|
public String title;
|
|
|
|
|
public CharSequence content;
|
|
|
|
|
|
|
|
|
|
public TimelineItem(String time, String title, CharSequence content) {
|
|
|
|
|
this.time = time;
|
|
|
|
|
this.title = title;
|
|
|
|
|
this.content = content;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class InventoryThread extends Thread {
|
|
|
|
|
byte[] accessPassword = Tools.HexString2Bytes("00000000");
|
|
|
|
|
private List<TagModel> tagList;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
super.run();
|
|
|
|
|
while (runFlag) {
|
|
|
|
|
if (startFlag) {
|
|
|
|
|
tagList = manager.inventoryRealTime();
|
|
|
|
|
if (tagList != null && !tagList.isEmpty()) {
|
|
|
|
|
Util.play(1, 0);
|
|
|
|
|
for (TagModel tag : tagList) {
|
|
|
|
|
if (tag == null) {
|
|
|
|
|
String epcStr = "";
|
|
|
|
|
addToList(listEPC, epcStr, (byte) -1);
|
|
|
|
|
} else {
|
|
|
|
|
String epcStr =
|
|
|
|
|
Tools.Bytes2HexString(tag.getmEpcBytes(), tag.getmEpcBytes().length);
|
|
|
|
|
byte rssi = tag.getmRssi();
|
|
|
|
|
addToList(listEPC, epcStr, rssi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tagList = null;
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(20);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class KeyReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -360,275 +646,10 @@ public class TyreSearchActivity extends AppCompatActivity {
|
|
|
|
|
case KeyEvent.KEYCODE_F5:
|
|
|
|
|
case 136:
|
|
|
|
|
startFlag = true;
|
|
|
|
|
//binding.scanButton.callOnClick();
|
|
|
|
|
// binding.scanButton.callOnClick();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void find(String epc) {
|
|
|
|
|
OkGo.<String>post(MyUrl.url + "/tyre/tyre/pdaQueryTyreTimeLine").tag(this)
|
|
|
|
|
.params("keyParam", epc)
|
|
|
|
|
.execute(new StringCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<String> response) {
|
|
|
|
|
hideLoadingDialog();
|
|
|
|
|
String body = response.body();
|
|
|
|
|
try {
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
JsonElement rootElement = JsonParser.parseString(body);
|
|
|
|
|
JsonObject rootObject = rootElement.getAsJsonObject();
|
|
|
|
|
BaseTyre baseTyre =new BaseTyre();
|
|
|
|
|
// 3. 获取 "data" 节点 (注意判空,防止空指针异常)
|
|
|
|
|
if (rootObject.has("data") && !rootObject.get("data").isJsonNull()) {
|
|
|
|
|
JsonObject dataObject = rootObject.getAsJsonObject("data");
|
|
|
|
|
// 4. 获取 "resultBase" 节点
|
|
|
|
|
String team = "";
|
|
|
|
|
String TYREPYTE = "";
|
|
|
|
|
String patternDepth = "";
|
|
|
|
|
if (dataObject.has("resultBase") && !dataObject.get("resultBase").isJsonNull()) {
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("resultBase");
|
|
|
|
|
// 5. 【关键步骤】将 resultBase 节点直接转换为 BaseTyre 对象
|
|
|
|
|
baseTyre = gson.fromJson(resultBaseElement, BaseTyre.class);
|
|
|
|
|
if (baseTyre != null) {
|
|
|
|
|
String brand = safeGetString(baseTyre.getTyreBrand());
|
|
|
|
|
String model = safeGetString(baseTyre.getTyreModel());
|
|
|
|
|
String level = safeGetString(baseTyre.getTyreLevel());
|
|
|
|
|
String pattern = safeGetString(baseTyre.getTyrePattern());
|
|
|
|
|
String patternDeepth = safeGetString(baseTyre.getPatternDepth());
|
|
|
|
|
String pressure = safeGetString(baseTyre.getPressure());
|
|
|
|
|
team = safeGetString(baseTyre.getTeam());
|
|
|
|
|
TYREPYTE = "new".equals(TYREPYTE) ? "全新胎" : TYREPYTE;
|
|
|
|
|
patternDepth = safeGetString(baseTyre.getPatternDepth());
|
|
|
|
|
pinpai.setText(brand);
|
|
|
|
|
xinghao.setText(model);
|
|
|
|
|
cengji.setText(level);
|
|
|
|
|
huawen.setText(pattern);
|
|
|
|
|
huawendepth.setText(patternDeepth);
|
|
|
|
|
shengyuhuawen.setText(patternDeepth);
|
|
|
|
|
qiya.setText(pressure);
|
|
|
|
|
String carNo = baseTyre.getCarNo();
|
|
|
|
|
if (carNo == null || "".equals(carNo)) {
|
|
|
|
|
zhuangtai.setText("未装车");
|
|
|
|
|
} else {
|
|
|
|
|
zhuangtai.setText("已装车|车牌号:"+ carNo);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
pinpai.setText("");
|
|
|
|
|
xinghao.setText("");
|
|
|
|
|
cengji.setText("");
|
|
|
|
|
huawen.setText("");
|
|
|
|
|
huawendepth.setText("");
|
|
|
|
|
qiya.setText("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<TimelineItem> data = new ArrayList<>();
|
|
|
|
|
if (dataObject.has("bizMaintenanceOrder") && !dataObject.get("bizMaintenanceOrder").isJsonNull()){
|
|
|
|
|
JsonObject maintenanceOrderObj = dataObject.get("bizMaintenanceOrder").getAsJsonObject();
|
|
|
|
|
if (maintenanceOrderObj.has("bizOrderTireDetailList") && !maintenanceOrderObj.get("bizOrderTireDetailList").isJsonNull()) {
|
|
|
|
|
JsonArray detailListArray = maintenanceOrderObj.get("bizOrderTireDetailList").getAsJsonArray();
|
|
|
|
|
|
|
|
|
|
try {String mileage = maintenanceOrderObj.has("lastMileage") ? maintenanceOrderObj.get("lastMileage").getAsString() : "";
|
|
|
|
|
String inputmileage = maintenanceOrderObj.has("inputMileage") ? maintenanceOrderObj.get("inputMileage").getAsString() : "";
|
|
|
|
|
}catch (Exception e){}
|
|
|
|
|
String mileage = maintenanceOrderObj.has("lastMileage") ? maintenanceOrderObj.get("lastMileage").getAsString() : "";
|
|
|
|
|
|
|
|
|
|
String type = maintenanceOrderObj.has("typeCode") ? maintenanceOrderObj.get("typeCode").getAsString() : "";
|
|
|
|
|
String teams = maintenanceOrderObj.has("factoryName") ? maintenanceOrderObj.get("factoryName").getAsString() : "";
|
|
|
|
|
String plateNumber = maintenanceOrderObj.has("plateNumber") ? maintenanceOrderObj.get("plateNumber").getAsString() : "";
|
|
|
|
|
for (JsonElement element : detailListArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo = itemObject.has("tireCode") ? itemObject.get("tireCode").getAsString() : "";
|
|
|
|
|
String time = itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user = itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
String wheel = itemObject.has("positionName") ? itemObject.get("positionName").getAsString() : "";
|
|
|
|
|
String tirePress = itemObject.has("tirePress") ? itemObject.get("tirePress").getAsString() : "";
|
|
|
|
|
// 直接获取,如果为 null 或不存在,自动返回 ""
|
|
|
|
|
String depth = itemObject.has("treadDepth") && !itemObject.get("treadDepth").isJsonNull()
|
|
|
|
|
? itemObject.get("treadDepth").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
if (type.equals("1")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
|
|
|
|
|
}else if (type.equals("2")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
else if (type.equals("3")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
else if (type.equals("4")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
else if (type.equals("5")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
else if (type.equals("6")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
else if (type.equals("7")){
|
|
|
|
|
data.add(new TimelineItem(time, "二级保养", Html.fromHtml("操作人:"+user+"<br>场站: "+teams+
|
|
|
|
|
"<br>车辆信息: "+plateNumber+
|
|
|
|
|
"<br>当前车辆里程: "+mileage+" KM"+
|
|
|
|
|
"<br>上次车辆里程: "+inputmileage+"KM"+
|
|
|
|
|
"<br>轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>胎压: "+tirePress)));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (dataObject.has("recordTyreInstallList") && !dataObject.get("recordTyreInstallList").isJsonNull()){
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("recordTyreInstallList");
|
|
|
|
|
JsonArray jsonArray = resultBaseElement.getAsJsonArray();
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo = itemObject.has("tyreNo") ? itemObject.get("tyreNo").getAsString() : "";
|
|
|
|
|
String type = itemObject.has("type") ? itemObject.get("type").getAsString() : "";
|
|
|
|
|
String time = itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user = itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
String wheel = itemObject.has("wheelPostion") ? itemObject.get("wheelPostion").getAsString() : "";
|
|
|
|
|
String mileage = itemObject.has("mileage") ? itemObject.get("mileage").getAsString() : "";
|
|
|
|
|
String carNo = itemObject.has("carNo") ? itemObject.get("carNo").getAsString() : "";
|
|
|
|
|
// 直接获取,如果为 null 或不存在,自动返回 ""
|
|
|
|
|
String depth = itemObject.has("patternDepth") && !itemObject.get("patternDepth").isJsonNull()
|
|
|
|
|
? itemObject.get("patternDepth").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
String stageMileage = itemObject.has("stageMileage") && !itemObject.get("stageMileage").isJsonNull()
|
|
|
|
|
? itemObject.get("stageMileage").getAsString()
|
|
|
|
|
: "";
|
|
|
|
|
if (type.equals("0")){
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎装车", Html.fromHtml("操作人:"+user+"<br>场站: "+team+
|
|
|
|
|
"<br>车牌号: "+carNo+
|
|
|
|
|
"<br>安装轮位: "+wheel+
|
|
|
|
|
"<br>装车里程: "+mileage+" KM"+
|
|
|
|
|
"<br>花纹深度: "+depth+"mm")));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}else if (type.equals("1")){
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎卸车", Html.fromHtml("操作人:"+user+"<br>场站: "+team+
|
|
|
|
|
"<br>车牌号: "+carNo+
|
|
|
|
|
"<br>卸下轮位: "+wheel+
|
|
|
|
|
"<br>剩余花纹深度: "+depth+"mm"+
|
|
|
|
|
"<br>卸车里程: "+mileage+"KM"+
|
|
|
|
|
"<br>行驶里程: "+stageMileage+"KM")));
|
|
|
|
|
shengyuhuawen.setText(depth);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//出入库数据
|
|
|
|
|
|
|
|
|
|
if(dataObject.has("recordWarehousingList") && !dataObject.get("recordWarehousingList").isJsonNull()){
|
|
|
|
|
JsonElement resultBaseElement = dataObject.get("recordWarehousingList");
|
|
|
|
|
JsonArray jsonArray = resultBaseElement.getAsJsonArray();
|
|
|
|
|
// 2. 遍历数组中的每一个元素
|
|
|
|
|
for (JsonElement element : jsonArray) {
|
|
|
|
|
// 3. 将每个元素转为 JsonObject,方便通过键名取值
|
|
|
|
|
JsonObject itemObject = element.getAsJsonObject();
|
|
|
|
|
// 4. 提取你需要的字段(假设里面有 "warehouseId" 和 "status" 字段)
|
|
|
|
|
String tyreNo = itemObject.has("tyreNo") ? itemObject.get("tyreNo").getAsString() : "";
|
|
|
|
|
String type = itemObject.has("type") ? itemObject.get("type").getAsString() : "";
|
|
|
|
|
String time = itemObject.has("createTime") ? itemObject.get("createTime").getAsString() : "";
|
|
|
|
|
String user = itemObject.has("createBy") ? itemObject.get("createBy").getAsString() : "";
|
|
|
|
|
// 打印或处理你的数据
|
|
|
|
|
if (type.equals("0")){
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎入库", Html.fromHtml("操作人:"+user+"<br>场站: "+team+
|
|
|
|
|
"<br>轮胎类型: "+TYREPYTE+
|
|
|
|
|
"<br>剩余花纹深度: "+patternDepth+"mm")));
|
|
|
|
|
}else if (type.equals("1")){
|
|
|
|
|
data.add(new TimelineItem(time, "轮胎出库", Html.fromHtml("操作人:"+user+"<br>场站: "+team+
|
|
|
|
|
"<br>轮胎类型: "+TYREPYTE+
|
|
|
|
|
"<br>剩余花纹深度: "+patternDepth+"mm")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderTimeline(data);
|
|
|
|
|
data.clear();
|
|
|
|
|
}
|
|
|
|
|
} catch (JsonSyntaxException e) {
|
|
|
|
|
pinpai.setText("");
|
|
|
|
|
xinghao.setText("");
|
|
|
|
|
cengji.setText("");
|
|
|
|
|
huawen.setText("");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onError(Response<String> response) {
|
|
|
|
|
super.onError(response);
|
|
|
|
|
// ✅ 修改点 3:网络请求失败也要关闭弹窗
|
|
|
|
|
Toast.makeText(TyreSearchActivity.this, "网络请求失败", Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
private String safeGetString(String value) {
|
|
|
|
|
return value == null || "null".equals(value) ? "" : value;
|
|
|
|
|
}
|
|
|
|
|
private void showLoadingDialog() {
|
|
|
|
|
if (progressDialog == null) {
|
|
|
|
|
progressDialog = new ProgressDialog(this);
|
|
|
|
|
progressDialog.setMessage("数据加载中...");
|
|
|
|
|
progressDialog.setCancelable(false);
|
|
|
|
|
}
|
|
|
|
|
if (!progressDialog.isShowing()) {
|
|
|
|
|
progressDialog.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void hideLoadingDialog() {
|
|
|
|
|
if (progressDialog != null && progressDialog.isShowing()) {
|
|
|
|
|
progressDialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|