修改poi录像和道路接口 修改bug

This commit is contained in:
md 2021-07-15 18:18:37 +08:00
parent d94f04b27e
commit 139865fdd9
9 changed files with 252 additions and 141 deletions

View File

@ -37,6 +37,7 @@ import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
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.PoiSaveBean; import com.navinfo.outdoor.bean.PoiSaveBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
@ -56,6 +57,7 @@ import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
@ -95,6 +97,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
private String takePhotoPath8; private String takePhotoPath8;
private String takePhotoPath9; private String takePhotoPath9;
private String takePhotoPath10; private String takePhotoPath10;
private int taskId;
public static ChargingPileFragment newInstance(Bundle bundle) { public static ChargingPileFragment newInstance(Bundle bundle) {
ChargingPileFragment fragment = new ChargingPileFragment(); ChargingPileFragment fragment = new ChargingPileFragment();
@ -178,6 +181,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) { if (isChecked) {
Toast.makeText(getContext(), "1", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "1", Toast.LENGTH_SHORT).show();
checkButton2.setChecked(false); checkButton2.setChecked(false);
checkButton3.setChecked(false); checkButton3.setChecked(false);
@ -223,15 +227,6 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
} }
} }
}); });
checkButton6 = findViewById(R.id.check_button6);
checkButton6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Toast.makeText(getContext(), "6", Toast.LENGTH_SHORT).show();
}
}
});
spinnerType = findViewById(R.id.spinner_type); spinnerType = findViewById(R.id.spinner_type);
adapterType = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, type); adapterType = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, type);
adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式
@ -384,6 +379,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
if (station!=null){ if (station!=null){
PoiEntity poiEntity = new Gson().fromJson(station, PoiEntity.class); PoiEntity poiEntity = new Gson().fromJson(station, PoiEntity.class);
pid = poiEntity.getId(); pid = poiEntity.getId();
taskId = poiEntity.getTaskId();
String x = poiEntity.getX(); String x = poiEntity.getX();
String y = poiEntity.getY(); String y = poiEntity.getY();
if (x != null && y != null) { if (x != null && y != null) {
@ -739,48 +735,40 @@ 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", chargingPileEntity.getTaskId()); httpParams.put("taskId", taskId);
// httpParams.put("name", chargingPileEntity.getName()); httpParams.put("name", chargingPileEntity.getName());
// httpParams.put("address", chargingPileEntity.getAddress()); httpParams.put("existence", chargingPileEntity.getExist());
// httpParams.put("existence", chargingPileEntity.getExistence()); httpParams.put("geo", chargingPileEntity.getP());
// httpParams.put("geo", chargingPileEntity.getGeoWkt()); httpParams.put("memo", chargingPileEntity.getMemo());
// httpParams.put("memo", chargingPileEntity.getMemo()); httpParams.put("ffid", chargingPileEntity.getFid());
// OkGoBuilder.getInstance() HashMap<String, Object> hashMap = new HashMap<>();
// .Builder(getActivity()) hashMap.put("cp_openType",chargingPileEntity.getCp_openType());
// .url(HttpInterface.SUBMIT_POI_TASK) hashMap.put("cp_floor",chargingPileEntity.getCp_floor());
// .method(OkGoBuilder.GET) hashMap.put("cp_availableState",chargingPileEntity.getCp_availableState());
// .cls(PoiSaveBean.class) hashMap.put("sign_exist",chargingPileEntity.getSign_exist());
// .params(httpParams) httpParams.put("detail", String.valueOf(hashMap));
// .callback(new Callback<PoiSaveBean>() { OkGoBuilder.getInstance()
// @Override .Builder(getActivity())
// public void onSuccess(PoiSaveBean poiSaveBean, int id) { .url(HttpInterface.SUBMIT_CSTASK)
// dismissLoadingDialog(); .method(OkGoBuilder.GET)
// body = poiSaveBean.getBody(); .cls(ChargingPileSaveBean.class)
// poiEntity.setBodyId(body); .params(httpParams)
// poiEntity.setTaskStatus(3); .callback(new Callback<ChargingPileSaveBean>() {
// new Thread(new Runnable() { @Override
// @Override public void onSuccess(ChargingPileSaveBean chargingPileSaveBean, int id) {
// public void run() { dismissLoadingDialog();
// InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show();
// getActivity().runOnUiThread(new Runnable() { Log.d("TAG", "onSuccess: " + chargingPileSaveBean.getBody());
// @Override }
// public void run() {
// Toast.makeText(getActivity(), "保存成功", Toast.LENGTH_SHORT).show(); @Override
// Log.d("TAG", "onSuccess: " + poiSaveBean.getBody()); public void onError(Throwable e, int id) {
// } dismissLoadingDialog();
// }); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
// } Log.d("TAG", "onError: " + e.getMessage());
// }).start(); }
// } }).build();
//
// @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
@ -893,7 +881,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
} }
}); });
} else { } else {
int angle1 = PictureUtil.readPictureDegree(takePhotoPath1); //int angle1 = PictureUtil.readPictureDegree(takePhotoPath1);
takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a",Geohash.getInstance().encode(latLng.latitude,latLng.longitude));
ivPanorama.setTag(takePhotoPath1); ivPanorama.setTag(takePhotoPath1);
ivPanorama.setImageBitmap(bitmap);//显示图像 ivPanorama.setImageBitmap(bitmap);//显示图像
@ -914,7 +902,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
} }
}); });
} else { } else {
int angle2 = PictureUtil.readPictureDegree(takePhotoPath2); //int angle2 = PictureUtil.readPictureDegree(takePhotoPath2);
takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b",Geohash.getInstance().encode(latLng.latitude,latLng.longitude)); takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b",Geohash.getInstance().encode(latLng.latitude,latLng.longitude));
ivCoding.setTag(takePhotoPath2); ivCoding.setTag(takePhotoPath2);
ivCoding.setImageBitmap(bitmap);//显示图像 ivCoding.setImageBitmap(bitmap);//显示图像

View File

@ -256,6 +256,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
if (name != null && !name.equals("")) { if (name != null && !name.equals("")) {
editTaskName.setText(name + ""); editTaskName.setText(name + "");
} }
body=showPoiEntity.getBodyId();
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) {
@ -395,6 +396,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
break; break;
case R.id.btn_other_uploading: case R.id.btn_other_uploading:
ArrayList<File> otherUploadList = new ArrayList<>(); ArrayList<File> otherUploadList = new ArrayList<>();
String tagPicture = (String) ivPicture.getTag(); String tagPicture = (String) ivPicture.getTag();
if (tagPicture != null) { if (tagPicture != null) {
@ -425,33 +427,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
} }
private void otherUploadByNet(int body, List<File> otherUploadList) { private void otherUploadByNet(int body, List<File> otherUploadList) {
if (body == 0) {
Toast.makeText(getActivity(), "没有保存不能上传", Toast.LENGTH_SHORT).show();
return;
}
// OkGo
// // 请求方式和请求url
// .<OtherUploadPicBean>post(HttpInterface.OTHER_TASK_UPLOAD_PIC)
// // 请求的 tag, 主要用于取消对应的请求
// .params("auditId", body)
// .addFileParams("file", otherUploadList)
// .tag(this)
// .execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
// @Override
// public void onSuccess(Response<OtherUploadPicBean> otherUploadPicBeanResponse) {
// dismissLoadingDialog();
// Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
// Log.d("TAG", "onSuccess: " + otherUploadPicBeanResponse.toString() + "sssssssssssss");
// }
//
// @Override
// public void onError(Response<OtherUploadPicBean> response) {
// super.onError(response);
// dismissLoadingDialog();
// Toast.makeText(getActivity(), response.message() + "", Toast.LENGTH_SHORT).show();
// Log.d("TAG", "onError: " + response.message());
// }
// });
if (body == 0) { if (body == 0) {
Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show(); Toast.makeText(getActivity(), "没有保存本地", Toast.LENGTH_SHORT).show();
Log.e("TAG", "poiUploadByNetWork: " + body + otherUploadList); Log.e("TAG", "poiUploadByNetWork: " + body + otherUploadList);

View File

@ -93,8 +93,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
String[] spinner = new String[]{"存在", "不存在", "无法验证"}; String[] spinner = new String[]{"存在", "不存在", "无法验证"};
private Integer poiVideoBody; private Integer poiVideoBody;
private File videoFile; private File videoFile;
private Button roadUpload; private Button btnPoiVideoUpload;
private String videoPath; private String videoPath;
private File fileZip;
public static PoiVideoFragment newInstance(Bundle bundle) { public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment(); PoiVideoFragment fragment = new PoiVideoFragment();
@ -149,16 +150,16 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
tvPictures = (TextView) findViewById(R.id.tv_pictures); tvPictures = (TextView) findViewById(R.id.tv_pictures);
tvPictures.setOnClickListener(this::onClick); tvPictures.setOnClickListener(this::onClick);
etRoadName = (EditText) findViewById(R.id.et_poi_video_name); etRoadName = (EditText) findViewById(R.id.et_poi_video_name);
ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_road_picture); ivPoiVideoPicture = (ImageView) findViewById(R.id.iv_poi_video_picture);
rbCar = (RadioButton) findViewById(R.id.rb_car); rbCar = (RadioButton) findViewById(R.id.rb_car);
rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle); rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle);
rbWalking = (RadioButton) findViewById(R.id.rb_walking); rbWalking = (RadioButton) findViewById(R.id.rb_walking);
rbManual = (RadioButton) findViewById(R.id.rb_manual); rbManual = (RadioButton) findViewById(R.id.rb_manual);
etDesc = (EditText) findViewById(R.id.et_desc); etDesc = (EditText) findViewById(R.id.et_desc);
btnRoadSave = (Button) findViewById(R.id.btn_road_save); btnRoadSave = (Button) findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this::onClick); btnRoadSave.setOnClickListener(this::onClick);
roadUpload = findViewById(R.id.road_upload); btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
roadUpload.setOnClickListener(this::onClick); btnPoiVideoUpload.setOnClickListener(this::onClick);
rgType = (RadioGroup) findViewById(R.id.rg_type); rgType = (RadioGroup) findViewById(R.id.rg_type);
linearExist = findViewById(R.id.linear_exist); linearExist = findViewById(R.id.linear_exist);
spinnerExist = findViewById(R.id.spinner_exist); spinnerExist = findViewById(R.id.spinner_exist);
@ -237,6 +238,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
int type = roadExtend.getType(); int type = roadExtend.getType();
showPictureType(type); showPictureType(type);
} }
poiVideoBody=showPoiEntity.getBodyId();
if (showPoiEntity.getName()!=null){ if (showPoiEntity.getName()!=null){
linearExist.setVisibility(View.VISIBLE); linearExist.setVisibility(View.VISIBLE);
} }
@ -296,7 +298,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.btn_road_save: case R.id.btn_poi_video_save:
XXPermissions.with(getContext()) XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE) .permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() { .request(new OnPermissionCallback() {
@ -375,6 +377,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
}).start(); }).start();
//onBackPressed(); //onBackPressed();
}else {
Toast.makeText(getActivity(), "没有申请权限,请手动申请", Toast.LENGTH_SHORT).show();
} }
} }
@ -391,32 +395,60 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
case R.id.tv_pictures: case R.id.tv_pictures:
// 根据用户点击的时间为视频名称赋值 // 根据用户点击的时间为视频名称赋值
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HHmmss");
String videoFormatName = formatter.format(new Date()); String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class); Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4"); intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4");
startActivityForResult(intent, 0x101); startActivityForResult(intent, 0x101);
break; break;
case R.id.road_upload: case R.id.btn_poi_video_upload:
ArrayList<File> videoFileList = new ArrayList<>(); ArrayList<File> videoFileList = new ArrayList<>();
if (videoFile != null) { if (videoFile != null) {
videoFileList.add(videoFile); videoFileList.add(videoFile);
File file = new File(videoFile.getPath()+".txt");
videoFileList.add(file);
} }
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip"); File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null); ZipUtil.zipFiles(videoFileList, fileZip,null);
poiVideoUpload(poiVideoBody,videoFileList); if (poiVideoBody!=null){
poiVideoUpload(poiVideoBody,fileZip);
}else {
new Thread(new Runnable() {
@Override
public void run() {
PoiEntity poiVideoDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiVideoDaoPoiEntity.getBodyId(),fileZip);
}
});
}
}).start();
}
break; break;
} }
} }
private void poiVideoUpload(Integer poiVideoBody, ArrayList<File> videoFileList) {
private void poiVideoUpload(int poiVideoBody, File fileZip) {
if (poiVideoBody == 0) {
Toast.makeText(getActivity(), "请先保存本地在上传", Toast.LENGTH_SHORT).show();
return;
}
if (fileZip==null){
Toast.makeText(getActivity(), "未压缩完成", Toast.LENGTH_SHORT).show();
return;
}
OkGo OkGo
// 请求方式和请求url // 请求方式和请求url
.<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC) .<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)
// 请求的 tag, 主要用于取消对应的请求 // 请求的 tag, 主要用于取消对应的请求
.params("auditId",poiVideoBody ) .params("auditId",poiVideoBody)
.addFileParams("file",videoFileList) .params("file",fileZip)
.tag(this) .tag(this)
.execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) { .execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
@Override @Override
@ -439,11 +471,23 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private void poiVideoSave(PoiEntity poiEntity) { private void poiVideoSave(PoiEntity poiEntity) {
showLoadingDialog(); showLoadingDialog();
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", pictureType);
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder.getInstance() OkGoBuilder.getInstance()
.Builder(getActivity()) .Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST) .url(HttpInterface.INSIDE_API_LIST)
.method(OkGoBuilder.GET) .method(OkGoBuilder.GET)
.cls(PoiVideoBean.class) .cls(PoiVideoBean.class)
.params(httpParams)
.callback(new Callback<PoiVideoBean>() { .callback(new Callback<PoiVideoBean>() {
@Override @Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) { public void onSuccess(PoiVideoBean poiVideoBean, int id) {

View File

@ -27,19 +27,25 @@ import androidx.annotation.Nullable;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions; 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.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.PictureActivity; import com.navinfo.outdoor.activity.PictureActivity;
import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.activity.PicturesActivity;
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.OtherUploadPicBean;
import com.navinfo.outdoor.bean.PoiBean; import com.navinfo.outdoor.bean.PoiBean;
import com.navinfo.outdoor.bean.PoiVideoBean; import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.RoadExtend; import com.navinfo.outdoor.bean.RoadExtend;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.DialogCallback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.InsertAndUpdateUtils;
@ -84,8 +90,11 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private PoiEntity showPoiEntity; private PoiEntity showPoiEntity;
private ImageView ivRoadFinal; private ImageView ivRoadFinal;
private RelativeLayout linearExist; private RelativeLayout linearExist;
String[] spinner = new String[]{"存在","不存在","无法验证"}; String[] spinner = new String[]{"存在", "不存在", "无法验证"};
private int body; private Integer body;
private Button roadUpload;
private File videoFile;
private String videoPath;
public static RoadFragment newInstance(Bundle bundle) { public static RoadFragment newInstance(Bundle bundle) {
RoadFragment fragment = new RoadFragment(); RoadFragment fragment = new RoadFragment();
@ -110,20 +119,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Bundle arguments = getArguments(); Bundle arguments = getArguments();
if (arguments!=null) { if (arguments != null) {
isSliding= arguments.getBoolean("isSliding",true); isSliding = arguments.getBoolean("isSliding", true);
Log.d("TAG", "onCreatessss: "+isSliding); Log.d("TAG", "onCreatessss: " + isSliding);
} }
if (isSliding) { if (isSliding) {
// 监听到返回按钮点击事件 // 监听到返回按钮点击事件
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what= Constant.TREASURE_FRAGMENT; obtain.what = Constant.TREASURE_FRAGMENT;
obtain.obj=isSliding; obtain.obj = isSliding;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
Message mainButtonVisiableMsg = Message.obtain(); Message mainButtonVisiableMsg = Message.obtain();
mainButtonVisiableMsg.what= Constant.MAIN_BUTTON_VISIABLE; mainButtonVisiableMsg.what = Constant.MAIN_BUTTON_VISIABLE;
mainButtonVisiableMsg.obj= View.VISIBLE; mainButtonVisiableMsg.obj = View.VISIBLE;
EventBus.getDefault().post(mainButtonVisiableMsg); EventBus.getDefault().post(mainButtonVisiableMsg);
} }
onBackPressed(); onBackPressed();
@ -151,6 +160,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
btnRoadSave.setOnClickListener(this::onClick); btnRoadSave.setOnClickListener(this::onClick);
rgType = (RadioGroup) findViewById(R.id.rg_type); rgType = (RadioGroup) findViewById(R.id.rg_type);
linearExist = findViewById(R.id.linear_exist); linearExist = findViewById(R.id.linear_exist);
roadUpload = findViewById(R.id.road_upload);
roadUpload.setOnClickListener(this::onClick);
Spinner spinnerExist = findViewById(R.id.spinner_exist); Spinner spinnerExist = findViewById(R.id.spinner_exist);
ArrayAdapter<String> adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); ArrayAdapter<String> adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner);
adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式
@ -191,6 +202,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
// disables(); // disables();
} }
private void initShowPoi() { private void initShowPoi() {
// 添加信息 // 添加信息
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity"); showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
@ -199,13 +211,14 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (name != null && !name.equals("")) { if (name != null && !name.equals("")) {
etRoadName.setText(name + ""); etRoadName.setText(name + "");
} }
body=showPoiEntity.getBodyId();
String extend = showPoiEntity.getExtend(); String extend = showPoiEntity.getExtend();
if (extend!=null&& !extend.equals("")){ if (extend != null && !extend.equals("")) {
RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class); RoadExtend roadExtend = new Gson().fromJson(extend, RoadExtend.class);
int type= roadExtend.getType(); int type = roadExtend.getType();
showPictureType(type); showPictureType(type);
} }
if (showPoiEntity.getName()!=null){ if (showPoiEntity.getName() != null) {
linearExist.setVisibility(View.VISIBLE); linearExist.setVisibility(View.VISIBLE);
} }
String describe = showPoiEntity.getDescribe();//任务描述 String describe = showPoiEntity.getDescribe();//任务描述
@ -213,7 +226,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
etDesc.setText(describe); etDesc.setText(describe);
} }
String photo = showPoiEntity.getPhoto(); String photo = showPoiEntity.getPhoto();
if (photo!=null) { if (photo != null) {
File videoFile = new File(photo); File videoFile = new File(photo);
if (videoFile.exists()) { if (videoFile.exists()) {
// 使用glide加载视频的第一帧 // 使用glide加载视频的第一帧
@ -224,6 +237,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} }
} }
//禁用控件 //禁用控件
private void disables() throws JSONException { private void disables() throws JSONException {
etRoadName.setEnabled(false); etRoadName.setEnabled(false);
@ -296,15 +310,15 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} else { } else {
poiEntity.setDescribe(desc); poiEntity.setDescribe(desc);
} }
if (showPoiEntity!=null){ if (showPoiEntity != null) {
if (showPoiEntity.getTaskId()!=0){ if (showPoiEntity.getTaskId() != 0) {
poiEntity.setTaskId(showPoiEntity.getTaskId()); poiEntity.setTaskId(showPoiEntity.getTaskId());
} }
} }
if (ivRoadPicture.getTag()!=null) { if (ivRoadPicture.getTag() != null) {
File videoFile = (File) ivRoadPicture.getTag(); File videoFile = (File) ivRoadPicture.getTag();
poiEntity.setPhoto(videoFile.getAbsolutePath()); poiEntity.setPhoto(videoFile.getAbsolutePath());
String path = videoFile.getPath()+".txt"; String path = videoFile.getPath() + ".txt";
poiEntity.setPhoto(videoFile.getAbsolutePath()); poiEntity.setPhoto(videoFile.getAbsolutePath());
List<String> strings = FileUtils.readFileToList(path, "utf-8"); List<String> strings = FileUtils.readFileToList(path, "utf-8");
ArrayList<LatLng> latLngs = new ArrayList<>(); ArrayList<LatLng> latLngs = new ArrayList<>();
@ -315,12 +329,12 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
latLng.setLongitude(Double.valueOf(split[3])); latLng.setLongitude(Double.valueOf(split[3]));
latLngs.add(latLng); latLngs.add(latLng);
} }
if (strings.size()==1){ if (strings.size() == 1) {
LatLng latLng = latLngs.get(0); LatLng latLng = latLngs.get(0);
latLngs.add(latLng); latLngs.add(latLng);
} }
String lineString = GeometryTools.getLineString(latLngs); String lineString = GeometryTools.getLineString(latLngs);
Log.d("TAG", "onGranted: "+lineString); Log.d("TAG", "onGranted: " + lineString);
poiEntity.setGeoWkt(lineString); poiEntity.setGeoWkt(lineString);
} }
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -364,16 +378,89 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String videoFormatName = formatter.format(new Date()); String videoFormatName = formatter.format(new Date());
Intent intent = new Intent(getContext(), PictureActivity.class); Intent intent = new Intent(getContext(), PictureActivity.class);
intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER+"/"+videoFormatName+".mp4"); intent.putExtra(Constant.INTENT_VIDEO_PATH, Constant.PICTURE_FOLDER + "/" + videoFormatName + ".mp4");
startActivityForResult(intent, 0x101); startActivityForResult(intent, 0x101);
break; break;
case R.id.road_upload:
ArrayList<File> videoFileList = new ArrayList<>();
if (videoFile != null) {
videoFileList.add(videoFile);
File file = new File(videoFile.getPath() + ".txt");
videoFileList.add(file);
}
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
ZipUtil.zipFiles(videoFileList, fileZip, null);
if (body != null) {
poiVideoUpload(body, fileZip);
} else {
new Thread(new Runnable() {
@Override
public void run() {
PoiEntity poiVideoDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiVideoDaoPoiEntity.getBodyId(), fileZip);
}
});
}
}).start();
}
break;
} }
} }
private void poiVideoUpload(int body, File fileZip) {
if (body == 0) {
Toast.makeText(getActivity(), "请先保存本地在上传", Toast.LENGTH_SHORT).show();
return;
}
if (fileZip==null){
Toast.makeText(getActivity(), "未压缩完成", Toast.LENGTH_SHORT).show();
return;
}
OkGo
// 请求方式和请求url
.<OtherUploadPicBean>post(HttpInterface.POI_VIDEO_UPLOAD_PIC)
// 请求的 tag, 主要用于取消对应的请求
.params("auditId",body)
.params("file",fileZip)
.tag(this)
.execute(new DialogCallback<OtherUploadPicBean>(OtherUploadPicBean.class) {
@Override
public void onSuccess(Response<OtherUploadPicBean> otherUploadPicBeanResponse) {
dismissLoadingDialog();
Toast.makeText(getActivity(), "上传成功", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onSuccess: " + otherUploadPicBeanResponse.toString() + "sssssssssssss");
}
@Override
public void onError(Response<OtherUploadPicBean> response) {
super.onError(response);
dismissLoadingDialog();
Toast.makeText(getActivity(), response.code()+"", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: " + response.code()+"");
}
});
}
private void poiVideoSave(PoiEntity poiEntity) { private void poiVideoSave(PoiEntity poiEntity) {
showLoadingDialog(); showLoadingDialog();
int pictureType = getPictureType();
if (pictureType == -1) {
Toast.makeText(getContext(), "请选择拍照方式", Toast.LENGTH_SHORT).show();
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", pictureType);
httpParams.put("memo", poiEntity.getMemo());
OkGoBuilder.getInstance() OkGoBuilder.getInstance()
.Builder(getActivity()) .Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST) .url(HttpInterface.INSIDE_API_LIST)
@ -384,7 +471,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
public void onSuccess(PoiVideoBean poiVideoBean, int id) { public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog(); dismissLoadingDialog();
body = poiVideoBean.getBody(); body = poiVideoBean.getBody();
body = poiVideoBean.getBody();
poiEntity.setBodyId(body); poiEntity.setBodyId(body);
poiEntity.setTaskStatus(3); poiEntity.setTaskStatus(3);
new Thread(new Runnable() { new Thread(new Runnable() {
@ -416,10 +502,10 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101&&resultCode == 0x101) { if (requestCode == 0x101 && resultCode == 0x101) {
if (data!=null&&data.hasExtra(Constant.INTENT_VIDEO_PATH)) { if (data != null && data.hasExtra(Constant.INTENT_VIDEO_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH); videoPath = data.getStringExtra(Constant.INTENT_VIDEO_PATH);
File videoFile = new File(videoPath); videoFile = new File(videoPath);
if (videoFile.exists()) { if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500); AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
ivRoadPicture.setTag(videoFile); ivRoadPicture.setTag(videoFile);
@ -427,6 +513,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} }
} }
} }
@Override @Override
public void onSaveInstanceState(@NonNull Bundle outState) { public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
@ -434,9 +521,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} }
/** /**
*防止程序崩溃后数据丢失 * 防止程序崩溃后数据丢失
*/ */
public void initRoadSharePre(){ public void initRoadSharePre() {
//获取SharedPreferences对象方法中两个参数的意思为第一个name //获取SharedPreferences对象方法中两个参数的意思为第一个name
//表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成 //表示文件名系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看 //一个以该参数命名的.xml文件第二个mode表示创建的模式通过查看
@ -463,8 +550,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (desc != null && !desc.equals("")) { if (desc != null && !desc.equals("")) {
poiEntity.setDescribe(desc); poiEntity.setDescribe(desc);
} }
if (showPoiEntity!=null){ if (showPoiEntity != null) {
if (showPoiEntity.getTaskId()!=0){ if (showPoiEntity.getTaskId() != 0) {
poiEntity.setTaskId(showPoiEntity.getTaskId()); poiEntity.setTaskId(showPoiEntity.getTaskId());
} }
} }
@ -481,7 +568,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
edit.putString("poiEntity", newPoiEntity); edit.putString("poiEntity", newPoiEntity);
//提交新值必须执行否则前面的操作都无效 //提交新值必须执行否则前面的操作都无效
edit.commit(); edit.commit();
Log.d("TAG", "initRoadSharePre: "+newPoiEntity); Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
} }
//获取拍照类型 //获取拍照类型
@ -497,8 +584,9 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} }
return -1; return -1;
} }
private void showPictureType(int type){
switch (type){ private void showPictureType(int type) {
switch (type) {
case 0: case 0:
rbCar.setChecked(true); rbCar.setChecked(true);
break; break;

View File

@ -54,6 +54,8 @@ public class HttpInterface {
public static final String RECEIVED_CTASK=IPm6+"ctask/1/receivedCtask";//充电站-领取任务 public static final String RECEIVED_CTASK=IPm6+"ctask/1/receivedCtask";//充电站-领取任务
//172.23.139.4:8003/ctask/1/submitCtask?id=8608&name=充电站&address=地址&telephone=18812345678|14712345678&geo=1rn7exd5uhxy&memo=测试备注&sptype=1 //172.23.139.4:8003/ctask/1/submitCtask?id=8608&name=充电站&address=地址&telephone=18812345678|14712345678&geo=1rn7exd5uhxy&memo=测试备注&sptype=1
public static final String SUBMIT_CTASK=IPm6+"ctask/1/submitCtask";//充电站-保存本地 public static final String SUBMIT_CTASK=IPm6+"ctask/1/submitCtask";//充电站-保存本地
//172.23.139.4:8003/cstask/1/submitCstask?taskId=0&name=充电站&geo=1rn7exd5uhxy&memo=测试备注&sptype=1&ffid=104&existence=1&detail={"cp_openType":"1,2","cp_floor":1,"cp_availableState":0,"sign_exist":0}
public static final String SUBMIT_CSTASK =IPm6+"cstask/1/submitCstask";//充电桩保存
//172.23.139.4:8003/poitask/1/uploadpic //172.23.139.4:8003/poitask/1/uploadpic
public static final String POI_TASK_UPLOAD_PIC=IPm6+"poitask/1/uploadpic";//poi-上传 public static final String POI_TASK_UPLOAD_PIC=IPm6+"poitask/1/uploadpic";//poi-上传
//172.23.139.4:8003/roadtask/1/receivedRoadtask/8569 //172.23.139.4:8003/roadtask/1/receivedRoadtask/8569
@ -66,8 +68,10 @@ public class HttpInterface {
public static final String POI_VIDEO_UPLOAD_PIC = IPm6+"poivideotask/1/uploadpic";//poi录像-上传 public static final String POI_VIDEO_UPLOAD_PIC = IPm6+"poivideotask/1/uploadpic";//poi录像-上传
//http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy //http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy
public static final String GET_PHONE = IPm6 + "m4/task/1/getPhone"; //任务搜索 public static final String GET_PHONE = IPm6 + "m4/task/1/getPhone"; //任务搜索
//172.23.139.4:8003/cstask/1/submitCstask?taskId=0&name=充电站&geo=1rn7exd5uhxy&memo=测试备注&sptype=1&ffid=104&existence=1&detail={"cp_openType":"1,2","cp_floor":1,"cp_availableState":0,"sign_exist":0}
public static final String SUBMIT_CSTASK =IPm6+"cstask/1/submitCstask"; // http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy
// public static final String GET_PHONES = IPm6+"m4/task/1/getPhone";//电话区号和电话位数
/** /**
* 面状任务 * 面状任务

View File

@ -24,16 +24,25 @@ public class ChargingPileEntity implements Serializable {
@PrimaryKey(autoGenerate = true) // 设置主键并且自动生长 @PrimaryKey(autoGenerate = true) // 设置主键并且自动生长
private int pileId; private int pileId;
private String name;//名称 private String name;//名称
private String p;//经纬度 private String p;//经纬度 geo加密
private int exist;//是否存在 0不存在1存在 private int exist;//是否存在 0不存在1存在
private int cp_floor;//充电桩地面层 地面层是1 地上二层为2向上依次加1地下一层为-1向下依次减1.默认为1 private int cp_floor;//充电桩地面层 地面层是1 地上二层为2向上依次加1地下一层为-1向下依次减1.默认为1
private int sign_exist;//设备标牌是否存在 0不存在1存在 private int sign_exist;//设备标牌是否存在 0不存在1存在
private int cp_availableState;//可以状态 0可以使用有电默认1(不可使用没电)2(维修中)3建设中4规划中 private int cp_availableState;//可用状态 0可以使用有电默认1(不可使用没电)2(维修中)3建设中4规划中
private int cp_openType;// 1.对所有车辆开放 2.对环卫车开放 3.对公交和开放 4.对出租车开放 5.对特种兵车辆开放
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 long fid;//对应充电站id
public int getCp_openType() {
return cp_openType;
}
public void setCp_openType(int cp_openType) {
this.cp_openType = cp_openType;
}
public int getPileId() { public int getPileId() {
return pileId; return pileId;
} }

View File

@ -45,6 +45,15 @@ public class PoiEntity implements Serializable {
private int isLocalData;//是否是本地数据 0,服务 1,本地 private int isLocalData;//是否是本地数据 0,服务 1,本地
private int isExclusive;//任务类型 0.普通任务1.专属任务 private int isExclusive;//任务类型 0.普通任务1.专属任务
private int bodyId;//保存本地的bodyId private int bodyId;//保存本地的bodyId
//private int work_type;//0."车行" 1."自行车" 2."步行" 3."手动"
// public int getWork_type() {
// return work_type;
// }
//
// public void setWork_type(int work_type) {
// this.work_type = work_type;
// }
public String getGeoWkt() { public String getGeoWkt() {
return geoWkt; return geoWkt;

View File

@ -178,16 +178,10 @@
> >
<CheckBox <CheckBox
android:id="@+id/check_button5" android:id="@+id/check_button5"
android:layout_width="150dp" android:layout_width="250dp"
android:layout_height="80dp" android:layout_height="80dp"
android:text="对除环卫,公交,出租,品牌,之外的其他 特种车辆开放" android:text="对除环卫,公交,出租,品牌,之外的其他 特种车辆开放"
/> />
<CheckBox
android:id="@+id/check_button6"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="对某品牌汽车开放"
/>
</LinearLayout> </LinearLayout>

View File

@ -136,7 +136,7 @@
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:id="@+id/iv_road_picture" android:id="@+id/iv_poi_video_picture"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
@ -147,8 +147,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintLeft_toLeftOf="@id/iv_road_picture" app:layout_constraintLeft_toLeftOf="@id/iv_poi_video_picture"
app:layout_constraintTop_toBottomOf="@id/iv_road_picture"> app:layout_constraintTop_toBottomOf="@id/iv_poi_video_picture">
<RelativeLayout <RelativeLayout
android:id="@+id/linear_exist" android:id="@+id/linear_exist"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -224,7 +224,7 @@
app:layout_constraintTop_toBottomOf="@id/ll_desc"> app:layout_constraintTop_toBottomOf="@id/ll_desc">
<Button <Button
android:id="@+id/btn_road_save" android:id="@+id/btn_poi_video_save"
style="@style/user_data_style" style="@style/user_data_style"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -232,7 +232,7 @@
android:text="保存本地" /> android:text="保存本地" />
<Button <Button
android:id="@+id/road_upload" android:id="@+id/btn_poi_video_upload"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"