|
@@ -54,6 +54,7 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
private final int LOAD_WORKLOG = 0x13;//打卡列表
|
|
private final int LOAD_WORKLOG = 0x13;//打卡列表
|
|
|
private final int SIGNIN_MISSION = 0x14;//外勤签到
|
|
private final int SIGNIN_MISSION = 0x14;//外勤签到
|
|
|
private final int HAVE_OUT_PLAN = 0x15;//还有未拜访外勤计划
|
|
private final int HAVE_OUT_PLAN = 0x15;//还有未拜访外勤计划
|
|
|
|
|
+ private final int END_MISSION = 0x19;//还有未拜访外勤计划
|
|
|
|
|
|
|
|
private final int WORK_DATA = 0x16;//内勤列表
|
|
private final int WORK_DATA = 0x16;//内勤列表
|
|
|
private final int WORK_LOG = 0x17;//下拉列表时候的获取打卡列表
|
|
private final int WORK_LOG = 0x17;//下拉列表时候的获取打卡列表
|
|
@@ -115,7 +116,7 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
private void endMission(MissionModel model) {
|
|
private void endMission(MissionModel model) {
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
param.put("id", model.getId());
|
|
param.put("id", model.getId());
|
|
|
- HttpHandler.getInstance().loadERPByNet(SIGNIN_MISSION,
|
|
|
|
|
|
|
+ HttpHandler.getInstance().loadERPByNet(END_MISSION,
|
|
|
"mobile/mobileplanUpdate.action", param, null, this);
|
|
"mobile/mobileplanUpdate.action", param, null, this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -305,6 +306,11 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
|
"对" + model.getCompanyName() + "外勤签退成功", MissionActivity.class);
|
|
"对" + model.getCompanyName() + "外勤签退成功", MissionActivity.class);
|
|
|
} else {//没有外勤计划
|
|
} else {//没有外勤计划
|
|
|
|
|
+ //TODO 没有外勤计划 关闭自动外勤循环
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_MISSION_TASK);
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_MISSION_TASK, false);
|
|
|
|
|
+ MyApplication.getInstance().sendBroadcast(intent);
|
|
|
endMission(model, saveOk);
|
|
endMission(model, saveOk);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -378,6 +384,9 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
|
if (mission.getStatus() < 1) {
|
|
if (mission.getStatus() < 1) {
|
|
|
mission.setStatus(1);//说明没有打过卡 TODO 可以通过判断签到时间是否存在来判断是否提示签到
|
|
mission.setStatus(1);//说明没有打过卡 TODO 可以通过判断签到时间是否存在来判断是否提示签到
|
|
|
|
|
+ if (StringUtils.isEmpty(mission.getRealTime()))
|
|
|
|
|
+ mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
|
|
|
+ else mission.setRealTime(TimeUtils.f_long_2_str(System.currentTimeMillis()));
|
|
|
boolean saveOk = MissionDao.getInstance().updata(mission);
|
|
boolean saveOk = MissionDao.getInstance().updata(mission);
|
|
|
if (saveOk)
|
|
if (saveOk)
|
|
|
notificationManage.sendNotification(MyApplication.getInstance(), "外勤签到成功",
|
|
notificationManage.sendNotification(MyApplication.getInstance(), "外勤签到成功",
|
|
@@ -474,6 +483,7 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
String time = object.getString("cl_time");//获取最后一次打卡信息,班次打卡信息
|
|
String time = object.getString("cl_time");//获取最后一次打卡信息,班次打卡信息
|
|
|
time = TimeUtils.clearDay(time);//获取到的
|
|
time = TimeUtils.clearDay(time);//获取到的
|
|
|
if (StringUtils.isEmpty(time) || model == null) return;
|
|
if (StringUtils.isEmpty(time) || model == null) return;
|
|
|
|
|
+
|
|
|
if (StringUtils.isEmpty(model.getWorkSignin()) && model.getWorkStart().compareTo(time) <= 0
|
|
if (StringUtils.isEmpty(model.getWorkSignin()) && model.getWorkStart().compareTo(time) <= 0
|
|
|
&& model.getWorkTime().compareTo(time) >= 0) {
|
|
&& model.getWorkTime().compareTo(time) >= 0) {
|
|
|
model.setWorkSignin(time);
|
|
model.setWorkSignin(time);
|
|
@@ -481,6 +491,14 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
log("i=" + i);
|
|
log("i=" + i);
|
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
|
R.string.auto_signin, WorkActivity.class);
|
|
R.string.auto_signin, WorkActivity.class);
|
|
|
|
|
+ boolean b = hasMore();
|
|
|
|
|
+ if (!b) {
|
|
|
|
|
+ //TODO 关闭任务
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_WORK_TASK);
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_WORK_TASK, false);
|
|
|
|
|
+ MyApplication.getInstance().sendBroadcast(intent);
|
|
|
|
|
+ }
|
|
|
} else if (StringUtils.isEmpty(model.getOffSignin()) && model.getOffTime().compareTo(time) <= 0
|
|
} else if (StringUtils.isEmpty(model.getOffSignin()) && model.getOffTime().compareTo(time) <= 0
|
|
|
&& model.getOffend().compareTo(time) >= 0) {
|
|
&& model.getOffend().compareTo(time) >= 0) {
|
|
|
model.setOffSignin(time);
|
|
model.setOffSignin(time);
|
|
@@ -488,7 +506,26 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
log("i=" + i);
|
|
log("i=" + i);
|
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
notificationManage.sendNotification(MyApplication.getInstance(),
|
|
|
R.string.auto_signin, WorkActivity.class);
|
|
R.string.auto_signin, WorkActivity.class);
|
|
|
|
|
+ boolean b = hasMore();
|
|
|
|
|
+ if (!b) {
|
|
|
|
|
+ //TODO 关闭任务
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_WORK_TASK);
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_WORK_TASK, false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean hasMore() {
|
|
|
|
|
+ List<WorkModel> models = WorkModelDao.getInstance().query(false);
|
|
|
|
|
+ if (ListUtils.isEmpty(models)) return false;
|
|
|
|
|
+ else {
|
|
|
|
|
+ for (WorkModel m : models) {
|
|
|
|
|
+ if (StringUtils.isEmpty(m.getWorkSignin()) || StringUtils.isEmpty(m.getOffSignin()))
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void log(String message) {
|
|
private void log(String message) {
|
|
@@ -646,7 +683,8 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
boolean saveOK = WorkModelDao.getInstance().createOrUpdata(models);
|
|
boolean saveOK = WorkModelDao.getInstance().createOrUpdata(models);
|
|
|
if (saveOK) {
|
|
if (saveOK) {
|
|
|
Intent intent = new Intent();
|
|
Intent intent = new Intent();
|
|
|
- intent.setAction(AutoErpService.SAVE_WORK_ACTION);
|
|
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_WORK_TASK, true);
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_WORK_TASK);//保存到数据库成功,开启
|
|
|
MyApplication.getInstance().sendBroadcast(intent);
|
|
MyApplication.getInstance().sendBroadcast(intent);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -659,7 +697,14 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
*/
|
|
*/
|
|
|
private void handlerData(JSONArray array) throws Exception {
|
|
private void handlerData(JSONArray array) throws Exception {
|
|
|
if (ListUtils.isEmpty(array)) {
|
|
if (ListUtils.isEmpty(array)) {
|
|
|
- return; //获取到拜访计划数据
|
|
|
|
|
|
|
+ List<MissionModel> models = MissionDao.getInstance().queryByEnCode();
|
|
|
|
|
+ if (!ListUtils.isEmpty(models)) {
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_MISSION_TASK, true);
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_MISSION_TASK);
|
|
|
|
|
+ MyApplication.getInstance().sendBroadcast(intent);
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
} else {
|
|
} else {
|
|
|
JSONObject object = null;
|
|
JSONObject object = null;
|
|
|
MissionModel entity = null;
|
|
MissionModel entity = null;
|
|
@@ -694,6 +739,7 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
entity.setLocation(object.getString("MPD_LOCATION"));
|
|
entity.setLocation(object.getString("MPD_LOCATION"));
|
|
|
entity.setRemark(object.getString("MPD_REMARK"));
|
|
entity.setRemark(object.getString("MPD_REMARK"));
|
|
|
entity.setRecorddate(object.getString("MPD_RECORDDATE"));
|
|
entity.setRecorddate(object.getString("MPD_RECORDDATE"));
|
|
|
|
|
+ entity.setType(getType(object.getString("MPD_KIND")));
|
|
|
entities.add(entity);
|
|
entities.add(entity);
|
|
|
}
|
|
}
|
|
|
if (!ListUtils.isEmpty(entities)) {
|
|
if (!ListUtils.isEmpty(entities)) {
|
|
@@ -704,7 +750,8 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
boolean saveOk = MissionDao.getInstance().updataOrCreate(entities);
|
|
boolean saveOk = MissionDao.getInstance().updataOrCreate(entities);
|
|
|
if (saveOk) {
|
|
if (saveOk) {
|
|
|
Intent intent = new Intent();
|
|
Intent intent = new Intent();
|
|
|
- intent.setAction(AutoErpService.SAVE_MISSION_ACTION);
|
|
|
|
|
|
|
+ intent.putExtra(AutoErpService.CHANGE_MISSION_TASK, true);
|
|
|
|
|
+ intent.setAction(AutoErpService.CHANGE_MISSION_TASK);
|
|
|
MyApplication.getInstance().sendBroadcast(intent);
|
|
MyApplication.getInstance().sendBroadcast(intent);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -713,6 +760,11 @@ public class AutoErpSigninUitl implements HttpHandler.OnResultListener {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private int getType(String str) {
|
|
|
|
|
+ if (StringUtils.isEmpty(str)) return 1;
|
|
|
|
|
+ return "一天".equals(str) ? 2 : 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取截至时间
|
|
* 获取截至时间
|
|
|
*
|
|
*
|