Quellcode durchsuchen

修改自动外勤和自动打卡

RaoMeng vor 9 Jahren
Ursprung
Commit
ae025b8bf2

+ 3 - 1
WeiChat/src/main/AndroidManifest.xml

@@ -772,7 +772,9 @@
         <activity
             android:name=".ui.message.Subscription2Activity"
             android:label="订阅号" />
-        <activity android:name=".ui.erp.activity.oa.LocationSearchActivity" />
+        <activity android:name=".ui.erp.activity.oa.LocationSearchActivity"
+            android:windowSoftInputMode="stateUnspecified|adjustNothing"
+            />
         <activity
             android:name=".ui.erp.activity.oa.MissionPlanActivity"
             android:label="@string/activity_mission_plan" />

+ 15 - 7
WeiChat/src/main/java/com/xzjmyk/pm/activity/BdLocationHelper.java

@@ -9,6 +9,7 @@ import com.baidu.location.LocationClient;
 import com.baidu.location.LocationClientOption;
 import com.baidu.location.Poi;
 import com.xzjmyk.pm.activity.sp.LocationSp;
+import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
 
 import java.util.List;
 
@@ -33,12 +34,19 @@ public class BdLocationHelper {
     BdLocationHelper(Context context) {
         mContext = context;
         // 获取上一次的定位数据
-        mLongitude = LocationSp.getInstance(context).getLongitude(0);
-        mLatitude = LocationSp.getInstance(context).getLatitude(0);
-        mAddress = LocationSp.getInstance(context).getAddress("");
-        mProvinceName = LocationSp.getInstance(context).getProvinceName("");
-        mCityName = LocationSp.getInstance(context).getCityName("");
-        mDistrictName = LocationSp.getInstance(context).getDistrictName("");
+//        mLongitude = LocationSp.getInstance(context).getLongitude(0);
+//        mLatitude = LocationSp.getInstance(context).getLatitude(0);
+//        mAddress = LocationSp.getInstance(context).getAddress("");
+//        mProvinceName = LocationSp.getInstance(context).getProvinceName("");
+//        mCityName = LocationSp.getInstance(context).getCityName("");
+//        mDistrictName = LocationSp.getInstance(context).getDistrictName("");
+        //关闭缓存
+        mLongitude = 0;
+        mLatitude = 0;
+        mAddress = "";
+        mProvinceName = "";
+        mCityName = "";
+        mDistrictName = "";
 
         mLocationClient = new LocationClient(context.getApplicationContext()); // 声明LocationClient类
         mLocationClient.registerLocationListener(mMyLocationListener); // 注册监听函数
@@ -150,7 +158,7 @@ public class BdLocationHelper {
 
 
     public String getName() {
-        return pois == null ? (name == null ? "当前位置" : name) : (pois.get(0) == null ? (name == null ? "当前位置" : name) : pois.get(0).getName());
+        return pois == null ? (StringUtils.isEmail(name)? "当前位置" : name) : (pois.get(0) == null ? (name == null ? "当前位置" : name) : pois.get(0).getName());
     }
 
     public void setName(String name) {

+ 1 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/db/dao/MissionDao.java

@@ -118,7 +118,7 @@ public class MissionDao {
     }
 
     public boolean updataOrCreate(MissionModel mission) {
-        if (mission == null || StringUtils.isEmpty(mission.getVisitTime()))return false;
+        if (mission == null || StringUtils.isEmpty(mission.getVisitTime())) return false;
         show("updataOrCreate");
         SQLiteDatabase db = null;
         long i = 0;

+ 70 - 73
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/crm/BusinessDetailInfoActivity.java

@@ -49,7 +49,6 @@ import java.util.List;
 import java.util.Map;
 
 
-
 /**
  * @功能:商机详情
  * @author:Arisono
@@ -58,8 +57,8 @@ import java.util.Map;
  */
 public class BusinessDetailInfoActivity extends BaseActivity implements View.OnClickListener {
 
-    private static final int LOAD_JIEDUAN =0x21 ;
-    private static final int LOAD_STAGEPOINT =0x22 ;
+    private static final int LOAD_JIEDUAN = 0x21;
+    private static final int LOAD_STAGEPOINT = 0x22;
     @ViewInject(R.id.bt_fenpei)
     private Button bt_fenpei;
     @ViewInject(R.id.bt_qiang)
@@ -115,21 +114,22 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
 
     @ViewInject(R.id.stepsView)
     private StepsView mStepsView;
-    
-    @ViewInject(R.id. lv_business)
+
+    @ViewInject(R.id.lv_business)
     private StickyListHeadersListView mList;
-    
+
     private StickyListAdapter mAapter;
-    
+
     private int type = 0;
     private String formCondition;
     private String gridCondition;
     private String en_code;
 
-    private  String[] labels;
+    private String[] labels;
 
     private final static int BUSINESS_FAILURE_REQUEST = 99;
     private final static int BUSINESS_FOLLOW_REQUEST = 100;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -183,22 +183,22 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
         }
 
 
-            List<SimpleData> hasHeaderIdList = new ArrayList<SimpleData>();
-            int groupId = 1;
-            for (int i = 0; i < 25; i++) {
-                SimpleData item = new SimpleData();
-                item.setLeft("左边"+i);
-                item.setRight("右边"+i);
-                item.setGroupId(groupId);
-                item.setGroup("组名" + groupId);
-                if (i % 5 == 0) {
-                    groupId++;
-                }
-                hasHeaderIdList.add(item);
+        List<SimpleData> hasHeaderIdList = new ArrayList<SimpleData>();
+        int groupId = 1;
+        for (int i = 0; i < 25; i++) {
+            SimpleData item = new SimpleData();
+            item.setLeft("左边" + i);
+            item.setRight("右边" + i);
+            item.setGroupId(groupId);
+            item.setGroup("组名" + groupId);
+            if (i % 5 == 0) {
+                groupId++;
             }
-        mAapter=new StickyListAdapter(mContext,hasHeaderIdList);
+            hasHeaderIdList.add(item);
+        }
+        mAapter = new StickyListAdapter(mContext, hasHeaderIdList);
         mList.setAdapter(mAapter);
-        
+
     }
 
     private void initListener() {
@@ -221,7 +221,7 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                 showPopupWindow(v.findViewById(R.id.bt_manage_go));
                 break;
             case R.id.bt_manage_date:
-                isEnableClick(bt_code,5);
+                isEnableClick(bt_code, 5);
                 break;
             case R.id.bt_qiang:
                 progressDialog.show();
@@ -289,14 +289,14 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                                     .putExtra("type", 1)
                                     .putExtra("code", bt_code)
                                     .putExtra("process", bt_process)
-                                    .putExtra("doman", bt_doman),BUSINESS_FAILURE_REQUEST);
+                                    .putExtra("doman", bt_doman), BUSINESS_FAILURE_REQUEST);
                             break;
                         case 3:
                             startActivityForResult(new Intent(BusinessDetailInfoActivity.this, BusinessLessActivity.class)
                                     .putExtra("type", 2)
                                     .putExtra("code", bt_code)
                                     .putExtra("process", bt_process)
-                                    .putExtra("doman", bt_doman),BUSINESS_FOLLOW_REQUEST);
+                                    .putExtra("doman", bt_doman), BUSINESS_FOLLOW_REQUEST);
                             break;
                       /*  case 4:
                             startActivity(new Intent(BusinessDetailInfoActivity.this, BusinessTransferActivity.class)
@@ -304,11 +304,11 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                             break;*/
                         case 4:
                             startActivity(new Intent(BusinessDetailInfoActivity.this, CustomerAddActivity.class)
-                                    .putExtra("companyname",bc_custname.getText().toString().trim())
-                                    .putExtra("companyaddress",bc_address.getText().toString().trim())
-                                    .putExtra("contact",bc_contact.getText().toString().trim())
-                                    .putExtra("position",bc_position.getText().toString().trim())
-                                    .putExtra("telephone",bt_tel.getText().toString().trim())
+                                    .putExtra("companyname", bc_custname.getText().toString().trim())
+                                    .putExtra("companyaddress", bc_address.getText().toString().trim())
+                                    .putExtra("contact", bc_contact.getText().toString().trim())
+                                    .putExtra("position", bc_position.getText().toString().trim())
+                                    .putExtra("telephone", bt_tel.getText().toString().trim())
                             );
                             break;
                         case 5:
@@ -399,9 +399,8 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                         bt_doman = root.getString("bc_doman");
                         bt_code = root.getString("bc_code");
                         bt_process = root.getString("bc_currentprocess");
-                    
-                        
-                        
+
+
                     }
                     loadJieDuan();
                     loadStagePoints();
@@ -409,16 +408,16 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                 case BUSINESS_QIANG:
                     Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
                     progressDialog.dismiss();
-                    Crouton.makeText(activity,45,"成功抢得此商机,\n" +
+                    Crouton.makeText(activity, 45, "成功抢得此商机,\n" +
                                     "请到商机跟进中查看商机!\n",
                             getResources().getColor(R.color.light_green),
                             5000).show();
-                   new Handler().postDelayed(new Runnable() {
-                      @Override
-                      public void run() {
-                          finish();
-                      }
-                  },5000);
+                    new Handler().postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            finish();
+                        }
+                    }, 5000);
 //                    startActivity(new Intent(ct, BusinessDetailActivty.class).putExtra("bt_type",1));
                     break;
                 case BUSINESS_FENPEI:
@@ -427,7 +426,7 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                     crm_ll_followup.setVisibility(View.GONE);
                     crm_ll_qiang.setVisibility(View.GONE);
                     crm_ll_manage.setVisibility(View.GONE);
- //                   finish();
+                    //                   finish();
 //                    startActivity(new Intent(ct, BusinessDetailActivty.class).putExtra("bt_type",2));
                     break;
                 case BUSINESS_RELEASE:
@@ -449,15 +448,15 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                     }
                 case 5:
                     progressDialog.dismiss();
-                     result = JSON.parseObject(msg.getData().getString("result"));
-                    JSONArray items=result.getJSONArray("result");
-                    if (items!=null){
-                        if (items.size()>0){
+                    result = JSON.parseObject(msg.getData().getString("result"));
+                    JSONArray items = result.getJSONArray("result");
+                    if (items != null) {
+                        if (items.size() > 0) {
                             Crouton.makeText(BusinessDetailInfoActivity.this, "不能重复添加到日程!", 0xffff4444, 2000).show();
-                        }else{
+                        } else {
                             Intent intent = new Intent(ct, TaskAddActivity.class);
                             intent.putExtra("type", 1);
-                            intent.putExtra("from","BusinessDetailInfo");
+                            intent.putExtra("from", "BusinessDetailInfo");
                             intent.putExtra("data", bt_code);
                             startActivityForResult(intent, 0x11);
                         }
@@ -474,25 +473,25 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                     Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
                     String json = msg.getData().getString("result");
                     JSONArray array = JSON.parseObject(json).getJSONArray("stages");
-                    labels=new String[array.size()];
+                    labels = new String[array.size()];
                     if (!array.isEmpty()) {
                         for (int i = 0; i < array.size(); i++) {
-                          //  lists.add(array.getJSONObject(i).getString("BS_NAME"));
-                            labels[i]=array.getJSONObject(i).getString("BS_NAME");
+                            //  lists.add(array.getJSONObject(i).getString("BS_NAME"));
+                            labels[i] = array.getJSONObject(i).getString("BS_NAME");
                         }
                     }
 
-                    if (labels!=null){
-                        int position=0;
-                        for (int i=0;i<labels.length;i++){
-                            if (labels[i].equals(bc_currentprocess.getText().toString())){
-                                position=i;
+                    if (labels != null) {
+                        int position = 0;
+                        for (int i = 0; i < labels.length; i++) {
+                            if (labels[i].equals(bc_currentprocess.getText().toString())) {
+                                position = i;
                             }
                         }
                         LogUtil.d(JSON.toJSONString(labels));
                         LogUtil.d(JSON.toJSONString(position));
                         LogUtil.d(bc_currentprocess.getText().toString());
-                        mStepsView.setCompletedPosition(position%labels.length)
+                        mStepsView.setCompletedPosition(position % labels.length)
                                 .setLabels(labels)
                                 .setBarColorIndicator(
                                         ct.getResources().getColor(R.color.light_gray))
@@ -502,11 +501,11 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                     }
                     break;
                 case LOAD_STAGEPOINT:
-                     progressDialog.dismiss();
-                     Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
-                     json = msg.getData().getString("result");
-                     LogUtil.d(JSON.toJSONString(json));
-                     
+                    progressDialog.dismiss();
+                    Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
+                    json = msg.getData().getString("result");
+                    LogUtil.d(JSON.toJSONString(json));
+
                     break;
             }
         }
@@ -540,7 +539,7 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
         if (StringUtils.isEmpty(emname)) {
             emname = MyApplication.getInstance().mLoginUser.getNickName().trim();
         }
-        params.put("bc_doman",emname);
+        params.put("bc_doman", emname);
         params.put("bc_domancode", CommonUtil.getSharedPreferences(ct, "erp_username"));
         LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
         headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
@@ -563,7 +562,7 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
 
     }
 
-    public void isEnableClick(String bt_code,int what){
+    public void isEnableClick(String bt_code, int what) {
         String url = Constants.getAppBaseUrl(ct) + "mobile/crm/getSchedule.action";
         progressDialog.show();
         Map<String, Object> params = new HashMap<>();
@@ -577,7 +576,7 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
         headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
         ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, what, null, null, "post");
     }
-    
+
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         switch (requestCode) {
@@ -590,13 +589,13 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
                 sendHttpBusinessFenpei(BUSINESS_FENPEI, bt_code, bt_doman, en_code);
                 break;
             case BUSINESS_FAILURE_REQUEST:
-                if (data == null){
+                if (data == null) {
                     return;
                 }
                 this.finish();
                 break;
             case BUSINESS_FOLLOW_REQUEST:
-                if (data == null){
+                if (data == null) {
                     return;
                 }
                 this.finish();
@@ -622,8 +621,6 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
     }
 
 
-
-
     /**
      * @desc:加载阶段
      * @author:Arison on 2016/7/20
@@ -637,16 +634,16 @@ public class BusinessDetailInfoActivity extends BaseActivity implements View.OnC
         headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
         ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, LOAD_JIEDUAN, null, null, "post");
     }
-    
-    
-    public void loadStagePoints(){
+
+
+    public void loadStagePoints() {
         progressDialog.show();
         String url = Constants.getAppBaseUrl(ct) + "mobile/crm/getStagePoints.action";
         Map<String, Object> params = new HashMap<>();
         params.put("bccode", "2016120035");
         params.put("currentStep", "testpoints");
-        params.put("master", CommonUtil.getSharedPreferences(mContext,"erp_master"));
-      
+        params.put("master", CommonUtil.getSharedPreferences(mContext, "erp_master"));
+
         LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
         headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
         ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, LOAD_STAGEPOINT, null, null, "post");

+ 54 - 22
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/MissionActivity.java

@@ -1,8 +1,14 @@
 package com.xzjmyk.pm.activity.ui.erp.activity.oa;
 
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.RecyclerView;
+import android.util.Log;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -42,11 +48,23 @@ public class MissionActivity extends BaseActivity implements View.OnClickListene
     private int flag;
     private boolean adminStatus;
 
+    private BroadcastReceiver receiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent != null && !StringUtils.isEmpty(intent.getAction()) && "error_bdlocation".equals(intent.getAction())) {
+                Crouton.showToast(MissionActivity.this, "定位失败,请检查定位权限", R.color.load_warning);
+            }
+        }
+    };
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_mission);
         ViewUtils.inject(this);
+        IntentFilter filter = new IntentFilter();
+        filter.addAction("error_bdlocation");
+        registerReceiver(receiver, filter);
         initView();
         initEvent();
     }
@@ -83,12 +101,18 @@ public class MissionActivity extends BaseActivity implements View.OnClickListene
     private void initView() {
         if (getIntent() != null)
             flag = getIntent().getIntExtra("flag", 0);
+        String addrName = MyApplication.getInstance().getBdLocationHelper().getName();
+        if (StringUtils.isEmpty(addrName) || "当前位置".equals(addrName)) {
+            Crouton.showToast(ct, "定位失败,请检查定位权限", R.color.load_warning);
+        }
         adminStatus = getIntent() == null ? false : getIntent().getBooleanExtra(AppConfig.IS_ADMIN, false);
         adapter = new MissionAdapter(this, this);
         recycler.setLayoutManager(new MostLinearLayoutManager(ct));
         recycler.setAdapter(adapter);
         presenter = new MissionPresenter(this);
         presenter.start();
+
+
     }
 
 
@@ -188,28 +212,36 @@ public class MissionActivity extends BaseActivity implements View.OnClickListene
                 startActivityForResult(intent, 0x21);
                 break;
             case R.id.item_delete_tv://删除选项
-//                MissionModel m = adapter.getModels().remove(position);
-//                if (!StringUtils.isEmpty(m.getCompanyName()) || !StringUtils.isEmpty(m.getCompanyAddr()) ||
-//                        !StringUtils.isEmpty(m.getVisitTime())) {
-//                    AlertDialog.Builder builder = new AlertDialog.Builder(ct);
-//                    builder.setTitle(R.string.prompt_title).setMessage("是否确认删除单号" + (position + 1)).setPositiveButton("确定", new DialogInterface.OnClickListener() {
-//                        @Override
-//                        public void onClick(DialogInterface dialogInterface, int i) {
-//                            adapter.getModels().remove(position);
-//                            adapter.notifyItemRemoved(position);
-//                            adapter.notifyItemRangeChanged(position, adapter.getModels().size());
-//                        }
-//                    }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
-//                        @Override
-//                        public void onClick(DialogInterface dialogInterface, int i) {
-//
-//                        }
-//                    }).show();
-//                } else {
-                adapter.getModels().remove(position);
-                adapter.notifyItemRemoved(position);
-                adapter.notifyItemRangeChanged(position, adapter.getModels().size());
-//                }
+                try {
+                    MissionModel m = adapter.getModels().get(position);
+                    Log.i("gongpengming","position1="+position);
+                    if (!StringUtils.isEmpty(m.getCompanyName()) || !StringUtils.isEmpty(m.getCompanyAddr()) ||
+                            !StringUtils.isEmpty(m.getVisitTime())) {
+                        AlertDialog.Builder builder = new AlertDialog.Builder(ct);
+                        builder.setTitle(R.string.prompt_title).setMessage("是否确认删除单号" + (position + 1)).setPositiveButton("确定", new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialogInterface, int i) {
+                                Log.i("gongpengming","position2="+position);
+                                adapter.getModels().remove(position);
+                                adapter.notifyItemRemoved(position);
+                                adapter.notifyItemRangeChanged(position, adapter.getModels().size());
+                            }
+                        }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialogInterface, int i) {
+
+                            }
+                        }).show();
+                    } else {
+                        adapter.getModels().remove(position);
+                        adapter.notifyItemRemoved(position);
+                        adapter.notifyItemRangeChanged(position, adapter.getModels().size());
+                    }
+                } catch (Exception e) {
+                    Log.i("gongpengming", "Exception e=" + e.getMessage());
+
+                }
+
                 break;
             case R.id.item_reckontime_tv://预计到达时间
                 if (model == null || model.getStatus() == 1) return;

+ 12 - 9
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/oa/WorkActivity.java

@@ -112,6 +112,8 @@ public class WorkActivity extends BaseActivity implements View.OnClickListener,
     public void showLocation(String location) {
         if (!StringUtils.isEmpty(location))
             office_addr.setText(location);
+        else
+            Crouton.showToast(ct, "定位失败,请检查定位权限", R.color.load_warning);
     }
 
     @Override
@@ -210,15 +212,16 @@ public class WorkActivity extends BaseActivity implements View.OnClickListener,
 //                if (ListUtils.isEmpty(pois)) {
 //                    Crouton.showToast(ct, "距离太远,无法微调至有效打卡范围", R.color.load_message);
 //                } else {
-                Intent intent = new Intent(ct, LocationSearchActivity.class);
-                intent.putExtra("type", 1);
-                intent.putExtra("title", "地点微调");
-                intent.putExtra("single", true);
-                intent.putExtra("radius", 300);
-                intent.putExtra("latlng", latLng);
-                intent.putExtra("resultCode", ADDRESS_CHANGE);
-                intent.putExtra("resultName", "resultName");
-                startActivityForResult(intent, ADDRESS_CHANGE);
+                presenter.gotoLocationActivity(WorkActivity.this);
+//                Intent intent = new Intent(ct, LocationSearchActivity.class);
+//                intent.putExtra("type", 1);
+//                intent.putExtra("title", "地点微调");
+//                intent.putExtra("single", true);
+//                intent.putExtra("radius", 300);
+//                intent.putExtra("latlng", latLng);
+//                intent.putExtra("resultCode", ADDRESS_CHANGE);
+//                intent.putExtra("resultName", "resultName");
+//                startActivityForResult(intent, ADDRESS_CHANGE);
 //                }
                 break;
         }

+ 34 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/presenter/WorkPresenter.java

@@ -1,5 +1,7 @@
 package com.xzjmyk.pm.activity.ui.erp.presenter;
 
+import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 
@@ -15,6 +17,7 @@ import com.xzjmyk.pm.activity.BdLocationHelper;
 import com.xzjmyk.pm.activity.MyApplication;
 import com.xzjmyk.pm.activity.R;
 import com.xzjmyk.pm.activity.db.dao.WorkModelDao;
+import com.xzjmyk.pm.activity.ui.erp.activity.oa.LocationSearchActivity;
 import com.xzjmyk.pm.activity.ui.erp.model.WorkModel;
 import com.xzjmyk.pm.activity.ui.erp.presenter.imp.IWorkPresenter;
 import com.xzjmyk.pm.activity.ui.erp.presenter.imp.IWorkView;
@@ -158,8 +161,27 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
         }
     }
 
+    private final int ADDRESS_CHANGE = 0x14;
+
+    public void gotoLocationActivity(Activity ct) {
+//                        if (ListUtils.isEmpty(pois)) {
+//                    Crouton.showToast(ct, "距离太远,无法微调至有效打卡范围", R.color.load_message);
+//                } else {
+        Intent intent = new Intent(ct, LocationSearchActivity.class);
+        intent.putExtra("type", 1);
+        intent.putExtra("title", "地点微调");
+        intent.putExtra("single", true);
+        intent.putExtra("radius", 300);
+        intent.putExtra("latlng", new LatLng(companyLongitude, companyLatitude));
+        intent.putExtra("resultCode", ADDRESS_CHANGE);
+        intent.putExtra("resultName", "resultName");
+        ct.startActivityForResult(intent, ADDRESS_CHANGE);
+//                }
+    }
+
     private void getPoi() {
-        final LatLng compayLng = new LatLng(companyLatitude, companyLongitude);
+        //公司地址必须反过来
+        final LatLng compayLng = new LatLng(companyLongitude, companyLatitude);
         LatLng latLng = new LatLng(latitude, longitude);
         BaiduMapUtil.getInstence().getNearInfo(500, 0, latLng,
                 "公司", new BaiduMapUtil.OnSearchPoiListener() {
@@ -170,6 +192,10 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
                             if (ListUtils.isEmpty(pois)) return;
                             for (int i = 0; i < pois.size(); i++) {
                                 double dis = BaiduMapUtil.getInstence().distance(compayLng, pois.get(i).location);
+                                log("name=" + pois.get(i).name);
+                                log("address=" + pois.get(i).address);
+                                log("dis=" + dis);
+                                log("___________________________");
                                 if (companyDistance < dis) {
                                     pois.remove(i);
                                     i--;
@@ -368,6 +394,7 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
         return TimeUtils.long2str(time, "HH:mm");
     }
 
+    long subMitTime;
 
     private boolean isSubmitAble() {
         if (isSubmiting) {
@@ -378,6 +405,10 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
             if (iWorkView != null)
                 iWorkView.showToast(R.string.too_long, R.color.load_warning);
             return false;
+        } else if (subMitTime != 0 && (System.currentTimeMillis() - subMitTime) < (20 * 1000)) {
+            if (iWorkView != null)
+                iWorkView.showToast(R.string.not_signin_agin, R.color.load_warning);
+            return false;
         }
         return true;
     }
@@ -456,6 +487,7 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
      * @param macAddress mac地址
      */
     public void submitWork(ArrayList<WorkModel> models, String macAddress) {
+        subMitTime = System.currentTimeMillis();
         validatorMac(models, macAddress);
     }
 
@@ -543,6 +575,7 @@ public class WorkPresenter implements HttpHandler.OnResultListener, IWorkPresent
     @Override
     public void error(int what, int statuCode, String message, Bundle bundle) {
         try {
+            isSubmiting = false;
             if (iWorkView != null) iWorkView.dimssLoading();
 
             if (StringUtils.isInclude(message, "该设备不是考勤打卡常用设备")) {

+ 1 - 2
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/attendance/AutoErpService.java

@@ -132,7 +132,7 @@ public class AutoErpService extends Service {
                 } else if (intent.getAction().equals(CHANGE_MISSION_TASK)) {
                     log(CHANGE_MISSION_TASK);
                     canMission = intent.getBooleanExtra(CHANGE_MISSION_TASK, true);
-                }else if (intent.getAction().equals(INIT_MISSION_TASK)){
+                } else if (intent.getAction().equals(INIT_MISSION_TASK)) {
                     initMission();
                 }
             } catch (Exception e) {
@@ -255,7 +255,6 @@ public class AutoErpService extends Service {
                             isMissionRuning = false;
                             break;
                         }
-
                         log("startMissionTask run");
                         List<MissionModel> plans = MissionDao.getInstance().queryByEnCode();
                         log("自动外勤 plans==" + (ListUtils.isEmpty(plans) ? 0 : plans.size()));

+ 1 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/util/attendance/ReckonAutoUtil.java

@@ -44,7 +44,7 @@ public class ReckonAutoUtil {
             if (e.getStatus() == 2) continue;
             float distance = Float.valueOf(BaiduMapUtil.getInstence().getDistance(e.getLatLng()));
             if (distance > companyDistance && !StringUtils.isEmpty(e.getRealTime())) {
-                //1.判断进行中的外勤计划,如果离开了签到最后一次,结束该计划
+                //1.没有签退过   2.有签到记录  3.距离大于规定范围   进行签退提示
                 log("符合外勤签退");
                 minBean = e;
                 minBean.setStatus(2);//结束该外勤