Ver código fonte

优化打印,日志,更新内容

songw 2 meses atrás
pai
commit
58279bfcce
23 arquivos alterados com 559 adições e 421 exclusões
  1. 5 5
      app/src/main/java/com/uas/pda_smart_com/activity/FunctionActivity.java
  2. 7 1
      app/src/main/java/com/uas/pda_smart_com/application/PdaApplication.java
  3. 45 46
      app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialFra.java
  4. 10 11
      app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialOperFra.java
  5. 2 2
      app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutManagementFra.java
  6. 1 1
      app/src/main/java/com/uas/pda_smart_com/fragment/IndexInOutContentFragment.java
  7. 2 2
      app/src/main/java/com/uas/pda_smart_com/fragment/InventoryBarcodeFreeze.java
  8. 1 2
      app/src/main/java/com/uas/pda_smart_com/fragment/InventoryBindingFragment.java
  9. 1 2
      app/src/main/java/com/uas/pda_smart_com/fragment/JLTStorageInBarcodeFragment.java
  10. 5 3
      app/src/main/java/com/uas/pda_smart_com/fragment/MaterialOutRevocationStockFragment.java
  11. 72 24
      app/src/main/java/com/uas/pda_smart_com/fragment/VersionUpgradeFragment.java
  12. 3 1
      app/src/main/java/com/uas/pda_smart_com/util/CommonUtil.java
  13. 68 6
      app/src/main/java/com/uas/pda_smart_com/util/FileUtils.java
  14. 282 143
      app/src/main/java/com/uas/pda_smart_com/util/MyLog.java
  15. 16 14
      app/src/main/java/com/uas/pda_smart_com/util/PrintUtils.java
  16. 6 2
      app/src/main/java/com/uas/pda_smart_com/util/VolleyRequest.java
  17. 0 145
      app/src/main/java/com/uas/pda_smart_com/util/VollyRequest.java
  18. 1 1
      app/src/main/res/layout/fragment_iocout_free_collect.xml
  19. 1 1
      app/src/main/res/layout/fragment_iocout_make_material.xml
  20. 1 1
      app/src/main/res/layout/fragment_iocout_make_material_oper.xml
  21. 1 1
      app/src/main/res/layout/fragment_out_make_material.xml
  22. 5 3
      app/src/main/res/layout/item_grid_first.xml
  23. 24 4
      app/src/main/res/xml/file_paths.xml

+ 5 - 5
app/src/main/java/com/uas/pda_smart_com/activity/FunctionActivity.java

@@ -13,7 +13,7 @@ import android.widget.TextView;
 
 import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.fragment.BaseFragment;
-import com.uas.pda_smart_com.fragment.IOCOutMakeMaterial;
+import com.uas.pda_smart_com.fragment.IOCOutMakeMaterialFra;
 import com.uas.pda_smart_com.fragment.IndexInOutContentFragment;
 import com.uas.pda_smart_com.fragment.IndexSettingFragment;
 import com.uas.pda_smart_com.fragment.IndexShopContentFragment;
@@ -78,7 +78,7 @@ public class FunctionActivity extends BaseActivity implements View.OnClickListen
                     break;
                 //出库
                 case GloableParams.GRIDNAME_OUT_STORAGE:
-                    fragment = new IOCOutMakeMaterial();
+                    fragment = new IOCOutMakeMaterialFra();
                     break;
                 //车间管理
                 case GloableParams.GRIDNAME_SHOPCONTENT:
@@ -204,8 +204,8 @@ public class FunctionActivity extends BaseActivity implements View.OnClickListen
                 return;
             }
         }
-        if (fragment instanceof IOCOutMakeMaterialOper) {
-            if (((IOCOutMakeMaterialOper) fragment).onFragmentBackPressed()) {
+        if (fragment instanceof IOCOutMakeMaterialOperFra) {
+            if (((IOCOutMakeMaterialOperFra) fragment).onFragmentBackPressed()) {
                 return;
             }
         }
@@ -265,7 +265,7 @@ public class FunctionActivity extends BaseActivity implements View.OnClickListen
         /*if ((fragment instanceof MaterialCollectionFragment) && ((MaterialCollectionFragment) fragment).onFragmentBackPressed()) {
             return;
         }
-        if ((fragment instanceof IOCOutMakeMaterialOper) && ((IOCOutMakeMaterialOper) fragment).onFragmentBackPressed()) {
+        if ((fragment instanceof IOCOutMakeMaterialOperFra) && ((IOCOutMakeMaterialOperFra) fragment).onFragmentBackPressed()) {
             return;
         }
         if ((fragment instanceof FinishedGoodsCollectFragment) && ((FinishedGoodsCollectFragment) fragment).onFragmentBackPressed()) {

+ 7 - 1
app/src/main/java/com/uas/pda_smart_com/application/PdaApplication.java

@@ -19,6 +19,7 @@ import com.uas.pda_smart_com.tools.VolleyUtil;
 import com.uas.pda_smart_com.util.AndroidUtil;
 import com.uas.pda_smart_com.util.Constants;
 import com.uas.pda_smart_com.util.FakeX509TrustManager;
+import com.uas.pda_smart_com.util.MyLog;
 import com.uas.pda_smart_com.util.SoundUtil;
 import com.umeng.analytics.MobclickAgent;
 import com.umeng.commonsdk.UMConfigure;
@@ -95,7 +96,12 @@ public class PdaApplication extends Application {
         //友盟统计SDK
         initUmeng();
 
-
+        //删除非当天的Log日志, Android8.0以下用不了
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+            MyLog.delNotDayFile();
+        }else {
+            MyLog.isFileCreatedTodayDel();
+        }
     }
     private CountDownTimer countDownTimer = new CountDownTimer(COUNTDOWN_TIME, COUNTDOWN_INTERVAL) {
 

+ 45 - 46
app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterial.java → app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialFra.java

@@ -59,7 +59,7 @@ import com.uas.pda_smart_com.util.JsonTools;
 import com.uas.pda_smart_com.util.JsonUtils;
 import com.uas.pda_smart_com.util.LogUtil;
 import com.uas.pda_smart_com.util.MyArrayAdapter;
-import com.uas.pda_smart_com.util.VollyRequest;
+import com.uas.pda_smart_com.util.VolleyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
 
 import org.json.JSONArray;
@@ -75,14 +75,13 @@ import java.util.List;
 import java.util.Map;
 
 import butterknife.ButterKnife;
-import butterknife.OnClick;
 
 /**
  * 材料出库页面
  */
-public class IOCOutMakeMaterial extends BaseFragment {
+public class IOCOutMakeMaterialFra extends BaseFragment {
 
-    private static String TAG = "IOCOutMakeMaterial";
+    private static String TAG = "IOCOutMakeMaterialFra";
 
     private IOCOutMakeMaterialFuzzySearch fuzzySearchData;
     private MyArrayAdapter<String> autoStringAdapter;
@@ -265,7 +264,7 @@ public class IOCOutMakeMaterial extends BaseFragment {
                         pi_id.append(dataList.get(i).getPI_ID() + ",");
                     }
 
-                    IOCOutMakeMaterialOper iocOutMakeMaterialOper = new IOCOutMakeMaterialOper();
+                    IOCOutMakeMaterialOperFra iocOutMakeMaterialOperFra = new IOCOutMakeMaterialOperFra();
 
                     Bundle bundle = new Bundle();
                     if (pi_inoutno.length() >= 1)
@@ -274,9 +273,44 @@ public class IOCOutMakeMaterial extends BaseFragment {
                         bundle.putString("pi_id", pi_id.substring(0, pi_id.length() - 1));
                     bundle.putString("pd_whcode", "");
                     bundle.putBoolean("isMultiple", true);
-                    iocOutMakeMaterialOper.setArguments(bundle);
+                    iocOutMakeMaterialOperFra.setArguments(bundle);
 
-                    getFragmentManager().beginTransaction().replace(R.id.container_function_fragment, iocOutMakeMaterialOper).addToBackStack(null).commit();
+                    getFragmentManager().beginTransaction().replace(R.id.container_function_fragment, iocOutMakeMaterialOperFra).addToBackStack(null).commit();
+                }
+            }
+        });
+
+        cleanIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                inOutNo.setText("");
+            }
+        });
+
+        submitBtn.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
+                    CommonUtil.toastNoRepeat(getActivity(), "请输入出库单号");
+                } else if (CommonUtil.isStringContainsSpecialChar(inOutNo.getText().toString().trim())) {
+                    CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
+                } else if (CommonUtil.isStringContainsSpecialChar(whCode.getText().toString().trim())) {
+                    CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.whcode_cannot_contain_special));
+                } else {
+                    //判断单号和仓库组合是否已经存在于变量orders中
+                    boolean isExist = false;
+                    for (int i = 0; i < dataList.size(); i++) {
+                        if ((dataList.get(i).getPI_INOUTNO()).equals(inOutNo.getText().toString().trim()) && (dataList.get(i).getPD_WHCODE()).equals(whCode.getText().toString().trim())) {
+                            isExist = true;
+                            break;
+                        }
+                    }
+                    if (isExist) {
+                        Toast.makeText(getActivity(), "单号重复", Toast.LENGTH_SHORT).show();
+                        reset();
+                    } else {
+                        submitBtnClick();
+                    }
                 }
             }
         });
@@ -289,7 +323,7 @@ public class IOCOutMakeMaterial extends BaseFragment {
 
     private void getlistData() {
         progressDialog.show();
-        VollyRequest.getInstance().stringRequest(mStringRequest,
+        VolleyRequest.getInstance().stringRequest(mStringRequest,
                 new HttpParams.Builder()
                         .url(GloableParams.ADDRESS_GET_OUT_PRODIO_LIST)
                         .method(Request.Method.GET)
@@ -456,16 +490,16 @@ public class IOCOutMakeMaterial extends BaseFragment {
         String pi_inoutno = dataList.get(i).getPI_INOUTNO();
         String pd_whcode = dataList.get(i).getPD_WHCODE();
         String pi_id = dataList.get(i).getPI_ID() + "";
-        IOCOutMakeMaterialOper iocOutMakeMaterialOper = new IOCOutMakeMaterialOper();
+        IOCOutMakeMaterialOperFra iocOutMakeMaterialOperFra = new IOCOutMakeMaterialOperFra();
 
         Bundle bundle = new Bundle();
         bundle.putString("pi_inoutno", pi_inoutno);
         bundle.putString("pd_whcode", pd_whcode);
         bundle.putString("pi_id", pi_id);
         bundle.putBoolean("isMultiple", false);
-        iocOutMakeMaterialOper.setArguments(bundle);
+        iocOutMakeMaterialOperFra.setArguments(bundle);
 
-        getFragmentManager().beginTransaction().replace(R.id.container_function_fragment, iocOutMakeMaterialOper).addToBackStack(null).commit();
+        getFragmentManager().beginTransaction().replace(R.id.container_function_fragment, iocOutMakeMaterialOperFra).addToBackStack(null).commit();
     }
 
     @Override
@@ -571,41 +605,6 @@ public class IOCOutMakeMaterial extends BaseFragment {
         PdaApplication.mRequestQueue.add(stringRequest);
     }
 
-    @OnClick({R.id.clean_iv, R.id.submit_btn})
-    public void onClick(View view) {
-        switch (view.getId()) {
-            case R.id.clean_iv:
-                inOutNo.setText("");
-                break;
-            case R.id.submit_btn:
-                if (TextUtils.isEmpty(inOutNo.getText().toString().trim())) {
-                    CommonUtil.toastNoRepeat(getActivity(), "请输入出库单号");
-                } else if (CommonUtil.isStringContainsSpecialChar(inOutNo.getText().toString().trim())) {
-                    CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
-                } else if (CommonUtil.isStringContainsSpecialChar(whCode.getText().toString().trim())) {
-                    CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.whcode_cannot_contain_special));
-                } else {
-                    //判断单号和仓库组合是否已经存在于变量orders中
-                    boolean isExist = false;
-                    for (int i = 0; i < dataList.size(); i++) {
-                        if ((dataList.get(i).getPI_INOUTNO()).equals(inOutNo.getText().toString().trim()) && (dataList.get(i).getPD_WHCODE()).equals(whCode.getText().toString().trim())) {
-                            isExist = true;
-                            break;
-                        }
-                    }
-                    if (isExist) {
-                        Toast.makeText(getActivity(), "单号重复", Toast.LENGTH_SHORT).show();
-                        reset();
-                    } else {
-                        submitBtnClick();
-                    }
-                }
-
-                break;
-        }
-    }
-
-
     private void submitBtnClick() {
         progressDialog.show();
         String inOutNoString = inOutNo.getText().toString();

+ 10 - 11
app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialOper.java → app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutMakeMaterialOperFra.java

@@ -91,7 +91,6 @@ import com.uas.pda_smart_com.util.JsonUtils;
 import com.uas.pda_smart_com.util.LogUtil;
 import com.uas.pda_smart_com.util.PrintUtils;
 import com.uas.pda_smart_com.util.VolleyRequest;
-import com.uas.pda_smart_com.util.VollyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
 import com.uuzuche.lib_zxing.activity.CaptureActivity;
 import com.uuzuche.lib_zxing.activity.CodeUtils;
@@ -117,7 +116,7 @@ import okhttp3.OkHttpClient;
  * Created by RaoMeng on 2016/7/27.
  * 材料出库采集页面
  */
-public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener,
+public class IOCOutMakeMaterialOperFra extends BaseFragment implements View.OnClickListener, RadioGroup.OnCheckedChangeListener,
         HttpCallback, DataSourceManager.NotifyData,
         VolleyUtil.VolleyFinishListener {
     private static final int SCAN_BARCODE_CODE = 103;
@@ -129,7 +128,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
     private ImageView mScanImageView;
 
     private JsonObjectRequest jsonRequest;
-    private static final String TAG = "IOCOutMakeMaterialOper";
+    private static final String TAG = "IOCOutMakeMaterialOperFra";
     private Button btnActionbarWithback, btnActionbarRight;
     private String pi_inoutno;
     private String pd_whcode;
@@ -474,7 +473,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
     @Override
     protected void initViews() {
         ((TextView) (getActivity().findViewById(R.id.tv_actionbar_withback))).setText(getString(R.string.out_material_collect));
-        //        ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialOper();
+        //        ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialOperFra();
         ((FunctionActivity) getActivity()).setMoreBtnVisible(true);
         ((FunctionActivity) getActivity()).setScanIvVisible(true);
 
@@ -751,7 +750,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
 
     private void getInvertoryBarcode(String barcode) {
         progressDialog.show();
-        VollyRequest.getInstance().stringRequest(mStringRequest,
+        VolleyRequest.getInstance().stringRequest(mStringRequest,
                 new HttpParams.Builder()
                         .url(GloableParams.ADDRESS_GET_INVENTORY_BARCODE_DATA)
                         .method(Request.Method.GET)
@@ -1601,7 +1600,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                                                         .addParam("piid", pi_id)
                                                         .tag(TAG + "confirmpost")
                                                         .flag(FLAG_CONFIRM_POST).build(),
-                                                30 * 1000, IOCOutMakeMaterialOper.this);
+                                                30 * 1000, IOCOutMakeMaterialOperFra.this);
                                     }
                                 }).create().show();
                     }
@@ -2393,7 +2392,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                     Bundle bundle = new Bundle();
                     bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
                     blueToothPrintFragment.setArguments(bundle);
-                    FragmentUtils.switchFragment(IOCOutMakeMaterialOper.this, blueToothPrintFragment);
+                    FragmentUtils.switchFragment(IOCOutMakeMaterialOperFra.this, blueToothPrintFragment);
                 }
             }
         });
