Переглянути джерело

Merge branch 'developer' of https://gitlab.com/Arisono/SkWeiChat-Baidu into uu_v1.0

Arison 8 роки тому
батько
коміт
6a6b6b637f

+ 5 - 4
app_core/common/src/main/java/com/core/model/OAConfig.java

@@ -1,9 +1,5 @@
 package com.core.model;
 
-import com.common.config.BaseConfig;
-import com.core.app.MyApplication;
-import com.core.utils.CommonUtil;
-
 /**
  * 自动打卡变量集合
  * 1.上班地址(数组)
@@ -28,6 +24,11 @@ public class OAConfig {
     public static int overlatetime = 0; //严重迟到时间
     public static int latetime = 0;    //迟到时间(在该时间内不算迟到)
     public static int nonclass = 90;   //矿工时间
+    public static String days = "1,2,3,4,5";
+    public static String name = "默认班次";
+
+
+
 
     /*是否显示Crm2.0功能*/
     public static boolean canShowRed = false;

+ 500 - 485
app_modular/appme/src/main/java/com/uas/appme/settings/activity/SettingActivity.java

@@ -31,17 +31,21 @@ import com.baidu.autoupdatesdk.AppUpdateInfoForInstall;
 import com.baidu.autoupdatesdk.BDAutoUpdateSDK;
 import com.baidu.autoupdatesdk.CPCheckUpdateCallback;
 import com.baidu.autoupdatesdk.UICheckUpdateCallback;
+import com.common.data.ListUtils;
 import com.common.file.FileUtils;
 import com.common.preferences.PreferenceUtils;
 import com.common.system.DisplayUtil;
 import com.core.api.wxapi.ApiPlatform;
 import com.core.api.wxapi.ApiUtils;
 import com.core.app.AppConfig;
+import com.core.app.AppConstant;
 import com.core.app.Constants;
 import com.core.app.MyApplication;
 import com.core.base.BaseActivity;
-import com.core.app.AppConstant;
 import com.core.dao.work.VideoFileDao;
+import com.core.dao.work.WorkModelDao;
+import com.core.model.OAConfig;
+import com.core.model.WorkModel;
 import com.core.net.http.ViewUtil;
 import com.core.utils.CommonUtil;
 import com.core.utils.ToastUtil;
@@ -59,6 +63,8 @@ import com.uas.appworks.OA.erp.activity.OfficeAddressSettingsActivity;
 import com.uas.appworks.OA.erp.activity.SignSeniorSettingActivity;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -66,495 +72,504 @@ import java.io.File;
  */
 public class SettingActivity extends BaseActivity implements View.OnClickListener {
 
-    private Button mExitBtn;
-    private TextView mCacheTv;
-    private TextView uas_website_tv;
-    private TextView tv_menu_setting;
-    private SwitchView cb_task_reply;
-    private RelativeLayout uu_step_rl;
-    private RelativeLayout sign_in_rl;
-    private RelativeLayout sign_out_rl;
-    private TextView tv_signauto_new;
-    private TextView tv_sign_new;
-    private TextView tv_language_new;
-    private TextView tv_booking_new;
-    private TextView tv_help_new;
-    private RelativeLayout language_us_rl;
-    private ImageView uu_step_im;
-    private SwitchView uu_step_reply;
-    private RelativeLayout rl_app_update;
-    private TextView version_value;
-    private RelativeLayout close_push_rl;
-    private RelativeLayout speech_recognition_rl;
-    private RelativeLayout new_step_rl;
-    private RelativeLayout booking_set_rl;
-
-    private ProgressDialog dialog;
-    private RelativeLayout share_rl;
-    private String newStep_service_name = "com.uas.appme.pedometer.service.StepService";
-
-    private PopupWindow setWindow = null;//
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_setting);
-        getSupportActionBar().setTitle(getString(R.string.user_setting));
-        initView();
-    }
-
-
-    private void initView() {
-        uas_website_tv = (TextView) findViewById(R.id.uas_website_tv);
-        tv_menu_setting = (TextView) findViewById(R.id.tv_menu_setting);
-        cb_task_reply = (SwitchView) findViewById(R.id.cb_task_reply);
-        uu_step_rl = (RelativeLayout) findViewById(R.id.uu_step_rl);
-        sign_in_rl = (RelativeLayout) findViewById(R.id.sign_in_rl);
-        sign_out_rl = (RelativeLayout) findViewById(R.id.sign_out_rl);
-        tv_signauto_new = (TextView) findViewById(R.id.tv_signauto_new);
-        tv_sign_new = (TextView) findViewById(R.id.tv_sign_new);
-        tv_language_new = (TextView) findViewById(R.id.tv_language_new);
-        tv_booking_new = (TextView) findViewById(R.id.tv_booking_new);
-        tv_help_new = (TextView) findViewById(R.id.tv_help_new);
-        language_us_rl = (RelativeLayout) findViewById(R.id.language_us_rl);
-        uu_step_im = (ImageView) findViewById(R.id.uu_step_im);
-        uu_step_reply = (SwitchView) findViewById(R.id.uu_step_reply);
-        rl_app_update = (RelativeLayout) findViewById(R.id.rl_app_update);
-        version_value = (TextView) findViewById(R.id.version_value);
-        close_push_rl = (RelativeLayout) findViewById(R.id.close_push_rl);
-        speech_recognition_rl = (RelativeLayout) findViewById(R.id.speech_recognition_rl);
-        new_step_rl = (RelativeLayout) findViewById(R.id.new_step_rl);
-        booking_set_rl = (RelativeLayout) findViewById(R.id.booking_set_rl);
-
-
-        new_step_rl.setOnClickListener(this);
+	private Button mExitBtn;
+	private TextView mCacheTv;
+	private TextView uas_website_tv;
+	private TextView tv_menu_setting;
+	private SwitchView cb_task_reply;
+	private RelativeLayout uu_step_rl;
+	private RelativeLayout sign_in_rl;
+	private RelativeLayout sign_out_rl;
+	private TextView tv_signauto_new;
+	private TextView tv_sign_new;
+	private TextView tv_language_new;
+	private TextView tv_booking_new;
+	private TextView tv_help_new;
+	private RelativeLayout language_us_rl;
+	private ImageView uu_step_im;
+	private SwitchView uu_step_reply;
+	private RelativeLayout rl_app_update;
+	private TextView version_value;
+	private RelativeLayout close_push_rl;
+	private RelativeLayout speech_recognition_rl;
+	private RelativeLayout new_step_rl;
+	private RelativeLayout booking_set_rl;
+
+	private ProgressDialog dialog;
+	private RelativeLayout share_rl;
+	private String newStep_service_name = "com.uas.appme.pedometer.service.StepService";
+
+	private PopupWindow setWindow = null;//
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_setting);
+		getSupportActionBar().setTitle(getString(R.string.user_setting));
+		initView();
+	}
+
+
+	private void initView() {
+		uas_website_tv = (TextView) findViewById(R.id.uas_website_tv);
+		tv_menu_setting = (TextView) findViewById(R.id.tv_menu_setting);
+		cb_task_reply = (SwitchView) findViewById(R.id.cb_task_reply);
+		uu_step_rl = (RelativeLayout) findViewById(R.id.uu_step_rl);
+		sign_in_rl = (RelativeLayout) findViewById(R.id.sign_in_rl);
+		sign_out_rl = (RelativeLayout) findViewById(R.id.sign_out_rl);
+		tv_signauto_new = (TextView) findViewById(R.id.tv_signauto_new);
+		tv_sign_new = (TextView) findViewById(R.id.tv_sign_new);
+		tv_language_new = (TextView) findViewById(R.id.tv_language_new);
+		tv_booking_new = (TextView) findViewById(R.id.tv_booking_new);
+		tv_help_new = (TextView) findViewById(R.id.tv_help_new);
+		language_us_rl = (RelativeLayout) findViewById(R.id.language_us_rl);
+		uu_step_im = (ImageView) findViewById(R.id.uu_step_im);
+		uu_step_reply = (SwitchView) findViewById(R.id.uu_step_reply);
+		rl_app_update = (RelativeLayout) findViewById(R.id.rl_app_update);
+		version_value = (TextView) findViewById(R.id.version_value);
+		close_push_rl = (RelativeLayout) findViewById(R.id.close_push_rl);
+		speech_recognition_rl = (RelativeLayout) findViewById(R.id.speech_recognition_rl);
+		new_step_rl = (RelativeLayout) findViewById(R.id.new_step_rl);
+		booking_set_rl = (RelativeLayout) findViewById(R.id.booking_set_rl);
+
+
+		new_step_rl.setOnClickListener(this);
 //        new_step_rl.setVisibility(View.GONE);
 
-        dialog = new ProgressDialog(this);
-        dialog.setIndeterminate(true);
-        share_rl = (RelativeLayout) findViewById(R.id.share_rl);
-        mExitBtn = (Button) findViewById(R.id.exit_btn);
-        //share_rl.setVisibility(View.GONE);
-        int isPush = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.BAIDU_PUSH);
-
-        if (isPush == -1) {//第一次进入没有配置
-            cb_task_reply.setChecked(true);
-        } else if (isPush == 0) {//选择不推送
-            cb_task_reply.setChecked(false);
-        } else { //选择推送
-            cb_task_reply.setChecked(true);
-        }
-        share_rl.setOnClickListener(this);
-        cb_task_reply.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(View view, boolean isChecked) {
-                if (isChecked) {
-                    PreferenceUtils.putInt(Constant.BAIDU_PUSH, 1);
-                    PushManager.resumeWork(MyApplication.getInstance());
-                } else {
-                    PushManager.stopWork(MyApplication.getInstance());
-                    PreferenceUtils.putInt(Constant.BAIDU_PUSH, 0);
-                }
-            }
-        });
-
-        rl_app_update.setOnClickListener(this);
-        close_push_rl.setOnClickListener(this);
-        version_value.setText(CommonUtil.ApkVersionCode(this));
-        mExitBtn.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                showExitDialog();
-
-            }
-        });
-        mCacheTv = (TextView) findViewById(R.id.cache_tv);
-        findViewById(R.id.clear_cache_rl).setOnClickListener(this);
-        findViewById(R.id.use_help_rl).setOnClickListener(this);
-        findViewById(R.id.about_us_rl).setOnClickListener(this);
-        long cacheSize = FileUtils.getFileSize(new File(MyApplication.getInstance().mAppDir));
-        mCacheTv.setText(FileUtils.formatFileSize(cacheSize));
-        uas_website_tv.setText(CommonUtil.getSharedPreferences(this, "erp_baseurl"));
-
-
-        //UU开关的 根据StepService是否开启显示状态
-        int isStep = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.UU_STEP);
-        if (isServiceRunning(newStep_service_name) && (isStep == -1 || isStep == 1)) {
-            uu_step_reply.setChecked(true);
-        } else {
-            speech_recognition_rl.setVisibility(View.GONE);
-            uu_step_reply.setChecked(false);
-        }
-
-        uu_step_reply.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(View view, boolean isChecked) {
-                tv_menu_setting.setVisibility(View.GONE);
-                CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
-                if (isChecked) {
-                    PreferenceUtils.putInt(Constant.UU_STEP, 1);
+		dialog = new ProgressDialog(this);
+		dialog.setIndeterminate(true);
+		share_rl = (RelativeLayout) findViewById(R.id.share_rl);
+		mExitBtn = (Button) findViewById(R.id.exit_btn);
+		//share_rl.setVisibility(View.GONE);
+		int isPush = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.BAIDU_PUSH);
+
+		if (isPush == -1) {//第一次进入没有配置
+			cb_task_reply.setChecked(true);
+		} else if (isPush == 0) {//选择不推送
+			cb_task_reply.setChecked(false);
+		} else { //选择推送
+			cb_task_reply.setChecked(true);
+		}
+		share_rl.setOnClickListener(this);
+		cb_task_reply.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
+			@Override
+			public void onCheckedChanged(View view, boolean isChecked) {
+				if (isChecked) {
+					PreferenceUtils.putInt(Constant.BAIDU_PUSH, 1);
+					PushManager.resumeWork(MyApplication.getInstance());
+				} else {
+					PushManager.stopWork(MyApplication.getInstance());
+					PreferenceUtils.putInt(Constant.BAIDU_PUSH, 0);
+				}
+			}
+		});
+
+		rl_app_update.setOnClickListener(this);
+		close_push_rl.setOnClickListener(this);
+		version_value.setText(CommonUtil.ApkVersionCode(this));
+		mExitBtn.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				showExitDialog();
+
+			}
+		});
+		mCacheTv = (TextView) findViewById(R.id.cache_tv);
+		findViewById(R.id.clear_cache_rl).setOnClickListener(this);
+		findViewById(R.id.use_help_rl).setOnClickListener(this);
+		findViewById(R.id.about_us_rl).setOnClickListener(this);
+		long cacheSize = FileUtils.getFileSize(new File(MyApplication.getInstance().mAppDir));
+		mCacheTv.setText(FileUtils.formatFileSize(cacheSize));
+		uas_website_tv.setText(CommonUtil.getSharedPreferences(this, "erp_baseurl"));
+
+
+		//UU开关的 根据StepService是否开启显示状态
+		int isStep = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.UU_STEP);
+		if (isServiceRunning(newStep_service_name) && (isStep == -1 || isStep == 1)) {
+			uu_step_reply.setChecked(true);
+		} else {
+			speech_recognition_rl.setVisibility(View.GONE);
+			uu_step_reply.setChecked(false);
+		}
+
+		uu_step_reply.setOnCheckedChangeListener(new SwitchView.OnCheckedChangeListener() {
+			@Override
+			public void onCheckedChanged(View view, boolean isChecked) {
+				tv_menu_setting.setVisibility(View.GONE);
+				CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
+				if (isChecked) {
+					PreferenceUtils.putInt(Constant.UU_STEP, 1);
 //                    PushManager.resumeWork(MyApplication.getInstance());
 //
-                    startActivity(new Intent(mContext, StepSplashActivity.class));
-                } else {
+					startActivity(new Intent(mContext, StepSplashActivity.class));
+				} else {
 //                    PushManager.stopWork(MyApplication.getInstance());
-                    PreferenceUtils.putInt(Constant.UU_STEP, 0);
+					PreferenceUtils.putInt(Constant.UU_STEP, 0);
 //                    stopService(intent);
-                    Toast.makeText(mContext, getString(R.string.set_close_step_notice1), Toast.LENGTH_LONG).show();
-                    speech_recognition_rl.setVisibility(View.GONE);
-                }
-            }
-        });
-        uu_step_rl.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                tv_menu_setting.setVisibility(View.GONE);
-                CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
-                int last_isStep = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.UU_STEP);
-                if (isServiceRunning(newStep_service_name) && last_isStep == 1) {
-                    startActivity(new Intent(mContext, NewStepActivity.class));
-                } else {
-                    Toast.makeText(mContext, getString(R.string.set_close_step_notice2), Toast.LENGTH_SHORT).show();
-                }
-            }
-        });
-        new_step_rl.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                tv_menu_setting.setVisibility(View.GONE);
-                CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
-                startActivity(new Intent(mContext, NewStepActivity.class));
-            }
-        });
-
-        booking_set_rl.setOnClickListener(this);
-
-        tv_menu_setting.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.NEW_UURUN, false) ? View.GONE : View.VISIBLE);
-        tv_signauto_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_AUTO, false) ? View.GONE : View.VISIBLE);
-        tv_sign_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_IN, false) ? View.GONE : View.VISIBLE);
-        tv_language_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_LANGUAGE, false) ? View.GONE : View.VISIBLE);
-        tv_booking_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_BOOKING_TIME, false) ? View.GONE : View.VISIBLE);
-        tv_help_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_CALL, false) ? View.GONE : View.VISIBLE);
-
-        speech_recognition_rl.setOnClickListener(this);
-        sign_in_rl.setOnClickListener(this);
-        sign_out_rl.setOnClickListener(this);
-        language_us_rl.setOnClickListener(this);
-
-        if (ApiUtils.getApiModel() instanceof ApiPlatform) {
-            language_us_rl.setVisibility(View.GONE);
-        } else {
-            language_us_rl.setVisibility(View.VISIBLE);
-        }
+					Toast.makeText(mContext, getString(R.string.set_close_step_notice1), Toast.LENGTH_LONG).show();
+					speech_recognition_rl.setVisibility(View.GONE);
+				}
+			}
+		});
+		uu_step_rl.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				tv_menu_setting.setVisibility(View.GONE);
+				CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
+				int last_isStep = PreferenceUtils.getInt(MyApplication.getInstance(), Constant.UU_STEP);
+				if (isServiceRunning(newStep_service_name) && last_isStep == 1) {
+					startActivity(new Intent(mContext, NewStepActivity.class));
+				} else {
+					Toast.makeText(mContext, getString(R.string.set_close_step_notice2), Toast.LENGTH_SHORT).show();
+				}
+			}
+		});
+		new_step_rl.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				tv_menu_setting.setVisibility(View.GONE);
+				CommonUtil.putSharedPreferencesBoolean(SettingActivity.this, Constants.NEW_UURUN, true);
+				startActivity(new Intent(mContext, NewStepActivity.class));
+			}
+		});
+
+		booking_set_rl.setOnClickListener(this);
+
+		tv_menu_setting.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.NEW_UURUN, false) ? View.GONE : View.VISIBLE);
+		tv_signauto_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_AUTO, false) ? View.GONE : View.VISIBLE);
+		tv_sign_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_IN, false) ? View.GONE : View.VISIBLE);
+		tv_language_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_SIGN_LANGUAGE, false) ? View.GONE : View.VISIBLE);
+		tv_booking_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_BOOKING_TIME, false) ? View.GONE : View.VISIBLE);
+		tv_help_new.setVisibility(CommonUtil.getSharedPreferencesBoolean(this, Constants.SET_CALL, false) ? View.GONE : View.VISIBLE);
+
+		speech_recognition_rl.setOnClickListener(this);
+		sign_in_rl.setOnClickListener(this);
+		sign_out_rl.setOnClickListener(this);
+		language_us_rl.setOnClickListener(this);
+
+		if (ApiUtils.getApiModel() instanceof ApiPlatform) {
+			language_us_rl.setVisibility(View.GONE);
+		} else {
+			language_us_rl.setVisibility(View.VISIBLE);
+		}
 //        UserRoleUtils.checkUserRole(this,getRootView());
