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