@@ -2407,7 +2406,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                 Bundle bundle = new Bundle();
                 bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, listArray.toString());
                 blueToothPrintFragment.setArguments(bundle);
-                FragmentUtils.switchFragment(IOCOutMakeMaterialOper.this, blueToothPrintFragment);
+                FragmentUtils.switchFragment(IOCOutMakeMaterialOperFra.this, blueToothPrintFragment);
             }
         });
 
@@ -2466,7 +2465,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                 Bundle bundle = new Bundle();
                 bundle.putString(Constants.KEY.BARCODE_PRINT_ARRAY, printArray.toString());
                 blueToothPrintFragment.setArguments(bundle);
-                FragmentUtils.switchFragment(IOCOutMakeMaterialOper.this, blueToothPrintFragment);
+                FragmentUtils.switchFragment(IOCOutMakeMaterialOperFra.this, blueToothPrintFragment);
             } else {
                 CommonUtil.toastNoRepeat(mActivity, "打印成功");
             }
@@ -2491,7 +2490,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
                     JSONObject resultObject = new JSONObject(s);
                     if (resultObject.optBoolean("success")) {
                         mPrintUrl = resultObject.optString("data");
-                        FileUtils.printBarcode(mPrintUrl, mHandler);
+                        FileUtils.printBarcode(getActivity(),mPrintUrl, mHandler);
                     }
                 } catch (JSONException e) {
                     if (progressDialog.isShowing())
@@ -2977,7 +2976,7 @@ public class IOCOutMakeMaterialOper extends BaseFragment implements View.OnClick
         mDbManager.closeDB();
         CommonUtil.closeKeybord(((EditText) etBarCode), mActivity);
         ButterKnife.unbind(this);
-        ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterial();
+        ((FunctionActivity) getActivity()).fragment = new IOCOutMakeMaterialFra();
     }
 
     /**

+ 2 - 2
app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutManagement.java → app/src/main/java/com/uas/pda_smart_com/fragment/IOCOutManagementFra.java

@@ -20,7 +20,7 @@ import butterknife.OnClick;
  * A simple {@link Fragment} subclass.
  * 出货管理页面
  */