-    }
-
-    private boolean isServiceRunning(String servicename) { // 判断某个服务是否已经运行
-        ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
-        for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
-            if (servicename.equals(service.service.getClassName())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        return super.onCreateOptionsMenu(menu);
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        if (item.getItemId() == android.R.id.home) {
-            startActivity(new Intent("com.modular.main.MainActivity"));
-        }
-        return super.onOptionsItemSelected(item);
-    }
-
-    @Override
-    public void onBackPressed() {
-        startActivity(new Intent("com.modular.main.MainActivity"));
-        super.onBackPressed();
-    }
-
-    private void showExitDialog() {
-        new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setMessage(R.string.exit_tips).setNegativeButton(R.string.common_cancel, null)
-                .setPositiveButton(R.string.common_sure, new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-                        UserSp.getInstance(mContext).clearUserInfo();
-                        ViewUtil.clearAccount(mContext);
-                        LoginHelper.broadcastLogout(mContext);
-                        SettingActivity.this.finish();
-
-                    }
-                }).create().show();
-    }
-
-
-    @Override
-    public void onClick(View v) {
-        Intent intent = null;
-       if (v.getId() == R.id.booking_set_rl){
-           startActivity(new Intent(this, BookingSetActivity.class));
-           CommonUtil.setSharedPreferences(this, Constants.SET_BOOKING_TIME, true);
-           tv_booking_new.setVisibility(View.GONE);
-       }else if (v.getId() == R.id.language_us_rl){
-           startActivity(new Intent(this, SelectLanguageActivity.class));
-           CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_LANGUAGE, true);
-           tv_language_new.setVisibility(View.GONE);
-       }else if (v.getId() == R.id.sign_in_rl){
-           showPopupWindow();
-           CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_IN, true);
-           tv_sign_new.setVisibility(View.GONE);
-       }else if (v.getId() == R.id.sign_out_rl){
-          intent = new Intent(mContext, MissionSetActivity.class);
-           intent.putExtra(AppConfig.IS_ADMIN, PreferenceUtils.getBoolean(AppConfig.IS_ADMIN, false));
-           startActivity(intent);
-           CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_AUTO, true);
-           tv_signauto_new.setVisibility(View.GONE);
-       }else if (v.getId() == R.id.clear_cache_rl){
-           showclearDialog();
-       }else if (v.getId() == R.id.use_help_rl){
-           CommonUtil.setSharedPreferences(this, Constants.SET_CALL, true);
-           tv_help_new.setVisibility(View.GONE);
-           intent = new Intent(mContext, FeedbackActivity.class);
-           intent.putExtra("type", 1);
-           intent.putExtra(AppConstant.EXTRA_URL, mConfig.help_url);
-           intent.putExtra(AppConstant.EXTRA_TITLE, getString(R.string.use_help));
-           startActivity(intent);
-       }else if (v.getId() == R.id.about_us_rl){
-           startActivity(new Intent(mContext, AboutActivity.class));
-       }else if (v.getId() == R.id.share_rl){
-           share();
-       }else if (v.getId() == R.id.rl_app_update){
-           dialog.setMessage(getString(R.string.set_check_update_wait));
-           dialog.show();
-           BDAutoUpdateSDK.uiUpdateAction(this, new UICheckUpdateCallback() {
-               @Override
-               public void onCheckComplete() {
-                   BDAutoUpdateSDK.cpUpdateCheck(SettingActivity.this,
-                           new CPCheckUpdateCallback() {
-
-                               @Override
-                               public void onCheckUpdateCallback(
-                                       AppUpdateInfo info,
-                                       AppUpdateInfoForInstall infoForInstall) {
-                                   if (infoForInstall != null
-                                           && !TextUtils
-                                           .isEmpty(infoForInstall
-                                                   .getInstallPath())) {
-                                   } else if (info != null) {
-                                   } else {
-                                       ViewUtil.ShowMessageTitle(
-                                               SettingActivity.this,
-                                               getString(R.string.set_isnewVersion));
-                                   }
-                                   dialog.dismiss();
-                               }
-                           });
-               }
-           });
-       }else if (v.getId() == R.id.super_setting_tv){
-           startActivityForResult(new Intent(mContext, SignSeniorSettingActivity.class), 0x12);
-           closePopupWindow();
-       }else if (v.getId() == R.id.work_setting_tv){
-           intent = new Intent(mContext, FlightsActivity.class);
-           startActivityForResult(intent, 0x12);
-           closePopupWindow();
-       }else if (v.getId() == R.id.office_addr_setting_tv){
-           startActivityForResult(new Intent(mContext, OfficeAddressSettingsActivity.class), 0x12);
-           closePopupWindow();
-       }else if (v.getId() == R.id.my_rule_setting_tv){
-           intent = new Intent(mContext, MyRuleSetActivity.class);
-//                presenter.showMyRele(intent, adapter.getModels());
-           startActivity(intent);
-           closePopupWindow();
-       }else if (v.getId() == R.id.cancel_tv){
-           closePopupWindow();
-       }
-    }
-
-    private void share() {
-        shareSingleImage();
-    }
-
-    //分享单张图片
-    public void shareSingleImage() {
-        Uri imageUri = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.drawable.ic_uu_scan_code);
-        Intent shareIntent = new Intent();
-        shareIntent.setAction(Intent.ACTION_SEND);
-        shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
-        shareIntent.setType("image/*");
-        startActivity(Intent.createChooser(shareIntent, getString(R.string.set_share_to)));
-    }
-
-    //确认是否清空本地缓存
-    private void showclearDialog() {
-        new AlertDialog
-                .Builder(mContext)
-                .setTitle(getString(R.string.common_notice))
-                .setMessage(getString(R.string.cache_msg))
-                .setNegativeButton(getString(R.string.common_cancel), null)
-                .setPositiveButton(getString(R.string.common_sure), new DialogInterface.OnClickListener() {
-
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-                        clearCache();
-                        Log.i("clearCache", "clearCache");
-                    }
-                }).create().show();
-    }
-
-    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
-    private void clearCache() {
-        String filePath = MyApplication.getInstance().mAppDir;
-        //删除文件
-        VideoFileDao.getInstance().deleteAllVideoFile(
-                VideoFileDao.getInstance().getVideoFiles(
-                        MyApplication.getInstance().mLoginUser.getUserId()));
-        if (Build.VERSION.SDK_INT >= 11)
-            new ClearCacheAsyncTaska(filePath).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, true);
-        else
-            new ClearCacheAsyncTaska(filePath).execute(true);
-    }
-
-    private class ClearCacheAsyncTaska extends AsyncTask<Boolean, String, Integer> {
-        private File rootFile;
-        private ProgressDialog progressDialog;
-        private int filesNumber = 0;
-        private boolean canceled = false;
-
-        public ClearCacheAsyncTaska(String filePath) {
-            this.rootFile = new File(filePath);
-        }
-
-        @Override
-        protected void onPreExecute() {
-            filesNumber = FileUtils.getFolderSubFilesNumber(rootFile);
-            progressDialog = new ProgressDialog(mContext);
-            progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
-            progressDialog.setIndeterminate(false);
-            progressDialog.setCancelable(false);
-            progressDialog.setMessage(getString(R.string.deleteing));
-            progressDialog.setMax(filesNumber);
-            progressDialog.setProgress(0);
-            // 设置取消按钮
-            progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
-                public void onClick(DialogInterface dialog, int i) {
-                    canceled = true;
-                }
-            });
-            progressDialog.show();
-        }
-
-        /**
-         * 返回true代表删除完成,false表示取消了删除
-         */
-        @Override
-        protected Integer doInBackground(Boolean... params) {
-            if (filesNumber == 0) {
-                return 0;
-            }
-            Log.i("gongpengming", "doInBackground");
-            boolean deleteSubFolder = params[0];// 是否删除已清空的子文件夹
-            return deleteFolder(rootFile, true, deleteSubFolder, 0);
-        }
-
-        @Override
-        protected void onProgressUpdate(String... values) {
-            super.onProgressUpdate(values);
-            // String filePath = values[0];
-            int progress = Integer.parseInt(values[1]);
-            // progressDialog.setMessage(filePath);
-            progressDialog.setProgress(progress);
-        }
-
-        @Override
-        protected void onPostExecute(Integer result) {
-            super.onPostExecute(result);
-            progressDialog.dismiss();
-            if (!canceled && result == filesNumber) {
-                ToastUtil.showToast(mContext, R.string.clear_completed);
-            }
-            long cacheSize = FileUtils.getFileSize(rootFile);
-            mCacheTv.setText(FileUtils.formatFileSize(cacheSize));
-        }
-
-        private long notifyTime = 0;
-
-        /**
-         * 是否删除完毕
-         *
-         * @param file
-         * @param deleteSubFolder
-         * @return
-         */
-        private int deleteFolder(File file, boolean rootFolder, boolean deleteSubFolder, int progress) {
-            if (file == null || !file.exists() || !file.isDirectory()) {
-                return 0;
-            }
-            File flist[] = file.listFiles();
-            for (File subFile : flist) {
-                if (canceled) {
-                    return progress;
-                }
-                if (subFile.isFile()) {
-                    subFile.delete();
-                    progress++;
-                    long current = System.currentTimeMillis();
-                    if (current - notifyTime > 200) {// 200毫秒更新一次界面
-                        notifyTime = current;
-                        publishProgress(subFile.getAbsolutePath(), String.valueOf(progress));
-                    }
-                } else {
-                    progress = deleteFolder(subFile, false, deleteSubFolder, progress);
-                    if (deleteSubFolder) {
-                        subFile.delete();
-                    }
-                }
-            }
-            return progress;
-        }
-    }
-
-    private void showPopupWindow() {
-        if (setWindow == null) initPopupWindow();
-        setWindow.showAtLocation(getWindow().getDecorView().
-                findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
-        DisplayUtil.backgroundAlpha(this, 0.4f);
-    }
-
-    private void initPopupWindow() {
-        View viewContext = LayoutInflater.from(mContext).inflate(R.layout.pop_work_activity, null);
-        if (!PreferenceUtils.getBoolean(AppConfig.IS_ADMIN, false)) {
-            viewContext.findViewById(R.id.super_setting_tv).setVisibility(View.GONE);
-            viewContext.findViewById(R.id.work_setting_tv).setVisibility(View.GONE);
-            viewContext.findViewById(R.id.office_addr_setting_tv).setVisibility(View.GONE);
-        } else {
-            viewContext.findViewById(R.id.super_setting_tv).setOnClickListener(this);
-            viewContext.findViewById(R.id.work_setting_tv).setOnClickListener(this);
-            viewContext.findViewById(R.id.office_addr_setting_tv).setOnClickListener(this);
-        }
-        viewContext.findViewById(R.id.my_rule_setting_tv).setOnClickListener(this);
-        viewContext.findViewById(R.id.cancel_tv).setOnClickListener(this);
-        setWindow = new PopupWindow(viewContext,
-                LinearLayout.LayoutParams.MATCH_PARENT,
-                LinearLayout.LayoutParams.WRAP_CONTENT, true);
-        setWindow.setAnimationStyle(R.style.MenuAnimationFade);
-        setWindow.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_popuwin));
-        setWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
-            @Override
-            public void onDismiss() {
-                closePopupWindow();
-            }
-        });
-    }
-
-    private void closePopupWindow() {
-        if (setWindow != null)
-            setWindow.dismiss();
-        DisplayUtil.backgroundAlpha(this, 1f);
-    }
+	}
+
+	private boolean isServiceRunning(String servicename) { // 判断某个服务是否已经运行
+		ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
+		for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
+			if (servicename.equals(service.service.getClassName())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		return super.onCreateOptionsMenu(menu);
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		if (item.getItemId() == android.R.id.home) {
+			startActivity(new Intent("com.modular.main.MainActivity"));
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
+	@Override
+	public void onBackPressed() {
+		startActivity(new Intent("com.modular.main.MainActivity"));
+		super.onBackPressed();
+	}
+
+	private void showExitDialog() {
+		new AlertDialog.Builder(mContext).setTitle(R.string.app_name).setMessage(R.string.exit_tips).setNegativeButton(R.string.common_cancel, null)
+				.setPositiveButton(R.string.common_sure, new DialogInterface.OnClickListener() {
+					@Override
+					public void onClick(DialogInterface dialog, int which) {
+						UserSp.getInstance(mContext).clearUserInfo();
+						ViewUtil.clearAccount(mContext);
+						LoginHelper.broadcastLogout(mContext);
+						SettingActivity.this.finish();
+
+					}
+				}).create().show();
+	}
+
+
+	@Override
+	public void onClick(View v) {
+		Intent intent = null;
+		if (v.getId() == R.id.booking_set_rl) {
+			startActivity(new Intent(this, BookingSetActivity.class));
+			CommonUtil.setSharedPreferences(this, Constants.SET_BOOKING_TIME, true);
+			tv_booking_new.setVisibility(View.GONE);
+		} else if (v.getId() == R.id.language_us_rl) {
+			startActivity(new Intent(this, SelectLanguageActivity.class));
+			CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_LANGUAGE, true);
+			tv_language_new.setVisibility(View.GONE);
+		} else if (v.getId() == R.id.sign_in_rl) {
+			showPopupWindow();
+			CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_IN, true);
+			tv_sign_new.setVisibility(View.GONE);
+		} else if (v.getId() == R.id.sign_out_rl) {
+			intent = new Intent(mContext, MissionSetActivity.class);
+			intent.putExtra(AppConfig.IS_ADMIN, PreferenceUtils.getBoolean(AppConfig.IS_ADMIN, false));
+			startActivity(intent);
+			CommonUtil.setSharedPreferences(this, Constants.SET_SIGN_AUTO, true);
+			tv_signauto_new.setVisibility(View.GONE);
+		} else if (v.getId() == R.id.clear_cache_rl) {
+			showclearDialog();
+		} else if (v.getId() == R.id.use_help_rl) {
+			CommonUtil.setSharedPreferences(this, Constants.SET_CALL, true);
+			tv_help_new.setVisibility(View.GONE);
+			intent = new Intent(mContext, FeedbackActivity.class);
+			intent.putExtra("type", 1);
+			intent.putExtra(AppConstant.EXTRA_URL, mConfig.help_url);
+			intent.putExtra(AppConstant.EXTRA_TITLE, getString(R.string.use_help));
+			startActivity(intent);
+		} else if (v.getId() == R.id.about_us_rl) {
+			startActivity(new Intent(mContext, AboutActivity.class));
+		} else if (v.getId() == R.id.share_rl) {
+			share();
+		} else if (v.getId() == R.id.rl_app_update) {
+			dialog.setMessage(getString(R.string.set_check_update_wait));
+			dialog.show();
+			BDAutoUpdateSDK.uiUpdateAction(this, new UICheckUpdateCallback() {
+				@Override
+				public void onCheckComplete() {
+					BDAutoUpdateSDK.cpUpdateCheck(SettingActivity.this,
+							new CPCheckUpdateCallback() {
+
+								@Override
+								public void onCheckUpdateCallback(
+										AppUpdateInfo info,
+										AppUpdateInfoForInstall infoForInstall) {
+									if (infoForInstall != null
+											&& !TextUtils
+											.isEmpty(infoForInstall
+													.getInstallPath())) {
+									} else if (info != null) {
+									} else {
+										ViewUtil.ShowMessageTitle(
+												SettingActivity.this,
+												getString(R.string.set_isnewVersion));
+									}
+									dialog.dismiss();
+								}
+							});
+				}
+			});
+		} else if (v.getId() == R.id.super_setting_tv) {
+			startActivityForResult(new Intent(mContext, SignSeniorSettingActivity.class), 0x12);
+			closePopupWindow();
+		} else if (v.getId() == R.id.work_setting_tv) {
+			intent = new Intent(mContext, FlightsActivity.class);
+			startActivityForResult(intent, 0x12);
+			closePopupWindow();
+		} else if (v.getId() == R.id.office_addr_setting_tv) {
+			startActivityForResult(new Intent(mContext, OfficeAddressSettingsActivity.class), 0x12);
+			closePopupWindow();
+		} else if (v.getId() == R.id.my_rule_setting_tv) {
+			intent = new Intent(mContext, MyRuleSetActivity.class);
+			showMyRele(intent);
+			startActivity(intent);
+			closePopupWindow();
+		} else if (v.getId() == R.id.cancel_tv) {
+			closePopupWindow();
+		}
+	}
+
+	public void showMyRele(Intent intent) {
+		List<WorkModel> models = WorkModelDao.getInstance().query(true);
+		if (models instanceof ArrayList)
+			intent.putParcelableArrayListExtra("data", (ArrayList<WorkModel>) models);
+		intent.putExtra("isFree", ListUtils.isEmpty(models));
+		intent.putExtra("day", OAConfig.days);
+		intent.putExtra("name",  OAConfig.name);
+	}
+
+	private void share() {
+		shareSingleImage();
+	}
+
+	//分享单张图片
+	public void shareSingleImage() {
+		Uri imageUri = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/" + R.drawable.ic_uu_scan_code);
+		Intent shareIntent = new Intent();
+		shareIntent.setAction(Intent.ACTION_SEND);
+		shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
+		shareIntent.setType("image/*");
+		startActivity(Intent.createChooser(shareIntent, getString(R.string.set_share_to)));
+	}
+
+	//确认是否清空本地缓存
+	private void showclearDialog() {
+		new AlertDialog
+				.Builder(mContext)
+				.setTitle(getString(R.string.common_notice))
+				.setMessage(getString(R.string.cache_msg))
+				.setNegativeButton(getString(R.string.common_cancel), null)
+				.setPositiveButton(getString(R.string.common_sure), new DialogInterface.OnClickListener() {
+
+					@Override
+					public void onClick(DialogInterface dialog, int which) {
+						clearCache();
+						Log.i("clearCache", "clearCache");
+					}
+				}).create().show();
+	}
+
+	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+	private void clearCache() {
+		String filePath = MyApplication.getInstance().mAppDir;
+		//删除文件
+		VideoFileDao.getInstance().deleteAllVideoFile(
+				VideoFileDao.getInstance().getVideoFiles(
+						MyApplication.getInstance().mLoginUser.getUserId()));
+		if (Build.VERSION.SDK_INT >= 11)
+			new ClearCacheAsyncTaska(filePath).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, true);
+		else
+			new ClearCacheAsyncTaska(filePath).execute(true);
+	}
+
+	private class ClearCacheAsyncTaska extends AsyncTask<Boolean, String, Integer> {
+		private File rootFile;
+		private ProgressDialog progressDialog;
+		private int filesNumber = 0;
+		private boolean canceled = false;
+
+		public ClearCacheAsyncTaska(String filePath) {
+			this.rootFile = new File(filePath);
+		}
+
+		@Override
+		protected void onPreExecute() {
+			filesNumber = FileUtils.getFolderSubFilesNumber(rootFile);
+			progressDialog = new ProgressDialog(mContext);
+			progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+			progressDialog.setIndeterminate(false);
+			progressDialog.setCancelable(false);
+			progressDialog.setMessage(getString(R.string.deleteing));
+			progressDialog.setMax(filesNumber);
+			progressDialog.setProgress(0);
+			// 设置取消按钮
+			progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() {
+				public void onClick(DialogInterface dialog, int i) {
+					canceled = true;
+				}
+			});
+			progressDialog.show();
+		}
+
+		/**
+		 * 返回true代表删除完成,false表示取消了删除
+		 */
+		@Override
+		protected Integer doInBackground(Boolean... params) {
+			if (filesNumber == 0) {
+				return 0;
+			}
+			Log.i("gongpengming", "doInBackground");
+			boolean deleteSubFolder = params[0];// 是否删除已清空的子文件夹
+			return deleteFolder(rootFile, true, deleteSubFolder, 0);
+		}
+
+		@Override
+		protected void onProgressUpdate(String... values) {
+			super.onProgressUpdate(values);
+			// String filePath = values[0];
+			int progress = Integer.parseInt(values[1]);
+			// progressDialog.setMessage(filePath);
+			progressDialog.setProgress(progress);
+		}
+
+		@Override
+		protected void onPostExecute(Integer result) {
+			super.onPostExecute(result);
+			progressDialog.dismiss();
+			if (!canceled && result == filesNumber) {
+				ToastUtil.showToast(mContext, R.string.clear_completed);
+			}
+			long cacheSize = FileUtils.getFileSize(rootFile);
+			mCacheTv.setText(FileUtils.formatFileSize(cacheSize));
+		}
+
+		private long notifyTime = 0;
+
+		/**
+		 * 是否删除完毕
+		 *
+		 * @param file
+		 * @param deleteSubFolder
+		 * @return
+		 */
+		private int deleteFolder(File file, boolean rootFolder, boolean deleteSubFolder, int progress) {
+			if (file == null || !file.exists() || !file.isDirectory()) {
+				return 0;
+			}
+			File flist[] = file.listFiles();
+			for (File subFile : flist) {
+				if (canceled) {
+					return progress;
+				}
+				if (subFile.isFile()) {
+					subFile.delete();
+					progress++;
+					long current = System.currentTimeMillis();
+					if (current - notifyTime > 200) {// 200毫秒更新一次界面
+						notifyTime = current;
+						publishProgress(subFile.getAbsolutePath(), String.valueOf(progress));
+					}
+				} else {
+					progress = deleteFolder(subFile, false, deleteSubFolder, progress);
+					if (deleteSubFolder) {
+						subFile.delete();
+					}
+				}
+			}
+			return progress;
+		}
+	}
+
+	private void showPopupWindow() {
+		if (setWindow == null) initPopupWindow();
+		setWindow.showAtLocation(getWindow().getDecorView().
+				findViewById(android.R.id.content), Gravity.BOTTOM, 0, 0);
+		DisplayUtil.backgroundAlpha(this, 0.4f);
+	}
+
+	private void initPopupWindow() {
+		View viewContext = LayoutInflater.from(mContext).inflate(R.layout.pop_work_activity, null);
+		if (!PreferenceUtils.getBoolean(AppConfig.IS_ADMIN, false)) {
+			viewContext.findViewById(R.id.super_setting_tv).setVisibility(View.GONE);
+			viewContext.findViewById(R.id.work_setting_tv).setVisibility(View.GONE);
+			viewContext.findViewById(R.id.office_addr_setting_tv).setVisibility(View.GONE);
+		} else {
+			viewContext.findViewById(R.id.super_setting_tv).setOnClickListener(this);
+			viewContext.findViewById(R.id.work_setting_tv).setOnClickListener(this);
+			viewContext.findViewById(R.id.office_addr_setting_tv).setOnClickListener(this);
+		}
+		viewContext.findViewById(R.id.my_rule_setting_tv).setOnClickListener(this);
+		viewContext.findViewById(R.id.cancel_tv).setOnClickListener(this);
+		setWindow = new PopupWindow(viewContext,
+				LinearLayout.LayoutParams.MATCH_PARENT,
+				LinearLayout.LayoutParams.WRAP_CONTENT, true);
+		setWindow.setAnimationStyle(R.style.MenuAnimationFade);
+		setWindow.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_popuwin));
+		setWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+			@Override
+			public void onDismiss() {
+				closePopupWindow();
+			}
+		});
+	}
+
+	private void closePopupWindow() {
+		if (setWindow != null)
+			setWindow.dismiss();
+		DisplayUtil.backgroundAlpha(this, 1f);
+	}
 }

