|
@@ -7,6 +7,9 @@ import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
import android.os.Message;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
import android.support.v7.app.AlertDialog;
|
|
|
|
|
+import android.text.Html;
|
|
|
|
|
+import android.text.Spanned;
|
|
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -125,6 +128,12 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
private JSONArray logsJson;
|
|
private JSONArray logsJson;
|
|
|
private String[] timeList;
|
|
private String[] timeList;
|
|
|
private AlertDialog.Builder builder;
|
|
private AlertDialog.Builder builder;
|
|
|
|
|
+ private int distance = 500;
|
|
|
|
|
+ private double longitude = 0;
|
|
|
|
|
+ private double latitude = 0;
|
|
|
|
|
+ private double mylongitude = 0;
|
|
|
|
|
+ private double mylatitude = 0;
|
|
|
|
|
+ private int distanceOk = -1;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected int inflateLayoutId() {
|
|
protected int inflateLayoutId() {
|
|
@@ -152,11 +161,13 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
if (requestCode == RECODE && resultCode == LocationMapActivity.REQUCODE) {
|
|
if (requestCode == RECODE && resultCode == LocationMapActivity.REQUCODE) {
|
|
|
PoiInfo poi = data.getParcelableExtra(LocationMapActivity.REQUESTNAME);
|
|
PoiInfo poi = data.getParcelableExtra(LocationMapActivity.REQUESTNAME);
|
|
|
office_addr.setText("考勤地点:" + poi.name);
|
|
office_addr.setText("考勤地点:" + poi.name);
|
|
|
- unoffice_mm.setText(getDistance(poi.location.latitude, poi.location.longitude) + " 地点微调");
|
|
|
|
|
|
|
+ unoffice_mm.setText(getDistance(poi.location.latitude, poi.location.longitude));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void init() {
|
|
private void init() {
|
|
|
|
|
+ mylongitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
|
|
|
|
|
+ mylatitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
|
|
|
timeList = new String[5];
|
|
timeList = new String[5];
|
|
|
for (int i = 0; i < timeList.length; i++)
|
|
for (int i = 0; i < timeList.length; i++)
|
|
|
timeList[i] = getTitle(System.currentTimeMillis() - (DAY_TIME * i));
|
|
timeList[i] = getTitle(System.currentTimeMillis() - (DAY_TIME * i));
|
|
@@ -164,23 +175,16 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
adapter = new SigninAdapter();
|
|
adapter = new SigninAdapter();
|
|
|
listview.setAdapter(adapter);
|
|
listview.setAdapter(adapter);
|
|
|
loadNetData(System.currentTimeMillis());//获取打卡班次信息
|
|
loadNetData(System.currentTimeMillis());//获取打卡班次信息
|
|
|
- BaiduMapUtil.getInstence().getPoiInfo(ct, new BaiduMapUtil.OnLocationListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void result(Map<String, Object> map) {
|
|
|
|
|
- if (map.containsKey("poi"))
|
|
|
|
|
- office_addr.setText("考勤地点:" + map.get("poi"));
|
|
|
|
|
- if (map.containsKey("latitude") && map.containsKey("lontitude"))
|
|
|
|
|
- unoffice_mm.setText(getDistance((double) map.get("latitude"), (double) map.get("latitude")) + " 地点微调");
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- unoffice_mm.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private String getDistance(double b1, double b2) {
|
|
|
|
|
- double a1 = 22.540551;
|
|
|
|
|
- double a2 = 113.953345;
|
|
|
|
|
- String distance = BaiduMapUtil.getInstence().getDistance(a1, a2, b1, b2);
|
|
|
|
|
- return "距离考勤地点:" + (distance == null ? "0" : distance) + "米";
|
|
|
|
|
|
|
+ private Spanned getDistance(double b1, double b2) {
|
|
|
|
|
+ String distance = BaiduMapUtil.getInstence().getDistance(longitude, latitude, b1, b2);
|
|
|
|
|
+ if (!StringUtils.isEmpty(distance)) {
|
|
|
|
|
+ distanceOk = (int) Double.parseDouble(distance);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Spanned str = Html.fromHtml("<font color=\'#858585\'>距离考勤地点: " + (distanceOk == -1 ? -1 : distanceOk) + "米 " + "</font><font color=\'#f02387\'><U>地点微调</U></font>");
|
|
|
|
|
+ return str;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void initView() {
|
|
private void initView() {
|
|
@@ -335,7 +339,7 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
SigninBean bean = new SigninBean();
|
|
SigninBean bean = new SigninBean();
|
|
|
bean.setCl_code(code);
|
|
bean.setCl_code(code);
|
|
|
bean.setCl_address(office_addr.getText().toString());
|
|
bean.setCl_address(office_addr.getText().toString());
|
|
|
- bean.setCl_distance(300);
|
|
|
|
|
|
|
+ bean.setCl_distance((int) distanceOk);
|
|
|
bean.setCl_emcode(CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
bean.setCl_emcode(CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
bean.setCl_time(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
bean.setCl_time(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
|
bean.setCl_location(getLocation());
|
|
bean.setCl_location(getLocation());
|
|
@@ -404,14 +408,19 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
break;
|
|
break;
|
|
|
case R.id.signin_btn:
|
|
case R.id.signin_btn:
|
|
|
if (isPlay && isPlayAble()) {
|
|
if (isPlay && isPlayAble()) {
|
|
|
- CodeUtil.getInstance().getCode(ct, "CardLog", new CodeUtil.OnCodeLinstener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void callBack(String code) {
|
|
|
|
|
- doSignin(code);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (distanceOk > distance) {
|
|
|
|
|
+ ToastUtil.showToast(ct, "您当前不在打卡允许位置范围,请稍后重试或联系管理员");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CodeUtil.getInstance().getCode(ct, "CardLog", new CodeUtil.OnCodeLinstener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void callBack(String code) {
|
|
|
|
|
+ doSignin(code);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
} else
|
|
} else
|
|
|
- ToastUtil.showToast(ct, "您未满足签到条件,请稍后再试");
|
|
|
|
|
|
|
+ ToastUtil.showToast(ct, "您不在打卡允许时间范围,请稍后重试或联系管理员");
|
|
|
break;
|
|
break;
|
|
|
case R.id.title:
|
|
case R.id.title:
|
|
|
showPopMenu();
|
|
showPopMenu();
|
|
@@ -424,30 +433,41 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private long long90 = 90 * 1000 * 60;
|
|
|
|
|
+
|
|
|
|
|
+ private String getNext90(String hhmm, boolean isU) {//通过给出的时分获取到对应90分钟的时分
|
|
|
|
|
+ String chche = TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + hhmm + ":00";
|
|
|
|
|
+ long chchelong = isU ? long90 : (-long90);
|
|
|
|
|
+ return TimeUtils.long2str(TimeUtils.f_str_2_long(chche) + chchelong, "HHmm");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//判断是否可以签到
|
|
//判断是否可以签到
|
|
|
private boolean isPlayAble() {
|
|
private boolean isPlayAble() {
|
|
|
//判断适配器
|
|
//判断适配器
|
|
|
if (adapter == null || adapter.getBeans() == null || adapter.getBeans().size() <= 0)
|
|
if (adapter == null || adapter.getBeans() == null || adapter.getBeans().size() <= 0)
|
|
|
return false;
|
|
return false;
|
|
|
ArrayList<Bean> beans = adapter.getBeans();
|
|
ArrayList<Bean> beans = adapter.getBeans();
|
|
|
- boolean ok = false;
|
|
|
|
|
String str = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");//获取当前的时分
|
|
String str = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");//获取当前的时分
|
|
|
for (Bean b : beans) {
|
|
for (Bean b : beans) {
|
|
|
|
|
+ if (StringUtils.isEmpty(b.time) || StringUtils.isEmpty(b.time2)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
//判断是否在上班打卡和下班打卡范围内
|
|
//判断是否在上班打卡和下班打卡范围内
|
|
|
//比较大小(在上班打卡时间和下班打卡时间之内)
|
|
//比较大小(在上班打卡时间和下班打卡时间之内)
|
|
|
if (!StringUtils.isEmpty(b.startSignin) && !StringUtils.isEmpty(b.startSignin2) && str.compareTo(b.startSignin) > 0 && str.compareTo(b.startSignin2) < 0) {
|
|
if (!StringUtils.isEmpty(b.startSignin) && !StringUtils.isEmpty(b.startSignin2) && str.compareTo(b.startSignin) > 0 && str.compareTo(b.startSignin2) < 0) {
|
|
|
//在该班次时间范围之内
|
|
//在该班次时间范围之内
|
|
|
-// ok = true;
|
|
|
|
|
-// break;
|
|
|
|
|
- if (StringUtils.isEmpty(b.time2) && str.compareTo(b.time2) > 0 && !(StringUtils.isEmpty(b.signin) || b.signin.length() <= 4)) {
|
|
|
|
|
- //当前时间大于下班时间而且上班没有打过卡已经打卡过了,不能打卡
|
|
|
|
|
- } else {
|
|
|
|
|
- ok = true;
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(b.signin)) {//上班卡还没有打
|
|
|
|
|
+ if (getNext90(b.time, true).compareTo(str) > 0) {//当前时间在上班后的90分钟之外
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {///上班打过卡了 计算是否可以下班打卡
|
|
|
|
|
+ if (getNext90(b.time2, false).compareTo(str) < 0) {//如果大于0,说明当前时间在打卡时间范围之前
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return ok;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String getTitle(long time) {
|
|
private String getTitle(long time) {
|
|
@@ -488,6 +508,12 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
ArrayList<Bean> beans = new ArrayList<>();
|
|
ArrayList<Bean> beans = new ArrayList<>();
|
|
|
Bean b = null;
|
|
Bean b = null;
|
|
|
//上午
|
|
//上午
|
|
|
|
|
+ //获取打卡地点及距离
|
|
|
|
|
+ distance = Integer.parseInt(object.containsKey("distance") ? object.getString("distance") : "0");
|
|
|
|
|
+ boolean comaddressset = object.containsKey("comaddressset") ? object.getBoolean("comaddressset") : false;
|
|
|
|
|
+ longitude = Double.parseDouble(object.containsKey("longitude") ? object.getString("longitude") : "0");
|
|
|
|
|
+ latitude = Double.parseDouble(object.containsKey("latitude") ? object.getString("latitude") : "0");
|
|
|
|
|
+ setDistance();
|
|
|
b = new Bean();
|
|
b = new Bean();
|
|
|
b.time = object.containsKey("as_amstarttime") ? object.getString("as_amstarttime") : "08:30";
|
|
b.time = object.containsKey("as_amstarttime") ? object.getString("as_amstarttime") : "08:30";
|
|
|
b.startSignin = getEndSignin(b.time, true);
|
|
b.startSignin = getEndSignin(b.time, true);
|
|
@@ -515,12 +541,22 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
return TimeUtils.long2str(minTime, "HH:mm");
|
|
return TimeUtils.long2str(minTime, "HH:mm");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void setDistance() {
|
|
|
|
|
+ office_addr.setText("考勤地点: " + MyApplication.getInstance().getBdLocationHelper().getAddress());
|
|
|
|
|
+ unoffice_mm.setText(getDistance(mylatitude, mylongitude));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//处理数据,用户有排班时候
|
|
//处理数据,用户有排班时候
|
|
|
public void setDataByDegree(JSONObject object) {
|
|
public void setDataByDegree(JSONObject object) {
|
|
|
int num = object.getInteger("wd_degree");//获取排班数
|
|
int num = object.getInteger("wd_degree");//获取排班数
|
|
|
ArrayList<Bean> beans = new ArrayList<>();
|
|
ArrayList<Bean> beans = new ArrayList<>();
|
|
|
- ArrayList<Bean> chche = new ArrayList<>();
|
|
|
|
|
Bean b = null;
|
|
Bean b = null;
|
|
|
|
|
+ //获取打卡地点及距离
|
|
|
|
|
+ distance = Integer.parseInt(object.containsKey("distance") ? object.getString("distance") : "0");
|
|
|
|
|
+ boolean comaddressset = object.containsKey("comaddressset") ? object.getBoolean("comaddressset") : false;
|
|
|
|
|
+ longitude = Double.parseDouble(object.containsKey("longitude") ? object.getString("longitude") : "0");
|
|
|
|
|
+ latitude = Double.parseDouble(object.containsKey("latitude") ? object.getString("latitude") : "0");
|
|
|
|
|
+ setDistance();
|
|
|
switch (num) {
|
|
switch (num) {
|
|
|
case 3:
|
|
case 3:
|
|
|
b = new Bean();//上班
|
|
b = new Bean();//上班
|
|
@@ -635,7 +671,6 @@ public class SigninClickFragment extends EasyFragment implements View.OnClickLis
|
|
|
holder.signin.setText(chche.signin == null ? "" : chche.signin);
|
|
holder.signin.setText(chche.signin == null ? "" : chche.signin);
|
|
|
if (!"-1".equals(chche.signin2))
|
|
if (!"-1".equals(chche.signin2))
|
|
|
holder.signin2.setText(chche.signin2 == null ? "" : chche.signin2);
|
|
holder.signin2.setText(chche.signin2 == null ? "" : chche.signin2);
|
|
|
-
|
|
|
|
|
holder.tag.setText(tag1);
|
|
holder.tag.setText(tag1);
|
|
|
holder.tag2.setText(tag2);
|
|
holder.tag2.setText(tag2);
|
|
|
return view;
|
|
return view;
|