fix: 修改充电站充电桩数据保存流程
This commit is contained in:
parent
7339f6ad1d
commit
578a95013c
@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion '29.0.2'
|
||||
ndkVersion '23.0.7123448'
|
||||
ndkVersion '21.0.6113669'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
@ -123,7 +123,7 @@ dependencies {
|
||||
|
||||
// 视频拼接 https://blog.csdn.net/u011520181/article/details/89324292
|
||||
implementation 'com.googlecode.mp4parser:isoparser:1.1.21'
|
||||
// Android常用库
|
||||
// Android常用库 https://github.com/l123456789jy/Lazy
|
||||
implementation 'com.github.lazylibrary:lazylibrary:1.0.2'
|
||||
//屏幕的适配百分比
|
||||
//https://www.jianshu.com/p/0c2a8db91bda?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
|
||||
|
@ -79,8 +79,8 @@ public class Constant {
|
||||
public static final int HOME_TREASURE = 33;//点击寻宝实时监听刷新
|
||||
public static final int JOB_WORD_MONITOR = 34;//筛选条件的刷新
|
||||
public static final int EVENT_WHAT_LOCATION_CHANGE = 35; // 定位位置更新的Event的What值
|
||||
public static final int CHARGING_PILE_BODY = 36;//充电装的body
|
||||
public static final int CHARGING_PILE_PHONE = 37;//充电桩的照片
|
||||
// public static final int CHARGING_PILE_BODY = 36;//充电装的body
|
||||
// public static final int CHARGING_PILE_PHOTO = 37;//充电桩的照片
|
||||
public static final int EVENT_WHAT_CURRENT_MARKER = 41; // 显示当前正在编辑的POI类型数据的Event的What值
|
||||
|
||||
|
||||
|
@ -52,6 +52,7 @@ import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.PhotoPathUtil;
|
||||
import com.navinfo.outdoor.util.PictureUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@ -88,7 +89,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
private String buffer1="",buffer2="",buffer3="",buffer4="",buffer5="";
|
||||
private StringBuffer openType = new StringBuffer();
|
||||
private CheckBox checkButton1, checkButton2, checkButton3, checkButton4, checkButton5;
|
||||
private long pid;
|
||||
private String pid;
|
||||
private String station;
|
||||
private LatLng latLng;
|
||||
private String takePhotoPath1;
|
||||
@ -211,6 +212,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
buffer2="2,";
|
||||
checkButton1.setChecked(false);
|
||||
}else {
|
||||
buffer2="";
|
||||
}
|
||||
@ -222,6 +224,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
buffer3="3,";
|
||||
checkButton1.setChecked(false);
|
||||
}else {
|
||||
buffer3="";
|
||||
}
|
||||
@ -233,6 +236,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
buffer4="4,";
|
||||
checkButton1.setChecked(false);
|
||||
}else {
|
||||
buffer4="";
|
||||
}
|
||||
@ -244,6 +248,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
buffer5="5,";
|
||||
checkButton1.setChecked(false);
|
||||
}else {
|
||||
buffer5="";
|
||||
}
|
||||
@ -426,8 +431,8 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
if (memo != null&&!memo.equals("")) {
|
||||
editDescribe.setText(memo);
|
||||
}
|
||||
long fid = chargingPileEntity.getFid();
|
||||
if (fid != 0) {
|
||||
String fid = chargingPileEntity.getFid();
|
||||
if (fid != null) {
|
||||
pid = fid;
|
||||
}
|
||||
int sign_exist = chargingPileEntity.getSign_exist();
|
||||
@ -570,16 +575,15 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
if (all) {
|
||||
//保存数据库:
|
||||
ChargingPileEntity chargingPileEntity = new ChargingPileEntity();
|
||||
ArrayList<String> photoBean;
|
||||
photoBean = new ArrayList<>();
|
||||
ArrayList<String> photoBean = new ArrayList<>();
|
||||
if (latLng == null || latLng.equals("")) {
|
||||
Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
} else {
|
||||
String encode = Geohash.getInstance().encode(latLng.latitude,latLng.longitude);
|
||||
chargingPileEntity.setP(encode);
|
||||
poiEntity.setX(String.valueOf(latLng.longitude));
|
||||
poiEntity.setY(String.valueOf(latLng.latitude));
|
||||
// poiEntity.setX(String.valueOf(latLng.longitude));
|
||||
// poiEntity.setY(String.valueOf(latLng.latitude));
|
||||
|
||||
}
|
||||
String name = tvNameContent.getText().toString().trim();//名称
|
||||
@ -667,7 +671,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
photoBean.add(tagNumber);
|
||||
}
|
||||
chargingPileEntity.setPhotos(photoBean);
|
||||
if (buffer1!=null&&!buffer1.equals("")){
|
||||
|
||||
if ("".equals(buffer1)&&"".equals(buffer2)&&"".equals(buffer3)&&"".equals(buffer4)&&"".equals(buffer5)) {
|
||||
Toast.makeText(getActivity(), "开放状态未勾选", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (buffer1!=null&&!buffer1.equals("")&&buffer1.length()>0){
|
||||
openType.delete(0,openType.length());
|
||||
openType.append(buffer1);
|
||||
String charAt = openType.deleteCharAt(openType.length() - 1).toString();
|
||||
@ -691,22 +700,36 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
if (describe != null && !describe.equals("")) {
|
||||
chargingPileEntity.setMemo(describe);
|
||||
}
|
||||
if (pid == 0) {
|
||||
Toast.makeText(getActivity(), "没有tastId", Toast.LENGTH_SHORT).show();
|
||||
if (pid == null) {
|
||||
Toast.makeText(getActivity(), "没有对应的充电站Id", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
chargingPileEntity.setFid(pid);
|
||||
}
|
||||
chargingPileEntity.setTaskStatus(2); // 设置当前充电桩任务状态为本地保存但未上传
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chargingPileDao.insertChargingPileEntity(chargingPileEntity);
|
||||
long[] result = InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result[0]!=0) {
|
||||
ToastUtil.showShort(getActivity(), "充电桩保存成功");
|
||||
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.CHARGING_PILE_STATION;
|
||||
obtain.obj = chargingPileEntity;
|
||||
EventBus.getDefault().post(obtain);
|
||||
// chargingPileByWork(chargingPileEntity);
|
||||
getActivity().onBackPressed();
|
||||
} else {
|
||||
ToastUtil.showShort(getActivity(), "充电桩保存失败,请重试!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.CHARGING_PILE_STATION;
|
||||
obtain.obj = chargingPileEntity;
|
||||
EventBus.getDefault().post(obtain);
|
||||
chargingPileByWork(chargingPileEntity);
|
||||
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
|
||||
@ -770,56 +793,56 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
}
|
||||
}
|
||||
|
||||
private void chargingPileByWork(ChargingPileEntity chargingPileEntity) {
|
||||
showLoadingDialog();
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", taskId);
|
||||
httpParams.put("name", chargingPileEntity.getName());
|
||||
httpParams.put("existence", chargingPileEntity.getExist());
|
||||
httpParams.put("geo", chargingPileEntity.getP());
|
||||
httpParams.put("memo", chargingPileEntity.getMemo());
|
||||
httpParams.put("ffid", chargingPileEntity.getFid());
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
|
||||
hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
|
||||
hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
|
||||
hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
|
||||
httpParams.put("detail", String.valueOf(hashMap));
|
||||
OkGoBuilder.getInstance()
|
||||
.Builder(getActivity())
|
||||
.url(HttpInterface.SUBMIT_CSTASK)
|
||||
.method(OkGoBuilder.GET)
|
||||
.cls(ChargingPileSaveBean.class)
|
||||
.params(httpParams)
|
||||
.callback(new Callback<ChargingPileSaveBean>() {
|
||||
@Override
|
||||
public void onSuccess(ChargingPileSaveBean chargingPileSaveBean, int id) {
|
||||
dismissLoadingDialog();
|
||||
chargingPileBody = chargingPileSaveBean.getBody();
|
||||
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onSuccess: " + chargingPileSaveBean.getBody());
|
||||
phoneList();
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.CHARGING_PILE_BODY;
|
||||
obtain.obj = chargingPileBody;
|
||||
EventBus.getDefault().post(obtain);
|
||||
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.CHARGING_PILE_PHONE;
|
||||
obtain1.obj = phoneLists;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
getActivity().onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + e.getMessage());
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
// private void chargingPileByWork(ChargingPileEntity chargingPileEntity) {
|
||||
// showLoadingDialog();
|
||||
// HttpParams httpParams = new HttpParams();
|
||||
// httpParams.put("taskId", taskId);
|
||||
// httpParams.put("name", chargingPileEntity.getName());
|
||||
// httpParams.put("existence", chargingPileEntity.getExist());
|
||||
// httpParams.put("geo", chargingPileEntity.getP());
|
||||
// httpParams.put("memo", chargingPileEntity.getMemo());
|
||||
// httpParams.put("ffid", chargingPileEntity.getFid());
|
||||
// HashMap<String, Object> hashMap = new HashMap<>();
|
||||
// hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
|
||||
// hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
|
||||
// hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
|
||||
// hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
|
||||
// httpParams.put("detail", String.valueOf(hashMap));
|
||||
// OkGoBuilder.getInstance()
|
||||
// .Builder(getActivity())
|
||||
// .url(HttpInterface.SUBMIT_CSTASK)
|
||||
// .method(OkGoBuilder.GET)
|
||||
// .cls(ChargingPileSaveBean.class)
|
||||
// .params(httpParams)
|
||||
// .callback(new Callback<ChargingPileSaveBean>() {
|
||||
// @Override
|
||||
// public void onSuccess(ChargingPileSaveBean chargingPileSaveBean, int id) {
|
||||
// dismissLoadingDialog();
|
||||
// chargingPileBody = chargingPileSaveBean.getBody();
|
||||
// Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
|
||||
// Log.d("TAG", "onSuccess: " + chargingPileSaveBean.getBody());
|
||||
// phoneList();
|
||||
// Message obtain = Message.obtain();
|
||||
// obtain.what = Constant.CHARGING_PILE_BODY;
|
||||
// obtain.obj = chargingPileBody;
|
||||
// EventBus.getDefault().post(obtain);
|
||||
//
|
||||
// Message obtain1 = Message.obtain();
|
||||
// obtain1.what = Constant.CHARGING_PILE_PHOTO;
|
||||
// obtain1.obj = phoneLists;
|
||||
// EventBus.getDefault().post(obtain1);
|
||||
// getActivity().onBackPressed();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e, int id) {
|
||||
// dismissLoadingDialog();
|
||||
// Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
// Log.d("TAG", "onError: " + e.getMessage());
|
||||
// }
|
||||
// }).build();
|
||||
// }
|
||||
|
||||
private void phoneList() {
|
||||
phoneLists = new ArrayList<>();
|
||||
@ -943,7 +966,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
if (describe != null && !describe.equals("")) {
|
||||
chargingPileEntity.setMemo(describe);
|
||||
}
|
||||
if (pid != 0) {
|
||||
if (pid != null) {
|
||||
chargingPileEntity.setFid(pid);
|
||||
}
|
||||
if (buffer1!=null&&!buffer1.equals("")){
|
||||
@ -954,8 +977,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
|
||||
openType.append(buffer3);
|
||||
openType.append(buffer4);
|
||||
openType.append(buffer5);
|
||||
String charAt = openType.deleteCharAt(openType.length() - 1).toString();
|
||||
chargingPileEntity.setCp_openType(charAt);
|
||||
if (openType!=null&&!"".equals(openType)&&openType.length()>0) {
|
||||
String charAt = openType.deleteCharAt(openType.length() - 1).toString();
|
||||
chargingPileEntity.setCp_openType(charAt);
|
||||
} else {
|
||||
chargingPileEntity.setCp_openType("");
|
||||
}
|
||||
}
|
||||
String newChargingPileEntity = new Gson().toJson(chargingPileEntity);
|
||||
//以键值对的形式添加新值。
|
||||
|
@ -45,6 +45,7 @@ import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.adapter.ChargingPileAdapter;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.bean.ChargingPileSaveBean;
|
||||
import com.navinfo.outdoor.bean.ChargingStationBean;
|
||||
import com.navinfo.outdoor.bean.Info;
|
||||
import com.navinfo.outdoor.bean.PhoneBean;
|
||||
@ -68,12 +69,16 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
||||
/**
|
||||
@ -103,17 +108,17 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
private RecyclerView recyclerStation;
|
||||
private ChargingPileAdapter chargingPileAdapter;
|
||||
private int station_type = 0;
|
||||
private PoiEntity showPoiEntity;
|
||||
private PoiEntity showPoiEntity; // 要显示的entity数据,从外部界面传入
|
||||
private ChargingPileDao chargingPileDao;
|
||||
private LatLng latLng;
|
||||
private RelativeLayout linearExist;
|
||||
private Spinner spinnerExist;
|
||||
private Integer body;
|
||||
private Integer bodyId;
|
||||
private LinearLayout linearContact;
|
||||
private ContactView contactView;
|
||||
private Integer chargingPileBody;
|
||||
// private Integer chargingPileBody;
|
||||
private ArrayList<File> chargingStationList;
|
||||
private ArrayList<File> fileList;
|
||||
// private ArrayList<File> fileList;
|
||||
|
||||
public static ChargingStationFragment newInstance(Bundle bundle) {
|
||||
ChargingStationFragment fragment = new ChargingStationFragment();
|
||||
@ -364,7 +369,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
if (address != null && !address.equals("")) {
|
||||
editSiteContent.setText(address);
|
||||
}
|
||||
body = showPoiEntity.getBodyId();
|
||||
bodyId = showPoiEntity.getBodyId(); // 获取当前数据的bodyId
|
||||
String x = showPoiEntity.getX();
|
||||
String y = showPoiEntity.getY();
|
||||
if (x != null && y != null) {
|
||||
@ -427,7 +432,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
poiBeans.add(new PhoneBean("电话*", "", Constant.CODE, R.drawable.icon_add_bg));
|
||||
}
|
||||
}
|
||||
body = showPoiEntity.getBodyId();
|
||||
contactView = new ContactView(getActivity(), linearContact, poiBeans);
|
||||
contactView.resetView();
|
||||
//poiRecycleAdapter.setList(poiBeans);
|
||||
@ -457,30 +461,19 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<ChargingPileEntity> chargingPileEntities = new ArrayList<>();
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<ChargingPileEntity> chargingPile = chargingPileDao.getChargingPile();
|
||||
for (int i = 0; i < chargingPile.size(); i++) {
|
||||
ChargingPileEntity chargingPileEntity = chargingPile.get(i);
|
||||
if (showPoiEntity.getId() == chargingPileEntity.getFid()) {
|
||||
chargingPileEntities.add(chargingPileEntity);
|
||||
}
|
||||
}
|
||||
List<ChargingPileEntity> chargingPileList = chargingPileDao.getChargingPileByStationId(showPoiEntity.getId());
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chargingPileAdapter.setChargingPileEntities(chargingPileEntities);
|
||||
chargingPileAdapter.setChargingPileEntities(chargingPileList);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
if (showPoiEntity.getId() != 0) {
|
||||
initPile();
|
||||
}
|
||||
if (showPoiEntity.getTaskStatus()==3){
|
||||
disables();
|
||||
}
|
||||
@ -580,22 +573,21 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.CHARGING_STATION_WORD) {
|
||||
if (data.what == Constant.CHARGING_STATION_WORD) { // 移动充电站点位
|
||||
latLng = (LatLng) data.obj;
|
||||
} else if (data.what == Constant.CHARGING_PILE_STATION) {
|
||||
} else if (data.what == Constant.CHARGING_PILE_STATION) { // 新增充电桩
|
||||
ChargingPileEntity chargingPileEntity = (ChargingPileEntity) data.obj;
|
||||
ArrayList<ChargingPileEntity> chargingPileEntities = new ArrayList<>();
|
||||
chargingPileEntities.add(chargingPileEntity);
|
||||
chargingPileAdapter.setChargingPileEntities(chargingPileEntities);
|
||||
} else if (data.what == Constant.CHARGING_PILE_BODY) {
|
||||
chargingPileBody = (Integer) data.obj;
|
||||
} else if (data.what == Constant.CHARGING_PILE_PHONE) {
|
||||
fileList = (ArrayList<File>) data.obj;
|
||||
}
|
||||
/*else if (data.what == Constant.CHARGING_PILE_BODY) {
|
||||
chargingPileBody = (Integer) data.obj;
|
||||
} else if (data.what == Constant.CHARGING_PILE_PHOTO) {
|
||||
fileList = (ArrayList<File>) data.obj;
|
||||
}*/
|
||||
}
|
||||
|
||||
private boolean isChargeStationUploaded = false, isChargingPoleUploaded = false;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
@ -629,9 +621,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
if (tagScutcheon != null) {
|
||||
chargingStationList.add(new File(tagScutcheon));
|
||||
}
|
||||
|
||||
isChargeStationUploaded = false;
|
||||
isChargingPoleUploaded = false;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -639,11 +628,12 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
if (poiDaoPoiEntity == null || poiDaoPoiEntity.getTaskStatus() == 0 || poiDaoPoiEntity.getTaskStatus() == 1 || poiDaoPoiEntity.getTaskStatus() == 2) {
|
||||
initRoadSaveLocal(true);
|
||||
} else {
|
||||
// 首先批量保存充电站对应的充电桩数据
|
||||
saveChargingPileByChargingStation(poiDaoPoiEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chargingPileUploadNetWork(poiDaoPoiEntity.getBodyId(), fileList);
|
||||
stationUploadByNetWork(poiDaoPoiEntity.getBodyId(), chargingStationList);
|
||||
stationUploadByNetWork(poiDaoPoiEntity, chargingStationList);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -683,43 +673,89 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
}
|
||||
}
|
||||
|
||||
private void chargingPileUploadNetWork(int chargingPileBody, ArrayList<File> fileList) {
|
||||
if (chargingPileBody == 0) {
|
||||
/**
|
||||
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
|
||||
* */
|
||||
private void saveChargingPileByChargingStation(PoiEntity chargingStationPoiEntity) {
|
||||
if (chargingStationPoiEntity != null) {
|
||||
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
|
||||
if (chargingPileEntityList!=null&&!chargingPileEntityList.isEmpty()) {
|
||||
for (ChargingPileEntity pileEntity: chargingPileEntityList) {
|
||||
if (pileEntity.getBodyId()==0) {
|
||||
saveChargingPileByWork(pileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传充电桩数据
|
||||
* */
|
||||
private void chargingPileUploadNetWork(ChargingPileEntity chargingPileEntity) {
|
||||
if (chargingPileEntity==null|| chargingPileEntity.getBodyId() == 0) {
|
||||
Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show();
|
||||
Log.e("TAG", "poiUploadByNetWork: " + body + fileList);
|
||||
return;
|
||||
}
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<PoiUploadBean>post(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", chargingPileBody)
|
||||
.addFileParams("file", fileList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<PoiUploadBean>(PoiUploadBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
|
||||
isChargingPoleUploaded = true;
|
||||
if (isChargeStationUploaded && isChargingPoleUploaded) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getActivity().onBackPressed();//回退
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
super.onError(poiUploadBeanResponse);
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), poiUploadBeanResponse.code() + "", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + poiUploadBeanResponse.code() + "");
|
||||
}
|
||||
});
|
||||
List<File> chargingPileFileList = new ArrayList<>();
|
||||
if (chargingPileEntity.getPhotos()!=null&&!chargingPileEntity.getPhotos().isEmpty()) {
|
||||
for (String photoPath: chargingPileEntity.getPhotos()) {
|
||||
chargingPileFileList.add(new File(photoPath));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
okhttp3.Response execute = OkGo
|
||||
// 请求方式和请求url
|
||||
.<PoiUploadBean>post(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", chargingPileEntity.getBodyId())
|
||||
.addFileParams("file", chargingPileFileList)
|
||||
.tag(this)
|
||||
.execute();
|
||||
String pileUpLoadResultStr = execute.body().string();
|
||||
PoiUploadBean uploadBeanResult = new Gson().fromJson(pileUpLoadResultStr, PoiUploadBean.class);
|
||||
if (uploadBeanResult!=null) {
|
||||
if (uploadBeanResult.getCode() == 200) {
|
||||
PoiDatabase.getInstance(getActivity()).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// OkGo
|
||||
// // 请求方式和请求url
|
||||
// .<PoiUploadBean>post(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
||||
// // 请求的 tag, 主要用于取消对应的请求
|
||||
// .params("auditId", chargingPileEntity.getBodyId())
|
||||
// .addFileParams("file", chargingPileFileList)
|
||||
// .tag(this)
|
||||
// .execute(new DialogCallback<PoiUploadBean>(PoiUploadBean.class) {
|
||||
// @Override
|
||||
// public void onSuccess(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
// dismissLoadingDialog();
|
||||
// Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
|
||||
// isChargingPoleUploaded = true;
|
||||
// if (isChargeStationUploaded && isChargingPoleUploaded) {
|
||||
// getActivity().runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// getActivity().onBackPressed();//回退
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
// super.onError(poiUploadBeanResponse);
|
||||
// dismissLoadingDialog();
|
||||
// Toast.makeText(getActivity(), poiUploadBeanResponse.code() + "", Toast.LENGTH_SHORT).show();
|
||||
// Log.d("TAG", "onError: " + poiUploadBeanResponse.code() + "");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void initRoadSaveLocal(boolean isLocal) {
|
||||
@ -829,53 +865,84 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
});
|
||||
}
|
||||
|
||||
private void stationUploadByNetWork(int body, ArrayList<File> chargingStationList) {
|
||||
if (body == 0) {
|
||||
private void stationUploadByNetWork(PoiEntity poiEntity, ArrayList<File> chargingStationList) {
|
||||
if (poiEntity == null || poiEntity.getBodyId()==0) {
|
||||
Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show();
|
||||
Log.e("TAG", "poiUploadByNetWork: " + body + chargingStationList);
|
||||
Log.e("TAG", "poiUploadByNetWork: " + poiEntity.getBodyId() + chargingStationList);
|
||||
return;
|
||||
}
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<PoiUploadBean>post(HttpInterface.C_TASK_UP_LOAD_PIC)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", body)
|
||||
.addFileParams("file", chargingStationList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<PoiUploadBean>(PoiUploadBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onSuccess: " + poiUploadBeanResponse.toString() + "sssssssssssss");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiDao.deletePoiEntity(showPoiEntity);
|
||||
isChargeStationUploaded = true;
|
||||
if (isChargeStationUploaded && isChargingPoleUploaded) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getActivity().onBackPressed();//回退
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 首先批量上传充电桩数据
|
||||
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(poiEntity.getId());
|
||||
if (chargingPileEntityList!=null&&!chargingPileEntityList.isEmpty()) {
|
||||
for (ChargingPileEntity chargingPileEntity: chargingPileEntityList) {
|
||||
if (chargingPileEntity.getBodyId()!=0) {
|
||||
chargingPileUploadNetWork(chargingPileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void onError(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
super.onError(poiUploadBeanResponse);
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), poiUploadBeanResponse.code() + "", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + poiUploadBeanResponse.code() + "");
|
||||
public void run() {
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<PoiUploadBean>post(HttpInterface.C_TASK_UP_LOAD_PIC)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", poiEntity.getBodyId())
|
||||
.addFileParams("file", chargingStationList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<PoiUploadBean>(PoiUploadBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
dismissLoadingDialog();
|
||||
if (poiUploadBeanResponse == null || poiUploadBeanResponse.code()!=200||poiUploadBeanResponse.body().getCode()!=200) {
|
||||
Toast.makeText(getActivity(), "上传失败", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (poiUploadBeanResponse!=null&&poiUploadBeanResponse.code()==200) {
|
||||
PoiUploadBean body = poiUploadBeanResponse.body();
|
||||
if (body.getCode() == 200) {
|
||||
Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onSuccess: " + poiUploadBeanResponse.toString() + "sssssssssssss");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiDao.deletePoiEntity(showPoiEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getActivity().onBackPressed();//回退
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<PoiUploadBean> poiUploadBeanResponse) {
|
||||
super.onError(poiUploadBeanResponse);
|
||||
dismissLoadingDialog();
|
||||
Toast.makeText(getActivity(), poiUploadBeanResponse.code() + "", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + poiUploadBeanResponse.code() + "");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存充电站数据到服务器
|
||||
* */
|
||||
private void chargingStationSaveByWork(PoiEntity poiEntity, boolean isLocal) {
|
||||
showLoadingDialog();
|
||||
|
||||
@ -897,19 +964,21 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
@Override
|
||||
public void onSuccess(ChargingStationBean chargingStationBean, int id) {
|
||||
dismissLoadingDialog();
|
||||
body = chargingStationBean.getBody();
|
||||
poiEntity.setBodyId(body);
|
||||
bodyId = chargingStationBean.getBody();
|
||||
poiEntity.setBodyId(bodyId);
|
||||
poiEntity.setTaskStatus(3);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
// 充电站数据已经保存在服务上,批量保存充电桩数据
|
||||
saveChargingPileByChargingStation(poiEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isLocal) {
|
||||
stationUploadByNetWork(body, chargingStationList);
|
||||
chargingPileUploadNetWork(chargingPileBody, fileList);
|
||||
stationUploadByNetWork(poiEntity, chargingStationList);
|
||||
// chargingPileUploadNetWork(chargingPileBody, fileList);
|
||||
} else {
|
||||
Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
|
||||
onBackPressed();
|
||||
@ -1178,6 +1247,64 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传充电桩数据到服务端
|
||||
* */
|
||||
private void saveChargingPileByWork(ChargingPileEntity chargingPileEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", chargingPileEntity.getTaskId());
|
||||
httpParams.put("name", chargingPileEntity.getName());
|
||||
httpParams.put("existence", chargingPileEntity.getExist());
|
||||
httpParams.put("geo", chargingPileEntity.getP());
|
||||
httpParams.put("memo", chargingPileEntity.getMemo());
|
||||
httpParams.put("ffid", chargingPileEntity.getFid());
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
|
||||
hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
|
||||
hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
|
||||
hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
|
||||
httpParams.put("detail", String.valueOf(hashMap));
|
||||
try {
|
||||
okhttp3.Response execute = OkGo.<String>get(HttpInterface.SUBMIT_CSTASK)
|
||||
.params(httpParams)
|
||||
.tag(ChargingStationFragment.this)
|
||||
.execute();
|
||||
String responseBodyStr = execute.body().string();
|
||||
if (responseBodyStr!=null) {
|
||||
Gson gson = new Gson();
|
||||
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
|
||||
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntity); // 更新当前充电桩的bodyId
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// OkGoBuilder.getInstance()
|
||||
// .Builder(getActivity())
|
||||
// .url(HttpInterface.SUBMIT_CSTASK)
|
||||
// .method(OkGoBuilder.GET)
|
||||
// .cls(ChargingPileSaveBean.class)
|
||||
// .params(httpParams)
|
||||
// .callback(new Callback<ChargingPileSaveBean>() {
|
||||
// @Override
|
||||
// public void onSuccess(ChargingPileSaveBean chargingPileSaveBean, int id) {
|
||||
// dismissLoadingDialog();
|
||||
// chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
|
||||
// Toast.makeText(getActivity(), "服务保存成功", Toast.LENGTH_SHORT).show();
|
||||
// // 更新数据状态
|
||||
// PoiDatabase.getInstance(getActivity()).getChargingPileDao().updateChargingPileEntity(chargingPileEntity);
|
||||
// Log.d("TAG", "onSuccess: " + chargingPileSaveBean.getBody());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e, int id) {
|
||||
// dismissLoadingDialog();
|
||||
// Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
// Log.d("TAG", "onError: " + e.getMessage());
|
||||
// }
|
||||
// }).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (EventBus.getDefault().isRegistered(this))//加上判断
|
||||
|
@ -33,6 +33,7 @@ import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -288,60 +289,63 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
public void onSuccess(ReceivedBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200){
|
||||
ReceivedBean.BodyBean listBean = response.getBody();
|
||||
PoiEntity chargingListEntity = new PoiEntity();
|
||||
if (listBean!=null){
|
||||
chargingListEntity.setTaskId(taskId);
|
||||
chargingListEntity.setStation_type(listBean.getSptype());
|
||||
chargingListEntity.setName(listBean.getName());
|
||||
chargingListEntity.setPrecision(listBean.getPrice() + "");
|
||||
chargingListEntity.setAddress(listBean.getAddress());
|
||||
chargingListEntity.setTelPhone(listBean.getTelephone() + "");
|
||||
chargingListEntity.setType(Integer.valueOf(listBean.getType()));
|
||||
chargingListEntity.setTaskStatus(1);
|
||||
chargingListEntity.setIsLocalData(1);
|
||||
String geo = listBean.getGeo();
|
||||
chargingListEntity.setGeoWkt(geo);
|
||||
ReceivedBean.BodyBean stationBean = response.getBody();
|
||||
PoiEntity chargingStationEntity = new PoiEntity();
|
||||
if (stationBean!=null){
|
||||
chargingStationEntity.setTaskId(taskId);
|
||||
chargingStationEntity.setStation_type(stationBean.getSptype());
|
||||
chargingStationEntity.setName(stationBean.getName());
|
||||
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
|
||||
chargingStationEntity.setAddress(stationBean.getAddress());
|
||||
chargingStationEntity.setTelPhone(stationBean.getTelephone() + "");
|
||||
chargingStationEntity.setType(Integer.valueOf(stationBean.getType()));
|
||||
chargingStationEntity.setTaskStatus(1);
|
||||
chargingStationEntity.setIsLocalData(1);
|
||||
String geo = stationBean.getGeo();
|
||||
chargingStationEntity.setGeoWkt(geo);
|
||||
Geometry geometry = GeometryTools.createGeometry(geo);
|
||||
if (geometry.getGeometryType().equals("Point")) {//点
|
||||
LatLng latLng = GeometryTools.createLatLng(geo);
|
||||
chargingListEntity.setX(latLng.longitude + "");
|
||||
chargingListEntity.setY(latLng.latitude + "");
|
||||
chargingStationEntity.setX(latLng.longitude + "");
|
||||
chargingStationEntity.setY(latLng.latitude + "");
|
||||
} else if (geometry.getGeometryType().equals("LineString")) {//线
|
||||
List<LatLng> latLineString = GeometryTools.getLatLngs(geo);
|
||||
chargingListEntity.setX(latLineString.get(0).longitude + "");
|
||||
chargingListEntity.setY(latLineString.get(0).latitude + "");
|
||||
chargingStationEntity.setX(latLineString.get(0).longitude + "");
|
||||
chargingStationEntity.setY(latLineString.get(0).latitude + "");
|
||||
} else if (geometry.getGeometryType().equals("Polygon")) {//面
|
||||
List<LatLng> latPolygon = GeometryTools.getLatLngs(geo);
|
||||
chargingListEntity.setX(latPolygon.get(0).longitude + "");
|
||||
chargingListEntity.setY(latPolygon.get(0).latitude + "");
|
||||
chargingStationEntity.setX(latPolygon.get(0).longitude + "");
|
||||
chargingStationEntity.setY(latPolygon.get(0).latitude + "");
|
||||
}
|
||||
}
|
||||
|
||||
//充电桩
|
||||
List<ReceivedBean.BodyBean.CsTaskListBean> csTaskList = response.getBody().getCsTaskList();
|
||||
if (csTaskList!=null){
|
||||
if (csTaskList!=null&&!csTaskList.isEmpty()){
|
||||
ChargingPileEntity[] chargingPileEntityList= new ChargingPileEntity[csTaskList.size()];
|
||||
for (int i = 0; i < csTaskList.size(); i++) {
|
||||
ChargingPileEntity chargingPileEntity = new ChargingPileEntity();
|
||||
chargingPileEntity.setFid(chargingStationEntity.getId());
|
||||
chargingPileEntity.setName(csTaskList.get(i).getName());
|
||||
chargingPileEntity.setMemo(csTaskList.get(i).getAddress());
|
||||
chargingPileEntity.setP(csTaskList.get(i).getGeo());
|
||||
chargingPileEntityList[i]=chargingPileEntity;
|
||||
}
|
||||
|
||||
}
|
||||
for (int i = 0; i < csTaskList.size(); i++) {
|
||||
ChargingPileEntity chargingPileEntity = new ChargingPileEntity();
|
||||
chargingPileEntity.setFid(taskId);
|
||||
chargingPileEntity.setName(csTaskList.get(i).getName());
|
||||
chargingPileEntity.setMemo(csTaskList.get(i).getAddress());
|
||||
chargingPileEntity.setP(csTaskList.get(i).getGeo());
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chargingPileDao.insertChargingPileEntity(chargingPileEntity);
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(getActivity(), chargingPileEntityList);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
//获取当前位置的marker
|
||||
senMessageMarker(chargingListEntity.getType(),chargingListEntity.getY(),chargingListEntity.getX());
|
||||
senMessageMarker(chargingStationEntity.getType(),chargingStationEntity.getY(),chargingStationEntity.getX());
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), chargingListEntity);
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), chargingStationEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -354,7 +358,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
if (isSaver) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_MAP;
|
||||
obtain.obj = chargingListEntity;
|
||||
obtain.obj = chargingStationEntity;
|
||||
EventBus.getDefault().post(obtain);
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,25 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
if (Constant.currentLocation != null) {
|
||||
initList(Constant.currentLocation);
|
||||
// 地图中心点位置设置为当前用户所在位置
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
|
||||
tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// 移动到当前位置后,开始请求地图数据
|
||||
initList(Constant.currentLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() {
|
||||
@Override
|
||||
@ -422,7 +440,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
|
||||
.flat(true)
|
||||
.clockwise(false));
|
||||
Log.d("面妆任务", "onSuccess: " + planarMarker);
|
||||
Log.d("面状任务", "onSuccess: " + planarMarker);
|
||||
planarMarker.setTag(listBean);
|
||||
removables.add(planarMarker);
|
||||
planarMarker.setClickable(true);
|
||||
@ -851,7 +869,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
fragmentTransaction.remove(gatherGetFragment);
|
||||
|
||||
}
|
||||
} else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩
|
||||
} else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩-新增
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("isSliding", false); // 通知抽屉不收回
|
||||
bundle.putString("station", (String) data.obj);
|
||||
@ -1067,11 +1085,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
break;
|
||||
case R.id.iv_location://定位:
|
||||
if (Constant.currentLocation != null) {
|
||||
Constant.currentLocation.getLongitude();
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
|
||||
19, //目标缩放级别
|
||||
tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma);
|
||||
@ -1093,9 +1110,15 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
PoiEntity poiEntity = new PoiEntity();
|
||||
LatLng mapCenterPoint = getMapCenterPoint();
|
||||
poiEntity.setX(mapCenterPoint.longitude + "");
|
||||
poiEntity.setY(mapCenterPoint.latitude + "");
|
||||
// 上报时以当前用户位置为准
|
||||
if (Constant.currentLocation==null) {
|
||||
ToastUtil.showShort(getContext(), "无法获取当前位置,请检查GPS是否打开!");
|
||||
return;
|
||||
}
|
||||
// LatLng mapCenterPoint = getMapCenterPoint();
|
||||
LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
|
||||
poiEntity.setX(newPoiLatLng.getLongitude() + "");
|
||||
poiEntity.setY(newPoiLatLng.getLatitude() + "");
|
||||
ShareDialog.show((AppCompatActivity) getActivity(), itemList, new ShareDialog.OnItemClickListener() {
|
||||
@Override
|
||||
public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) {
|
||||
@ -1109,7 +1132,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showPoiMarkerByType(1, mapCenterPoint);
|
||||
showPoiMarkerByType(1, newPoiLatLng);
|
||||
PoiFragment poiFragment = PoiFragment.newInstance(bundle);
|
||||
|
||||
showSlidingFragment(poiFragment);
|
||||
@ -1129,7 +1152,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showPoiMarkerByType(2, mapCenterPoint);
|
||||
showPoiMarkerByType(2, newPoiLatLng);
|
||||
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
|
||||
showSlidingFragment(poiVideoFragment);
|
||||
ivMessage.setVisibility(View.GONE);
|
||||
@ -1149,7 +1172,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
@Override
|
||||
public void run() {
|
||||
bundle.putSerializable("poiEntity", poiEntity);
|
||||
showPoiMarkerByType(3, mapCenterPoint);
|
||||
showPoiMarkerByType(3, newPoiLatLng);
|
||||
RoadFragment roadFragment = RoadFragment.newInstance(bundle);
|
||||
showSlidingFragment(roadFragment);
|
||||
}
|
||||
@ -1161,12 +1184,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
// InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
bundle.putSerializable("poiEntity", poiEntity);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showPoiMarkerByType(4, mapCenterPoint);
|
||||
showPoiMarkerByType(4, newPoiLatLng);
|
||||
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
|
||||
showSlidingFragment(chargingStationFragment);
|
||||
}
|
||||
@ -1183,7 +1206,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showPoiMarkerByType(5, mapCenterPoint);
|
||||
showPoiMarkerByType(5, newPoiLatLng);
|
||||
OtherFragment otherFragment = OtherFragment.newInstance(bundle);
|
||||
showSlidingFragment(otherFragment);
|
||||
}
|
||||
|
@ -20,13 +20,19 @@ public interface ChargingPileDao {
|
||||
*/
|
||||
@Query("SELECT * FROM pile")
|
||||
List<ChargingPileEntity> getChargingPile();
|
||||
/**
|
||||
* 查询
|
||||
* @return
|
||||
*/
|
||||
@Query("SELECT * FROM pile where fid = :fid")
|
||||
List<ChargingPileEntity> getChargingPileByStationId(String fid);
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param chargingPileEntities
|
||||
*/
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
void insertChargingPileEntity(ChargingPileEntity... chargingPileEntities);
|
||||
long[] insertChargingPileEntity(ChargingPileEntity... chargingPileEntities);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
@ -45,7 +51,7 @@ public interface ChargingPileDao {
|
||||
* 删除
|
||||
*/
|
||||
@Query("DELETE FROM pile where fid=:fid")
|
||||
void deleteChargingFidPileEntity(long fid);
|
||||
void deleteChargingFidPileEntity(String fid);
|
||||
/**
|
||||
*删除
|
||||
* @param chargingPileEntities
|
||||
|
@ -22,7 +22,7 @@ import static androidx.room.ForeignKey.CASCADE;
|
||||
@Entity(tableName = "pile")
|
||||
public class ChargingPileEntity implements Serializable {
|
||||
@PrimaryKey(autoGenerate = true) // 设置主键,并且自动生长
|
||||
private int pileId;
|
||||
private long pileId;
|
||||
private String name;//名称
|
||||
private String p;//经纬度 geo加密
|
||||
private int exist;//是否存在 0不存在1存在
|
||||
@ -33,7 +33,10 @@ public class ChargingPileEntity implements Serializable {
|
||||
private String memo;//备注 默认为空
|
||||
@TypeConverters(StringTypeConverter.class)
|
||||
private List<String> photos;//照片组
|
||||
private long fid;//对应充电站id
|
||||
private String fid;//对应充电站id
|
||||
private int taskStatus;//任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集)
|
||||
private long taskId; // 充电桩的taskId,保存到服务时需要将此字段作为参数上传,自上报数据taskId为0
|
||||
private long bodyId; // 记录当前数据的bodyId,当保存到服务后,服务会返回该字段的值
|
||||
|
||||
public String getCp_openType() {
|
||||
return cp_openType;
|
||||
@ -43,11 +46,11 @@ public class ChargingPileEntity implements Serializable {
|
||||
this.cp_openType = cp_openType;
|
||||
}
|
||||
|
||||
public int getPileId() {
|
||||
public long getPileId() {
|
||||
return pileId;
|
||||
}
|
||||
|
||||
public void setPileId(int pileId) {
|
||||
public void setPileId(long pileId) {
|
||||
this.pileId = pileId;
|
||||
}
|
||||
|
||||
@ -115,11 +118,35 @@ public class ChargingPileEntity implements Serializable {
|
||||
this.photos = photos;
|
||||
}
|
||||
|
||||
public long getFid() {
|
||||
public String getFid() {
|
||||
return fid;
|
||||
}
|
||||
|
||||
public void setFid(long fid) {
|
||||
public void setFid(String fid) {
|
||||
this.fid = fid;
|
||||
}
|
||||
|
||||
public int getTaskStatus() {
|
||||
return taskStatus;
|
||||
}
|
||||
|
||||
public void setTaskStatus(int taskStatus) {
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
public long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public long getBodyId() {
|
||||
return bodyId;
|
||||
}
|
||||
|
||||
public void setBodyId(long bodyId) {
|
||||
this.bodyId = bodyId;
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,22 @@ public class InsertAndUpdateUtils {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public long[] insertOrUpdate(Context mContext,PoiEntity... entities) {
|
||||
long[] ids = PoiDatabase.getInstance(mContext).getPoiDao().insertPoiEntity(entities);
|
||||
if (ids!=null) {
|
||||
for (int i = 0; i < entities.length&&i<ids.length; i++) {
|
||||
entities[i].setId(ids[i]);
|
||||
public String[] insertOrUpdate(Context mContext,PoiEntity... entities) {
|
||||
String[] ids = new String[entities.length];
|
||||
if (entities!=null) {
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().insertPoiEntity(entities);
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
ids[i] = entities[i].getId();
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public long[] insertOrUpdateChargingPile(Context mContext,ChargingPileEntity... entities) {
|
||||
long[] ids = new long[entities.length];
|
||||
if (entities!=null) {
|
||||
ids = PoiDatabase.getInstance(mContext).getChargingPileDao().insertChargingPileEntity(entities);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public interface PoiDao {
|
||||
|
||||
|
||||
@Query("SELECT * FROM poi where id=:id")
|
||||
PoiEntity getPoiEntity(long id);
|
||||
PoiEntity getPoiEntity(String id);
|
||||
|
||||
@Query("SELECT * FROM poi where taskId=:taskId")
|
||||
PoiEntity getTaskIdPoiEntity(int taskId);
|
||||
@ -42,7 +42,7 @@ public interface PoiDao {
|
||||
* @param poiEntities
|
||||
*/
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
long[] insertPoiEntity(PoiEntity... poiEntities);
|
||||
void insertPoiEntity(PoiEntity... poiEntities);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.navinfo.outdoor.room;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
import androidx.room.TypeConverters;
|
||||
@ -9,14 +10,16 @@ import com.navinfo.outdoor.util.PhotoInfoConverter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* poi, 道路,充电站,其他的表结构
|
||||
*/
|
||||
@Entity(tableName = "poi")
|
||||
public class PoiEntity implements Serializable {
|
||||
@PrimaryKey(autoGenerate = true) // 设置主键,并且自动生长
|
||||
private long id;
|
||||
@PrimaryKey// 设置主键,并且自动生长
|
||||
@NonNull
|
||||
private String id = UUID.randomUUID().toString().replaceAll("-","");
|
||||
private int pid; //采集id 保存本地或提交数据时时返回
|
||||
private int taskId;//任务id
|
||||
private int userId;//用户id
|
||||
@ -134,11 +137,11 @@ public class PoiEntity implements Serializable {
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ -270,6 +273,7 @@ public class PoiEntity implements Serializable {
|
||||
this.detail = detail;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PoiEntity{" +
|
||||
|
197
app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java
Normal file
197
app/src/main/java/com/navinfo/outdoor/util/PoiSaveUtils.java
Normal file
@ -0,0 +1,197 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.navinfo.outdoor.bean.ChargingPileSaveBean;
|
||||
import com.navinfo.outdoor.bean.OtherUploadPicBean;
|
||||
import com.navinfo.outdoor.bean.PoiSaveBean;
|
||||
import com.navinfo.outdoor.fragment.ChargingStationFragment;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.DialogCallback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Poi数据保存公共类
|
||||
* */
|
||||
public class PoiSaveUtils {
|
||||
private Activity mContext;
|
||||
private static PoiSaveUtils instance;
|
||||
|
||||
public static PoiSaveUtils getInstance(Activity mContext) {
|
||||
if (instance == null) {
|
||||
instance = new PoiSaveUtils(mContext);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private PoiSaveUtils(Activity mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据到本地,保存后taskStatus为2
|
||||
* */
|
||||
public void savePoiLocal(PoiEntity poiEntity) {
|
||||
if (poiEntity!=null) {
|
||||
XXPermissions.with(mContext)
|
||||
//读写权限
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
.request(new OnPermissionCallback() {
|
||||
@Override
|
||||
public void onGranted(List<String> permissions, boolean all) {
|
||||
poiEntity.setTaskStatus(2);
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(mContext, poiEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied(List<String> permissions, boolean never) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据到服务
|
||||
* */
|
||||
public void savePoiNet(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("existence", poiEntity.getExistence());
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
OkGoBuilder.getInstance()
|
||||
.Builder(mContext)
|
||||
.url(HttpInterface.SUBMIT_POI_TASK)
|
||||
.method(OkGoBuilder.GET)
|
||||
.cls(PoiSaveBean.class)
|
||||
.params(httpParams)
|
||||
.callback(new Callback<PoiSaveBean>() {
|
||||
@Override
|
||||
public void onSuccess(PoiSaveBean poiSaveBean, int id) {
|
||||
Integer body = poiSaveBean.getBody();
|
||||
poiEntity.setBodyId(body);
|
||||
poiEntity.setTaskStatus(3);
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(mContext, poiEntity);
|
||||
Toast.makeText(mContext, "保存成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + e.getMessage());
|
||||
}
|
||||
}).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 最终上传数据到服务
|
||||
* */
|
||||
public void uploadPoiNet(PoiEntity poiEntity, ArrayList<File> poiPicList) {
|
||||
if (poiEntity == null) {
|
||||
Toast.makeText(mContext, "无法获取POI数据", Toast.LENGTH_SHORT).show();
|
||||
Log.e("TAG", "poiUploadByNetWork: " + poiEntity.toString());
|
||||
return;
|
||||
}
|
||||
int bodyId =poiEntity.getBodyId();
|
||||
if (bodyId == 0) {
|
||||
Toast.makeText(mContext, "该数据未保存到服务,无法上传", Toast.LENGTH_SHORT).show();
|
||||
Log.e("TAG", "poiUploadByNetWork: " + bodyId + poiPicList);
|
||||
return;
|
||||
}
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<OtherUploadPicBean>post(HttpInterface.POI_TASK_UPLOAD_PIC)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", bodyId)
|
||||
.addFileParams("file", poiPicList)
|
||||
.tag(this)
|
||||
.execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
|
||||
@Override
|
||||
public void onSuccess(Response<OtherUploadPicBean> otherUploadPicBeanResponse) {
|
||||
Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show();
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().deletePoiEntity(poiEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<OtherUploadPicBean> response) {
|
||||
super.onError(response);
|
||||
Toast.makeText(mContext, response.message() + "", Toast.LENGTH_SHORT).show();
|
||||
Log.d("TAG", "onError: " + response.message() + "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
|
||||
* */
|
||||
private void saveChargingPileByChargingStation(PoiEntity chargingStationPoiEntity) {
|
||||
if (chargingStationPoiEntity != null) {
|
||||
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(mContext).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
|
||||
if (chargingPileEntityList!=null&&!chargingPileEntityList.isEmpty()) {
|
||||
for (ChargingPileEntity pileEntity: chargingPileEntityList) {
|
||||
if (pileEntity.getBodyId()==0) {
|
||||
saveChargingPileByWork(pileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传充电桩数据到服务端
|
||||
* */
|
||||
private void saveChargingPileByWork(ChargingPileEntity chargingPileEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", chargingPileEntity.getTaskId());
|
||||
httpParams.put("name", chargingPileEntity.getName());
|
||||
httpParams.put("existence", chargingPileEntity.getExist());
|
||||
httpParams.put("geo", chargingPileEntity.getP());
|
||||
httpParams.put("memo", chargingPileEntity.getMemo());
|
||||
httpParams.put("ffid", chargingPileEntity.getFid());
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
|
||||
hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
|
||||
hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
|
||||
hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
|
||||
httpParams.put("detail", String.valueOf(hashMap));
|
||||
try {
|
||||
okhttp3.Response execute = OkGo.<String>get(HttpInterface.SUBMIT_CSTASK)
|
||||
.params(httpParams)
|
||||
.tag(PoiSaveUtils.this)
|
||||
.execute();
|
||||
String responseBodyStr = execute.body().string();
|
||||
if (responseBodyStr!=null) {
|
||||
Gson gson = new Gson();
|
||||
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(responseBodyStr, ChargingPileSaveBean.class);
|
||||
chargingPileEntity.setBodyId(chargingPileSaveBean.getBody());
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdateChargingPile(mContext, chargingPileEntity); // 更新当前充电桩的bodyId
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user