|
|
@@ -144,82 +144,89 @@ public class OAActivity extends BaseActivity implements View.OnClickListener, Wo
|
|
|
private Handler handler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
- if (progressDialog.isShowing())
|
|
|
- progressDialog.dismiss();
|
|
|
- String message = (String) msg.getData().get("result");
|
|
|
- switch (msg.what) {
|
|
|
- case 0x11:
|
|
|
- JSONObject jsonObject = parseObject(message);
|
|
|
- if (!jsonObject.containsKey("success") || !jsonObject.getBoolean("success") || jsonObject.isEmpty()) {
|
|
|
- emptyLayout.showEmpty();
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject chche = null;
|
|
|
- meArray = new JSONArray();
|
|
|
- otherArray = new JSONArray();
|
|
|
- //处理我的
|
|
|
- if (jsonObject.containsKey("me")) {
|
|
|
- chche = jsonObject.getJSONObject("me");
|
|
|
- addJsonToArray(meArray, chche);
|
|
|
- meInt.clear();
|
|
|
- if (meArray != null && meArray.size() > 0) {
|
|
|
- meInt.addAll(getDay(meArray));
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ if (progressDialog.isShowing())
|
|
|
+ progressDialog.dismiss();
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ String message = (String) msg.getData().get("result");
|
|
|
+ switch (msg.what) {
|
|
|
+ case 0x11:
|
|
|
+ JSONObject jsonObject = parseObject(message);
|
|
|
+ if (!jsonObject.containsKey("success") || !jsonObject.getBoolean("success") || jsonObject.isEmpty()) {
|
|
|
+ emptyLayout.showEmpty();
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
- //处理下属
|
|
|
- if (jsonObject.containsKey("other")) {
|
|
|
- chche = jsonObject.getJSONObject("other");
|
|
|
- addJsonToArray(otherArray, chche);
|
|
|
- otherInt.clear();
|
|
|
- if (otherArray != null && otherArray.size() > 0) {
|
|
|
- otherInt.addAll(getDay(otherArray));
|
|
|
+ JSONObject chche = null;
|
|
|
+ meArray = new JSONArray();
|
|
|
+ otherArray = new JSONArray();
|
|
|
+ //处理我的
|
|
|
+ if (jsonObject.containsKey("me")) {
|
|
|
+ chche = jsonObject.getJSONObject("me");
|
|
|
+ addJsonToArray(meArray, chche);
|
|
|
+ meInt.clear();
|
|
|
+ if (meArray != null && meArray.size() > 0) {
|
|
|
+ meInt.addAll(getDay(meArray));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理下属
|
|
|
+ if (jsonObject.containsKey("other")) {
|
|
|
+ chche = jsonObject.getJSONObject("other");
|
|
|
+ addJsonToArray(otherArray, chche);
|
|
|
+ otherInt.clear();
|
|
|
+ if (otherArray != null && otherArray.size() > 0) {
|
|
|
+ otherInt.addAll(getDay(otherArray));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- loadSuccess();
|
|
|
- if (mPullToRefreshScrollView.isRefreshing()) {
|
|
|
- ViewUtil.ToastMessage(OAActivity.this, "刷新成功", Style.holoGreenLight, 2000);
|
|
|
- mPullToRefreshScrollView.onRefreshComplete();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 0x12:
|
|
|
- JSONArray array = JSON.parseObject(message).getJSONArray("datas");//获取到数据
|
|
|
- if (array == null || array.size() <= 0) {//无下属
|
|
|
- hasOther = false;
|
|
|
- chaneTAG(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- case 0x14://是否为管理员
|
|
|
- JSONObject object = JSON.parseObject(message);
|
|
|
- if (!object.containsKey("success") || !object.getBoolean("success")) return;
|
|
|
- String isAdmin = object.getString("isAdmin");
|
|
|
- if (StringUtils.isEmpty(isAdmin)) return;
|
|
|
- try {
|
|
|
- adminStatus = Integer.valueOf(isAdmin);
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- if (mPullToRefreshScrollView.isRefreshing()) {
|
|
|
loadSuccess();
|
|
|
- mPullToRefreshScrollView.onRefreshComplete();
|
|
|
- }
|
|
|
- try {
|
|
|
- if (!StringUtils.isEmpty(message) && StringUtils.isInclude(message, "会话已断开")) {
|
|
|
- returnLogin();
|
|
|
- return;
|
|
|
+ if (mPullToRefreshScrollView.isRefreshing()) {
|
|
|
+ ViewUtil.ToastMessage(OAActivity.this, "刷新成功", Style.holoGreenLight, 2000);
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
}
|
|
|
- JsonValidator validator = new JsonValidator();
|
|
|
- if (validator.validate(message)) {
|
|
|
- JSONObject object1 = JSON.parseObject(message);
|
|
|
- Crouton.makeText(ct, StringUtils.isEmpty(object1.getString("exceptionInfo")) ? "程序错误" : object1.getString("exceptionInfo"));
|
|
|
- } else {
|
|
|
- Crouton.makeText(ct, StringUtils.isEmpty(message) ? "程序错误" : StringUtils.getChinese(message));
|
|
|
+ break;
|
|
|
+ case 0x12:
|
|
|
+ JSONArray array = JSON.parseObject(message).getJSONArray("datas");//获取到数据
|
|
|
+ if (array == null || array.size() <= 0) {//无下属
|
|
|
+ hasOther = false;
|
|
|
+ chaneTAG(true);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
+ break;
|
|
|
+ case 0x14://是否为管理员
|
|
|
+ JSONObject object = JSON.parseObject(message);
|
|
|
+ if (!object.containsKey("success") || !object.getBoolean("success")) return;
|
|
|
+ String isAdmin = object.getString("isAdmin");
|
|
|
+ if (StringUtils.isEmpty(isAdmin)) return;
|
|
|
+ try {
|
|
|
+ adminStatus = Integer.valueOf(isAdmin);
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
- }
|
|
|
- break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ if (mPullToRefreshScrollView.isRefreshing()) {
|
|
|
+ loadSuccess();
|
|
|
+ mPullToRefreshScrollView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (!StringUtils.isEmpty(message) && StringUtils.isInclude(message, "会话已断开")) {
|
|
|
+ returnLogin();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JsonValidator validator = new JsonValidator();
|
|
|
+ if (validator.validate(message)) {
|
|
|
+ JSONObject object1 = JSON.parseObject(message);
|
|
|
+ Crouton.makeText(ct, StringUtils.isEmpty(object1.getString("exceptionInfo")) ? "程序错误" : object1.getString("exceptionInfo"));
|
|
|
+ } else {
|
|
|
+ Crouton.makeText(ct, StringUtils.isEmpty(message) ? "程序错误" : StringUtils.getChinese(message));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -290,15 +297,15 @@ public class OAActivity extends BaseActivity implements View.OnClickListener, Wo
|
|
|
if (data == null) return;
|
|
|
Employees entity = data.getParcelableExtra("data");
|
|
|
if (entity == null) return;
|
|
|
- //TODO 选择下属后返回
|
|
|
String otherName = entity.getEm_name();
|
|
|
if (!StringUtils.isEmpty(otherName)) {
|
|
|
JSONArray array = new JSONArray();
|
|
|
for (int i = 0; i < otherArray.size(); i++) {
|
|
|
JSONObject object = otherArray.getJSONObject(i);
|
|
|
- String name = "," + (object.containsKey("handler") ? object.getString("handler") :
|
|
|
- (object.containsKey("recordman") ? object.getString("recordman") :
|
|
|
- (object.containsKey("visitman") ? object.getString("visitman") : ""))) + ",";
|
|
|
+ String name = "," + getString(object, "handler") +
|
|
|
+ getString(object, "recordman") +
|
|
|
+ getString(object, "visitman") +
|
|
|
+ getString(object, "mp_recorder") + ",";
|
|
|
if (StringUtils.isEmpty(otherName)//没有选择下属
|
|
|
|| getIsDecorat(name, "," + otherName + ",")) {
|
|
|
array.add(object);
|
|
|
@@ -385,10 +392,15 @@ public class OAActivity extends BaseActivity implements View.OnClickListener, Wo
|
|
|
intent.putExtra("data", object.toString());
|
|
|
startActivityForResult(intent, isMe ? 0x20 : 0x21);
|
|
|
} else if (adapter.isOutplan(object)) {
|
|
|
- //TODO 发布版本关闭
|
|
|
String actdate = adapter.getJSONString(object, "mpd_actdate");
|
|
|
String outdate = adapter.getJSONString(object, "mpd_outdate");
|
|
|
- if (StringUtils.isEmpty(actdate) || StringUtils.isEmpty(outdate)) return;
|
|
|
+ if (StringUtils.isEmpty(actdate) || StringUtils.isEmpty(outdate)) {
|
|
|
+ try {
|
|
|
+ Crouton.makeText(ct, "当前外勤计划未完成,不能创建拜访报告");
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
intent = new Intent(activity, VisitReportAddActivity.class);
|
|
|
intent.putExtra("type", 3);
|
|
|
intent.putExtra("isMe", isMe);//可以提交拜访报告
|
|
|
@@ -943,6 +955,10 @@ public class OAActivity extends BaseActivity implements View.OnClickListener, Wo
|
|
|
return super.dispatchTouchEvent(ev);
|
|
|
}
|
|
|
|
|
|
+ private String getString(JSONObject object, String key) {
|
|
|
+ return object == null ? "" : (object.containsKey(key) ? object.getString(key) : "");
|
|
|
+ }
|
|
|
+
|
|
|
public interface OnTaskChangeListener {
|
|
|
void onChange(Set<Integer> in);
|
|
|
}
|