|
|
@@ -13,6 +13,7 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
@@ -24,6 +25,7 @@ import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.auto.AutoMemoryUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.SwitchView;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
@@ -37,7 +39,7 @@ import static com.xzjmyk.pm.activity.AppConfig.AUTO_SIGNIN;
|
|
|
* Created by FANGlh on 2017/1/16.
|
|
|
* function:高级设置
|
|
|
*/
|
|
|
-public class SignSeniorSettingActivity extends BaseActivity implements View.OnClickListener,SwitchView.OnCheckedChangeListener{
|
|
|
+public class SignSeniorSettingActivity extends BaseActivity implements View.OnClickListener, SwitchView.OnCheckedChangeListener {
|
|
|
private static final int LATE_TIME_CODE = 11701;
|
|
|
private static final int ERIOUS_LATE_TIME = 11702;
|
|
|
private static final int LEAVE_EARLY_TIME = 11703;
|
|
|
@@ -60,7 +62,7 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
@ViewInject(R.id.senior_setting_absenteeism_tv)
|
|
|
private TextView absenteeism_time_tv;
|
|
|
@ViewInject(R.id.senior_setting_save_bt)
|
|
|
- private Button save_btn;
|
|
|
+ private Button save_btn;
|
|
|
private boolean isAuto;
|
|
|
private String caller = "MOBILE_ATTENDSYSTEM";
|
|
|
private int save_return_id;
|
|
|
@@ -70,44 +72,44 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
private String first_overlatetime;
|
|
|
private String first_earlyoff;
|
|
|
private String first_nonclass;
|
|
|
- private Handler handler = new Handler(){
|
|
|
+ private Handler handler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
super.handleMessage(msg);
|
|
|
|
|
|
- switch (msg.what){
|
|
|
+ switch (msg.what) {
|
|
|
case GET_SENIOR_CONFIGS_TIME:
|
|
|
String getconfigs_time_result = msg.getData().getString("result");
|
|
|
- LogUtil.prinlnLongMsg("getconfigs_time_result",getconfigs_time_result);
|
|
|
+ LogUtil.prinlnLongMsg("getconfigs_time_result", getconfigs_time_result);
|
|
|
doShowGetConfigsTime(getconfigs_time_result);
|
|
|
break;
|
|
|
case SENIOR_TIME_SAVE_REQUEST:
|
|
|
- if (msg.getData() != null){
|
|
|
+ if (msg.getData() != null) {
|
|
|
String sava_time_result = msg.getData().getString("result");
|
|
|
- LogUtil.prinlnLongMsg("sava_time_result",sava_time_result);
|
|
|
- if (JSON.parseObject(sava_time_result).getBoolean("success")){
|
|
|
- Toast.makeText(ct,"保存成功",Toast.LENGTH_LONG).show();
|
|
|
+ LogUtil.prinlnLongMsg("sava_time_result", sava_time_result);
|
|
|
+ if (JSON.parseObject(sava_time_result).getBoolean("success")) {
|
|
|
+ Toast.makeText(ct, "保存成功", Toast.LENGTH_LONG).show();
|
|
|
try {
|
|
|
save_return_id = JSON.parseObject(sava_time_result).getIntValue("id");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
finish();
|
|
|
- }else {
|
|
|
- Toast.makeText(ct,"保存失败",Toast.LENGTH_LONG).show();
|
|
|
+ } else {
|
|
|
+ Toast.makeText(ct, "保存失败", Toast.LENGTH_LONG).show();
|
|
|
}
|
|
|
progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case AUTO_SIGN_REQUEST:
|
|
|
- if (msg.getData() != null){
|
|
|
+ if (msg.getData() != null) {
|
|
|
String auto_sign_result = msg.getData().getString("result");
|
|
|
- LogUtil.prinlnLongMsg("auto_sign_result",auto_sign_result);
|
|
|
- if (JSON.parseObject(auto_sign_result).getBoolean("success")){
|
|
|
+ LogUtil.prinlnLongMsg("auto_sign_result", auto_sign_result);
|
|
|
+ if (JSON.parseObject(auto_sign_result).getBoolean("success")) {
|
|
|
if (auto_sign == 1) {
|
|
|
ToastMessage("已设置自动打卡");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
ToastMessage("您已关闭自动打卡,系统无法将帮您自动打卡");
|
|
|
|
|
|
}
|
|
|
@@ -151,6 +153,7 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
progressDialog.show();
|
|
|
save_btn.setEnabled(false);
|
|
|
}
|
|
|
+
|
|
|
private void initData() {
|
|
|
late_time_tv.setText(default_late_time);
|
|
|
serious_late_time_tv.setText(default_serious_late_time);
|
|
|
@@ -159,7 +162,7 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
|
|
|
//获取考勤高级设置时间请求
|
|
|
String url_getconfigs = Constants.getAppBaseUrl(getApplicationContext()) + "/mobile/getconfigs.action";
|
|
|
- Map<String,Object> param = new HashMap<>();
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
param.put("code", 1);
|
|
|
LinkedHashMap headers = new LinkedHashMap();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(getApplicationContext(), "sessionId"));
|
|
|
@@ -176,30 +179,36 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
first_earlyoff = JSON.parseObject(getconfigs_time_result).getString("earlyoff");
|
|
|
first_nonclass = JSON.parseObject(getconfigs_time_result).getString("nonclass");
|
|
|
first_autosign = JSON.parseObject(getconfigs_time_result).getString("autosign");
|
|
|
-
|
|
|
+ JSONObject o = JSON.parseObject(getconfigs_time_result);
|
|
|
+ AutoMemoryUtil.nonclass = getIntByJson(o, "nonclass"); //矿工时间
|
|
|
+ AutoMemoryUtil.autosign = getIntByJson(o, "autosign") == 1; //是否自动考勤
|
|
|
+ AutoMemoryUtil.earlyoff = getIntByJson(o, "earlyoff"); //早退时间
|
|
|
+ AutoMemoryUtil.overlatetime = getIntByJson(o, "overlatetime"); //严重迟到时间
|
|
|
+ AutoMemoryUtil.latetime = getIntByJson(o, "latetime"); //迟到时间
|
|
|
+ AutoMemoryUtil.loadWorkSeted = true;//是否下拉过高级考勤数据
|
|
|
auto_sign = CommonUtil.getNumByString(first_autosign);
|
|
|
|
|
|
- if (auto_sign == 1){
|
|
|
+ if (auto_sign == 1) {
|
|
|
auto_sign_sw.setChecked(true);
|
|
|
- }else if (auto_sign == 0){
|
|
|
+ } else if (auto_sign == 0) {
|
|
|
auto_sign_sw.setChecked(false);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- if (!TextUtils.isEmpty(first_latetime)){
|
|
|
+ if (!TextUtils.isEmpty(first_latetime)) {
|
|
|
late_time_tv.setText(first_latetime + "分钟");
|
|
|
}
|
|
|
- if (!TextUtils.isEmpty(first_overlatetime)){
|
|
|
+ if (!TextUtils.isEmpty(first_overlatetime)) {
|
|
|
serious_late_time_tv.setText(first_overlatetime + "分钟");
|
|
|
}
|
|
|
|
|
|
- if (!TextUtils.isEmpty(first_earlyoff)){
|
|
|
+ if (!TextUtils.isEmpty(first_earlyoff)) {
|
|
|
leave_early_tv.setText(first_earlyoff + "分钟");
|
|
|
}
|
|
|
|
|
|
- if (!TextUtils.isEmpty(first_nonclass)){
|
|
|
+ if (!TextUtils.isEmpty(first_nonclass)) {
|
|
|
absenteeism_time_tv.setText(first_nonclass + "分钟");
|
|
|
}
|
|
|
|
|
|
@@ -211,27 +220,27 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
public void onClick(View v) {
|
|
|
int requestCode = 0;
|
|
|
String[] time = null;
|
|
|
- switch (v.getId()){
|
|
|
- case R.id.senior_setting_late_time_tv :
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.senior_setting_late_time_tv:
|
|
|
time = getResources().getStringArray(R.array.late_time);
|
|
|
requestCode = LATE_TIME_CODE;
|
|
|
break;
|
|
|
- case R.id.senior_setting_serious_late_time_tv :
|
|
|
+ case R.id.senior_setting_serious_late_time_tv:
|
|
|
time = getResources().getStringArray(R.array.serious_late_time);
|
|
|
requestCode = ERIOUS_LATE_TIME;
|
|
|
break;
|
|
|
- case R.id.senior_setting_leave_early_tv :
|
|
|
+ case R.id.senior_setting_leave_early_tv:
|
|
|
time = getResources().getStringArray(R.array.serious_leave_early_time);
|
|
|
requestCode = LEAVE_EARLY_TIME;
|
|
|
break;
|
|
|
- case R.id.senior_setting_absenteeism_tv :
|
|
|
+ case R.id.senior_setting_absenteeism_tv:
|
|
|
time = getResources().getStringArray(R.array.absenteeism_time);
|
|
|
requestCode = ABSENTEEISM_TIME;
|
|
|
break;
|
|
|
case R.id.senior_setting_save_bt:
|
|
|
doTimejudgment();
|
|
|
break;
|
|
|
- case R.id.senior_setting_auto_sign_sw:
|
|
|
+ case R.id.senior_setting_auto_sign_sw:
|
|
|
doCheckjudge();
|
|
|
break;
|
|
|
default:
|
|
|
@@ -239,7 +248,7 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
}
|
|
|
ArrayList<SelectBean> beans = new ArrayList<>();
|
|
|
SelectBean bean = null;
|
|
|
- if (time != null){
|
|
|
+ if (time != null) {
|
|
|
for (String e : time) {
|
|
|
bean = new SelectBean();
|
|
|
bean.setName(e);
|
|
|
@@ -255,9 +264,9 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
}
|
|
|
|
|
|
private void doCheckjudge() {
|
|
|
- if (auto_sign == 1){
|
|
|
+ if (auto_sign == 1) {
|
|
|
new AlertDialog.Builder(mContext).setTitle("温馨提示").setMessage("关闭后系统无法帮您自动打卡,确认关闭?")
|
|
|
- .setNegativeButton("取消",null)
|
|
|
+ .setNegativeButton("取消", null)
|
|
|
.setPositiveButton("确认", new DialogInterface.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
@@ -266,7 +275,7 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
doAutoSignSetting();
|
|
|
}
|
|
|
}).show();
|
|
|
- }else if (auto_sign == 0){
|
|
|
+ } else if (auto_sign == 0) {
|
|
|
auto_sign = 1;
|
|
|
auto_sign_sw.setChecked(true);
|
|
|
doAutoSignSetting();
|
|
|
@@ -278,34 +287,35 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
if (data == null) return;
|
|
|
- if (resultCode == 0x20){
|
|
|
+ if (resultCode == 0x20) {
|
|
|
SelectBean b = data.getParcelableExtra("data");
|
|
|
if (b == null) return;
|
|
|
String selected_time = StringUtils.isEmpty(b.getName()) ? "" : b.getName();
|
|
|
- if (requestCode == LATE_TIME_CODE){
|
|
|
+ if (requestCode == LATE_TIME_CODE) {
|
|
|
late_time_tv.setText(selected_time);
|
|
|
- }else if (requestCode == ERIOUS_LATE_TIME){
|
|
|
+ } else if (requestCode == ERIOUS_LATE_TIME) {
|
|
|
serious_late_time_tv.setText(selected_time);
|
|
|
- }else if (requestCode == LEAVE_EARLY_TIME){
|
|
|
+ } else if (requestCode == LEAVE_EARLY_TIME) {
|
|
|
leave_early_tv.setText(selected_time);
|
|
|
- }else if (requestCode == ABSENTEEISM_TIME){
|
|
|
+ } else if (requestCode == ABSENTEEISM_TIME) {
|
|
|
absenteeism_time_tv.setText(selected_time);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private void doTimejudgment() {
|
|
|
int latetime = CommonUtil.getNumByString(late_time_tv.getText().toString()); //迟到
|
|
|
- int seniouslatetime = CommonUtil.getNumByString(serious_late_time_tv.getText().toString()) ;//严重迟到
|
|
|
+ int seniouslatetime = CommonUtil.getNumByString(serious_late_time_tv.getText().toString());//严重迟到
|
|
|
int leaveearlytime = CommonUtil.getNumByString(leave_early_tv.getText().toString()); //早退
|
|
|
int absenteeismtime = CommonUtil.getNumByString(absenteeism_time_tv.getText().toString());//旷工
|
|
|
|
|
|
- if (seniouslatetime > latetime && absenteeismtime > leaveearlytime && absenteeismtime > seniouslatetime){
|
|
|
- doSaveSeniorSetting(latetime,seniouslatetime,leaveearlytime,absenteeismtime);
|
|
|
- }else {
|
|
|
- if (seniouslatetime <= latetime){
|
|
|
+ if (seniouslatetime > latetime && absenteeismtime > leaveearlytime && absenteeismtime > seniouslatetime) {
|
|
|
+ doSaveSeniorSetting(latetime, seniouslatetime, leaveearlytime, absenteeismtime);
|
|
|
+ } else {
|
|
|
+ if (seniouslatetime <= latetime) {
|
|
|
ToastMessage("迟到时间必须小于严重迟到时间!");
|
|
|
}
|
|
|
- if (absenteeismtime <= seniouslatetime){
|
|
|
+ if (absenteeismtime <= seniouslatetime) {
|
|
|
ToastMessage("严重迟到时间必须小于旷工时间!");
|
|
|
}
|
|
|
if (absenteeismtime <= leaveearlytime) {
|
|
|
@@ -313,20 +323,21 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//保存操作
|
|
|
- private void doSaveSeniorSetting(int t1,int t2,int t3,int t4) {
|
|
|
+ private void doSaveSeniorSetting(int t1, int t2, int t3, int t4) {
|
|
|
progressDialog.show();
|
|
|
- Map<String,Object> formStoreMap = new HashMap<>();
|
|
|
- formStoreMap.put("MA_LATETIME",t1);
|
|
|
- formStoreMap.put("MA_SERIOUSLATETIME",t2);
|
|
|
- formStoreMap.put("MA_EARLYTIME",t3);
|
|
|
- formStoreMap.put("MA_ABSENTTIME",t4);
|
|
|
-
|
|
|
- String url = CommonUtil.getSharedPreferences(ct,"erp_baseurl") + "/mobile/saveconfigs.action";
|
|
|
- HashMap<String,Object> params = new HashMap<>();
|
|
|
- String formStore = JSON.toJSONString(formStoreMap);
|
|
|
- params.put("caller",caller);
|
|
|
- params.put("formStore",formStore);
|
|
|
+ Map<String, Object> formStoreMap = new HashMap<>();
|
|
|
+ formStoreMap.put("MA_LATETIME", t1);
|
|
|
+ formStoreMap.put("MA_SERIOUSLATETIME", t2);
|
|
|
+ formStoreMap.put("MA_EARLYTIME", t3);
|
|
|
+ formStoreMap.put("MA_ABSENTTIME", t4);
|
|
|
+
|
|
|
+ String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "/mobile/saveconfigs.action";
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ String formStore = JSON.toJSONString(formStoreMap);
|
|
|
+ params.put("caller", caller);
|
|
|
+ params.put("formStore", formStore);
|
|
|
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(this, url, params, handler, headers, SENIOR_TIME_SAVE_REQUEST, null, null, "post");
|
|
|
@@ -347,16 +358,22 @@ public class SignSeniorSettingActivity extends BaseActivity implements View.OnCl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private int getIntByJson(JSONObject object, String key) {
|
|
|
+ if (object.containsKey(key))
|
|
|
+ return object.getIntValue(key);
|
|
|
+ else return 1;
|
|
|
+ }
|
|
|
+
|
|
|
private void doAutoSignSetting() {
|
|
|
Map<String, Object> formStoreMap = new HashMap<>();
|
|
|
- formStoreMap.put("ma_id",save_return_id);
|
|
|
- formStoreMap.put("AUTOCARDLOG",auto_sign);
|
|
|
+ formStoreMap.put("ma_id", save_return_id);
|
|
|
+ formStoreMap.put("AUTOCARDLOG", auto_sign);
|
|
|
|
|
|
- String url = CommonUtil.getSharedPreferences(ct,"erp_baseurl") + "/mobile/autoCardLog.action";
|
|
|
- HashMap<String,Object> params = new HashMap<>();
|
|
|
+ String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "/mobile/autoCardLog.action";
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
String formStore = JSON.toJSONString(formStoreMap);
|
|
|
- params.put("caller",caller);
|
|
|
- params.put("formStore",formStore);
|
|
|
+ params.put("caller", caller);
|
|
|
+ params.put("formStore", formStore);
|
|
|
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(this, url, params, handler, headers, AUTO_SIGN_REQUEST, null, null, "post");
|