|
@@ -8,6 +8,8 @@ import android.text.TextUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baidu.mapapi.model.LatLng;
|
|
|
|
|
+import com.baidu.mapapi.search.core.PoiInfo;
|
|
|
import com.common.data.DateFormatUtil;
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
import com.common.data.ListUtils;
|
|
@@ -58,6 +60,8 @@ public class SignUtils implements OnHttpResultListener {
|
|
|
|
|
|
|
|
|
|
|
|
|
private SignListener mSignListener;
|
|
private SignListener mSignListener;
|
|
|
|
|
+ public PoiInfo localPoi;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private long lastTime = 0;//最后一次打卡时间
|
|
private long lastTime = 0;//最后一次打卡时间
|
|
|
|
|
|
|
@@ -70,8 +74,14 @@ public class SignUtils implements OnHttpResultListener {
|
|
|
void sign(boolean signOk, String message);
|
|
void sign(boolean signOk, String message);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void changeLocalPoi(PoiInfo localPoi) {
|
|
|
|
|
+ if (localPoi != null && localPoi.location != null && localPoi.location.latitude > 0 && localPoi.location.longitude > 0) {
|
|
|
|
|
+ this.localPoi = localPoi;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//人脸打卡 1.先判断班次 2.判断距离
|
|
//人脸打卡 1.先判断班次 2.判断距离
|
|
|
- public int judgeFrontFace() {
|
|
|
|
|
|
|
+ public int judgeFrontFace() {
|
|
|
if (!MyApplication.getInstance().isNetworkActive()) {
|
|
if (!MyApplication.getInstance().isNetworkActive()) {
|
|
|
return R.string.networks_out;
|
|
return R.string.networks_out;
|
|
|
} else {
|
|
} else {
|
|
@@ -112,18 +122,29 @@ public class SignUtils implements OnHttpResultListener {
|
|
|
if (!MyApplication.getInstance().isNetworkActive()) {
|
|
if (!MyApplication.getInstance().isNetworkActive()) {
|
|
|
callBack(false, StringUtil.getMessage(R.string.networks_out));
|
|
callBack(false, StringUtil.getMessage(R.string.networks_out));
|
|
|
} else {
|
|
} else {
|
|
|
- //判断位置
|
|
|
|
|
|
|
+
|
|
|
MyApplication.getInstance().getBdLocationHelper().requestLocation();
|
|
MyApplication.getInstance().getBdLocationHelper().requestLocation();
|
|
|
List<WorkLocationModel> beanList = WorkLocationDao.getInstance().queryByEnCode();
|
|
List<WorkLocationModel> beanList = WorkLocationDao.getInstance().queryByEnCode();
|
|
|
if (ListUtils.isEmpty(beanList)) {
|
|
if (ListUtils.isEmpty(beanList)) {
|
|
|
callBack(false, R.string.not_addr_message);
|
|
callBack(false, R.string.not_addr_message);
|
|
|
//没有打卡地址,TODO 获取班次接口
|
|
//没有打卡地址,TODO 获取班次接口
|
|
|
} else {
|
|
} else {
|
|
|
- BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
|
|
|
|
|
|
|
+ LatLng latLng = null;
|
|
|
|
|
+ //判断位置
|
|
|
|
|
+ if (this.localPoi == null) {
|
|
|
|
|
+ BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
|
|
|
|
|
+ latLng = helper.getLatLng();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ latLng = this.localPoi.location;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (latLng == null) {
|
|
|
|
|
+ callBack(false, R.string.not_addr_message);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
float minDis = -1;
|
|
float minDis = -1;
|
|
|
for (WorkLocationModel bean : beanList) {
|
|
for (WorkLocationModel bean : beanList) {
|
|
|
String chche = BaiduMapUtil.getInstence().getDistance(bean.getLongitude(),
|
|
String chche = BaiduMapUtil.getInstence().getDistance(bean.getLongitude(),
|
|
|
- bean.getLatitude(), helper.getLatitude(), helper.getLongitude());
|
|
|
|
|
|
|
+ bean.getLatitude(), latLng.latitude, latLng.longitude);
|
|
|
Float dis = Float.valueOf(chche);
|
|
Float dis = Float.valueOf(chche);
|
|
|
if (dis < bean.getValidrange() && (minDis < 0 || dis < minDis)) {
|
|
if (dis < bean.getValidrange() && (minDis < 0 || dis < minDis)) {
|
|
|
minDis = dis;
|
|
minDis = dis;
|
|
@@ -160,6 +181,7 @@ public class SignUtils implements OnHttpResultListener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/*判断mac地址是否符合*/
|
|
/*判断mac地址是否符合*/
|
|
|
private void validatorMac(boolean isB2b, float minDis, WorkModel model) {
|
|
private void validatorMac(boolean isB2b, float minDis, WorkModel model) {
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
@@ -268,13 +290,21 @@ public class SignUtils implements OnHttpResultListener {
|
|
|
private boolean isHasLocation(Map<String, Object> form) {
|
|
private boolean isHasLocation(Map<String, Object> form) {
|
|
|
try {
|
|
try {
|
|
|
//判断是否符合打卡
|
|
//判断是否符合打卡
|
|
|
- BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
|
|
|
|
|
- String address = helper.getAddress();
|
|
|
|
|
|
|
+ String address = null;
|
|
|
|
|
+ String name = null;
|
|
|
|
|
+ if (this.localPoi == null) {
|
|
|
|
|
+ BdLocationHelper helper = MyApplication.getInstance().getBdLocationHelper();
|
|
|
|
|
+ address = helper.getAddress();
|
|
|
|
|
+ name = helper.getName();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ name = this.localPoi.name;
|
|
|
|
|
+ address = this.localPoi.address;
|
|
|
|
|
+ }
|
|
|
if (StringUtil.isEmpty(address)) {
|
|
if (StringUtil.isEmpty(address)) {
|
|
|
address = PreferenceUtils.getString("bdaddress");
|
|
address = PreferenceUtils.getString("bdaddress");
|
|
|
}
|
|
}
|
|
|
form.put("cl_address", address);
|
|
form.put("cl_address", address);
|
|
|
- form.put("cl_location", helper.getName());
|
|
|
|
|
|
|
+ form.put("cl_location", name);
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|