guilin 6 mesiacov pred
rodič
commit
3cb786b0fb
49 zmenil súbory, kde vykonal 7711 pridanie a 827 odobranie
  1. 1 1
      app/build.gradle
  2. 54 2
      app/src/main/AndroidManifest.xml
  3. 5 0
      app/src/main/java/com/fxy/adapter/GridImageAdapter.java
  4. 28 0
      app/src/main/java/com/fxy/base/ChargeStateReceiver.java
  5. 0 2
      app/src/main/java/com/fxy/base/ServiceSettingActivity.java
  6. 69 0
      app/src/main/java/com/fxy/base/UploadAppCompat.java
  7. 58 0
      app/src/main/java/com/fxy/base/UploadContentProvider.java
  8. 351 0
      app/src/main/java/com/fxy/common/AsyncFileUpload.java
  9. 515 0
      app/src/main/java/com/fxy/common/AsyncPictureSelector.java
  10. 502 0
      app/src/main/java/com/fxy/common/AsyncPictureUpload.java
  11. 9 1
      app/src/main/java/com/fxy/common/CommonDialog.java
  12. 10 85
      app/src/main/java/com/fxy/constant/EventCode.java
  13. 7 2
      app/src/main/java/com/fxy/constant/SPCache.java
  14. 267 386
      app/src/main/java/com/fxy/detection/DetectionPutInMainActivity.java
  15. 756 0
      app/src/main/java/com/fxy/detection/BoxPutInMainActivity.java
  16. 802 0
      app/src/main/java/com/fxy/detection/TrayMakeFourMainActivity.java
  17. 561 0
      app/src/main/java/com/fxy/detection/TrayMakeMainActivity.java
  18. 744 0
      app/src/main/java/com/fxy/detection/TrayMakeSecondMainActivity.java
  19. 561 0
      app/src/main/java/com/fxy/detection/TrayMakeThirdMainActivity.java
  20. 775 0
      app/src/main/java/com/fxy/detection/TrayPutInMainActivity.java
  21. 46 0
      app/src/main/java/com/fxy/detection/bean/StorageRecordBean.java
  22. 174 0
      app/src/main/java/com/fxy/detection/bean/TrackingBoxBean.java
  23. 174 0
      app/src/main/java/com/fxy/detection/bean/TrayMakeBean.java
  24. 20 1
      app/src/main/java/com/fxy/main/MainActivity.java
  25. 22 6
      app/src/main/java/com/fxy/main/fragment/HomePagerFragment.java
  26. 2 0
      app/src/main/java/com/fxy/main/fragment/MineFragment.java
  27. 22 0
      app/src/main/java/com/fxy/net/Urls.java
  28. 1 1
      app/src/main/java/com/fxy/realm/AsyncUploadRealm.java
  29. 57 0
      app/src/main/java/com/fxy/service/UploadJobService.java
  30. 112 0
      app/src/main/java/com/fxy/utils/JobUtils.java
  31. 27 0
      app/src/main/java/com/fxy/utils/UploadUtils.java
  32. 113 0
      app/src/main/res/layout/activity_base_setting.xml
  33. 125 0
      app/src/main/res/layout/activity_fxy_detection_box_putin.xml
  34. 133 140
      app/src/main/res/layout/activity_fxy_detection_putin.xml
  35. 0 189
      app/src/main/res/layout/activity_fxy_detection_putin_check.xml
  36. 39 0
      app/src/main/res/layout/activity_fxy_detection_tray_make.xml
  37. 125 0
      app/src/main/res/layout/activity_fxy_detection_tray_make_four.xml
  38. 95 0
      app/src/main/res/layout/activity_fxy_detection_tray_make_second.xml
  39. 70 0
      app/src/main/res/layout/activity_fxy_detection_tray_make_third.xml
  40. 111 0
      app/src/main/res/layout/activity_fxy_detection_tray_putin.xml
  41. 27 1
      app/src/main/res/layout/fragment_homepager.xml
  42. 2 2
      app/src/main/res/layout/item_card_intercept.xml
  43. 102 0
      app/src/main/res/layout/item_tray_make.xml
  44. 24 0
      app/src/main/res/layout/item_upload_await_number.xml
  45. 2 1
      baselibrary/build.gradle
  46. 6 2
      baselibrary/src/main/java/com/fxy/baselibrary/base/BaseActivity.java
  47. 1 1
      baselibrary/src/main/res/layout/pager_empty.xml
  48. 3 3
      config.gradle
  49. 1 1
      gradle/wrapper/gradle-wrapper.properties

+ 1 - 1
app/build.gradle

@@ -152,7 +152,7 @@ dependencies {
     testImplementation 'junit:junit:4.12'
     compile 'com.android.support:multidex:1.0.2'
     compile project(':baselibrary')
-
+    implementation 'com.aliyun.dpa:oss-android-sdk:2.9.13'
     implementation 'com.github.bingoogolapple.BGAQRCode-Android:zbar:1.3.8'
 
     // 自定义构建类型依赖

+ 54 - 2
app/src/main/AndroidManifest.xml

@@ -4,6 +4,7 @@
 
     <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"
                      tools:ignore="ProtectedPermissions"/>
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
     <uses-permission android:name="android.permission.BLUETOOTH"/>
     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
@@ -22,7 +23,6 @@
 
 
     <application
-        xmlns:tools="http://schemas.android.com/tools"
         tools:replace="label"
         android:name="com.fxy.base.StorageApplication"
         android:allowBackup="true"
@@ -200,12 +200,49 @@
             android:screenOrientation="portrait"
             tools:ignore="LockedOrientationActivity"/>
 
+
+
+        <activity
+            android:name=".detection.BoxPutInMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
+        <activity
+            android:name=".detection.BoxPutInDetailsMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
         <activity
-            android:name=".detection.DetectionPutInMainActivity"
+            android:name=".detection.TrayPutInMainActivity"
             android:windowSoftInputMode="stateHidden|adjustPan"
             android:screenOrientation="portrait"
             tools:ignore="LockedOrientationActivity"/>
 
+        <activity
+            android:name=".detection.TrayMakeMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
+        <activity
+            android:name=".detection.TrayMakeSecondMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
+
+
+        <activity
+            android:name=".detection.TrayMakeThirdMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
+
+        <activity
+            android:name=".detection.TrayMakeFourMainActivity"
+            android:windowSoftInputMode="stateHidden|adjustPan"
+            android:screenOrientation="portrait"
+            tools:ignore="LockedOrientationActivity"/>
+
+
         <activity
             android:name=".detection.DetectionPutawayMainActivity"
             android:windowSoftInputMode="stateHidden|adjustPan"
@@ -296,6 +333,21 @@
             android:windowSoftInputMode="stateHidden|adjustPan"
             android:screenOrientation="portrait"
             tools:ignore="LockedOrientationActivity"/>
+
+
+
+        <!--后台自动上传-->
+        <provider
+            android:name=".base.UploadContentProvider"
+            android:authorities="com.fxy.base.UploadContentProvider"
+            android:exported="false" />
+
+        <service
+            android:name=".service.UploadJobService"
+            android:exported="false"
+            android:permission="android.permission.BIND_JOB_SERVICE">
+            <!-- 如果需要其他属性,可以在这里添加 -->
+        </service>
     </application>
 
 

+ 5 - 0
app/src/main/java/com/fxy/adapter/GridImageAdapter.java

@@ -157,6 +157,11 @@ public class GridImageAdapter extends RecyclerView.Adapter<GridImageAdapter.View
     @Override
     public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
         //少于8张,显示继续添加的图标
+
+        if (position>=selectMax){
+            viewHolder.mImg.setVisibility(View.GONE);
+        }
+
         if (getItemViewType(position) == TYPE_CAMERA) {
             viewHolder.ll_del.setVisibility(View.INVISIBLE);
             if (pictureType==PictureConfig.TYPE_AUDIO){

+ 28 - 0
app/src/main/java/com/fxy/base/ChargeStateReceiver.java

@@ -0,0 +1,28 @@
+package com.fxy.base;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.BatteryManager;
+
+import com.fxy.utils.JobUtils;
+
+public class ChargeStateReceiver extends BroadcastReceiver {
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
+            int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+            boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
+                    status == BatteryManager.BATTERY_STATUS_FULL;
+
+            // 处理充电状态的变化
+            if (isCharging) {
+                // 设备正在充电
+                JobUtils.chargingJob(context);
+            } else {
+                // 设备不在充电
+            }
+        }
+    }
+}

+ 0 - 2
app/src/main/java/com/fxy/base/ServiceSettingActivity.java

@@ -346,8 +346,6 @@ public class ServiceSettingActivity extends BaseActivity {
 
                     Intent intent = new Intent();
                     setResult(200, intent);//返回值,2 是改返回的标志,也会返回
-                    finish();
-
                     finish();
                     break;
             }

+ 69 - 0
app/src/main/java/com/fxy/base/UploadAppCompat.java

@@ -0,0 +1,69 @@
+package com.fxy.base;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.ComponentName;
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+
+import com.fxy.service.UploadJobService;
+
+public class UploadAppCompat {
+    private Activity mActivity;
+    private JobScheduler mJobScheduler;
+    private SensorManager mSensorManager;
+    private SensorEventListener mSensorEventListener;
+    private long lastMotionTime = 0L;
+
+    public void startIdleDetection(Activity activity) {
+        mActivity = activity;
+        mSensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
+        mSensorEventListener = new SensorEventListener() {
+            @Override
+            public void onSensorChanged(SensorEvent event) {
+                // 检查传感器值的变化来判断设备是否空闲
+                float[] values = event.values;
+                long currentTime = System.currentTimeMillis();
+                if (values[0] != 0 || values[1] != 0 || values[2] != 0) {
+                    lastMotionTime = currentTime;
+                } else if (currentTime - lastMotionTime > 60 * 1000) {
+                    // 设备空闲 5 分钟后触发 job
+                    triggerJob(mActivity);
+                }
+            }
+
+            @Override
+            public void onAccuracyChanged(Sensor sensor, int accuracy) {
+                // 不需要实现
+            }
+        };
+
+        Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+        if (sensor != null) {
+            mSensorManager.registerListener(mSensorEventListener, sensor, SensorManager.SENSOR_DELAY_NORMAL);
+        }
+    }
+
+    public void stopIdleDetection() {
+        if (mSensorManager != null && mSensorEventListener != null) {
+            mSensorManager.unregisterListener(mSensorEventListener);
+        }
+    }
+
+    @SuppressLint("JobSchedulerService")
+    public void triggerJob(Activity activity) {
+        // 触发 job
+        JobScheduler jobScheduler = (JobScheduler) activity.getSystemService(Context.JOB_SCHEDULER_SERVICE);
+        ComponentName componentName = new ComponentName(activity, UploadJobService.class);
+        JobInfo jobInfo = new JobInfo.Builder(101, componentName)
+                .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
+                .setPersisted(true)
+                .build();
+        jobScheduler.schedule(jobInfo);
+    }
+}

+ 58 - 0
app/src/main/java/com/fxy/base/UploadContentProvider.java

@@ -0,0 +1,58 @@
+package com.fxy.base;
+
+import android.annotation.SuppressLint;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * 后台获取Content
+ */
+public class UploadContentProvider  extends ContentProvider {
+    private static Context context;
+
+    @Override
+    public boolean onCreate() {
+        context = getContext();
+        return true;
+    }
+
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+        // 实现查询逻辑
+        return null;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+        // 实现类型逻辑
+        return null;
+    }
+
+    @Override
+    public Uri insert(Uri uri, ContentValues values) {
+        // 实现插入逻辑
+        return null;
+    }
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+        // 实现删除逻辑
+        return 0;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+        // 实现更新逻辑
+        return 0;
+    }
+
+    public static Context getCurrentContext() {
+        return context;
+    }
+
+}

+ 351 - 0
app/src/main/java/com/fxy/common/AsyncFileUpload.java

@@ -0,0 +1,351 @@
+package com.fxy.common;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.os.Message;
+import android.widget.Toast;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.util.RxTimeTool;
+import com.fxy.bean.ActionBean;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.realm.AsyncUploadRealm;
+import com.luck.picture.lib.entity.LocalMedia;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.greenrobot.eventbus.EventBus;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+import io.realm.Realm;
+import io.realm.RealmResults;
+
+public class AsyncFileUpload {
+
+    private final Context mContext;
+     private String uploadType = "";
+    //文件上传类型
+    protected String fileKey = "";
+
+
+    protected Realm mRealm;
+    private List<AsyncUploadRealm> awaitUploadList=new ArrayList<>();
+
+
+
+
+    private OssService ossService;
+
+
+    private boolean allowUpload = true;
+
+
+
+    public AsyncFileUpload(Context context){
+        mContext = context;
+        initData();
+    }
+
+
+
+    private void initData() {
+        mRealm = Realm.getDefaultInstance();
+    }
+
+
+
+    public void setUploadType(String fileKey) {
+        this.fileKey = fileKey;
+    }
+
+
+
+
+
+    @SuppressLint("HandlerLeak")
+    private Handler uploadHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            HashMap<String,Object> hashMap = new HashMap<>();
+            hashMap.put("fileKey",fileKey);
+            boolean result = false;
+            try {
+
+                //XLog.e(msg);
+                int current = (Integer) msg.arg1;
+
+                switch (msg.what){
+                    case 0:
+                         break;
+                    case 1://失败
+
+                        if (awaitUploadList.size()>0){
+
+                            AsyncUploadRealm asyncUploadRealm = awaitUploadList.get(current);
+                            awaitUploadList.remove(current);
+                            resultUpload(asyncUploadRealm.getId(),0,"");
+                            hashMap.put("error",(String) msg.obj);
+                            hashMap.put("result","error");
+                            hashMap.put("realmId",asyncUploadRealm.getId());
+                        }
+
+                        break;
+                    case 2://成功
+                        result = true;
+                        //表示数据存在
+                        if (awaitUploadList.size()>0){
+                            AsyncUploadRealm asyncUploadRealm = awaitUploadList.get(current);
+                            awaitUploadList.remove(current);
+                            resultUpload(asyncUploadRealm.getId(),1,(String) msg.obj);
+                            hashMap.put("result","success");
+                            hashMap.put("realmId",asyncUploadRealm.getId());
+                        }
+                        break;
+                    case 3:
+                        //设置进度条
+                        EventBus.getDefault().post(new UploadProgressEvent(msg.arg2));
+
+                        hashMap.put("result","process");
+                        hashMap.put("process",(int)msg.arg2);
+                        if (awaitUploadList.get(current)!=null){
+                            hashMap.put("realmId",awaitUploadList.get(current).getId());
+                        }
+
+                        EventBus.getDefault().post(new BaseEventBusBean<>(EventCode.file_upload_progress_lister,hashMap));
+                        return;
+                        //progressDialog.show();
+                    case 4:
+                        //获取上传状态
+                        return;
+                    default:
+                        break;
+                }
+
+
+
+
+            } catch (Exception e) {
+                XLog.e(e.getMessage());
+                e.printStackTrace();
+                // 通过接口对象传上传状态
+                hashMap.put("error",e.getMessage());
+            }
+
+            hashMap.put("result",false);
+            EventBus.getDefault().post(new BaseEventBusBean<>(EventCode.file_upload_lister,hashMap));
+        }
+    };
+
+
+
+
+    // 调用回调方法
+    //uploadChangeListener.uploadResult(false);
+
+    public void filedUpload(int num){
+
+
+        // 例如 LocalMedia 里面返回三种path
+        // 1.media.getPath(); 为原图path
+        // 2.media.getCutPath();为裁剪后path,需判断media.isCut();是否为true
+        // 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true
+        // 如果裁剪并压缩了,以取压缩路径为准,因为是先裁剪后压缩的
+        LocalMedia localMedia = awaitUploadList.get(num).getLocalMedia();
+        String urlPath =localMedia.getPath();
+        if (localMedia.isCompressed() && localMedia.getCompressPath()!=null){
+            urlPath = localMedia.getCompressPath();
+        }
+
+        if (urlPath.isEmpty()){
+            Message msg = new Message();
+            msg.obj = "文件路径不存在";
+            msg.what = 1;
+            uploadHandler.sendMessage(msg);
+            return;
+        }
+
+
+        String fileName = "";
+        String path_prefix = "";
+
+        String ossUrl = awaitUploadList.get(num).getOssUrl();
+        fileKey = awaitUploadList.get(num).getNotifyKey();
+
+        //目录为空
+        if (ossUrl.isEmpty()){
+            resultUpload( awaitUploadList.get(num).getId(),0,"");
+            awaitUploadList.remove(num);
+            return;
+        }
+
+        // 找到最后一个斜杠的位置
+        int lastSlashIndex = ossUrl.lastIndexOf('/');
+        // 如果找到了斜杠,则从斜杠之后的位置开始切割
+        fileName = ossUrl.substring(lastSlashIndex + 1);
+        path_prefix = ossUrl.substring(0,lastSlashIndex+ 1);
+
+        if (ossService ==null){
+            ossService = new OssService(mContext,path_prefix);
+        }
+        ossService.ossUpload(urlPath, fileName , num,uploadHandler);
+        setIsFinish(awaitUploadList.get(num).getId(),1);
+    }
+
+
+
+    public int getAwaitNum(){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .equalTo("uploadType",uploadType)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+
+    public int getAwaitNum(String[] uploadTypeList){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .in("uploadType",uploadTypeList)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+
+    public int getAllAwaitNum(){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+
+    //存储数据问题
+    private void asyncUpload(){
+        if (awaitUploadList==null || awaitUploadList.size()==0){
+            Integer[] isFinish = {0,2};
+            RealmResults<AsyncUploadRealm> realmResults  = getBatchUploadRealm(isFinish);
+            if (realmResults.size()==0){
+                Integer[] isFinish2 = {0,1,2};
+                realmResults  = getBatchUploadRealm(isFinish2);
+            }
+            awaitUploadList.addAll(realmResults);
+        }
+
+        if (awaitUploadList.size()>0){
+            filedUpload(0);
+        }
+    }
+
+
+    //取消任务
+    public void taskCancel(){
+
+    }
+
+    public void setStartUpload(){
+        allowUpload = true;
+        asyncUpload();
+    }
+
+    public void setStopUpload(){
+        allowUpload = false;
+        if(ossService !=null){
+            ossService.taskCancel();
+        }
+        EventBus.getDefault().post(new UploadProgressEvent(0));
+    }
+
+    /**
+     * 设置是否完成
+     * @param realmId String
+     * @param  isFinish Integer
+     */
+    private void setIsFinish(String realmId,Integer isFinish){
+        //更新值
+        mRealm.beginTransaction();
+        AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",realmId).findFirst();
+        assert myObject != null;
+        myObject.setIsFinish(isFinish);
+        mRealm.commitTransaction();
+    }
+
+    private RealmResults<AsyncUploadRealm> getBatchUploadRealm(Integer[] isFinish){
+        //更新值
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .in("isFinish",isFinish)
+//                    .equalTo("notifyKey",fileKey)
+//                    .equalTo("uploadType",uploadType)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return realmResults;
+    }
+
+
+    /**
+     * 上传结果
+     * @param tmpRealmId String
+     * @param status Integer
+     * @param photoPath String
+     */
+    private void resultUpload(String tmpRealmId,Integer status,String photoPath){
+        if (tmpRealmId!=null && !tmpRealmId.isEmpty()){
+            int rePush = 0;
+            //遍历删除
+            if (awaitUploadList.size()>0){
+                for (int i=0;i<awaitUploadList.size();i++){
+                    if (awaitUploadList.get(i).getId().equals(tmpRealmId)){
+                        rePush = awaitUploadList.get(i).getRePush();
+                        awaitUploadList.remove(i);
+                        break;
+                    }
+                }
+            }
+
+            int pushStatus = 2;
+            if (status==0){
+                pushStatus = rePush>4 ? 1 : 0;
+            }
+            //更新值
+            mRealm.beginTransaction();
+            AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",tmpRealmId).findFirst();
+            assert myObject != null;
+            myObject.setPushStatus(pushStatus);
+            myObject.setIsFinish( pushStatus == 1 ? 3 : 2);
+            myObject.setOssUrl(photoPath);
+            mRealm.commitTransaction();
+
+        }
+
+        //可以允许上传
+        if (allowUpload){
+            //上传完,继续执行
+            asyncUpload();
+        }
+
+    }
+
+    //销毁
+    public void removeHandler(){
+        if (uploadHandler!=null){
+            uploadHandler.removeCallbacksAndMessages(null);
+        }
+    }
+}

+ 515 - 0
app/src/main/java/com/fxy/common/AsyncPictureSelector.java

@@ -0,0 +1,515 @@
+package com.fxy.common;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.bluetooth.BluetoothSocket;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.adapter.GridImageAdapter;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.util.DateUtil;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.util.RxTimeTool;
+import com.fxy.bean.ActionBean;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.realm.AsyncUploadRealm;
+import com.fxy.view.FullyGridLayoutManager;
+import com.google.gson.Gson;
+import com.luck.picture.lib.PictureSelector;
+import com.luck.picture.lib.config.PictureConfig;
+import com.luck.picture.lib.config.PictureMimeType;
+import com.luck.picture.lib.entity.LocalMedia;
+import com.luck.picture.lib.permissions.Permission;
+import com.luck.picture.lib.permissions.RxPermissions;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.greenrobot.eventbus.EventBus;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+import io.reactivex.functions.Consumer;
+import io.realm.Realm;
+import io.realm.RealmResults;
+
+public class AsyncPictureSelector {
+    private final Activity mActivity;
+    private final Context mContext;
+    private int maxSelectNum = 9;
+    private GridImageAdapter adapter;
+    private final RecyclerView mRecyclerView;
+    private PopupWindow pop;
+
+    private boolean onlyCamera = false;
+    private boolean isCompress = false;
+    private int compressQuality = 100;//默认值
+    private int minimumCompressSize = 100;//最小压缩
+
+
+    //资源类型
+    private int pictureType=1;
+
+
+
+    private String uploadType = "";
+    //文件上传类型
+    protected String fileKey = "";
+
+    //通知地址
+    private String notifyUrl = "";
+
+    //唯一标识
+    private String uniqueTag = "";
+
+    //通知地址
+    private HashMap<String, Object> notifyParam  = new HashMap<>();
+
+
+    private HashMap<String, Object> limitOperate  = new HashMap<>();
+
+    protected Realm mRealm;
+
+
+    //
+    private List<LocalMedia> selectList = new ArrayList<>();
+    //上传图片路径
+    private ArrayList<String> ossPhotoList =new ArrayList<>();
+
+    private String mPrefix="tally";
+
+
+    private String resourcePrefix = "/fxy";
+
+
+    //是自动上传
+    private boolean isAutoUpload = true;
+
+    private boolean allowUpload = false;
+
+
+    public AsyncPictureSelector(Activity activity, RecyclerView rvShowImg, String prefix, String fileKey, String notifyUrl, boolean isAutoUpload){
+
+        mActivity = activity;
+        mContext  = activity.getBaseContext();
+        mRecyclerView = rvShowImg;
+        this.fileKey = fileKey;
+        this.mPrefix = prefix;
+        this.notifyUrl = notifyUrl;
+        this.isAutoUpload = isAutoUpload;
+
+        //自动上传则允许继续上次
+        this.allowUpload  = isAutoUpload;
+        initAdapter();
+        initData();
+    }
+
+
+
+    private void initData() {
+        SPCache spCache = SPCache.getInstance(mContext);
+        resourcePrefix = spCache.getResourcePrefix();
+        mRealm = Realm.getDefaultInstance();
+        uploadType = mActivity.getClass().getSimpleName();
+        limitOperate = new HashMap<>();
+        uniqueTag =  this.fileKey+UUID.randomUUID().toString();
+    }
+
+    public void setCompress(Boolean isCompress) {
+        this.isCompress = isCompress;
+    }
+    public void setCompress(Boolean isCompress,int compressQuality,int minimumCompressSize) {
+        this.isCompress = isCompress;
+        this.compressQuality = compressQuality;
+        this.minimumCompressSize = minimumCompressSize;
+    }
+
+
+    public void setUploadType(String fileKey) {
+        this.fileKey = fileKey;
+    }
+
+    public void setPictureType(int pictureType){
+        this.pictureType = pictureType;
+    }
+
+    public void setOnlyCamera(boolean onlyCamera){
+        this.onlyCamera = onlyCamera;
+    }
+
+    public void  setMaxSelectNum(int num){
+        this.maxSelectNum = num;
+        adapter.setSelectMax(maxSelectNum);
+    }
+
+    public void  setNotifyParam( HashMap<String, Object> map){
+        this.notifyParam = map;
+    }
+
+    //操作限制
+    public void setLimitOperate(HashMap<String, Object> map){
+        this.limitOperate = map;
+    }
+
+    /**
+     * 设置操作类型
+     * @return
+     */
+    public String getUploadType() {
+       return fileKey;
+    }
+
+
+
+
+    public List<LocalMedia> getSelectList (){
+        return  selectList;
+    }
+
+
+    public List<String> getOssPhotoList (){
+        return  ossPhotoList;
+    }
+
+
+
+    public void emptyRemake(){
+        selectList.clear();
+        ossPhotoList.clear();
+        adapter.clearData();
+        uniqueTag =  this.fileKey+UUID.randomUUID().toString();
+    }
+
+
+    /**
+     * 获取选中图片
+     * @param data
+     */
+    public void getSelectImg (Intent data){
+        List<LocalMedia>  fileList = PictureSelector.obtainMultipleResult(data);
+        for (int i = 0; i < fileList.size(); i++) {
+            addUploadFile(fileList.get(i));
+            selectList.add(fileList.get(i));
+        }
+
+        adapter.setList(selectList);
+        adapter.notifyDataSetChanged();
+
+
+
+    }
+
+    public String getUniqueTag(){
+        return  this.uniqueTag;
+    }
+
+
+
+
+
+
+
+
+    private void initAdapter() {
+        FullyGridLayoutManager manager = new FullyGridLayoutManager(mActivity, 3, GridLayoutManager.VERTICAL, false);
+        mRecyclerView.setLayoutManager(manager);
+        adapter = new GridImageAdapter(mActivity,mActivity, onAddPicClickListener,pictureType);
+        adapter.setList(selectList);
+        adapter.setSelectMax(maxSelectNum);
+        mRecyclerView.setAdapter(adapter);
+        adapter.setOnItemClickListener(new GridImageAdapter.OnItemClickListener() {
+            @Override
+            public void onItemClick(int position, View v) {
+                if (selectList.size() > 0) {
+                    LocalMedia media = selectList.get(position);
+                    String pictureType = media.getPictureType();
+                    int mediaType = PictureMimeType.pictureToVideo(pictureType);
+                    switch (mediaType) {
+                        case 1:
+                            // 预览图片 可自定长按保存路径
+                            //PictureSelector.create(MainActivity.this).externalPicturePreview(position, "/custom_file", selectList);
+                            PictureSelector.create(mActivity).externalPicturePreview(position, selectList);
+                            break;
+                        case 2:
+                            // 预览视频
+                            PictureSelector.create(mActivity).externalPictureVideo(media.getPath());
+                            break;
+                        case 3:
+                            // 预览音频
+                            PictureSelector.create(mActivity).externalPictureAudio(media.getPath());
+                            break;
+                    }
+                }
+            }
+        });
+
+        //回调语音
+        adapter.setOnAudioListener(new GridImageAdapter.OnAudioListener() {
+            @Override
+            public void onSaveResult(Intent data) {
+                getSelectImg(data);
+            }
+        });
+    }
+
+
+
+    public GridImageAdapter.onAddPicClickListener onAddPicClickListener = new GridImageAdapter.onAddPicClickListener() {
+
+        @SuppressLint("CheckResult")
+        @Override
+        public void onAddPicClick() {
+            //获取写的权限
+            RxPermissions rxPermission = new RxPermissions(mActivity);
+            rxPermission.requestEach(Manifest.permission.WRITE_EXTERNAL_STORAGE)
+                    .subscribe(new Consumer<Permission>() {
+                        @Override
+                        public void accept(Permission permission) {
+                            if (permission.granted) {// 用户已经同意该权限
+                                //第一种方式,弹出选择和拍照的dialog
+
+                                if (limitOperate.containsKey("disabled")){
+                                    String message = "暂时无法拍照";
+
+                                    if(limitOperate.containsKey("error")){
+                                        message = limitOperate.get("error").toString();
+                                    }
+                                    Toast.makeText(mActivity, message, Toast.LENGTH_SHORT).show();
+                                    return;
+                                }
+
+                                if (pictureType==PictureConfig.TYPE_AUDIO){
+                                    authAudio();
+                                }else {
+                                    if (onlyCamera){
+                                        //第二种方式,直接进入相册,但是 是有拍照得按钮的
+                                        authCamera();
+                                    }else{
+                                        showPop();
+                                    }
+                                }
+
+
+
+                            } else {
+                                Toast.makeText(mContext, "拒绝", Toast.LENGTH_SHORT).show();
+                            }
+                        }
+                    });
+
+
+
+        }
+    };
+
+    private void showAlbum() {
+        //参数很多,根据需要添加
+        PictureSelector.create(mActivity)
+                .openGallery(PictureMimeType.ofImage())// 全部.PictureMimeType.ofAll()、图片.ofImage()、视频.ofVideo()、音频.ofAudio()
+                .maxSelectNum(maxSelectNum)// 最大图片选择数量
+                .minSelectNum(1)// 最小选择数量
+                .imageSpanCount(4)// 每行显示个数
+                .selectionMode(PictureConfig.MULTIPLE)// 多选 or 单选PictureConfig.MULTIPLE : PictureConfig.SINGLE
+                .previewImage(true)// 是否可预览图片
+                .isCamera(true)// 是否显示拍照按钮
+                .isZoomAnim(true)// 图片列表点击 缩放效果 默认true
+                //.setOutputCameraPath("/CustomPath")// 自定义拍照保存路径
+                .enableCrop(true)// 是否裁剪
+                .compress(true)// 是否压缩
+                //.sizeMultiplier(0.5f)// glide 加载图片大小 0~1之间 如设置 .glideOverride()无效
+                .glideOverride(160, 160)// glide 加载宽高,越小图片列表越流畅,但会影响列表图片浏览的清晰度
+                .withAspectRatio(1, 1)// 裁剪比例 如16:9 3:2 3:4 1:1 可自定义
+                //.selectionMedia(selectList)// 是否传入已选图片
+                //.previewEggs(false)// 预览图片时 是否增强左右滑动图片体验(图片滑动一半即可看到上一张是否选中)
+                //.cropCompressQuality(90)// 裁剪压缩质量 默认100
+                //.compressMaxKB()//压缩最大值kb compressGrade()为Luban.CUSTOM_GEAR有效
+                //.compressWH() // 压缩宽高比 compressGrade()为Luban.CUSTOM_GEAR有效
+                //.cropWH()// 裁剪宽高比,设置如果大于图片本身宽高则无效
+                .rotateEnabled(false) // 裁剪是否可旋转图片
+                //.scaleEnabled()// 裁剪是否可放大缩小图片
+                //.recordVideoSecond()//录制视频秒数 默认60s
+                .forResult(PictureConfig.CHOOSE_REQUEST);//结果回调onActivityResult code
+    }
+
+    private void showPop() {
+        View bottomView = View.inflate(mContext, R.layout.layout_bottom_dialog, null);
+        TextView mAlbum = bottomView.findViewById(R.id.tv_album);
+        TextView mCamera = bottomView.findViewById(R.id.tv_camera);
+        TextView mCancel = bottomView.findViewById(R.id.tv_cancel);
+
+        pop = new PopupWindow(bottomView, -1, -2);
+        pop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+        pop.setOutsideTouchable(true);
+        pop.setFocusable(true);
+        WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
+        lp.alpha = 0.5f;
+        mActivity.getWindow().setAttributes(lp);
+        pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
+
+            @Override
+            public void onDismiss() {
+                WindowManager.LayoutParams lp = mActivity.getWindow().getAttributes();
+                lp.alpha = 1f;
+                mActivity.getWindow().setAttributes(lp);
+            }
+        });
+        pop.setAnimationStyle(R.style.main_menu_photo_anim);
+        pop.showAtLocation(mActivity.getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
+
+        View.OnClickListener clickListener = new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                switch (view.getId()) {
+                    case R.id.tv_album:
+                        //相册
+                        PictureSelector.create(mActivity)
+                                .openGallery(PictureMimeType.ofImage())
+                                .maxSelectNum(maxSelectNum)
+                                .minSelectNum(1)
+                                .imageSpanCount(4)
+                                .selectionMode(PictureConfig.MULTIPLE)
+                                .compress(isCompress) // 压缩
+                                .cropCompressQuality(compressQuality)// 裁剪压缩质量 默认100
+                                .minimumCompressSize(minimumCompressSize) //最新压缩图片
+
+                                .forResult(PictureConfig.CHOOSE_REQUEST);
+                        break;
+                    case R.id.tv_camera:
+                        //拍照
+                        PictureSelector.create(mActivity)
+                                .openCamera(PictureMimeType.ofImage())
+                                //只需要拍照
+                                //.selectionMode(PictureConfig.SINGLE)
+                                //.isCamera(true)
+                                .compress(isCompress) // 压缩
+                                .cropCompressQuality(compressQuality)// 裁剪压缩质量 默认100
+                                .minimumCompressSize(minimumCompressSize) //最新压缩图片
+                                .forResult(PictureConfig.CHOOSE_REQUEST);
+
+                        break;
+                    case R.id.tv_cancel:
+                        //取消
+                        //closePopupWindow();
+
+                        break;
+                }
+                closePopupWindow();
+            }
+        };
+
+        mAlbum.setOnClickListener(clickListener);
+        mCamera.setOnClickListener(clickListener);
+        mCancel.setOnClickListener(clickListener);
+
+
+    }
+
+    /**
+     * 外部直接调取拍照接口
+     */
+    public void authCamera(){
+        //拍照
+        PictureSelector.create(mActivity)
+                .openCamera(PictureMimeType.ofImage())
+                //只需要拍照
+                //.selectionMode(PictureConfig.SINGLE)
+                //.isCamera(true)
+                //.compressMaxKB()//压缩最大值kb compressGrade()为Luban.CUSTOM_GEAR有效
+                .compress(isCompress) // 压缩
+                .cropCompressQuality(compressQuality)// 裁剪压缩质量 默认100
+                .minimumCompressSize(minimumCompressSize) //最新压缩图片
+                .forResult(PictureConfig.CHOOSE_REQUEST);
+
+        //监听返回当前某个上传类型
+        EventBus.getDefault().post(new BaseEventBusBean<String>(EventCode.picture_selector_lister,fileKey));
+    }
+
+    /**
+     * 自动打开录音
+     */
+    public void authAudio(){
+        // 自带音频
+        PictureSelector.create(mActivity)
+                .openCamera(PictureMimeType.ofAudio())
+                //只需要音频
+                .selectionMode(PictureConfig.TYPE_AUDIO)
+                .compress(isCompress) // 压缩
+                .forResult(PictureConfig.CHOOSE_REQUEST);
+
+
+
+        //监听返回当前某个上传类型
+        EventBus.getDefault().post(new BaseEventBusBean<String>(EventCode.picture_selector_lister,fileKey));
+    }
+
+
+    /**
+     * 关闭弹窗
+     */
+    public void closePopupWindow() {
+        if (pop != null && pop.isShowing()) {
+            pop.dismiss();
+            pop = null;
+        }
+    }
+
+
+
+    private void addUploadFile(LocalMedia localMedia){
+        String realmId = UUID.randomUUID().toString();
+        String scan_date = DateUtil.getCurDateStr(DateUtil.FORMAT_YMDHMS);
+        //同步操作写法一:
+        mRealm.beginTransaction();
+        //会创建对象和user表
+        AsyncUploadRealm takePhotosRealm = mRealm.createObject(AsyncUploadRealm.class,realmId);
+        Gson gson = new Gson();
+        String localMediaStr = gson.toJson(localMedia);
+        takePhotosRealm.setLocalMediaStr(localMediaStr);
+        takePhotosRealm.setOssUrl("");
+        takePhotosRealm.setScanDate(scan_date);
+        takePhotosRealm.setUploadType(uploadType);
+        takePhotosRealm.setNotifyKey(fileKey);
+        takePhotosRealm.setNotifyParam(gson.toJson(notifyParam));
+        takePhotosRealm.setNotifyUrl(notifyUrl);
+        takePhotosRealm.setUniqueTag(uniqueTag);
+
+
+        String path_prefix = resourcePrefix+"/android/"+mPrefix+"/"+RxTimeTool.getYestoryDate("yyyyMMd")+"/";
+        String urlPath = isCompress && localMedia.getCompressPath()!=null ? localMedia.getCompressPath() :  localMedia.getPath();
+        String fileSuffix = urlPath.lastIndexOf(".")>-1 ? urlPath.substring(urlPath.lastIndexOf(".")) : "";
+        String fileName = UUID.randomUUID().toString() + fileSuffix;
+        takePhotosRealm.setOssUrl(path_prefix+fileName);
+        ossPhotoList.add("/"+path_prefix+fileName);
+        //
+
+        Date date = new Date();
+        takePhotosRealm.setCreateTime(date.getTime());
+        takePhotosRealm.setPushStatus(0);
+        //提交事务,操作就被执行
+        mRealm.commitTransaction();
+    }
+}

