|
@@ -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("质量管理");
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
}
|