|
@@ -1,699 +0,0 @@
|
|
|
-package com.xzjmyk.pm.activity.ui.erp.fragment;
|
|
|
|
|
-
|
|
|
|
|
-import android.app.Activity;
|
|
|
|
|
-import android.content.DialogInterface;
|
|
|
|
|
-import android.content.Intent;
|
|
|
|
|
-import android.os.Bundle;
|
|
|
|
|
-import android.os.Handler;
|
|
|
|
|
-import android.os.Message;
|
|
|
|
|
-import android.support.v7.app.AlertDialog;
|
|
|
|
|
-import android.text.Html;
|
|
|
|
|
-import android.text.Spanned;
|
|
|
|
|
-import android.view.LayoutInflater;
|
|
|
|
|
-import android.view.View;
|
|
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
-import android.widget.BaseAdapter;
|
|
|
|
|
-import android.widget.ImageView;
|
|
|
|
|
-import android.widget.LinearLayout;
|
|
|
|
|
-import android.widget.ListView;
|
|
|
|
|
-import android.widget.TextView;
|
|
|
|
|
-
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
-import com.baidu.mapapi.search.core.PoiInfo;
|
|
|
|
|
-import com.lidroid.xutils.ViewUtils;
|
|
|
|
|
-import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
|
|
-import com.xzjmyk.pm.activity.MyApplication;
|
|
|
|
|
-import com.xzjmyk.pm.activity.R;
|
|
|
|
|
-import com.xzjmyk.pm.activity.bean.oa.Signin;
|
|
|
|
|
-import com.xzjmyk.pm.activity.bean.oa.SigninBean;
|
|
|
|
|
-import com.xzjmyk.pm.activity.db.dao.SigninDao;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.base.EasyFragment;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.activity.oa.AlarmaActivity;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.activity.oa.LocationMapActivity;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.activity.oa.SigninActivity;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.CodeUtil;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.FlexJsonUtil;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.ViewUtil;
|
|
|
|
|
-import com.xzjmyk.pm.activity.util.BaiduMapUtil;
|
|
|
|
|
-import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
|
|
|
-import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
|
|
-
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.LinkedHashMap;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * Created by gongp on 2016/8/12.
|
|
|
|
|
- */
|
|
|
|
|
-public class SigninClickFragment extends EasyFragment implements View.OnClickListener {
|
|
|
|
|
- private static final long DAY_TIME = 1000 * 60 * 60 * 24;
|
|
|
|
|
- private static final int WHATLOAD = 0x11;
|
|
|
|
|
- private static final int WHATLOG = 0x12;
|
|
|
|
|
- private static final int WHATSIGNIN = 0x13;
|
|
|
|
|
- private static final int RECODE = 0x14;
|
|
|
|
|
-
|
|
|
|
|
- @ViewInject(R.id.listview)
|
|
|
|
|
- private ListView listview;
|
|
|
|
|
- @ViewInject(R.id.seting)
|
|
|
|
|
- private ImageView seting;
|
|
|
|
|
- @ViewInject(R.id.title)
|
|
|
|
|
- private TextView title;
|
|
|
|
|
- @ViewInject(R.id.back)
|
|
|
|
|
- private ImageView back;
|
|
|
|
|
- @ViewInject(R.id.oa_range_addr_rl)
|
|
|
|
|
- private LinearLayout oa_range_addr_rl;
|
|
|
|
|
- @ViewInject(R.id.signin_btn)
|
|
|
|
|
- private ImageView signin_btn;
|
|
|
|
|
- @ViewInject(R.id.office_addr)
|
|
|
|
|
- private TextView office_addr;//考勤地点
|
|
|
|
|
- @ViewInject(R.id.unoffice_mm)
|
|
|
|
|
- private TextView unoffice_mm;//地点微调
|
|
|
|
|
- //初始化
|
|
|
|
|
- private String sessionId = null;
|
|
|
|
|
- private String baseUrl = null;
|
|
|
|
|
- private SigninActivity ct = null;
|
|
|
|
|
- private String code = null;
|
|
|
|
|
- private boolean isPlay = true;
|
|
|
|
|
- private Bean chche = null;//临时对象
|
|
|
|
|
- private SigninAdapter adapter;
|
|
|
|
|
- private long selectTime;//显示的日期long
|
|
|
|
|
- private Handler handler = new Handler() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void handleMessage(Message msg) {
|
|
|
|
|
- String message = msg.getData().getString("result");
|
|
|
|
|
- ct.progressDialog.dismiss();
|
|
|
|
|
- if (!signin_btn.isFocusable()) {
|
|
|
|
|
- signin_btn.setFocusable(true);
|
|
|
|
|
- }
|
|
|
|
|
- switch (msg.what) {
|
|
|
|
|
- case WHATLOAD://下拉时间
|
|
|
|
|
- JSONObject jsonObject = JSON.parseObject(message);//返回对象
|
|
|
|
|
- if (jsonObject.containsKey("success") && jsonObject.getBoolean("success")) {//返回正常
|
|
|
|
|
- if (jsonObject.containsKey("wd_degree") && jsonObject.getInteger("wd_degree") > 0) {//当该用户有排班
|
|
|
|
|
- //用户有排班时候
|
|
|
|
|
- setDataByDegree(jsonObject);
|
|
|
|
|
- } else {
|
|
|
|
|
- setDataByNoDegree(jsonObject);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- //如果返回失败
|
|
|
|
|
- ct.finish();
|
|
|
|
|
- ToastUtil.showToast(ct, "系统尚未找到您的班次,请联系管理员设置班次");
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- case WHATLOG://获取打卡
|
|
|
|
|
- logsSeccess(message);
|
|
|
|
|
- break;
|
|
|
|
|
- case WHATSIGNIN://签到
|
|
|
|
|
- if (JSON.parseObject(message).getBoolean("success")) {//返回正确
|
|
|
|
|
- ToastUtil.showToast(ct, "签到成功");
|
|
|
|
|
- signinOK();
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- ct.ToastMessage(message);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private JSONArray logsJson;
|
|
|
|
|
- private String[] timeList;
|
|
|
|
|
- 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
|
|
|
|
|
- protected int inflateLayoutId() {
|
|
|
|
|
- return R.layout.fragment_click_signin;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onAttach(Activity activity) {
|
|
|
|
|
- super.onAttach(activity);
|
|
|
|
|
- ct = (SigninActivity) activity;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void onCreateView(Bundle savedInstanceState, boolean createView) {
|
|
|
|
|
- ViewUtils.inject(getmRootView());
|
|
|
|
|
- setHasOptionsMenu(true);
|
|
|
|
|
- init();
|
|
|
|
|
- initView();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
- if (data == null) return;
|
|
|
|
|
- if (requestCode == RECODE && resultCode == LocationMapActivity.REQUCODE) {
|
|
|
|
|
- PoiInfo poi = data.getParcelableExtra(LocationMapActivity.REQUESTNAME);
|
|
|
|
|
- office_addr.setText("考勤地点:" + poi.name);
|
|
|
|
|
- unoffice_mm.setText(getDistance(poi.location.latitude, poi.location.longitude));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void init() {
|
|
|
|
|
- mylongitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
|
|
|
|
|
- mylatitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
|
|
|
|
|
- timeList = new String[5];
|
|
|
|
|
- for (int i = 0; i < timeList.length; i++)
|
|
|
|
|
- timeList[i] = getTitle(System.currentTimeMillis() - (DAY_TIME * i));
|
|
|
|
|
- title.setText(TimeUtils.day_long_2_str(System.currentTimeMillis()) + " " + TimeUtils.getWeek(System.currentTimeMillis()));
|
|
|
|
|
- adapter = new SigninAdapter();
|
|
|
|
|
- listview.setAdapter(adapter);
|
|
|
|
|
- loadNetData(System.currentTimeMillis());//获取打卡班次信息
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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() {
|
|
|
|
|
- seting.setOnClickListener(this);
|
|
|
|
|
- back.setOnClickListener(this);
|
|
|
|
|
- signin_btn.setOnClickListener(this);
|
|
|
|
|
- title.setOnClickListener(this);
|
|
|
|
|
- findViewById(R.id.unoffice_mm).setOnClickListener(this);
|
|
|
|
|
- unoffice_mm.setText(getDistance(mylatitude, mylongitude));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void seccess(boolean is) {
|
|
|
|
|
- if (oa_range_addr_rl.getVisibility() == View.GONE) {
|
|
|
|
|
- if (is)
|
|
|
|
|
- oa_range_addr_rl.setVisibility(View.VISIBLE);
|
|
|
|
|
- } else {
|
|
|
|
|
- if (!is)
|
|
|
|
|
- oa_range_addr_rl.setVisibility(View.GONE);
|
|
|
|
|
- }
|
|
|
|
|
- if (signin_btn.getVisibility() == View.GONE) {
|
|
|
|
|
- if (is)
|
|
|
|
|
- signin_btn.setVisibility(View.VISIBLE);
|
|
|
|
|
- } else {
|
|
|
|
|
- if (!is)
|
|
|
|
|
- signin_btn.setVisibility(View.GONE);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //签到成功
|
|
|
|
|
- private void signinOK() {
|
|
|
|
|
- //判断当前签到在那个区间
|
|
|
|
|
- ArrayList<Bean> beans = adapter.getBeans();
|
|
|
|
|
- for (int i = 0; i < beans.size(); i++) {
|
|
|
|
|
- //判断是否在当前区间内
|
|
|
|
|
- String str = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
|
|
|
|
|
- if (!StringUtils.isEmpty(beans.get(i).startSignin) && !StringUtils.isEmpty(beans.get(i).startSignin2)) {
|
|
|
|
|
- if (str.compareTo(beans.get(i).startSignin) > 0 && str.compareTo(beans.get(i).startSignin2) < 0) {
|
|
|
|
|
- //当前时间在当前区间中
|
|
|
|
|
- if (beans.get(i).signin == null || beans.get(i).signin.length() <= 1) {
|
|
|
|
|
- beans.get(i).signin = str;
|
|
|
|
|
- } else {
|
|
|
|
|
- beans.get(i).signin2 = str;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- adapter.setBeens(beans);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //获取列表成功
|
|
|
|
|
- private void logsSeccess(String message) {
|
|
|
|
|
- ArrayList<Bean> beans;
|
|
|
|
|
- if (adapter == null) adapter = new SigninAdapter();
|
|
|
|
|
- if (adapter.getBeans() == null)
|
|
|
|
|
- beans = new ArrayList<>();
|
|
|
|
|
- else
|
|
|
|
|
- beans = adapter.getBeans();
|
|
|
|
|
- logsJson = JSON.parseObject(message).getJSONArray("listdata");//获取签到列表
|
|
|
|
|
- String[] times = new String[logsJson.size()];
|
|
|
|
|
- for (int i = 0; i < logsJson.size(); i++) {
|
|
|
|
|
- times[i] = TimeUtils.long2str(TimeUtils.f_str_2_long(logsJson.getJSONObject(i).getString("cl_time")), "HH:mm");
|
|
|
|
|
- }
|
|
|
|
|
- Arrays.sort(times);
|
|
|
|
|
- for (String str : times) {//遍历签到列表
|
|
|
|
|
- for (int j = 0; j < beans.size(); j++) {
|
|
|
|
|
- //判断是否在当前区间内
|
|
|
|
|
- if (!StringUtils.isEmpty(beans.get(j).startSignin) && !StringUtils.isEmpty(beans.get(j).startSignin2)) {
|
|
|
|
|
- if (str.compareTo(beans.get(j).startSignin) > 0 && str.compareTo(beans.get(j).startSignin2) < 0) {
|
|
|
|
|
- //当前时间在当前区间中
|
|
|
|
|
- if (beans.get(j).signin == null || beans.get(j).signin.length() <= 1) {
|
|
|
|
|
- beans.get(j).signin = str;
|
|
|
|
|
- } else {
|
|
|
|
|
- beans.get(j).signin2 = str;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- boolean is = false;
|
|
|
|
|
- if (isPlay) {//在当前日期
|
|
|
|
|
- for (int i = beans.size() - 1; i >= 0; i--) {
|
|
|
|
|
- //判断前面是否有签到情况
|
|
|
|
|
- String str = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");
|
|
|
|
|
- if (!StringUtils.isEmpty(beans.get(i).startSignin) && !StringUtils.isEmpty(beans.get(i).startSignin2)) {
|
|
|
|
|
- if (str.compareTo(beans.get(0).startSignin) < 0) break;
|
|
|
|
|
- if (str.compareTo(beans.get(i).startSignin) > 0 && str.compareTo(beans.get(i).startSignin2) < 0) {
|
|
|
|
|
- //当前时间在该签到区间内
|
|
|
|
|
- is = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- //当前时间不在该签到区间内
|
|
|
|
|
- if (is) {
|
|
|
|
|
- if (beans.get(i).signin == null || beans.get(i).signin.length() <= 0)
|
|
|
|
|
- beans.get(i).signin = "-1";
|
|
|
|
|
- if (beans.get(i).signin2 == null || beans.get(i).signin2.length() <= 0)
|
|
|
|
|
- beans.get(i).signin2 = "-1";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {//查看历史记录
|
|
|
|
|
- for (int i = beans.size() - 1; i >= 0; i--) {
|
|
|
|
|
- //判断前面是否有签到情况
|
|
|
|
|
- if (StringUtils.isEmpty(beans.get(i).signin)) {
|
|
|
|
|
- beans.get(i).signin = "-1";
|
|
|
|
|
- }
|
|
|
|
|
- if (StringUtils.isEmpty(beans.get(i).signin2)) {
|
|
|
|
|
- beans.get(i).signin = "-1";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- saveDB(beans);
|
|
|
|
|
- adapter.setBeens(beans);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void saveDB(ArrayList<Bean> beans) {
|
|
|
|
|
- ArrayList<Signin> signins = new ArrayList<>();
|
|
|
|
|
- for (Bean e : beans) {
|
|
|
|
|
- signins.add(new Signin(e.time, e.time2, e.signin, e.signin2));
|
|
|
|
|
- }
|
|
|
|
|
- SigninDao.getInstance(ct).updata(signins);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private ArrayList<Bean> getBeanByAdapter() {
|
|
|
|
|
- ArrayList<Bean> beans;
|
|
|
|
|
- if (adapter == null) adapter = new SigninAdapter();
|
|
|
|
|
- if (adapter.getBeans() == null)
|
|
|
|
|
- beans = new ArrayList<>();
|
|
|
|
|
- else
|
|
|
|
|
- beans = adapter.getBeans();
|
|
|
|
|
- return beans;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //当位置信息长度超过8个字符,就会报错
|
|
|
|
|
- public String getLocation() {
|
|
|
|
|
- String temp = MyApplication.getInstance().getBdLocationHelper().getAddress();
|
|
|
|
|
- String locationStr = "";
|
|
|
|
|
- if (temp.length() > 8) {
|
|
|
|
|
- locationStr = temp.substring(0, 7);
|
|
|
|
|
- }
|
|
|
|
|
- if (temp.length() <= 0) {
|
|
|
|
|
- locationStr = "未捕获位置名称";
|
|
|
|
|
- }
|
|
|
|
|
- return locationStr;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //签到
|
|
|
|
|
- private void doSignin(String code) {
|
|
|
|
|
- signin_btn.setFocusable(false);
|
|
|
|
|
- String url = "mobile/saveCardLog.action";
|
|
|
|
|
- final Map<String, Object> param = new HashMap<>();
|
|
|
|
|
- SigninBean bean = new SigninBean();
|
|
|
|
|
- bean.setCl_code(code);
|
|
|
|
|
- bean.setCl_address(office_addr.getText().toString());
|
|
|
|
|
- bean.setCl_distance((int) distanceOk);
|
|
|
|
|
- bean.setCl_emcode(CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
|
|
- bean.setCl_time(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
|
|
|
- bean.setCl_location(getLocation());
|
|
|
|
|
- bean.setCl_emname(MyApplication.getInstance().mLoginUser.getNickName());
|
|
|
|
|
- bean.setCl_phone(MyApplication.getInstance().mLoginUser.getTelephone());
|
|
|
|
|
- String formStore = FlexJsonUtil.toJson(bean);
|
|
|
|
|
- param.put("caller", "CardLog");
|
|
|
|
|
- param.put("formStore", formStore);
|
|
|
|
|
- loadNet(url, param, WHATSIGNIN);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //获取打卡时间
|
|
|
|
|
- private void loadNetData(long time) {
|
|
|
|
|
- selectTime = time;
|
|
|
|
|
- //获取网络数据
|
|
|
|
|
- String url = "mobile/getWorkDate.action";
|
|
|
|
|
- int date = TimeUtils.int_long_2_str(time);
|
|
|
|
|
- final Map<String, Object> param = new HashMap<>();
|
|
|
|
|
- param.put("date", date);
|
|
|
|
|
- loadNet(url, param, WHATLOAD);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //获取打卡记录 date:yyyy-MM-dd
|
|
|
|
|
- private void loadLog(String date) {
|
|
|
|
|
- //获取网络数据
|
|
|
|
|
- String url = "mobile/common/list.action";
|
|
|
|
|
- String emcode = CommonUtil.getSharedPreferences(ct, "erp_username");
|
|
|
|
|
- sessionId = CommonUtil.getSharedPreferences(ct, "sessionId");
|
|
|
|
|
- final Map<String, Object> param = new HashMap<>();
|
|
|
|
|
- param.put("currentMaster", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
|
|
- param.put("page", 1);
|
|
|
|
|
- param.put("pageSize", 1000);
|
|
|
|
|
- param.put("condition", "cl_emcode='" + emcode + "' and to_char(cl_time,'yyyy-MM-dd')='" + date + "'");
|
|
|
|
|
- param.put("caller", "CardLog");
|
|
|
|
|
- loadNet(url, param, WHATLOG);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //请求合并,抽取共同代码
|
|
|
|
|
- private void loadNet(String urlCheche, Map<String, Object> param, int what) {
|
|
|
|
|
- ct.progressDialog.show();
|
|
|
|
|
- if (baseUrl == null)
|
|
|
|
|
- baseUrl = CommonUtil.getSharedPreferences(ct, "erp_baseurl");
|
|
|
|
|
- String url = baseUrl + urlCheche;
|
|
|
|
|
- if (sessionId == null || sessionId.length() <= 0)
|
|
|
|
|
- sessionId = CommonUtil.getSharedPreferences(ct, "sessionId");
|
|
|
|
|
- if (code == null || code.length() <= 0) {
|
|
|
|
|
- code = CommonUtil.getSharedPreferences(ct, "erp_username");
|
|
|
|
|
- }
|
|
|
|
|
- param.put("emcode", code);
|
|
|
|
|
- param.put("sessionId", sessionId);
|
|
|
|
|
- LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
|
|
- headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
|
|
- ViewUtil.httpSendRequest(ct, url, param, handler, headers, what, null, null, "get");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(View view) {
|
|
|
|
|
- Intent intent = null;
|
|
|
|
|
- switch (view.getId()) {
|
|
|
|
|
- case R.id.seting:
|
|
|
|
|
- intent = new Intent(ct, AlarmaActivity.class);
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.back:
|
|
|
|
|
- ct.finish();
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.signin_btn:
|
|
|
|
|
- if (isPlay && isPlayAble()) {
|
|
|
|
|
-
|
|
|
|
|
- if (distanceOk > distance) {
|
|
|
|
|
- ToastUtil.showToast(ct, "您当前不在打卡允许位置范围,请稍后重试或联系管理员");
|
|
|
|
|
- } else {
|
|
|
|
|
- CodeUtil.getInstance().getCode(ct, "CardLog", new CodeUtil.OnCodeLinstener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void callBack(String code) {
|
|
|
|
|
- doSignin(code);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } else
|
|
|
|
|
- ToastUtil.showToast(ct, "您不在打卡允许时间范围,请稍后重试或联系管理员");
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.title:
|
|
|
|
|
- showPopMenu();
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.unoffice_mm:
|
|
|
|
|
- intent = new Intent(ct, LocationMapActivity.class);
|
|
|
|
|
- startActivityForResult(intent, RECODE);
|
|
|
|
|
- break;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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() {
|
|
|
|
|
- //判断适配器
|
|
|
|
|
- if (adapter == null || adapter.getBeans() == null || adapter.getBeans().size() <= 0)
|
|
|
|
|
- return false;
|
|
|
|
|
- ArrayList<Bean> beans = adapter.getBeans();
|
|
|
|
|
- String str = TimeUtils.long2str(System.currentTimeMillis(), "HH:mm");//获取当前的时分
|
|
|
|
|
- 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.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 false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private String getTitle(long time) {
|
|
|
|
|
- return TimeUtils.day_long_2_str(time) + " " + TimeUtils.getWeek(time);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void showPopMenu() {
|
|
|
|
|
- //显示选择日期窗口
|
|
|
|
|
- if (builder == null) {
|
|
|
|
|
- builder = new AlertDialog.Builder(ct);
|
|
|
|
|
- builder.setItems(timeList, new DialogInterface.OnClickListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
|
- isPlay = i == 0 ? true : false;
|
|
|
|
|
- title.setText(timeList[i]);
|
|
|
|
|
- if (adapter != null && adapter.getBeans() != null && adapter.getBeans().size() > 0)
|
|
|
|
|
- adapter.getBeans().clear();
|
|
|
|
|
- loadNetData(System.currentTimeMillis() - (DAY_TIME * i));
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- builder.show();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void endLoadData(ArrayList<Bean> beans) {
|
|
|
|
|
- if (adapter == null) {//容错
|
|
|
|
|
- adapter = new SigninAdapter(beans);
|
|
|
|
|
- listview.setAdapter(adapter);
|
|
|
|
|
- } else {
|
|
|
|
|
- adapter.setBeens(beans);
|
|
|
|
|
- }
|
|
|
|
|
- loadLog(TimeUtils.s_long_2_str(selectTime));//获取打卡时间
|
|
|
|
|
- seccess(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //没有班次排班
|
|
|
|
|
- public void setDataByNoDegree(JSONObject object) {
|
|
|
|
|
- ArrayList<Bean> beans = new ArrayList<>();
|
|
|
|
|
- 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.time = object.containsKey("as_amstarttime") ? object.getString("as_amstarttime") : "08:30";
|
|
|
|
|
- b.startSignin = getEndSignin(b.time, true);
|
|
|
|
|
- b.time2 = object.containsKey("as_amendtime") ? object.getString("as_amendtime") : "12:00";
|
|
|
|
|
- b.startSignin2 = getEndSignin(b.time2, false);
|
|
|
|
|
- beans.add(b);
|
|
|
|
|
- //下午
|
|
|
|
|
- b = new Bean();
|
|
|
|
|
- b.time = object.containsKey("as_pmstarttime") ? object.getString("as_pmstarttime") : "13:30";
|
|
|
|
|
- b.startSignin = getEndSignin(b.time, true);
|
|
|
|
|
- b.time2 = object.containsKey("as_pmendtime") ? object.getString("as_pmendtime") : "18:00";
|
|
|
|
|
- b.startSignin2 = getEndSignin(b.time2, false);
|
|
|
|
|
- beans.add(b);
|
|
|
|
|
- endLoadData(beans);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //前后90分钟,isU--是否是上班
|
|
|
|
|
- private String getEndSignin(String signin, boolean isU) {
|
|
|
|
|
- long sigTime = TimeUtils.f_str_2_long(TimeUtils.s_long_2_str(System.currentTimeMillis()) + " " + signin + ":00");
|
|
|
|
|
- long minTime = 0;
|
|
|
|
|
- if (isU)
|
|
|
|
|
- minTime = sigTime - 90 * 60 * 1000;
|
|
|
|
|
- else
|
|
|
|
|
- minTime = sigTime + 90 * 60 * 1000;
|
|
|
|
|
- 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) {
|
|
|
|
|
- int num = object.getInteger("wd_degree");//获取排班数
|
|
|
|
|
- ArrayList<Bean> beans = new ArrayList<>();
|
|
|
|
|
- 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) {
|
|
|
|
|
- case 3:
|
|
|
|
|
- b = new Bean();//上班
|
|
|
|
|
- b.time = object.containsKey("wd_ondutythree") ? object.getString("wd_ondutythree") : "08:30";
|
|
|
|
|
- b.startSignin = object.containsKey("wd_onbeg3") ? object.getString("wd_onbeg3") : "07:00";
|
|
|
|
|
- b.time2 = object.containsKey("wd_offdutythree") ? object.getString("wd_offdutythree") : "11:30";
|
|
|
|
|
- b.startSignin2 = object.containsKey("wd_offend3") ? object.getString("wd_offend3") : "12:00";
|
|
|
|
|
- beans.add(0, b);
|
|
|
|
|
- case 2:
|
|
|
|
|
- b = new Bean();
|
|
|
|
|
- b.time = object.containsKey("wd_ondutytwo") ? object.getString("wd_ondutytwo") : "--:--";
|
|
|
|
|
- b.startSignin = object.containsKey("wd_onbeg2") ? object.getString("wd_onbeg2") : "07:00";
|
|
|
|
|
- b.time2 = object.containsKey("wd_offdutytwo") ? object.getString("wd_offdutytwo") : "--:--";
|
|
|
|
|
- b.startSignin2 = object.containsKey("wd_offend2") ? object.getString("wd_offend2") : "07:00";
|
|
|
|
|
- beans.add(0, b);
|
|
|
|
|
- case 1:
|
|
|
|
|
- b = new Bean();
|
|
|
|
|
- b.time = object.containsKey("wd_ondutyone") ? object.getString("wd_ondutyone") : "--:--";
|
|
|
|
|
- b.startSignin = object.containsKey("wd_onbeg1") ? object.getString("wd_onbeg1") : "07:00";
|
|
|
|
|
- b.time2 = object.containsKey("wd_offdutyone") ? object.getString("wd_offdutyone") : "--:--";
|
|
|
|
|
- b.startSignin2 = object.containsKey("wd_offend1") ? object.getString("wd_offend1") : "07:00";
|
|
|
|
|
- beans.add(0, b);
|
|
|
|
|
- break;
|
|
|
|
|
- }//添加上班签到时间完成
|
|
|
|
|
- endLoadData(beans);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- class SigninAdapter extends BaseAdapter {
|
|
|
|
|
- private ArrayList<Bean> beans;
|
|
|
|
|
-
|
|
|
|
|
- public SigninAdapter() {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public SigninAdapter(ArrayList<Bean> beans) {
|
|
|
|
|
- this.beans = beans;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public ArrayList<Bean> getBeans() {
|
|
|
|
|
- return beans;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public void setBeens(ArrayList<Bean> beens) {
|
|
|
|
|
- this.beans = beens;
|
|
|
|
|
- notifyDataSetChanged();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public int getCount() {
|
|
|
|
|
- return beans == null ? 0 : beans.size();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public Object getItem(int i) {
|
|
|
|
|
- return beans.get(i);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public long getItemId(int i) {
|
|
|
|
|
- return i;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public View getView(int i, View view, ViewGroup viewGroup) {
|
|
|
|
|
- Holder holder = null;
|
|
|
|
|
- if (view == null) {
|
|
|
|
|
- holder = new Holder();
|
|
|
|
|
- view = LayoutInflater.from(ct).inflate(R.layout.item_signin_list, null);
|
|
|
|
|
- holder.time = (TextView) view.findViewById(R.id.time);
|
|
|
|
|
- holder.signin = (TextView) view.findViewById(R.id.signin);
|
|
|
|
|
- holder.tag = (TextView) view.findViewById(R.id.tag);
|
|
|
|
|
- holder.time2 = (TextView) view.findViewById(R.id.time2);
|
|
|
|
|
- holder.signin2 = (TextView) view.findViewById(R.id.signin2);
|
|
|
|
|
- holder.tag2 = (TextView) view.findViewById(R.id.tag2);
|
|
|
|
|
- view.setTag(holder);
|
|
|
|
|
- } else {
|
|
|
|
|
- holder = (Holder) view.getTag();
|
|
|
|
|
- }
|
|
|
|
|
- chche = beans.get(i);
|
|
|
|
|
- holder.time.setText(chche.time == null ? "" : chche.time);
|
|
|
|
|
- holder.time2.setText(chche.time2 == null ? "" : chche.time2);
|
|
|
|
|
- String tag1 = "";
|
|
|
|
|
- String tag2 = "";
|
|
|
|
|
- if (chche.signin != null) {
|
|
|
|
|
- if ("-1".equals(chche.signin.trim())) {
|
|
|
|
|
- tag1 = "缺勤";
|
|
|
|
|
- } else {
|
|
|
|
|
- holder.signin.setText(chche.signin == null ? "" : chche.signin);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (chche.signin2 != null) {
|
|
|
|
|
- if ("-1".equals(chche.signin.trim())) {
|
|
|
|
|
- tag2 = "缺勤";
|
|
|
|
|
- } else {
|
|
|
|
|
- holder.signin.setText(chche.signin2 == null ? "" : chche.signin2);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!StringUtils.isEmpty(chche.time) && !StringUtils.isEmpty(chche.signin) && !"-1".equals(chche.signin)) {
|
|
|
|
|
- if (chche.time.compareTo(chche.signin) < 0)
|
|
|
|
|
- tag1 = "迟到";
|
|
|
|
|
- }
|
|
|
|
|
- if (!StringUtils.isEmpty(chche.time2) && !StringUtils.isEmpty(chche.signin2) && !"-1".equals(chche.signin2)) {
|
|
|
|
|
- if (chche.time2.compareTo(chche.signin2) > 0)
|
|
|
|
|
- tag2 = "早退";
|
|
|
|
|
- }
|
|
|
|
|
- if (tag1.length() > 1) holder.tag.setVisibility(View.VISIBLE);
|
|
|
|
|
- else holder.tag.setVisibility(View.GONE);
|
|
|
|
|
- if (tag2.length() > 1) holder.tag2.setVisibility(View.VISIBLE);
|
|
|
|
|
- else holder.tag2.setVisibility(View.GONE);
|
|
|
|
|
- if (!"-1".equals(chche.signin))
|
|
|
|
|
- holder.signin.setText(chche.signin == null ? "" : chche.signin);
|
|
|
|
|
- if (!"-1".equals(chche.signin2))
|
|
|
|
|
- holder.signin2.setText(chche.signin2 == null ? "" : chche.signin2);
|
|
|
|
|
- holder.tag.setText(tag1);
|
|
|
|
|
- holder.tag2.setText(tag2);
|
|
|
|
|
- return view;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- class Holder {
|
|
|
|
|
- TextView time,
|
|
|
|
|
- signin,
|
|
|
|
|
- tag,
|
|
|
|
|
- time2,
|
|
|
|
|
- signin2,
|
|
|
|
|
- tag2;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- class Bean {
|
|
|
|
|
- String time;//上班时间
|
|
|
|
|
- String signin;//打卡签到时间
|
|
|
|
|
- String startSignin;//限制签到时间
|
|
|
|
|
- String time2;//下班时间
|
|
|
|
|
- String signin2;//下班打卡签到时间
|
|
|
|
|
- String startSignin2;//下班限制签到时间
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|