+ 502 - 0
app/src/main/java/com/fxy/common/AsyncPictureUpload.java

@@ -0,0 +1,502 @@
+package com.fxy.common;
+
+import android.Manifest;
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Handler;
+import android.os.Message;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.Gravity;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.PopupWindow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.adapter.GridImageAdapter;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.util.DateUtil;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.util.RxTimeTool;
+import com.fxy.bean.ActionBean;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.realm.AsyncUploadRealm;
+import com.fxy.view.FullyGridLayoutManager;
+import com.google.gson.Gson;
+import com.luck.picture.lib.PictureSelector;
+import com.luck.picture.lib.config.PictureConfig;
+import com.luck.picture.lib.config.PictureMimeType;
+import com.luck.picture.lib.entity.LocalMedia;
+import com.luck.picture.lib.permissions.Permission;
+import com.luck.picture.lib.permissions.RxPermissions;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.greenrobot.eventbus.EventBus;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+import io.reactivex.functions.Consumer;
+import io.realm.Realm;
+import io.realm.RealmResults;
+
+public class AsyncPictureUpload {
+    private final Activity mActivity;
+    private final Context mContext;
+
+
+    private String uploadType = "";
+    //文件上传类型
+    protected String fileKey = "";
+
+    //通知地址
+    private String notifyUrl = "";
+
+    //唯一标识
+    private String uniqueTag = "";
+
+    //通知地址
+    private HashMap<String, Object> notifyParam  = new HashMap<>();
+
+
+    private HashMap<String, Object> limitOperate  = new HashMap<>();
+
+    protected Realm mRealm;
+    private List<AsyncUploadRealm> awaitUploadList=new ArrayList<>();
+
+
+    //
+    private List<LocalMedia> selectList = new ArrayList<>();
+    //上传图片路径
+    private ArrayList<String> ossPhotoList =new ArrayList<>();
+
+    private String mPrefix="tally";
+
+    //是否停止上传
+    private String resourceUrl = "";
+
+    private String resourceType = "";
+
+    private String resourcePrefix = "/fxy";
+
+    private OssService ossService;
+
+    private CosService cosService;
+
+    private boolean allowUpload = true;
+
+
+
+    public AsyncPictureUpload(Activity activity){
+        mActivity = activity;
+        mContext  = activity.getBaseContext();
+        initData();
+    }
+
+
+
+    private void initData() {
+        SPCache spCache = SPCache.getInstance(mContext);
+        resourceUrl    = spCache.getResourceHost()+"/";
+        resourceType   = spCache.getResourceType();
+        resourcePrefix = spCache.getResourcePrefix();
+        mRealm = Realm.getDefaultInstance();
+        uploadType = mActivity.getClass().getSimpleName();
+        limitOperate = new HashMap<>();
+        uniqueTag =  this.fileKey+UUID.randomUUID().toString();
+    }
+
+
+
+    public void setUploadType(String fileKey) {
+        this.fileKey = fileKey;
+    }
+
+
+
+    public void  setNotifyParam( HashMap<String, Object> map){
+        this.notifyParam = map;
+    }
+
+    //操作限制
+    public void setLimitOperate(HashMap<String, Object> map){
+        this.limitOperate = map;
+    }
+
+
+
+    public int getAwaitNum(){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .equalTo("uploadType",uploadType)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+    public int getAwaitNum(String[] uploadTypeList){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .in("uploadType",uploadTypeList)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+
+
+
+
+    @SuppressLint("HandlerLeak")
+    private Handler uploadHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            HashMap<String,Object> hashMap = new HashMap<>();
+            hashMap.put("fileKey",fileKey);
+
+             try {
+
+                //XLog.e(msg);
+                int current = (Integer) msg.arg1;
+
+                switch (msg.what){
+                    case 0:
+                        Toast.makeText(mActivity, "error", Toast.LENGTH_SHORT).show();
+                        break;
+                    case 1://失败
+
+                        if (awaitUploadList.size()>0){
+
+                            AsyncUploadRealm asyncUploadRealm = awaitUploadList.get(current);
+                            awaitUploadList.remove(current);
+                            resultUpload(asyncUploadRealm.getId(),0,"");
+                            String message = (String) msg.obj;
+                            if (!message.isEmpty() && mActivity!=null){
+                                Toast.makeText(mActivity, message, Toast.LENGTH_SHORT).show();
+                            }
+                            hashMap.put("error",(String) msg.obj);
+                            hashMap.put("result","error");
+                            hashMap.put("realmId",asyncUploadRealm.getId());
+                        }
+
+                        break;
+                    case 2://成功
+                         //表示数据存在
+                        if (awaitUploadList.size()>0){
+                            AsyncUploadRealm asyncUploadRealm = awaitUploadList.get(current);
+                            awaitUploadList.remove(current);
+                            resultUpload(asyncUploadRealm.getId(),1,(String) msg.obj);
+                            hashMap.put("result","success");
+                            hashMap.put("realmId",asyncUploadRealm.getId());
+                        }
+                        break;
+                    case 3:
+                        //设置进度条
+                        hashMap.put("result","process");
+                        hashMap.put("process",(int)msg.arg2);
+                        if (awaitUploadList.get(current)!=null){
+                            hashMap.put("realmId",awaitUploadList.get(current).getId());
+                        }
+
+                        EventBus.getDefault().post(new BaseEventBusBean<>(EventCode.file_upload_progress_lister,hashMap));
+                        return;
+                    case 4:
+                        //获取上传状态
+                        return;
+                    default:
+                        break;
+                }
+
+
+
+
+            } catch (Exception e) {
+                XLog.e(e.getMessage());
+                e.printStackTrace();
+                // 通过接口对象传上传状态
+                hashMap.put("error",e.getMessage());
+            }
+
+             EventBus.getDefault().post(new BaseEventBusBean<>(EventCode.file_upload_lister,hashMap));
+        }
+    };
+
+
+
+
+    // 调用回调方法
+    //uploadChangeListener.uploadResult(false);
+
+    public void filedUpload(int num){
+
+
+        // 例如 LocalMedia 里面返回三种path
+        // 1.media.getPath(); 为原图path
+        // 2.media.getCutPath();为裁剪后path,需判断media.isCut();是否为true
+        // 3.media.getCompressPath();为压缩后path,需判断media.isCompressed();是否为true
+        // 如果裁剪并压缩了,以取压缩路径为准,因为是先裁剪后压缩的
+        LocalMedia localMedia = awaitUploadList.get(num).getLocalMedia();
+        String urlPath =localMedia.getPath();
+        if (localMedia.isCompressed() && localMedia.getCompressPath()!=null){
+            urlPath = localMedia.getCompressPath();
+        }
+
+        if (urlPath.isEmpty()){
+            Message msg = new Message();
+            msg.obj = "文件路径不存在";
+            msg.what = 1;
+            uploadHandler.sendMessage(msg);
+            return;
+        }
+
+
+        String fileName = "";
+        String path_prefix = "";
+
+        String ossUrl = awaitUploadList.get(num).getOssUrl();
+        fileKey = awaitUploadList.get(num).getNotifyKey();
+        if (!ossUrl.isEmpty()){
+            // 找到最后一个斜杠的位置
+            int lastSlashIndex = ossUrl.lastIndexOf('/');
+            // 如果找到了斜杠,则从斜杠之后的位置开始切割
+            fileName = ossUrl.substring(lastSlashIndex + 1);
+            path_prefix = ossUrl.substring(0,lastSlashIndex+ 1);
+
+        }else{
+            path_prefix = resourcePrefix+"/android/"+mPrefix+"/"+RxTimeTool.getYestoryDate("yyyyMMd")+"/";
+            String fileSuffix = urlPath.lastIndexOf(".")>-1 ? urlPath.substring(urlPath.lastIndexOf(".")) : "";
+            fileName = UUID.randomUUID().toString() + fileSuffix;
+        }
+
+
+        if (resourceType.equals("tencent")){
+            if (cosService==null){
+                cosService  = new CosService(mActivity.getBaseContext(),path_prefix);
+            }
+            //new cosThread(urlPath, fileName , num).start();
+            cosService.cosUpload(urlPath, fileName , num,uploadHandler);
+
+        }else{
+            if (ossService ==null){
+                ossService = new OssService(mActivity,path_prefix);
+
+            }
+
+
+            ossService.ossUpload(urlPath, fileName , num,uploadHandler);
+            //new ossThread(urlPath, fileName , num).start();
+        }
+        // task.cancel(); // 可以取消任务
+        // task.waitUntilFinished(); // 可以等待直到任务完成
+    }
+
+
+
+
+
+
+
+    //存储数据问题
+    private void asyncUpload(){
+
+        if (!getIsNetwork()){
+            //无网络时在请求检查是否有网络
+            return;
+        }
+
+        if (awaitUploadList==null || awaitUploadList.size()==0){
+            Integer[] isFinish = {0,2};
+            RealmResults<AsyncUploadRealm> realmResults  = getBatchUploadRealm();
+            awaitUploadList.addAll(realmResults);
+        }
+
+        if (awaitUploadList.size()>0){
+            filedUpload(0);
+        }
+    }
+
+    //取消任务
+    public void taskCancel(){
+
+    }
+
+    public void setStartUpload(){
+        allowUpload = true;
+        asyncUpload();
+    }
+
+    public void setStopUpload(){
+        allowUpload = false;
+        if(ossService !=null){
+            ossService.taskCancel();
+        }
+        EventBus.getDefault().post(new UploadProgressEvent(0));
+    }
+
+    /**
+     * 设置是否完成
+     * @param realmId String
+     * @param  isFinish Integer
+     */
+    private void setIsFinish(String realmId,Integer isFinish){
+        //更新值
+        mRealm.beginTransaction();
+        AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",realmId).findFirst();
+        assert myObject != null;
+        myObject.setIsFinish(isFinish);
+        mRealm.commitTransaction();
+    }
+
+
+    private RealmResults<AsyncUploadRealm> getBatchUploadRealm(){
+        //更新值
+        mRealm.beginTransaction();
+        Integer[] isFinish = {0,2};
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .in("isFinish",isFinish)
+//                    .equalTo("notifyKey",fileKey)
+//                    .equalTo("uploadType",uploadType)
+                .sort("pushStatus").findAll();
+        // 遍历结果并修改
+        for (AsyncUploadRealm item : realmResults) {
+            item.setIsFinish(1);
+        }
+        realmResults.load();
+        mRealm.commitTransaction();
+        return realmResults;
+    }
+
+
+
+    /**
+     * 上传结果
+     * @param tmpRealmId String
+     * @param status Integer
+     * @param photoPath String
+     */
+    private void resultUpload(String tmpRealmId,Integer status,String photoPath){
+        if (tmpRealmId!=null && !tmpRealmId.isEmpty()){
+            int rePush = 0;
+            //遍历删除
+            if (awaitUploadList.size()>0){
+                for (int i=0;i<awaitUploadList.size();i++){
+                    if (awaitUploadList.get(i).getId().equals(tmpRealmId)){
+                        rePush = awaitUploadList.get(i).getRePush();
+                        awaitUploadList.remove(i);
+                        break;
+                    }
+                }
+            }
+
+            int pushStatus = 2;
+            if (status==0){
+                pushStatus = rePush>4 ? 1 : 0;
+            }
+            //更新值
+            mRealm.beginTransaction();
+            AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",tmpRealmId).findFirst();
+            assert myObject != null;
+            myObject.setPushStatus(pushStatus);
+            myObject.setIsFinish( pushStatus == 1 ? 3 : 2);
+            myObject.setOssUrl(photoPath);
+            mRealm.commitTransaction();
+
+        }
+
+        //可以允许上传
+        if (allowUpload){
+            //上传完,继续执行
+            asyncUpload();
+        }
+
+    }
+
+    //异步通知结果
+    private void  asyncNotify(AsyncUploadRealm myObject){
+        try {
+            JSONObject jsonObject = new JSONObject(myObject.getNotifyParam());
+            jsonObject.put(myObject.getNotifyKey(),myObject.getOssUrl());
+            jsonObject.put("realm_id",myObject.getId());
+            jsonObject.put("unique_tag",myObject.getUniqueTag());
+            final String tmpRealmId1 = myObject.getId();
+            OkGo.<String>post(myObject.getNotifyUrl()).upJson(jsonObject)
+                    .execute(new MyDialogCallback(mContext, true, false) {
+                        @Override
+                        public void onSuccess(Response<String> response) {
+                            super.onSuccess(response);
+                            try {
+                                ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                                if(bean.code == 1){
+                                    setIsFinish(tmpRealmId1,3);
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                                XLog.e("回传图片地址错误",e.getMessage());
+                                setIsFinish(tmpRealmId1,2);
+                            }
+                        }
+                    });
+        } catch (Exception e) {
+            e.printStackTrace();
+            XLog.e("异步通知"+e.getMessage());
+
+        }
+    }
+
+    /**
+     * 获取当前网络
+     * @return Boolean
+     */
+    private Boolean getIsNetwork(){
+        boolean isNetwork = false;
+
+        try {
+            if (mActivity==null){
+                return  isNetwork;
+            }
+
+            ConnectivityManager connectivityManager = (ConnectivityManager) mActivity.getSystemService(Context.CONNECTIVITY_SERVICE);
+            if (connectivityManager == null) {
+                XLog.d( "无法获取ConnectivityManager实例");
+                return  isNetwork;
+            }
+            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+            if (networkInfo != null) {
+                XLog.d( "当前网络状态:" + networkInfo.getState());
+                isNetwork = true;
+            } else {
+                XLog.d( "当前无网络连接");
+                isNetwork = false;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return  isNetwork;
+    }
+
+    //销毁
+    public void removeHandler(){
+        if (uploadHandler!=null){
+            uploadHandler.removeCallbacksAndMessages(null);
+        }
+    }
+}

+ 9 - 1
app/src/main/java/com/fxy/common/CommonDialog.java

@@ -96,11 +96,14 @@ public class CommonDialog extends Dialog implements View.OnClickListener{
         return this;
     }
 
+    public void setContentLabel(String prefix){
+        tvContentLabel.setText(prefix);
+    }
+
     public CommonDialog setTypeCode(String typeCode){
         this.typeCode = typeCode;
         if (tvContentLabel!=null){
             if (typeCode.equals("need_customer")){
-                tvContentLabel.setText("FX");
                 tvContentLabel.setVisibility(View.VISIBLE);
             }else{
                 tvContentLabel.setVisibility(View.GONE);
@@ -247,6 +250,11 @@ public class CommonDialog extends Dialog implements View.OnClickListener{
                 break;
         }
     }
+
+    public void show(){
+        super.show();
+        contentTxt.setSelection(contentTxt.getText().length());
+    }
     public interface OnCloseListener{
         void onClickCancel(Dialog dialog, boolean confirm);
         void onClickSubmit(Dialog dialog, boolean confirm);

+ 10 - 85
app/src/main/java/com/fxy/constant/EventCode.java

@@ -1,116 +1,41 @@
 package com.fxy.constant;
 
-/**
- * 项目名称:FingerStorage
- * 类描述:EventBus通讯标志
- * 创建人:admin
- * 创建时间:2018/3/14 16:58
- * 修改人:COMP-021-2006
- * 修改时间:2018/3/14 16:58
- * 修改备注:
- */
-
 public final class EventCode {
     /**
      * 刷新蓝牙监听
      */
     public static final int refresh_blue_lister = 0x1;
-    /**
-     * 未完成任务刷新
-     */
-    public static final int taskToRefresh = 0x2;
-    /**
-     * 已完成任务刷新
-     */
-    public static final int taskCompleteRefresh = 0x3;
 
     /**
-     * 完成单项货物信息的添加
+     * 图片选择
      */
-    public static final int taskToTransmissionGoodsDetails = 0x4;
+    public static final int picture_selector_lister = 0x2;
 
-    /**
-     * 更新显示的商户信息
-     */
-    public static final int taskToTransmissionBusinessInfomation = 0x5;
-    /**
-     * 更新显示的商品名称信息
-     */
-    public static final int taskToTransmissionGoodsNameInfomation = 0x6;
 
     /**
-     * 完成更新按箱收货的单货信息
+     * 声音选择
      */
-    public static final int taskToTransmissionGoodsBarInfomation = 0x7;
+    public static final int voice_selector_lister = 0x3;
 
     /**
-     * 完成更新按箱收货的单箱信息
+     * 视频选择
      */
-    public static final int taskToTransmissionGoodsBarOfBoxInfomation = 0x8;
+    public static final int video_selector_lister = 0x4;
 
     /**
-     * 完成更新上架的货品信息
+     * 文件上传
      */
-    public static final int taskToTransmissionUpperShelf = 0x9;
+    public static final int file_upload_lister = 0x5;
 
     /**
-     * 拣货任务的拣货item
+     * 文件上传
      */
-    public static final int pickCargoItemBean = 0x101;
-    /**
-     * 装箱任务的装箱item
-     */
-    public static final int binningBoxItemBean = 0x102;
-/**
-     * 装箱任务的装箱item里的货物item
-     */
-    public static final int binningBoxCargoItemBean = 0x103;
-    /**
-     * 码盘任务的码盘列表
-     */
-    public static final int trayBoxItemBean = 0x104;
-    /**
-     * 获取图片上传后服务器返回的地址集合(逗号分隔)
-     */
-    public static final int getImgUrl = 0x105;
-    /**
-     * 录制视频后视频存储地址
-     */
-    public static final int getVideoModel = 0x106;
-    /**
-     * 上传视频后的model
-     */
-    public static final int getVideoUrlModel = 0x107;
-    /**
-     * 盘点任务刷新
-     */
-    public static final int check_refresh = 0x108;
-    /**
-     * 收货包材赋值
-     */
-    public static final int packingMaterials = 0x109;
-    /**
-     * 收货主面板刷新
-     */
-    public static final int receive_main_refresh = 0x110;
-    /**
-     * 上架主面板刷新
-     */
-    public static final int putway_main_refresh = 0x111;
-
-    /**
-     * 包装校验-剔除无货订单
-     */
-    public static final int pack_validate_delete_order = 0x112;
+    public static final int file_upload_progress_lister = 0x5;
 
     /**
      * 移位刷新
      */
     public static final int displacement_refresh = 0x113;
 
-    /**
-     * FBA签出任务刷新
-     */
-    public static final int check_out_refresh = 0x114;
 
 }

+ 7 - 2
app/src/main/java/com/fxy/constant/SPCache.java

@@ -253,7 +253,12 @@ public class SPCache {
         editor.putInt("business_type", business_type).commit();
     }
 
-
-
+    //设置空闲时间 默认5分钟
+    public int getLeisure() {
+        return sp.getInt("leisure", 15);
+    }
+    public void setLeisure(int leisure){
+        editor.putInt("leisure", leisure).commit();
+    }
 
 }

+ 267 - 386
app/src/main/java/com/fxy/detection/DetectionPutInMainActivity.java

@@ -9,43 +9,51 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
+import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.view.KeyEvent;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
 import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 import android.widget.ProgressBar;
+import android.widget.Switch;
 import android.widget.TextView;
-import android.widget.Toast;
 
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
 import com.elvishew.xlog.XLog;
 import com.fxy.R;
 import com.fxy.baselibrary.base.BaseActivity;
 import com.fxy.baselibrary.bean.BaseEventBusBean;
 import com.fxy.baselibrary.interfaces.OnRxScanerListener;
-import com.fxy.baselibrary.qrcode.ActivityScanerCode;
 import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.views.MarqueeTextView;
 import com.fxy.bean.ActionBean;
 import com.fxy.bean.ScanBean;
-import com.fxy.common.AsyncUpload;
-import com.fxy.common.PictureSelectorUpload;
+import com.fxy.common.AsyncFileUpload;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureUpload;
 import com.fxy.common.UploadProgressEvent;
 import com.fxy.constant.BaseConfig;
 import com.fxy.constant.EventCode;
-import com.fxy.detection.bean.NeedPhotoBean;
+import com.fxy.constant.SPCache;
+import com.fxy.detection.bean.StorageRecordBean;
 import com.fxy.detection.bean.TakePictureBean;
+import com.fxy.detection.bean.TrackingBoxBean;
 import com.fxy.net.MyDialogCallback;
 import com.fxy.net.Urls;
-import com.fxy.view.FloatingImageView;
+import com.fxy.putIn.TrayMainActivity;
+import com.fxy.utils.UploadUtils;
 import com.google.gson.Gson;
 import com.google.zxing.Result;
 import com.luck.picture.lib.config.PictureConfig;
-import com.luck.picture.lib.entity.LocalMedia;
 import com.lzy.okgo.OkGo;
 import com.lzy.okgo.model.Response;
 
@@ -67,94 +75,101 @@ import sto.android.app.StoJNI;
 import sto.android.app.StoPdaKeyEvent;
 import sto.android.app.StoTongJNI;
 
-public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
+public class BoxPutInDetailsMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
 
     /**
      * 列表适配器
      */
     Context mContext = this;
-
-    @BindView(R.id.et_order_number)
-    EditText etOrderNumber;
-
-
-
-    @BindView(R.id.et_tracking_number)
-    EditText etTrackingNumber;
-
+    
     @BindView(R.id.et_unit_code)
     EditText etUnitCode;
 
     //拍照区域
     @BindView(R.id.ll_camera_picture_module)
     LinearLayout llCameraPictureModule;
-
-
-    @BindView(R.id.ll_label_picture)
-    LinearLayout llLabelPicture;
-
-
-    @BindView(R.id.ll_weigh_picture)
-    LinearLayout llWeighPicture;
-
-    @BindView(R.id.ll_result)
-    LinearLayout llResult;
-
-    @BindView(R.id.tv_result)
-    TextView tvResult;
-
+ 
     @BindView(R.id.ll_await_num)
     LinearLayout llAwaitNum;
 
     @BindView(R.id.tv_await_num)
     TextView tvAwaitNum;
+ 
+    @BindView(R.id.btn_confirm)
+    TextView btnConfirm;
+
 
+    @BindView(R.id.ll_btn_confirm)
+    LinearLayout llConfirm;
 
-    @BindView(R.id.pb_progressbar)
-    ProgressBar pbProgressbar;
+    @BindView(R.id.btn_clear)
+    TextView btnClear;
 
-    @BindView(R.id.percentage_text_view)
-    TextView tvPercentageTextView;
+    @BindView(R.id.ll_btn_clear)
+    LinearLayout llClear;
+    
+    @BindView(R.id.ll_unit_code)
+    LinearLayout llUnitCode;
 
+    @BindView(R.id.recyclerview)
+    RecyclerView recyclerView;
 
-    @BindView(R.id.btn_start_upload)
-    TextView btnStartUpload;
+    @BindView(R.id.mt_tracking_number)
+    MarqueeTextView mtTrackingNumber;
 
-    @BindView(R.id.ll_upload_progressbar)
-    LinearLayout llUploadProgressbar;
+    @BindView(R.id.mt_box_number)
+    MarqueeTextView mtBoxNumber;
 
+    @BindView(R.id.tv_qty)
+    TextView tvQty;
+
+
+    private String customerCode = "";
 
     private HashMap<String, Object> postData  = new HashMap<>();
 
-    private HashMap<String,AsyncUpload> mapPictureSelector = new HashMap<>();
+    private HashMap<String,AsyncPictureSelector> mapPictureSelector = new HashMap<>();
 
     private List<TakePictureBean> takePictureBeanList = new ArrayList<>();
 
+    private TrackingBoxBean trackingBoxBean;
 
     private String currentPictureType= "";
 
     private boolean currentUploadStatus = false;
+
+
+    private boolean isRequiredShow = false;
+
     //
     //扫码扫码动作
     private ScanBean scanBean;
 
+    
+    private Unbinder unbinder;
 
-    private boolean showWeightImg = false;
+    private JSONObject postParam = new JSONObject();
 
-    private boolean isRequiredShow = false;
+    private int leisure = 10;
 
-    private  ArrayList<String> baseImgList = new ArrayList<>();
-    protected String action;
 
 
-    private Unbinder unbinder;
 
-    private JSONObject postParam = new JSONObject();
+
+    private View notDataView;   //没有数据显示页
+    private View errorView;     //错误显示页
+    private View emptyView;     //空显示页
+    /**
+     * 列表适配器
+     */
+    private FinishWorkAdapter mAdapter;
+
+    private List<StorageRecordBean> tallyDataList = new ArrayList<>()   ;
 
 
     @Override
     public int getContentViewResId() {
-        return R.layout.activity_fxy_detection_putin;
+        return R.layout.activity_fxy_detection_box_putin_details;
     }
 
     @Override
@@ -170,6 +185,8 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     @Override
     protected void getBundleExtras(Bundle bundle) {
         //XLog.e("接收数据解析:",bundle);
+        trackingBoxBean = JsonUtil.jsonString2Bean(bundle.getString("data"),TrackingBoxBean.class);
+        customerCode    = bundle.getString("customer_code","");
     }
 
 
@@ -191,7 +208,18 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
                     mapPictureSelector.get(currentPictureType).getSelectImg(data);
                 }
                 totalAwaitNum();
-                checkSubmit();
+                for (int i=0;i<takePictureBeanList.size();i++){
+                    int num = takePictureBeanList.get(i).getNumber();
+                    String field = takePictureBeanList.get(i).getField();
+                    int has = mapPictureSelector.get(field).getOssPhotoList().size();
+                    if (has < num ){
+                        mapPictureSelector.get(field).authCamera();
+                        return;
+                    }
+                }
+                finishInbound();
+
+
             }
         }
     }
@@ -199,14 +227,20 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     /**
      * EventBus接收信息的方法,开启后才会调用(非粘性事件)
      *
-     * @param event
+     * @param event BaseEventBusBean
      */
     @Override
     protected void EventBean(BaseEventBusBean event) {
 //        XLog.e("----------接收返回--------------");
 //        XLog.e("接收返回:"+event.getEventCode());
-        if (event != null && event.getEventCode() == EventCode.displacement_refresh){
-
+        assert event != null;
+        switch (event.getEventCode()){
+            case EventCode.picture_selector_lister:
+                currentPictureType = event.getData().toString();
+                break;
+            case EventCode.file_upload_lister:
+                totalAwaitNum();
+                break;
         }
     }
 
@@ -219,51 +253,37 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     @Override
     protected void initView() {
         unbinder = ButterKnife.bind(this);
-        setTitleName("单箱入库");
+        setTitleName("内件码操作");
 
+        initAdapter();
+
+        setRequestResult();
+        setCameraPicture();
         initEdit();
-        iniData();
-        RecyclerView rvLabelShowImg = (RecyclerView)llLabelPicture.findViewById(R.id.rv_show_img);
-        RecyclerView rvWeighShowImg = (RecyclerView)llWeighPicture.findViewById(R.id.rv_show_img);
-        mapPictureSelector.put("label_img",setItemPicture("label_img",rvLabelShowImg,9));
-        mapPictureSelector.put("weight_img",setItemPicture("weight_img",rvWeighShowImg,9));
 
-        iniPhoto();
         totalAwaitNum();
+
+
+
     }
 
 
 
+
+
     /**
      * 设置多个上传文件
      * @param uploadType String
      * @param showImg RecyclerView
      */
-    private AsyncUpload setItemPicture(String uploadType,RecyclerView showImg,int num){
+    private AsyncPictureSelector setItemPicture(String uploadType,RecyclerView showImg,int num){
 
         String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
-        AsyncUpload pictureUpload = new AsyncUpload(DetectionPutInMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
+        AsyncPictureSelector pictureUpload = new AsyncPictureSelector(BoxPutInDetailsMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
         pictureUpload.setUploadType(uploadType);
         pictureUpload.setCompress(true,100,100);
         pictureUpload.setOnlyCamera(true);
         pictureUpload.setMaxSelectNum(num);
-
-        //showImg.onTouchEvent()
-
-        pictureUpload.setOnChangeListener(new AsyncUpload.UploadChangeListener() {
-            @Override
-            public void uploadResult(boolean State,String actionType) {
-                if (State) {
-                    totalAwaitNum();
-                }
-            }
-
-            @Override
-            public void uploadFileKey(String fileKey) {
-                System.out.println("fileKey:"+fileKey);
-                currentPictureType = fileKey;
-            }
-        });
         return  pictureUpload;
     }
 
@@ -271,17 +291,18 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     private void setCameraPicture(){
         llCameraPictureModule.removeAllViews();;
         for (int i=0;i<takePictureBeanList.size();i++){
-            addPictureSelectorUpload(llCameraPictureModule,takePictureBeanList.get(i));
+            TakePictureBean takePictureBean = takePictureBeanList.get(i);
+            addPictureSelectorUpload(llCameraPictureModule,takePictureBean);
         }
     }
 
     public void addPictureSelectorUpload(LinearLayout linearLayout, TakePictureBean takePictureBean){
         View itemPictureSelector = View.inflate(mContext, R.layout.item_picture_selector, null);
         TextView tvPicturesTitle = itemPictureSelector.findViewById(R.id.tv_pictures_title);
-        tvPicturesTitle.setText(takePictureBean.getField());
+        tvPicturesTitle.setText(takePictureBean.getTitle());
         RecyclerView rvLabelShowImg = (RecyclerView)itemPictureSelector.findViewById(R.id.recyclerview);
         linearLayout.addView(itemPictureSelector);
-        AsyncUpload tmpPictureSelector  = setItemPicture(takePictureBean.getField(),rvLabelShowImg,takePictureBean.getNumber());
+        AsyncPictureSelector tmpPictureSelector  = setItemPicture(takePictureBean.getField(),rvLabelShowImg,takePictureBean.getNumber());
         mapPictureSelector.put(takePictureBean.getField(),tmpPictureSelector);
     }
 
@@ -296,14 +317,41 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     }
 
     public HashMap<String, Object> getNotifyParam(){
-        postData.put("box_number",etOrderNumber.getText().toString().trim());
-        postData.put("tracking_number",etTrackingNumber.getText().toString().trim());
+        postData.put("tracking_number",trackingBoxBean.getTrackingNumber().trim());
+        postData.put("box_number",trackingBoxBean.getBoxNumber().trim());
         postData.put("unit_code",etUnitCode.getText().toString().trim());
-        mapPictureSelector.get(currentPictureType).setNotifyParam(postData);
-        mapPictureSelector.get(currentPictureType).setNotifyParam(postData);
         return postData;
     }
 
+    private static class FinishWorkAdapter extends BaseQuickAdapter<StorageRecordBean, BaseViewHolder> {
+        public FinishWorkAdapter(List<StorageRecordBean> data){
+            super(R.layout.item_card_intercept, data);
+        }
+        @Override
+        protected void convert(BaseViewHolder helper, StorageRecordBean item) {
+            helper.addOnClickListener(R.id.tv_status);//定义setOnItemChildClickListener 事件点击
+            try {
+                helper.setText(R.id.tv_order_no,item.getUnitCode());
+                helper.getView(R.id.tv_location).setVisibility(View.GONE);
+                helper.getView(R.id.tv_status).setVisibility(View.GONE);
+            } catch (Exception e) {
+                XLog.e("列表赋值错误",e);
+                e.printStackTrace();
+            }
+        }
+    }
+    private void initAdapter(){
+        emptyView = this.getLayoutInflater().inflate(R.layout.pager_empty, (ViewGroup) recyclerView.getParent(), false);
+        errorView = this.getLayoutInflater().inflate(R.layout.pager_error, (ViewGroup) recyclerView.getParent(), false);
+        notDataView = emptyView;
+
+        mAdapter  = new FinishWorkAdapter(tallyDataList);
+        mAdapter.setEmptyView(emptyView);
+        mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
+        recyclerView.setLayoutManager(new LinearLayoutManager(this));
+        recyclerView.setAdapter(mAdapter);
+
+    }
 
 
     //监听按键
@@ -413,67 +461,28 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
 
     private void initEdit() {
         List<EditText> list = new ArrayList<>();
-        list.add(etTrackingNumber);
-        list.add(etOrderNumber);
         list.add(etUnitCode);
         unifyEdit(list);
-        llResult.setVisibility(View.GONE);
-        llWeighPicture.setVisibility(View.GONE);
     }
 
 
-    private void iniData(){
-        baseImgList.add("label_img");
-        baseImgList.add("weight_img");
-    }
 
     //getAwaitNum
     private void totalAwaitNum(){
-        int awaitNum = mapPictureSelector.get("label_img").getAwaitNum();
+        int awaitNum = UploadUtils.getAwaitNum(mRealm,getClass().getSimpleName());
         tvAwaitNum.setText(String.valueOf(awaitNum));
-        if (awaitNum == 0){
-            operateStopUpload();
-        }
+
     }
 
     //统一按钮回调
     @SuppressLint("NonConstantResourceId")
     public void callbackEditor(View v){
-        XLog.e("获取:"+v.getId());
-        XLog.e("id:"+R.id.et_tracking_number);
         switch (v.getId()) {
-            case R.id.et_tracking_number:
-                getInboundTrack();
-                break;
-            case R.id.et_order_number:
-                if (etTrackingNumber.getText().toString().isEmpty()){
-                    etTrackingNumber.requestFocus();
-                    return;
-                }
-                if (etOrderNumber.getText().toString().isEmpty()){
-                    etOrderNumber.requestFocus();
-                    return;
-                }
-                etUnitCode.requestFocus();
-                etUnitCode.setSelection(etUnitCode.getText().toString().length());
-                break;
+
             case R.id.et_unit_code:
-                for (int i=0;i<baseImgList.size();i++){
-                    String tmpKey = baseImgList.get(0);
-                    if (mapPictureSelector.containsKey(tmpKey) && mapPictureSelector.get(tmpKey).getOssPhotoList().size()==0){
-                        mapPictureSelector.get(tmpKey).authCamera();
-                        return;
-                    }
-                }
 
-                for (int i=0;i<takePictureBeanList.size();i++){
-                    String tmpKey = takePictureBeanList.get(0).getField();
-                    if (mapPictureSelector.containsKey(tmpKey) && mapPictureSelector.get(tmpKey).getOssPhotoList().size()==0){
-                        mapPictureSelector.get(tmpKey).authCamera();
-                        return;
-                    }
-                }
-                pictureInbound();
+                checkUnitCode();
+
                 break;
 
             default:
@@ -590,164 +599,149 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
         }
     }
 
-    private void getInboundTrack(){
-        int awaitNum = mapPictureSelector.get("label_img").getAwaitNum();
-        if (currentUploadStatus  && awaitNum>0){
-            new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
-                    .setMessage("当前正在上传图片。是否需要停止上传继续操作")
-                    .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
-                        @Override
-                        public void onClick(DialogInterface dialogInterface, int i) {
-                            if (!currentUploadStatus){
-                                operateStartUpload();
-                            }
-                            dialogInterface.dismiss();
-                        }
-                    }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
 
-                @Override
-                public void onClick(DialogInterface dialogInterface, int i) {
+    //检查是否存在上传
+    private void checkIsUpload(){
+        int awaitNum = UploadUtils.getAwaitNum(mRealm,getClass().getSimpleName());
+    }
 
-                }
-            }).show();
+
+
+
+
+    //设置返回
+    private void setRequestResult(){
+        takePictureBeanList = trackingBoxBean.getNeedPhoto();
+        tallyDataList.clear();
+        if (!trackingBoxBean.getZuijinNums().isEmpty()){
+            tallyDataList = trackingBoxBean.getZuijinNums();
         }
 
-        if (etTrackingNumber.getText().toString().isEmpty()){
-            showErrorToast(etTrackingNumber.getHint().toString());
-            return;
+        llCameraPictureModule.setVisibility(View.VISIBLE);
+        
+        mtBoxNumber.setText(trackingBoxBean.getBoxNumber());
+        mtTrackingNumber.setText(trackingBoxBean.getTrackingNumber());
+        tvQty.setText(String.valueOf(trackingBoxBean.getYipaizhaoQty()));
+
+        btnConfirm.setText("入库完成".concat(" - ").concat(trackingBoxBean.getShowText()));
+        if (trackingBoxBean.getYipaizhaoQty()>0){
+            llConfirm.setVisibility(View.VISIBLE);
+        }else{
+            llConfirm.setVisibility(View.GONE);
         }
 
+        if (trackingBoxBean.getNoClear().equals("Y")){
+            llClear.setVisibility(View.VISIBLE);
+        }else{
+            llClear.setVisibility(View.GONE);
+        }
 
-        Map<String,Object> math = new HashMap<>();
-        math.put("tracking_number",etTrackingNumber.getText().toString().trim());
+        mAdapter.setNewData(tallyDataList);
+        mAdapter.notifyDataSetChanged();
+    }
 
 
-        String mathJson = (new Gson()).toJson(math);
 
-        if (!checkRepeat(Urls.FXY_DETECTION_PUTIN_TRACK+(mathJson.toString()))){
-            Toast.makeText(this, getString(R.string.error_data_processed), Toast.LENGTH_LONG).show();
+    private void checkUnitCode(){
+        checkIsUpload();
+        if (etUnitCode.getText().toString().isEmpty()){
+            showErrorToast(etUnitCode.getHint().toString());
             return;
         }
 
-        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN_TRACK).upJson(mathJson)
-                .execute(new MyDialogCallback(this, true, true) {
+        Gson gson = new Gson();
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",trackingBoxBean.getTrackingNumber().trim());
+        math.put("box_number",trackingBoxBean.getBoxNumber().trim());
+        math.put("unit_code",etUnitCode.getText().toString().trim());
+        if (!customerCode.isEmpty()){
+            math.put("customer_code",customerCode);
+        }
+
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN_UNIT).upJson(gson.toJson(math))
+                .execute(new MyDialogCallback(this, true, false) {
                     @Override
                     public void onSuccess(Response<String> response) {
                         super.onSuccess(response);
                         try {
+
                             ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
-                            JSONObject result = new JSONObject();
+                            TrackingBoxBean resTrackingBoxBean = new TrackingBoxBean();
                             if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
-                                result = new JSONObject(bean.data);
+                                resTrackingBoxBean =  JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
                             }
+                            String voiceName = resTrackingBoxBean.getVoiceName();
+
+                            if (resTrackingBoxBean.getNeedConfirm().equals("Y")){
+                                new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                                        .setMessage(resTrackingBoxBean.getConfirmMsg())
+                                        .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                dialogInterface.dismiss();
+                                                etUnitCode.setText("");
+                                            }
+                                        }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+                                    @Override
+                                    public void onClick(DialogInterface dialogInterface, int i) {
+                                        checkTakePicture();
+                                    }
+                                }).show();
+                            }else{
+                                if(bean.code == 1){
+                                    showSuccessToast(bean.msg,voiceName);
+                                    checkTakePicture();
+                                }else{
+                                    showWarningToast(bean.msg,voiceName);
+                                }
 
-                            String voiceName = result.has("voice_name") ? result.getString("voice_name"):"";
-                            String showText = result.has("show_text") ? result.getString("show_text"):"";
-                            String show_weight_img = result.has("show_weight_img") ? result.getString("show_weight_img"):"";
-
-
-                            if (result.has("need_photo")){
-                                takePictureBeanList = JsonUtil.jsonString2Beans(result.getString("need_photo"),TakePictureBean.class);
                             }
 
-                            showWeightImg = show_weight_img.contains("1");
-                            llWeighPicture.setVisibility(showWeightImg ? View.VISIBLE:View.GONE);
-                            llResult.setVisibility(showText.isEmpty() ? View.GONE:View.VISIBLE);
-                            tvResult.setText(showText);
-
-                            setCameraPicture();
-
-                            if(bean.code == 1){
-                                showSuccessToast(bean.msg,voiceName);
-
-                            }else{
-                                showWarningToast(bean.msg,voiceName);
-                            }
-                        } catch (Exception e) {
+                        }catch (Exception e) {
                             e.printStackTrace();
-                            XLog.e("添加开箱拆柜数据结果返回错误",e.getMessage());
+                            XLog.e("第二步确认错误",e.getMessage());
                         }
                     }
                 });
 
-        etOrderNumber.requestFocus();
-        etOrderNumber.setSelection(etOrderNumber.getText().toString().length());
     }
 
-    private void checkSubmit(){
-        if (mapPictureSelector.get("label_img").getOssPhotoList().size()==0){
-            return;
-        }
-
-        if (showWeightImg && mapPictureSelector.get("weight_img").getOssPhotoList().size()==0){
-            return;
-        }
-
-        if (takePictureBeanList.size()>0){
-            for (int i=0;i<takePictureBeanList.size();i++){
-                if (mapPictureSelector.get(takePictureBeanList.get(i).getField()).getOssPhotoList().size()==0){
-                    return;
-                }
+    private void checkTakePicture(){
+        for (int i=0;i<takePictureBeanList.size();i++){
+            String tmpKey = takePictureBeanList.get(0).getField();
+            if (mapPictureSelector.containsKey(tmpKey) && mapPictureSelector.get(tmpKey).getOssPhotoList().size()==0){
+                mapPictureSelector.get(tmpKey).authCamera();
+                return;
             }
         }
-        pictureInbound();
-        initUnitCode();
+        finishInbound();
     }
 
-    private void pictureInbound(){
+
+    //提交内件码
+    private void finishInbound(){
         isRequiredShow = true;
         if (!validate()){
             return;
         }
 
-//        if (!checkRepeat(Urls.FXY_DETECTION_PUTIN+(postParam.toString()))){
-//            Toast.makeText(this, getString(R.string.error_data_processed), Toast.LENGTH_LONG).show();
-//            return;
-//        }
-
         OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(postParam)
-                .execute(new MyDialogCallback(this, true, false) {
-                    @Override
-                    public void onSuccess(Response<String> response) {
-                        super.onSuccess(response);
-                    }
-                });
-
-        //假成功
-
-        showSuccessToast("success");
-    }
-
-    //完成入库
-    private void finishInbound(){
-        isRequiredShow = true;
-        if (etTrackingNumber.getText().toString().isEmpty()){
-            showWarningToast(etTrackingNumber.getHint().toString());
-            return ;
-        }
-
-        if (etOrderNumber.getText().toString().isEmpty()){
-            showWarningToast(etOrderNumber.getHint().toString());
-            return ;
-        }
-        HashMap<String,Object> postData = new HashMap<>();
-        postData.put("box_number",etOrderNumber.getText().toString().trim());
-        postData.put("tracking_number",etTrackingNumber.getText().toString().trim());
-
-        String body = (new Gson()).toJson(postData);
-
-        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(body)
                 .execute(new MyDialogCallback(this, true, false) {
                     @Override
                     public void onSuccess(Response<String> response) {
                         super.onSuccess(response);
                         try {
                             ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
-//                            if(bean.code == 1){
-//                                showSuccessToast(bean.msg);
-//                            }else{
-//                                showWarningToast(bean.msg);
-//                            }
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg);
+                                if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                    trackingBoxBean = JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
+                                    setRequestResult();
+                                }
+                                initFinish();
+                            }else{
+                                showWarningToast(bean.msg);
+                            }
                         } catch (Exception e) {
                             e.printStackTrace();
                             XLog.e("添加开箱拆柜数据结果返回错误",e.getMessage());
@@ -755,42 +749,24 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
                     }
                 });
 
-        //假成功
+     }
 
-        showSuccessToast("success");
-        initFinish();
-    }
 
-    public void initUnitCode(){
+    private void initFinish(){
         isRequiredShow = false;
-        for (String key : mapPictureSelector.keySet()) {
-            if (!baseImgList.contains(key)){
-                mapPictureSelector.get(key).emptyRemake();
-            }
-        }
-
         etUnitCode.setText("");
         etUnitCode.requestFocus();
-        llLabelPicture.setVisibility(View.GONE);
-    }
 
-    private void initFinish(){
-        initUnitCode();
-        for (int i=0;i<baseImgList.size();i++){
-            if (mapPictureSelector.containsKey(baseImgList.get(i))){
-                mapPictureSelector.get(baseImgList.get(i)).emptyRemake();
+        if (!trackingBoxBean.getNoClear().equals("Y")){
+            for (int n=0;n<takePictureBeanList.size();n++){
+                String tmpKey = takePictureBeanList.get(n).getField();
+                if (mapPictureSelector.containsKey(tmpKey) ){
+                    mapPictureSelector.get(tmpKey).emptyRemake();
+                }
             }
-
         }
-        llResult.setVisibility(View.GONE);
-        llWeighPicture.setVisibility(View.GONE);
-        llLabelPicture.setVisibility(View.VISIBLE);
 
-        takePictureBeanList.clear();
-        setCameraPicture();
-        etTrackingNumber.setText("");
-        etOrderNumber.setText("");
-        etTrackingNumber.requestFocus();
+        llConfirm.setVisibility(View.VISIBLE);
     }
 
     /*
@@ -799,15 +775,7 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
     private boolean validate(){
 
 
-        if (etTrackingNumber.getText().toString().isEmpty()){
-            showWarningToast(etTrackingNumber.getHint().toString());
-            return  false;
-        }
-
-        if (etOrderNumber.getText().toString().isEmpty()){
-            showWarningToast(etOrderNumber.getHint().toString());
-            return  false;
-        }
+        
 
         if (etUnitCode.getText().toString().isEmpty()){
             showWarningToast(etUnitCode.getHint().toString());
@@ -818,25 +786,7 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
             postParam = new JSONObject();
             Gson gson = new Gson();
 
-            List<String> stringList = mapPictureSelector.get("label_img").getOssPhotoList();
-            if (stringList.size()==0){
-                showWarningToast("面单照片不能为空");
-                return false;
-            }
-            postParam.put("label_img_tag",mapPictureSelector.get("label_img").getUniqueTag());
-            postParam.put("label_img",gson.toJson(stringList));
-
-
-            AsyncUpload weightUpload = mapPictureSelector.get("weight_img");
-            if (showWeightImg && weightUpload!=null){
-                List<String> weighPhotoList = weightUpload.getOssPhotoList();
-                if (weighPhotoList.size()==0){
-                    showWarningToast("内件照片不能为空");
-                    return false;
-                }
-                postParam.put("weight_img_tag",weightUpload.getUniqueTag());
-                postParam.put("weight_img",gson.toJson(weighPhotoList));
-            }
+          
 
             //拍照
             if (takePictureBeanList.size()>0){
@@ -858,10 +808,15 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
             }
 
 
-            postParam.put("box_number",etOrderNumber.getText().toString().trim());
-            postParam.put("tracking_number",etTrackingNumber.getText().toString().trim());
+            postParam.put("box_number",trackingBoxBean.getBoxNumber().trim());
+            postParam.put("tracking_number",trackingBoxBean.getTrackingNumber().trim());
             postParam.put("unit_code",etUnitCode.getText().toString().trim());
 
+            if (!customerCode.isEmpty()){
+                postParam.put("is_customer_code",1);
+                postParam.put("customer_code",customerCode);
+            }
+
 
         } catch (JSONException e) {
             showWarningToast("系统异常"+e.getMessage());
@@ -871,110 +826,36 @@ public class DetectionPutInMainActivity extends  BaseActivity implements StoJNI.
         return true;
     }
 
-    private void iniPhoto(){
-//        HashMap<String, Object> map = new HashMap<>();
-//        map.put("disabled",false);
-//        map.put("error","不可拍照");
-//        labelPictureSelectorUpload.setLimitOperate(map);
-//        weighPictureSelectorUpload.setLimitOperate(map);
-    }
+
 
     //sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
-    @OnClick({R.id.btn_confirm,R.id.btn_start_upload})
+    @SuppressLint("NonConstantResourceId")
+    @OnClick({R.id.btn_confirm,R.id.btn_clear})
     public void onViewClicked(View view) {
         Bundle bundle = new Bundle();
         switch (view.getId()) {
             case R.id.btn_confirm:
-                finishInbound();
+                Intent intent = new Intent();
+                setResult(200, intent);//返回值,2 是改返回的标志,也会返回
+                showSuccessToast("success");
+                finish();
                 break;
-            case R.id.btn_start_upload:
-
-                if (currentUploadStatus) {
-                    operateStopUpload();
-                } else {
-                    operateStartUpload();
+            case R.id.btn_clear:
+                for (int n=0;n<takePictureBeanList.size();n++){
+                    String tmpKey = takePictureBeanList.get(n).getField();
+                    if (mapPictureSelector.containsKey(tmpKey) ){
+                        mapPictureSelector.get(tmpKey).emptyRemake();
+                    }
                 }
+                break;
             default:
                 break;
         }
     }
 
-    private void operateStopUpload(){
-        if (currentUploadStatus){
-            mapPictureSelector.get("label_img").setStopUpload();
-            currentUploadStatus = false;
-            btnStartUpload.setText("开始上传");
-            llUploadProgressbar.setVisibility(View.GONE);
-        }
-    }
-    private void operateStartUpload(){
-        if (!currentUploadStatus){
-            mapPictureSelector.get("label_img").setStartUpload();
-            currentUploadStatus = true;
-            btnStartUpload.setText("停止上传");
-            llUploadProgressbar.setVisibility(View.VISIBLE);
-        }
-    }
-
-    protected void showBack() {
-        super.showBack();
-        tb_iv_left.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-
-                int num = mapPictureSelector.get("label_img").getAwaitNum();
-
-                if (num>0){
-                    new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
-                            .setMessage("返回会取消上传还有"+num+"条数据未上传,确定要返回吗")
-                            .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
-                                @Override
-                                public void onClick(DialogInterface dialogInterface, int i) {
-                                    if (!currentUploadStatus){
-                                        operateStartUpload();
-                                    }
-                                    dialogInterface.dismiss();
-                                }
-                            }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
-
-                        @Override
-                        public void onClick(DialogInterface dialogInterface, int i) {
-                                if (isShowBackDialog) {
-                                    onBackPressedSupport();
-                                } else {
-                                    finish();
-                                }
-                        }
-                    }).show();
-
-                }else{
-                    if (isShowBackDialog) {
-                        onBackPressedSupport();
-                    } else {
-                        finish();
-                    }
-                }
-
-            }
-        });
-    }
-
-    @Subscribe(threadMode = ThreadMode.MAIN)
-    public void onUploadProgress(UploadProgressEvent event) {
-        // 更新进度条或其他 UI 元素
-        int num = event.getProgress();
-        pbProgressbar.setProgress(num);
-        tvPercentageTextView.setText(String.valueOf(num).concat("%"));
-    }
-
     @Override
     protected void onDestroy() {
         unbinder.unbind();
-
-         for (AsyncUpload asyncUpload : mapPictureSelector.values()) {
-             asyncUpload.removeHandler();
-        }
-
         super.onDestroy();
     }
     @Override

+ 756 - 0
app/src/main/java/com/fxy/detection/BoxPutInMainActivity.java

@@ -0,0 +1,756 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.views.MarqueeTextView;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.common.AsyncFileUpload;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureUpload;
+import com.fxy.common.CommonDialog;
+import com.fxy.common.UploadProgressEvent;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.detection.bean.TakePictureBean;
+import com.fxy.detection.bean.TrackingBoxBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.fxy.putOut.QualityInspectionMainActivity;
+import com.fxy.putOut.QualityVolumeMainActivity;
+import com.fxy.utils.UploadUtils;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.luck.picture.lib.config.PictureConfig;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class BoxPutInMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
+
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+
+    @BindView(R.id.et_order_number)
+    EditText etOrderNumber;
+
+    @BindView(R.id.et_tracking_number)
+    EditText etTrackingNumber;
+
+
+    @BindView(R.id.ll_await_num)
+    LinearLayout llAwaitNum;
+
+
+    @BindView(R.id.ll_extend_info)
+    LinearLayout llExtendInfo;
+
+    @BindView(R.id.tv_await_num)
+    TextView tvAwaitNum;
+
+    @BindView(R.id.mt_customer_code)
+    MarqueeTextView mtCustomerCode;
+
+
+    private HashMap<String, Object> postData  = new HashMap<>();
+
+    private TrackingBoxBean trackingBoxBean;
+
+    //
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+
+    private boolean showWeightImg = false;
+
+    private boolean isRequiredShow = false;
+
+    private  ArrayList<String> baseImgList = new ArrayList<>();
+    protected String action;
+
+
+    private Unbinder unbinder;
+
+
+
+    private CommonDialog commonDialog;
+
+    //是否需要显示客户
+    private boolean needCustomer;
+
+    //客户名称
+    private String customerCode="";
+
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_box_putin;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+        //XLog.e("接收数据解析:",bundle);
+    }
+
+
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (requestCode == 200 && resultCode == 200)//之前提到的两个标志,在这里显示出了作用
+        {
+            initFinish();
+        }
+
+
+    }
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+
+        assert event != null;
+        switch (event.getEventCode()){
+
+            case EventCode.file_upload_lister:
+                totalAwaitNum();
+                break;
+        }
+
+
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("单箱入库");
+
+        initEdit();
+        iniData();
+        initDialog();
+        totalAwaitNum();
+
+    }
+
+
+
+
+    private void initDialog(){
+        commonDialog = new CommonDialog(mContext, R.style.dialog, "need_customer", new CommonDialog.OnCloseListener() {
+            @Override
+            public void onClickCancel(Dialog dialog, boolean confirm) {
+                customerCode = "" ;
+                dialog.dismiss();
+            }
+            @Override
+            public void onClickSubmit(Dialog dialog, boolean confirm) {
+                String string = commonDialog.contentTxt.getText().toString().trim();
+                if (commonDialog.getTypeCode().equals("need_customer")){
+                    customerCode = string;
+                }
+                dialog.dismiss();
+                mtCustomerCode.setText(customerCode);
+
+                if (etOrderNumber.getText().toString().isEmpty()){
+                    etOrderNumber.requestFocus();
+                }else{
+                    getBoxNumber();
+                }
+
+            }
+        });
+        commonDialog.setContentLabel("QC");
+
+
+    }
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode()==KeyEvent.KEYCODE_ENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+            //按确定键
+
+        }
+        return super.dispatchKeyEvent(event);
+    }
+
+
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast()==0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode)  == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()){
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult==null){return; }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()){
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            }else{
+                scanStatus = scanResult.isEmpty()? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()){
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)){
+                setScanResult(scanResult);
+            }else{
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver(){
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast ==1){
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            }else{
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()){
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        }catch (Exception e) {
+            showErrorToast("获取扫码配置失败"+e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+    private void initEdit() {
+        List<EditText> list = new ArrayList<>();
+        list.add(etTrackingNumber);
+        list.add(etOrderNumber);
+        unifyEdit(list);
+    }
+
+
+    private void iniData(){
+        baseImgList.add("label_img");
+        baseImgList.add("weight_img");
+    }
+
+    //getAwaitNum
+    private void totalAwaitNum(){
+        String[] uploadTypeList = {getClass().getSimpleName(),"BoxPutInDetailsMainActivity"};
+        int awaitNum = UploadUtils.getAwaitNum(mRealm,uploadTypeList);
+        tvAwaitNum.setText(String.valueOf(awaitNum));
+    }
+
+    //统一按钮回调
+    @SuppressLint("NonConstantResourceId")
+    public void callbackEditor(View v){
+
+        switch (v.getId()) {
+            case R.id.et_tracking_number:
+                getTrackingNumber();
+                break;
+            case R.id.et_order_number:
+                if (etTrackingNumber.getText().toString().isEmpty()){
+                    etTrackingNumber.requestFocus();
+                    return;
+                }
+                if (etOrderNumber.getText().toString().isEmpty()){
+                    etOrderNumber.requestFocus();
+                    return;
+                }
+                getBoxNumber();
+
+                break;
+            default:
+        }
+
+    }
+
+    /**
+     * 统一设置Edit监听
+     * @param  list
+     */
+    public void unifyEdit(List<EditText> list){
+        for (int i=0;i<list.size();i++){
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout)editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    //XLog.e("actionId:"+actionId);
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE   ) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v,true);
+                            showWarningToast(v.getHint().toString());
+                            return false;
+                        }else{
+                            setEditTextNormal(v,true);
+                        }
+
+                        callbackEditor(v);
+
+                        return false;
+                    }
+                    return false;
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view=getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if(view instanceof EditText){
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout)currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0  ) {
+
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText!=null){
+                            setEditTextNormal(currentEditText,true);
+                        }
+
+                    } else {
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText!=null && isRequiredShow){
+                            setEditTextFocused(currentEditText,true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton !=null ){
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type){
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult){
+        //获取焦点的view对象
+        View view=getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if(view instanceof EditText)
+        {
+            ((EditText) view).setText(scanResult);
+            showSuccessToast("扫描成功");
+            callbackEditor(view);
+        }
+    }
+
+
+    //检查是否存在上传
+    private void checkIsUpload(){
+
+    }
+
+    //获取跟踪单号
+    private void getTrackingNumber(){
+
+        checkIsUpload();
+        if (etTrackingNumber.getText().toString().isEmpty()){
+            showErrorToast(etTrackingNumber.getHint().toString());
+            return;
+        }
+
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",etTrackingNumber.getText().toString().trim());
+
+        String mathJson = (new Gson()).toJson(math);
+        trackingBoxBean = null;
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN_TRACK).upJson(mathJson)
+                .execute(new MyDialogCallback(this, true, true) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trackingBoxBean =  JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
+                            }
+
+                            String voiceName = trackingBoxBean.getVoiceName();
+                            final Bundle bundle = new Bundle();
+                            bundle.putString("data",bean.data);
+                            bundle.putString("customer_code",customerCode);
+
+                            if (trackingBoxBean.getNeedConfirm().equals("Y")){
+                                new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                                        .setMessage(trackingBoxBean.getConfirmMsg())
+                                        .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                dialogInterface.dismiss();
+                                            }
+                                        }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+
+                                    @Override
+                                    public void onClick(DialogInterface dialogInterface, int i) {
+
+//                                        etOrderNumber.setEnabled(true);
+//                                        etOrderNumber.requestFocus();
+                                        intent2Page(BoxPutInMainActivity.this, BoxPutInDetailsMainActivity.class, false,bundle);
+                                    }
+                                }).show();
+                                return;
+                            }
+
+                            needCustomer = trackingBoxBean.getNeedCustomer().equals("Y");
+                            if (needCustomer){
+                                commonDialog.setTitle("客户编号","请输入客户编号").setContent("").show();
+                            }
+                            llExtendInfo.setVisibility(needCustomer ? View.VISIBLE:View.GONE);
+
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg,voiceName);
+                                etOrderNumber.setEnabled(true);
+                                etOrderNumber.requestFocus();
+                            }else{
+                                showWarningToast(bean.msg,voiceName);
+                            }
+
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("确认错误",e.getMessage());
+                        }
+
+                    }
+                });
+    }
+
+
+    //获取跟踪单号
+    private void getBoxNumber(){
+
+        checkIsUpload();
+        if (etTrackingNumber.getText().toString().isEmpty()){
+            showErrorToast(etTrackingNumber.getHint().toString());
+            return;
+        }
+
+        if (etOrderNumber.getText().toString().isEmpty()){
+            showErrorToast(etOrderNumber.getHint().toString());
+            return;
+        }
+
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",etTrackingNumber.getText().toString().trim());
+        math.put("box_number",etOrderNumber.getText().toString().trim());
+        if (needCustomer){
+
+            if (customerCode.isEmpty()){
+                showErrorToast("请输入客户代码");
+                return;
+            }
+            math.put("is_customer_code","1");
+            math.put("customer_code",customerCode);
+        }
+
+        String mathJson = (new Gson()).toJson(math);
+        trackingBoxBean = null;
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN_TRACK).upJson(mathJson)
+                .execute(new MyDialogCallback(this, true, true) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trackingBoxBean =  JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
+                            }
+
+                            String voiceName = trackingBoxBean.getVoiceName();
+                            final Bundle bundle = new Bundle();
+                            bundle.putString("data",bean.data);
+                            bundle.putString("customer_code",customerCode);
+
+                            if (trackingBoxBean.getNeedConfirm().equals("Y")){
+                                new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                                        .setMessage(trackingBoxBean.getConfirmMsg())
+                                        .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                dialogInterface.dismiss();
+                                            }
+                                        }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+
+                                    @Override
+                                    public void onClick(DialogInterface dialogInterface, int i) {
+
+//                                        etOrderNumber.setEnabled(true);
+//                                        etOrderNumber.requestFocus();
+                                        intentPageResult(BoxPutInMainActivity.this, BoxPutInDetailsMainActivity.class, bundle,200);
+                                    }
+                                }).show();
+                            }else{
+
+                                if(bean.code == 1){
+                                    showSuccessToast(bean.msg,voiceName);
+                                    intentPageResult(BoxPutInMainActivity.this, BoxPutInDetailsMainActivity.class, bundle,200);
+                                }else{
+                                    showWarningToast(bean.msg,voiceName);
+                                }
+                            }
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("确认错误",e.getMessage());
+                        }
+
+                    }
+                });
+    }
+
+
+
+    private void initFinish(){
+        llExtendInfo.setVisibility(View.GONE);
+        mtCustomerCode.setText("");
+        customerCode = "";
+        needCustomer = false;
+
+        etOrderNumber.setText("");
+        etOrderNumber.setEnabled(true);
+        etTrackingNumber.setText("");
+        etTrackingNumber.setEnabled(true);
+
+        etTrackingNumber.requestFocus();
+
+
+    }
+
+
+
+    //sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
+    @OnClick({R.id.tv_edit_customer})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            case R.id.tv_edit_customer:
+                if (needCustomer){
+                    commonDialog.setTitle("客户编号","请输入客户编号").setContent(customerCode).show();
+                }
+                break;
+
+            default:
+                break;
+        }
+    }
+
+
+
+
+
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+        super.onDestroy();
+
+    }
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast==0){
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            }else{
+                unregisterReceiver(mReceiver);
+            }
+        }catch (Exception e){
+            XLog.e("销毁广播失败:",e.getMessage());
+        }
+    }
+
+}

