app/src/main/java/cn/flightfeather/thirdapp/module/inspectioninfo/ProblemChangeDetailActivity.java
@@ -45,7 +45,7 @@
import cn.flightfeather.thirdapp.CommonApplication;
import cn.flightfeather.thirdapp.R;
import cn.flightfeather.thirdapp.activity.PhotoViewerActivity;
import cn.flightfeather.thirdapp.bean.Mediafile;
import cn.flightfeather.thirdapp.bean.entity.Mediafile;
import cn.flightfeather.thirdapp.bean.vo.MediafileVo;
import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo;
import cn.flightfeather.thirdapp.httpservice.ProblemListService;
@@ -184,7 +184,12 @@
            if (data!=null){
                int position = data.getIntExtra("position",-1);
                if (position>-1){
                    mediafileDao.deleteByKey(mediafileListChange.get(position).getGuid());
                    this.mediafileListChange.remove(position);
                    //fixme 2020/11/12 由于删除单张图片是直接联网将服务器数据一并删除,因此当图片全部删除后,立即更新问题为未整改状态
                    if (mediafileListChange.isEmpty()) {
                        uploadProblem();
                    }
                    this.isEdited = !mediafileListChange.isEmpty();
                    initChangingPhoto(this.mediafileListChange, this.imageViewChangeList);
                    if (this.problemlistVo.getIschanged()) {
@@ -511,31 +516,39 @@
    //<editor-fold desc="点击事件">
    private void refreshProblemStatus() {
        this.problemlistVo.setIschanged(true);//设置为已整改
        this.problemlistVo.setExtension3(Domain.CHANGE_UNCHECKED);//设置为整改待审核
        this.problemlistVo.setChangedtime(new Date());//设置整改时间为当前时间
        this.problemlistVo.getMediafileList().clear();
        this.problemlistVo.getMediafileList().addAll(this.mediafileListProblem);
        this.problemlistVo.getMediafileList().addAll(this.mediafileListChange);//将新增的图片添加进媒体文件列表,用于app数据刷新
        //整改图片全删除后,问题退回未整改审核通过状态
        if (mediafileListChange.isEmpty()) {
            this.problemlistVo.setIschanged(false);//设置为未整改
            this.problemlistVo.setExtension3(Domain.PROBLEM_CHECK_PASS);
            this.problemlistVo.setChangedtime(null);
            this.problemlistVo.setChangecatalog(null);
        } else {
            this.problemlistVo.setIschanged(true);//设置为已整改
            this.problemlistVo.setExtension3(Domain.CHANGE_UNCHECKED);//设置为整改待审核
            this.problemlistVo.setChangedtime(new Date());//设置整改时间为当前时间
            this.problemlistVo.getMediafileList().clear();
            this.problemlistVo.getMediafileList().addAll(this.mediafileListProblem);
            this.problemlistVo.getMediafileList().addAll(this.mediafileListChange);//将新增的图片添加进媒体文件列表,用于app数据刷新
        Calendar calendar = Calendar.getInstance();
        int today = calendar.get(Calendar.DAY_OF_YEAR);
        calendar.setTime(this.problemlistVo.getTime());
        int problemDay = calendar.get(Calendar.DAY_OF_YEAR);
        //有承诺整改的日期
        if (this.problemlistVo.getExtension1() != null){
            //整改时间已超过监管当天的24点,则认为是承诺整改
            if (today > problemDay) {
                this.problemlistVo.setChangecatalog(Domain.PROMISE_CHANGE);
            Calendar calendar = Calendar.getInstance();
            int today = calendar.get(Calendar.DAY_OF_YEAR);
            calendar.setTime(this.problemlistVo.getTime());
            int problemDay = calendar.get(Calendar.DAY_OF_YEAR);
            //有承诺整改的日期
            if (this.problemlistVo.getExtension1() != null) {
                //整改时间已超过监管当天的24点,则认为是承诺整改
                if (today > problemDay) {
                    this.problemlistVo.setChangecatalog(Domain.PROMISE_CHANGE);
                }
                //否则是现场当天整改
                else {
                    this.problemlistVo.setChangecatalog(Domain.LOACAL_CHANGE);
                }
            }
            //否则是现场当天整改
            //没有承诺整改的日期是未承诺整改
            else {
                this.problemlistVo.setChangecatalog(Domain.LOACAL_CHANGE);
                this.problemlistVo.setChangecatalog(Domain.UNPROMISE_CHANGE);
            }
        }
        //没有承诺整改的日期是未承诺整改
        else {
            this.problemlistVo.setChangecatalog(Domain.UNPROMISE_CHANGE);
        }
    }
@@ -547,29 +560,8 @@
//            return;
//        }
        if (this.isEdited){
             loadingDialog = DialogUtil.createLoadingDialog(this, "");
            refreshProblemStatus();
            Call<ResponseBody> updateProblemList = application.getRetrofit().create(ProblemListService.class).updateProblemList(this.problemlistVo);
            updateProblemList.enqueue(new Callback<ResponseBody>() {
                @Override
                public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                    if (response.body()!=null){
                        Toast.makeText(application, R.string.submit_success, Toast.LENGTH_LONG).show();
                        //上传问题成功后,开始上传对应的整改图片
                        upLoadPic();
                    }else if (response.errorBody()!=null){
                        Toast.makeText(application, R.string.submit_unsuccess, Toast.LENGTH_LONG).show();
                        loadingDialog.dismiss();
                    }
                }
                @Override
                public void onFailure(Call<ResponseBody> call, Throwable t) {
                    Toast.makeText(application, R.string.network_error, Toast.LENGTH_LONG).show();
                    loadingDialog.dismiss();
                }
            });
            loadingDialog = DialogUtil.createLoadingDialog(this, "");
            upLoadPic();
        }else {
            Toast.makeText(application, R.string.take_one_change_photo_at_least, Toast.LENGTH_SHORT).show();
        }
@@ -603,6 +595,45 @@
        }
    }
    private void uploadProblem() {
        refreshProblemStatus();
        Call<ResponseBody> updateProblemList = application.getRetrofit().create(ProblemListService.class).updateProblemList(this.problemlistVo);
        updateProblemList.enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.body()!=null){
                    Toast.makeText(application, R.string.submit_success, Toast.LENGTH_LONG).show();
                    if (loadingDialog != null && loadingDialog.isShowing()) {
                        loadingDialog.dismiss();
                    }
                    //返回requestCode
                    Intent intent = new Intent();
                    intent.putExtra(ARG_PROBLEM, problemlistVo);
                    setResult(RESULT_OK, intent);
                    //发送数据更新广播
                    Intent intent1 = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
                    intent1.setAction(Constant.REFRESH_DATA);
                    intent1.putExtra(ARG_PROBLEM, problemlistVo);
                    sendBroadcast(intent1);
                    finish();
                }else if (response.errorBody()!=null){
                    Toast.makeText(application, R.string.submit_unsuccess, Toast.LENGTH_LONG).show();
                    loadingDialog.dismiss();
                }
            }
            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                Toast.makeText(application, R.string.network_error, Toast.LENGTH_LONG).show();
                loadingDialog.dismiss();
            }
        });
    }
    private void upLoadPic() {
@@ -617,37 +648,22 @@
        PhotoUtil photoUtil = new PhotoUtil(mediafiles.size(), application, new OnUpLoadListener() {
            @Override
            public void onSuccess() {
                Toast.makeText(application, "上传成功", Toast.LENGTH_SHORT).show();
                if (loadingDialog != null && loadingDialog.isShowing()) {
                    loadingDialog.dismiss();
                }
                //返回requestCode
                Intent intent = new Intent();
                intent.putExtra(ARG_PROBLEM, problemlistVo);
                setResult(RESULT_OK, intent);
                //发送数据更新广播
                Intent intent1 = new Intent("cn.flightfeather.thirdapp.broadcasereceiver.MainReceiver");
                intent1.setAction(Constant.REFRESH_DATA);
                intent1.putExtra(ARG_PROBLEM, problemlistVo);
                sendBroadcast(intent1);
                finish();
                uploadProblem();
            }
            @Override
            public void onFail() {
                Toast.makeText(application, "上传失败", Toast.LENGTH_SHORT).show();
                Toast.makeText(application, "上传失败,请重试", Toast.LENGTH_SHORT).show();
                loadingDialog.dismiss();
                AlertDialog.Builder dialog = new AlertDialog.Builder(application);
                dialog.setMessage("图片上传失败,请手动上传或联系我司!");
                dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        finish();
                    }
                });
                dialog.show();
//                AlertDialog.Builder dialog = new AlertDialog.Builder(application);
//                dialog.setMessage("图片上传失败,请重试");
//                dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialogInterface, int i) {
//                        finish();
//                    }
//                });
//                dialog.show();
            }
        });