|
|
@@ -108,31 +108,45 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|
|
form.put("cl_phone", MyApplication.getInstance().mLoginUser.getTelephone());
|
|
|
form.put("cl_emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
form.put("cl_emname", MyApplication.getInstance().mLoginUser.getNickName());
|
|
|
+ boolean isp = isPlay(ct, form);
|
|
|
+ if (!isp) return;//不符合打卡
|
|
|
+ String formStore = StringUtils.mapToJson(form);
|
|
|
+ param.put("caller", "CardLog");
|
|
|
+ param.put("formStore", formStore);
|
|
|
+ String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/saveCardLog.action";
|
|
|
+ param.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, 0x11, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isPlay(Context ct, Map<String, Object> form) {
|
|
|
try {
|
|
|
+ //判断是否符合打卡
|
|
|
BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
|
|
|
form.put("cl_address", helper.getAddress());
|
|
|
form.put("cl_location", helper.getName());
|
|
|
double companyX = CommonUtil.getSharedPreferencesfloat(ct, "companyX", 0);
|
|
|
double companyY = CommonUtil.getSharedPreferencesfloat(ct, "companyY", 0);
|
|
|
+ int comDistance = CommonUtil.getSharedPreferencesInt(ct, "distance", 0);
|
|
|
double latitude = helper.getLatitude();
|
|
|
double longitude = helper.getLongitude();
|
|
|
String distance = BaiduMapUtil.getInstence().getDistance(companyX, companyY, latitude, longitude);
|
|
|
- form.put("cl_distance", distance);
|
|
|
+ if (comDistance < Float.valueOf(distance)) {//规定地址<实际地址 不符合
|
|
|
+ helper.requestLocation();//当不符合时候提交定位,并不执行打卡签到
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ form.put("cl_distance", distance);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
} catch (NullPointerException e) {
|
|
|
-
|
|
|
+ return false;
|
|
|
} catch (SQLException e) {
|
|
|
-
|
|
|
+ return false;
|
|
|
}
|
|
|
- String formStore = StringUtils.mapToJson(form);
|
|
|
- param.put("caller", "CardLog");
|
|
|
- param.put("formStore", formStore);
|
|
|
- String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/saveCardLog.action";
|
|
|
- param.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
- LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
- headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
- ViewUtil.httpSendRequest(ct, url, param, handler, headers, 0x11, null, null, "get");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//获取打卡记录 date:yyyy-MM-dd
|
|
|
private void loadLog() {
|
|
|
String date = TimeUtils.s_long_2_str(System.currentTimeMillis());
|