+ 802 - 0
app/src/main/java/com/fxy/detection/TrayMakeFourMainActivity.java

@@ -0,0 +1,802 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.views.MarqueeTextView;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureUpload;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.detection.bean.StorageRecordBean;
+import com.fxy.detection.bean.TakePictureBean;
+import com.fxy.detection.bean.TrackingBoxBean;
+import com.fxy.detection.bean.TrayMakeBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.luck.picture.lib.config.PictureConfig;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class TrayMakeFourMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
+
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+    
+    @BindView(R.id.et_unit_code)
+    EditText etUnitCode;
+
+
+ 
+    @BindView(R.id.ll_await_num)
+    LinearLayout llAwaitNum;
+
+    @BindView(R.id.tv_await_num)
+    TextView tvAwaitNum;
+ 
+    @BindView(R.id.ll_btn_confirm)
+    LinearLayout llConfirm;
+    
+    @BindView(R.id.ll_unit_code)
+    LinearLayout llUnitCode;
+
+    @BindView(R.id.recyclerview)
+    RecyclerView recyclerView;
+
+    @BindView(R.id.mt_tracking_number)
+    MarqueeTextView mtTrackingNumber;
+
+    @BindView(R.id.mt_box_number)
+    MarqueeTextView mtBoxNumber;
+
+    @BindView(R.id.mt_operate_number)
+    MarqueeTextView mtOperateNumber;
+
+    @BindView(R.id.mt_contents_number)
+    MarqueeTextView mtContentsNumber;
+
+
+
+    @BindView(R.id.ll_box_number)
+    LinearLayout llBoxNumber;
+
+    @BindView(R.id.ll_contents_number)
+    LinearLayout llContentsNumber;
+
+    private TrayMakeBean trayMakeBean;
+
+    private int abImgId;
+
+    private HashMap<String, Object> postData  = new HashMap<>();
+
+
+     private AsyncPictureUpload asyncPictureUpload = new AsyncPictureUpload(this);
+
+
+    private String currentPictureType= "";
+
+    private boolean currentUploadStatus = false;
+
+
+    private boolean isRequiredShow = false;
+
+    //
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+    
+    private Unbinder unbinder;
+
+    private JSONObject postParam = new JSONObject();
+
+    private int leisure = 10;
+
+
+    private Handler workHandler;
+    private Runnable idleRunnable;
+
+
+    private View notDataView;   //没有数据显示页
+    private View errorView;     //错误显示页
+    private View emptyView;     //空显示页
+    /**
+     * 列表适配器
+     */
+    private FinishWorkAdapter mAdapter;
+
+    private List<StorageRecordBean> tallyDataList = new ArrayList<>()   ;
+
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_tray_make_four;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+        //XLog.e("接收数据解析:",bundle);
+        trayMakeBean = JsonUtil.jsonString2Bean(bundle.getString("data"),TrayMakeBean.class);
+        abImgId = bundle.getInt("ab_img_id");
+    }
+
+
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+    }
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event BaseEventBusBean
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+        assert event != null;
+        switch (event.getEventCode()){
+            case EventCode.picture_selector_lister:
+                currentPictureType = event.getData().toString();
+                break;
+            case EventCode.file_upload_lister:
+                totalAwaitNum();
+                break;
+        }
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("托盘清点-内件码");
+
+        initAdapter();
+
+        setRequestResult();
+        initEdit();
+
+        totalAwaitNum();
+
+
+        workHandler = new Handler(Looper.getMainLooper());
+        // 定义空闲任务
+        idleRunnable = new Runnable() {
+            @Override
+            public void run() {
+                // 执行空闲后的操作
+                operateStartUpload();
+            }
+        };
+
+        SPCache spCache = SPCache.getInstance(this);
+        leisure = spCache.getLeisure();
+
+        // 初始化时设置计时器
+        workHandler.postDelayed(idleRunnable, leisure * 60 * 1000);
+    }
+
+
+    private void setNewTiming(){
+        try {
+            // 取消之前的计时器
+            workHandler.removeCallbacks(idleRunnable);
+            // 重新计时
+            workHandler.postDelayed(idleRunnable, leisure * 60 * 1000); // 2 分钟
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+    }
+
+
+
+    /**
+     * 设置多个上传文件
+     * @param uploadType String
+     * @param showImg RecyclerView
+     */
+    private AsyncPictureSelector setItemPicture(String uploadType,RecyclerView showImg,int num){
+
+        String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
+        AsyncPictureSelector pictureUpload = new AsyncPictureSelector(TrayMakeFourMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
+        pictureUpload.setUploadType(uploadType);
+        pictureUpload.setCompress(true,100,100);
+        pictureUpload.setOnlyCamera(true);
+        pictureUpload.setMaxSelectNum(num);
+        return  pictureUpload;
+    }
+
+
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode()==KeyEvent.KEYCODE_ENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+            //按确定键
+
+        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    public HashMap<String, Object> getNotifyParam(){
+        postData.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+        postData.put("box_number",trayMakeBean.getBoxNumber().trim());
+        postData.put("unit_code",etUnitCode.getText().toString().trim());
+        return postData;
+    }
+
+    private static class FinishWorkAdapter extends BaseQuickAdapter<StorageRecordBean, BaseViewHolder> {
+        public FinishWorkAdapter(List<StorageRecordBean> data){
+            super(R.layout.item_card_intercept, data);
+        }
+        @Override
+        protected void convert(BaseViewHolder helper, StorageRecordBean item) {
+            helper.addOnClickListener(R.id.tv_status);//定义setOnItemChildClickListener 事件点击
+            try {
+                helper.setText(R.id.tv_order_no,item.getUnitCode());
+                helper.getView(R.id.tv_location).setVisibility(View.GONE);
+                helper.getView(R.id.tv_status).setVisibility(View.GONE);
+            } catch (Exception e) {
+                XLog.e("列表赋值错误",e);
+                e.printStackTrace();
+            }
+        }
+    }
+    private void initAdapter(){
+        emptyView = this.getLayoutInflater().inflate(R.layout.pager_empty, (ViewGroup) recyclerView.getParent(), false);
+        errorView = this.getLayoutInflater().inflate(R.layout.pager_error, (ViewGroup) recyclerView.getParent(), false);
+        notDataView = emptyView;
+
+        mAdapter  = new FinishWorkAdapter(tallyDataList);
+        mAdapter.setEmptyView(emptyView);
+        mAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
+        recyclerView.setLayoutManager(new LinearLayoutManager(this));
+        recyclerView.setAdapter(mAdapter);
+
+    }
+
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast()==0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode)  == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()){
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult==null){return; }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()){
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            }else{
+                scanStatus = scanResult.isEmpty()? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()){
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)){
+                setScanResult(scanResult);
+            }else{
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver(){
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast ==1){
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            }else{
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()){
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        }catch (Exception e) {
+            showErrorToast("获取扫码配置失败"+e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+    private void initEdit() {
+        List<EditText> list = new ArrayList<>();
+        list.add(etUnitCode);
+        unifyEdit(list);
+    }
+
+
+
+    //getAwaitNum
+    private void totalAwaitNum(){
+        int awaitNum = asyncPictureUpload.getAwaitNum();
+        tvAwaitNum.setText(String.valueOf(awaitNum));
+        if (awaitNum == 0){
+            operateStopUpload();
+        }
+    }
+
+    //统一按钮回调
+    @SuppressLint("NonConstantResourceId")
+    public void callbackEditor(View v){
+        setNewTiming();
+        switch (v.getId()) {
+
+            case R.id.et_unit_code:
+
+                checkUnitCode();
+                break;
+
+            default:
+        }
+
+    }
+
+    /**
+     * 统一设置Edit监听
+     * @param  list
+     */
+    public void unifyEdit(List<EditText> list){
+        for (int i=0;i<list.size();i++){
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout)editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    //XLog.e("actionId:"+actionId);
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE   ) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v,true);
+                            showWarningToast(v.getHint().toString());
+                            return false;
+                        }else{
+                            setEditTextNormal(v,true);
+                        }
+
+                        callbackEditor(v);
+
+                        return false;
+                    }
+                    return false;
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view=getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if(view instanceof EditText){
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout)currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0  ) {
+
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText!=null){
+                            setEditTextNormal(currentEditText,true);
+                        }
+
+                    } else {
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText!=null && isRequiredShow){
+                            setEditTextFocused(currentEditText,true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton !=null ){
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type){
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult){
+        //获取焦点的view对象
+        View view=getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if(view instanceof EditText)
+        {
+            ((EditText) view).setText(scanResult);
+            showSuccessToast("扫描成功");
+            callbackEditor(view);
+        }
+    }
+
+
+    //检查是否存在上传
+    private void checkIsUpload(){
+        int awaitNum = asyncPictureUpload.getAwaitNum();
+        if (currentUploadStatus  && awaitNum>0){
+            operateStartUpload();
+        }
+    }
+
+
+
+
+
+    //设置返回
+    private void setRequestResult(){
+        tallyDataList.clear();
+        tallyDataList = trayMakeBean.getZuijinNums();
+
+
+        mtOperateNumber.setText(String.valueOf(trayMakeBean.getHasDoDui()));
+        mtTrackingNumber.setText(trayMakeBean.getTrackingNumber());
+
+
+        mtContentsNumber.setText(String.valueOf(trayMakeBean.getBenBoxQty()));
+        mtBoxNumber.setText(trayMakeBean.getBoxNumber());
+
+        llBoxNumber.setVisibility(View.VISIBLE);
+        llContentsNumber.setVisibility(View.VISIBLE);
+        mAdapter.setNewData(tallyDataList);
+        mAdapter.notifyDataSetChanged();
+    }
+
+
+    private void checkUnitCode(){
+        checkIsUpload();
+        if (etUnitCode.getText().toString().isEmpty()){
+            showErrorToast(etUnitCode.getHint().toString());
+            return;
+        }
+
+        Gson gson = new Gson();
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+        math.put("box_number",trayMakeBean.getBoxNumber().trim());
+        math.put("unit_code",etUnitCode.getText().toString().trim());
+        math.put("is_check",1);
+        math.put("ab_img_id",abImgId);
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET_BOX_UNIT).upJson(gson.toJson(math))
+                .execute(new MyDialogCallback(this, true, false) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            trayMakeBean = new TrayMakeBean();
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trayMakeBean =  JsonUtil.jsonString2Bean(bean.data,TrayMakeBean.class);
+                                setRequestResult();
+                            }
+                            String voiceName = trayMakeBean.getVoiceName();
+
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg,voiceName);
+                                initFinish();
+                            }else{
+                                showWarningToast(bean.msg,voiceName);
+                            }
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("第二步确认错误",e.getMessage());
+                        }
+                    }
+                });
+
+    }
+
+
+
+
+
+
+    //提交内件码
+    private void finishInbound(){
+        isRequiredShow = true;
+        if (!validate()){
+            return;
+        }
+
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN).upJson(postParam)
+                .execute(new MyDialogCallback(this, true, false) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+                        try {
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg);
+                                if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                    trayMakeBean =  JsonUtil.jsonString2Bean(bean.data,TrayMakeBean.class);
+                                    setRequestResult();
+
+                                }
+
+
+                                initFinish();
+                            }else{
+                                showWarningToast(bean.msg);
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("添加开箱拆柜数据结果返回错误",e.getMessage());
+                        }
+                    }
+                });
+
+     }
+
+
+    private void initFinish(){
+        etUnitCode.setText("");
+        etUnitCode.requestFocus();
+        llConfirm.setVisibility(View.VISIBLE);
+    }
+
+    /*
+     * 校验必录
+     */
+    private boolean validate(){
+
+        if (etUnitCode.getText().toString().isEmpty()){
+            showWarningToast(etUnitCode.getHint().toString());
+            return  false;
+        }
+
+        try {
+            postParam = new JSONObject();
+            Gson gson = new Gson();
+
+
+            postParam.put("box_number",trayMakeBean.getBoxNumber().trim());
+            postParam.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+            postParam.put("unit_code",etUnitCode.getText().toString().trim());
+            postParam.put("is_check",1);
+            postParam.put("ab_img_id",abImgId);
+        } catch (JSONException e) {
+            showWarningToast("系统异常"+e.getMessage());
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+
+
+
+    //sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
+    @SuppressLint("NonConstantResourceId")
+    @OnClick({R.id.btn_confirm})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            case R.id.btn_confirm:
+                Intent intent = new Intent();
+                setResult(200, intent);//返回值,2 是改返回的标志,也会返回
+                showSuccessToast("success");
+                intent.putExtra("data",(new Gson()).toJson(trayMakeBean));
+                finish();
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    private void operateStopUpload(){
+        if (currentUploadStatus){
+            asyncPictureUpload.setStopUpload();
+        }
+    }
+    private void operateStartUpload(){
+        if (!currentUploadStatus){
+            asyncPictureUpload.setStartUpload();
+        }
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+        asyncPictureUpload.removeHandler();
+
+        // 确保清除所有的回调以防止内存泄漏
+        workHandler.removeCallbacks(idleRunnable);
+        super.onDestroy();
+    }
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast==0){
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            }else{
+                unregisterReceiver(mReceiver);
+            }
+        }catch (Exception e){
+            XLog.e("销毁广播失败:",e.getMessage());
+        }
+    }
+
+}

