app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/InspectionInfoFragment.java
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -30,14 +31,17 @@
import cn.flightfeather.thirdapp.CommonApplication;
import cn.flightfeather.thirdapp.R;
import cn.flightfeather.thirdapp.adapter.AllRecyclerViewAdapter;
import cn.flightfeather.thirdapp.bean.Domainitem;
import cn.flightfeather.thirdapp.bean.Scense;
import cn.flightfeather.thirdapp.bean.entity.Problemtype;
import cn.flightfeather.thirdapp.bean.entity.Scense;
import cn.flightfeather.thirdapp.bean.vo.ProblemCategoryVo;
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo;
import cn.flightfeather.thirdapp.common.net.ResultCallBack;
import cn.flightfeather.thirdapp.httpservice.ProblemListService;
import cn.flightfeather.thirdapp.repository.ProblemRepository;
import cn.flightfeather.thirdapp.util.CommonUtils;
import cn.flightfeather.thirdapp.util.Constant;
import cn.flightfeather.thirdapp.util.DateFormatter;
import cn.flightfeather.thirdapp.util.Domain;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -49,8 +53,6 @@
 */
public class InspectionInfoFragment extends Fragment implements Serializable{
    //<editor-fold desc="全局变量">
    private final static String TITLE = "问题";
    private static final long serialVersionUID = 6072583863506447855L;
@@ -60,9 +62,7 @@
    private String sceneType = Constant.SCENE_TYPE_SITE;
    private Unbinder unbinder;
    //</editor-fold>
    //<editor-fold desc="构造函数">
    public InspectionInfoFragment() {
        // Required empty public constructor
    }
@@ -73,9 +73,7 @@
//        fragment.setArguments(args);
        return fragment;
    }
    //</editor-fold>
    //<editor-fold desc="生命周期">
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -121,9 +119,6 @@
        }
    }
    //</editor-fold>
    //<editor-fold desc="标题栏">
    @BindView(R.id.action_bar)
    View action_bar;
@@ -140,9 +135,6 @@
        title.setGravity(Gravity.CENTER_HORIZONTAL);
    }
    //</editor-fold>
    //<editor-fold desc="统计信息栏">
    @BindView(R.id.text_total) TextView text_total;
    @BindView(R.id.text_changed) TextView text_changed;
    @BindView(R.id.text_unchanged) TextView text_unchanged;
@@ -154,10 +146,9 @@
        text_changed.setText(String.valueOf(changed_problems));
        text_unchanged.setText(String.valueOf(total_problems-changed_problems));
    }
    //</editor-fold>
    //<editor-fold desc="初始化列表数据">
    private ArrayList<ProblemCategoryVo> problemCategories = new ArrayList<>();//列表中展示的数据,按问题类型分类
    private ProblemRepository problemRepository = new ProblemRepository();
    private DomainitemDao domainitemDao;
    private ScenseDao scenseDao;
@@ -175,31 +166,64 @@
                .limit(1).list();
        if (scenses != null && !scenses.isEmpty()) {
            this.sceneType = String.valueOf(scenses.get(0).getTypeid());
            Scense s = scenses.get(0);
            //查询当前场景类型下的问题类型值域
            byte b = 1;
            problemRepository.getProblemType(b, s.getCitycode(), s.getDistrictcode(), s.getTypeid(), new ResultCallBack<ArrayList<Problemtype>>() {
                @Override
                public void onCacheSuccess(@Nullable ArrayList<Problemtype> result) {
                }
                @Override
                public void onSuccess(@Nullable ArrayList<Problemtype> result) {
                    if (result != null) {
                        List<String> types = new ArrayList<>();
                        for (int i = 0; i < result.size(); i++) {
                            Problemtype d = result.get(i);
                            if (!types.contains(d.getTypeid().toString())) {
                                types.add(d.getTypeid().toString());
                                ProblemCategoryVo p = new ProblemCategoryVo();
                                p.setProblemTypeId(d.getTypeid().toString());
                                p.setProblemTypeName(d.getTypename());
                                problemCategories.add(p);
                            }
                        }
                    }
                }
                @Override
                public void onPage(int current, int total) {
                }
                @Override
                public void onFailure() {
                }
            });
        }
        //endregion
        //region 查询当前场景类型下的问题类型值域
        this.domainitemDao = this.application.getDaoSession().getDomainitemDao();
        List<Domainitem> domainitems = domainitemDao.queryBuilder()
                .where(
                        DomainitemDao.Properties.Dcguid.eq(
                                CommonUtils.getProblemTypeGUID(this.sceneType)
                        )
                )
                .orderAsc(DomainitemDao.Properties.Index).list();
        for (Domainitem d :
                domainitems) {
            ProblemCategoryVo p = new ProblemCategoryVo();
            p.setProblemTypeId(d.getValue());
            p.setProblemTypeName(d.getText());
            this.problemCategories.add(p);
        }
        //endregion
//        this.domainitemDao = this.application.getDaoSession().getDomainitemDao();
//        List<Domainitem> domainitems = domainitemDao.queryBuilder()
//                .where(
//                        DomainitemDao.Properties.Dcguid.eq(
//                                CommonUtils.getProblemTypeGUID(this.sceneType)
//                        )
//                )
//                .orderAsc(DomainitemDao.Properties.Index).list();
//        for (Domainitem d :
//                domainitems) {
//            ProblemCategoryVo p = new ProblemCategoryVo();
//            p.setProblemTypeId(d.getValue());
//            p.setProblemTypeName(d.getText());
//            this.problemCategories.add(p);
//        }
    }
    //</editor-fold>
    //<editor-fold desc="initView">
    //问题按分类进行个数统计
    @BindView(R.id.rv_problem_type) RecyclerView rv_problem_type;
    AllRecyclerViewAdapter<ProblemCategoryVo> adapter;
@@ -231,9 +255,7 @@
        rv_problem_type.setLayoutManager(gl);
        rv_problem_type.setAdapter(adapter);
    }
    //</editor-fold>
    //<editor-fold desc="联网刷新">
    private void refresh(String sceneId, String date) {
        Call<List<ProblemlistVo>> getProblemByScene = this.application.getRetrofit().create(ProblemListService.class).getProblemByScene(sceneId, date);
        getProblemByScene.enqueue(new Callback<List<ProblemlistVo>>() {
@@ -268,7 +290,7 @@
                    p.setTotalCount(p.getTotalCount() + 1 );
                    this.total_problems++;
                    //已整改问题数累加
                    if (problemlistVo.getIschanged()){
                    if (problemlistVo.getIschanged() && Objects.equals(problemlistVo.getExtension3(), Domain.CHANGE_CHECK_PASS)) {
                        p.setIsRectifiedCount(p.getIsRectifiedCount() + 1);
                        this.changed_problems++;
                    }
@@ -302,14 +324,11 @@
            }
        }
    }
    //</editor-fold>
    //<editor-fold desc="用户提交整改图片完成后,在内存中更新数据">
    public void updateData() {
        Date now = new Date();
        String date = DateFormatter.dateTimeFormat3.format(now);
        refresh(application.getCurrentUser().getDguid(), date);//对于客户来说,D_GUID就是场景id
    }
    //</editor-fold>
}