-public class IOCOutManagement extends BaseFragment {
+public class IOCOutManagementFra extends BaseFragment {
 
     @Bind(R.id.out_material)
     LinearLayout outMaterial;
@@ -79,7 +79,7 @@ public class IOCOutManagement extends BaseFragment {
                 //材料出库
                 if (mProdOutType != null) {
                     if (mProdOutType.equals("byBatch") || mProdOutType.equals("byProdcode")) {
-                        mFragment = new IOCOutMakeMaterial();
+                        mFragment = new IOCOutMakeMaterialFra();
                         getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.container_function_fragment, mFragment).commit();
                     } else if (mProdOutType.equals("byBarcode")) {
 //                        mFragment = new IOCOutFreeCollectFragment();

+ 1 - 1
app/src/main/java/com/uas/pda_smart_com/fragment/IndexInOutContentFragment.java

@@ -68,7 +68,7 @@ public class IndexInOutContentFragment extends BaseFragment implements AdapterVi
                 break;
             //出库
             case GloableParams.GRIDNAME_CODEBAR_VERIFY:
-                fragment = new IOCOutManagement();
+                fragment = new IOCOutManagementFra();
                 getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.container_function_fragment, fragment, FunctionActivity.TAG_OUTMAKE).commit();
                 break;
         }

+ 2 - 2
app/src/main/java/com/uas/pda_smart_com/fragment/InventoryBarcodeFreeze.java

@@ -21,7 +21,7 @@ import com.uas.pda_smart_com.util.CommonUtil;
 import com.uas.pda_smart_com.util.FastjsonUtil;
 import com.uas.pda_smart_com.util.HttpCallback;
 import com.uas.pda_smart_com.util.HttpParams;
-import com.uas.pda_smart_com.util.VollyRequest;
+import com.uas.pda_smart_com.util.VolleyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
 
 public
@@ -114,7 +114,7 @@ class InventoryBarcodeFreeze extends BaseFragment implements View.OnClickListene
             return;
         }
         progressDialog.show();
-        VollyRequest.getInstance().stringRequest(mStringRequest,
+        VolleyRequest.getInstance().stringRequest(mStringRequest,
                 new HttpParams.Builder()
                         .url(GloableParams.ADDRESS_GET_INVENTORY_BARCODE_FREEZE)
                         .method(Request.Method.GET)

+ 1 - 2
app/src/main/java/com/uas/pda_smart_com/fragment/InventoryBindingFragment.java

@@ -65,7 +65,6 @@ import com.uas.pda_smart_com.util.HttpCallback;
 import com.uas.pda_smart_com.util.HttpParams;
 import com.uas.pda_smart_com.util.StringUtil;
 import com.uas.pda_smart_com.util.VolleyRequest;
-import com.uas.pda_smart_com.util.VollyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
 import com.uas.pda_smart_com.view.RecyclerItemDecoration;
 import com.uas.pda_smart_com.view.business.CommonSelectPop;
@@ -1277,7 +1276,7 @@ public class InventoryBindingFragment extends BaseFragment implements View.OnCli
                             public void onClick(DialogInterface dialogInterface, int i) {
                                 dialogInterface.dismiss();
                                 progressDialog.show();
-                                VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
+                                VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
                                         .url(GloableParams.ADDRESS_PDAIO_CONFIRMPOST)
                                         .method(Request.Method.POST)
                                         .addParam("piid", mPiid)

+ 1 - 2
app/src/main/java/com/uas/pda_smart_com/fragment/JLTStorageInBarcodeFragment.java

@@ -63,7 +63,6 @@ import com.uas.pda_smart_com.util.HttpCallback;
 import com.uas.pda_smart_com.util.HttpParams;
 import com.uas.pda_smart_com.util.StringUtil;
 import com.uas.pda_smart_com.util.VolleyRequest;
-import com.uas.pda_smart_com.util.VollyRequest;
 import com.uas.pda_smart_com.view.ClearableEditText;
 import com.uas.pda_smart_com.view.RecyclerItemDecoration;
 import com.uas.pda_smart_com.view.business.CommonSelectPop;
@@ -1277,7 +1276,7 @@ public class JLTStorageInBarcodeFragment extends BaseFragment implements View.On
                             public void onClick(DialogInterface dialogInterface, int i) {
                                 dialogInterface.dismiss();
                                 progressDialog.show();
-                                VollyRequest.getInstance().stringRequest(new HttpParams.Builder()
+                                VolleyRequest.getInstance().stringRequest(new HttpParams.Builder()
                                         .url(GloableParams.ADDRESS_PDAIO_CONFIRMPOST)
                                         .method(Request.Method.POST)
                                         .addParam("piid", mPiid)

+ 5 - 3
app/src/main/java/com/uas/pda_smart_com/fragment/MaterialOutRevocationStockFragment.java

@@ -181,9 +181,11 @@ public class MaterialOutRevocationStockFragment extends BaseFragment {
         String currentText = mBarcodeEditText.getText().toString().trim();
         if (TextUtils.isEmpty(currentText)) {
             CommonUtil.toastNoRepeat(getActivity(), "请输入号码");
-        } else if (!currentText.matches(Constants.REGEX.NO_CN_SYMBOL)) {
-            CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
-        } else {
+        }
+//        else if (!currentText.matches(Constants.REGEX.NO_CN_SYMBOL)) {
+//            CommonUtil.toastNoRepeat(getActivity(), getResources().getString(R.string.barcode_cannot_contain_special));
+//        }
+        else {
             if (CommonUtil.isNetWorkConnected(getActivity())) {
                 revokeStock();
             } else {

+ 72 - 24
app/src/main/java/com/uas/pda_smart_com/fragment/VersionUpgradeFragment.java

@@ -1,20 +1,26 @@
 package com.uas.pda_smart_com.fragment;
 
+import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Build;
+import android.os.Environment;
 import android.os.Handler;
 import android.os.Message;
+import android.support.annotation.RequiresApi;
 import android.support.v4.content.FileProvider;
 import android.text.TextUtils;
 import android.view.KeyEvent;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.android.volley.Request;
+import com.android.volley.toolbox.StringRequest;
 import com.uas.pda_smart_com.R;
 import com.uas.pda_smart_com.global.GloableParams;
 import com.uas.pda_smart_com.util.AndroidUtil;
@@ -24,16 +30,13 @@ import com.uas.pda_smart_com.util.FastjsonUtil;
 import com.uas.pda_smart_com.util.FileUtils;
 import com.uas.pda_smart_com.util.HttpCallback;
 import com.uas.pda_smart_com.util.HttpParams;
+import com.uas.pda_smart_com.util.MyLog;
 import com.uas.pda_smart_com.util.VolleyRequest;
 import com.uas.pda_smart_com.util.download.ProgressDownloader;
 import com.uas.pda_smart_com.util.download.ProgressResponseBody;
 import com.uas.pda_smart_com.view.business.CommonProgressPop;
 
 import java.io.File;
-import java.io.IOException;
-
-import static com.uas.pda_smart_com.util.Constants.CONSTANT.APK_FILE_NAME;
-import static com.uas.pda_smart_com.util.Constants.CONSTANT.APK_FILE_PATH;
 
 
 /**
@@ -48,6 +51,8 @@ public class VersionUpgradeFragment extends BaseFragment implements ProgressResp
     private long breakPoints, contentLength, totalBytes;
     private File file;
     private String mAttachId;
+    private StringRequest mStringRequest;
+    private File apkFile;
 
     @Override
     protected int getLayout() {
@@ -75,20 +80,9 @@ public class VersionUpgradeFragment extends BaseFragment implements ProgressResp
                 mProgressPop.showPopupWindow();
 
                 breakPoints = 0L;
-                File directory = new File(APK_FILE_PATH);
-                if (!directory.exists() && !directory.isDirectory()) {
-                    boolean mkdirs = directory.mkdirs();
-                } else {
-                    FileUtils.delAllFile(APK_FILE_PATH);
-                }
-                file = new File(APK_FILE_PATH, APK_FILE_NAME);
-                try {
-                    file.createNewFile();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
                 String downloadUrl = GloableParams.ADDRESS_COMMON_DOWNLOADBYID + "?id=" + mAttachId;
-                mDownloader = new ProgressDownloader(downloadUrl, file, VersionUpgradeFragment.this);
+                MyLog.e("aaa","下载路径为:" + downloadUrl);
+                mDownloader = new ProgressDownloader(downloadUrl, apkFile, VersionUpgradeFragment.this);
                 mDownloader.download(0L);
             }
         });
@@ -98,6 +92,64 @@ public class VersionUpgradeFragment extends BaseFragment implements ProgressResp
     protected void initDatas() {
         mOldVersionTv.setText(AndroidUtil.getVersionName(mActivity));
         getNewVersionMsg();
+
+        //不同版本分区处理
+        String fileName = "update_" + "APP" + ".apk";
+        File downloadDir;
+        if (Build.VERSION.SDK_INT >= 29) {
+            // Android 10+ 使用私有目录
+            downloadDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
+        } else {
+            downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+        }
+        if (!downloadDir.exists()) {
+            downloadDir.mkdirs();
+        }else {
+            FileUtils.delAllFile(downloadDir.getAbsolutePath()+ fileName);
+        }
+
+        apkFile = new File(downloadDir, fileName);
+
+        //检查权限
+        if (Build.VERSION.SDK_INT >= 26) {
+            if (!isHasInstallPermissionWithO(getActivity())) {
+                startInstallPermissionSettingActivity(getActivity());
+            }
+        }
+    }
+
+    /**
+     * 检测是否拥有安装未知应用权限canRequestPackageInstalls
+     */
+    @RequiresApi(api = Build.VERSION_CODES.O)
+    private boolean isHasInstallPermissionWithO(Context context){
+        if (context == null){
+            return false;
+        }
+        return context.getPackageManager().canRequestPackageInstalls();
+    }
+
+    /**
+     * 如果没有权限,则申请安装未知应用权限(打开获取权限界面)
+     */
+    @RequiresApi(api = Build.VERSION_CODES.O)
+    private void startInstallPermissionSettingActivity(Context context) {
+        if (context == null) {
+            return;
+        }
+        Intent intent = new Intent();
+        //获取当前apk包URI,并设置到intent中(这一步设置,可让“未知应用权限设置界面”只显示当前应用的设置项)
+        Uri packageURI = Uri.parse("package:" + context.getPackageName());
+        intent.setData(packageURI);
+        //设置不同版本跳转未知应用的动作
+        if (Build.VERSION.SDK_INT >= 26) {
+            //intent = new Intent(android.provider.Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES,packageURI);
+            intent.setAction(android.provider.Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
+        } else {
+            intent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
+        }
+        ((Activity) context).startActivity(intent);
+        Toast.makeText(getActivity(), "请打开未知应用安装权限", Toast.LENGTH_SHORT).show();
     }
 
     private void getNewVersionMsg() {
@@ -160,7 +212,6 @@ public class VersionUpgradeFragment extends BaseFragment implements ProgressResp
         }
     }
 
-
     private Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
@@ -181,17 +232,14 @@ public class VersionUpgradeFragment extends BaseFragment implements ProgressResp
                     CommonUtil.toastNoRepeat(mActivity, "下载完成");
                     mProgressPop.dismiss();
                     try {
-                        File apk = new File(APK_FILE_PATH, APK_FILE_NAME);
                         Intent intent = new Intent(Intent.ACTION_VIEW);
+                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                         if (Build.VERSION.SDK_INT >= 24) {
-                            Uri apkUri = FileProvider.getUriForFile(mActivity,
-                                    "com.uas.pda_smart_com.fileprovider", apk);
-                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                            Uri apkUri = FileProvider.getUriForFile(mActivity, getActivity().getPackageName() +".fileprovider", apkFile);
                             intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                             intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
                         } else {
-                            intent.setDataAndType(Uri.fromFile(apk), "application/vnd.android.package-archive");
-                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                            intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
                         }
                         mActivity.startActivity(intent);
                     } catch (Exception e) {

+ 3 - 1
app/src/main/java/com/uas/pda_smart_com/util/CommonUtil.java

@@ -609,9 +609,11 @@ public class CommonUtil {
             if (errorMsg != null && errorMsg.exceptionInfo != null) {
                 errorStr = errorMsg.exceptionInfo;
             } else {
-                errorStr = "系统错误";
+                //errorStr = "系统错误";
+                errorStr = new String(volleyError.networkResponse.data);
             }
         }
+        MyLog.d("aaa", "响应失败:" + errorStr);
         //振动提示
         makeNotice();
         /*MediaPlayer mp = new MediaPlayer();

+ 68 - 6
app/src/main/java/com/uas/pda_smart_com/util/FileUtils.java

@@ -15,6 +15,7 @@ import java.io.InputStream;
 import java.security.SecureRandom;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
+import java.util.Calendar;
 
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.SSLContext;
@@ -72,7 +73,7 @@ public class FileUtils {
     }
 
     public static File getCacheDir(Context context) {
-        File dirFire = new File(Constants.CONSTANT.APP_DIR_NAME + context.getPackageName() + "/cache/");
+        File dirFire = new File(context.getFilesDir().getAbsolutePath() + "/Android/data/" + context.getPackageName() + "/cache/");
         if (!dirFire.exists()) {
             dirFire.mkdirs();
         }
@@ -109,7 +110,7 @@ public class FileUtils {
             delAllFile(folderPath); //删除完里面所有内容
             String filePath = folderPath;
             filePath = filePath.toString();
-            java.io.File myFilePath = new java.io.File(filePath);
+            File myFilePath = new File(filePath);
             myFilePath.delete(); //删除空文件夹
         } catch (Exception e) {
             e.printStackTrace();
@@ -151,7 +152,7 @@ public class FileUtils {
      * @param printUrl 文件地址
      * @param mHandler
      */
-    public static void printBarcode(String printUrl, final Handler mHandler) {
+    public static void printBarcode(Context context,String printUrl, final Handler mHandler) {
         if (printUrl == null) {
             mHandler.sendEmptyMessage(Constants.CONSTANT.PRINT_FAILED);
             return;
@@ -187,11 +188,11 @@ public class FileUtils {
                         if (overload) {
                             mHandler.sendEmptyMessage(Constants.CONSTANT.PRINT_OVERLOAD);
                         } else {
-                            File directory = new File(Constants.CONSTANT.PRINT_FILE_PATH);
+                            File directory = new File(context.getFilesDir().getAbsolutePath() + "/UASPDA/printFile");
                             if (!directory.exists() && !directory.isDirectory()) {
                                 boolean mkdirs = directory.mkdirs();
                             } else {
-                                FileUtils.delAllFile(Constants.CONSTANT.PRINT_FILE_PATH);
+                                FileUtils.delAllFile(context.getFilesDir().getAbsolutePath() + "/UASPDA/printFile");
                             }
                             String printData = responseObject.optString("data");
                             if (TextUtils.isEmpty(printData)) {
@@ -199,7 +200,7 @@ public class FileUtils {
                             } else {
                                 inputStream = getStringStream(printData);
 
-                                File file = new File(Constants.CONSTANT.PRINT_FILE_PATH + "/", Constants.CONSTANT.PRINT_FILE_NAME);
+                                File file = new File(context.getFilesDir().getAbsolutePath() + "/UASPDA/printFile" + "/", Constants.CONSTANT.PRINT_FILE_NAME);
                                 if (!file.exists()) {
                                     try {
                                         file.createNewFile();
@@ -282,4 +283,65 @@ public class FileUtils {
             return true;
         }
     }
+
+    /**
+     * 判断文件是否为当天创建(使用最后修改时间)
+     * Android 7.0推荐使用此方法
+     */
+    public static boolean isFileCreatedToday(File file) {
+        if (file == null || !file.exists()) {
+            return false;
+        }
+
+        // 获取文件的最后修改时间
+        long lastModified = file.lastModified();
+
+        // 获取当前时间的Calendar
+        Calendar today = Calendar.getInstance();
+
+        // 获取文件时间的Calendar
+        Calendar fileDate = Calendar.getInstance();
+        fileDate.setTimeInMillis(lastModified);
+
+        // 比较年、月、日是否相同
+        return today.get(Calendar.YEAR) == fileDate.get(Calendar.YEAR) &&
+                today.get(Calendar.MONTH) == fileDate.get(Calendar.MONTH) &&
+                today.get(Calendar.DAY_OF_MONTH) == fileDate.get(Calendar.DAY_OF_MONTH);
+    }
+
+    /**
+     * 获取文件创建时间的字符串表示
+     */
+    public static String getFileCreationTimeString(File file) {
+        if (file == null || !file.exists()) {
+            return "文件不存在";
+        }
+
+        long lastModified = file.lastModified();
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(lastModified);
+
+        return String.format("%04d-%02d-%02d %02d:%02d:%02d",
+                cal.get(Calendar.YEAR),
+                cal.get(Calendar.MONTH) + 1, // 月份从0开始
+                cal.get(Calendar.DAY_OF_MONTH),
+                cal.get(Calendar.HOUR_OF_DAY),
+                cal.get(Calendar.MINUTE),
+                cal.get(Calendar.SECOND));
+    }
+
+    /**
+     * 格式化文件大小
+     */
+    public static String formatFileSize(long size) {
+        if (size < 1024) {
+            return size + " B";
+        } else if (size < 1024 * 1024) {
+            return String.format("%.2f KB", size / 1024.0);
+        } else if (size < 1024 * 1024 * 1024) {
+            return String.format("%.2f MB", size / (1024.0 * 1024));
+        } else {
+            return String.format("%.2f GB", size / (1024.0 * 1024 * 1024));
+        }
+    }
 }

+ 282 - 143
app/src/main/java/com/uas/pda_smart_com/util/MyLog.java

@@ -1,161 +1,300 @@
 package com.uas.pda_smart_com.util;
 
 import android.annotation.SuppressLint;
+import android.os.Build;
+import android.os.Environment;
+import android.support.annotation.RequiresApi;
 import android.util.Log;
 
+import com.uas.pda_smart_com.application.PdaApplication;
+
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.util.Date;
 
+
 /**
  * 带日志文件输入,又可控开关的日志调试
  */
 @SuppressLint("SimpleDateFormat")
 public class MyLog {
-	public static Boolean MYLOG_SWITCH = true; // 日志文件总开关
-	private static Boolean MYLOG_WRITE_TO_FILE = true;// 日志写入文件开关
-	private static char MYLOG_TYPE = 'v';// 输入日志类型,w代表只输出告警信息等,v代表输出所有信息
-	@SuppressLint("SdCardPath")
-	private static String MYLOG_PATH_SDCARD_DIR1 = "/sdcard/MSShow";    // 日志文件在sdcard中的路径
-	private static String MYLOG_PATH_SDCARD_DIR2 = "/Log";
-	private static String MYLOG_PATH_SDCARD_DIR = MYLOG_PATH_SDCARD_DIR1+MYLOG_PATH_SDCARD_DIR2;
-	private static String MYLOGFILEName = "Log.txt";// 本类输出的日志文件名称
-
-	@SuppressLint("SimpleDateFormat")
-	private static SimpleDateFormat myLogSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
-
-	private static boolean isDebug = true;		//普通log的开关
-	private static String TAG = "英唐" +"-----------";
-
-	public static void e(String msg){
-		if(isDebug){
-			Log.e(TAG, msg);
-		}
-	}
-
-	public static void w(String msg){
-		if(isDebug){
-			Log.w(TAG, msg);
-		}
-	}
-
-	public static void d(String msg){
-		if(isDebug){
-			Log.d(TAG, msg);
-		}
-	}
-
-	public static void i(String msg){
-		if(isDebug){
-			Log.i(TAG, msg);
-		}
-	}
-
-	public static void w(String tag, Object msg) { // 警告信息
-		log(tag, msg.toString(), 'w');
-	}
-
-	public static void e(String tag, Object msg) { // 错误信息
-		log(tag, msg.toString(), 'e');
-	}
-
-	public static void d(String tag, Object msg) {// 调试信息
-		log(tag, msg.toString(), 'd');
-	}
-
-	public static void i(String tag, Object msg) {//
-		log(tag, msg.toString(), 'i');
-	}
-
-	public static void v(String tag, Object msg) {
-		log(tag, msg.toString(), 'v');
-	}
-
-	public static void w(String tag, String text) {
-		log(tag, text, 'w');
-	}
-
-	public static void e(String tag, String text) {
-		log(tag, text, 'e');
-	}
-
-	public static void d(String tag, String text) {
-		log(tag, text, 'd');
-	}
-
-	public static void i(String tag, String text) {
-		log(tag, text, 'i');
-	}
-
-	public static void v(String tag, String text) {
-		log(tag, text, 'v');
-	}
-
-	/**
-	 * 根据tag, msg和等级,输出日志
-	 */
-	private static void log(String tag, String msg, char level) {
-		msg = "\r\n"+msg;
-		if (MYLOG_SWITCH) {
-			if ('e' == level && ('e' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) { // 输出错误信息
-				Log.e(tag, msg);
-			} else if ('w' == level && ('w' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
-				Log.w(tag, msg);
-			} else if ('d' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
-				Log.d(tag, msg);
-			} else if ('i' == level && ('d' == MYLOG_TYPE || 'v' == MYLOG_TYPE)) {
-				Log.i(tag, msg);
-			} else {
-				Log.v(tag, msg);
-			}
-			if (MYLOG_WRITE_TO_FILE) {
-				writeLogtoFile(String.valueOf(level), tag, msg);
-			}
-		}
-	}
-
-	/**
-	 * 打开日志文件并写入日志
-	 * **/
-	private static void writeLogtoFile(String mylogtype, String tag, String text) {// 新建或打开日志文件
-		isExist(MYLOG_PATH_SDCARD_DIR1);
-		isExist(MYLOG_PATH_SDCARD_DIR);
-		Date nowtime = new Date();
-//		String needWriteFiel = logfile.format(nowtime);
-		String needWriteMessage = myLogSdf.format(nowtime) + "    " + mylogtype
-				+ "    " + tag + "    " + text;
-		File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
-		try {
-			FileWriter filerWriter = new FileWriter(file, true);// 后面这个参数代表是不是要接上文件中原来的数据,不进行覆盖
-			BufferedWriter bufWriter = new BufferedWriter(filerWriter);
-			bufWriter.write(needWriteMessage);
-			bufWriter.newLine();
-			bufWriter.close();
-			filerWriter.close();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * 删除制定的日志文件
-	 * */
-	public static void delFile() {// 删除日志文件
-		File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
-		if (file.exists()) {
-			file.delete();
-		}
-	}
-
-	public static void isExist(String path) {
-		File file = new File(path);
-		// 判断文件夹是否存在,如果不存在则创建文件夹
-		if (!file.exists()) {
-			file.mkdir();
-		}
-
-	}
+    public static Boolean MYLOG_SWITCH = true; // 日志文件总开关
+    private static Boolean MYLOG_WRITE_TO_FILE = true;// 日志写入文件开关
+    private static char MYLOG_TYPE = 'v';// 输入日志类型,w代表只输出告警信息等,v代表输出所有信息
+    @SuppressLint("SdCardPath")
+//    private static String MYLOG_PATH_SDCARD_DIR1 = "/sdcard/MSShow";    // 日志文件在sdcard中的路径
+//    private static String MYLOG_PATH_SDCARD_DIR1 = "/data/data/" + PdaApplication.getmContext().getPackageName();  //APP包下创建的文件不需要权限
+    private static String MYLOG_PATH_SDCARD_DIR1 = "/sdcard/Android/data/" + PdaApplication.getmContext().getPackageName();  //模拟器的APP包下创建的文件
+    private static String MYLOG_PATH_SDCARD_DIR2 = "/Log";
+    private static String MYLOG_PATH_SDCARD_DIR = MYLOG_PATH_SDCARD_DIR1 + MYLOG_PATH_SDCARD_DIR2;
+    private static String MYLOGFILEName = "Log.txt";// 本类输出的日志文件名称
+
+    @SuppressLint("SimpleDateFormat")
+    private static SimpleDateFormat myLogSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 日志的输出格式
+
+    private static boolean isDebug = true;        //普通log的开关
+    private static String TAG = "英唐" + "-----------";
+
+    private static volatile MyLog myLog; // 使用 volatile 关键字确保多线程环境下的可见性
+
+    private MyLog() {
+    }
+
+    public static MyLog getInstance() {
+        if (myLog == null) { // 第一次检查,提高效率,避免每次都进行同步
+            synchronized (MyLog.class) { // 同步代码块,保证线程安全
+                if (myLog == null) { // 第二次检查,防止多个线程同时进入同步块时重复创建实例
+                    myLog = new MyLog();
+                    //兼容不同版本分区处理
+                    File downloadDir = null;
+                    if (Build.VERSION.SDK_INT >= 29) {
+                        // Android 10+ 使用私有目录
+                        downloadDir = PdaApplication.getmContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
+                    } else {
+                        downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+                    }
+                    if (!downloadDir.exists()) {
+                        downloadDir.mkdirs();
+                    }
+                    MYLOG_PATH_SDCARD_DIR1 = downloadDir.getAbsolutePath() + File.separator + PdaApplication.getmContext().getPackageName();
+
+                    //Log.e("aaa", "MyLog被创建了: " + MYLOG_PATH_SDCARD_DIR1);
+                }
+            }
+        }
+        return myLog;
+    }
+
+    public static void e(String msg) {
+        if (isDebug) {
+            Log.e(TAG, msg);
+        }
+    }
+
+    public static void w(String msg) {
+        if (isDebug) {
+            Log.w(TAG, msg);
+        }
+    }
+
+    public static void d(String msg) {
+        if (isDebug) {
+            Log.d(TAG, msg);
+        }
+    }
+
+    public static void i(String msg) {
+        if (isDebug) {
+            Log.i(TAG, msg);
+        }
+    }
+
+    public static void w(String tag, Object msg) { // 警告信息
+        log(tag, msg.toString(), 'w');
+    }
+
+    public static void e(String tag, Object msg) { // 错误信息
+        log(tag, msg.toString(), 'e');
+    }
+
+    public static void d(String tag, Object msg) {// 调试信息
+        log(tag, msg.toString(), 'd');
+    }
+
+    public static void i(String tag, Object msg) {//
+        log(tag, msg.toString(), 'i');
+    }
+
+    public static void v(String tag, Object msg) {
+        log(tag, msg.toString(), 'v');
+    }
+
+    public static void w(String tag, String text) {
+        log(tag, text, 'w');
+    }
+
+    public static void e(String tag, String text) {
+        log(tag, text, 'e');
+    }
+
+    public static void d(String tag, String text) {
+        log(tag, text, 'd');
+    }
+
+    public static void i(String tag, String text) {
+        log(tag, text, 'i');
+    }
+
+    public static void v(String tag, String text) {
+        log(tag, text, 'v');
+    }
+
+    /**
+     * 根据tag, msg和等级,输出日志
+     */
+    private static void log(String tag, String msg, char level) {
+        msg = "\r\n" + msg;
+        if (MYLOG_SWITCH) {
+            setInterceptlength(tag, msg, level);
+            if (MYLOG_WRITE_TO_FILE && 'd' == level) {
+                writeLogtoFile(String.valueOf(level), tag, msg);
+            }
+        }
+    }
+
+    public static void setInterceptlength(String tag, String msg,char level) {
+        if (msg.length() > 3000) {
+            // 因为Logcat一次最多能输出4000个字符左右,所以按3000字符分段比较好
+            int chunkCount = msg.length() / 3000; // 分割成多少段
+            for (int i = 0; i <= chunkCount; i++) {
+                int max = 3000 * (i + 1);
+                if (max >= msg.length()) {
+                    if ('e' == level) { // 输出错误信息
+                        Log.e(tag, msg.substring(3000 * i));
+                    } else if ('w' == level) {
+                        Log.w(tag, msg.substring(3000 * i));
+                    } else if ('d' == level) {
+                        Log.d(tag, msg.substring(3000 * i));
+                    } else if ('i' == level) {
+                        Log.i(tag, msg.substring(3000 * i));
+                    } else {
+                        Log.v(tag, msg.substring(3000 * i));
+                    }
+                } else {
+                    if ('e' == level) {
+                        Log.e(tag, msg.substring(3000 * i, max));
+                    } else if ('w' == level) {
+                        Log.w(tag, msg.substring(3000 * i, max));
+                    } else if ('d' == level) {
+                        Log.d(tag, msg.substring(3000 * i, max));
+                    } else if ('i' == level) {
+                        Log.i(tag, msg.substring(3000 * i, max));
+                    } else {
+                        Log.v(tag, msg.substring(3000 * i, max));
+                    }
+                }
+            }
+        } else {
+            if ('e' == level) {
+                Log.e(tag, msg);
+            } else if ('w' == level) {
+                Log.w(tag, msg);
+            } else if ('d' == level) {
+                Log.d(tag, msg);
+            } else if ('i' == level) {
+                Log.i(tag, msg);
+            } else {
+                Log.v(tag, msg);
+            }
+        }
+    }
+
+    /**
+     * 打开日志文件并写入日志,
+     **/
+    private static void writeLogtoFile(String mylogtype, String tag, String text) {
+    	// 新建或打开日志文件
+        isExist(MYLOG_PATH_SDCARD_DIR1);
+        isExist(MYLOG_PATH_SDCARD_DIR);
+        Date nowtime = new Date();
+        //		String needWriteFiel = logfile.format(nowtime);
+        String needWriteMessage = myLogSdf.format(nowtime) + "    " + mylogtype
+                + "    " + tag + "    " + text;
+        File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+        try {
+            FileWriter filerWriter = new FileWriter(file, true);// 后面这个参数代表是不是要接上文件中原来的数据,不进行覆盖
+            BufferedWriter bufWriter = new BufferedWriter(filerWriter);
+            bufWriter.write(needWriteMessage);
+            bufWriter.newLine();
+            bufWriter.close();
+            filerWriter.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 删除制定的日志文件
+     */
+    public static void delFile() {// 删除日志文件
+        File file = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+        if (file.exists()) {
+            file.delete();
+        }
+    }
+
+    public static void isExist(String path) {
+        File file = new File(path);
+        // 判断文件夹是否存在,如果不存在则创建文件夹
+        if (!file.exists()) {
+            file.mkdir();
+        }
+    }
+
+    /**
+     * 取消Android8.0的提示限制
+     */
+    @RequiresApi(api = Build.VERSION_CODES.O)
+    public static void delNotDayFile(){
+        File fileP = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+        if (fileP.exists()) {
+            Path path = Paths.get(MYLOG_PATH_SDCARD_DIR + "/" + MYLOGFILEName); //文件路径
+            try {
+                // 获取文件的属性
+                BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
+                // 获取文件的创建时间
+                FileTime creationTime = attrs.creationTime();
+                // 转换为LocalDateTime以便于比较
+                //将FileTime对象转换为LocalDateTime以便于与当前日期进行比较。这里使用了系统的默认时区(ZoneId.systemDefault())。如果需要特定时区,可以替换为相应的ZoneId。
+                //通过LocalDateTime 的 toLocalDate()方法将时间转换为仅包含日期(忽略时间),然后与当前日期进行比较。
+                LocalDateTime creationDateTime = creationTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+                LocalDateTime now = LocalDateTime.now();
+
+                // 比较是否为当天创建
+                if (isToday(creationDateTime)) {
+                    //System.out.println("文件是今天创建的。");
+                } else {
+                    //System.out.println("文件不是今天创建的。");
+                    delFile();  //删除不是当天日期
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    // 辅助方法,检查日期是否为今天
+    @RequiresApi(api = Build.VERSION_CODES.O)
+    private static boolean isToday(LocalDateTime dateTime) {
+        LocalDate today = LocalDate.now();
+        LocalDate fileDate = dateTime.toLocalDate();
+        return today.equals(fileDate);
+    }
+
+    /**
+     * 判断文件是否为当天创建(使用最后修改时间),不同则删除
+     * Android 7.0推荐使用此方法
+     */
+    public static void isFileCreatedTodayDel() {
+        File fileP = new File(MYLOG_PATH_SDCARD_DIR, MYLOGFILEName);
+        if (fileP.exists()) {
+            if (!FileUtils.isFileCreatedToday(fileP)) {
+                delFile();  //删除不是当天创建的日期
+            }
+        }
+    }
+
+
+
 }

+ 16 - 14
app/src/main/java/com/uas/pda_smart_com/util/PrintUtils.java

@@ -2,7 +2,6 @@ package com.uas.pda_smart_com.util;
 
 import android.content.Context;
 import android.text.TextUtils;
-import android.util.Log;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
@@ -13,29 +12,32 @@ import com.uas.pda_smart_com.tools.SharedPreUtil;
 public class PrintUtils {
 
     public static int printBar(Context context, String dataJson, int dpi, String printTemplate) {
-        Log.e("listArraythree1",dataJson);
         try {
             if (dpi <= 0) {
                 dpi = 203;
             }
-
+            MyLog.e("aaa", "打印数据是;"  + dataJson);
             if (TextUtils.isEmpty(printTemplate)) {
                 printTemplate = SharedPreUtil.getString(context, Constants.FLAG.PRINT_TEMPLATE_CACHE, "");
             }
-            Log.e("listArraythree2",printTemplate);
-            int offset = 6,
-                    h = 400,
-                    v = 800,
-                    height = 300,
-                    qty = 1;
-//                    h = 200,
-//                    v = 200,
-//                    height = 200,
-//                    qty = 1;
+            MyLog.e("aaa", "模版数据是:" + printTemplate);
 
             JSONArray templateArray = JSON.parseArray(printTemplate);
+            JSONObject templateObj = templateArray.getJSONObject(0);
+            //la_offset 偏移值
+            //la_h    横向分辨率
+            //la_y   纵向分辨率
+            //la_height  最大高度
+            //la_qty 重复打印次数
+            int la_offset = FastjsonUtil.getInt(templateObj, "LA_OFFSET") == 0 ? 6 : FastjsonUtil.getInt(templateObj, "LA_OFFSET");
+            int la_h = FastjsonUtil.getInt(templateObj, "LA_H") == 0 ? 400 : FastjsonUtil.getInt(templateObj, "LA_H");
+            int la_y = FastjsonUtil.getInt(templateObj, "LA_Y") == 0 ? 800 : FastjsonUtil.getInt(templateObj, "LA_Y");
+            int la_height = FastjsonUtil.getInt(templateObj, "LA_HEIGHT") == 0 ? 300 : FastjsonUtil.getInt(templateObj, "LA_HEIGHT");
+            int la_qty = FastjsonUtil.getInt(templateObj, "LA_QTY") == 0 ? 1 : FastjsonUtil.getInt(templateObj, "LA_QTY");
+
             if (templateArray != null && templateArray.size() > 0) {
-                PrintHelper printHelper = new PrintHelper(offset, h, v, height, qty);
+                PrintHelper printHelper = new PrintHelper(la_offset, la_h, la_y, la_height, la_qty);
+
                 for (int i = 0; i < templateArray.size(); i++) {
                     JSONObject templateObject = templateArray.getJSONObject(i);
 

+ 6 - 2
app/src/main/java/com/uas/pda_smart_com/util/VolleyRequest.java

@@ -52,6 +52,10 @@ public class VolleyRequest {
         stringRequest(null, httpParams, 10 * 1000, httpCallback);
     }
 
+    public void stringRequest(final HttpParams httpParams, final int timeoutMs, final HttpCallback httpCallback) {
+        stringRequest(null, httpParams, timeoutMs, httpCallback);
+    }
+
     public void stringRequest(StringRequest stringRequest, final HttpParams httpParams, final int timeoutMs, final HttpCallback httpCallback) {
         if (httpParams == null) {
             throw new IllegalArgumentException("httpParams can not be NULL");
@@ -99,8 +103,8 @@ public class VolleyRequest {
                 index++;
             }
         }
-        MyLog.e("aaa","接口地址:" + url);
 
+        MyLog.d("aaa","*************************" + "\n" + "接口地址:" + url);
         PdaApplication.mRequestQueue.cancelAll(httpParams.getUrl());
 
         stringRequest = new StringRequest(httpParams.getMethod(), url,
@@ -108,7 +112,7 @@ public class VolleyRequest {
                     @Override
                     public void onResponse(String s) {
                         try {
-                            LogUtil.prinlnLongMsg("responseSucc", s);
+                            MyLog.d("aaa","响应成功:" + s);
                             httpCallback.onSuccess(httpParams.getFlag(), s);
                         } catch (Exception e) {
                             e.printStackTrace();

+ 0 - 145
app/src/main/java/com/uas/pda_smart_com/util/VollyRequest.java

@@ -1,145 +0,0 @@
-package com.uas.pda_smart_com.util;
-
-import com.android.volley.AuthFailureError;
-import com.android.volley.DefaultRetryPolicy;
-import com.android.volley.Request;
-import com.android.volley.Response;
-import com.android.volley.VolleyError;
-import com.android.volley.toolbox.StringRequest;
-import com.uas.pda_smart_com.R;
-import com.uas.pda_smart_com.application.PdaApplication;
-import com.uas.pda_smart_com.tools.VolleyUtil;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author RaoMeng
- * @describe
- * @date 2018/4/27 11:26
- */
-
-public class VollyRequest {
-    private static VollyRequest instance;
-
-    private VollyRequest() {
-
-    }
-
-    public static final VollyRequest getInstance() {
-        if (instance == null) {
-            synchronized (VollyRequest.class) {
-                if (instance == null) {
-                    return new VollyRequest();
-                }
-            }
-        }
-        return instance;
-    }
-
-    public void stringRequest(StringRequest stringRequest, final HttpParams httpParams, final HttpCallback httpCallback) {
-        stringRequest(stringRequest, httpParams, 10 * 1000, httpCallback);
-    }
-
-    public void stringRequest(final HttpParams httpParams, final HttpCallback httpCallback) {
-        stringRequest(null, httpParams, 10 * 1000, httpCallback);
-    }
-
-    public void stringRequest(final HttpParams httpParams, final int timeoutMs, final HttpCallback httpCallback) {
-        stringRequest(null, httpParams, timeoutMs, httpCallback);
-    }
-
-    public void stringRequest(StringRequest stringRequest, final HttpParams httpParams, final int timeoutMs, final HttpCallback httpCallback) {
-        if (httpParams == null) {
-            throw new IllegalArgumentException("httpParams can not be NULL");
-        }
-        if (httpCallback == null) {
-            throw new IllegalArgumentException("callback can not be NULL");
-        }
-        if (httpParams.getUrl() == null) {
-            throw new IllegalArgumentException("requestUrl can not be NULL");
-        }
-
-        if (!CommonUtil.isNetWorkConnected((PdaApplication.getmContext()))) {
-            try {
-                httpCallback.onFail(httpParams.getFlag(), PdaApplication.getmContext().getString(R.string.net_not_connect));
-                return;
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-
-        String url = httpParams.getUrl();
-        if (httpParams.getMethod() == Request.Method.GET && httpParams.getParams().size() > 0) {
-            Set<Map.Entry<String, String>> entries = httpParams.getParams().entrySet();
-
-            int index = 1;
-            for (Map.Entry<String, String> paramEntry : entries) {
-                if (index == 1) {
-                    try {
-                        url += "?" + paramEntry.getKey() + "=" + URLEncoder.encode(paramEntry.getValue(), "UTF-8");
-                    } catch (UnsupportedEncodingException e) {
-                        url += "?" + paramEntry.getKey() + "=" + paramEntry.getValue();
-                    }
-                } else {
-                    try {
-                        url += "&" + paramEntry.getKey() + "=" + URLEncoder.encode(paramEntry.getValue(), "UTF-8");
-                    } catch (UnsupportedEncodingException e) {
-                        url += "&" + paramEntry.getKey() + "=" + paramEntry.getValue();
-                    }
-                }
-                index++;
-            }
-        }
-
-        MyLog.e("aaa","接口地址: " + url);
-//        PdaApplication.mRequestQueue.cancelAll(httpParams.getTag());
-
-        stringRequest = new StringRequest(httpParams.getMethod(), url,
-                new Response.Listener<String>() {
-                    @Override
-                    public void onResponse(String s) {
-                        try {
-                            LogUtil.prinlnLongMsg("responseSucc", s);
-                            httpCallback.onSuccess(httpParams.getFlag(), s);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                },
-                new Response.ErrorListener() {
-                    @Override
-                    public void onErrorResponse(VolleyError volleyError) {
-                        String errorToast = CommonUtil.showErrorToast(volleyError, false);
-                        try {
-                            httpCallback.onFail(httpParams.getFlag(), errorToast);
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                }) {
-            @Override
-            public Map<String, String> getHeaders() throws AuthFailureError {
-                if (httpParams.getHeaders().isEmpty()) {
-                    return VolleyUtil.getVolleyUtil().setCookies();
-                } else {
-                    return httpParams.getHeaders();
-                }
-            }
-
-            @Override
-            protected Map<String, String> getParams() throws AuthFailureError {
-                if (httpParams.getMethod() == Method.POST) {
-                    return httpParams.getParams();
-                }
-                return super.getParams();
-            }
-        };
-
-        stringRequest.setRetryPolicy(new DefaultRetryPolicy(timeoutMs, 0, 1f));
-        stringRequest.setTag(httpParams.getTag());
-        PdaApplication.mRequestQueue.add(stringRequest);
-    }
-}

+ 1 - 1
app/src/main/res/layout/fragment_iocout_free_collect.xml

@@ -5,7 +5,7 @@
     android:layout_height="match_parent"
     android:orientation="vertical"
     android:id="@+id/fragment_iocout_make_material_oper"
-    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterialOper">
+    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterialOperFra">
     <!--    <include
             android:id="@+id/include_menuactionbar"
             layout="@layout/actionbar_withback" />-->

+ 1 - 1
app/src/main/res/layout/fragment_iocout_make_material.xml

@@ -3,7 +3,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterial">
+    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterialFra">
 
     <!--    &lt;!&ndash;SearchButton&ndash;&gt;
         <LinearLayout

+ 1 - 1
app/src/main/res/layout/fragment_iocout_make_material_oper.xml

@@ -2,7 +2,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterialOper">
+    tools:context="com.uas.pda_smart_com.fragment.IOCOutMakeMaterialOperFra">
     <!--    <include
             android:id="@+id/include_menuactionbar"
             layout="@layout/actionbar_withback" />-->

+ 1 - 1
app/src/main/res/layout/fragment_out_make_material.xml

@@ -3,7 +3,7 @@
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:orientation="vertical"
-              tools:context=".fragment.IOCOutManagement">
+              tools:context=".fragment.IOCOutManagementFra">
 
     <LinearLayout
         android:id="@+id/out_material"

+ 5 - 3
app/src/main/res/layout/item_grid_first.xml

@@ -1,15 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--一级griditem布局-->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="100dp"
-    android:layout_height="100dp"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
     android:gravity="center"
     android:focusable="false"
     android:layout_centerInParent="true"
     android:background="@drawable/bg_griditem"
     android:backgroundTint="@color/button_normal"
     android:translationZ="120dp"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:layout_margin="10dp"
+    >
 
     <ImageView
         android:id="@+id/first_griditem_img"

+ 24 - 4
app/src/main/res/xml/file_paths.xml

@@ -1,7 +1,27 @@
 <?xml version="1.0" encoding="utf-8"?>
-<paths xmlns:android="http://schemas.android.com/apk/res/android">
+<paths>
+    <!-- 外部存储根目录 -->
     <external-path
-        path="Android/data/com.uas.pda_smart_com/"
-        name="files_root" />
-    <external-path path="." name="external_storage_root" />
+        name="external"
+        path="." />
+
+    <!-- 下载目录 -->
+    <external-path
+        name="download"
+        path="Download" />
+
+    <!-- 应用私有目录 -->
+    <external-files-path
+        name="files"
+        path="." />
+
+    <!-- 缓存目录 -->
+    <external-cache-path
+        name="cache"
+        path="." />
+
+    <!-- 内部存储目录 -->
+    <files-path
+        name="internal"
+        path="." />
 </paths>