+ 561 - 0
app/src/main/java/com/fxy/detection/TrayMakeMainActivity.java

@@ -0,0 +1,561 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.qrcode.ActivityScanerCode;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.detection.bean.TrackingBoxBean;
+import com.fxy.detection.bean.TrayMakeBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.fxy.view.FloatingImageView;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class TrayMakeMainActivity extends BaseActivity implements StoJNI.ScanCallBack {
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+
+    //单号
+    @BindView(R.id.et_tracking_number)
+    EditText etTrackingNumber;
+
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+    //浮动按钮
+    @BindView(R.id.iv_drag)
+    FloatingImageView iv_drag;
+    
+
+    private Unbinder unbinder;
+    
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_tray_make;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+
+    }
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == 200 && resultCode == 200)//之前提到的两个标志,在这里显示出了作用
+        {
+            clearData();
+        }
+    }
+
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+        if (event != null && event.getEventCode() == EventCode.displacement_refresh) {
+
+        }
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("托盘清点");
+
+        initAdapter();
+        initData();
+        initEdit();
+        //监听浮动按钮
+        iv_drag.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (!iv_drag.isDrag()) {
+                    ActivityScanerCode.setScanerListener(mScanerListener);
+                    ActivityScanerCode.intent2Activity(mContext, BaseConfig.COMMON_SCANNER_ONLY);
+                }
+            }
+        });
+
+
+
+    }
+
+
+    private void initData() {
+
+    }
+
+    private void initAdapter() {
+
+
+    }
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+//        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+//            //按确定键
+//            if(validate()){
+//                doPutIn();
+//            }
+//            return true;
+//        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        //XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast() == 0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode) == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()) {
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult == null) {
+                return;
+            }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()) {
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            } else {
+                scanStatus = scanResult.isEmpty() ? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()) {
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)) {
+                setScanResult(scanResult);
+            } else {
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver() {
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast == 1) {
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            } else {
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()) {
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        } catch (Exception e) {
+            showErrorToast("获取扫码配置失败" + e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+
+    //统一按钮回调
+    public void callbackEditor(View v) {
+        switch (v.getId()) {
+            case R.id.et_tracking_number:
+                checkInboundPallet();
+                break;
+
+            default:
+        }
+    }
+
+    private void initEdit() {
+        List<EditText> list = new ArrayList<>();
+        list.add(etTrackingNumber);
+        unifyEdit(list);
+    }
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type) {
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult) {
+        //获取焦点的view对象
+        View view = getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if (view instanceof EditText) {
+            ((EditText) view).setText(scanResult);
+            //执行回调
+            callbackEditor(view);
+        }
+    }
+
+
+    /**
+     * 检查托盘
+     */
+    private void checkInboundPallet() {
+        if (!checkNull(etTrackingNumber)) {
+            setEditTextFocused(etTrackingNumber, true);
+            showWarningToast(etTrackingNumber.getHint().toString());
+            return ;
+        }
+        String postJson = formatParam();
+        if (!checkRepeat(Urls.FXY_DETECTION_PALLET + (postJson))) {
+            return;
+        }
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET).upJson(postJson)
+                .execute(new MyDialogCallback(this, true, true) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+                        try {
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+
+                            TrayMakeBean trayMakeBean = new TrayMakeBean();
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trayMakeBean =  JsonUtil.jsonString2Bean(bean.data,TrayMakeBean.class);
+                            }
+
+                            final Bundle bundle = new Bundle();
+                            bundle.putString("data",bean.data);
+
+                            if (trayMakeBean.getNeedConfirm().equals("Y")){
+                                new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                                        .setMessage(trayMakeBean.getConfirmMsg())
+                                        .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                dialogInterface.dismiss();
+                                                etTrackingNumber.selectAll();
+                                            }
+                                        }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+
+                                    @Override
+                                    public void onClick(DialogInterface dialogInterface, int i) {
+                                        intentPageResult(TrayMakeMainActivity.this, TrayMakeSecondMainActivity.class, bundle,200);
+                                    }
+                                }).show();
+                            }else{
+                                String voiceName = trayMakeBean.getVoiceName();
+                                if(bean.code == 1){
+                                    showSuccessToast(bean.msg,voiceName);
+                                    intentPageResult(TrayMakeMainActivity.this, TrayMakeSecondMainActivity.class, bundle,200);
+                                }else{
+                                    showWarningToast(bean.msg,voiceName);
+                                }
+                            }
+
+
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("请求返回箱号检查错误", e.getMessage());
+                        }
+                    }
+                });
+    }
+
+    /**
+     * 完成
+     */
+    private void finished() {
+        clearData();
+    }
+
+
+    private String formatParam() {
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.put("tracking_number", etTrackingNumber.getText().toString().trim());
+            jsonObject.put("is_check", 1);
+        } catch (Exception e) {
+            e.printStackTrace();
+            XLog.e("组装数据失败");
+        }
+        return jsonObject.toString();
+    }
+
+
+
+    //清除订单信息
+    private void clearData() {
+        etTrackingNumber.setText("");
+        setEditTextNormal(etTrackingNumber, true);
+        etTrackingNumber.requestFocus();
+    }
+
+    @OnClick({})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            default:
+                break;
+        }
+    }
+
+    /**
+     * 统一设置Edit监听
+     *
+     * @param list
+     */
+    public void unifyEdit(List<EditText> list) {
+        for (int i = 0; i < list.size(); i++) {
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout) editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    XLog.e("actionId:" + actionId);
+                    if (event != null) {
+                        XLog.e("KeyCode:" + event.getKeyCode() + "--ActionCode:" + event.getAction());
+                    }
+
+                    //|| (actionId == KeyEvent.ACTION_DOWN && event.getKeyCode()==KeyEvent.KEYCODE_ENTER )
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE ||
+                            (actionId == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v, true);
+                            showWarningToast(v.getHint().toString());
+                            return true;
+                        } else {
+                            setEditTextNormal(v, true);
+                        }
+                        callbackEditor(v);
+                        return false;
+                    }
+                    return false;
+
+                    //返回true,保留软键盘。false,隐藏软键盘
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view = getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if (view instanceof EditText) {
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout) currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0) {
+
+                        if (currentImage != null) {
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText != null) {
+                            setEditTextNormal(currentEditText, true);
+                        }
+
+                    } else {
+                        if (currentImage != null) {
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText != null) {
+                            setEditTextFocused(currentEditText, true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton != null) {
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+
+
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast == 0) {
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            } else {
+                unregisterReceiver(mReceiver);
+            }
+        } catch (Exception e) {
+            XLog.e("销毁广播失败:", e.getMessage());
+        }
+    }
+
+
+}

