Преглед на файлове

华研增加检验送样接口文档内容以及附件上传内容

songw преди 4 месеца
родител
ревизия
28f43f0de7

+ 2 - 0
app/build.gradle

@@ -103,6 +103,8 @@ dependencies {
 //    implementation 'com.github.bumptech.glide:glide:4.12.0'
 //    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
 
+    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
+
 }
 
 def getVersionName() {

+ 1 - 0
app/src/main/java/com/uas/hystorage/activity/InspectionSendSamplesAct.java

@@ -347,6 +347,7 @@ public class InspectionSendSamplesAct extends BaseActivity {
                 intent.putExtra(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
                 startActivity(intent);
             } else {
+                bt_dayinbiaoqian.setEnabled(false);
                 CommonUtil.toastNoRepeat(InspectionSendSamplesAct.this, "打印成功");
             }
         } else {

+ 3 - 4
app/src/main/java/com/uas/hystorage/activity/SampleDeliveryListAct.java

@@ -193,7 +193,7 @@ public class SampleDeliveryListAct extends BaseActivity{
             @Override
             public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                 try{
-                    int numberId = ComDataBeanList.get(i).getSR_ID();
+                    int numberId = ComDataBeanList.get((int) l).getSR_ID();
                     new AlertDialog.Builder(SampleDeliveryListAct.this).setTitle("提示").setMessage("是否打印标签?")
                             .setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() {
                                 @Override
@@ -285,7 +285,7 @@ public class SampleDeliveryListAct extends BaseActivity{
                         @Override
                         public void onSuccess(int flag, Object o) throws Exception {
                             progressDialog.dismiss();
-                            Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                            boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
                             JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
                             if (isSuccess) {
                                 if (dataArray == null) {
@@ -315,7 +315,7 @@ public class SampleDeliveryListAct extends BaseActivity{
                         @Override
                         public void onSuccess(int flag, Object o) throws Exception {
                             progressDialog.dismiss();
-                            Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                            boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
                             JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "data");
                             if (isSuccess) {
                                 if (dataArray == null) {
@@ -416,7 +416,6 @@ public class SampleDeliveryListAct extends BaseActivity{
             helper.setText(R.id.tv_jitai_num,item.getSR_DEVCODE());     //机台
             helper.setText(R.id.tv_xiangmuhao_num,item.getSR_ITEMCODE());     //项目号
             helper.setText(R.id.tv_gongdanhao_num,item.getSR_MAKECODE());     //工单号
-
         }
     }
 

+ 16 - 4
app/src/main/java/com/uas/hystorage/adapter/AnnexAdapter.java

@@ -30,8 +30,14 @@ public class AnnexAdapter extends RecyclerView.Adapter<AnnexAdapter.ViewHolder>
         this.itemList = itemList;
     }
 
+    public void setListNotTitle(List<AnnexBean> itemList){
+        this.itemList = itemList;
+        notifyDataSetChanged();
+    }
+
     public void setList(List<AnnexBean> itemList){
         this.itemList = itemList;
+        this.itemList.add(0,new AnnexBean(true,"","",true));
         notifyDataSetChanged();
     }
 
@@ -58,6 +64,9 @@ public class AnnexAdapter extends RecyclerView.Adapter<AnnexAdapter.ViewHolder>
         }
 
         AnnexBean annexBean = itemList.get(position);
+        if (!annexBean.isUsable()) {
+            return;
+        }
         if (!TextUtils.isEmpty(annexBean.getImagePath())) {
             String imagePath = annexBean.getImagePath();
             BitmapFactory.Options options = new BitmapFactory.Options();
@@ -76,7 +85,7 @@ public class AnnexAdapter extends RecyclerView.Adapter<AnnexAdapter.ViewHolder>
             @Override
             public void onClick(View v) {
                 if (addImage != null) {
-                    addImage.startUpload();
+                    addImage.startAdd();
                 }
             }
         });
@@ -92,8 +101,10 @@ public class AnnexAdapter extends RecyclerView.Adapter<AnnexAdapter.ViewHolder>
             @Override
             public void onClick(View v) {
                 if (position > 0) {
-                    itemList.remove(position);
-                    notifyDataSetChanged();
+//                    itemList.remove(position);
+                    if (addImage != null) {
+                        addImage.delete(position);
+                    }
                 }
             }
         });
@@ -124,7 +135,8 @@ public class AnnexAdapter extends RecyclerView.Adapter<AnnexAdapter.ViewHolder>
     }
 
     public interface AddImage {
-        void startUpload();
+        void startAdd();
+        void delete(int position);
     }
 
 }

+ 14 - 4
app/src/main/java/com/uas/hystorage/bean/AnnexBean.java

@@ -2,14 +2,16 @@ package com.uas.hystorage.bean;
 
 public class AnnexBean {
 
-    private boolean isAddImage;
-    private String imagePath;
-    private String imageID;
+    private boolean isAddImage;     //是否是添加的图标
+    private String imagePath;   //图片路径
+    private String imageID;     //图片附件的ID,每张图片都带";"号
+    private boolean isUsable;   //是否可用
 
-    public AnnexBean(boolean isAddImage, String imagePath, String imageID) {
+    public AnnexBean(boolean isAddImage, String imagePath, String imageID, boolean isUsable) {
         this.isAddImage = isAddImage;
         this.imagePath = imagePath;
         this.imageID = imageID;
+        this.isUsable = isUsable;
     }
 
     public boolean isAddImage() {
@@ -37,4 +39,12 @@ public class AnnexBean {
     public void setImageID(String imageID) {
         this.imageID = imageID;
     }
+
+    public boolean isUsable() {
+        return isUsable;
+    }
+
+    public void setUsable(boolean usable) {
+        isUsable = usable;
+    }
 }

+ 68 - 0
app/src/main/java/com/uas/hystorage/bean/AnnexInfo.java

@@ -0,0 +1,68 @@
+package com.uas.hystorage.bean;
+
+public class AnnexInfo {
+
+    //{
+    //	"fp_id": 159438,
+    //	"fp_path": "/app/mes/webapps/postattach/xiaost@manage/7648a18a3bea46a1af402deea0ad567e.png",
+    //	"fp_size": 16857,
+    //	"fp_name": "出勤人数PNG.png",
+    //	"fp_date": "2024-09-14 11:53:47",
+    //	"fp_man": "管理员"
+    //}
+
+    private int fp_id;
+    private String fp_path;
+    private String fp_size;
+    private String fp_name;
+    private String fp_date;
+    private String fp_man;
+
+    public int getFp_id() {
+        return fp_id;
+    }
+
+    public void setFp_id(int fp_id) {
+        this.fp_id = fp_id;
+    }
+
+    public String getFp_path() {
+        return fp_path;
+    }
+
+    public void setFp_path(String fp_path) {
+        this.fp_path = fp_path;
+    }
+
+    public String getFp_size() {
+        return fp_size;
+    }
+
+    public void setFp_size(String fp_size) {
+        this.fp_size = fp_size;
+    }
+
+    public String getFp_name() {
+        return fp_name;
+    }
+
+    public void setFp_name(String fp_name) {
+        this.fp_name = fp_name;
+    }
+
+    public String getFp_date() {
+        return fp_date;
+    }
+
+    public void setFp_date(String fp_date) {
+        this.fp_date = fp_date;
+    }
+
+    public String getFp_man() {
+        return fp_man;
+    }
+
+    public void setFp_man(String fp_man) {
+        this.fp_man = fp_man;
+    }
+}

+ 558 - 87
app/src/main/java/com/uas/hystorage/fragment/ReportPageFra.java

@@ -8,6 +8,7 @@ import android.database.Cursor;
 import android.graphics.Color;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Handler;
 import android.provider.MediaStore;
 import android.support.v4.app.ActivityCompat;
 import android.support.v7.widget.LinearLayoutManager;
@@ -21,30 +22,50 @@ import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.android.volley.Request;
 import com.android.volley.toolbox.StringRequest;
+import com.google.gson.Gson;
 import com.uas.hystorage.R;
+import com.uas.hystorage.activity.SampleDeliveryListAct;
 import com.uas.hystorage.adapter.AnnexAdapter;
 import com.uas.hystorage.bean.AnnexBean;
+import com.uas.hystorage.bean.AnnexInfo;
+import com.uas.hystorage.bean.InspectionPaintBean;
+import com.uas.hystorage.bean.SampleDeliveryBean;
 import com.uas.hystorage.global.GloableParams;
 import com.uas.hystorage.interfaces.ProgressListener;
 import com.uas.hystorage.listener.MyEditorActionListener;
+import com.uas.hystorage.util.ClickUtils;
 import com.uas.hystorage.util.CommonUtil;
 import com.uas.hystorage.util.Constants;
 import com.uas.hystorage.util.FastjsonUtil;
 import com.uas.hystorage.util.HttpCallback;
 import com.uas.hystorage.util.HttpParams;
+import com.uas.hystorage.util.MyLog;
+import com.uas.hystorage.util.OKHttpUitls;
+import com.uas.hystorage.util.OnDownloadListener;
 import com.uas.hystorage.util.UploadUtils;
 import com.uas.hystorage.util.VollyRequest;
+import com.uas.hystorage.util.YLDownload;
 import com.uas.hystorage.view.ClearableEditText;
 import com.uas.hystorage.view.business.ProgressPopup;
+import com.umeng.commonsdk.debug.E;
 import com.uuzuche.lib_zxing.activity.CodeUtils;
 
+import org.json.JSONException;
 import org.w3c.dom.Text;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -70,10 +91,10 @@ public class ReportPageFra extends BaseFragment {
     private StringRequest mStringRequest;
     private String sr_sendtype;
 
-    private  final int REQUEST_EXTERNAL_STORAGE = 1;
-    private  String[] PERMISSIONS_STORAGE = {
+    private final int REQUEST_EXTERNAL_STORAGE = 1;
+    private String[] PERMISSIONS_STORAGE = {
             Manifest.permission.READ_EXTERNAL_STORAGE,
-            Manifest.permission.WRITE_EXTERNAL_STORAGE };
+            Manifest.permission.WRITE_EXTERNAL_STORAGE};
     private static final int REQUEST_CODE1 = 1;
     private static final int REQUEST_CODE2 = 2;
 
@@ -90,6 +111,16 @@ public class ReportPageFra extends BaseFragment {
     private List<AnnexBean> templist;
     private TextView tv_updater_info;
 
+    private String sr_qcattach;
+    private String sr_laboratoryattach;
+    private String sr_qcremark;
+    private String sr_laboratoryremark;
+    private List<AnnexInfo> imageQCUrlList;
+    private List<AnnexInfo> imageTestUrlList;
+    private int numberOfTimes = 0;  //下载完成次数
+    private String pathQc;
+    private String pathTest;
+
     @Override
     protected int getLayout() {
         return R.layout.fra_report_page;
@@ -123,6 +154,11 @@ public class ReportPageFra extends BaseFragment {
         bt_gengxin.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                ClickUtils.pauseTime = 2000;
+                if (ClickUtils.isFastClick()) {
+                    CommonUtil.toastNoRepeat(mActivity, "请勿点击过快");
+                    return;
+                }
                 getUpdater();
             }
         });
@@ -152,19 +188,21 @@ public class ReportPageFra extends BaseFragment {
         });
     }
 
-
     @Override
     protected void initDatas() {
+        pathQc = Constants.CONSTANT.APP_DIR_NAME + getActivity().getPackageName() + "/imageQC/";
+        pathTest = Constants.CONSTANT.APP_DIR_NAME + getActivity().getPackageName() + "/imageTest/";
+        deleteFile();
+
+
         cet_danhao.requestFocus();
         Bundle arguments = getArguments();
         if (arguments != null) {
-            sr_sendtype = arguments.getString("sr_sendtype","");
+            sr_sendtype = arguments.getString("sr_sendtype", "");
             setTitle(sr_sendtype + "报告");
         }
         //如果单号没有数据,并且没有执行enter 校验不成功的情况,不允许编辑下面的字段,包含上传图片、备注、点更新按钮(新增)
 
-
-
         LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
         rv_qc_fujian.setLayoutManager(linearLayoutManager);
 
@@ -172,12 +210,12 @@ public class ReportPageFra extends BaseFragment {
         rv_shiyanfujian.setLayoutManager(linearLayoutManager2);
 
         fujianList1 = new ArrayList<>();
-        fujianList1.add(new AnnexBean(true,"",""));
-        annexQCFuJianAdapter = new AnnexAdapter(getActivity(),fujianList1);
+//        fujianList1.add(new AnnexBean(true, "", "", false));
+        annexQCFuJianAdapter = new AnnexAdapter(getActivity(), fujianList1);
         rv_qc_fujian.setAdapter(annexQCFuJianAdapter);
         annexQCFuJianAdapter.setImageUpload(new AnnexAdapter.AddImage() {
             @Override
-            public void startUpload() {
+            public void startAdd() {
                 verifyStoragePermissions(mActivity);
                 // 启动文件选择器
                 Intent intent = new Intent(Intent.ACTION_PICK);
@@ -185,15 +223,23 @@ public class ReportPageFra extends BaseFragment {
                 intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                 startActivityForResult(Intent.createChooser(intent, "Select Images"), REQUEST_CODE1);
             }
+
+            @Override
+            public void delete(int position) {
+                if(position < fujianList1.size()) {
+                    fujianList1.remove(position);
+                    annexQCFuJianAdapter.setListNotTitle(fujianList1);
+                }
+            }
         });
 
         fujianList2 = new ArrayList<>();
-        fujianList2.add(new AnnexBean(true,"",""));
-        annexShiYanFuJianAdapter = new AnnexAdapter(getActivity(),fujianList2);
+//        fujianList2.add(new AnnexBean(true, "", "", false));
+        annexShiYanFuJianAdapter = new AnnexAdapter(getActivity(), fujianList2);
         rv_shiyanfujian.setAdapter(annexShiYanFuJianAdapter);
         annexShiYanFuJianAdapter.setImageUpload(new AnnexAdapter.AddImage() {
             @Override
-            public void startUpload() {
+            public void startAdd() {
                 verifyStoragePermissions(mActivity);
                 // 启动文件选择器
                 Intent intent = new Intent(Intent.ACTION_PICK);
@@ -201,11 +247,57 @@ public class ReportPageFra extends BaseFragment {
                 intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
                 startActivityForResult(Intent.createChooser(intent, "Select Images"), REQUEST_CODE2);
             }
+
+            @Override
+            public void delete(int position) {
+                if(position < fujianList2.size()) {
+                    fujianList2.remove(position);
+                    annexShiYanFuJianAdapter.setListNotTitle(fujianList2);
+                }
+            }
         });
 
+        imageQCUrlList = new ArrayList<>();
+        imageTestUrlList = new ArrayList<>();
+
+        cet_beizhu1.setEnabled(false);
+        cet_beizhu2.setEnabled(false);
+        bt_gengxin.setEnabled(false);
+    }
+
+    private void deleteFile() {
+        try{
+            File fileQc = new File(pathQc);
+            File fileTest = new File(pathTest);
+            if (!fileQc.exists()) {
+                fileQc.mkdirs();
+            }
+            if (!fileTest.exists()) {
+                fileTest.mkdirs();
+            }
+            deleteFiles(fileQc);
+            deleteFiles(fileTest);
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
-    public  void verifyStoragePermissions(Activity activity) {
+    private void deleteFiles(File file) {
+        if (file.exists()) {
+            if (file.isDirectory()) {
+                File[] files = file.listFiles();
+                if (files != null) {
+                    for (File f : files) {
+                        deleteFiles(f);
+                    }
+                }
+            } else {
+                file.delete();
+            }
+        }
+    }
+
+    public void verifyStoragePermissions(Activity activity) {
         int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
         if (permission != PackageManager.PERMISSION_GRANTED) {
             ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
@@ -213,33 +305,32 @@ public class ReportPageFra extends BaseFragment {
     }
 
     private void getUpdater() {
-        if (TextUtils.isEmpty(cet_danhao.getText().toString().trim())){
+        if (TextUtils.isEmpty(cet_danhao.getText().toString().trim())) {
             CommonUtil.toastNoRepeat(getActivity(), "请输入单号");
             return;
         }
 
         String fujianStr1 = "";
-        for (int i = 0;i < fujianList1.size();i++){
-            String s = fujianList1.get(i).getImageID();
-            fujianStr1 += s;
+        if (fujianList1.size() > 0) {
+            for (int i = 1; i < fujianList1.size(); i++) {
+                String s = fujianList1.get(i).getImageID();
+                fujianStr1 += s;
+            }
         }
         String fujianStr2 = "";
-        for (int i = 0;i < fujianList2.size();i++){
-            String s = fujianList2.get(i).getImageID();
-            fujianStr2 += s;
+        if (fujianList2.size() > 0) {
+            for (int i = 1; i < fujianList2.size(); i++) {
+                String s = fujianList2.get(i).getImageID();
+                fujianStr2 += s;
+            }
         }
 
-        //{sr_qcattach :QC检验附件 ,sr_qcremark :QC检验备注,
-        // sr_laboratoryattach:实验室检验附件 --值:163510;  ,
-        //sr_laboratoryremark :实验室检验备注,
-        // sr_sendtype:送样类型 (首件或者巡检)}
-
         Map<String, Object> params = new HashMap<>();
-        params.put("sr_qcattach",fujianStr1);
-        params.put("sr_qcremark ",cet_beizhu1.getText().toString().trim());
-        params.put("sr_laboratoryattach",fujianStr2);
-        params.put("sr_laboratoryremark",cet_beizhu2.getText().toString().trim());
-        params.put("sr_sendtype",sr_sendtype);
+        params.put("sr_qcattach", fujianStr1);
+        params.put("sr_qcremark ", cet_beizhu1.getText().toString().trim());
+        params.put("sr_laboratoryattach", fujianStr2);
+        params.put("sr_laboratoryremark", cet_beizhu2.getText().toString().trim());
+        params.put("sr_sendtype", sr_sendtype);
         String data = JSON.toJSONString(params);
         progressDialog.show();
         VollyRequest.getInstance().stringRequest(mStringRequest,
@@ -248,19 +339,20 @@ public class ReportPageFra extends BaseFragment {
                         .method(Request.Method.POST)
                         .tag("getMaCode")
                         .flag(0)
-                        .addParam("sr_code",cet_danhao.getText().toString().trim())
-                        .addParam("data",data) //首件或巡检
+                        .addParam("sr_code", cet_danhao.getText().toString().trim())
+                        .addParam("data", data) //首件或巡检
                         .build(), new HttpCallback() {
                     @Override
                     public void onSuccess(int flag, Object o) throws Exception {
                         progressDialog.dismiss();
-                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
-                        if (isSuccess){
+                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                        if (isSuccess) {
                             tv_updater_info.setTextColor(getResources().getColor(R.color.blue));
                             tv_updater_info.setText("更新成功");
                             CommonUtil.toastNoRepeat(mActivity, "更新成功");
                         }
                     }
+
                     @Override
                     public void onFail(int flag, String failStr) throws Exception {
                         progressDialog.dismiss();
@@ -272,7 +364,7 @@ public class ReportPageFra extends BaseFragment {
     }
 
     private void getTrackingNumberInquiry(String text) {
-        if (TextUtils.isEmpty(text)){
+        if (TextUtils.isEmpty(text)) {
             CommonUtil.toastNoRepeat(getActivity(), "请输入单号");
             return;
         }
@@ -283,39 +375,201 @@ public class ReportPageFra extends BaseFragment {
                         .method(Request.Method.GET)
                         .tag("getMaCode")
                         .flag(0)
-                        .addParam("sr_code",text)
-                        .addParam("sr_sendtype",sr_sendtype) //首件或巡检
+                        .addParam("sr_code", text)
+                        .addParam("sr_sendtype", sr_sendtype) //首件或巡检
                         .build(), new HttpCallback() {
                     @Override
                     public void onSuccess(int flag, Object o) throws Exception {
+                        //progressDialog.dismiss();
+                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                        if (isSuccess) {
+                            JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(), "data");
+                            if (dataObject != null) {
+                                String SC_CODE = dataObject.getString("SR_CODE") == null ? "" : dataObject.getString("SC_CODE");
+                                sr_qcattach = dataObject.getString("SR_QCATTACH") == null ? "" : dataObject.getString("SR_QCATTACH");
+                                sr_laboratoryattach = dataObject.getString("SR_LABORATORYATTACH") == null ? "" : dataObject.getString("SR_LABORATORYATTACH");
+                                sr_qcremark = dataObject.getString("SR_QCREMARK") == null ? "" : dataObject.getString("SR_QCREMARK");
+                                sr_laboratoryremark = dataObject.getString("SR_LABORATORYREMARK") == null ? "" : dataObject.getString("SR_LABORATORYREMARK");
+                                cet_beizhu1.setText(sr_qcremark);
+                                cet_beizhu2.setText(sr_laboratoryremark);
+                                //先删除文件在下载
+                                deleteFile();
+                                numberOfTimes = 0;
+                                imageQCUrlList.clear();
+                                imageTestUrlList.clear();
+                                fujianList1.clear();
+                                fujianList2.clear();
+                                fujianList1.add(new AnnexBean(true, "", "", false));
+                                fujianList2.add(new AnnexBean(true, "", "", false));
+                                cet_beizhu1.setEnabled(true);
+                                cet_beizhu2.setEnabled(true);
+                                bt_gengxin.setEnabled(true);
+                                for (int i = 0; i < fujianList1.size(); i++) {
+                                    fujianList1.get(i).setUsable(true);
+                                }
+                                annexQCFuJianAdapter.setListNotTitle(fujianList1);
+                                for (int i = 0; i < fujianList2.size(); i++) {
+                                    fujianList2.get(i).setUsable(true);
+                                }
+                                annexShiYanFuJianAdapter.setListNotTitle(fujianList2);
+                                //获取附件图片数据
+                                if (!TextUtils.isEmpty(sr_qcattach)) {
+                                    getImageData(sr_qcattach);
+                                }
+                                if (!TextUtils.isEmpty(sr_laboratoryattach)) {
+                                    getImageData2(sr_laboratoryattach, "Test");
+                                }
+                                if (TextUtils.isEmpty(sr_qcattach) && TextUtils.isEmpty(sr_laboratoryattach)) {
+                                    progressDialog.dismiss();
+                                }
+                            }
+                        }
+                    }
+
+                    @Override
+                    public void onFail(int flag, String failStr) throws Exception {
                         progressDialog.dismiss();
-                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(),"success");
-                        if (isSuccess){
-                            //{
-                            //    "success": true,
-                            //    "data": {
-                            //        "SR_ID": 2,         //单据ID
-                            //        "SR_CODE": "XJ24090002",  //单据编号
-                            //        "SR_DATE": "2024-09-06 11:02:16",  //单据日期
-                            //        "SR_SENDTYPE": "巡检",      //单据检验类型
-                            //        "SR_SOURCETYPE": "PDA新增",   //来源类型
-                            //        "SR_SCCODE": "ZX0000-104",  //岗位资源编号
-                            //        "SR_SCNAME": "半检五线12",  //岗位资源名称
-                            //        "SR_DEVCODE": "DEV001",  //机台号
-                            //        "SR_MAKECODE": "5106-24090610269-5",  //工单号
-                            //        "SR_ITEMCODE": "2323342",  //项目号
-                            //        "SR_STATUSCODE": "ENTERING"
-                            //    }
-                            //}
-                            JSONObject dataObject = FastjsonUtil.getJSONObject(o.toString(),"data");
-                            if (dataObject == null){
-
-                            }else {
-                                String SC_CODE = dataObject.getString("SC_CODE") == null ? "" : dataObject.getString("SC_CODE");
-                                cet_danhao.setText(SC_CODE);
+                        CommonUtil.toastNoRepeat(mActivity, failStr);
+                    }
+                });
+    }
+
+    private synchronized void getImageData(String imageDataID) {
+//        new Handler().postDelayed(new Runnable() {
+//            @Override
+//            public void run() {
+                VollyRequest.getInstance().stringRequest(mStringRequest,
+                        new HttpParams.Builder()
+                                .url(GloableParams.ADDRESS_GETFILEPATHS)
+                                .method(Request.Method.GET)
+                                .tag("getMaCode1")
+                                .flag(1)
+                                .addParam("id",imageDataID)
+                                .build(), new HttpCallback() {
+                            @Override
+                            public void onSuccess(int flag, Object o) throws Exception {
+                                Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                                JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "files");
+                                if (isSuccess) {
+                                    if (dataArray == null) {
+                                        CommonUtil.toastNoRepeat(getActivity(), "未搜索到匹配数据");
+                                    } else {
+                                        if (dataArray.size() <= 0) {
+                                            progressDialog.dismiss();
+                                        }else {
+                                            downloadImages(dataArray,"QC");
+                                        }
+                                    }
+                                }
+                            }
+                            @Override
+                            public void onFail(int flag, String failStr) throws Exception {
+                                progressDialog.dismiss();
+                                CommonUtil.toastNoRepeat(mActivity, failStr);
+                            }
+                        });
+
+//            }
+//        }, 3 * 1000);
+
+
+//                VollyRequest.getInstance().stringRequest(mStringRequest,
+//                        new HttpParams.Builder()
+//                                .url(GloableParams.ADDRESS_GETFILEPATHS)
+//                                .method(Request.Method.GET)
+//                                .tag("getMaCode1")
+//                                .flag(1)
+//                                .addParam("id",imageDataID)
+//                                .build(), new HttpCallback() {
+//                            @Override
+//                            public void onSuccess(int flag, Object o) throws Exception {
+//                                Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+//                                JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "files");
+//                                if (isSuccess) {
+//                                    if (dataArray == null) {
+//                                        CommonUtil.toastNoRepeat(getActivity(), "未搜索到匹配数据");
+//                                    } else {
+//                                        if (dataArray.size() <= 0) {
+//                                            progressDialog.dismiss();
+//                                        }else {
+//                                            downloadImages(dataArray,"QC");
+//                                        }
+//                                    }
+//                                }
+//                            }
+//                            @Override
+//                            public void onFail(int flag, String failStr) throws Exception {
+//                                progressDialog.dismiss();
+//                                CommonUtil.toastNoRepeat(mActivity, failStr);
+//                            }
+//                        });
+//
+
+
+
+//        String url = GloableParams.ADDRESS_GETFILEPATHS + "?" + "id=" + imageDataID;
+//        OKHttpUitls okHttpUitls = new OKHttpUitls();
+//        okHttpUitls.get(url);
+//        okHttpUitls.setOnOKHttpGetListener(new OKHttpUitls.OKHttpGetListener() {
+//            @Override
+//            public void error(String error) {
+//                progressDialog.dismiss();
+//                CommonUtil.toastNoRepeat(mActivity, "附件加载失败");
+//            }
+//
+//            @Override
+//            public void success(String json) {
+//                try {
+//                    //                    org.json.JSONObject jsonObject = new org.json.JSONObject(json);
+//                    Boolean isSuccess = FastjsonUtil.getBoolean(json, "success");
+//                    //                    String success = jsonObject.getString("success");
+//                    JSONArray dataArray = FastjsonUtil.getJSONArray(json, "files");
+//                    if (isSuccess) {
+//                        if (dataArray == null) {
+//                            CommonUtil.toastNoRepeat(getActivity(), "未搜索到匹配数据");
+//                        } else {
+//                            if (dataArray.size() <= 0) {
+//                                progressDialog.dismiss();
+//                            } else {
+//                                downloadImages(dataArray, "QC");
+//                            }
+//                        }
+//                    }
+//                } catch (Exception e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//        });
+
+
+    }
+
+    private synchronized void getImageData2(String imageDataID, String type) {
+        VollyRequest.getInstance().stringRequest(mStringRequest,
+                new HttpParams.Builder()
+                        .url(GloableParams.ADDRESS_GETFILEPATHS)
+                        .method(Request.Method.GET)
+                        .tag("getMaCode")
+                        .flag(0)
+                        .addParam("id", imageDataID)
+                        .build(), new HttpCallback() {
+                    @Override
+                    public void onSuccess(int flag, Object o) throws Exception {
+                        Boolean isSuccess = FastjsonUtil.getBoolean(o.toString(), "success");
+                        JSONArray dataArray = FastjsonUtil.getJSONArray(o.toString(), "files");
+                        if (isSuccess) {
+                            if (dataArray == null) {
+                                CommonUtil.toastNoRepeat(getActivity(), "未搜索到匹配数据");
+                            } else {
+                                if (dataArray.size() <= 0) {
+                                    progressDialog.dismiss();
+                                } else {
+                                    downloadImages(dataArray, "Test");
+                                }
                             }
                         }
                     }
+
                     @Override
                     public void onFail(int flag, String failStr) throws Exception {
                         progressDialog.dismiss();
@@ -324,6 +578,215 @@ public class ReportPageFra extends BaseFragment {
                 });
     }
 
+    private synchronized void downloadImages(JSONArray dataArray,String type) {
+        if (type.equals("QC")) {
+            for (Object index : dataArray) {
+                JSONObject data = (JSONObject) index;
+                AnnexInfo annexInfo = new Gson().fromJson(data.toString(), AnnexInfo.class);
+                imageQCUrlList.add(annexInfo);
+            }
+            getImageStream(imageQCUrlList, type);
+        } else if (type.equals("Test")) {
+            for (Object index : dataArray) {
+                JSONObject data = (JSONObject) index;
+                AnnexInfo annexInfo = new Gson().fromJson(data.toString(), AnnexInfo.class);
+                imageTestUrlList.add(annexInfo);
+            }
+            getImageStream2(imageTestUrlList, type);
+        }
+
+    }
+
+    private int index;
+    private String path = "";
+    private List<AnnexInfo> qcList;
+    private synchronized void getImageStream(List<AnnexInfo> list, String type) {
+        index = 0;
+        qcList = list;
+        for (int i = 0; i < list.size(); i++) {
+            String Path = "http://" + GloableParams.IP + ":"
+                    + GloableParams.PORT + "/" + GloableParams.SITE
+                    + "/api/pdashop/quality/download.action?" + "path="
+                    + list.get(i).getFp_path() + "&" + "size=" + list.get(i).getFp_size()
+                    + "&" + "fileName=" + list.get(i).getFp_name();
+            path = "";
+            if (type.equals("QC")) {
+                path = pathQc;
+            } else if (type.equals("Test")) {
+                path = pathTest;
+            }
+//            new Thread(new Runnable() {
+//                @Override
+//                public void run() {
+            String fileName = list.get(i).getFp_name();
+            fileName = System.currentTimeMillis() + fileName;
+            YLDownload.getInstance().download(Path, path, fileName, new OnDownloadListener() {
+                        @Override
+                        public void onDownloadFailed(Exception e) {
+                            e.printStackTrace();
+                            progressDialog.dismiss();
+                            CommonUtil.toastNoRepeat(mActivity, "附件下载出错,请重试");
+                        }
+
+                        @Override
+                        public void onDownloadSuccess() {
+                            MyLog.e("aaa","Qc下载次数:" + index + ",list大小:" + qcList.size());
+                            index++;
+                            if (index == qcList.size()) {
+                                //校验完整性
+                                if (type.equals("QC")) {
+                                    File dirFire = new File(pathQc);
+                                    setImagePath(dirFire, imageQCUrlList, "QC");
+                                } else if (type.equals("Test")) {
+                                    File dirFire = new File(pathTest);
+                                    setImagePath(dirFire, imageTestUrlList, "Test");
+                                }
+                            }
+                        }
+
+                        @Override
+                        public void onDownloading(int i) {
+                            Log.e("aaa", "下载图片的进度是: " + i);
+                        }
+                    });
+//                }
+//            }).start();
+        }
+    }
+
+    private int index2;
+    private String path2 = "";
+    private List<AnnexInfo> testList;
+    private synchronized void getImageStream2(List<AnnexInfo> list, String type) {
+        index2 = 0;
+        testList = list;
+        for (int i = 0; i < list.size(); i++) {
+            String Path = "http://" + GloableParams.IP + ":"
+                    + GloableParams.PORT + "/" + GloableParams.SITE
+                    + "/api/pdashop/quality/download.action?" + "path="
+                    + list.get(i).getFp_path() + "&" + "size=" + list.get(i).getFp_size()
+                    + "&" + "fileName=" + list.get(i).getFp_name();
+            path2 = "";
+            if (type.equals("QC")) {
+                path2 = pathQc;
+            } else if (type.equals("Test")) {
+                path2 = pathTest;
+            }
+            //            new Thread(new Runnable() {
+            //                @Override
+            //                public void run() {
+            String fileName = list.get(i).getFp_name();
+            fileName = System.currentTimeMillis() + fileName;
+            YLDownload.getInstance().download(Path, path2, fileName, new OnDownloadListener() {
+                @Override
+                public void onDownloadFailed(Exception e) {
+                    e.printStackTrace();
+                    progressDialog.dismiss();
+                    CommonUtil.toastNoRepeat(mActivity, "附件下载出错,请重试");
+                }
+
+                @Override
+                public void onDownloadSuccess() {
+                    MyLog.e("aaa","Test下载次数:" + index2 + ",list大小:" + testList.size());
+                    index2++;
+                    if (index2 == testList.size()) {
+                        //校验完整性
+                        if (type.equals("QC")) {
+                            File dirFire = new File(pathQc);
+                            setImagePath(dirFire, imageQCUrlList, "QC");
+                        } else if (type.equals("Test")) {
+                            File dirFire = new File(pathTest);
+                            setImagePath(dirFire, imageTestUrlList, "Test");
+                        }
+                    }
+                }
+
+                @Override
+                public void onDownloading(int i) {
+                    Log.e("aaa", "下载图片的进度是: " + i);
+                }
+            });
+            //                }
+            //            }).start();
+        }
+    }
+
+    private synchronized void setImagePath(File dirFire, List<AnnexInfo> list, String type) {
+        try{
+            MyLog.e("aaa","我执行了type:" + type + ",数量是:" + list.size());
+            long QCDownloadFileSize = 0;
+            for (int i1 = 0; i1 < list.size(); i1++) {
+                QCDownloadFileSize += Long.parseLong(list.get(i1).getFp_size());
+            }
+            File[] listOfFiles = dirFire.listFiles();
+            long QCFileSize = 0;
+            String filePath = "";
+            List<AnnexBean> fujianList = new ArrayList<>();
+            for (int i = 0; i < listOfFiles.length; i++) {
+                if (listOfFiles[i].isFile()) {
+                    // 获取文件路径
+                    filePath = listOfFiles[i].getAbsolutePath();
+                    fujianList.add(new AnnexBean(false, filePath,
+                            list.get(i).getFp_id() + ";", true));
+                    // 获取文件大小
+                    QCFileSize += listOfFiles[i].length();
+                }
+            }
+
+            //        if (QCDownloadFileSize == QCFileSize) {
+            //        if (listOfFiles.length == list.size()) {
+            getActivity().runOnUiThread(new Runnable() {
+                @Override
+                public void run() {
+                    MyLog.e("aaa","22222添加了文件类型:" + type + ",数量是:" + fujianList.size());
+                    if (type.equals("QC")) {
+                        //                        annexQCFuJianAdapter.addList(fujianList);
+//                        annexQCFuJianAdapter.setList(fujianList);
+//                        fujianList1.addAll(fujianList);
+
+//                        fujianList1.addAll(fujianList);
+//                        annexQCFuJianAdapter.addList(fujianList);
+
+                        fujianList1.clear();
+                        fujianList1.add(new AnnexBean(true, "", "", false));
+                        fujianList1.addAll(fujianList);
+                        annexQCFuJianAdapter.setListNotTitle(fujianList1);
+                        for (int i = 0; i < fujianList1.size(); i++) {
+                            MyLog.e("aaa","33333添加了文件类型:" + type + ",id是:" + fujianList1.get(i)+",是否是加号:" + fujianList1.get(i).isAddImage());
+                        }
+                    } else if (type.equals("Test")) {
+                        //                        annexShiYanFuJianAdapter.addList(fujianList);
+//                        annexShiYanFuJianAdapter.setList(fujianList);
+//                        fujianList2.addAll(fujianList);
+
+                        fujianList2.clear();
+                        fujianList2.add(new AnnexBean(true, "", "", false));
+                        fujianList2.addAll(fujianList);
+                        annexShiYanFuJianAdapter.setListNotTitle(fujianList2);
+
+//                        fujianList2.addAll(fujianList);
+//                        annexShiYanFuJianAdapter.addList(fujianList);
+
+                        for (int i = 0; i < fujianList2.size(); i++) {
+                            MyLog.e("aaa","33333添加了文件类型:" + type + ",id是:" + fujianList2.get(i)+",是否是加号:" + fujianList2.get(i).isAddImage());
+                        }
+                    }
+                }
+            });
+            if (imageQCUrlList.size() > 0 && imageTestUrlList.size() > 0) {
+                numberOfTimes++;
+                if (numberOfTimes >= 2) {
+                    progressDialog.dismiss();
+                }
+            }else {
+                progressDialog.dismiss();
+            }
+            //        }
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         return false;
@@ -340,9 +803,9 @@ public class ReportPageFra extends BaseFragment {
         if (resultCode != Activity.RESULT_OK) {
             return;
         }
-        if (requestCode == REQUEST_CODE1 && data!=null){
+        if (requestCode == REQUEST_CODE1 && data != null) {
             fujian = 1;
-        }else if (requestCode == REQUEST_CODE2 && data!=null){
+        } else if (requestCode == REQUEST_CODE2 && data != null) {
             fujian = 2;
         }
         selectedImagePaths.clear();
@@ -379,14 +842,10 @@ public class ReportPageFra extends BaseFragment {
     }
 
     private void uploadImages(List<String> imagePaths) {
-//        fujianList1.clear();
-//        fujianList2.clear();
-//        fujianList1.add(new AnnexBean(true,"",""));
-//        fujianList2.add(new AnnexBean(true,"",""));
         uploadRecords = 0;
         if (templist == null) {
             templist = new ArrayList<>();
-        }else {
+        } else {
             templist.clear();
         }
         uploadRecordsNumber = imagePaths.size();
@@ -444,34 +903,46 @@ public class ReportPageFra extends BaseFragment {
                                 String mEnclusureId = FastjsonUtil.getText(resultObject, "id");
                                 String s = removeSpace(mEnclusureId);
                                 String s1 = removeSpace2(s);
-                                Log.d("aaa", "切割后的数据: " + s1+"");
+                                Log.d("aaa", "切割后的数据: " + s1 + "");
                                 if (fujian == 1) {
-//                                    fujianList1.add(new AnnexBean(false,mFile.getAbsolutePath(),s1 + ";"));
-                                    templist.add(new AnnexBean(false,mFile.getAbsolutePath(),s1 + ";"));
-                                }else if (fujian == 2) {
-//                                    fujianList2.add(new AnnexBean(false,mFile.getAbsolutePath(),s1 + ";"));
-                                    templist.add(new AnnexBean(false,mFile.getAbsolutePath(),s1 + ";"));
+//                                    templist.add(new AnnexBean(false, mFile.getAbsolutePath(), s1 + ";", true));
+                                    for (int i = 0; i < fujianList1.size(); i++) {
+                                        MyLog.e("aaa","是否为+号" + fujianList1.get(i).isAddImage() + "当前的id是:" + fujianList1.get(i).getImageID());
+                                    }
+                                    fujianList1.add(new AnnexBean(false, mFile.getAbsolutePath(), s1 + ";", true));
+
+                                } else if (fujian == 2) {
+//                                    templist.add(new AnnexBean(false, mFile.getAbsolutePath(), s1 + ";", true));
+                                    fujianList2.add(new AnnexBean(false, mFile.getAbsolutePath(), s1 + ";", true));
                                 }
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
-                            uploadRecords++;
                             mActivity.runOnUiThread(new Runnable() {
                                 @Override
                                 public void run() {
+                                    uploadRecords++;
                                     if (uploadRecords == uploadRecordsNumber) {
                                         tv_updater_info.setTextColor(getResources().getColor(R.color.blue));
                                         tv_updater_info.setText("附件上传成功");
-                                       // CommonUtil.toastNoRepeat(mActivity,  "附件上传成功");
+                                        // CommonUtil.toastNoRepeat(mActivity,  "附件上传成功");
                                         if (fujian == 1) {
-//                                            Collections.reverse(fujianList1);
-//                                            annexQCFuJianAdapter.addList(fujianList1);
-                                            annexQCFuJianAdapter.addList(templist);
-                                        }else if (fujian == 2) {
-//                                            Collections.reverse(fujianList2);
-//                                            annexShiYanFuJianAdapter.addList(fujianList2);
-                                            annexShiYanFuJianAdapter.addList(templist);
+                                            //                                            Collections.reverse(fujianList1);
+//                                            annexQCFuJianAdapter.addList(templist);
+//                                            fujianList1.addAll(templist);
+                                            annexQCFuJianAdapter.setListNotTitle(fujianList1);
+                                            for (int i = 0; i < fujianList1.size(); i++) {
+                                                MyLog.e("aaa","2222是否为+号" + fujianList1.get(i).isAddImage() + "当前的id是:" + fujianList1.get(i).getImageID());
+                                            }
+                                        } else if (fujian == 2) {
+                                            //                                            Collections.reverse(fujianList2);
+//                                            annexShiYanFuJianAdapter.addList(templist);
+//                                            fujianList2.addAll(templist);
+                                            annexShiYanFuJianAdapter.setListNotTitle(fujianList2);
                                         }
+                                        cet_beizhu1.setEnabled(true);
+                                        cet_beizhu2.setEnabled(true);
+                                        bt_gengxin.setEnabled(true);
                                     }
                                 }
                             });
@@ -507,9 +978,9 @@ public class ReportPageFra extends BaseFragment {
     @Override
     public void onHiddenChanged(boolean hidden) {
         super.onHiddenChanged(hidden);
-//        if (!hidden) {
-//            setTitle("质量管理");
-//        }
+        //        if (!hidden) {
+        //            setTitle("质量管理");
+        //        }
     }
 
 }

+ 12 - 3
app/src/main/java/com/uas/hystorage/global/GloableParams.java

@@ -14,9 +14,9 @@ import com.uas.hystorage.util.Constants;
  */
 public class GloableParams {
     //记录用户请求IP
-    private static String IP = null;
-    private static String PORT = null;
-    private static String SITE = null;
+    public static String IP = null;
+    public static String PORT = null;
+    public static String SITE = null;
     public static String ADDRESS_CONNECT_SERVER;
     public static String ADDRESS_LOGIN_APPLY;
     public static String ADDRESS_INOUTNO_APPLY;
@@ -358,11 +358,14 @@ public class GloableParams {
     public static String ADDRESS_FUZZYSEARCHSAMPLEREPORT;  //搜索按钮点击或者输入框ENTER事件
     public static String ADDRESS_PRINTSAMPLEREPORT;  //送样单列表页面打印事件
 
+
     /**
      * 送样报告
      * */
     public static String ADDRESS_GETSAMPLEREPORT;  //送样报告---单号enter
     public static String ADDRESS_UPDATESAMPLEREPORT;  //送样报告---更新
+    public static String ADDRESS_GETFILEPATHS;  //通过附件图片的id获取图片
+    public static String ADDRESS_DOWNLOAD;  //根据地质url获取数据流
 
     /**
      * 高登
@@ -1054,6 +1057,10 @@ public class GloableParams {
     private static final String ADDRESSTAIL_GETSAMPLEREPORT = "/api/pdashop/quality/getSampleReport.action";
     //更新按钮点击事件
     private static final String ADDRESSTAIL_UPDATESAMPLEREPORT = "/api/pdashop/quality/updateSampleReport.action";
+    //通过图片ID获取图片url
+    private static final String ADDRESSTAIL_GETFILEPATHS = "/common/getFilePaths.action";
+    //根据地址URL获取数据流
+    private static final String ADDRESSTAIL_DOWNLOAD = "/api/pdashop/quality/download.action";
 
 
 
@@ -1642,6 +1649,8 @@ public class GloableParams {
         GloableParams.ADDRESS_PRINTSAMPLEREPORT = uriHead + GloableParams.ADDRESSTAIL_PRINTSAMPLEREPORT;
         GloableParams.ADDRESS_GETSAMPLEREPORT = uriHead + GloableParams.ADDRESSTAIL_GETSAMPLEREPORT;
         GloableParams.ADDRESS_UPDATESAMPLEREPORT = uriHead + GloableParams.ADDRESSTAIL_UPDATESAMPLEREPORT;
+        GloableParams.ADDRESS_GETFILEPATHS = uriHead + GloableParams.ADDRESSTAIL_GETFILEPATHS;
+        GloableParams.ADDRESS_DOWNLOAD = uriHead + GloableParams.ADDRESSTAIL_DOWNLOAD;
 
 
     }

+ 18 - 0
app/src/main/java/com/uas/hystorage/util/ClickUtils.java

@@ -0,0 +1,18 @@
+package com.uas.hystorage.util;
+
+public class ClickUtils {
+
+    private static long lastClickTime;
+    public static long pauseTime = 1000;
+
+    public static boolean isFastClick() {
+        long currentTime = System.currentTimeMillis();
+        if (currentTime - lastClickTime < pauseTime) {
+            return true;
+        }
+        lastClickTime = currentTime;
+        return false;
+    }
+
+
+}

+ 161 - 0
app/src/main/java/com/uas/hystorage/util/MyLog.java

@@ -0,0 +1,161 @@
+package com.uas.hystorage.util;
+
+import android.annotation.SuppressLint;
+import android.util.Log;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * 带日志文件输入,又可控开关的日志调试
+ */
+@SuppressLint("SimpleDateFormat")
+public class MyLog {
+	public static Boolean MYLOG_SWITCH = true; // 日志文件总开关
+	private static Boolean MYLOG_WRITE_TO_FILE = true;// 日志写入文件开关
+	private static char MYLOG_TYPE = 'v';// 输入日志类型,w代表只输出告警信息等,v代表输出所有信息
+	@SuppressLint("SdCardPath")
+	private static String MYLOG_PATH_SDCARD_DIR1 = "/sdcard/MSShow";    // 日志文件在sdcard中的路径
+	private static String MYLOG_PATH_SDCARD_DIR2 = "/Log";
+	private static String MYLOG_PATH_SDCARD_DIR = MYLOG_PATH_SDCARD_DIR1+MYLOG_PATH_SDCARD_DIR2;
+	private static String MYLOGFILEName = "Log.txt";// 本类输出的日志文件名称
+
+	@SuppressLint("SimpleDateFormat")
+	private static SimpleDateFormat myLogSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
+
+	private static boolean isDebug = true;		//普通log的开关
+	private static String TAG = "我的天啊" +"-----------";
+
+	public static void e(String msg){
+		if(isDebug){
+			Log.e(TAG, msg);
+		}
+	}
+
+	public static void w(String msg){
+		if(isDebug){
+			Log.w(TAG, msg);
+		}
+	}
+
+	public static void d(String msg){
+		if(isDebug){
+			Log.d(TAG, msg);
+		}
+	}
+
+	public static void i(String msg){
+		if(isDebug){
+			Log.i(TAG, msg);
+		}
+	}
+
+	public static void w(String tag, Object msg) { // 警告信息
+		log(tag, msg.toString(), 'w');
+	}
+
+	public static void e(String tag, Object msg) { // 错误信息
+		log(tag, msg.toString(), 'e');
+	}
+
+	public static void d(String tag, Object msg) {// 调试信息
+		log(tag, msg.toString(), 'd');
+	}
+
+	public static void i(String tag, Object msg) {//
+		log(tag, msg.toString(), 'i');
+	}
+
+	public static void v(String tag, Object msg) {
+		log(tag, msg.toString(), 'v');
+	}
+
+	public static void w(String tag, String text) {
+		log(tag, text, 'w');
+	}
+
+	public static void e(String tag, String text) {
+		log(tag, text, 'e');
+	}
+
+	public static void d(String tag, String text) {
+		log(tag, text, 'd');
+	}
+
+	public static void i(String tag, String text) {
+		log(tag, text, 'i');
+	}
+
+	public static void v(String tag, String text) {
+		log(tag, text, 'v');
+	}
+
+	/**
+	 * 根据tag, msg和等级,输出日志
+	 */
+	private static void log(String tag, String msg, char level) {
+		msg = "\r\n"+msg;
+		if (MYLOG_SWITCH) {
+			if ('e' == level && ('e' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) { // 输出错误信息
+				Log.e(tag, msg);
+			} else if ('w' == level && ('w' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
+				Log.w(tag, msg);
+			} else if ('d' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
+				Log.d(tag, msg);
+			} else if ('i' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
+				Log.i(tag, msg);
+			} else {
+				Log.v(tag, msg);
+			}
+			if (MYLOG_WRITE_TO_FILE) {
+				writeLogtoFile(String.valueOf(level), tag, msg);
+			}
+		}
+	}
+
+	/**
+	 * 打开日志文件并写入日志
+	 * **/
+	private static void writeLogtoFile(String mylogtype, String tag, String text) {// 新建或打开日志文件
+		isExist(MYLOG_PATH_SDCARD_DIR1);
+		isExist(MYLOG_PATH_SDCARD_DIR);
+		Date nowtime = new Date();
+//		String needWriteFiel = logfile.format(nowtime);
+		String needWriteMessage = myLogSdf.format(nowtime) + "    " + mylogtype
+				+ "    " + tag + "    " + text;
+		File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+		try {
+			FileWriter filerWriter = new FileWriter(file, true);// 后面这个参数代表是不是要接上文件中原来的数据,不进行覆盖
+			BufferedWriter bufWriter = new BufferedWriter(filerWriter);
+			bufWriter.write(needWriteMessage);
+			bufWriter.newLine();
+			bufWriter.close();
+			filerWriter.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 删除制定的日志文件
+	 * */
+	public static void delFile() {// 删除日志文件
+		File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+		if (file.exists()) {
+			file.delete();
+		}
+	}
+
+	public static void isExist(String path) {
+		File file = new File(path);
+		// 判断文件夹是否存在,如果不存在则创建文件夹
+		if (!file.exists()) {
+			file.mkdir();
+		}
+
+	}
+}

+ 164 - 0
app/src/main/java/com/uas/hystorage/util/OKHttpUitls.java

@@ -0,0 +1,164 @@
+package com.uas.hystorage.util;
+
+import android.os.Handler;
+import android.os.Message;
+import android.text.TextUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
+public class OKHttpUitls {
+
+    private OKHttpGetListener onOKHttpGetListener;
+    private MyHandler myHandler = new MyHandler();
+
+    private static final String TAG = "OKHttpUitls";
+
+    // get
+    public void get(String url) {
+        OkHttpClient.Builder builderlog = new OkHttpClient.Builder();
+//        if (BuildConfig.DEBUG) {
+//            builderlog.addNetworkInterceptor(new StethoInterceptor());
+//        }
+        OkHttpClient client = builderlog.build();
+
+//        OkHttpClient client = new OkHttpClient();
+        //创建请求对象
+        Request request = new Request.Builder().url(url).build();
+        //创建Call请求队列
+        //请求都是放到一个队列里面的
+        Call call = client.newCall(request);
+        MyLog.i(TAG,"get请求到的数据: " + call + "------------");
+        //开始请求
+        call.enqueue(new Callback() {
+            //       失败,成功的方法都是在子线程里面,不能直接更新UI
+            @Override
+            public void onFailure(Call call, IOException e) {
+                Message message = myHandler.obtainMessage();
+                message.obj = "请求失败";
+                message.what = 0;
+                myHandler.sendMessage(message);
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                Message message = myHandler.obtainMessage();
+                String json = response.body().string();
+                message.obj = json;
+                message.what = 1;
+                myHandler.sendMessage(message);
+            }
+        });
+    }
+
+    public void post(HashMap<String,String> map,String url){
+        OkHttpClient.Builder builderlog = new OkHttpClient.Builder();
+//        if (BuildConfig.DEBUG) {
+//            builderlog.addNetworkInterceptor(new StethoInterceptor());
+//        }
+        OkHttpClient okHttpClient = builderlog.build();
+
+//        OkHttpClient okHttpClient = new OkHttpClient();
+
+//        RequestBody requestBody = new FormBody.Builder()
+//                .add("companycode","1031")
+//                .add("password","a123456")
+//                .add("username","admin")
+//                .build();
+
+
+//        if (!url.equals(Http.loginUrl)) {
+//            SharedPreferencesHelper sp = App.getSP();
+//            String token = (String) sp.getSharedPreference("token", "");
+//            if (!TextUtils.isEmpty(token)) {
+//                map.put("token", token);
+//            }
+//        }
+
+        FormBody.Builder builder = new FormBody.Builder();
+        Iterator<String> iterator = map.keySet().iterator();
+        while (iterator.hasNext()) {
+            String key = iterator.next();
+            builder.add(key,"" + map.get(key));
+            MyLog.i(TAG,"post的参数是:" + key +",值是:" + map.get(key));
+        }
+        RequestBody requestBody = builder.build();
+        Request request = new Request.Builder()
+                .addHeader("content-type", "application/json")
+                .url(url)
+                .post(requestBody)
+                .build();
+
+        //方式二: 如果后端接收的使字符串就可以用这种方式
+ //       OkHttpClient client = new OkHttpClient();
+//        Request request = new Request.Builder()
+//                .addHeader("content-type", "application/json")
+//                .url(url)
+//                .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"),map.toString()))
+//                .build();
+
+        Call call = okHttpClient.newCall(request);
+        MyLog.i(TAG,"post() returned: " + call + "------------");
+        call.enqueue(new Callback() {
+            //       失败,成功的方法都是在子线程里面,不能直接更新UI
+            @Override
+            public void onFailure(Call call, IOException e) {
+                Message message = myHandler.obtainMessage();
+                message.obj = "请求失败";
+                message.what = 0;
+                myHandler.sendMessage(message);
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                Message message = myHandler.obtainMessage();
+                String json = response.body().string();
+                message.obj = json;
+                message.what = 1;
+                myHandler.sendMessage(message);
+            }
+        });
+
+
+    }
+
+    //使用接口回到,将数据返回
+    public interface OKHttpGetListener {
+        void error(String error);
+
+        void success(String json);
+    }
+
+    //给外部调用的方法
+    public void setOnOKHttpGetListener(OKHttpGetListener onOKHttpGetListener) {
+        this.onOKHttpGetListener = onOKHttpGetListener;
+    }
+
+    //使用Handler,将数据在主线程返回
+    class MyHandler extends Handler {
+        @Override
+        public void handleMessage(Message msg) {
+            int w = msg.what;
+            MyLog.i(TAG, "handleMessage() returned: " + msg);
+            if (w == 0) {
+                String error = (String) msg.obj;
+                onOKHttpGetListener.error(error);
+            }
+            if (w == 1) {
+                String json = (String) msg.obj;
+                onOKHttpGetListener.success(json);
+            }
+        }
+    }
+
+
+}

+ 11 - 0
app/src/main/java/com/uas/hystorage/util/OnDownloadListener.java

@@ -0,0 +1,11 @@
+package com.uas.hystorage.util;
+
+public interface OnDownloadListener {
+
+    void onDownloadFailed(Exception e);
+
+    void onDownloadSuccess();
+
+    void onDownloading(int i);
+
+}

+ 26 - 14
app/src/main/java/com/uas/hystorage/util/PrintUtils.java

@@ -32,10 +32,9 @@ public class PrintUtils {
 //                    h = 400,
 //                    v = 800,
 //                    height = 400,
-
                                         h = 400,
                                         v = 800,
-                                        height = 200,
+                                        height = 400,
                     qty = 1;
 
             JSONArray templateArray = JSON.parseArray(printTemplate);
@@ -43,8 +42,19 @@ public class PrintUtils {
                 PrintHelper printHelper = new PrintHelper(offset, h, v, height, qty);
                 for (int i = 0; i < templateArray.size(); i++) {
                     JSONObject templateObject = templateArray.getJSONObject(i);
-
                     if (templateObject != null) {
+                        //la_offset 偏移值
+                        //la_h    横向分辨率
+                        //la_y   纵向分辨率
+                        //la_height  最大高度
+                        //la_qty  重复打印次数
+                        int la_offset = FastjsonUtil.getInt(templateObject, "LA_OFFSET") == 0 ? 6:FastjsonUtil.getInt(templateObject, "LA_OFFSET");
+                        int la_h = FastjsonUtil.getInt(templateObject, "LA_H") == 0 ? 400:FastjsonUtil.getInt(templateObject, "LA_H");
+                        int la_y = FastjsonUtil.getInt(templateObject, "LA_Y") == 0 ? 800:FastjsonUtil.getInt(templateObject, "LA_Y");
+                        int la_height = FastjsonUtil.getInt(templateObject, "LA_HEIGHT") == 0 ? 300:FastjsonUtil.getInt(templateObject, "LA_HEIGHT");
+                        int la_qty = FastjsonUtil.getInt(templateObject, "LA_QTY") == 0 ? 1:FastjsonUtil.getInt(templateObject, "LA_QTY");
+                        printHelper = new PrintHelper(la_offset, la_h, la_y, la_height, la_qty);
+
                         String valuetype = FastjsonUtil.getText(templateObject, "LP_VALUETYPE");
                         double leftrate = FastjsonUtil.getDouble(templateObject, "LP_LEFTRATE");
                         int printX = (int) (leftrate * dpi / 25.4);
@@ -67,23 +77,24 @@ public class PrintUtils {
                             switch (valuetype) {
                                 case "barcode":     //条形码
                                     printHelper = printHelper.printBarCode(printText)
-                                            .setX(printX)
-                                            .setY(printY)
-                                            .setHeight(barHeightInt - (int) (2 * dpi / 25.4))
+                                            .setX(printX)//宽
+                                            .setY(printY)//高
+                                            .setHeight(barHeightInt - (int) (2 * dpi / 25.4))//条码单位高度
                                             .setCodeTextFont(4)
-                                            .setCodeTextSize(2)
+                                            .setCodeTextSize(fontSize)
                                             .build();
                                     break;
                                 case "text":    //文字
-                                    int textFont = 3;
+                                    int textFont = 7;
                                     if ("BAR_BATCHCODE".equals(printKey)) {
-                                        textFont = 3;
+                                        textFont = 7;
                                     }
                                     printHelper = printHelper.printText(printText)
                                             .setX(printX)
                                             .setY(printY)
-                                            .setBold(2)
-                                            .setTextFont(textFont)
+                                            .setBold(1)
+                                            .setTextFont(textFont)//字号
+                                            .setTextSize(fontSize)//字体大小,取接口的值
                                             .build();
                                     break;
                                 case "qrcode"://打印二维码
@@ -95,15 +106,16 @@ public class PrintUtils {
                                             .build();
                                     break;
                                 case "constant":        //文字
-                                    int textFont2 = 3;
+                                    int textFont2 = 7;
                                     if ("BAR_BATCHCODE".equals(printKey)) {
-                                        textFont2 = 3;
+                                        textFont2 = 7;
                                     }
                                     printHelper = printHelper.printText(printText)
                                             .setX(printX)
                                             .setY(printY)
                                             .setBold(2)
-                                            .setTextFont(textFont2)
+                                            .setTextFont(textFont2)//字号
+                                            .setTextSize(fontSize)//字体大小,取接口的值
                                             .build();
                                     break;
                             }

+ 2 - 1
app/src/main/java/com/uas/hystorage/util/VollyRequest.java

@@ -92,7 +92,8 @@ public class VollyRequest {
             }
         }
 
-        PdaApplication.mRequestQueue.cancelAll(httpParams.getUrl());
+        // 取消所有带有这个tag的请求
+//        PdaApplication.mRequestQueue.cancelAll(httpParams.getUrl());
 
         stringRequest = new StringRequest(httpParams.getMethod(), url,
                 new Response.Listener<String>() {

+ 152 - 0
app/src/main/java/com/uas/hystorage/util/YLDownload.java

@@ -0,0 +1,152 @@
+package com.uas.hystorage.util;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.support.annotation.NonNull;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.TimeUnit;
+
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+
+import okhttp3.Callback;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+
+/**
+ * 文件下载工具栏
+ */
+public class YLDownload {
+    private static YLDownload ylDownload;
+    private OkHttpClient client = new OkHttpClient.Builder()
+            .connectTimeout(60, TimeUnit.SECONDS)
+            .readTimeout(60, TimeUnit.SECONDS)
+            .writeTimeout(60, TimeUnit.SECONDS)
+            .build();
+
+    //    private OkHttpClient client = new OkHttpClient();
+
+
+    private YLDownload() {
+    }
+
+    public static YLDownload getInstance() {
+        if (ylDownload == null) {
+            ylDownload = new YLDownload();
+        }
+        return ylDownload;
+    }
+
+    /**
+     * @param url                下载地址
+     * @param fileDir            储存下载文件的目录
+     * @param fileName           文件名称
+     * @param onDownloadListener 下载监听
+     */
+    public void download(String url, String fileDir, String fileName, OnDownloadListener onDownloadListener) {
+        Request request = new Request.Builder()
+                .url(url)
+                .build();
+        //MyLog.e("aaa","下载路径是:" + url + ",文件夹:" + fileDir + ",文件名:" + fileName);
+        Call call = client.newCall(request);
+        call.enqueue(new Callback() {
+            @Override
+            public void onFailure(@NonNull Call call, @NonNull IOException e) {
+                onDownloadListener.onDownloadFailed(e);
+            }
+
+            @Override
+            public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
+                if (response.isSuccessful()) {
+                    MyLog.e("aaa","下载路径是:" + url + ",文件夹:" + fileDir + ",文件名:" + fileName);
+                    ResponseBody responseBody = response.body();
+                    File file_dir = new File(fileDir);
+                    if (!file_dir.exists()) {
+                        file_dir.mkdirs();
+                    }
+                    File file = new File(file_dir, fileName);
+                    FileOutputStream fos = new FileOutputStream(file);
+
+
+//                    // 获取输入流
+//                    InputStream inputStream = responseBody.byteStream();
+//                    // 创建文件输出流
+//                    FileOutputStream fos = new FileOutputStream(file);
+//                    // 定义缓冲区
+//                    byte[] buffer = new byte[4096];
+//                    int bytesRead;
+//
+//                    // 读取文件并写入到本地
+//                    while ((bytesRead = inputStream.read(buffer)) != -1) {
+//                        fos.write(buffer, 0, bytesRead);
+//                    }
+//                    // 关闭流
+//                    fos.close();
+//                    inputStream.close();
+
+
+
+                    fos.write(responseBody.bytes());
+                    fos.close();
+                    onDownloadListener.onDownloadSuccess();
+                }else {
+                    MyLog.e("aaa","下载失败路径是:" + url + ",文件名:" + fileName);
+                }
+
+
+                //                InputStream inputStream = null;
+                //                FileOutputStream outputStream = null;
+                //                byte[] buff = new byte[2048];
+                //                int length = 0;
+                //
+                //                // 储存下载文件的目录
+                //                File file_dir = new File(fileDir);
+                //                if (!file_dir.exists()) {
+                //                    file_dir.mkdirs();
+                //                }
+                //                File file = new File(file_dir, fileName);
+                //
+                //                try {
+                //                    inputStream = response.body().byteStream();
+                //                    long total = response.body().contentLength();
+                //                    outputStream = new FileOutputStream(file);
+                //                    length = inputStream.read(buff);
+                //                    long sum = 0;
+                //                    while (length != -1) {
+                //                        outputStream.write(buff, 0, length);
+                //                        sum += length;
+                //                        int progress = (int) (sum * 1.0f / total * 100);
+                //                        // 下载中更新进度条
+                //                        onDownloadListener.onDownloading(progress);
+                //                    }
+                //                    outputStream.flush();
+                //                    // 下载完成
+                //                    onDownloadListener.onDownloadSuccess();
+                //                } catch (Exception e) {
+                //                    onDownloadListener.onDownloadFailed(e);
+                //                } finally {
+                //                    if (inputStream != null) {
+                //                        inputStream.close();
+                //                    }
+                //                    if (outputStream != null) {
+                //                        outputStream.close();
+                //                    }
+                //                }
+
+
+            }
+        });
+
+        //        try {
+        //            call.execute();
+        //        } catch (IOException e) {
+        //            e.printStackTrace();
+        //        }
+    }
+}

+ 11 - 9
app/src/main/res/layout/fra_report_page.xml

@@ -128,6 +128,17 @@
                 android:hint=""
                 android:textColor="@color/black"/>
 
+            <TextView
+                android:id="@+id/tv_updater_info"
+                android:layout_marginTop="10dp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text=""
+                android:textSize="16sp"
+                android:textColor="@color/red"
+                />
+
+
             <Button
                 android:layout_marginTop="10dp"
                 android:id="@+id/bt_gengxin"
@@ -140,15 +151,6 @@
                 android:text="更新" />
 
 
-            <TextView
-                android:id="@+id/tv_updater_info"
-                android:layout_marginTop="10dp"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text=""
-                android:textSize="16sp"
-                android:textColor="@color/red"
-                />
 
 
         </LinearLayout>

+ 2 - 2
app/src/main/res/layout/item_annex_image.xml

@@ -20,8 +20,8 @@
 
         <ImageView
             android:id="@+id/iv_cancel"
-            android:layout_width="35dp"
-            android:layout_height="35dp"
+            android:layout_width="25dp"
+            android:layout_height="25dp"
             android:src="@drawable/ic_delete"
             android:layout_alignParentEnd="true"
             />

+ 2 - 2
build.gradle

@@ -54,8 +54,8 @@ ext {
             targetSdkVersion : 28,
             compileSdkVersion: 28,
             buildToolsVersion: "28.0.3",
-            versionCode      : 33,
-            versionName      : "v1.2.3"
+            versionCode      : 34,
+            versionName      : "v1.2.4"
     ]
 
     depsVersion = [