|
|
@@ -13,6 +13,7 @@ import com.huntersun.vkyes.etcopencard.project.api.MyRetrofit; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.Result; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.bean.CardBean; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.bean.QueryCardInfoResponse; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.ui.adapter.CheckRunningCardListAdapter2; |
|
|
@@ -25,7 +26,8 @@ import com.huntersun.vkyes.etcopencard.src.widget.StatusLayout; |
|
|
|
import com.parkingwang.keyboard.PopupKeyboard; |
|
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout; |
|
|
|
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener; |
|
|
|
|
|
|
|
import com.huntersun.vkyes.etcopencard.project.tool.MyShared; |
|
|
|
import com.huntersun.vkyes.etcopencard.project.utils.Constants; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
@@ -35,6 +37,8 @@ import java.util.Map; |
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import retrofit2.Response; |
|
|
|
import com.hjq.toast.ToastUtils; |
|
|
|
import com.blankj.utilcode.util.LogUtils; |
|
|
|
|
|
|
|
/** |
|
|
|
* Date :2023-03-24 |
|
|
@@ -92,29 +96,49 @@ public class CheckRunningWaterStep1Activity extends AppActivity implements OnRef |
|
|
|
|
|
|
|
private void getList() { |
|
|
|
Map<String, String> params = new HashMap<>(); |
|
|
|
// params.put("vehicleId", curVehicleId); |
|
|
|
params.put("accessToken", MyShared.getInstance().get(MyShared.ACCESSTOKEN, "") + ""); |
|
|
|
params.put("loginSource", Constants.LOGIN_SOURCE); |
|
|
|
params.put("vehicleId", curVehicleId); |
|
|
|
params.put("vehiclePlate", curVehicleId.split("_")[0]); |
|
|
|
params.put("vehiclePlateColor", curVehicleId.split("_")[1]); |
|
|
|
MyRetrofit.newInstanceGZ(true,IFCode.IFCODE152, params, new MyRetrofit.ReturnResult() { |
|
|
|
|
|
|
|
LogUtils.i("通行流水查询", "请求参数: " + JSONObject.toJSONString(params)); |
|
|
|
MyRetrofit.newInstanceGZ(true, IFCode.IFCODE152, params, new MyRetrofit.ReturnResult() { |
|
|
|
@Override |
|
|
|
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { |
|
|
|
//FunHelper.closeKeyboard(etSearch); |
|
|
|
if (popupKeyboard != null) popupKeyboard.dismiss(CheckRunningWaterStep1Activity.this); |
|
|
|
LinkedTreeMap<String,Object> data = JSONObject.parseObject(resultBean.getData().toString(),LinkedTreeMap.class); |
|
|
|
List<CardBean> result = JSONArray.parseArray(data.get("result").toString(),CardBean.class); |
|
|
|
if (FunHelper.isEmpty(result)) { |
|
|
|
postDelayed(CheckRunningWaterStep1Activity.this::showEmpty, 300); |
|
|
|
return; |
|
|
|
LogUtils.i("通行流水查询", "接口返回: " + JSONObject.toJSONString(resultBean)); |
|
|
|
|
|
|
|
try { |
|
|
|
// 解析返回数据 |
|
|
|
String dataStr = resultBean.getData().toString(); |
|
|
|
LogUtils.i("通行流水查询", "原始数据: " + dataStr); |
|
|
|
|
|
|
|
// 使用JSONObject解析数据 |
|
|
|
com.alibaba.fastjson.JSONObject dataJson = JSONObject.parseObject(dataStr); |
|
|
|
QueryCardInfoResponse response = parseQueryCardInfoResponse(dataJson); |
|
|
|
|
|
|
|
if (popupKeyboard != null) popupKeyboard.dismiss(CheckRunningWaterStep1Activity.this); |
|
|
|
|
|
|
|
if (response == null || response.cardInfoList == null || response.cardInfoList.isEmpty()) { |
|
|
|
postDelayed(CheckRunningWaterStep1Activity.this::showEmpty, 300); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 将新数据模型转换为CardBean列表 |
|
|
|
List<CardBean> result = convertToCardBeanList(response); |
|
|
|
showComplete(); |
|
|
|
adapter.replaceData(result); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
LogUtils.e("通行流水查询", "数据解析失败: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
if (popupKeyboard != null) popupKeyboard.dismiss(CheckRunningWaterStep1Activity.this); |
|
|
|
ToastUtils.show("数据解析失败"); |
|
|
|
} |
|
|
|
showComplete(); |
|
|
|
adapter.replaceData(result); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onError(Result resp) { |
|
|
|
if (popupKeyboard != null) popupKeyboard.dismiss(CheckRunningWaterStep1Activity.this); |
|
|
|
if (null!=resp){ |
|
|
|
if (null != resp) { |
|
|
|
new ConfirmDialog.Builder(CheckRunningWaterStep1Activity.this).setMsg(resp.message, "", "确定", "", R.mipmap.icon_lotgout_etc_hint, 0, true) |
|
|
|
.onClick(new ConfirmDialog.Result() { |
|
|
|
@Override |
|
|
@@ -131,6 +155,59 @@ public class CheckRunningWaterStep1Activity extends AppActivity implements OnRef |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 解析查询车辆(卡、人信息)接口返回数据 |
|
|
|
*/ |
|
|
|
private QueryCardInfoResponse parseQueryCardInfoResponse(com.alibaba.fastjson.JSONObject dataJson) { |
|
|
|
QueryCardInfoResponse response = new QueryCardInfoResponse(); |
|
|
|
|
|
|
|
try { |
|
|
|
// 解析用户手机号 |
|
|
|
response.customerTel = dataJson.getString("customerTel"); |
|
|
|
|
|
|
|
// 解析卡信息列表 |
|
|
|
com.alibaba.fastjson.JSONArray cardInfoArray = dataJson.getJSONArray("cardInfoList"); |
|
|
|
if (cardInfoArray != null && !cardInfoArray.isEmpty()) { |
|
|
|
response.cardInfoList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < cardInfoArray.size(); i++) { |
|
|
|
com.alibaba.fastjson.JSONObject cardInfoJson = cardInfoArray.getJSONObject(i); |
|
|
|
QueryCardInfoResponse.CardInfoModel cardInfo = new QueryCardInfoResponse.CardInfoModel(); |
|
|
|
cardInfo.cardId = cardInfoJson.getString("cardId"); |
|
|
|
cardInfo.cardStatus = cardInfoJson.getString("cardStatus"); |
|
|
|
cardInfo.cardType = cardInfoJson.getIntValue("cardType"); |
|
|
|
response.cardInfoList.add(cardInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
LogUtils.e("通行流水查询", "解析数据异常: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将新数据模型转换为CardBean列表 |
|
|
|
*/ |
|
|
|
private List<CardBean> convertToCardBeanList(QueryCardInfoResponse response) { |
|
|
|
List<CardBean> result = new ArrayList<>(); |
|
|
|
|
|
|
|
if (response.cardInfoList != null) { |
|
|
|
for (QueryCardInfoResponse.CardInfoModel cardInfo : response.cardInfoList) { |
|
|
|
CardBean cardBean = new CardBean(); |
|
|
|
cardBean.cardId = cardInfo.cardId; |
|
|
|
cardBean.cardStatus = cardInfo.cardStatus; |
|
|
|
cardBean.cardType = String.valueOf(cardInfo.cardType); |
|
|
|
cardBean.tel = response.customerTel; // 设置用户手机号 |
|
|
|
result.add(cardBean); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public StatusLayout getStatusLayout() { |
|
|
|
return binding.hlStatusHint; |