+ 744 - 0
app/src/main/java/com/fxy/detection/TrayMakeSecondMainActivity.java

@@ -0,0 +1,744 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.views.MarqueeTextView;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureUpload;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.detection.bean.TakePictureBean;
+import com.fxy.detection.bean.TrackingBoxBean;
+import com.fxy.detection.bean.TrayMakeBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.luck.picture.lib.config.PictureConfig;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class TrayMakeSecondMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
+
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+
+    @BindView(R.id.ll_label_picture)
+    LinearLayout llLabelPicture;
+    //拍照区域
+    @BindView(R.id.ll_camera_picture_module)
+    LinearLayout llCameraPictureModule;
+
+    @BindView(R.id.mt_tracking_number)
+    MarqueeTextView mtTrackingNumber;
+
+    @BindView(R.id.mt_operate_number)
+    MarqueeTextView mtOperateNumber;
+
+
+
+    @BindView(R.id.ll_await_num)
+    LinearLayout llAwaitNum;
+
+    @BindView(R.id.tv_await_num)
+    TextView tvAwaitNum;
+
+
+    private HashMap<String, Object> postData  = new HashMap<>();
+
+    private HashMap<String, AsyncPictureSelector> mapPictureSelector = new HashMap<>();
+
+    private List<TakePictureBean> takePictureBeanList = new ArrayList<>();
+    private AsyncPictureUpload asyncPictureUpload = new AsyncPictureUpload(this);
+
+    private TrayMakeBean trayMakeBean;
+
+    private String currentPictureType= "stack_img";
+
+    private boolean currentUploadStatus = false;
+
+    //
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+
+    private boolean showWeightImg = false;
+
+    private boolean isRequiredShow = false;
+
+    private  ArrayList<String> baseImgList = new ArrayList<>();
+    protected String action;
+
+
+    private Unbinder unbinder;
+
+    private JSONObject postParam = new JSONObject();
+
+    private int leisure = 10;
+
+
+    private Handler workHandler;
+    private Runnable idleRunnable;
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_tray_make_second;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+        //XLog.e("接收数据解析:",bundle);
+        trayMakeBean = JsonUtil.jsonString2Bean(bundle.getString("data"), TrayMakeBean.class);
+    }
+
+
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (resultCode == RESULT_OK) {
+            // 图片选择结果回调
+            if (requestCode == PictureConfig.CHOOSE_REQUEST) {
+                if (mapPictureSelector.containsKey(currentPictureType)){
+                    mapPictureSelector.get(currentPictureType).setNotifyParam(getNotifyParam());
+                    mapPictureSelector.get(currentPictureType).getSelectImg(data);
+                }
+                totalAwaitNum();
+                setNewTiming();
+                for (int i=0;i<takePictureBeanList.size();i++){
+                    int num = takePictureBeanList.get(i).getNumber();
+                    String field = takePictureBeanList.get(i).getField();
+                    int has = mapPictureSelector.get(field).getOssPhotoList().size();
+                    if (has < num ){
+                        mapPictureSelector.get(field).authCamera();
+                        return;
+                    }
+                }
+
+                if (mapPictureSelector.get("stack_img").getOssPhotoList().size()>0){
+                    //页面跳转
+                    submitLabelImg();
+                }else{
+                    llLabelPicture.setVisibility(View.VISIBLE);
+                }
+
+            }
+        }
+
+        if (requestCode == 200 && resultCode == 200)//之前提到的两个标志,在这里显示出了作用
+        {
+            if (data.hasExtra("data") && !data.getStringExtra("data").isEmpty()){
+                trayMakeBean = JsonUtil.jsonString2Bean(data.getStringExtra("data"), TrayMakeBean.class);
+                setRequestResult();
+            }
+
+
+            initFinish();
+        }
+
+
+    }
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+
+        assert event != null;
+        switch (event.getEventCode()){
+            case EventCode.picture_selector_lister:
+                currentPictureType = event.getData().toString();
+                break;
+            case EventCode.file_upload_lister:
+                totalAwaitNum();
+                break;
+        }
+
+
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("托盘清点");
+
+        setRequestResult();
+        setCameraPicture();
+        initEdit();
+        iniData();
+        RecyclerView rvLabelShowImg = (RecyclerView)llLabelPicture.findViewById(R.id.rv_show_img);
+        mapPictureSelector.put("stack_img",setItemPicture("stack_img",rvLabelShowImg,9));
+
+
+        totalAwaitNum();
+
+        workHandler = new Handler(Looper.getMainLooper());
+        // 定义空闲任务
+        idleRunnable = new Runnable() {
+            @Override
+            public void run() {
+                // 执行空闲后的操作
+                operateStartUpload();
+            }
+        };
+
+        SPCache spCache = SPCache.getInstance(this);
+        leisure = spCache.getLeisure();
+
+        // 初始化时设置计时器
+        workHandler.postDelayed(idleRunnable, leisure * 60 * 1000);
+    }
+
+
+    private void setNewTiming(){
+        try {
+            // 取消之前的计时器
+            workHandler.removeCallbacks(idleRunnable);
+            // 重新计时
+            workHandler.postDelayed(idleRunnable, leisure * 60 * 1000); // 2 分钟
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+    }
+
+
+    //设置返回
+    private void setRequestResult(){
+        takePictureBeanList = trayMakeBean.getNeedPhoto();
+        llCameraPictureModule.setVisibility(View.VISIBLE);
+
+        mtOperateNumber.setText(String.valueOf(trayMakeBean.getHasDoDui()));
+        mtTrackingNumber.setText(trayMakeBean.getTrackingNumber());
+     }
+
+    private void setCameraPicture(){
+        llCameraPictureModule.removeAllViews();;
+        for (int i=0;i<takePictureBeanList.size();i++){
+            TakePictureBean takePictureBean = takePictureBeanList.get(i);
+            addPictureSelectorUpload(llCameraPictureModule,takePictureBean);
+        }
+    }
+
+    public void addPictureSelectorUpload(LinearLayout linearLayout, TakePictureBean takePictureBean){
+        View itemPictureSelector = View.inflate(mContext, R.layout.item_picture_selector, null);
+        TextView tvPicturesTitle = itemPictureSelector.findViewById(R.id.tv_pictures_title);
+        tvPicturesTitle.setText(takePictureBean.getTitle());
+        RecyclerView rvLabelShowImg = (RecyclerView)itemPictureSelector.findViewById(R.id.recyclerview);
+        linearLayout.addView(itemPictureSelector);
+        AsyncPictureSelector tmpPictureSelector  = setItemPicture(takePictureBean.getField(),rvLabelShowImg,takePictureBean.getNumber());
+        mapPictureSelector.put(takePictureBean.getField(),tmpPictureSelector);
+    }
+
+    /**
+     * 设置多个上传文件
+     * @param uploadType String
+     * @param showImg RecyclerView
+     */
+    private AsyncPictureSelector setItemPicture(String uploadType,RecyclerView showImg,int num){
+
+        String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
+        AsyncPictureSelector pictureUpload = new AsyncPictureSelector(TrayMakeSecondMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
+        pictureUpload.setUploadType(uploadType);
+        pictureUpload.setCompress(true,100,100);
+        pictureUpload.setOnlyCamera(true);
+        pictureUpload.setMaxSelectNum(num);
+
+        return  pictureUpload;
+    }
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode()==KeyEvent.KEYCODE_ENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+            //按确定键
+
+        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    public HashMap<String, Object> getNotifyParam(){
+        postData.put("is_check",1);
+        postData.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+        return postData;
+    }
+
+
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast()==0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode)  == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()){
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult==null){return; }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()){
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            }else{
+                scanStatus = scanResult.isEmpty()? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()){
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)){
+                setScanResult(scanResult);
+            }else{
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver(){
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast ==1){
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            }else{
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()){
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        }catch (Exception e) {
+            showErrorToast("获取扫码配置失败"+e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+    private void initEdit() {
+
+    }
+
+
+    private void iniData(){
+        baseImgList.add("stack_img");
+    }
+
+    //getAwaitNum
+    private void totalAwaitNum(){
+        int awaitNum = asyncPictureUpload.getAwaitNum();
+        tvAwaitNum.setText(String.valueOf(awaitNum));
+        if (awaitNum == 0){
+            operateStopUpload();
+        }
+    }
+
+    //统一按钮回调
+    @SuppressLint("NonConstantResourceId")
+    public void callbackEditor(View v){
+        setNewTiming();
+        switch (v.getId()) {
+
+            default:
+        }
+
+    }
+
+    /**
+     * 统一设置Edit监听
+     * @param  list
+     */
+    public void unifyEdit(List<EditText> list){
+        for (int i=0;i<list.size();i++){
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout)editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    //XLog.e("actionId:"+actionId);
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE   ) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v,true);
+                            showWarningToast(v.getHint().toString());
+                            return false;
+                        }else{
+                            setEditTextNormal(v,true);
+                        }
+
+                        callbackEditor(v);
+
+                        return false;
+                    }
+                    return false;
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view=getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if(view instanceof EditText){
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout)currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0  ) {
+
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText!=null){
+                            setEditTextNormal(currentEditText,true);
+                        }
+
+                    } else {
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText!=null && isRequiredShow){
+                            setEditTextFocused(currentEditText,true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton !=null ){
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type){
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult){
+        //获取焦点的view对象
+        View view=getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if(view instanceof EditText)
+        {
+            ((EditText) view).setText(scanResult);
+            showSuccessToast("扫描成功");
+            callbackEditor(view);
+        }
+    }
+
+
+    //检查是否存在上传
+    private void checkIsUpload(){
+
+    }
+
+
+
+    //提交面单信息
+    private void submitLabelImg(){
+        checkIsUpload();
+
+
+        Gson gson = new Gson();
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+
+        //面单
+        List<String> stringList = mapPictureSelector.get("stack_img").getOssPhotoList();
+        if (stringList.size()==0){
+            showWarningToast("面单照片不能为空");
+            return;
+        }
+        math.put("stack_img_tag",mapPictureSelector.get("stack_img").getUniqueTag());
+        math.put("stack_img",gson.toJson(stringList));
+        math.put("is_check",1);
+        //拍照
+        if (takePictureBeanList.size()>0){
+
+            Map<String,Object> otherImg = new HashMap<>();
+            for (int i=0; i < takePictureBeanList.size();i++){
+                String name = takePictureBeanList.get(i).getField();
+                if (!mapPictureSelector.containsKey(name) ){
+                    showErrorToast("页面渲染异常,请更新操作");
+                }
+
+                List<String> tmpList = mapPictureSelector.get(name).getOssPhotoList();
+                if (tmpList.size() == 0){
+                    showWarningToast("请上传".concat(takePictureBeanList.get(i).getTitle()).concat("拍照"));
+                }
+                otherImg.put(name,gson.toJson(tmpList));
+            }
+            math.put("other_img",gson.toJson(otherImg));
+        }
+
+
+
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET_STACK_IMG).upJson(gson.toJson(math))
+                .execute(new MyDialogCallback(this, true, false) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trayMakeBean =  JsonUtil.jsonString2Bean(bean.data,TrayMakeBean.class);
+                            }
+
+                            String voiceName = trayMakeBean.getVoiceName();
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg,voiceName);
+                                Bundle bundle = new Bundle();
+                                bundle.putString("data",bean.data);
+                                intentPageResult(TrayMakeSecondMainActivity.this, TrayMakeThirdMainActivity.class, bundle,200);
+
+                            }else{
+                                showWarningToast(bean.msg,voiceName);
+                            }
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("第二步确认错误",e.getMessage());
+                        }
+                    }
+                });
+
+    }
+
+    private void initFinish(){
+
+        for (int i=0;i<baseImgList.size();i++){
+            if (mapPictureSelector.containsKey(baseImgList.get(i))){
+                mapPictureSelector.get(baseImgList.get(i)).emptyRemake();
+            }
+        }
+        for (int n=0;n<takePictureBeanList.size();n++){
+            String tmpKey = takePictureBeanList.get(n).getField();
+            if (mapPictureSelector.containsKey(tmpKey) ){
+                mapPictureSelector.get(tmpKey).emptyRemake();
+            }
+        }
+    }
+
+
+
+    //sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
+    @OnClick({R.id.btn_confirm})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            case R.id.btn_confirm:
+                Intent intent = new Intent();
+                setResult(200, intent);//返回值,2 是改返回的标志,也会返回
+                showSuccessToast("success");
+                finish();
+                break;
+            default:
+                break;
+        }
+    }
+
+    private void operateStopUpload(){
+        if (currentUploadStatus){
+            asyncPictureUpload.setStopUpload();
+        }
+    }
+    private void operateStartUpload(){
+        if (!currentUploadStatus){
+            asyncPictureUpload.setStartUpload();
+        }
+    }
+
+
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+
+        asyncPictureUpload.removeHandler();
+        // 确保清除所有的回调以防止内存泄漏
+        workHandler.removeCallbacks(idleRunnable);
+        super.onDestroy();
+    }
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast==0){
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            }else{
+                unregisterReceiver(mReceiver);
+            }
+        }catch (Exception e){
+            XLog.e("销毁广播失败:",e.getMessage());
+        }
+    }
+
+}

+ 561 - 0
app/src/main/java/com/fxy/detection/TrayMakeThirdMainActivity.java

