|
|
@@ -1,35 +1,79 @@
|
|
|
package com.uas.equipment.fragment;
|
|
|
|
|
|
+import android.Manifest;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.database.Cursor;
|
|
|
import android.graphics.Color;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.provider.MediaStore;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.app.ActivityCompat;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.text.TextUtils;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.KeyEvent;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.Window;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
import android.widget.Button;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
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.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
+import com.chad.library.adapter.base.BaseViewHolder;
|
|
|
import com.uas.equipment.R;
|
|
|
import com.uas.equipment.activity.FunctionActivity;
|
|
|
+import com.uas.equipment.adapter.AnnexAdapter;
|
|
|
+import com.uas.equipment.bean.AnnexBean;
|
|
|
+import com.uas.equipment.bean.LineCodeEntity;
|
|
|
import com.uas.equipment.camera.CaptureActivity;
|
|
|
import com.uas.equipment.camera.CodeUtils;
|
|
|
import com.uas.equipment.global.GloableParams;
|
|
|
+import com.uas.equipment.interfaces.ProgressListener;
|
|
|
import com.uas.equipment.tools.SharedPreUtil;
|
|
|
import com.uas.equipment.util.CameraUtil;
|
|
|
+import com.uas.equipment.util.ClickUtils;
|
|
|
import com.uas.equipment.util.CommonUtil;
|
|
|
import com.uas.equipment.util.Constants;
|
|
|
import com.uas.equipment.util.FastjsonUtil;
|
|
|
import com.uas.equipment.util.HttpCallback;
|
|
|
import com.uas.equipment.util.HttpParams;
|
|
|
+import com.uas.equipment.util.LogUtil;
|
|
|
import com.uas.equipment.util.StringUtil;
|
|
|
+import com.uas.equipment.util.UploadUtils;
|
|
|
+import com.uas.equipment.util.VolleyRequest;
|
|
|
import com.uas.equipment.util.VollyRequest;
|
|
|
import com.uas.equipment.view.ClearableEditText;
|
|
|
+import com.uas.equipment.view.business.ProgressPopup;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+import okhttp3.Call;
|
|
|
+import okhttp3.Callback;
|
|
|
+import okhttp3.MediaType;
|
|
|
+import okhttp3.MultipartBody;
|
|
|
+import okhttp3.RequestBody;
|
|
|
+import okhttp3.Response;
|
|
|
+import razerdp.basepopup.BasePopupWindow;
|
|
|
|
|
|
/**
|
|
|
* Created by cjh-sail on 2023-01-31
|
|
|
@@ -49,6 +93,31 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
private ImageView storage_recharge_scan_iv;
|
|
|
private int mFocusId;
|
|
|
private static final int SCAN_BARCODE_CODE = 111;
|
|
|
+
|
|
|
+ private TextView tv_dc_emcode;
|
|
|
+ private ImageView iv_dc_emcode_delete, iv_number_search_for, iv_clear;
|
|
|
+ private String li_personne_id; //人员编号
|
|
|
+ private GetLinePortAdapter getLinePortAdapter;
|
|
|
+ private ArrayList<LineCodeEntity> personnelList;
|
|
|
+ private ClearableEditText edit_et;
|
|
|
+ private RecyclerView rv_getline_ip_port_data;
|
|
|
+ private PopupWindow editPW;
|
|
|
+
|
|
|
+ private RecyclerView rv_qc_fujian;
|
|
|
+ private List<AnnexBean> fujianList1;
|
|
|
+ private AnnexAdapter fuJianAdapter;
|
|
|
+ private final int REQUEST_EXTERNAL_STORAGE = 1;
|
|
|
+ private String[] PERMISSIONS_STORAGE = {
|
|
|
+ Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
+ Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
|
|
+ private static final int REQUEST_CODE1 = 1;
|
|
|
+ private int fujian = 0;
|
|
|
+ private List<String> selectedImagePaths = new ArrayList<>();
|
|
|
+ private int uploadRecords;
|
|
|
+ private List<AnnexBean> templist;
|
|
|
+ private int uploadRecordsNumber;
|
|
|
+ private ProgressPopup mProgressPopup;
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayout() {
|
|
|
return R.layout.fragment_breakdownrepair;
|
|
|
@@ -65,10 +134,33 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
btn_commit = root.findViewById(R.id.btn_commit);
|
|
|
ce_de_code = root.findViewById(R.id.ce_de_code);
|
|
|
storage_recharge_scan_iv = root.findViewById(R.id.storage_recharge_scan_iv);
|
|
|
+
|
|
|
+ tv_dc_emcode = root.findViewById(R.id.tv_dc_emcode);
|
|
|
+ iv_dc_emcode_delete = root.findViewById(R.id.iv_dc_emcode_delete);
|
|
|
+ iv_number_search_for = root.findViewById(R.id.iv_number_search_for);
|
|
|
+ iv_clear = root.findViewById(R.id.iv_clear);
|
|
|
+
|
|
|
+ rv_qc_fujian = root.findViewById(R.id.rv_qc_fujian);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initEvents() {
|
|
|
+ iv_clear.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ tv_dc_emcode.setFocusableInTouchMode(true);
|
|
|
+ tv_dc_emcode.setText("");
|
|
|
+ tv_dc_emcode.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ iv_dc_emcode_delete.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ tv_dc_emcode.setFocusableInTouchMode(true);
|
|
|
+ tv_dc_emcode.setText("");
|
|
|
+ tv_dc_emcode.requestFocus();
|
|
|
+ }
|
|
|
+ });
|
|
|
ce_de_code.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
@Override
|
|
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
@@ -102,8 +194,254 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ iv_number_search_for.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ initGetPersonnelID();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+ private void initGetPersonnelID() {
|
|
|
+ li_personne_id = "";
|
|
|
+ personnelList.clear();
|
|
|
+ getLinePortAdapter = new GetLinePortAdapter(personnelList);
|
|
|
+ View contView = LayoutInflater.from(mActivity).inflate(R.layout.index_line_pup, null);
|
|
|
+ edit_et = (ClearableEditText) contView.findViewById(R.id.edit_et);
|
|
|
+ TextView sure_tv = (TextView) contView.findViewById(R.id.sure_tv);
|
|
|
+ TextView cancle_tv = (TextView) contView.findViewById(R.id.cancle_tv);
|
|
|
+ ImageView search_im = contView.findViewById(R.id.search_im);
|
|
|
+ LinearLayout line_top = contView.findViewById(R.id.line_top);
|
|
|
+ rv_getline_ip_port_data = contView.findViewById(R.id.rv_ip_port_data);
|
|
|
+ rv_getline_ip_port_data.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayout.VERTICAL));
|
|
|
+ rv_getline_ip_port_data.setLayoutManager(new LinearLayoutManager(mActivity));
|
|
|
+ getLinePortAdapter.setmList(personnelList);
|
|
|
+ rv_getline_ip_port_data.setAdapter(getLinePortAdapter);
|
|
|
+ getPersonnelID();
|
|
|
+
|
|
|
+ editPW = new PopupWindow(contView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ editPW.setTouchable(true);
|
|
|
+ editPW.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ editPW.setOnDismissListener(new BasePopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ View parentView = mActivity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
|
|
|
+ editPW.showAtLocation(parentView, Gravity.CENTER, 0, 0);
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 0.5f);
|
|
|
+ search_im.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String mSearchStr = edit_et.getText().toString().trim();
|
|
|
+ if (!mSearchStr.isEmpty()) {
|
|
|
+ List<LineCodeEntity> thisList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < personnelList.size(); i++) {
|
|
|
+ if (personnelList.get(i).getLI_CODE().contains(mSearchStr) ||
|
|
|
+ personnelList.get(i).getLI_NAME().contains(mSearchStr)
|
|
|
+ ) {
|
|
|
+ thisList.add(personnelList.get(i));
|
|
|
+ }
|
|
|
+ if (i == personnelList.size() - 1) {
|
|
|
+ getLinePortAdapter = new GetLinePortAdapter(thisList);
|
|
|
+ rv_getline_ip_port_data.setAdapter(getLinePortAdapter);
|
|
|
+ LogUtil.i("mSearchStr", JSON.toJSONString(thisList));
|
|
|
+ }
|
|
|
+ List<LineCodeEntity> lineCodeEntities = getLinePortAdapter.getmList();
|
|
|
+ for (int j = 0; j < lineCodeEntities.size(); j++) {
|
|
|
+ lineCodeEntities.get(j).setChecked(false);
|
|
|
+ }
|
|
|
+ getLinePortAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getLinePortAdapter = new GetLinePortAdapter(personnelList);
|
|
|
+ rv_getline_ip_port_data.setAdapter(getLinePortAdapter);
|
|
|
+ List<LineCodeEntity> lineCodeEntities = getLinePortAdapter.getmList();
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ lineCodeEntities.get(i).setChecked(false);
|
|
|
+ }
|
|
|
+ getLinePortAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ }
|
|
|
+ getLinePortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ try {
|
|
|
+ List<LineCodeEntity> lineCodeEntities = getLinePortAdapter.getmList();
|
|
|
+ String li_code = lineCodeEntities.get(position).getLI_CODE();
|
|
|
+ if (TextUtils.isEmpty(li_personne_id)) {
|
|
|
+ li_personne_id = li_code;
|
|
|
+ }else{
|
|
|
+ if (li_personne_id.contains(li_code)){
|
|
|
+ String[] split = li_personne_id.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ if (split[i].equals(li_code)) {
|
|
|
+ if (li_personne_id.length() > li_code.length()) {
|
|
|
+ int start = li_personne_id.indexOf(li_code) - 1;
|
|
|
+ int end = start + li_code.length() + 1;
|
|
|
+ if(start <= 0) {
|
|
|
+ li_personne_id = li_personne_id.substring(end);
|
|
|
+ }else {
|
|
|
+ li_personne_id = li_personne_id.substring(0, start).concat(li_personne_id.substring(end));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ li_personne_id = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ li_personne_id += "," + li_code;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ String[] split = li_personne_id.split(",");
|
|
|
+ for (int i1 = 0; i1 < split.length; i1++) {
|
|
|
+ if (li_code.equals(split[i1])) {
|
|
|
+ lineCodeEntities.get(position).setChecked(true);
|
|
|
+ }else {
|
|
|
+ lineCodeEntities.get(position).setChecked(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getLinePortAdapter.notifyDataSetChanged();
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ getLinePortAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
|
+ try {
|
|
|
+ List<LineCodeEntity> lineCodeEntities = getLinePortAdapter.getmList();
|
|
|
+ String li_code = lineCodeEntities.get(position).getLI_CODE();
|
|
|
+ if (TextUtils.isEmpty(li_personne_id)) {
|
|
|
+ li_personne_id = li_code;
|
|
|
+ }else{
|
|
|
+ if (li_personne_id.contains(li_code)){
|
|
|
+ String[] split = li_personne_id.split(",");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ if (split[i].equals(li_code)) {
|
|
|
+ if (li_personne_id.length() > li_code.length()) {
|
|
|
+ int start = li_personne_id.indexOf(li_code) - 1;
|
|
|
+ int end = start + li_code.length() + 1;
|
|
|
+ if(start <= 0) {
|
|
|
+ li_personne_id = li_personne_id.substring(end);
|
|
|
+ }else {
|
|
|
+ li_personne_id = li_personne_id.substring(0, start).concat(li_personne_id.substring(end));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ li_personne_id = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ li_personne_id += "," + li_code;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < lineCodeEntities.size(); i++) {
|
|
|
+ String[] split = li_personne_id.split(",");
|
|
|
+ for (int i1 = 0; i1 < split.length; i1++) {
|
|
|
+ if (li_code.equals(split[i1])) {
|
|
|
+ lineCodeEntities.get(position).setChecked(true);
|
|
|
+ }else {
|
|
|
+ lineCodeEntities.get(position).setChecked(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getLinePortAdapter.notifyDataSetChanged();
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //确定
|
|
|
+ sure_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (!StringUtil.isEmpty(li_personne_id)) {
|
|
|
+ tv_dc_emcode.setText(li_personne_id);
|
|
|
+ } else {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请选择人员编号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //取消
|
|
|
+ cancle_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ closeListPopupWindow();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setcodelineAdapter(ArrayList<LineCodeEntity> mList) {
|
|
|
+ getLinePortAdapter.setmList(mList);
|
|
|
+ getLinePortAdapter.notifyDataSetChanged();
|
|
|
+ rv_getline_ip_port_data.setAdapter(getLinePortAdapter);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void closeListPopupWindow() {
|
|
|
+ if (editPW != null) {
|
|
|
+ editPW.dismiss();
|
|
|
+ editPW = null;
|
|
|
+ CommonUtil.setBackgroundAlpha(mActivity, 1f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getPersonnelID() {
|
|
|
+ // progressDialog.show();
|
|
|
+ VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
|
|
|
+ .url(GloableParams.ADD_GET_PERSONNEL_ID)
|
|
|
+ .method(Request.Method.POST)
|
|
|
+ .build(), new HttpCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ personnelList.clear();
|
|
|
+ try {
|
|
|
+ String result = o.toString();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ JSONArray dataArray = resultObject.getJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.getJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ LineCodeEntity lineCodeEntity = new LineCodeEntity();
|
|
|
+ lineCodeEntity.setLI_CODE(FastjsonUtil.getText(dataObject, "EM_CODE"));
|
|
|
+ lineCodeEntity.setLI_NAME(FastjsonUtil.getText(dataObject, "EM_NAME"));
|
|
|
+ personnelList.add(lineCodeEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (personnelList.size() == 0) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "人员编号数据为空");
|
|
|
+ } else {
|
|
|
+ setcodelineAdapter(personnelList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, failStr);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
protected void initDatas() {
|
|
|
Bundle arguments = getArguments();
|
|
|
@@ -122,9 +460,183 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ personnelList = new ArrayList<>();
|
|
|
+
|
|
|
+ LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
|
|
|
+ rv_qc_fujian.setLayoutManager(linearLayoutManager);
|
|
|
+ fujianList1 = new ArrayList<>();
|
|
|
+ fujianList1.add(new AnnexBean(true, "", "", true));
|
|
|
+ fuJianAdapter = new AnnexAdapter(getActivity(), fujianList1);
|
|
|
+ rv_qc_fujian.setAdapter(fuJianAdapter);
|
|
|
+ fuJianAdapter.setImageUpload(new AnnexAdapter.AddImage() {
|
|
|
+ @Override
|
|
|
+ public void startAdd() {
|
|
|
+ verifyStoragePermissions(mActivity);
|
|
|
+ // 启动文件选择器
|
|
|
+ Intent intent = new Intent(Intent.ACTION_PICK);
|
|
|
+ intent.setType("image/*");
|
|
|
+ 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);
|
|
|
+ fuJianAdapter.setListNotTitle(fujianList1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRealPathFromUri(Uri uri) {
|
|
|
+ // 获取真实的文件路径
|
|
|
+ String filePath;
|
|
|
+ String[] projection = {MediaStore.Images.Media.DATA};
|
|
|
+ Cursor cursor = mActivity.getContentResolver().query(uri, projection, null, null, null);
|
|
|
+ if (cursor == null) {
|
|
|
+ filePath = uri.getPath();
|
|
|
+ } else {
|
|
|
+ cursor.moveToFirst();
|
|
|
+ int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
|
|
+ filePath = cursor.getString(columnIndex);
|
|
|
+ cursor.close();
|
|
|
+ }
|
|
|
+ return filePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void uploadImages(List<String> imagePaths) {
|
|
|
+ uploadRecords = 0;
|
|
|
+ if (templist == null) {
|
|
|
+ templist = new ArrayList<>();
|
|
|
+ } else {
|
|
|
+ templist.clear();
|
|
|
+ }
|
|
|
+ uploadRecordsNumber = imagePaths.size();
|
|
|
+ for (String imagePath : imagePaths) {
|
|
|
+ try {
|
|
|
+ File mFile = new File(imagePath);
|
|
|
+ // 获得文件名
|
|
|
+ String fileName = mFile.getName();
|
|
|
+ MultipartBody.Builder builder = new MultipartBody.Builder();
|
|
|
+ builder.setType(MultipartBody.FORM);
|
|
|
+ //第一个参数要与Servlet中的一致
|
|
|
+ builder.addFormDataPart("file", fileName,
|
|
|
+ RequestBody.create(MediaType.parse("application/octet-stream"), mFile))
|
|
|
+ .addFormDataPart("type", "common")
|
|
|
+ .addFormDataPart("master", CommonUtil.getMaster(mActivity));
|
|
|
+ RequestBody multipartBody = builder.build();
|
|
|
+ if (mProgressPopup == null) {
|
|
|
+ mProgressPopup = new ProgressPopup(getActivity());
|
|
|
+ mProgressPopup.setTitle("附件上传中...");
|
|
|
+ }
|
|
|
+ mProgressPopup.setProgress(0);
|
|
|
+ mProgressPopup.showPopupWindow();
|
|
|
+
|
|
|
+ UploadUtils.getInstance().postFile(GloableParams.ADDRESS_MOBILE_UPLOADATTACHS, multipartBody, new ProgressListener() {
|
|
|
+ @Override
|
|
|
+ public void onProgress(long currentBytes, long contentLength, boolean isDone) {
|
|
|
+ int progress = (int) ((double) currentBytes * 100 / (double) contentLength);
|
|
|
+ mProgressPopup.setProgress(progress);
|
|
|
+ if (isDone || progress == 100) {
|
|
|
+ mProgressPopup.dismiss();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, new Callback() {
|
|
|
+ @Override
|
|
|
+ public void onFailure(Call call, IOException e) {
|
|
|
+ mProgressPopup.dismiss();
|
|
|
+ Log.d("raomeng_uploadf", e.getMessage());
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //CommonUtil.toastNoRepeat(mActivity, "附件上传失败");
|
|
|
+ tv_prompt.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_prompt.setText("附件上传失败");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResponse(Call call, Response response) throws IOException {
|
|
|
+ mProgressPopup.dismiss();
|
|
|
+ if (response.code() == 200) {
|
|
|
+ try {
|
|
|
+ String result = response.body().string();
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ String mEnclusureId = FastjsonUtil.getText(resultObject, "id");
|
|
|
+ String s = removeSpace(mEnclusureId);
|
|
|
+ String s1 = removeSpace2(s);
|
|
|
+ Log.d("aaa", "切割后的数据: " + s1 + "");
|
|
|
+ if (fujian == 1) {
|
|
|
+ fujianList1.add(new AnnexBean(false, mFile.getAbsolutePath(), s1 + ";", true));
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ mActivity.runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ uploadRecords++;
|
|
|
+ if (uploadRecords == uploadRecordsNumber) {
|
|
|
+ tv_prompt.setTextColor(getResources().getColor(R.color.blue));
|
|
|
+ tv_prompt.setText("附件上传成功");
|
|
|
+ // CommonUtil.toastNoRepeat(mActivity, "附件上传成功");
|
|
|
+ if (fujian == 1) {
|
|
|
+ // Collections.reverse(fujianList1);
|
|
|
+ // annexQCFuJianAdapter.addList(templist);
|
|
|
+ // fujianList1.addAll(templist);
|
|
|
+ fuJianAdapter.setListNotTitle(fujianList1);
|
|
|
+ for (int i = 0; i < fujianList1.size(); i++) {
|
|
|
+ Log.e("aaa","是否为+号" + fujianList1.get(i).isAddImage() + "当前的id是:" + fujianList1.get(i).getImageID());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, new File[]{mFile});
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (mProgressPopup != null) {
|
|
|
+ mProgressPopup.dismiss();
|
|
|
+ }
|
|
|
+ tv_prompt.setTextColor(getResources().getColor(R.color.red));
|
|
|
+ tv_prompt.setText("附件上传失败");
|
|
|
+ //CommonUtil.toastNoRepeat(mActivity, "附件上传失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public String removeSpace(String s) {
|
|
|
+ String regex = "\\[";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(s);
|
|
|
+ return matcher.replaceAll("");
|
|
|
+ }
|
|
|
+
|
|
|
+ public String removeSpace2(String s) {
|
|
|
+ String regex = "]";
|
|
|
+ Pattern pattern = Pattern.compile(regex);
|
|
|
+ Matcher matcher = pattern.matcher(s);
|
|
|
+ return matcher.replaceAll("");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void getNewCommitData(){
|
|
|
+ ClickUtils.pauseTime = 2000;
|
|
|
+ if (ClickUtils.isFastClick()) {
|
|
|
+ CommonUtil.toastNoRepeat(mActivity, "请勿点击过快");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (index_fault_phenomenon.getText().toString().trim().isEmpty()||index_position_resource.getText().toString().trim().isEmpty()){
|
|
|
CommonUtil.toastNoRepeat(mActivity, "请填写故障现象!");
|
|
|
return;
|
|
|
@@ -133,6 +645,16 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
// CommonUtil.toastNoRepeat(mActivity, "请填写备注!");
|
|
|
// return;
|
|
|
// }
|
|
|
+
|
|
|
+ //附件ID
|
|
|
+ String fujianStr1 = "";
|
|
|
+ if (fujianList1.size() > 0) {
|
|
|
+ for (int i = 1; i < fujianList1.size(); i++) {
|
|
|
+ String s = fujianList1.get(i).getImageID();
|
|
|
+ fujianStr1 += s;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
progressDialog.show();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
@@ -147,6 +669,8 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
.addParam("caller", "DeviceChange!Inspect")
|
|
|
.addParam("de_code",de_code)
|
|
|
.addParam("formStore",jsonArray.toString())
|
|
|
+ .addParam("fp_id",fujianStr1)
|
|
|
+ .addParam("em_name",li_personne_id)
|
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
@@ -237,5 +761,58 @@ public class BreakdownRepairFragment extends BaseFragment{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //图片附件上传相关
|
|
|
+ if (requestCode == REQUEST_CODE1 && data != null) {
|
|
|
+ fujian = 1;
|
|
|
+ }
|
|
|
+ selectedImagePaths.clear();
|
|
|
+ if (data.getClipData() != null) {
|
|
|
+ // 用户选择了多个图片
|
|
|
+ int count = data.getClipData().getItemCount();
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ Uri imageUri = data.getClipData().getItemAt(i).getUri();
|
|
|
+ selectedImagePaths.add(getRealPathFromUri(imageUri));
|
|
|
+ }
|
|
|
+ } else if (data.getData() != null) {
|
|
|
+ // 用户选择了单个图片
|
|
|
+ Uri imageUri = data.getData();
|
|
|
+ selectedImagePaths.add(getRealPathFromUri(imageUri));
|
|
|
+ }
|
|
|
+ // 批量上传图片
|
|
|
+ uploadImages(selectedImagePaths);
|
|
|
}
|
|
|
+
|
|
|
+ private class GetLinePortAdapter extends BaseQuickAdapter<LineCodeEntity, BaseViewHolder> {
|
|
|
+ private List<LineCodeEntity> mmmmList;
|
|
|
+
|
|
|
+ public List<LineCodeEntity> getmList() {
|
|
|
+ return mmmmList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setmList(List<LineCodeEntity> mList) {
|
|
|
+ this.mmmmList = mList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public LineCodeEntity getBeanByPositon(int position) {
|
|
|
+ return mmmmList.get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ private GetLinePortAdapter(@Nullable List<LineCodeEntity> data) {
|
|
|
+ super(R.layout.fuzzy_ipandport_item, data);
|
|
|
+ this.mmmmList = data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void convert(BaseViewHolder helper, LineCodeEntity item) {
|
|
|
+ helper.setText(R.id.macode_ip__Tv, item.getLI_NAME() + "(" + item.getLI_CODE() + ")");
|
|
|
+ LinearLayout line_true = helper.itemView.findViewById(R.id.line_true);
|
|
|
+ if (item.getChecked()) {
|
|
|
+ line_true.setSelected(true);
|
|
|
+ } else {
|
|
|
+ line_true.setSelected(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|