+ 836 - 829
app_modular/appworks/src/main/java/com/uas/appworks/OA/erp/utils/AutoErpSigninUitl.java

@@ -65,835 +65,842 @@ import static com.core.utils.CommonUtil.getSharedPreferences;
  */
 public class AutoErpSigninUitl implements OnHttpResultListener {
 
-    private final int MAC_VAL = 0x11;//判断mac地址
-    private final int SIGNING = 0x12;//内勤签到
-    private final int LOAD_WORKLOG = 0x13;//打卡列表
-    private final int SIGNIN_MISSION = 0x14;//外勤签到
-    private final int HAVE_OUT_PLAN = 0x15;//还有未拜访外勤计划
-    private final int WORK_DATA = 0x16;//内勤列表
-    private final int WORK_LOG = 0x17;//下拉列表时候的获取打卡列表
-    private final int LOAD_PLAN = 0x18;
-    private final int LOAD_WORK_SET = 0x21;//获取打卡高级设置
-    private boolean isB2b;
-    private NotificationManage notificationManage;
-
-    public AutoErpSigninUitl() {
-        notificationManage = new NotificationManage();
-        isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
-    }
-
-    /**
-     * 签到内勤
-     *
-     * @param model 签到班次对象
-     */
-    public void signinWork(WorkModel model) {
-        //1.判读mac地址是否符合     3.签到
-        if (!MyApplication.getInstance().isNetworkActive()) {
-            CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), getString(R.string.common_notlinknet));
-            return;
-        }
-        String macAddress = SystemUtil.getMac(MyApplication.getInstance());
-        if (StringUtil.isEmpty(macAddress)) {
-            CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), "未获取到mac地址");
-            return;
-        }
-        if (isB2b) {
-            Bundle bundle = new Bundle();
-            bundle.putParcelable("data", model);
-            signinWork(bundle, "");
-        } else {
-            validatorMac(model, macAddress);
-        }
-    }
-
-    /**
-     * 签到外勤
-     *
-     * @param model 签到对象
-     */
-    public void signinMission(MissionModel model) {
-        if (model == null) return;
-        if (!MyApplication.getInstance().isNetworkActive()) {
-            notificationManage.sendNotification(ct, R.string.out_net_signin, MissionActivity.class);
-            CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_outplan_failed), getString(R.string.common_notlinknet));
-            return;
-        }
-        Map<String, Object> param = new HashMap<>();
-        Map<String, Object> formStore = new HashMap<>();
-        String emcode = CommonUtil.getEmcode();
-        String name = CommonUtil.getName();
-        String address = MyApplication.getInstance().getBdLocationHelper().getAddress();
-        if (StringUtil.isEmpty(address))
-            address = model.getCompanyAddr();
-        String remark = model.getStatus() == 2 ? MyApplication.getInstance().getString(R.string.auto_mission_signindown)
-                : MyApplication.getInstance().getString(R.string.auto_mission_signinup);
-        String location = model.getCompanyName();
-        if (StringUtil.isEmpty(location) || isB2b)
-            location = MyApplication.getInstance().getBdLocationHelper().getName();
-        formStore.put("mo_remark", remark);//备注
-        formStore.put("mo_company", location);
-        formStore.put("mo_address", address);
-        if (isB2b) {
-            formStore.put("enuu", CommonUtil.getMaster());
-            formStore.put("mpd_id", model.getId());
-            formStore.put("emcode", emcode);
-        } else {
-            param.put("mpd_id", model.getId());
-            param.put("caller", "Mobile_outsign");
-            formStore.put("mo_man", name);
-            formStore.put("mo_mancode", emcode);
-        }
-        param.put("formStore", JSONUtil.map2JSON(formStore));
-        Bundle bundle = new Bundle();
-        bundle.putParcelable("data", model);
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().saveOutSign :
-                "mobile/addAutoSign.action";
-        Request request = new Request.Bulider()
-                .setBundle(bundle)
-                .setMode(Request.Mode.POST)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(SIGNIN_MISSION)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    /*判断mac地址是否符合*/
-    private void validatorMac(WorkModel model, String macAddress) {
-        Map<String, Object> param = new HashMap<>();
-        param.put("macAddress", macAddress);
-        param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
-        Bundle bundle = new Bundle();
-        bundle.putParcelable("data", model);
-        String url = "mobile/addMobileMac.action";
-        Request request = new Request.Bulider()
-                .setBundle(bundle)
-                .setMode(Request.Mode.POST)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(MAC_VAL)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    //签到
-    private void signinWork(Bundle bunder, String code) {
-        Context ct = MyApplication.getInstance();
-        Map<String, Object> param = new HashMap<>();
-        Map<String, Object> form = new HashMap<>();
-        if (!isB2b)
-            form.put("cl_code", code);
-        String phone = MyApplication.getInstance().mLoginUser.getTelephone();
-        if (StringUtil.isEmpty(phone)) {
-            String userId = MyApplication.getInstance().mLoginUser.getUserId();
-            if (!StringUtil.isEmpty(userId)) {
-                User user = UserDao.getInstance().getUserByUserId(userId);
-                phone = user.getTelephone();
-            } else
-                phone = getSharedPreferences(MyApplication.getInstance(), "user_phone");
-        }
-        form.put("cl_phone", phone);
-        form.put("cl_emcode", getSharedPreferences(ct, "erp_username"));
-        String emname = getSharedPreferences(ct, "erp_emname");
-        if (StringUtil.isEmpty(emname)) {
-            emname = MyApplication.getInstance().mLoginUser.getNickName().trim();
-        }
-        form.put("cl_emname", emname);
-        boolean isp = isPlay(form);
-        if (!isp) {
-            return;//不符合打卡
-        }
-        if (isB2b) {
-            form.put("enuu", getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu"));
-            form.put("emcode", getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu"));
-        } else
-            param.put("caller", "CardLog");
-
-        String formStore = JSONUtil.map2JSON(form);
-        param.put("formStore", formStore);
-        param.put("emcode", getSharedPreferences(ct, "erp_username"));
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_worksignin_url :
-                "mobile/saveCardLog.action";
-        Request request = new Request.Bulider()
-                .setBundle(bunder)
-                .setMode(Request.Mode.POST)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(SIGNING)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-
-    }
-
-
-    /*判断是否符合打卡*/
-    private boolean isPlay(Map<String, Object> form) {
-        try {
-            //判断是否符合打卡
-            BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
-            String address = helper.getAddress();
-            if (StringUtil.isEmpty(address))
-                address = PreferenceUtils.getString("bdaddress");
-            form.put("cl_address", address);
-            form.put("cl_location", "android " + MyApplication.getInstance().getString(R.string.auto_work_signin_log));
+	private final int MAC_VAL = 0x11;//判断mac地址
+	private final int SIGNING = 0x12;//内勤签到
+	private final int LOAD_WORKLOG = 0x13;//打卡列表
+	private final int SIGNIN_MISSION = 0x14;//外勤签到
+	private final int HAVE_OUT_PLAN = 0x15;//还有未拜访外勤计划
+	private final int WORK_DATA = 0x16;//内勤列表
+	private final int WORK_LOG = 0x17;//下拉列表时候的获取打卡列表
+	private final int LOAD_PLAN = 0x18;
+	private final int LOAD_WORK_SET = 0x21;//获取打卡高级设置
+	private boolean isB2b;
+	private NotificationManage notificationManage;
+
+	public AutoErpSigninUitl() {
+		notificationManage = new NotificationManage();
+		isB2b = ApiUtils.getApiModel() instanceof ApiPlatform;
+	}
+
+	/**
+	 * 签到内勤
+	 *
+	 * @param model 签到班次对象
+	 */
+	public void signinWork(WorkModel model) {
+		//1.判读mac地址是否符合     3.签到
+		if (!MyApplication.getInstance().isNetworkActive()) {
+			CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), getString(R.string.common_notlinknet));
+			return;
+		}
+		String macAddress = SystemUtil.getMac(MyApplication.getInstance());
+		if (StringUtil.isEmpty(macAddress)) {
+			CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), "未获取到mac地址");
+			return;
+		}
+		if (isB2b) {
+			Bundle bundle = new Bundle();
+			bundle.putParcelable("data", model);
+			signinWork(bundle, "");
+		} else {
+			validatorMac(model, macAddress);
+		}
+	}
+
+	/**
+	 * 签到外勤
+	 *
+	 * @param model 签到对象
+	 */
+	public void signinMission(MissionModel model) {
+		if (model == null) return;
+		if (!MyApplication.getInstance().isNetworkActive()) {
+			notificationManage.sendNotification(ct, R.string.out_net_signin, MissionActivity.class);
+			CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_outplan_failed), getString(R.string.common_notlinknet));
+			return;
+		}
+		Map<String, Object> param = new HashMap<>();
+		Map<String, Object> formStore = new HashMap<>();
+		String emcode = CommonUtil.getEmcode();
+		String name = CommonUtil.getName();
+		String address = MyApplication.getInstance().getBdLocationHelper().getAddress();
+		if (StringUtil.isEmpty(address))
+			address = model.getCompanyAddr();
+		String remark = model.getStatus() == 2 ? MyApplication.getInstance().getString(R.string.auto_mission_signindown)
+				: MyApplication.getInstance().getString(R.string.auto_mission_signinup);
+		String location = model.getCompanyName();
+		if (StringUtil.isEmpty(location) || isB2b)
+			location = MyApplication.getInstance().getBdLocationHelper().getName();
+		formStore.put("mo_remark", remark);//备注
+		formStore.put("mo_company", location);
+		formStore.put("mo_address", address);
+		if (isB2b) {
+			formStore.put("enuu", CommonUtil.getMaster());
+			formStore.put("mpd_id", model.getId());
+			formStore.put("emcode", emcode);
+		} else {
+			param.put("mpd_id", model.getId());
+			param.put("caller", "Mobile_outsign");
+			formStore.put("mo_man", name);
+			formStore.put("mo_mancode", emcode);
+		}
+		param.put("formStore", JSONUtil.map2JSON(formStore));
+		Bundle bundle = new Bundle();
+		bundle.putParcelable("data", model);
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().saveOutSign :
+				"mobile/addAutoSign.action";
+		Request request = new Request.Bulider()
+				.setBundle(bundle)
+				.setMode(Request.Mode.POST)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(SIGNIN_MISSION)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	/*判断mac地址是否符合*/
+	private void validatorMac(WorkModel model, String macAddress) {
+		Map<String, Object> param = new HashMap<>();
+		param.put("macAddress", macAddress);
+		param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
+		Bundle bundle = new Bundle();
+		bundle.putParcelable("data", model);
+		String url = "mobile/addMobileMac.action";
+		Request request = new Request.Bulider()
+				.setBundle(bundle)
+				.setMode(Request.Mode.POST)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(MAC_VAL)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	//签到
+	private void signinWork(Bundle bunder, String code) {
+		Context ct = MyApplication.getInstance();
+		Map<String, Object> param = new HashMap<>();
+		Map<String, Object> form = new HashMap<>();
+		if (!isB2b)
+			form.put("cl_code", code);
+		String phone = MyApplication.getInstance().mLoginUser.getTelephone();
+		if (StringUtil.isEmpty(phone)) {
+			String userId = MyApplication.getInstance().mLoginUser.getUserId();
+			if (!StringUtil.isEmpty(userId)) {
+				User user = UserDao.getInstance().getUserByUserId(userId);
+				phone = user.getTelephone();
+			} else
+				phone = getSharedPreferences(MyApplication.getInstance(), "user_phone");
+		}
+		form.put("cl_phone", phone);
+		form.put("cl_emcode", getSharedPreferences(ct, "erp_username"));
+		String emname = getSharedPreferences(ct, "erp_emname");
+		if (StringUtil.isEmpty(emname)) {
+			emname = MyApplication.getInstance().mLoginUser.getNickName().trim();
+		}
+		form.put("cl_emname", emname);
+		boolean isp = isPlay(form);
+		if (!isp) {
+			return;//不符合打卡
+		}
+		if (isB2b) {
+			form.put("enuu", getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu"));
+			form.put("emcode", getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu"));
+		} else
+			param.put("caller", "CardLog");
+
+		String formStore = JSONUtil.map2JSON(form);
+		param.put("formStore", formStore);
+		param.put("emcode", getSharedPreferences(ct, "erp_username"));
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_worksignin_url :
+				"mobile/saveCardLog.action";
+		Request request = new Request.Bulider()
+				.setBundle(bunder)
+				.setMode(Request.Mode.POST)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(SIGNING)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+
+	}
+
+
+	/*判断是否符合打卡*/
+	private boolean isPlay(Map<String, Object> form) {
+		try {
+			//判断是否符合打卡
+			BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
+			String address = helper.getAddress();
+			if (StringUtil.isEmpty(address))
+				address = PreferenceUtils.getString("bdaddress");
+			form.put("cl_address", address);
+			form.put("cl_location", "android " + MyApplication.getInstance().getString(R.string.auto_work_signin_log));
 //            int comDistance = PreferenceUtils.getInt("distance", 0);
-            float distance = BaiduMapUtil.getInstence().getDistance();
-            if (distance == 0) {
-                //TODO 规定地址<实际地址  不符合
-                //判断是否有外勤
-                boolean isOutPlan = PreferenceUtils.getBoolean(AppConfig.HAVE_OUT_PLAN, false);
-                if (!isOutPlan) {
-                    //TODO 没有自动外勤
-                }
-                return false;
-            } else {
-                form.put("cl_distance", distance);
-                return true;
-            }
-        } catch (NullPointerException e) {
-            return false;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-    //获取打卡记录
-    private void loadLog(Bundle bunder) throws Exception {
-        String date = TimeUtils.s_long_2_str(System.currentTimeMillis());
-        //获取网络数据
-        Map<String, Object> param = new HashMap<>();
-        String code = getSharedPreferences(MyApplication.getInstance(), "erp_username");
-        param.put("currentMaster", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
-        if (isB2b) {
-            param.put("pageNumber", 1);
-            param.put("date", DateFormatUtil.long2Str(System.currentTimeMillis(), "yyyyMMdd"));
-        } else {
-            param.put("page", 1);
-            param.put("condition", "cl_emcode='" + code + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
-        }
-        param.put("pageSize", 100);
-        param.put("caller", "CardLog");
-        param.put("emcode", code);
-        param.put("master", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
-
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_record_url :
-                "mobile/oa/workdata.action";
-        Request request = new Request.Bulider()
-                .setBundle(bunder)
-                .setMode(Request.Mode.GET)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(LOAD_WORKLOG)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    //获取是否有外勤计划
-    public void loadIsMission(MissionModel model) {
-        Map<String, Object> param = new HashMap<>();
-        param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
-        Bundle bunder = new Bundle();
-        bunder.putParcelable("data", model);
-        String url = "mobile/yesornoplan.action";
-        Request request = new Request.Bulider()
-                .setParam(param)
-                .setBundle(bunder)
-                .setUrl(url)
-                .setWhat(HAVE_OUT_PLAN)
-                .setMode(Request.Mode.GET)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-
-    /*****************
-     * 下拉列表
-     ***********************/
-    /**
-     * 下拉内勤数据
-     */
-    public void loadWorkData() {
-        Map<String, Object> param = new HashMap<>();
-        param.put("date", DateFormatUtil.long2Str("yyyyMMdd"));
-        param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
-        Bundle bundle = new Bundle();
-
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_schedule_url :
-                "mobile/getWorkDate.action";
-        Request request = new Request.Bulider()
-                .setBundle(bundle)
-                .setMode(Request.Mode.GET)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(WORK_DATA)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-
-    }
-
-
-    private void loadLog(ArrayList<WorkModel> models) {
-        String date = TimeUtils.s_long_2_str(System.currentTimeMillis());
-        //获取网络数据
-        Map<String, Object> param = new HashMap<>();
-        String code = getSharedPreferences(MyApplication.getInstance(), "erp_username");
-        param.put("currentMaster", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
-        if (isB2b) {
-            param.put("date", DateFormatUtil.long2Str(System.currentTimeMillis(), "yyyyMMdd"));
-            param.put("pageNumber", 1);
-        } else {
-            param.put("condition", "cl_emcode='" + code + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
-            param.put("page", 1);
-        }
-        param.put("pageSize", 100);
-        param.put("caller", "CardLog");
-        param.put("emcode", code);
-        param.put("master", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
-        Bundle bundle = new Bundle();
-        bundle.putParcelableArrayList("models", models);
-
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_record_url :
-                "mobile/oa/workdata.action";
-        Request request = new Request.Bulider()
-                .setBundle(bundle)
-                .setMode(Request.Mode.GET)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(WORK_LOG)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    public void loadWorkSet() {
-        //获取考勤高级设置时间请求
-        Map<String, Object> param = new HashMap<>();
-        if (!isB2b)
-            param.put("code", 1);
-
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().get_plat_senior_setting_url :
-                "mobile/getconfigs.action";
-        Request request = new Request.Bulider()
-                .setMode(Request.Mode.GET)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(LOAD_WORK_SET)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    //获取外勤计划列表
-    public void loadMissionPlan() {
-        Map<String, Object> param = new HashMap<>();
-        param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
-        String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getOutPlan :
-                "mobile/mobileoutplan.action";
-        Request request = new Request.Bulider()
-                .setMode(Request.Mode.GET)
-                .setParam(param)
-                .setUrl(url)
-                .setWhat(LOAD_PLAN)
-                .bulid();
-        OAHttpHelper.getInstance().requestHttp(request, this);
-    }
-
-    @Override
-    public void result(int what, boolean isJSON, String message, final Bundle bundle) {
-        try {
-            switch (what) {
-                case MAC_VAL://判断mac地址
-                    if (isJSON && JSON.parseObject(message).containsKey("success") &&
-                            JSON.parseObject(message).getBoolean("success")) {
-                        CommonInterface.getInstance().getCodeByNet("CardLog", new CommonInterface.OnResultListener() {
-                            @Override
-                            public void result(boolean isOk, int result, String message) {
-                                signinWork(bundle, message);
-                            }
-                        });
-                    } else {
-                        CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), message);
-                    }
-                    break;
-                case SIGNING:
-                    String subtitle = MyApplication.getInstance().getBdLocationHelper().getName();
-                    if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true)) {
-                        boolean saveOk = MessageDao.getInstance().instartSignin(getString(R.string.auto_work_signin_alert),
-                                StringUtil.isEmpty(subtitle) ? getString(R.string.uu_auto_work_signined_up) : subtitle);
-                        if (saveOk) {
-                            Intent intent = new Intent(OAConfig.AUTO_SIGIN_ALART);
-                            LocalBroadcastManager.getInstance(MyApplication.getInstance()).sendBroadcast(intent);
-                        }
-                    }
-                    loadLog(bundle);
-                    break;
-                case LOAD_WORKLOG://签到后保存到打卡数据库里面
-                    if (isJSON && JSON.parseObject(message).containsKey("listdata")) {
-                        saveSignin2DB(bundle, JSON.parseObject(message).getJSONArray("listdata"));
-                    }
-                    break;
-                case SIGNIN_MISSION:
-                    if (isJSON) {
-                        if (JSON.parseObject(message).containsKey("success") && JSON.parseObject(message).getBoolean("success")) {
-                            //成功  更新数据库
-                            if (bundle == null) return;
-                            MissionModel mission = bundle.getParcelable("data");
-                            if (mission == null) return;
-                            updataMissonDB(mission);
-                        }
-                    }
-                    break;
-                case HAVE_OUT_PLAN:
-                    if (!isJSON) return;
-                    JSONObject object = JSON.parseObject(message);
-                    if (!object.containsKey("success") || !object.getBoolean("success")) return;
-                    if (object.containsKey("isOffline")) {
-                        int isOffline = Integer.valueOf(object.getString("isOffline"));
-                        //当判断到外勤计划为有值  1.外勤计划有  2.自动外勤
-                        if (bundle != null && bundle.getParcelable("data") != null) {
-                            MissionModel model = bundle.getParcelable("data");
-                            if (model == null) {
-                                LogUtil.i("model==null");
-                                return;
-                            }
-                            boolean saveOk = MissionDao.getInstance().updata(model);
-                            if (isOffline > 0) {//还有外勤计划
-                                if (saveOk)
-                                    notificationManage.sendNotification(MyApplication.getInstance(),
-                                            model.getCompanyName() + MyApplication.getInstance().getString(R.string.success_signin_down_mission), MissionActivity.class);
-                            } else {//没有外勤计划
-                                endMission(model, saveOk);
-                                List<MissionModel> models = MissionDao.getInstance().queryByEnCode();
-                                if (ListUtils.isEmpty(models) || !isMoreMission(models))
-                                    endOfMission();
-
-                            }
-                        }
-                    }
-                case WORK_DATA://打卡班次
-                    handlerWorkData(isJSON, message);
-                    break;
-                case WORK_LOG://
-                    ArrayList<WorkModel> models = null;
-                    if (bundle != null) models = bundle.getParcelableArrayList("models");
-                    handlerWorkLog(isJSON, message, models);
-                    break;
-                case LOAD_PLAN:
-                    JSONArray array = null;
-                    if (isJSON && JSON.parseObject(message).get("data") instanceof JSONArray) {
-                        array = JSON.parseObject(message).getJSONArray("data");
-                    } else if (JSON.parseObject(message).get("success") instanceof JSONArray) {
-                        array = JSON.parseObject(message).getJSONArray("success");
-                    }
-                    handlerData(array);
-                    break;
-                case LOAD_WORK_SET:
-                    if (isJSON) {
-                        handlerWorkSet(JSON.parseObject(message));
-                    }
-                    break;
-                default:
-                    break;
-            }
-        } catch (Exception e) {
-            if (e != null) {
-                LogUtil.i("result=" + e.getMessage());
-                CommonUtil.saveAutoLogtoLocal(getString(R.string.app_monitor_log), e.getMessage());
-            }
-        }
-    }
-
-    boolean isErrorMac;
-
-    @Override
-    public void error(int what, String message, Bundle bundle) {
-        if (!StringUtil.isEmpty(message)) {
-            String msg = null;
-            if (StringUtil.isInclude(message, MyApplication.getInstance().getString(R.string.is_not_common_device))) {
-                msg = MyApplication.getInstance().getString(R.string.is_not_common_device_not_signin);
-                CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
-            } else if (StringUtil.isInclude(message, "设备正处于申请变更绑定阶段")) {
-                msg = MyApplication.getInstance().getString(R.string.is_changeing_not_signin);
-                CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
-            } else if (StringUtil.isInclude(message, "该设备已被他人绑定")) {
-                msg = MyApplication.getInstance().getString(R.string.is_binded_other_not_signin);
-                CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
-            } else if (what == SIGNIN_MISSION) {
-                try {
-                    Intent intent = new Intent();
-                    intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
-                    intent.setAction(AppConstant.CHANGE_MISSION_TASK);
-                    MsgBroadcast.sendLocalBroadcast(intent);
-                    if (!StringUtil.isEmpty(message))
-                        CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_outplan_failed), message);
-                } catch (Exception e) {
-                }
-            }
-            if (!StringUtil.isEmpty(msg))
-                CommonUtil.saveAutoLogtoLocal(getString(R.string.app_monitor_log), msg);
-            if (!isErrorMac && !StringUtil.isEmpty(msg)) {
-                isErrorMac = true;
-                notificationManage.sendNotification(MyApplication.getInstance(), msg, WorkActivity.class);
-            }
-        }
-    }
-
-    /**
-     * 外勤签到签退处理
-     * 1.签退:status==1&&离开范围之内==》mission.setStatus(2) ,先把状态设置位2在传进来签退
-     * 2.签到:在范围之内,status不做任何改变 传进来签到
-     *
-     * @param mission 传进来的对象
-     * @throws Exception
-     */
-
-    private void updataMissonDB(MissionModel mission) throws Exception {
-        //更新数据库
-        if (mission == null) return;//如果数据库没有,一般不会出现这样的情况
-        if (StringUtil.isEmpty(mission.getRealTime()))
-            mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
-        else mission.setRealLeave(TimeUtils.f_long_2_str(System.currentTimeMillis()));
-        String title = "";
-        String subTitle = "";
-        if (mission.getStatus() == 2) {//签退
-            title = MyApplication.getInstance().getString(R.string.auto_mission_alert);
-            if (StringUtil.isEmpty(mission.getCompanyName()))
-                subTitle = MyApplication.getInstance().getString(R.string.uu_auto_signined_down);
-            else
-                subTitle = MyApplication.getInstance().getString(R.string.visit) + mission.getCompanyName() + getString(R.string.success_signin_down);
-
-            CommonInterface.getInstance().endMission(mission.getId(), false);
-            loadIsMission(mission);
-        } else {//签到
-            if (mission.getStatus() < 1) {
-                title = getString(R.string.auto_mission_alert);
-                if (StringUtil.isEmpty(mission.getCompanyName()))
-                    subTitle = getString(R.string.uu_auto_signined_up);
-                else
-                    subTitle = getString(R.string.visit) + mission.getCompanyName() + getString(R.string.success_signin_up);
-                mission.setStatus(1);//说明没有打过卡
-                boolean saveOk = MissionDao.getInstance().updata(mission);
-                if (saveOk)//XXX公司自动外勤签到成功
-                    notificationManage.sendNotification(MyApplication.getInstance(), mission.getCompanyName()
-                                    + getString(R.string.success_signin_up_mission),
-                            MissionActivity.class);
-            }
-        }
-        MissionDao.getInstance().updata(mission);
-        if (!StringUtil.isEmpty(title) && !StringUtil.isEmpty(subTitle))
-            MessageDao.getInstance().instartSignin(title, subTitle);
-    }
-
-    /**
-     * 外勤签退后判断时候还有外勤计划,如果没有,判断是否符合返回公司  返回提示请返回公司签到
-     *
-     * @param model
-     * @param saveOk
-     * @throws Exception
-     */
-    private void endMission(final MissionModel model, final boolean saveOk) throws Exception {
-        float longitude = PreferenceUtils.getFloat("longitude");
-        float latitude = PreferenceUtils.getFloat("latitude");
-        BaiduMapUtil.getInstence().getDrivingRoute(MyApplication.getInstance().
-                getBdLocationHelper().getLocation(), new LatLng(latitude, longitude), new OnGetDrivingRouteResult() {
-            @Override
-            public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
-                List<DrivingRouteLine> list = drivingRouteResult.getRouteLines();
-                if (ListUtils.isEmpty(list)) {//获取路线列表为空
-                    if (saveOk)
-                        notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
-                                MissionActivity.class);
-                    return;
-                }
-                int minTime = 0;
-                for (DrivingRouteLine e : list) {
-                    if (minTime == 0 || minTime > e.getDuration()) {
-                        minTime = e.getDuration();
-                    }
-                }
-                LogUtil.i("最短时间为" + minTime);
-                //获取使用时间为。。。。
-                //当前时间
-                List<WorkModel> models = WorkModelDao.getInstance().query(true);
-                if (ListUtils.isEmpty(models)) {
-                    LogUtil.i("数据库中的班次为空的");
-                    if (saveOk)
-                        notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
-                                MissionActivity.class);
-                    return;
-                }
-                String lastTime = null;
-                for (WorkModel e : models) {
-                    if (StringUtil.isEmpty(e.getOffTime())) continue;
-                    if (StringUtil.isEmpty(lastTime) || e.getOffTime().compareTo(lastTime) > 0)
-                        lastTime = e.getOffTime();
-                }
-                if (StringUtil.isEmpty(lastTime)) {
-                    if (saveOk)
-                        notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
-                                MissionActivity.class);
-                    return;
-                }
-                int time = getTime(lastTime);
-                LogUtil.i("与下班时间相差" + time);
-                int deTime = PreferenceUtils.getInt(AppConfig.AUTO_MISSION_TIME, 10);
-                if ((minTime + deTime * 60) < time) {
-                    notificationManage.sendNotification(MyApplication.getInstance(),
-                            R.string.success_signin_down_can_back, WorkActivity.class);
-                } else {
-                    Log.i("gongpengming", "时间不符合");
-                    if (saveOk)
-                        notificationManage.sendNotification(MyApplication.getInstance(),
-                                R.string.success_signin_down_task_ok, MissionActivity.class);
-                }
-            }
-        });
-    }
-
-    //保存到数据库
-    private void saveSignin2DB(Bundle bundle, JSONArray array) throws Exception {
-        WorkModel model = null;
-        if (bundle != null && bundle.getParcelable("data") != null) {
-            model = bundle.getParcelable("data");
-        } else {
-            List<WorkModel> models = WorkModelDao.getInstance().query(false);
-            if (ListUtils.isEmpty(models)) return;
-            String time = DateFormatUtil.long2Str(System.currentTimeMillis(), "HH:mm");
-            for (WorkModel m : models) {
-                //当前时间位于该班次之间
-                if (m.getWorkStart().compareTo(time) < 0 && m.getOffend().compareTo(time) > 0) {
-                    model = m;
-                    break;
-                }
-            }
-        }
-        //取最后一个
-        JSONObject object = array.getJSONObject(array.size() - 1);
-        String time = object.getString("cl_time");//获取最后一次打卡信息,班次打卡信息
-        time = DateFormatUtil.formatChange(time, DateFormatUtil.HM);//获取到的
-        if (StringUtil.isEmpty(time) || model == null) return;
-
-        if (StringUtil.isEmpty(model.getWorkSignin()) && model.getWorkStart().compareTo(time) <= 0
-                && model.getWorkTime().compareTo(time) >= 0) {
-            model.setWorkSignin(time);
-            long i = WorkModelDao.getInstance().update(model);
-            if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true))
-                notificationManage.sendNotification(MyApplication.getInstance(),
-                        R.string.auto_signin, WorkActivity.class);
-            boolean b = hasMore();
-            if (!b) {
-                //TODO 关闭任务
-                Intent intent = new Intent();
-                intent.setAction(CHANGE_WORK_TASK);
-                intent.putExtra(CHANGE_WORK_TASK, false);
-                MsgBroadcast.sendLocalBroadcast(intent);
-            }
-        } else if (StringUtil.isEmpty(model.getOffSignin()) && model.getOffTime().compareTo(time) <= 0
-                && model.getOffend().compareTo(time) >= 0) {
-            model.setOffSignin(time);
-            WorkModelDao.getInstance().update(model);
-            if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true))
-                notificationManage.sendNotification(MyApplication.getInstance(),
-                        R.string.auto_signin, WorkActivity.class);
-            boolean b = hasMore();
-            if (!b) {
-                Intent intent = new Intent();
-                intent.setAction(CHANGE_WORK_TASK);
-                intent.putExtra(CHANGE_WORK_TASK, false);
-                MsgBroadcast.sendLocalBroadcast(intent);
-            }
-        }
-    }
-
-    private boolean hasMore() {
-        List<WorkModel> models = WorkModelDao.getInstance().query(false);
-        if (ListUtils.isEmpty(models)) return false;
-        else {
-            for (WorkModel m : models) {
-                if (StringUtil.isEmpty(m.getWorkSignin()) || StringUtil.isEmpty(m.getOffSignin()))
-                    return true;
-            }
-        }
-        return false;
-    }
-
-
-    /**
-     * 处理打卡签到
-     *
-     * @param isJSON
-     * @param message
-     */
-    private void handlerWorkData(boolean isJSON, String message) throws Exception {
-        if (!isJSON)
-            return;
-        JSONObject object = JSON.parseObject(message);
-        ArrayList<WorkModel> models = WorkHandlerUtil.handlerWorkData(object, isB2b);
-        WorkHandlerUtil.handerLocation(object, isB2b);
-        if (ListUtils.isEmpty(models)) {
-            return;
-        }
-        loadLog(models);
-    }
-
-
-    /**
-     * 处理打卡签到列表,建议在线程钟使用
-     *
-     * @param isJSON     是否是json数据
-     * @param message    返回信息
-     * @param workModels 获取班次信息时候的数据
-     * @throws Exception
-     */
-    private void handlerWorkLog(boolean isJSON, String message, ArrayList<WorkModel> workModels) throws Exception {
-        if (!isJSON || ListUtils.isEmpty(workModels)) {
-            saveDb(workModels);
-            return;
-        }
-        JSONObject object = JSON.parseObject(message);
-        ArrayList<WorkModel> models = WorkHandlerUtil.handlerWorkLog(object, workModels);
-        saveDb(models);
-    }
-
-
-    private void saveDb(final List<WorkModel> models) {
-        if (!ListUtils.isEmpty(models)) {
-            ThreadUtil.getInstance().addTask(new Runnable() {
-                @Override
-                public void run() {
-                    boolean saveOK = WorkModelDao.getInstance().createOrUpdata(models, System.currentTimeMillis());
-                    if (saveOK) {
-                        OAHttpHelper.getInstance().post(new Runnable() {
-                            @Override
-                            public void run() {
-                                Intent intent = new Intent();
-                                intent.setAction(CHANGE_WORK_TASK);//保存到数据库成功,开启
-                                intent.putExtra(CHANGE_WORK_TASK, true);
-                                MsgBroadcast.sendLocalBroadcast(intent);
-                            }
-                        });
-                    }
-                }
-            });
-        }
-    }
-
-    /**
-     * 第一次进来应用会请求一次数据,并把数据保存到数据库中,保存成功后发送广播,更新轮询
-     * 解析处理外勤计划列表并保存到数据库
-     *
-     * @param array
-     */
-    private void handlerData(JSONArray array) throws Exception {
-        if (ListUtils.isEmpty(array)) {
-            ThreadUtil.getInstance().addTask(new Runnable() {
-                @Override
-                public void run() {
-                    List<MissionModel> models = MissionDao.getInstance().queryByEnCode();
-                    if (!ListUtils.isEmpty(models)) {
-                        OAHttpHelper.getInstance().post(new Runnable() {
-                            @Override
-                            public void run() {
-                                Intent intent = new Intent();
-                                intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
-                                intent.setAction(AppConstant.CHANGE_MISSION_TASK);
-                                MsgBroadcast.sendLocalBroadcast(intent);
-                            }
-                        });
-
-                    }
-                }
-            });
-        } else {
-            JSONObject object = null;
-            MissionModel entity = null;
-            final List<MissionModel> entities = new ArrayList<>();
-            for (int i = 0; i < array.size(); i++) {
-                object = array.getJSONObject(i);
-                entity = WorkHandlerUtil.handlerEntity(isB2b, object);
-                if (entity == null)
-                    continue;
-                entities.add(entity);
-            }
-            if (!ListUtils.isEmpty(entities)) {
-                LogUtil.i("保存到数据库成功");
-                ThreadUtil.getInstance().addTask(new Runnable() {
-                    @Override
-                    public void run() {
-                        boolean saveOk = false;
-                        try {
-                            saveOk = MissionDao.getInstance().updataOrCreate(entities);
-                            if (!saveOk)
-                                saveOk = !ListUtils.isEmpty(MissionDao.getInstance().queryByEnCode());
-                        } catch (Exception e) {
-
-                        }
-                        if (saveOk) {
-                            CommonUtil.saveAutoLogtoLocal(getString(R.string.app_start_log), getString(R.string.app_outplan_running));
-                            //TODO 保存异常数据库
-                            OAHttpHelper.getInstance().post(new Runnable() {
-                                @Override
-                                public void run() {
-                                    Intent intent = new Intent();
-                                    intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
-                                    intent.setAction(AppConstant.CHANGE_MISSION_TASK);
-                                    MsgBroadcast.sendLocalBroadcast(intent);
-                                    LogUtil.i("发送广播成功");
-                                }
-                            });
-                        }
-                    }
-                });
-            }
-        }
-    }
-
-
-    private void handlerWorkSet(JSONObject o) {
-        try {
-            WorkHandlerUtil.handlerWorkSet(o);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        if (OAConfig.autosign)
-            loadWorkData();
-        else
-            try {
-                //如果不是自动打卡和提醒,清空数据库今天的数据
-                WorkModelDao.getInstance().clearByDate(System.currentTimeMillis());
-            } catch (Exception e) {
-                if (e != null)
-                    LogUtil.i("initNet Exception=" + e.getMessage());
-            }
-    }
-
-    private boolean isMoreMission(List<MissionModel> models) {
-        for (MissionModel e : models) {
-            if (e.getType() != 1) {
-                LogUtil.i("返回正确");
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void endOfMission() {
-        Intent intent = new Intent();
-        intent.setAction(AppConstant.CHANGE_MISSION_TASK);
-        intent.putExtra(AppConstant.CHANGE_MISSION_TASK, false);
-        MsgBroadcast.sendLocalBroadcast(intent);
-    }
-
-    //获取当前时间鱼下班时间的差
-    private int getTime(String lastTime) {
-        long time = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis())
-                + " " + lastTime + ":00");
-        long time2 = time - System.currentTimeMillis();
-        if (time < 0) return 0;
-        return (int) (time2 / 1000);
-    }
-
-    private String getString(int id) {
-        return MyApplication.getInstance().getString(id);
-    }
+			float distance = BaiduMapUtil.getInstence().getDistance();
+			if (distance == 0) {
+				//TODO 规定地址<实际地址  不符合
+				//判断是否有外勤
+				boolean isOutPlan = PreferenceUtils.getBoolean(AppConfig.HAVE_OUT_PLAN, false);
+				if (!isOutPlan) {
+					//TODO 没有自动外勤
+				}
+				return false;
+			} else {
+				form.put("cl_distance", distance);
+				return true;
+			}
+		} catch (NullPointerException e) {
+			return false;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	//获取打卡记录
+	private void loadLog(Bundle bunder) throws Exception {
+		String date = TimeUtils.s_long_2_str(System.currentTimeMillis());
+		//获取网络数据
+		Map<String, Object> param = new HashMap<>();
+		String code = getSharedPreferences(MyApplication.getInstance(), "erp_username");
+		param.put("currentMaster", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
+		if (isB2b) {
+			param.put("pageNumber", 1);
+			param.put("date", DateFormatUtil.long2Str(System.currentTimeMillis(), "yyyyMMdd"));
+		} else {
+			param.put("page", 1);
+			param.put("condition", "cl_emcode='" + code + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
+		}
+		param.put("pageSize", 100);
+		param.put("caller", "CardLog");
+		param.put("emcode", code);
+		param.put("master", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
+
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_record_url :
+				"mobile/oa/workdata.action";
+		Request request = new Request.Bulider()
+				.setBundle(bunder)
+				.setMode(Request.Mode.GET)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(LOAD_WORKLOG)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	//获取是否有外勤计划
+	public void loadIsMission(MissionModel model) {
+		Map<String, Object> param = new HashMap<>();
+		param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
+		Bundle bunder = new Bundle();
+		bunder.putParcelable("data", model);
+		String url = "mobile/yesornoplan.action";
+		Request request = new Request.Bulider()
+				.setParam(param)
+				.setBundle(bunder)
+				.setUrl(url)
+				.setWhat(HAVE_OUT_PLAN)
+				.setMode(Request.Mode.GET)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+
+	/*****************
+	 * 下拉列表
+	 ***********************/
+	/**
+	 * 下拉内勤数据
+	 */
+	public void loadWorkData() {
+		Map<String, Object> param = new HashMap<>();
+		param.put("date", DateFormatUtil.long2Str("yyyyMMdd"));
+		param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
+		Bundle bundle = new Bundle();
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_schedule_url :
+				"mobile/getWorkDate.action";
+		Request request = new Request.Bulider()
+				.setBundle(bundle)
+				.setMode(Request.Mode.GET)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(WORK_DATA)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+
+	}
+
+
+	private void loadLog(ArrayList<WorkModel> models) {
+		String date = TimeUtils.s_long_2_str(System.currentTimeMillis());
+		//获取网络数据
+		Map<String, Object> param = new HashMap<>();
+		String code = getSharedPreferences(MyApplication.getInstance(), "erp_username");
+		param.put("currentMaster", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
+		if (isB2b) {
+			param.put("date", DateFormatUtil.long2Str(System.currentTimeMillis(), "yyyyMMdd"));
+			param.put("pageNumber", 1);
+		} else {
+			param.put("condition", "cl_emcode='" + code + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
+			param.put("page", 1);
+		}
+		param.put("pageSize", 100);
+		param.put("caller", "CardLog");
+		param.put("emcode", code);
+		param.put("master", getSharedPreferences(MyApplication.getInstance(), "erp_master"));
+		Bundle bundle = new Bundle();
+		bundle.putParcelableArrayList("models", models);
+
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().punch_record_url :
+				"mobile/oa/workdata.action";
+		Request request = new Request.Bulider()
+				.setBundle(bundle)
+				.setMode(Request.Mode.GET)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(WORK_LOG)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	public void loadWorkSet() {
+		//获取考勤高级设置时间请求
+		Map<String, Object> param = new HashMap<>();
+		if (!isB2b)
+			param.put("code", 1);
+
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().get_plat_senior_setting_url :
+				"mobile/getconfigs.action";
+		Request request = new Request.Bulider()
+				.setMode(Request.Mode.GET)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(LOAD_WORK_SET)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	//获取外勤计划列表
+	public void loadMissionPlan() {
+		Map<String, Object> param = new HashMap<>();
+		param.put("emcode", getSharedPreferences(MyApplication.getInstance(), "erp_username"));
+		String url = isB2b ? ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getOutPlan :
+				"mobile/mobileoutplan.action";
+		Request request = new Request.Bulider()
+				.setMode(Request.Mode.GET)
+				.setParam(param)
+				.setUrl(url)
+				.setWhat(LOAD_PLAN)
+				.bulid();
+		OAHttpHelper.getInstance().requestHttp(request, this);
+	}
+
+	@Override
+	public void result(int what, boolean isJSON, String message, final Bundle bundle) {
+		try {
+			switch (what) {
+				case MAC_VAL://判断mac地址
+					if (isJSON && JSON.parseObject(message).containsKey("success") &&
+							JSON.parseObject(message).getBoolean("success")) {
+						CommonInterface.getInstance().getCodeByNet("CardLog", new CommonInterface.OnResultListener() {
+							@Override
+							public void result(boolean isOk, int result, String message) {
+								signinWork(bundle, message);
+							}
+						});
+					} else {
+						CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), message);
+					}
+					break;
+				case SIGNING:
+					String subtitle = MyApplication.getInstance().getBdLocationHelper().getName();
+					if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true)) {
+						boolean saveOk = MessageDao.getInstance().instartSignin(getString(R.string.auto_work_signin_alert),
+								StringUtil.isEmpty(subtitle) ? getString(R.string.uu_auto_work_signined_up) : subtitle);
+						if (saveOk) {
+							Intent intent = new Intent(OAConfig.AUTO_SIGIN_ALART);
+							LocalBroadcastManager.getInstance(MyApplication.getInstance()).sendBroadcast(intent);
+						}
+					}
+					loadLog(bundle);
+					break;
+				case LOAD_WORKLOG://签到后保存到打卡数据库里面
+					if (isJSON && JSON.parseObject(message).containsKey("listdata")) {
+						saveSignin2DB(bundle, JSON.parseObject(message).getJSONArray("listdata"));
+					}
+					break;
+				case SIGNIN_MISSION:
+					if (isJSON) {
+						if (JSON.parseObject(message).containsKey("success") && JSON.parseObject(message).getBoolean("success")) {
+							//成功  更新数据库
+							if (bundle == null) return;
+							MissionModel mission = bundle.getParcelable("data");
+							if (mission == null) return;
+							updataMissonDB(mission);
+						}
+					}
+					break;
+				case HAVE_OUT_PLAN:
+					if (!isJSON) return;
+					JSONObject object = JSON.parseObject(message);
+					if (!object.containsKey("success") || !object.getBoolean("success")) return;
+					if (object.containsKey("isOffline")) {
+						int isOffline = Integer.valueOf(object.getString("isOffline"));
+						//当判断到外勤计划为有值  1.外勤计划有  2.自动外勤
+						if (bundle != null && bundle.getParcelable("data") != null) {
+							MissionModel model = bundle.getParcelable("data");
+							if (model == null) {
+								LogUtil.i("model==null");
+								return;
+							}
+							boolean saveOk = MissionDao.getInstance().updata(model);
+							if (isOffline > 0) {//还有外勤计划
+								if (saveOk)
+									notificationManage.sendNotification(MyApplication.getInstance(),
+											model.getCompanyName() + MyApplication.getInstance().getString(R.string.success_signin_down_mission), MissionActivity.class);
+							} else {//没有外勤计划
+								endMission(model, saveOk);
+								List<MissionModel> models = MissionDao.getInstance().queryByEnCode();
+								if (ListUtils.isEmpty(models) || !isMoreMission(models))
+									endOfMission();
+
+							}
+						}
+					}
+				case WORK_DATA://打卡班次
+					handlerWorkData(isJSON, message);
+					break;
+				case WORK_LOG://
+					ArrayList<WorkModel> models = null;
+					if (bundle != null) models = bundle.getParcelableArrayList("models");
+					handlerWorkLog(isJSON, message, models);
+					break;
+				case LOAD_PLAN:
+					JSONArray array = null;
+					if (isJSON && JSON.parseObject(message).get("data") instanceof JSONArray) {
+						array = JSON.parseObject(message).getJSONArray("data");
+					} else if (JSON.parseObject(message).get("success") instanceof JSONArray) {
+						array = JSON.parseObject(message).getJSONArray("success");
+					}
+					handlerData(array);
+					break;
+				case LOAD_WORK_SET:
+					if (isJSON) {
+						handlerWorkSet(JSON.parseObject(message));
+					}
+					break;
+				default:
+					break;
+			}
+		} catch (Exception e) {
+			if (e != null) {
+				LogUtil.i("result=" + e.getMessage());
+				CommonUtil.saveAutoLogtoLocal(getString(R.string.app_monitor_log), e.getMessage());
+			}
+		}
+	}
+
+	boolean isErrorMac;
+
+	@Override
+	public void error(int what, String message, Bundle bundle) {
+		if (!StringUtil.isEmpty(message)) {
+			String msg = null;
+			if (StringUtil.isInclude(message, MyApplication.getInstance().getString(R.string.is_not_common_device))) {
+				msg = MyApplication.getInstance().getString(R.string.is_not_common_device_not_signin);
+				CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
+			} else if (StringUtil.isInclude(message, "设备正处于申请变更绑定阶段")) {
+				msg = MyApplication.getInstance().getString(R.string.is_changeing_not_signin);
+				CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
+			} else if (StringUtil.isInclude(message, "该设备已被他人绑定")) {
+				msg = MyApplication.getInstance().getString(R.string.is_binded_other_not_signin);
+				CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_sign_failed), msg);
+			} else if (what == SIGNIN_MISSION) {
+				try {
+					Intent intent = new Intent();
+					intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
+					intent.setAction(AppConstant.CHANGE_MISSION_TASK);
+					MsgBroadcast.sendLocalBroadcast(intent);
+					if (!StringUtil.isEmpty(message))
+						CommonUtil.saveAutoLogtoLocal(getString(R.string.auto_outplan_failed), message);
+				} catch (Exception e) {
+				}
+			}
+			if (!StringUtil.isEmpty(msg))
+				CommonUtil.saveAutoLogtoLocal(getString(R.string.app_monitor_log), msg);
+			if (!isErrorMac && !StringUtil.isEmpty(msg)) {
+				isErrorMac = true;
+				notificationManage.sendNotification(MyApplication.getInstance(), msg, WorkActivity.class);
+			}
+		}
+	}
+
+	/**
+	 * 外勤签到签退处理
+	 * 1.签退:status==1&&离开范围之内==》mission.setStatus(2) ,先把状态设置位2在传进来签退
+	 * 2.签到:在范围之内,status不做任何改变 传进来签到
+	 *
+	 * @param mission 传进来的对象
+	 * @throws Exception
+	 */
+
+	private void updataMissonDB(MissionModel mission) throws Exception {
+		//更新数据库
+		if (mission == null) return;//如果数据库没有,一般不会出现这样的情况
+		if (StringUtil.isEmpty(mission.getRealTime()))
+			mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
+		else mission.setRealLeave(TimeUtils.f_long_2_str(System.currentTimeMillis()));
+		String title = "";
+		String subTitle = "";
+		if (mission.getStatus() == 2) {//签退
+			title = MyApplication.getInstance().getString(R.string.auto_mission_alert);
+			if (StringUtil.isEmpty(mission.getCompanyName()))
+				subTitle = MyApplication.getInstance().getString(R.string.uu_auto_signined_down);
+			else
+				subTitle = MyApplication.getInstance().getString(R.string.visit) + mission.getCompanyName() + getString(R.string.success_signin_down);
+
+			CommonInterface.getInstance().endMission(mission.getId(), false);
+			loadIsMission(mission);
+		} else {//签到
+			if (mission.getStatus() < 1) {
+				title = getString(R.string.auto_mission_alert);
+				if (StringUtil.isEmpty(mission.getCompanyName()))
+					subTitle = getString(R.string.uu_auto_signined_up);
+				else
+					subTitle = getString(R.string.visit) + mission.getCompanyName() + getString(R.string.success_signin_up);
+				mission.setStatus(1);//说明没有打过卡
+				boolean saveOk = MissionDao.getInstance().updata(mission);
+				if (saveOk)//XXX公司自动外勤签到成功
+					notificationManage.sendNotification(MyApplication.getInstance(), mission.getCompanyName()
+									+ getString(R.string.success_signin_up_mission),
+							MissionActivity.class);
+			}
+		}
+		MissionDao.getInstance().updata(mission);
+		if (!StringUtil.isEmpty(title) && !StringUtil.isEmpty(subTitle))
+			MessageDao.getInstance().instartSignin(title, subTitle);
+	}
+
+	/**
+	 * 外勤签退后判断时候还有外勤计划,如果没有,判断是否符合返回公司  返回提示请返回公司签到
+	 *
+	 * @param model
+	 * @param saveOk
+	 * @throws Exception
+	 */
+	private void endMission(final MissionModel model, final boolean saveOk) throws Exception {
+		float longitude = PreferenceUtils.getFloat("longitude");
+		float latitude = PreferenceUtils.getFloat("latitude");
+		BaiduMapUtil.getInstence().getDrivingRoute(MyApplication.getInstance().
+				getBdLocationHelper().getLocation(), new LatLng(latitude, longitude), new OnGetDrivingRouteResult() {
+			@Override
+			public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
+				List<DrivingRouteLine> list = drivingRouteResult.getRouteLines();
+				if (ListUtils.isEmpty(list)) {//获取路线列表为空
+					if (saveOk)
+						notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
+								MissionActivity.class);
+					return;
+				}
+				int minTime = 0;
+				for (DrivingRouteLine e : list) {
+					if (minTime == 0 || minTime > e.getDuration()) {
+						minTime = e.getDuration();
+					}
+				}
+				LogUtil.i("最短时间为" + minTime);
+				//获取使用时间为。。。。
+				//当前时间
+				List<WorkModel> models = WorkModelDao.getInstance().query(true);
+				if (ListUtils.isEmpty(models)) {
+					LogUtil.i("数据库中的班次为空的");
+					if (saveOk)
+						notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
+								MissionActivity.class);
+					return;
+				}
+				String lastTime = null;
+				for (WorkModel e : models) {
+					if (StringUtil.isEmpty(e.getOffTime())) continue;
+					if (StringUtil.isEmpty(lastTime) || e.getOffTime().compareTo(lastTime) > 0)
+						lastTime = e.getOffTime();
+				}
+				if (StringUtil.isEmpty(lastTime)) {
+					if (saveOk)
+						notificationManage.sendNotification(MyApplication.getInstance(), getString(R.string.to) + model.getCompanyName() + getString(R.string.success_signin_down_mission),
+								MissionActivity.class);
+					return;
+				}
+				int time = getTime(lastTime);
+				LogUtil.i("与下班时间相差" + time);
+				int deTime = PreferenceUtils.getInt(AppConfig.AUTO_MISSION_TIME, 10);
+				if ((minTime + deTime * 60) < time) {
+					notificationManage.sendNotification(MyApplication.getInstance(),
+							R.string.success_signin_down_can_back, WorkActivity.class);
+				} else {
+					Log.i("gongpengming", "时间不符合");
+					if (saveOk)
+						notificationManage.sendNotification(MyApplication.getInstance(),
+								R.string.success_signin_down_task_ok, MissionActivity.class);
+				}
+			}
+		});
+	}
+
+	//保存到数据库
+	private void saveSignin2DB(Bundle bundle, JSONArray array) throws Exception {
+		WorkModel model = null;
+		LogUtil.i("saveSignin2DB");
+		if (bundle != null && bundle.getParcelable("data") != null) {
+			model = bundle.getParcelable("data");
+		}
+		if (model == null) {
+			LogUtil.i("model == null");
+			List<WorkModel> models = WorkModelDao.getInstance().query(false);
+			if (ListUtils.isEmpty(models)) return;
+			String time = DateFormatUtil.long2Str(System.currentTimeMillis(), "HH:mm");
+			for (WorkModel m : models) {
+				//当前时间位于该班次之间
+				if (m.getWorkStart().compareTo(time) < 0 && m.getOffend().compareTo(time) > 0) {
+					model = m;
+					break;
+				}
+			}
+		}
+		//取最后一个
+		JSONObject object = array.getJSONObject(array.size() - 1);
+		String time = object.getString("cl_time");//获取最后一次打卡信息,班次打卡信息
+		time = DateFormatUtil.long2Str(DateFormatUtil.str2Long(time,DateFormatUtil.YMD_HMS), DateFormatUtil.HM);//获取到的
+		LogUtil.i("获取最后一次打卡信息,班次打卡信息=" + time);
+		if (StringUtil.isEmpty(time) || model == null) return;
+		LogUtil.i("model="+JSON.toJSONString(model));
+		LogUtil.i("AUTO_SIGN_SW="+PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true));
+		if (StringUtil.isEmpty(model.getWorkSignin()) && model.getWorkStart().compareTo(time) <= 0
+				&& model.getWorkTime().compareTo(time) >= 0) {
+			LogUtil.i("11111111111111111111" );
+			model.setWorkSignin(time);
+			long i = WorkModelDao.getInstance().update(model);
+			if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true)) {
+				notificationManage.sendNotification(MyApplication.getInstance(),
+						R.string.auto_signin, WorkActivity.class);
+				LogUtil.i("发送上班打卡通知");
+			}
+			boolean b = hasMore();
+			Intent intent = new Intent();
+			intent.setAction(CHANGE_WORK_TASK);
+			intent.putExtra(CHANGE_WORK_TASK, b);
+			MsgBroadcast.sendLocalBroadcast(intent);
+		} else if (StringUtil.isEmpty(model.getOffSignin()) && model.getOffTime().compareTo(time) <= 0
+				&& model.getOffend().compareTo(time) >= 0) {
+			LogUtil.i("22222222222222222222222222222222" );
+			model.setOffSignin(time);
+			WorkModelDao.getInstance().update(model);
+			if (PreferenceUtils.getBoolean(PreferenceUtils.AUTO_SIGN_SW, true)) {
+				notificationManage.sendNotification(MyApplication.getInstance(),
+						R.string.auto_signin, WorkActivity.class);
+			}
+			LogUtil.i("发送下班打卡通知");
+			boolean b = hasMore();
+			Intent intent = new Intent();
+			intent.setAction(CHANGE_WORK_TASK);
+			intent.putExtra(CHANGE_WORK_TASK, b);
+			MsgBroadcast.sendLocalBroadcast(intent);
+		}
+	}
+
+	private boolean hasMore() {
+		List<WorkModel> models = WorkModelDao.getInstance().query(false);
+		if (ListUtils.isEmpty(models)) return false;
+		else {
+			for (WorkModel m : models) {
+				if (StringUtil.isEmpty(m.getWorkSignin()) || StringUtil.isEmpty(m.getOffSignin()))
+					return true;
+			}
+		}
+		return false;
+	}
+
+
+	/**
+	 * 处理打卡签到
+	 *
+	 * @param isJSON
+	 * @param message
+	 */
+	private void handlerWorkData(boolean isJSON, String message) throws Exception {
+		if (!isJSON)
+			return;
+		JSONObject object = JSON.parseObject(message);
+		ArrayList<WorkModel> models = WorkHandlerUtil.handlerWorkData(object, isB2b);
+		OAConfig.name = JSONUtil.getText(object, "wd_name");
+		OAConfig.days = JSONUtil.getText(object, "wd_day");
+		WorkHandlerUtil.handerLocation(object, isB2b);
+		if (ListUtils.isEmpty(models)) {
+			return;
+		}
+		loadLog(models);
+	}
+
+
+	/**
+	 * 处理打卡签到列表,建议在线程钟使用
+	 *
+	 * @param isJSON     是否是json数据
+	 * @param message    返回信息
+	 * @param workModels 获取班次信息时候的数据
+	 * @throws Exception
+	 */
+	private void handlerWorkLog(boolean isJSON, String message, ArrayList<WorkModel> workModels) throws Exception {
+		if (!isJSON || ListUtils.isEmpty(workModels)) {
+			saveDb(workModels);
+			return;
+		}
+		JSONObject object = JSON.parseObject(message);
+		ArrayList<WorkModel> models = WorkHandlerUtil.handlerWorkLog(object, workModels);
+		saveDb(models);
+	}
+
+
+	private void saveDb(final List<WorkModel> models) {
+		if (!ListUtils.isEmpty(models)) {
+			ThreadUtil.getInstance().addTask(new Runnable() {
+				@Override
+				public void run() {
+					boolean saveOK = WorkModelDao.getInstance().createOrUpdata(models, System.currentTimeMillis());
+					if (saveOK) {
+						OAHttpHelper.getInstance().post(new Runnable() {
+							@Override
+							public void run() {
+								Intent intent = new Intent();
+								intent.setAction(CHANGE_WORK_TASK);//保存到数据库成功,开启
+								intent.putExtra(CHANGE_WORK_TASK, true);
+								MsgBroadcast.sendLocalBroadcast(intent);
+							}
+						});
+					}
+				}
+			});
+		}
+	}
+
+	/**
+	 * 第一次进来应用会请求一次数据,并把数据保存到数据库中,保存成功后发送广播,更新轮询
+	 * 解析处理外勤计划列表并保存到数据库
+	 *
+	 * @param array
+	 */
+	private void handlerData(JSONArray array) throws Exception {
+		if (ListUtils.isEmpty(array)) {
+			ThreadUtil.getInstance().addTask(new Runnable() {
+				@Override
+				public void run() {
+					List<MissionModel> models = MissionDao.getInstance().queryByEnCode();
+					if (!ListUtils.isEmpty(models)) {
+						OAHttpHelper.getInstance().post(new Runnable() {
+							@Override
+							public void run() {
+								Intent intent = new Intent();
+								intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
+								intent.setAction(AppConstant.CHANGE_MISSION_TASK);
+								MsgBroadcast.sendLocalBroadcast(intent);
+							}
+						});
+
+					}
+				}
+			});
+		} else {
+			JSONObject object = null;
+			MissionModel entity = null;
+			final List<MissionModel> entities = new ArrayList<>();
+			for (int i = 0; i < array.size(); i++) {
+				object = array.getJSONObject(i);
+				entity = WorkHandlerUtil.handlerEntity(isB2b, object);
+				if (entity == null)
+					continue;
+				entities.add(entity);
+			}
+			if (!ListUtils.isEmpty(entities)) {
+				LogUtil.i("保存到数据库成功");
+				ThreadUtil.getInstance().addTask(new Runnable() {
+					@Override
+					public void run() {
+						boolean saveOk = false;
+						try {
+							saveOk = MissionDao.getInstance().updataOrCreate(entities);
+							if (!saveOk)
+								saveOk = !ListUtils.isEmpty(MissionDao.getInstance().queryByEnCode());
+						} catch (Exception e) {
+
+						}
+						if (saveOk) {
+							CommonUtil.saveAutoLogtoLocal(getString(R.string.app_start_log), getString(R.string.app_outplan_running));
+							//TODO 保存异常数据库
+							OAHttpHelper.getInstance().post(new Runnable() {
+								@Override
+								public void run() {
+									Intent intent = new Intent();
+									intent.putExtra(AppConstant.CHANGE_MISSION_TASK, true);
+									intent.setAction(AppConstant.CHANGE_MISSION_TASK);
+									MsgBroadcast.sendLocalBroadcast(intent);
+									LogUtil.i("发送广播成功");
+								}
+							});
+						}
+					}
+				});
+			}
+		}
+	}
+
+
+	private void handlerWorkSet(JSONObject o) {
+		try {
+			WorkHandlerUtil.handlerWorkSet(o);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		if (OAConfig.autosign)
+			loadWorkData();
+		else
+			try {
+				//如果不是自动打卡和提醒,清空数据库今天的数据
+				WorkModelDao.getInstance().clearByDate(System.currentTimeMillis());
+			} catch (Exception e) {
+				if (e != null)
+					LogUtil.i("initNet Exception=" + e.getMessage());
+			}
+	}
+
+	private boolean isMoreMission(List<MissionModel> models) {
+		for (MissionModel e : models) {
+			if (e.getType() != 1) {
+				LogUtil.i("返回正确");
+				return true;
+			}
+		}
+		return false;
+	}
+
+	private void endOfMission() {
+		Intent intent = new Intent();
+		intent.setAction(AppConstant.CHANGE_MISSION_TASK);
+		intent.putExtra(AppConstant.CHANGE_MISSION_TASK, false);
+		MsgBroadcast.sendLocalBroadcast(intent);
+	}
+
+	//获取当前时间鱼下班时间的差
+	private int getTime(String lastTime) {
+		long time = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis())
+				+ " " + lastTime + ":00");
+		long time2 = time - System.currentTimeMillis();
+		if (time < 0) return 0;
+		return (int) (time2 / 1000);
+	}
+
+	private String getString(int id) {
+		return MyApplication.getInstance().getString(id);
+	}
 
 }