@@ -0,0 +1,561 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.qrcode.ActivityScanerCode;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.baselibrary.views.MarqueeTextView;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.detection.bean.TrayMakeBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.fxy.view.FloatingImageView;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class TrayMakeThirdMainActivity extends BaseActivity implements StoJNI.ScanCallBack {
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+
+    //单号
+    @BindView(R.id.et_order_number)
+    EditText etOrderNumber;
+
+    @BindView(R.id.mt_tracking_number)
+    MarqueeTextView mtTrackingNumber;
+
+    @BindView(R.id.mt_operate_number)
+    MarqueeTextView mtOperateNumber;
+
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+    //浮动按钮
+    @BindView(R.id.iv_drag)
+    FloatingImageView iv_drag;
+    
+
+    private Unbinder unbinder;
+
+    private TrayMakeBean trayMakeBean;
+    private int abImgId = 0;
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_tray_make_third;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+        trayMakeBean = JsonUtil.jsonString2Bean(bundle.getString("data"), TrayMakeBean.class);
+        assert trayMakeBean != null;
+        abImgId = trayMakeBean.getAbImgId();
+    }
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == 200 && resultCode == 200)//之前提到的两个标志,在这里显示出了作用
+        {
+            if (data.hasExtra("data") && !data.getStringExtra("data").isEmpty()){
+                trayMakeBean = JsonUtil.jsonString2Bean(data.getStringExtra("data"), TrayMakeBean.class);
+                setRequestResult();
+            }
+            clearData();
+        }
+    }
+
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+        if (event != null && event.getEventCode() == EventCode.displacement_refresh) {
+
+        }
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("托盘清点");
+
+        setRequestResult();
+        initAdapter();
+        initData();
+        initEdit();
+        //监听浮动按钮
+        iv_drag.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (!iv_drag.isDrag()) {
+                    ActivityScanerCode.setScanerListener(mScanerListener);
+                    ActivityScanerCode.intent2Activity(mContext, BaseConfig.COMMON_SCANNER_ONLY);
+                }
+            }
+        });
+
+
+
+    }
+
+
+    //设置返回
+    private void setRequestResult(){
+
+        mtOperateNumber.setText(String.valueOf(trayMakeBean.getHasDoDui()));
+        mtTrackingNumber.setText(trayMakeBean.getTrackingNumber());
+    }
+
+
+    private void initData() {
+
+    }
+
+    private void initAdapter() {
+
+
+    }
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+//        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+//            //按确定键
+//            if(validate()){
+//                doPutIn();
+//            }
+//            return true;
+//        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        //XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast() == 0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode) == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()) {
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult == null) {
+                return;
+            }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()) {
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            } else {
+                scanStatus = scanResult.isEmpty() ? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()) {
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)) {
+                setScanResult(scanResult);
+            } else {
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver() {
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast == 1) {
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            } else {
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()) {
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        } catch (Exception e) {
+            showErrorToast("获取扫码配置失败" + e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+
+    //统一按钮回调
+    public void callbackEditor(View v) {
+        switch (v.getId()) {
+            case R.id.et_order_number:
+                getPalletBox();
+                break;
+
+            default:
+        }
+    }
+
+    private void initEdit() {
+        List<EditText> list = new ArrayList<>();
+        list.add(etOrderNumber);
+        unifyEdit(list);
+    }
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type) {
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult) {
+        //获取焦点的view对象
+        View view = getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if (view instanceof EditText) {
+            ((EditText) view).setText(scanResult);
+            //执行回调
+            callbackEditor(view);
+        }
+    }
+
+
+    //获取跟踪单号
+    private void getPalletBox(){
+
+
+        if (etOrderNumber.getText().toString().isEmpty()){
+            showErrorToast(etOrderNumber.getHint().toString());
+            return;
+        }
+
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",trayMakeBean.getTrackingNumber().trim());
+        math.put("box_number",etOrderNumber.getText().toString().trim());
+        math.put("is_check",1);
+        math.put("ab_img_id",abImgId);
+
+        String mathJson = (new Gson()).toJson(math);
+
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET_BOX).upJson(mathJson)
+                .execute(new MyDialogCallback(this, true, true) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            JSONObject result = new JSONObject();
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                result =  new JSONObject(bean.data);
+                            }
+
+                            String voiceName = result.has("voice_name") ? result.getString("voice_name"):"";
+                            Bundle bundle = new Bundle();
+                            bundle.putString("data",result.toString());
+                            bundle.putInt("ab_img_id",abImgId);
+
+
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg,voiceName);
+                                intentPageResult(TrayMakeThirdMainActivity.this, TrayMakeFourMainActivity.class, bundle,200);
+
+                            }else{
+                                showWarningToast(bean.msg,voiceName);
+                            }
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("确认错误",e.getMessage());
+                        }
+
+                    }
+                });
+
+
+    }
+
+
+
+
+    //清除订单信息
+    private void clearData() {
+        etOrderNumber.setText("");
+        setEditTextNormal(etOrderNumber, true);
+        etOrderNumber.requestFocus();
+    }
+
+    @OnClick({R.id.btn_confirm})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            case R.id.btn_confirm:
+                Intent intent = new Intent();
+                setResult(200, intent);//返回值,2 是改返回的标志,也会返回
+                showSuccessToast("success");
+                intent.putExtra("data",(new Gson()).toJson(trayMakeBean));
+                finish();
+                break;
+            default:
+                break;
+        }
+    }
+
+    /**
+     * 统一设置Edit监听
+     *
+     * @param list
+     */
+    public void unifyEdit(List<EditText> list) {
+        for (int i = 0; i < list.size(); i++) {
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout) editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    XLog.e("actionId:" + actionId);
+                    if (event != null) {
+                        XLog.e("KeyCode:" + event.getKeyCode() + "--ActionCode:" + event.getAction());
+                    }
+
+                    //|| (actionId == KeyEvent.ACTION_DOWN && event.getKeyCode()==KeyEvent.KEYCODE_ENTER )
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE ||
+                            (actionId == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v, true);
+                            showWarningToast(v.getHint().toString());
+                            return true;
+                        } else {
+                            setEditTextNormal(v, true);
+                        }
+                        callbackEditor(v);
+                        return false;
+                    }
+                    return false;
+
+                    //返回true,保留软键盘。false,隐藏软键盘
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view = getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if (view instanceof EditText) {
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout) currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0) {
+
+                        if (currentImage != null) {
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText != null) {
+                            setEditTextNormal(currentEditText, true);
+                        }
+
+                    } else {
+                        if (currentImage != null) {
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText != null) {
+                            setEditTextFocused(currentEditText, true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton != null) {
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+
+
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast == 0) {
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            } else {
+                unregisterReceiver(mReceiver);
+            }
+        } catch (Exception e) {
+            XLog.e("销毁广播失败:", e.getMessage());
+        }
+    }
+
+
+}

+ 775 - 0
app/src/main/java/com/fxy/detection/TrayPutInMainActivity.java

@@ -0,0 +1,775 @@
+package com.fxy.detection;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.support.v7.widget.RecyclerView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.R;
+import com.fxy.baselibrary.base.BaseActivity;
+import com.fxy.baselibrary.bean.BaseEventBusBean;
+import com.fxy.baselibrary.interfaces.OnRxScanerListener;
+import com.fxy.baselibrary.util.JsonUtil;
+import com.fxy.bean.ActionBean;
+import com.fxy.bean.ScanBean;
+import com.fxy.common.AsyncPictureSelector;
+import com.fxy.common.AsyncPictureUpload;
+import com.fxy.constant.BaseConfig;
+import com.fxy.constant.EventCode;
+import com.fxy.constant.SPCache;
+import com.fxy.detection.bean.TakePictureBean;
+import com.fxy.detection.bean.TrackingBoxBean;
+import com.fxy.net.MyDialogCallback;
+import com.fxy.net.Urls;
+import com.google.gson.Gson;
+import com.google.zxing.Result;
+import com.luck.picture.lib.config.PictureConfig;
+import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import sto.android.app.StoJNI;
+import sto.android.app.StoPdaKeyEvent;
+import sto.android.app.StoTongJNI;
+
+public class TrayPutInMainActivity extends  BaseActivity implements StoJNI.ScanCallBack{
+
+    /**
+     * 列表适配器
+     */
+    Context mContext = this;
+
+    @BindView(R.id.et_tracking_number)
+    EditText etTrackingNumber;
+
+
+    @BindView(R.id.ll_label_picture)
+    LinearLayout llLabelPicture;
+
+
+    @BindView(R.id.ll_await_num)
+    LinearLayout llAwaitNum;
+
+    @BindView(R.id.tv_await_num)
+    TextView tvAwaitNum;
+
+
+    private HashMap<String, Object> postData  = new HashMap<>();
+
+    private HashMap<String, AsyncPictureSelector> mapPictureSelector = new HashMap<>();
+
+    private AsyncPictureUpload asyncPictureUpload = new AsyncPictureUpload(this);
+
+    private TrackingBoxBean trackingBoxBean;
+
+    private String currentPictureType= "label_img";
+
+    private boolean currentUploadStatus = false;
+
+    //
+    //扫码扫码动作
+    private ScanBean scanBean;
+
+
+    private boolean showWeightImg = false;
+
+    private boolean isRequiredShow = false;
+
+    private  ArrayList<String> baseImgList = new ArrayList<>();
+    protected String action;
+
+
+    private Unbinder unbinder;
+
+    private JSONObject postParam = new JSONObject();
+
+    private int leisure = 10;
+
+
+    private Handler workHandler;
+    private Runnable idleRunnable;
+
+    @Override
+    public int getContentViewResId() {
+        return R.layout.activity_fxy_detection_tray_putin;
+    }
+
+    @Override
+    public boolean showToolBar() {
+        return true;
+    }
+
+    @Override
+    public boolean openEventBus() {
+        return true;
+    }
+
+    @Override
+    protected void getBundleExtras(Bundle bundle) {
+        //XLog.e("接收数据解析:",bundle);
+    }
+
+
+
+    //finish的返回监听
+    //这里的requestCode参数,就是上面设置的 1 ,当跳转的页面返回的时候,通过这个加以判断
+    //resultCode ,这个参数是在跳转的页面里面规定的,它也是一个int类型的标志
+    //第三个参数包含了返回的值
+    //如果不需要所跳转的页面返回值,也就不需要这个方法了
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        if (resultCode == RESULT_OK) {
+            // 图片选择结果回调
+            if (requestCode == PictureConfig.CHOOSE_REQUEST) {
+                if (mapPictureSelector.containsKey(currentPictureType)){
+                    mapPictureSelector.get(currentPictureType).setNotifyParam(getNotifyParam());
+                    mapPictureSelector.get(currentPictureType).getSelectImg(data);
+                }
+                totalAwaitNum();
+                setNewTiming();
+
+
+
+            }
+        }
+
+        if (requestCode == 200 && resultCode == 200)//之前提到的两个标志,在这里显示出了作用
+        {
+            initFinish();
+        }
+
+
+    }
+
+    /**
+     * EventBus接收信息的方法,开启后才会调用(非粘性事件)
+     *
+     * @param event
+     */
+    @Override
+    protected void EventBean(BaseEventBusBean event) {
+//        XLog.e("----------接收返回--------------");
+//        XLog.e("接收返回:"+event.getEventCode());
+
+        assert event != null;
+        switch (event.getEventCode()){
+            case EventCode.picture_selector_lister:
+                currentPictureType = event.getData().toString();
+                break;
+            case EventCode.file_upload_lister:
+                totalAwaitNum();
+                break;
+        }
+
+
+    }
+
+    @Override
+    public boolean isPlayMusic() {
+        return true;
+    }
+
+
+    @Override
+    protected void initView() {
+        unbinder = ButterKnife.bind(this);
+        setTitleName("托盘入库");
+
+        initEdit();
+        iniData();
+        RecyclerView rvLabelShowImg = (RecyclerView)llLabelPicture.findViewById(R.id.rv_show_img);
+        mapPictureSelector.put("label_img",setItemPicture("label_img",rvLabelShowImg,20));
+
+
+        totalAwaitNum();
+
+        workHandler = new Handler(Looper.getMainLooper());
+        // 定义空闲任务
+        idleRunnable = new Runnable() {
+            @Override
+            public void run() {
+                // 执行空闲后的操作
+                operateStartUpload();
+            }
+        };
+
+        SPCache spCache = SPCache.getInstance(this);
+        leisure = spCache.getLeisure();
+
+        // 初始化时设置计时器
+        workHandler.postDelayed(idleRunnable, leisure * 60 * 1000);
+    }
+
+
+    private void setNewTiming(){
+        try {
+            // 取消之前的计时器
+            workHandler.removeCallbacks(idleRunnable);
+            // 重新计时
+            workHandler.postDelayed(idleRunnable, leisure * 60 * 1000); // 2 分钟
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+    }
+
+
+
+    /**
+     * 设置多个上传文件
+     * @param uploadType String
+     * @param showImg RecyclerView
+     */
+    private AsyncPictureSelector setItemPicture(String uploadType,RecyclerView showImg,int num){
+
+        String notifyUrl = Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PUTIN;
+        AsyncPictureSelector pictureUpload = new AsyncPictureSelector(TrayPutInMainActivity.this,showImg,"detection",uploadType,notifyUrl,false);
+        pictureUpload.setUploadType(uploadType);
+        pictureUpload.setCompress(true,100,100);
+        pictureUpload.setOnlyCamera(true);
+        pictureUpload.setMaxSelectNum(num);
+
+        return  pictureUpload;
+    }
+
+
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        //XLog.e("event:"+event.getKeyCode());
+        if ((event.getKeyCode()==KeyEvent.KEYCODE_DPAD_CENTER || event.getKeyCode()==KeyEvent.KEYCODE_ENTER )  && event.getAction() == KeyEvent.ACTION_DOWN){
+            //按确定键
+
+        }
+        return super.dispatchKeyEvent(event);
+    }
+
+    public HashMap<String, Object> getNotifyParam(){
+        postData.put("tracking_number",etTrackingNumber.getText().toString().trim());
+        return postData;
+    }
+
+
+
+    //监听按键
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        XLog.e("监听按键:"+keyCode);XLog.e(event);
+        if (scanBean.getIsBroadcast()==0 && StoTongJNI.getIns(mContext).getEventFuction(keyCode)  == StoPdaKeyEvent.KEYCODE_SCAN
+                && event.getRepeatCount() == 0) {
+
+            if (StoTongJNI.getIns(mContext).GetScannerIsScanning()) {
+//
+            } else {
+                StoTongJNI.getIns(mContext).SetScannerStart();
+            }
+        }
+        return super.onKeyDown(keyCode, event);
+    }
+
+    @SuppressLint("HandlerLeak")
+    Handler scanHandler = new Handler() {
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            if (msg.obj != null) {
+
+                String scanResult = msg.obj.toString().trim();
+                if (!scanResult.isEmpty()){
+                    setScanResult(scanResult);
+                }
+            }
+
+        }
+
+    };
+    @Override
+    public void onScanResults(String str) {
+        Message msg = new Message();
+        msg.obj = str;
+        scanHandler.sendMessage(msg);
+
+
+    }
+
+
+    @Override
+    public void onScanResults(String str, int type) {
+
+    }
+    /**
+     * 定义广播接受
+     */
+    BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String scanResult = intent.getStringExtra(scanBean.getDataName());
+            if (scanResult==null){return; }
+            String scanStatus = "";
+            if (!scanBean.getStatusName().isEmpty()){
+                scanStatus = intent.getStringExtra(scanBean.getStatusName());
+            }else{
+                scanStatus = scanResult.isEmpty()? "" : "ok"; //有值 默认是扫码成功;
+            }
+
+            //新大陆(MT65,MT90) 需要手动关闭
+            if (!scanBean.getActionStop().isEmpty()){
+                Intent stopIntent = new Intent(scanBean.getActionStop());
+                mContext.sendBroadcast(stopIntent);
+            }
+
+            if ("ok".equals(scanStatus)){
+                setScanResult(scanResult);
+            }else{
+                showErrorToast(getString(R.string.scan_failed));
+            }
+        }
+    };
+
+    /**
+     * 注册广播
+     */
+    private void initReceiver(){
+
+        try {
+
+            String scanStr = getScanSetting();
+            scanBean = JsonUtil.getObject(scanStr, ScanBean.class);
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+
+            if (is_broadcast ==1){
+                IntentFilter mFilter = new IntentFilter(scanBean.getAction());
+                this.registerReceiver(mReceiver, mFilter);
+            }else{
+                //不广播进行处理 jni模式
+                String pdaBrand = StoTongJNI.getmPdaBrand();
+                if (!pdaBrand.isEmpty()){
+                    StoTongJNI.getIns(this).setmScanCB(this);
+                    StoTongJNI.getIns(this).SetScannerOn();
+                }
+            }
+
+
+        }catch (Exception e) {
+            showErrorToast("获取扫码配置失败"+e.getMessage());
+            XLog.e("获取扫码配置失败:" + e.getMessage());
+        }
+    }
+
+    private void initEdit() {
+        List<EditText> list = new ArrayList<>();
+        list.add(etTrackingNumber);
+        unifyEdit(list);
+    }
+
+
+    private void iniData(){
+        baseImgList.add("label_img");
+    }
+
+    //getAwaitNum
+    private void totalAwaitNum(){
+        int awaitNum = asyncPictureUpload.getAwaitNum();
+        tvAwaitNum.setText(String.valueOf(awaitNum));
+        if (awaitNum == 0){
+            operateStopUpload();
+        }
+    }
+
+    //统一按钮回调
+    @SuppressLint("NonConstantResourceId")
+    public void callbackEditor(View v){
+        setNewTiming();
+        switch (v.getId()) {
+            case R.id.et_tracking_number:
+                getTrackingNumber();
+                break;
+            default:
+        }
+
+    }
+
+    /**
+     * 统一设置Edit监听
+     * @param  list
+     */
+    public void unifyEdit(List<EditText> list){
+        for (int i=0;i<list.size();i++){
+            EditText editText = list.get(i);
+
+            LinearLayout linearLayout = (LinearLayout)editText.getParent();
+            ImageButton imageButton = getChildImageButton(linearLayout);
+
+
+            //监听按确定
+            editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+                @Override
+                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                    //XLog.e("actionId:"+actionId);
+                    if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE   ) {
+                        if (v.getText().toString().trim().isEmpty()) {
+                            setEditTextFocused(v,true);
+                            showWarningToast(v.getHint().toString());
+                            return false;
+                        }else{
+                            setEditTextNormal(v,true);
+                        }
+
+                        callbackEditor(v);
+
+                        return false;
+                    }
+                    return false;
+                }
+            });
+            editText.addTextChangedListener(new TextWatcher() {
+                public void onTextChanged(CharSequence s, int start, int before, int count) {
+                    EditText currentEditText = null;
+                    ImageButton currentImage = null;
+                    //获取焦点的view对象
+                    View view=getWindow().getDecorView().findFocus();
+                    //如果是EditText
+                    if(view instanceof EditText){
+                        currentEditText = (EditText) view;
+                        currentImage = getChildImageButton((LinearLayout)currentEditText.getParent());
+                    }
+
+                    if (s.length() > 0  ) {
+
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.VISIBLE);
+                        }
+                        if (currentEditText!=null){
+                            setEditTextNormal(currentEditText,true);
+                        }
+
+                    } else {
+                        if (currentImage !=null ){
+                            currentImage.setVisibility(View.INVISIBLE);
+                        }
+                        if (currentEditText!=null && isRequiredShow){
+                            setEditTextFocused(currentEditText,true);
+                        }
+                    }
+                }
+
+                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                }
+
+                public void afterTextChanged(Editable s) {
+
+                }
+            });
+
+            if (imageButton !=null ){
+                unifyClearEdit(imageButton);
+            }
+        }
+    }
+
+
+    private OnRxScanerListener mScanerListener = new OnRxScanerListener() {
+        @Override
+        public void onSuccess(String type, Result result) {
+            String scanResult = result.getText();
+            switch (type){
+                case BaseConfig.COMMON_SCANNER_ONLY:
+                    setScanResult(scanResult);
+
+                    break;
+            }
+        }
+        @Override
+        public void onFail(String type, String message) {
+
+        }
+    };
+
+    //把扫描结果赋值
+    private void setScanResult(String scanResult){
+        //获取焦点的view对象
+        View view=getWindow().getDecorView().findFocus();
+        //如果是EditText
+        if(view instanceof EditText)
+        {
+            ((EditText) view).setText(scanResult);
+            showSuccessToast("扫描成功");
+            callbackEditor(view);
+        }
+    }
+
+
+    //检查是否存在上传
+    private void checkIsUpload(){
+
+    }
+
+    //获取跟踪单号
+    private void getTrackingNumber(){
+
+        checkIsUpload();
+        if (etTrackingNumber.getText().toString().isEmpty()){
+            showErrorToast(etTrackingNumber.getHint().toString());
+            return;
+        }
+
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",etTrackingNumber.getText().toString().trim());
+
+        String mathJson = (new Gson()).toJson(math);
+        trackingBoxBean = null;
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET).upJson(mathJson)
+                .execute(new MyDialogCallback(this, true, true) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trackingBoxBean =  JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
+                            }
+
+                            if (trackingBoxBean.getNeedConfirm().equals("Y")){
+                                new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                                        .setMessage(trackingBoxBean.getConfirmMsg())
+                                        .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                            @Override
+                                            public void onClick(DialogInterface dialogInterface, int i) {
+                                                dialogInterface.dismiss();
+                                                etTrackingNumber.selectAll();
+                                            }
+                                        }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+
+                                    @Override
+                                    public void onClick(DialogInterface dialogInterface, int i) {
+
+                                        mapPictureSelector.get(currentPictureType).authCamera();
+                                    }
+                                }).show();
+                            }else{
+                                String voiceName = trackingBoxBean.getVoiceName();
+                                if(bean.code == 1){
+                                    showSuccessToast(bean.msg,voiceName);
+                                    mapPictureSelector.get(currentPictureType).authCamera();
+                                }else{
+                                    showWarningToast(bean.msg,voiceName);
+                                }
+                            }
+
+
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("确认错误",e.getMessage());
+                        }
+
+                    }
+                });
+
+
+    }
+
+    //提交面单信息
+    private void submitLabelImg(){
+        checkIsUpload();
+        if (etTrackingNumber.getText().toString().isEmpty()){
+            showErrorToast(etTrackingNumber.getHint().toString());
+            return;
+        }
+
+
+
+
+        Gson gson = new Gson();
+        Map<String,Object> math = new HashMap<>();
+        math.put("tracking_number",etTrackingNumber.getText().toString().trim());
+
+        //面单
+        List<String> stringList = mapPictureSelector.get("label_img").getOssPhotoList();
+        if (stringList.size()==0){
+            showWarningToast("面单照片不能为空");
+            return;
+        }
+        math.put("label_img_tag",mapPictureSelector.get("label_img").getUniqueTag());
+        math.put("label_img",gson.toJson(stringList));
+
+        OkGo.<String>post(Urls.getServiceAddress(this) + Urls.FXY_DETECTION_PALLET_RECEIVE).upJson(gson.toJson(math))
+                .execute(new MyDialogCallback(this, true, false) {
+                    @Override
+                    public void onSuccess(Response<String> response) {
+                        super.onSuccess(response);
+                        try {
+
+                            ActionBean bean = JsonUtil.getObject(response.body(), ActionBean.class);
+                            if (bean.data!=null && !bean.data.isEmpty() && !bean.data.equals("[]")){
+                                trackingBoxBean =  JsonUtil.jsonString2Bean(bean.data,TrackingBoxBean.class);
+                            }
+
+                            String voiceName = trackingBoxBean.getVoiceName();
+                            if(bean.code == 1){
+                                showSuccessToast(bean.msg,voiceName);
+                                initFinish();
+                            }else{
+                                showWarningToast(bean.msg,voiceName);
+                            }
+
+                        }catch (Exception e) {
+                            e.printStackTrace();
+                            XLog.e("第二步确认错误",e.getMessage());
+                        }
+                    }
+                });
+
+    }
+
+    private void initFinish(){
+
+        for (int i=0;i<baseImgList.size();i++){
+            if (mapPictureSelector.containsKey(baseImgList.get(i))){
+                mapPictureSelector.get(baseImgList.get(i)).emptyRemake();
+            }
+        }
+
+        llLabelPicture.setVisibility(View.VISIBLE);
+        etTrackingNumber.setText("");
+        etTrackingNumber.requestFocus();
+
+
+    }
+
+
+
+    //sIsGoodinfoMatch,sIsBattery,sIsMagnetic,sIsWood,sIsExtra,sIsOther
+    @OnClick({R.id.btn_confirm})
+    public void onViewClicked(View view) {
+        Bundle bundle = new Bundle();
+        switch (view.getId()) {
+            case R.id.btn_confirm:
+                submitLabelImg();
+            default:
+                break;
+        }
+    }
+
+    private void operateStopUpload(){
+        if (currentUploadStatus){
+            asyncPictureUpload.setStopUpload();
+        }
+    }
+    private void operateStartUpload(){
+        if (!currentUploadStatus){
+            asyncPictureUpload.setStartUpload();
+        }
+    }
+
+    protected void showBack() {
+        super.showBack();
+        tb_iv_left.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+
+                int num = asyncPictureUpload.getAwaitNum();
+
+                if (num>0){
+                    new AlertDialog.Builder(mContext).setTitle(R.string.dl_hint)
+                            .setMessage("返回会取消上传还有"+num+"条数据未上传,确定要返回吗")
+                            .setNegativeButton(R.string.str_cancel, new DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialogInterface, int i) {
+                                    if (!currentUploadStatus){
+                                        operateStartUpload();
+                                    }
+                                    dialogInterface.dismiss();
+                                }
+                            }).setPositiveButton(R.string.str_submit, new DialogInterface.OnClickListener() {
+
+                        @Override
+                        public void onClick(DialogInterface dialogInterface, int i) {
+                                if (isShowBackDialog) {
+                                    onBackPressedSupport();
+                                } else {
+                                    finish();
+                                }
+                        }
+                    }).show();
+
+                }else{
+                    if (isShowBackDialog) {
+                        onBackPressedSupport();
+                    } else {
+                        finish();
+                    }
+                }
+
+            }
+        });
+    }
+
+
+
+    @Override
+    protected void onDestroy() {
+        unbinder.unbind();
+
+        asyncPictureUpload.removeHandler();
+        // 确保清除所有的回调以防止内存泄漏
+        workHandler.removeCallbacks(idleRunnable);
+        super.onDestroy();
+    }
+    @Override
+    protected void onResume() {
+        super.onResume();
+        initReceiver();
+    }
+    @Override
+    protected void onPause() {
+        super.onPause();
+        //销毁在onResume()方法中的广播
+        try {
+            //停止扫描
+            Integer is_broadcast = scanBean.getIsBroadcast();//是否广播
+            if (is_broadcast==0){
+                StoTongJNI.getIns(mContext).SetScannerStop();
+                StoTongJNI.getIns(mContext).SetScannerOff();
+            }else{
+                unregisterReceiver(mReceiver);
+            }
+        }catch (Exception e){
+            XLog.e("销毁广播失败:",e.getMessage());
+        }
+    }
+
+}

+ 46 - 0
app/src/main/java/com/fxy/detection/bean/StorageRecordBean.java

