管灌系统巡查员智能手机App
1.添加当前巡检状态的功能。
2.修复工单界面刷新已完成列表导致未完成列表数据被清除的bug
3个文件已修改
149 ■■■■ 已修改文件
app/src/main/assets/js/map.js 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/src/main/assets/js/map.js
@@ -30,12 +30,12 @@
            "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=d8beed89b43160a9a185e5aff431f85d";
        //创建自定义图层对象
        //影像注记(地图上的地址)
        var imgURL2 ="http://t0.tianditu.gov.cn/cia_w/wmts?" +"SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
        "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" +
        "&tk=d8beed89b43160a9a185e5aff431f85d";
        var imgURL2 = "http://t0.tianditu.gov.cn/cia_w/wmts?" + "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
            "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" +
            "&tk=d8beed89b43160a9a185e5aff431f85d";
        var lay = new T.TileLayer(imageURL, { minZoom: 6, maxZoom: 18 });
        var lay2 = new T.TileLayer(imgURL2, { minZoom: 6, maxZoom: 18 });
        var config = { layers: [lay,lay2] };
        var config = { layers: [lay, lay2] };
        map = new T.Map("mapDiv", config);
        var scale = new T.Control.Scale();
        //添加比例尺控件
@@ -153,8 +153,8 @@
    //设置地图中心点
    function setCenterAndZoom(lng, lat,thiszoom) {
    zoom=thiszoom;
    function setCenterAndZoom(lng, lat, thiszoom) {
        zoom = thiszoom;
        console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat);
        map.centerAndZoom(new T.LngLat(lng, lat), zoom);
    }
@@ -166,7 +166,7 @@
        window.showToast = showToast;
        window.addMarker = addMarker;
        window.setCenterAndZoom = setCenterAndZoom;
        window.updateLocation=updateLocation;
        window.updateLocation = updateLocation;
    }
    // 调用原生安卓方法显示取水口详情
@@ -260,7 +260,7 @@
                position: marker.getLngLat(),
                offset: new T.Point(-35, 8), // 设置标注文字的位置
                opacity: 1, // 设置文本的显示不透明度(范围0-1)
                    });
            });
            label.setBorderLine(0); // 设置文本的边框线宽
            label.setBackgroundColor("transparent"); // 设置文本的背景色(透明色)
            label.setFontColor("#0000FF");
@@ -270,23 +270,32 @@
        return "addMarker加载成功"
    }
    //保存定位坐标生成轨迹
    var path=[];
    var path = [];
    var lineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 });
    function updateLocation(log,lat){
        var lastLat=lat;
    let locationMarker;
    function updateLocation(log, lat) {
        var lastLat = lat;
        // const intervalId = setInterval(() => {
            // lastLat=lastLat+0.0001;
            var newPoint = new T.LngLat(log,lastLat);
            path.push(newPoint);
            lineLayer.setLngLats(path);
            map.addOverLay(lineLayer);
             // 移动地图视角到最后一个位置
             map.panTo(newPoint);
        // lastLat=lastLat+0.0001;
        var newPoint = new T.LngLat(log, lastLat);
        path.push(newPoint);
        lineLayer.setLngLats(path);
        map.addOverLay(lineLayer);
        let icon = new T.Icon({
            iconUrl: locationIMGPath,
            iconSize: new T.Point(27, 27),
            iconAnchor: new T.Point(13, 20)
        });
        if (locationMarker) {
            map.removeOverLay(locationMarker);
        }
        locationMarker = new T.Marker(new T.LngLat(log, lastLat), { icon: icon });
        map.addOverLay(locationMarker);
        // 移动地图视角到最后一个位置
        map.panTo(newPoint);
        // }, 500);
    }
})();
app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java
@@ -6,6 +6,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
@@ -486,7 +487,7 @@
                //关闭定位
                this.getActivity().stopService(location);
                break;
            case 1:
            case InspectionUtils.STAT_INSPECTION://1开始
                //添加新的巡检记录
                startInspection();
                //获取定位服务传过来的坐标点
@@ -504,15 +505,21 @@
                }
                mInspectionBean = InspectionUtils.startInspection(this.getContext());
                inspectionRequest = new InspectionRequest();
                SharedPreferencesHelper.getInstance(this.getContext()).put(CommonKeyName.inspectionState, InspectionUtils.STAT_INSPECTION);
                break;
            case 2://暂停
                LiveEventBus.get(CommonKeyName.locationData).removeObserver(locationObserver);
                //关闭定位
                this.getActivity().stopService(location);
                binding.stateText.setText("已暂停巡检");
                binding.inspectPause.setText("继续");
                binding.inspectRL.setBackgroundColor(this.getContext().getResources().getColor(R.color.inspect_rl_bg_color));
                try {
                    LiveEventBus.get(CommonKeyName.locationData).removeObserver(locationObserver);
                    //关闭定位
                    this.getActivity().stopService(location);
                    binding.stateText.setText("已暂停巡检");
                    binding.inspectPause.setText("继续");
                    binding.inspectRL.setBackgroundColor(this.getContext().getResources().getColor(R.color.inspect_rl_bg_color));
                    SharedPreferencesHelper.getInstance(this.getContext()).put(CommonKeyName.inspectionState, InspectionUtils.PAUSE_INSPECTION);
                } catch (Resources.NotFoundException e) {
                    e.printStackTrace();
                }
                break;
            case 3:
                ConfirmDialog confirmDialog = new ConfirmDialog(MapFragment.this.getActivity(), "提示", "确认关闭巡检吗?", new ConfirmDialog.ConfirmOnClickListener() {
@@ -520,6 +527,7 @@
                    public void onClick(ConfirmDialog confirmDialog, View v) {
                        confirmDialog.dismiss();
                        chageInspecState(InspectionUtils.NO_INSPECTION);
                        SharedPreferencesHelper.getInstance(MapFragment.this.getContext()).put(CommonKeyName.inspectionState, InspectionUtils.NO_INSPECTION);
                    }
                });
                confirmDialog.show();
