|
|
@@ -6,6 +6,7 @@ import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
|
@@ -26,6 +27,7 @@ import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.oa.MeetUserEntity;
|
|
|
import com.xzjmyk.pm.activity.bean.oa.OABean;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.DetailTaskActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.ErpMenActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.crm.TaskAddActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.crm.VisitReportAddActivity;
|
|
|
@@ -38,9 +40,11 @@ import com.xzjmyk.pm.activity.view.CalendarView;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
@@ -70,9 +74,10 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
private View my_client_log_tag;//我的下属工作日志标识
|
|
|
@ViewInject(R.id.my_log_tag)
|
|
|
private View my_log_tag;//我的工作日志标识
|
|
|
-
|
|
|
private MyListViewAdapter adapter;
|
|
|
- private ArrayList<OABean> beans;
|
|
|
+ private List<OABean> beans;//适配器使用
|
|
|
+ private List<OABean> allBean;//所有数据 用于筛选
|
|
|
+ private List<OABean> chches;//临时缓冲
|
|
|
private Handler handler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
@@ -82,16 +87,10 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
case WHAT_LOAD:
|
|
|
JSONObject jsonObject = JSON.parseObject(message);
|
|
|
if (jsonObject.isEmpty()) return;
|
|
|
- JSONArray jsonTask = jsonObject.containsKey("task") ? null : jsonObject.getJSONArray("task");
|
|
|
- JSONArray jsonSchedule = jsonObject.containsKey("schedule") ? null : jsonObject.getJSONArray("schedule");
|
|
|
- JSONArray jsonVisitPlan = jsonObject.containsKey("visitPlan") ? null : jsonObject.getJSONArray("visitPlan");
|
|
|
- if (jsonTask != null && jsonTask.size() > 0)
|
|
|
- beans.addAll(JSON.parseArray(jsonTask.toJSONString(), OABean.class));
|
|
|
- if (jsonSchedule != null && jsonSchedule.size() > 0)
|
|
|
- beans.addAll(JSON.parseArray(jsonSchedule.toJSONString(), OABean.class));
|
|
|
- if (jsonVisitPlan != null && jsonVisitPlan.size() > 0)
|
|
|
- beans.addAll(JSON.parseArray(jsonVisitPlan.toJSONString(), OABean.class));
|
|
|
-
|
|
|
+ JSONArray jsonTask = jsonObject.containsKey("task") ? jsonObject.getJSONArray("task") : null;
|
|
|
+ JSONArray jsonSchedule = jsonObject.containsKey("schedule") ? jsonObject.getJSONArray("schedule") : null;
|
|
|
+ JSONArray jsonVisitPlan = jsonObject.containsKey("visitPlan") ? jsonObject.getJSONArray("visitPlan") : null;
|
|
|
+ setData(new int[]{1, 2, 3}, jsonTask, jsonSchedule, jsonVisitPlan);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -182,6 +181,8 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
|
|
|
private void initView() {
|
|
|
beans = new ArrayList<>();
|
|
|
+ allBean = new ArrayList<>();
|
|
|
+ chches = new ArrayList<>();
|
|
|
loadNetData();
|
|
|
chaneTAG(false);
|
|
|
baseUrl = CommonUtil.getSharedPreferences(this, "erp_baseurl");
|
|
|
@@ -206,6 +207,53 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //一次设置全部数据
|
|
|
+ private void setData(int[] type, JSONArray... json) {
|
|
|
+ for (int i = 0; i < type.length; i++) {
|
|
|
+ if (json[i] == null || json[i].size() <= 0) continue;
|
|
|
+ chches = JSON.parseArray(json[i].toJSONString(), OABean.class);//获取
|
|
|
+ for (int j = 0; j < chches.size(); j++)
|
|
|
+ chches.get(i).setType(type[i]);
|
|
|
+ }
|
|
|
+ beans.addAll(chches);
|
|
|
+ allBean.addAll(beans);
|
|
|
+ if (allBean.size() <= 0) return;
|
|
|
+ int[] ii = new int[allBean.size()];
|
|
|
+ for (int i = 0; i < allBean.size(); i++) {
|
|
|
+ String date = allBean.get(i).getStartdate();
|
|
|
+ long time = TimeUtils.f_str_2_long(date);
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTimeInMillis(time);
|
|
|
+ ii[i] = c.get(Calendar.DAY_OF_MONTH);
|
|
|
+ }
|
|
|
+ picker.setTaskDay(ii);
|
|
|
+ if (adapter != null) {
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ adapter = new MyListViewAdapter();
|
|
|
+ listview.setAdapter(adapter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setData(JSONArray json, int type) {
|
|
|
+ if (json == null || json.size() <= 0) return;
|
|
|
+ chches = JSON.parseArray(json.toJSONString(), OABean.class);
|
|
|
+ for (int i = 0; i < chches.size(); i++)
|
|
|
+ chches.get(i).setType(type);
|
|
|
+ beans.addAll(chches);
|
|
|
+ allBean.addAll(beans);
|
|
|
+ int[] ii = new int[allBean.size()];
|
|
|
+ for (int i = 0; i < allBean.size(); i++) {
|
|
|
+ String date = allBean.get(i).getStartdate();
|
|
|
+ long time = TimeUtils.f_str_2_long(date);
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTimeInMillis(time);
|
|
|
+ ii[i] = c.get(Calendar.DAY_OF_MONTH);
|
|
|
+ }
|
|
|
+ picker.setTaskDay(ii);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//获取数据
|
|
|
public void loadNetData() {
|
|
|
String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/crm/gettaskscheduleandvisitplanmsg.action";
|
|
|
@@ -235,9 +283,30 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
picker.setOnItemClickListener(new CalendarView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void OnItemClick(Date selectedStartDate, Date selectedEndDate, Date downDate) {
|
|
|
-
|
|
|
+// Log.i("gongpengming", downDate.getDay() + "");
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ int ok = 0;
|
|
|
+ int noOk = 0;
|
|
|
+ for (OABean e : allBean) {
|
|
|
+ c.setTimeInMillis(TimeUtils.f_str_2_long(e.getStartdate()));
|
|
|
+ int day = c.get(Calendar.DAY_OF_MONTH);
|
|
|
+ Log.i("gongpengming", "day=" + day + " downDate.getDay()=" + downDate.getDay());
|
|
|
+ if (day == downDate.getDay()) {//选择那天的任务
|
|
|
+ if ("已完成".equals(e.getStatus()) || "已拜访".equals("e.getStatus()")) {
|
|
|
+ ok += 1;
|
|
|
+ } else {
|
|
|
+ noOk += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log.i("gongpengming", "ok=" +ok + " noOk=" + noOk);
|
|
|
+ all_task_num.setText("我的任务日程:" + (ok + noOk));
|
|
|
+ ok_task_num.setText("已完成:" + ok);
|
|
|
+ uok_task_num.setText("未完成:" + noOk);
|
|
|
+ ok_scale.setText("达成率:" + ((ok + noOk) > 0 ? (ok * 100 / (ok + noOk) + "%") : "0"));
|
|
|
}
|
|
|
});
|
|
|
+ picker.setToday( );//初始化今天
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -302,7 +371,6 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
public MyListViewAdapter() {
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
return beans == null ? 0 : beans.size();
|
|
|
@@ -337,16 +405,82 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
viewholder.item_doit_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
- Intent intent = new Intent(activity, VisitActivity.class);
|
|
|
- startActivityForResult(intent, 1);
|
|
|
+ Intent intent = null;
|
|
|
+ chche = beans.get(i);
|
|
|
+ if (chche.getType() == 3) {
|
|
|
+ intent = new Intent(activity, VisitActivity.class);
|
|
|
+ startActivityForResult(intent, 1);
|
|
|
+ } else if (chche.getType() == 1 || chche.getType() == 2) {
|
|
|
+ intent = new Intent(ct, DetailTaskActivity.class);
|
|
|
+ intent.putExtra("description", chche.getDescription());
|
|
|
+ intent.putExtra("duration", chche.getDescription());
|
|
|
+ intent.putExtra("status", chche.getStatus() + "");
|
|
|
+ intent.putExtra("taskid", chche.getTaskcode());//编号
|
|
|
+ intent.putExtra("taskname", chche.getName());//名称
|
|
|
+ intent.putExtra("taskemcode", chche.getTaskcode());//发起人
|
|
|
+ intent.putExtra("tasktime", chche.getStartdate());//发起时间
|
|
|
+ intent.putExtra("performer", chche.getHandler());//处理人
|
|
|
+ intent.putExtra("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));//处理人编号
|
|
|
+ intent.putExtra("taskcode", chche.getTaskcode());//处理人编号
|
|
|
+// intent.putExtra("ra_taskid", store.task_id);//取回复内容id
|
|
|
+// intent.putExtra("attachs", store.attachs);
|
|
|
+ intent.putExtra("endtime", chche.getEnddate());
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
bindData(viewholder, i);
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
+ private OABean chche;//临时数据
|
|
|
+
|
|
|
private void bindData(Viewholder viewholder, int i) {
|
|
|
+ chche = beans.get(i);
|
|
|
+ if (chche.getName() != null) {//名字
|
|
|
+ viewholder.item_name_tv.setText(chche.getName());
|
|
|
+ viewholder.item_doit_tv.setVisibility(View.VISIBLE);
|
|
|
+ viewholder.item_doit_tv.setImageResource(R.drawable.oa_next);
|
|
|
+ } else if (chche.getClient() != null) {
|
|
|
+ viewholder.item_doit_tv.setVisibility(View.VISIBLE);
|
|
|
+ viewholder.item_doit_tv.setImageResource(R.drawable.oa_doit);
|
|
|
+ viewholder.item_name_tv.setText(chche.getClient());
|
|
|
+ } else {
|
|
|
+ viewholder.item_doit_tv.setVisibility(View.GONE);
|
|
|
+ viewholder.item_name_tv.setText("");
|
|
|
+ }
|
|
|
+ if (chche.getDescription() != null) {//备注
|
|
|
+ viewholder.item_remak.setText(chche.getDepartment());
|
|
|
+ } else if (chche.getRemark() != null) {
|
|
|
+ viewholder.item_remak.setText(chche.getRemark());
|
|
|
+ } else {
|
|
|
+ viewholder.item_remak.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chche.getStatus() != null) {//状态
|
|
|
+ viewholder.item_status_tv.setText(chche.getStatus());
|
|
|
+ } else {
|
|
|
+ viewholder.item_status_tv.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chche.getTaskcode() != null) {//地址
|
|
|
+ viewholder.item_addr_tv.setText(chche.getTaskcode());
|
|
|
+ } else if (chche.getAddress() != null) {
|
|
|
+ viewholder.item_addr_tv.setText(chche.getAddress());
|
|
|
+ } else {
|
|
|
+ viewholder.item_addr_tv.setText("");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chche.getHandler() != null) {//对象
|
|
|
+ viewholder.item_object_tv.setText(chche.getHandler());
|
|
|
+ } else if (chche.getDepartment() != null || chche.getRecordman() != null) {
|
|
|
+ String str = chche.getDepartment() == null ? "" : chche.getDepartment() + " -> " + chche.getRecordman() == null ? "" : chche.getRecordman();
|
|
|
+ viewholder.item_object_tv.setText(str);
|
|
|
+ } else {
|
|
|
+ viewholder.item_object_tv.setText("");
|
|
|
+ }
|
|
|
|
|
|
+ //处理去拜访的按钮
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -355,7 +489,7 @@ public class OAActivity extends BaseActivity implements View.OnClickListener {
|
|
|
item_addr_tv,//地址
|
|
|
item_object_tv,//对象
|
|
|
item_status_tv,//状态
|
|
|
- item_remak;
|
|
|
+ item_remak;//备注
|
|
|
ImageView item_doit_tv;//去拜访按钮
|
|
|
}
|
|
|
}
|