@@ -0,0 +1,46 @@
+package com.fxy.detection.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class StorageRecordBean implements Parcelable {
+    private String unit_code;
+    public StorageRecordBean(){
+
+    }
+
+
+    protected StorageRecordBean(Parcel in) {
+        unit_code = in.readString();
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(unit_code);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public static final Creator<StorageRecordBean> CREATOR = new Creator<StorageRecordBean>() {
+        @Override
+        public StorageRecordBean createFromParcel(Parcel in) {
+            return new StorageRecordBean(in);
+        }
+
+        @Override
+        public StorageRecordBean[] newArray(int size) {
+            return new StorageRecordBean[size];
+        }
+    };
+
+    public String getUnitCode() {
+        return unit_code;
+    }
+
+    public void setUnitCode(String unit_code) {
+        this.unit_code = unit_code;
+    }
+}

+ 174 - 0
app/src/main/java/com/fxy/detection/bean/TrackingBoxBean.java

@@ -0,0 +1,174 @@
+package com.fxy.detection.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TrackingBoxBean implements Parcelable {
+    private String need_confirm= "N";
+    private String confirm_msg= "";
+    private String voice_name= "";
+    private String show_weight_img= "";
+    private String show_text= "";
+    private List<TakePictureBean> need_photo= new ArrayList<>();
+    private String tracking_number= "";
+    private String box_number= "";
+    private int yipaizhao_qty= 0;
+    private String need_customer = "";
+    private String no_clear = "";
+    private List<StorageRecordBean> zuijin_nums= new ArrayList<>();
+
+    public TrackingBoxBean(){
+
+    }
+
+
+    protected TrackingBoxBean(Parcel in) {
+        need_confirm = in.readString();
+        confirm_msg = in.readString();
+        voice_name = in.readString();
+        show_weight_img = in.readString();
+        show_text = in.readString();
+        need_photo = in.createTypedArrayList(TakePictureBean.CREATOR);
+        tracking_number = in.readString();
+        box_number = in.readString();
+        yipaizhao_qty = in.readInt();
+        need_customer = in.readString();
+        no_clear = in.readString();
+        zuijin_nums = in.createTypedArrayList(StorageRecordBean.CREATOR);
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(need_confirm);
+        dest.writeString(confirm_msg);
+        dest.writeString(voice_name);
+        dest.writeString(show_weight_img);
+        dest.writeString(show_text);
+        dest.writeTypedList(need_photo);
+        dest.writeString(tracking_number);
+        dest.writeString(box_number);
+        dest.writeInt(yipaizhao_qty);
+        dest.writeString(need_customer);
+        dest.writeString(no_clear);
+        dest.writeTypedList(zuijin_nums);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public static final Creator<TrackingBoxBean> CREATOR = new Creator<TrackingBoxBean>() {
+        @Override
+        public TrackingBoxBean createFromParcel(Parcel in) {
+            return new TrackingBoxBean(in);
+        }
+
+        @Override
+        public TrackingBoxBean[] newArray(int size) {
+            return new TrackingBoxBean[size];
+        }
+    };
+
+    public String getNeedConfirm() {
+        return need_confirm;
+    }
+
+    public void setNeedConfirm(String need_confirm) {
+        this.need_confirm = need_confirm;
+    }
+
+    public String getConfirmMsg() {
+        return confirm_msg;
+    }
+
+    public void setConfirmMsg(String confirm_msg) {
+        this.confirm_msg = confirm_msg;
+    }
+
+    public String getVoiceName() {
+        return voice_name;
+    }
+
+    public void setVoiceName(String voice_name) {
+        this.voice_name = voice_name;
+    }
+
+    public String getShowWeightImg() {
+        return show_weight_img;
+    }
+
+    public void setShowWeightImg(String show_weight_img) {
+        this.show_weight_img = show_weight_img;
+    }
+
+    public String getShowText() {
+        return show_text;
+    }
+
+    public void setShowText(String show_text) {
+        this.show_text = show_text;
+    }
+
+    public List<TakePictureBean> getNeedPhoto() {
+        return need_photo;
+    }
+
+    public void setNeedPhoto(List<TakePictureBean> need_photo) {
+        this.need_photo = need_photo;
+    }
+
+    public String getTrackingNumber() {
+        return tracking_number;
+    }
+
+    public void setTrackingNumber(String tracking_number) {
+        this.tracking_number = tracking_number;
+    }
+
+    public String getBoxNumber() {
+        return box_number;
+    }
+
+    public void setBoxNumber(String box_number) {
+        this.box_number = box_number;
+    }
+
+    public int getYipaizhaoQty() {
+        return yipaizhao_qty;
+    }
+
+    public void setYipaizhaoQty(int yipaizhao_qty) {
+        this.yipaizhao_qty = yipaizhao_qty;
+    }
+
+    public List<StorageRecordBean> getZuijinNums() {
+        return zuijin_nums;
+    }
+
+    public void setZuijinNums(List<StorageRecordBean> zuijin_nums) {
+        this.zuijin_nums = zuijin_nums;
+    }
+
+    public String getNeedCustomer() {
+        return need_customer;
+    }
+
+    public void setNeedCustomer(String need_customer) {
+        this.need_customer = need_customer;
+    }
+
+    public String getNoClear() {
+        return no_clear;
+    }
+
+    public void setNoClear(String no_clear) {
+        this.no_clear = no_clear;
+    }
+}

+ 174 - 0
app/src/main/java/com/fxy/detection/bean/TrayMakeBean.java

@@ -0,0 +1,174 @@
+package com.fxy.detection.bean;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TrayMakeBean implements Parcelable {
+    private String need_confirm= "N";
+    private String confirm_msg= "";
+    private String voice_name= "";
+    private String show_weight_img= "";
+    private String show_text= "";
+    private List<TakePictureBean> need_photo= new ArrayList<>();
+    private String tracking_number= "";
+    private String box_number= "";
+    private int ab_img_id= 0;
+    private int has_do_dui= 0;
+    private int  ben_box_qty = 2;
+    private List<StorageRecordBean> zuijin_nums= new ArrayList<>();
+
+    public TrayMakeBean(){
+
+    }
+
+
+    protected TrayMakeBean(Parcel in) {
+        need_confirm = in.readString();
+        confirm_msg = in.readString();
+        voice_name = in.readString();
+        show_weight_img = in.readString();
+        show_text = in.readString();
+        need_photo = in.createTypedArrayList(TakePictureBean.CREATOR);
+        tracking_number = in.readString();
+        box_number = in.readString();
+        ab_img_id = in.readInt();
+        has_do_dui = in.readInt();
+        ben_box_qty = in.readInt();
+        zuijin_nums = in.createTypedArrayList(StorageRecordBean.CREATOR);
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(need_confirm);
+        dest.writeString(confirm_msg);
+        dest.writeString(voice_name);
+        dest.writeString(show_weight_img);
+        dest.writeString(show_text);
+        dest.writeTypedList(need_photo);
+        dest.writeString(tracking_number);
+        dest.writeString(box_number);
+        dest.writeInt(ab_img_id);
+        dest.writeInt(has_do_dui);
+        dest.writeInt(ben_box_qty);
+        dest.writeTypedList(zuijin_nums);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public static final Creator<TrayMakeBean> CREATOR = new Creator<TrayMakeBean>() {
+        @Override
+        public TrayMakeBean createFromParcel(Parcel in) {
+            return new TrayMakeBean(in);
+        }
+
+        @Override
+        public TrayMakeBean[] newArray(int size) {
+            return new TrayMakeBean[size];
+        }
+    };
+
+    public String getNeedConfirm() {
+        return need_confirm;
+    }
+
+    public void setNeedConfirm(String need_confirm) {
+        this.need_confirm = need_confirm;
+    }
+
+    public String getConfirmMsg() {
+        return confirm_msg;
+    }
+
+    public void setConfirmMsg(String confirm_msg) {
+        this.confirm_msg = confirm_msg;
+    }
+
+    public String getVoiceName() {
+        return voice_name;
+    }
+
+    public void setVoiceName(String voice_name) {
+        this.voice_name = voice_name;
+    }
+
+    public String getShowWeightImg() {
+        return show_weight_img;
+    }
+
+    public void setShowWeightImg(String show_weight_img) {
+        this.show_weight_img = show_weight_img;
+    }
+
+    public String getShowText() {
+        return show_text;
+    }
+
+    public void setShowText(String show_text) {
+        this.show_text = show_text;
+    }
+
+    public List<TakePictureBean> getNeedPhoto() {
+        return need_photo;
+    }
+
+    public void setNeedPhoto(List<TakePictureBean> need_photo) {
+        this.need_photo = need_photo;
+    }
+
+    public String getTrackingNumber() {
+        return tracking_number;
+    }
+
+    public void setTrackingNumber(String tracking_number) {
+        this.tracking_number = tracking_number;
+    }
+
+    public String getBoxNumber() {
+        return box_number;
+    }
+
+    public void setBoxNumber(String box_number) {
+        this.box_number = box_number;
+    }
+
+
+    public List<StorageRecordBean> getZuijinNums() {
+        return zuijin_nums;
+    }
+
+    public void setZuijinNums(List<StorageRecordBean> zuijin_nums) {
+        this.zuijin_nums = zuijin_nums;
+    }
+
+    public int getAbImgId() {
+        return ab_img_id;
+    }
+
+    public void setAbImgId(int ab_img_id) {
+        this.ab_img_id = ab_img_id;
+    }
+
+    public int getHasDoDui() {
+        return has_do_dui;
+    }
+
+    public void setHasDoDui(int has_do_dui) {
+        this.has_do_dui = has_do_dui;
+    }
+
+    public int getBenBoxQty() {
+        return ben_box_qty;
+    }
+
+    public void setBenBoxQty(int ben_box_qty) {
+        this.ben_box_qty = ben_box_qty;
+    }
+}

+ 20 - 1
app/src/main/java/com/fxy/main/MainActivity.java

@@ -1,11 +1,14 @@
 package com.fxy.main;
 
 import android.Manifest;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.Bundle;
 import android.support.v4.content.ContextCompat;
 import android.support.v4.view.ViewPager;
 import android.view.KeyEvent;
 
+import com.fxy.base.ChargeStateReceiver;
 import com.jaeger.library.StatusBarUtil;
 import com.jpeng.jptabbar.BadgeDismissListener;
 import com.jpeng.jptabbar.JPTabBar;
@@ -101,7 +104,8 @@ public class MainActivity extends BaseActivity implements BadgeDismissListener,
     }
 
 
-
+    private ChargeStateReceiver receiver;
+    private IntentFilter filter;
     @Override
     protected void initView() {
         StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.md_deep_orange_300), 0);
@@ -112,6 +116,14 @@ public class MainActivity extends BaseActivity implements BadgeDismissListener,
         initFragment();
         StorageApplication.context.isShowUpdateToast = false;
         UpdateBuilder.create().setUpdateStrategy(new AllDialogShowStrategy()).check();
+
+
+        // 创建 BroadcastReceiver
+        receiver = new ChargeStateReceiver();
+        // 创建 IntentFilter
+        filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+        // 注册 BroadcastReceiver
+        registerReceiver(receiver, filter);
     }
 
     private void initFragment() {
@@ -206,6 +218,13 @@ public class MainActivity extends BaseActivity implements BadgeDismissListener,
                 });
     }
 
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        // 注销 BroadcastReceiver
+        unregisterReceiver(receiver);
+    }
+
 }
 
 

+ 22 - 6
app/src/main/java/com/fxy/main/fragment/HomePagerFragment.java

@@ -14,10 +14,12 @@ import android.widget.LinearLayout;
 import com.fxy.common.VersionUpgrades;
 import com.elvishew.xlog.XLog;
 import com.fxy.constant.SPCache;
+import com.fxy.detection.BoxPutInMainActivity;
 import com.fxy.detection.DetectionConfirmGoodsMainActivity;
 import com.fxy.detection.DetectionDestroyOutboundMainActivity;
-import com.fxy.detection.DetectionPutInMainActivity;
 import com.fxy.detection.DetectionPutawayMainActivity;
+import com.fxy.detection.TrayMakeMainActivity;
+import com.fxy.detection.TrayPutInMainActivity;
 import com.fxy.helper.HkDataHelper;
 import com.fxy.hk.HkOutboundMainActivity;
 import com.fxy.hk.HkPickupStartMainActivity;
@@ -31,6 +33,7 @@ import com.fxy.detection.ScanPhotosMainActivity;
 import com.fxy.putIn.TallyMainActivity;
 import com.fxy.putOut.DeliveryGoodsMainActivity;
 import com.fxy.tool.OrderToolMainActivity;
+import com.fxy.utils.JobUtils;
 import com.fxy.workOrder.StartWorkOrderMainActivity;
 import com.fxy.workOrder.WorkOrderOptMainActivity;
 import com.fxy.baselibrary.base.BaseFragment;
@@ -123,7 +126,8 @@ public class HomePagerFragment extends BaseFragment implements View.OnClickListe
         //拉取数据
         (new HkDataHelper(getApplicationContext())).getBaseInfo();
 
-
+        //设备空闲
+        JobUtils.deviceIdleJob(getContext());
 
     }
 
@@ -146,8 +150,9 @@ public class HomePagerFragment extends BaseFragment implements View.OnClickListe
             R.id.ivt_order_tool,R.id.ivt_check,R.id.ivt_putin_pallet,R.id.ivt_hk_putin,
             R.id.ivt_handle_work_order,R.id.ivt_add_work_order,R.id.ivt_hk_tally,R.id.ivt_hk_outbound,
             R.id.ivt_hk_pallet_location,R.id.ivt_hk_pickup,
