| | |
| | | import android.content.pm.PackageManager; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.os.Message; |
| | | import android.text.TextUtils; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.dayu.recharge.MyApplication; |
| | | import com.dayu.recharge.databinding.ActivityMyBinding; |
| | |
| | | import com.dayu.recharge.net.SocketNet; |
| | | import com.dayu.recharge.utils.DeviceNumberUtils; |
| | | import com.dayu.recharge.utils.ExcelUtil; |
| | | import com.dayu.recharge.utils.SocketUtil; |
| | | import com.dayu.recharge.utils.TipUtil; |
| | | import com.dayu.recharge.view.PassWordDialog; |
| | | import com.dayu.recharge.view.datepicker.CustomDatePicker; |
| | |
| | | |
| | | } |
| | | }); |
| | | myBinding.sysIp.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | PassWordDialog passWordDialog = new PassWordDialog(MyActivity.this, new Intent(MyActivity.this, SysIpActivity.class)); |
| | | passWordDialog.show(); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | Handler handler = new Handler(new Handler.Callback() { |
| | | @Override |
| | | public boolean handleMessage(@NonNull Message msg) { |
| | | switch (msg.what) { |
| | | case 1: |
| | | TipUtil.show(MyActivity.this, "导出成功!"); |
| | | break; |
| | | case 3: |
| | | TipUtil.show(MyActivity.this, "记录为空!"); |
| | | break; |
| | | default: |
| | | TipUtil.show(MyActivity.this, "导出失败!"); |
| | | break; |
| | | } |
| | | stopAnim(); |
| | | return false; |
| | | } |
| | | }); |
| | | |
| | | /** |
| | | * 导出成Excel |
| | | */ |
| | | private void outExcl() { |
| | | startAnim(); |
| | | File file = new File(ExcelUtil.outPath); |
| | | //文件夹是否已经存在 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | List listData = new ArrayList(); |
| | | try { |
| | | if (isRechargeList) { |
| | | listData = baseDao.rechargeDao().findByTime(beginTime, endTime); |
| | | } else { |
| | | listData = baseDao.userCardDao().findByTime(beginTime, endTime); |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | { |
| | | try { |
| | | File file = new File(ExcelUtil.outPath); |
| | | //文件夹是否已经存在 |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | List listData = new ArrayList(); |
| | | try { |
| | | if (isRechargeList) { |
| | | listData = asynchBaseDao.rechargeDao().ansyFindByTime(beginTime, endTime); |
| | | } else { |
| | | listData = asynchBaseDao.userCardDao().findByTime(beginTime, endTime); |
| | | } |
| | | if (listData == null || listData.size() == 0) { |
| | | handler.sendEmptyMessage(2); |
| | | return; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String[] title; |
| | | String fileName; |
| | | if (listData == null || listData.size() == 0) { |
| | | TipUtil.show(MyActivity.this, "记录为空"); |
| | | return; |
| | | } |
| | | if (isRechargeList) { |
| | | title = new String[]{"设备序列号", "用户名", "订单号", "充值日期", "充值金额(元)", "剩余金额(元)"}; |
| | | fileName = file.toString() + "/" + ExcelUtil.outRechargePathName; |
| | | } else { |
| | | title = new String[]{"设备序列号", "用户名", "身份证号", "注册日期", "电话"}; |
| | | fileName = file.toString() + "/" + ExcelUtil.outUserPathName; |
| | | } |
| | | ExcelUtil.initExcel(fileName, title); |
| | | ExcelUtil.writeObjListToExcel(listData, fileName, MyActivity.this); |
| | | handler.sendEmptyMessage(1); |
| | | } catch (Exception e) { |
| | | handler.sendEmptyMessage(2); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String[] title; |
| | | String fileName; |
| | | if (listData == null || listData.size() == 0) { |
| | | TipUtil.show(MyActivity.this, "记录为空"); |
| | | return; |
| | | } |
| | | if (isRechargeList) { |
| | | title = new String[]{"设备序列号", "用户名", "身份证号", "充值日期", "充值金额(元)", "剩余金额(元)"}; |
| | | fileName = file.toString() + "/" + ExcelUtil.outRechargePathName; |
| | | } else { |
| | | title = new String[]{"设备序列号", "用户名", "身份证号", "注册日期", "电话"}; |
| | | fileName = file.toString() + "/" + ExcelUtil.outUserPathName; |
| | | } |
| | | ExcelUtil.initExcel(fileName, title); |
| | | ExcelUtil.writeObjListToExcel(listData, fileName, MyActivity.this); |
| | | stopAnim(); |
| | | }).start(); |
| | | |
| | | |
| | | } |
| | | |
| | | void getVersion(Activity context) { |