app/src/main/java/com/dayu/pipirrapp/fragment/OrderFragment.java
@@ -49,6 +49,7 @@
    FragmentOrderBinding binding;
    OrderAdapter mAdapter;
    OrderAdapter mDoneAdapter;
    int page = 1;
    int pageSize = 10;
    int state = 1;
@@ -82,11 +83,8 @@
        binding = FragmentOrderBinding.inflate(inflater, container, false);
        initView();
        //获取定位服务传过来的坐标点
        LiveEventBus.get(CommonKeyName.MQTTData).observeForever(new Observer<Object>() {
            @Override
            public void onChanged(Object o) {
        LiveEventBus.get(CommonKeyName.MQTTData).observeForever(o -> {
            }
        });
@@ -96,42 +94,30 @@
    void initView() {
        //未完成
        binding.manageStateProgress.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chooseStateView(true);
                state = STATE_UNDONE;//1 未开始 2 已完成
        binding.manageStateProgress.setOnClickListener(v -> {
            chooseStateView(true);
            state = STATE_UNDONE;//1 未开始 2 已完成
            }
        });
        //已完成
        binding.manageStateFinish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chooseStateView(false);
                state = STATE_DONE;//1 未开始 2 已完成
            }
        binding.manageStateFinish.setOnClickListener(v -> {
            chooseStateView(false);
            state = STATE_DONE;//1 未开始 2 已完成
        });
        //未完成
        RefreshLayout myRefreshLayout = (RefreshLayout) binding.refreshLayout;
        myRefreshLayout.setRefreshHeader(new ClassicsHeader(this.getContext()));
        myRefreshLayout.setRefreshFooter(new ClassicsFooter(this.getContext()));
        myRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
        myRefreshLayout.setOnRefreshListener(refreshlayout -> {
//                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
                recordsList.clear();
                page = 0;
                getMarkerData(refreshlayout, true, STATE_UNDONE);
            }
            recordsList.clear();
            page = 0;
            getMarkerData(refreshlayout, true, STATE_UNDONE);
        });
        myRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(RefreshLayout refreshlayout) {
                page = page + 1;
                getMarkerData(refreshlayout, false, STATE_UNDONE);
            }
        myRefreshLayout.setOnLoadMoreListener(refreshlayout -> {
            page = page + 1;
            getMarkerData(refreshlayout, false, STATE_UNDONE);
        });
        mAdapter = new OrderAdapter(this.getContext(), recordsList, this);
@@ -143,26 +129,20 @@
        RefreshLayout myRefreshLayoutDone = (RefreshLayout) binding.refreshLayoutDone;
        myRefreshLayoutDone.setRefreshHeader(new ClassicsHeader(this.getContext()));
        myRefreshLayoutDone.setRefreshFooter(new ClassicsFooter(this.getContext()));
        myRefreshLayoutDone.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshlayout) {
        myRefreshLayoutDone.setOnRefreshListener(refreshlayout -> {
//                refreshlayout.finishRefresh(2000/*,false*/);//传入false表示刷新失败
                recordsList.clear();
                page = 0;
                getMarkerData(refreshlayout, true, STATE_DONE);
            }
            recordsListDone.clear();
            page = 0;
            getMarkerData(refreshlayout, true, STATE_DONE);
        });
        myRefreshLayoutDone.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(RefreshLayout refreshlayout) {
                page = page + 1;
                getMarkerData(refreshlayout, false, STATE_DONE);
            }
        myRefreshLayoutDone.setOnLoadMoreListener(refreshlayout -> {
            page = page + 1;
            getMarkerData(refreshlayout, false, STATE_DONE);
        });
        mAdapter = new OrderAdapter(this.getContext(), recordsListDone, this);
        mDoneAdapter = new OrderAdapter(this.getContext(), recordsListDone, this);
        LinearLayoutManager layoutManagerDone = new LinearLayoutManager(this.getContext());
        binding.recyclerViewDone.setLayoutManager(layoutManagerDone);
        binding.recyclerViewDone.setAdapter(mAdapter);
        binding.recyclerViewDone.setAdapter(mDoneAdapter);
        getMarkerData(myRefreshLayoutDone, true, 2);
    }
@@ -218,7 +198,13 @@
            public void onCloose() {
                super.onCloose();
                layoutFinish(refreshlayout, isRefresh);
                mAdapter.notifyDataSetChanged();
                if (state == STATE_UNDONE) {
                    mAdapter.notifyDataSetChanged();
                } else {
                    mDoneAdapter.notifyDataSetChanged();
                }
            }
        });