-            R.id.ivt_detection_putin,R.id.ivt_detection_putaway,R.id.ivt_detection_destroy_outbound,
-            R.id.ivt_detection_work,R.id.ivt_scan_photos})
+            R.id.ivt_detection_putaway,R.id.ivt_detection_destroy_outbound,
+            R.id.ivt_detection_work,R.id.ivt_scan_photos,R.id.ivt_detection_box_putin,
+            R.id.ivt_detection_tray_putin,R.id.ivt_detection_tray_make})
     public void onClick(View v) {
         Bundle bundle = new Bundle();
         switch (v.getId()) {
@@ -179,9 +184,20 @@ public class HomePagerFragment extends BaseFragment implements View.OnClickListe
             case R.id.ivt_putin_pallet:
                 intent2Page(getActivity(), PutinPalletMainActivity.class, false,bundle);
                 break;
-            case R.id.ivt_detection_putin:
-                intent2Page(getActivity(), DetectionPutInMainActivity.class, false,bundle);
+
+            case R.id.ivt_detection_box_putin:
+                intent2Page(getActivity(), BoxPutInMainActivity.class, false,bundle);
+                break;
+
+            case R.id.ivt_detection_tray_putin:
+                intent2Page(getActivity(), TrayPutInMainActivity.class, false,bundle);
+                break;
+
+            case R.id.ivt_detection_tray_make:
+                intent2Page(getActivity(), TrayMakeMainActivity.class, false,bundle);
                 break;
+
+
             case R.id.ivt_detection_putaway:
                 intent2Page(getActivity(), DetectionPutawayMainActivity.class, false,bundle);
                 break;

+ 2 - 0
app/src/main/java/com/fxy/main/fragment/MineFragment.java

@@ -19,6 +19,7 @@ import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.elvishew.xlog.XLog;
+import com.fxy.utils.JobUtils;
 import com.lzy.okgo.OkGo;
 import com.lzy.okgo.model.Response;
 import com.fxy.baselibrary.base.BaseFragment;
@@ -147,6 +148,7 @@ public class MineFragment extends BaseFragment {
         if (!service_type.toUpperCase().equals("DEV")){
             rlPictureSelector.setVisibility(View.GONE);
         }
+        JobUtils.deviceIdleJob(getContext());
     }
     private String getVersionName(Context context) {
         try {

+ 22 - 0
app/src/main/java/com/fxy/net/Urls.java

@@ -161,6 +161,28 @@ public class Urls {
     //单箱入库
     public static final String FXY_DETECTION_PUTIN_TRACK = "/pda/inbound/QcInboundTrack";
 
+    //单箱检查内件码
+    public static final String FXY_DETECTION_PUTIN_UNIT = "/pda/inbound/QcInboundUnit";
+
+    //托盘-单号查询
+    public static final String FXY_DETECTION_PALLET = "/pda/inbound/QcInboundPallet";
+
+    //托盘入库 - 拍照完成
+    public static final String FXY_DETECTION_PALLET_RECEIVE = "/pda/inbound/QcPalletReceive";
+
+    //托盘箱号
+    public static final String FXY_DETECTION_PALLET_STACK_IMG = "/pda/inbound/QcPalletStackImg";
+
+    //托盘箱号
+    public static final String FXY_DETECTION_PALLET_BOX = "/pda/inbound/QcPalletBox";
+
+    //托盘箱号内件码
+    public static final String FXY_DETECTION_PALLET_BOX_UNIT = "/pda/inbound/QcPalletBoxUnit";
+
+
+
+
+
     // 单箱上架 -- 查验库位
     public static final String FXY_DETECTION_CHECK_LOCATION = "/pda/inbound/QcBindLocation";
     // 单箱上架

+ 1 - 1
app/src/main/java/com/fxy/realm/AsyncUploadRealm.java

@@ -23,7 +23,7 @@ public class AsyncUploadRealm extends RealmObject implements Parcelable {
     private Integer isDelete = 0; //是否删除
     private Integer pushStatus = 0; // 推送到oss状态 0 -未推送 1 - 推送失败;  2 - 推送成功
     private Integer rePush = 0; //重推次数
-    private Integer isFinish=0; // 是否完成 0未完成【】  1已完成 【已上传】 2上传失败
+    private Integer isFinish=0; // 是否完成 0未完成   1【上传中】   2上传失败 3上传成功
     private Long createTime;
     private String localMediaStr = "";
     public AsyncUploadRealm() {

+ 57 - 0
app/src/main/java/com/fxy/service/UploadJobService.java

@@ -0,0 +1,57 @@
+package com.fxy.service;
+
+import android.app.job.JobParameters;
+import android.app.job.JobService;
+import android.content.Context;
+import android.os.Build;
+
+import androidx.annotation.RequiresApi;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.base.UploadContentProvider;
+import com.fxy.common.AsyncFileUpload;
+import com.fxy.common.FiledUpload;
+import com.fxy.constant.SPCache;
+import com.fxy.realm.AsyncUploadRealm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.realm.Realm;
+
+public class UploadJobService  extends JobService {
+    public static final int CHARGING_JOB_ID = 100;
+    public static final int DEVICE_IDLE_JOB_ID = 101;
+
+    public  AsyncFileUpload asyncFileUpload;
+
+    @Override
+    public boolean onStartJob(JobParameters jobParameters) {
+        // 在这里执行你的任务
+        // 1. 查询Realm数据库
+        // 2. 上传文件到OSS
+
+        Context context = UploadContentProvider.getCurrentContext();
+
+        XLog.d("------------执行异步上传图片--------------------"+jobParameters.getJobId());
+        asyncFileUpload = new AsyncFileUpload(context);
+
+        asyncFileUpload.setStartUpload();
+        int awaitNum = asyncFileUpload.getAllAwaitNum();
+        if (awaitNum == 0){
+            // 标记任务为已完成(如果你不需要重试)
+            jobFinished(jobParameters, false);
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onStopJob(JobParameters jobParameters) {
+        if (asyncFileUpload!=null){
+            asyncFileUpload.taskCancel();
+        }
+        return false;
+    }
+
+
+}

+ 112 - 0
app/src/main/java/com/fxy/utils/JobUtils.java

@@ -0,0 +1,112 @@
+package com.fxy.utils;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.content.ComponentName;
+import android.content.Context;
+
+import com.elvishew.xlog.XLog;
+import com.fxy.constant.SPCache;
+import com.fxy.service.UploadJobService;
+
+import java.util.List;
+
+public class JobUtils {
+
+    /**
+     * 设备空闲时
+     * @param context Activity
+     */
+    public static void deviceIdleJob(Context context){
+        JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
+        @SuppressLint("JobSchedulerService")
+        JobInfo.Builder builder = new JobInfo.Builder(UploadJobService.DEVICE_IDLE_JOB_ID, new ComponentName(context, UploadJobService.class));
+
+
+        // 设置任务在设备空闲时执行
+        builder.setRequiresDeviceIdle(true);
+
+        // 或者,如果你也想要在充电时执行(可以与空闲条件组合,但通常不需要同时满足)
+        // builder.setRequiresCharging(true); // 如果只需要在充电时执行,则取消注释这行代码
+
+        // 可以设置其他条件,如网络状态等
+        builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
+
+        List<JobInfo> jobInfoList = jobScheduler.getAllPendingJobs();
+        for (int i = 0; i < jobInfoList.size(); i++) {
+            if (jobInfoList.get(i).getId()==UploadJobService.DEVICE_IDLE_JOB_ID){
+                return;
+            }
+        }
+        SPCache spCache = SPCache.getInstance(context);
+        int  leisure = spCache.getLeisure();
+
+        // 其他设置,如网络条件、延迟等
+        builder.setMinimumLatency(1000 * 60 * leisure); // 延迟至少60秒
+//        builder.setMinimumLatency(1000); // 延迟至少60秒
+        builder.setOverrideDeadline(2*60 * 1000 * 60); // 最多延迟2小时
+
+        JobInfo jobInfo = builder.build();
+
+
+        int result = jobScheduler.schedule(jobInfo);
+        if (result == JobScheduler.RESULT_SUCCESS) {
+            // 任务安排成功
+            XLog.d("设备空闲"+leisure+"分钟后任务安排成功");
+        } else {
+            // 任务安排失败
+            XLog.d("定时任务安排失败");
+        }
+    }
+
+    public static void chargingJob(Context context){
+        JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
+        @SuppressLint("JobSchedulerService")
+        JobInfo.Builder builder = new JobInfo.Builder(UploadJobService.CHARGING_JOB_ID, new ComponentName(context, UploadJobService.class));
+
+
+
+        // 设置任务在设备空闲时执行
+//        builder.setRequiresDeviceIdle(true);
+
+        // 或者,如果你也想要在充电时执行(可以与空闲条件组合,但通常不需要同时满足)
+        // builder.setRequiresCharging(true); // 如果只需要在充电时执行,则取消注释这行代码
+
+        // 可以设置其他条件,如网络状态等
+        builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY);
+
+        List<JobInfo> jobInfoList = jobScheduler.getAllPendingJobs();
+        for (int i = 0; i < jobInfoList.size(); i++) {
+            if (jobInfoList.get(i).getId()==UploadJobService.CHARGING_JOB_ID){
+                return;
+            }
+        }
+
+        // 其他设置,如网络条件、延迟等
+        builder.setMinimumLatency(1000 * 30); // 延迟至少60秒
+//        builder.setMinimumLatency(1000); // 延迟至少60秒
+        builder.setOverrideDeadline(2*60 * 1000 * 60); // 最多延迟2分钟
+
+        JobInfo jobInfo = builder.build();
+
+
+        int result = jobScheduler.schedule(jobInfo);
+        if (result == JobScheduler.RESULT_SUCCESS) {
+            // 任务安排成功
+            XLog.d("充电定时任务安排成功");
+        } else {
+            // 任务安排失败
+            XLog.d("充电定时任务安排失败");
+        }
+    }
+
+    public static void cancel(Activity activity){
+        JobScheduler jobScheduler = (JobScheduler) activity.getSystemService(Context.JOB_SCHEDULER_SERVICE);
+        // 取消指定的任务
+        jobScheduler.cancel(UploadJobService.CHARGING_JOB_ID);
+        jobScheduler.cancel(UploadJobService.DEVICE_IDLE_JOB_ID);
+    }
+
+}

+ 27 - 0
app/src/main/java/com/fxy/utils/UploadUtils.java

@@ -0,0 +1,27 @@
+package com.fxy.utils;
+
+import com.fxy.realm.AsyncUploadRealm;
+
+import io.realm.Realm;
+import io.realm.RealmResults;
+
+public class UploadUtils {
+    public static int getAwaitNum(Realm mRealm,String uploadType){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .equalTo("uploadType",uploadType)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+    public static int getAwaitNum(Realm mRealm, String[] uploadTypeList){
+        RealmResults<AsyncUploadRealm> realmResults  = mRealm.where(AsyncUploadRealm.class)
+                .equalTo("isDelete",0)
+                .equalTo("pushStatus",0)
+                .in("uploadType",uploadTypeList)
+                .sort("pushStatus").findAll();
+        realmResults.load();
+        return  realmResults.size();
+    }
+}

+ 113 - 0
app/src/main/res/layout/activity_base_setting.xml

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:padding="10dp"
+    android:background="@color/md_grey_200"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:scrollbars="vertical"
+    android:orientation="vertical">
+
+
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:background="@drawable/bg_white_et"
+                android:padding="@dimen/dp_10">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="空闲时间:"
+                    android:textColor="@color/black_3d3d3d"
+                    android:textSize="@dimen/t14" />
+                <EditText
+                    android:id="@+id/et_scan_test"
+                    android:layout_width="0dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:layout_marginStart="10dp"
+                    android:gravity="left"
+                    android:minLines="7"
+                    android:maxLength="15"
+                    android:background="@null"
+                    android:imeOptions="actionDone"
+                    android:paddingEnd="5dp"
+                    android:hint="请输入"
+                    android:textSize="@dimen/t14"
+                    android:singleLine="true"
+                    tools:ignore="RtlSymmetry" />
+                <ImageButton
+                    android:id="@+id/ib_scan_test_clear"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginEnd="3dp"
+                    android:background="@android:color/transparent"
+                    android:padding="6dp"
+                    android:src="@drawable/ic_clear"
+                    android:textSize="@dimen/sp_14"
+
+                    android:visibility="invisible" />
+
+
+            </LinearLayout>
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal">
+                <com.fxy.baselibrary.views.MarqueeTextView
+                    android:id="@+id/tv_blue_tips"
+                    android:layout_width="10dp"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:enabled="false"
+                    android:ellipsize="marquee"
+                    android:focusable="true"
+                    android:singleLine="true"
+                    android:layout_marginLeft="10dp"
+                    android:text="超过空闲时间会触发自动上传"
+                    android:drawableLeft="@drawable/tips"
+                    android:textColor="@color/actionsheet_red"
+                    android:gravity="left"
+                    android:textSize="@dimen/t16"
+                    />
+            </LinearLayout>
+
+
+            <Button
+                android:id="@+id/btn_scan"
+                android:gravity="center"
+                android:layout_width="match_parent"
+                android:layout_margin="@dimen/dp_10"
+                android:background="@drawable/bg_orange_item"
+                android:text="@string/save"
+                android:textColor="@color/white"
+                android:textSize="@dimen/t18"
+                android:layout_alignParentBottom ="true"
+                android:layout_marginLeft="10px"
+                android:layout_height="wrap_content">
+            </Button>
+
+        </LinearLayout>
+    </ScrollView>
+
+
+</LinearLayout>

+ 125 - 0
app/src/main/res/layout/activity_fxy_detection_box_putin.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <LinearLayout
+                android:id="@+id/ll_tracking_number"
+                style="@style/FromLinearLayoutItem"
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_tracking_number"
+                    android:hint="扫描或者输入跟踪单号"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_order_number"
+                style="@style/FromLinearLayoutItem"
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_order_number"
+                    android:hint="扫描或者输入箱号"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+
+            </LinearLayout>
+
+        <LinearLayout
+            android:id="@+id/ll_extend_info"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="@dimen/dp_10"
+            android:layout_marginRight="@dimen/dp_10"
+            android:layout_marginTop="@dimen/dp_10"
+            android:background="@drawable/bg_white_et"
+            android:gravity="center_vertical"
+            android:orientation="vertical"
+            android:paddingLeft="10dp"
+            android:visibility="gone"
+            android:paddingRight="10dp">
+            <LinearLayout
+                android:id="@+id/ll_customer_code"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingBottom="5dp"
+                android:paddingTop="5dp"
+
+                android:orientation="horizontal">
+
+                <TextView
+                    style="@style/tvLeftStyle"
+                    android:text="客户编号" />
+                <TextView
+                    style="@style/tvLeftStyle"
+                    android:text=":" />
+
+                <com.fxy.baselibrary.views.MarqueeTextView
+                    style="@style/mtRightStyle"
+                    android:id="@+id/mt_customer_code"
+
+                    />
+
+                <TextView
+                    android:id="@+id/tv_edit_customer"
+                    style="@style/tvLeftStyle"
+                    android:text="修改"
+                    android:textColor="@color/actionsheet_blue" />
+            </LinearLayout>
+        </LinearLayout>
+
+
+
+            <LinearLayout
+                android:id="@+id/ll_weigh_picture"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="gone"
+                android:orientation="vertical">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@null"
+                    android:padding="@dimen/dp_10"
+                    android:gravity="center_vertical"
+                    android:orientation="vertical">
+                    <TextView
+                        style="@style/fontSize"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textStyle="bold"
+                        android:text="内件拍照">
+                    </TextView>
+                </LinearLayout>
+                <include layout="@layout/fragment_show_img"/>
+            </LinearLayout>
+
+            <include layout="@layout/item_upload_await_number" />
+        </LinearLayout>
+
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 133 - 140
app/src/main/res/layout/activity_fxy_detection_putin.xml

@@ -19,88 +19,92 @@
             android:orientation="vertical">
 
             <LinearLayout
-                android:id="@+id/ll_tracking_number"
-                style="@style/FromLinearLayoutItem"
-                android:orientation="horizontal">
-                <EditText
-                    style="@style/EditTextStyle"
-                    android:id="@+id/et_tracking_number"
-                    android:hint="扫描或者输入跟踪单号"
-                    android:text=""/>
-                <include layout="@layout/item_image_close" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:id="@+id/ll_order_number"
-                style="@style/FromLinearLayoutItem"
-                android:orientation="horizontal">
-                <EditText
-                    style="@style/EditTextStyle"
-                    android:id="@+id/et_order_number"
-                    android:hint="扫描或者输入箱号"
-                    android:text=""/>
-                <include layout="@layout/item_image_close" />
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="vertical"
+                android:paddingLeft="10dp"
+                android:paddingRight="10dp">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
 
-            </LinearLayout>
+                    android:orientation="horizontal">
 
+                    <TextView
+                        style="@style/tvLeftStyle"
+                        android:text="跟踪号" />
+                    <TextView
+                        style="@style/tvLeftStyle"
+                        android:text=":" />
 
+                    <com.fxy.baselibrary.views.MarqueeTextView
+                        style="@style/mtRightStyle"
+                        android:id="@+id/mt_tracking_number"
+                        />
 
-            <LinearLayout
-                android:id="@+id/ll_label_picture"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:visibility="visible"
-                android:orientation="vertical">
+                </LinearLayout>
                 <LinearLayout
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_marginLeft="@dimen/dp_10"
-                    android:layout_marginRight="@dimen/dp_10"
-                    android:background="@null"
-                    android:padding="@dimen/dp_10"
-                    android:gravity="center_vertical"
-                    android:orientation="vertical">
+
+                    android:orientation="horizontal">
+
                     <TextView
-                        style="@style/fontSize"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:textStyle="bold"
-                        android:text="面单拍照">
-                    </TextView>
+                        style="@style/tvLeftStyle"
+                        android:text="箱    号" />
+                    <TextView
+                        style="@style/tvLeftStyle"
+                        android:text=":" />
+
+                    <com.fxy.baselibrary.views.MarqueeTextView
+                        style="@style/mtRightStyle"
+                        android:id="@+id/mt_box_number"
+                        />
+
                 </LinearLayout>
-                <include layout="@layout/fragment_show_img"/>
-            </LinearLayout>
 
-            <LinearLayout
-                android:id="@+id/ll_weigh_picture"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:visibility="gone"
-                android:orientation="vertical">
+
                 <LinearLayout
+                    android:id="@+id/ll_customer_code"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:layout_marginLeft="@dimen/dp_10"
-                    android:layout_marginRight="@dimen/dp_10"
-                    android:background="@null"
-                    android:padding="@dimen/dp_10"
-                    android:gravity="center_vertical"
-                    android:orientation="vertical">
+                    android:paddingBottom="5dp"
+                    android:paddingTop="5dp"
+                    android:visibility="gone"
+                    android:orientation="horizontal">
+
+                    <TextView
+                        style="@style/tvLeftStyle"
+                        android:text="客户编号" />
                     <TextView
-                        style="@style/fontSize"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:textStyle="bold"
-                        android:text="内件拍照">
-                    </TextView>
+                        style="@style/tvLeftStyle"
+                        android:text=":" />
+
+                    <com.fxy.baselibrary.views.MarqueeTextView
+                        style="@style/mtRightStyle"
+                        android:id="@+id/mt_customer_code"
+                        />
+
+                    <TextView
+                        android:id="@+id/tv_edit_customer"
+                        style="@style/tvLeftStyle"
+                        android:layout_height="42dp"
+                        android:text="修改"
+                        android:textColor="@color/actionsheet_blue" />
+
                 </LinearLayout>
-                <include layout="@layout/fragment_show_img"/>
+
             </LinearLayout>
 
             <LinearLayout
                 android:id="@+id/ll_unit_code"
                 style="@style/FromLinearLayoutItem"
+
                 android:orientation="horizontal">
                 <EditText
                     style="@style/EditTextStyle"
@@ -110,42 +114,84 @@
                 <include layout="@layout/item_image_close" />
             </LinearLayout>
 
+
+
             <LinearLayout
                 android:id="@+id/ll_camera_picture_module"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
-                android:visibility="visible"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+
                 android:orientation="vertical">
             </LinearLayout>
 
 
 
-            <LinearLayout
-                android:id="@+id/ll_result"
+            <View
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:background="@drawable/bg_white_et"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:layout_marginTop="20dp"
-                android:layout_marginBottom="20dp"
-                android:paddingBottom="10dp"
-                android:paddingTop="10dp"
-                android:gravity="center"
-                android:visibility="gone"
+                android:layout_height="1dp"
+                android:background="@color/md_grey_100" />
+
+            <LinearLayout
+                style="@style/LinearLayoutLoginStyle"
+                android:background="@null"
+
+                android:paddingBottom="5dp"
+                android:paddingTop="5dp"
                 android:orientation="horizontal">
                 <TextView
-                    android:id="@+id/tv_result"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    style="@style/tvLeftStyle"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="最近扫描:" />
+
+                <TextView
                     style="@style/tvLeftStyle"
-                    android:paddingStart="20dp"
-                    android:paddingEnd="20dp"
-                    android:textSize="50sp"/>
+                    android:layout_width="0dp"
+                    android:layout_weight="1"
+                    android:gravity="right"
+                    android:textSize="@dimen/t24"
+                    android:text="已拍照内件:"
+                    tools:ignore="RtlHardcoded">
+
+                </TextView>
+                <TextView
+                    android:id="@+id/tv_qty"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textSize="@dimen/t24"
+                    android:layout_marginRight="10dp"
+                    android:textColor="@color/actionsheet_red"
+                    android:text="0">
+
+                </TextView>
+
             </LinearLayout>
 
+            <LinearLayout
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:scrollbars="vertical"
+                android:paddingTop="@dimen/dp_10"
+                android:paddingBottom="@dimen/dp_10"
+                >
+                <android.support.v7.widget.RecyclerView
+                    android:id="@+id/recyclerview"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:overScrollMode="never"/>
+            </LinearLayout>
 
 
 
             <LinearLayout
+                android:id="@+id/ll_btn_clear"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="@dimen/dp_10"
@@ -156,23 +202,24 @@
                 android:gravity="center_vertical"
                 android:orientation="horizontal"
                 android:layout_gravity="bottom"
+                android:visibility="gone"
                 android:padding="10dp">
                 <TextView
                     style="@style/fontSize"
-                    android:id="@+id/btn_confirm"
+                    android:id="@+id/btn_clear"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginLeft="@dimen/dp_10"
                     android:layout_marginRight="@dimen/dp_10"
                     android:background="@drawable/bg_orange_item"
                     android:gravity="center"
-                    android:text="确认入库"
+                    android:text="切换彩盒"
                     android:padding="10dp"
                     android:textColor="@color/white"
                     android:visibility="visible" />
             </LinearLayout>
-
             <LinearLayout
+                android:id="@+id/ll_btn_confirm"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginLeft="@dimen/dp_10"
@@ -183,82 +230,28 @@
                 android:gravity="center_vertical"
                 android:orientation="horizontal"
                 android:layout_gravity="bottom"
+                android:visibility="gone"
                 android:padding="10dp">
                 <TextView
                     style="@style/fontSize"
-                    android:id="@+id/btn_start_upload"
+                    android:id="@+id/btn_confirm"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:layout_marginLeft="@dimen/dp_10"
                     android:layout_marginRight="@dimen/dp_10"
                     android:background="@drawable/bg_orange_item"
                     android:gravity="center"
-                    android:text="开始上传"
+                    android:text="入库完成"
                     android:padding="10dp"
                     android:textColor="@color/white"
                     android:visibility="visible" />
             </LinearLayout>
 
-            <LinearLayout
-                android:id="@+id/ll_upload_progressbar"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:gravity="center_vertical"
-                android:padding="@dimen/dp_10"
-                android:orientation="horizontal">
-                <TextView
 
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="上传进度:"
-                    android:textStyle="bold" />
-                <ProgressBar
-                    android:id="@+id/pb_progressbar"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:progress="0"
-                    android:secondaryProgress="0"
-                    android:max="100"
-                    style="?android:attr/progressBarStyleHorizontal"
-                    android:progressDrawable="@drawable/video_progress" />
-                <TextView
-                    android:id="@+id/percentage_text_view"
-                    android:layout_width="wrap_content"
-                    android:gravity="center_vertical"
-                    android:layout_marginStart="@dimen/dp_4"
-                    android:text="0%"
-                    android:layout_height="match_parent">
-                </TextView>
 
+            <include layout="@layout/item_upload_await_number" />
 
-            </LinearLayout>
 
-            <LinearLayout
-                android:id="@+id/ll_await_num"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:background="@null"
-                android:padding="@dimen/dp_10"
-                android:gravity="center_vertical"
-                android:orientation="horizontal">
-                <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                     android:text="待上传文件:">
-                </TextView>
-                <TextView
-                    android:id="@+id/tv_await_num"
-                    android:textColor="@color/md_red_900"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="0">
-                </TextView>
-            </LinearLayout>
         </LinearLayout>
 
 

+ 0 - 189
app/src/main/res/layout/activity_fxy_detection_putin_check.xml

@@ -1,189 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:background="@color/md_grey_100"
-    android:orientation="vertical">
-    <ScrollView
-        android:id="@+id/ll_scroll_view"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:fitsSystemWindows="true"
-        android:scrollbars="none">
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical">
-
-            <LinearLayout
-                android:id="@+id/ll_order_number"
-                style="@style/FromLinearLayoutItem"
-                android:orientation="horizontal">
-                <EditText
-                    style="@style/EditTextStyle"
-                    android:id="@+id/et_order_number"
-                    android:hint="扫描或者输入箱号"
-                    android:text=""/>
-                <include layout="@layout/item_image_close" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:id="@+id/ll_customer_code"
-                style="@style/FromLinearLayoutItem"
-                android:orientation="horizontal">
-                <EditText
-                    style="@style/EditTextStyle"
-                    android:id="@+id/et_customer_code"
-                    android:hint="扫描或者输入客户代码"
-                    android:text=""/>
-                <include layout="@layout/item_image_close" />
-
-
-            </LinearLayout>
-
-
-            <LinearLayout
-                android:id="@+id/ll_internals_cod"
-                style="@style/FromLinearLayoutItem"
-                android:orientation="horizontal">
-                <EditText
-                    style="@style/EditTextStyle"
-                    android:id="@+id/et_internals_code"
-                    android:hint="扫描或者输入内件码"
-                    android:text=""/>
-                <include layout="@layout/item_image_close" />
-            </LinearLayout>
-
-
-            <LinearLayout
-                android:id="@+id/ll_camera_picture_module"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:visibility="visible"
-                android:orientation="vertical">
-            </LinearLayout>
-
-
-            <LinearLayout
-                android:id="@+id/ll_picture_module"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:visibility="visible"
-                android:orientation="vertical">
-            </LinearLayout>
-
-
-
-
-            <LinearLayout
-                android:id="@+id/ll_weigh_picture"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-                <LinearLayout
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="@dimen/dp_10"
-                    android:layout_marginRight="@dimen/dp_10"
-                    android:background="@null"
-                    android:padding="@dimen/dp_10"
-                    android:gravity="center_vertical"
-                    android:orientation="vertical">
-                    <TextView
-                        style="@style/fontSize"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:textStyle="bold"
-                        android:text="内件拍照">
-                    </TextView>
-                </LinearLayout>
-                <include layout="@layout/fragment_show_img"/>
-            </LinearLayout>
-
-
-            <LinearLayout
-                android:id="@+id/ll_result"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:background="@drawable/bg_white_et"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:layout_marginTop="20dp"
-                android:layout_marginBottom="20dp"
-                android:paddingBottom="10dp"
-                android:paddingTop="10dp"
-                android:gravity="center"
-                android:visibility="gone"
-                android:orientation="horizontal">
-                <TextView
-                    android:id="@+id/tv_result"
-                    style="@style/tvLeftStyle"
-                    android:paddingStart="20dp"
-                    android:paddingEnd="20dp"
-                    android:textSize="50sp"/>
-            </LinearLayout>
-
-
-
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginTop="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:layout_marginBottom="@dimen/dp_4"
-                android:background="@drawable/bg_white_et"
-                android:gravity="center_vertical"
-                android:orientation="horizontal"
-                android:layout_gravity="bottom"
-                android:padding="10dp">
-                <TextView
-                    style="@style/fontSize"
-                    android:id="@+id/btn_confirm"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginLeft="@dimen/dp_10"
-                    android:layout_marginRight="@dimen/dp_10"
-                    android:background="@drawable/bg_orange_item"
-                    android:gravity="center"
-                    android:text="确认入库"
-                    android:padding="10dp"
-                    android:textColor="@color/white"
-                    android:visibility="visible" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:id="@+id/ll_await_num"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginLeft="@dimen/dp_10"
-                android:layout_marginRight="@dimen/dp_10"
-                android:background="@null"
-                android:padding="@dimen/dp_10"
-                android:gravity="center_vertical"
-                android:orientation="horizontal">
-                <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                     android:text="待上传文件:">
-                </TextView>
-                <TextView
-                    android:id="@+id/tv_await_num"
-                    android:textColor="@color/md_red_900"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="0">
-                </TextView>
-            </LinearLayout>
-        </LinearLayout>
-
-
-    </ScrollView>
-
-
-</LinearLayout>

+ 39 - 0
app/src/main/res/layout/activity_fxy_detection_tray_make.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="4dp"
+                android:background="@color/md_grey_100" />
+
+            <LinearLayout
+                android:id="@+id/ll_tracking_number"
+                style="@style/FromLinearLayoutItem"
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_tracking_number"
+                    android:hint="扫描或者输入签收单"
+                    android:focusable="true"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+
+            </LinearLayout>
+        </LinearLayout>
+    </ScrollView>
+    <include layout="@layout/item_float_image" />
+</LinearLayout>

+ 125 - 0
app/src/main/res/layout/activity_fxy_detection_tray_make_four.xml

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <include layout="@layout/item_tray_make" />
+
+            <LinearLayout
+                android:id="@+id/ll_unit_code"
+                style="@style/FromLinearLayoutItem"
+
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_unit_code"
+                    android:hint="扫描或者输入内件码"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+            </LinearLayout>
+
+
+
+
+
+
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1dp"
+                android:background="@color/md_grey_100" />
+
+            <LinearLayout
+                style="@style/LinearLayoutLoginStyle"
+                android:background="@null"
+
+                android:paddingBottom="5dp"
+                android:paddingTop="5dp"
+                android:orientation="horizontal">
+                <TextView
+                    android:layout_marginLeft="@dimen/dp_10"
+                    style="@style/tvLeftStyle"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="最近扫描:" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:background="@drawable/bg_white_et"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:scrollbars="vertical"
+                android:paddingTop="@dimen/dp_10"
+                android:paddingBottom="@dimen/dp_10"
+                >
+                <android.support.v7.widget.RecyclerView
+                    android:id="@+id/recyclerview"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="#fff"
+                    android:overScrollMode="never"/>
+            </LinearLayout>
+
+
+
+
+            <LinearLayout
+                android:id="@+id/ll_btn_confirm"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginBottom="@dimen/dp_4"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:layout_gravity="bottom"
+                android:visibility="gone"
+                android:padding="10dp">
+                <TextView
+                    style="@style/fontSize"
+                    android:id="@+id/btn_confirm"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@drawable/bg_orange_item"
+                    android:gravity="center"
+                    android:text="本箱装箱完成"
+                    android:padding="10dp"
+                    android:textColor="@color/white"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+
+
+            <include layout="@layout/item_upload_await_number" />
+
+
+        </LinearLayout>
+
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 95 - 0
app/src/main/res/layout/activity_fxy_detection_tray_make_second.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <include layout="@layout/item_tray_make" />
+
+            <LinearLayout
+                android:id="@+id/ll_camera_picture_module"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+
+                android:orientation="vertical">
+            </LinearLayout>
+
+
+            <LinearLayout
+                android:id="@+id/ll_label_picture"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="gone"
+                android:orientation="vertical">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@null"
+                    android:padding="@dimen/dp_10"
+                    android:gravity="center_vertical"
+                    android:orientation="vertical">
+                    <TextView
+                        style="@style/fontSize"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textStyle="bold"
+                        android:text="本堆拍照,共 1 张">
+                    </TextView>
+                </LinearLayout>
+                <include layout="@layout/fragment_show_img"/>
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_btn_confirm"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginBottom="@dimen/dp_4"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:layout_gravity="bottom"
+                 android:padding="10dp">
+                <TextView
+                    style="@style/fontSize"
+                    android:id="@+id/btn_confirm"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@drawable/bg_orange_item"
+                    android:gravity="center"
+                    android:text="本单清点结束"
+                    android:padding="10dp"
+                    android:textColor="@color/white"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+            <include layout="@layout/item_upload_await_number" />
+        </LinearLayout>
+
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 70 - 0
app/src/main/res/layout/activity_fxy_detection_tray_make_third.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+
+            <include layout="@layout/item_tray_make" />
+
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="4dp"
+                android:background="@color/md_grey_100" />
+
+            <LinearLayout
+                android:id="@+id/ll_order_number"
+                style="@style/FromLinearLayoutItem"
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_order_number"
+                    android:hint="扫描或者输入箱号"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/ll_btn_confirm"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginBottom="@dimen/dp_4"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:layout_gravity="bottom"
+                android:padding="10dp">
+                <TextView
+                    style="@style/fontSize"
+                    android:id="@+id/btn_confirm"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@drawable/bg_orange_item"
+                    android:gravity="center"
+                    android:text="完成本堆"
+                    android:padding="10dp"
+                    android:textColor="@color/white"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+        </LinearLayout>
+    </ScrollView>
+    <include layout="@layout/item_float_image" />
+</LinearLayout>

+ 111 - 0
app/src/main/res/layout/activity_fxy_detection_tray_putin.xml

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:background="@color/md_grey_100"
+    android:orientation="vertical">
+    <ScrollView
+        android:id="@+id/ll_scroll_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fitsSystemWindows="true"
+        android:scrollbars="none">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
+            <LinearLayout
+                android:id="@+id/ll_tracking_number"
+                style="@style/FromLinearLayoutItem"
+                android:orientation="horizontal">
+                <EditText
+                    style="@style/EditTextStyle"
+                    android:id="@+id/et_tracking_number"
+                    android:hint="扫描或者输入签收单号"
+                    android:text=""/>
+                <include layout="@layout/item_image_close" />
+
+            </LinearLayout>
+
+
+
+
+            <LinearLayout
+                android:id="@+id/ll_label_picture"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:visibility="visible"
+                android:orientation="vertical">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@null"
+                    android:padding="@dimen/dp_10"
+                    android:gravity="center_vertical"
+                    android:orientation="vertical">
+                    <TextView
+                        style="@style/fontSize"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:textStyle="bold"
+                        android:text="签收单 | 每托照片">
+                    </TextView>
+                </LinearLayout>
+                <include layout="@layout/fragment_show_img"/>
+            </LinearLayout>
+
+
+
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="1dp"
+                android:background="@color/md_grey_100" />
+
+
+
+
+            <LinearLayout
+                android:id="@+id/ll_btn_confirm"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="@dimen/dp_10"
+                android:layout_marginTop="@dimen/dp_10"
+                android:layout_marginRight="@dimen/dp_10"
+                android:layout_marginBottom="@dimen/dp_4"
+                android:background="@drawable/bg_white_et"
+                android:gravity="center_vertical"
+                android:orientation="horizontal"
+                android:layout_gravity="bottom"
+                android:padding="10dp">
+                <TextView
+                    style="@style/fontSize"
+                    android:id="@+id/btn_confirm"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginLeft="@dimen/dp_10"
+                    android:layout_marginRight="@dimen/dp_10"
+                    android:background="@drawable/bg_orange_item"
+                    android:gravity="center"
+                    android:text="托盘入库完成"
+                    android:padding="10dp"
+                    android:textColor="@color/white"
+                    android:visibility="visible" />
+            </LinearLayout>
+
+
+
+            <include layout="@layout/item_upload_await_number" />
+
+
+        </LinearLayout>
+
+
+    </ScrollView>
+
+
+</LinearLayout>

+ 27 - 1
app/src/main/res/layout/fragment_homepager.xml

@@ -263,6 +263,8 @@
                         android:visibility="gone"
                         android:textStyle="bold" />
 
+
+
                     <TableRow
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
@@ -271,11 +273,35 @@
 
                         <TextView
                             style="@style/ImageViewWithTextStyle.FontSize"
-                            android:id="@+id/ivt_detection_putin"
+                            android:id="@+id/ivt_detection_box_putin"
                             android:drawableTop="@drawable/ic_mapan"
                             android:drawablePadding="5dp"
                             android:text="单箱入库" />
 
+                        <TextView
+                            style="@style/ImageViewWithTextStyle.FontSize"
+                            android:id="@+id/ivt_detection_tray_putin"
+                            android:drawableTop="@drawable/ic_mapan"
+                            android:drawablePadding="5dp"
+                            android:text="托盘入库" />
+
+                    </TableRow>
+
+                    <TableRow
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:layout_marginTop="@dimen/t12"
+                        android:weightSum="2">
+
+
+
+                        <TextView
+                            style="@style/ImageViewWithTextStyle.FontSize"
+                            android:id="@+id/ivt_detection_tray_make"
+                            android:drawableTop="@drawable/ic_mapan"
+                            android:drawablePadding="5dp"
+                            android:text="托盘清点" />
+
                         <TextView
                             style="@style/ImageViewWithTextStyle.FontSize"
                             android:id="@+id/ivt_scan_photos"

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

@@ -8,10 +8,10 @@
     <android.support.v7.widget.CardView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginBottom="1dp"
+        android:layout_marginBottom="5dp"
         android:layout_marginLeft="5dp"
         android:layout_marginRight="5dp"
-        android:layout_marginTop="1dp"
+        android:layout_marginTop="5dp"
         app:cardCornerRadius="5dp"
         app:cardElevation="5dp">
 

+ 102 - 0
app/src/main/res/layout/item_tray_make.xml

@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginLeft="@dimen/dp_10"
+    android:layout_marginRight="@dimen/dp_10"
+    android:layout_marginTop="@dimen/dp_10"
+    android:background="@drawable/bg_white_et"
+    android:gravity="center_vertical"
+    android:orientation="vertical"
+    android:paddingLeft="10dp"
+    android:paddingRight="10dp">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:orientation="horizontal">
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text="签收单号" />
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text=":" />
+
+        <com.fxy.baselibrary.views.MarqueeTextView
+            style="@style/mtRightStyle"
+            android:id="@+id/mt_tracking_number"
+            />
+
+    </LinearLayout>
+    <LinearLayout
+        android:id="@+id/ll_operate_number"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:orientation="horizontal">
+
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text="已操作堆数" />
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text=":" />
+
+        <com.fxy.baselibrary.views.MarqueeTextView
+            style="@style/mtRightStyle"
+            android:textColor="@color/md_red_900"
+            android:id="@+id/mt_operate_number"
+            />
+
+    </LinearLayout>
+    <LinearLayout
+        android:id="@+id/ll_box_number"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:visibility="gone"
+        android:orientation="horizontal">
+
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text="箱    号" />
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text=":" />
+
+        <com.fxy.baselibrary.views.MarqueeTextView
+            style="@style/mtRightStyle"
+            android:textColor="@color/md_red_900"
+            android:id="@+id/mt_box_number"
+            />
+
+    </LinearLayout>
+    <LinearLayout
+        android:id="@+id/ll_contents_number"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp"
+        android:paddingTop="5dp"
+        android:visibility="gone"
+        android:orientation="horizontal">
+
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text="内件数" />
+        <TextView
+            style="@style/tvLeftStyle"
+            android:text=":" />
+
+        <com.fxy.baselibrary.views.MarqueeTextView
+            style="@style/mtRightStyle"
+            android:textColor="@color/md_red_900"
+            android:id="@+id/mt_contents_number"
+            />
+
+    </LinearLayout>
+
+
+</LinearLayout>

+ 24 - 0
app/src/main/res/layout/item_upload_await_number.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/ll_await_num"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginLeft="@dimen/dp_10"
+    android:layout_marginRight="@dimen/dp_10"
+    android:background="@null"
+    android:padding="@dimen/dp_10"
+    android:gravity="center_vertical"
+    android:orientation="horizontal">
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="待上传文件:">
+    </TextView>
+    <TextView
+        android:id="@+id/tv_await_num"
+        android:textColor="@color/md_red_900"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="0">
+    </TextView>
+</LinearLayout>

+ 2 - 1
baselibrary/build.gradle

@@ -106,8 +106,9 @@ dependencies {
         exclude group: 'com.tencent.qcloud', module: 'beacon-android-release'
     }
 
+
+
     compile 'com.android.support:multidex:1.0.3'
-    compile 'com.aliyun.dpa:oss-android-sdk:2.9.5'
     testImplementation 'junit:junit:4.12'
     api files('libs/zxing_core_3.0.1.jar')
 }

+ 6 - 2
baselibrary/src/main/java/com/fxy/baselibrary/base/BaseActivity.java

@@ -967,8 +967,12 @@ public abstract class BaseActivity extends SupportActivity implements Observer {
                 LinearLayout  linearLayout = (LinearLayout)view.getParent();
                 for( int i = 0; i < linearLayout.getChildCount(); i++ ){
                     if( linearLayout.getChildAt(i) instanceof EditText ){
-                        ((EditText) linearLayout.getChildAt(i)).getText().clear();
-                        linearLayout.getChildAt(i).requestFocus();
+                        EditText editText = (EditText) linearLayout.getChildAt(i);
+                        //激活状态才可以清除
+                        if (editText.isEnabled()){
+                            editText.getText().clear();
+                            linearLayout.getChildAt(i).requestFocus();
+                        }
                         break;
                     }
                 }

+ 1 - 1
baselibrary/src/main/res/layout/pager_empty.xml

@@ -8,7 +8,7 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
-        android:layout_marginTop="50dp"
+        android:layout_marginTop="10dp"
         android:src="@drawable/ic_no_data"
         >
     </ImageView>

+ 3 - 3
config.gradle

@@ -2,14 +2,14 @@ ext {
 
     android = [
             compileSdkVersion: 27,
-            buildToolsVersion: "27.0.3",
+            buildToolsVersion: "26.0.2",
             supportVersion   : "27.0.1",
             applicationId    : "com",
             minSdkVersion    : 17,
             targetSdkVersion : 23,
             versionCode      : 1,
-            versionName      : "2.8.1",
-            versionApi       : "2.8",
+            versionName      : "2.9.0",
+            versionApi       : "2.9",
             versionRealm     : 2,
     ]
 

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,4 +1,4 @@
-#Wed Jul 08 13:46:08 CST 2020
+#Sat Aug 24 18:27:39 CST 2024
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME