|
@@ -2,34 +2,53 @@ package com.xzjmyk.pm.activity.ui.erp.activity.crm;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baidu.mapapi.model.LatLng;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
|
|
+import com.xzjmyk.pm.activity.MyApplication;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.oa.OABaseActivity;
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.oa.OABaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.oa.SelectAimActivity;
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.oa.SelectAimActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.adapter.oa.AddBusinessAdapter;
|
|
import com.xzjmyk.pm.activity.ui.erp.adapter.oa.AddBusinessAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.model.oa.SelectAimModel;
|
|
import com.xzjmyk.pm.activity.ui.erp.model.oa.SelectAimModel;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.JsonValidator;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.OACheckUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.PopupWindowHelper;
|
|
import com.xzjmyk.pm.activity.ui.erp.util.PopupWindowHelper;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.oa.CommonInterface;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.oa.http.OAHttpHelper;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.oa.http.OnHttpResultListener;
|
|
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.oa.http.Request;
|
|
|
|
|
+import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
|
import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 创建商机
|
|
* 创建商机
|
|
|
* Created by Bitliker on 2017/5/8.
|
|
* Created by Bitliker on 2017/5/8.
|
|
|
*/
|
|
*/
|
|
|
-public class AddBusinessActivity extends OABaseActivity implements View.OnClickListener {
|
|
|
|
|
-
|
|
|
|
|
|
|
+public class AddBusinessActivity extends OABaseActivity implements View.OnClickListener, OnHttpResultListener {
|
|
|
|
|
+ private final int LOAD_ID = 0x201;
|
|
|
|
|
+ private final int LOAD_CODE = 0x202;
|
|
|
private final int SELECT_COMPANY = 0x761;
|
|
private final int SELECT_COMPANY = 0x761;
|
|
|
private final int SELECT_REMARK = 0x762;
|
|
private final int SELECT_REMARK = 0x762;
|
|
|
|
|
+ private final int SAVE_BUSINESS = 0x763;
|
|
|
|
|
+ private final int LOAD_BUSINESS_CHANCESTAGE = 0x764;
|
|
|
@ViewInject(R.id.company_tv)
|
|
@ViewInject(R.id.company_tv)
|
|
|
private TextView company_tv;
|
|
private TextView company_tv;
|
|
|
@ViewInject(R.id.company_add_tv)
|
|
@ViewInject(R.id.company_add_tv)
|
|
@@ -39,7 +58,7 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
@ViewInject(R.id.contact_lv)
|
|
@ViewInject(R.id.contact_lv)
|
|
|
private MyListView contact_lv;
|
|
private MyListView contact_lv;
|
|
|
private AddBusinessAdapter adapter;
|
|
private AddBusinessAdapter adapter;
|
|
|
-
|
|
|
|
|
|
|
+ private LatLng latLng;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -63,6 +82,7 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
findViewById(R.id.remark_tv).setOnClickListener(this);
|
|
findViewById(R.id.remark_tv).setOnClickListener(this);
|
|
|
findViewById(R.id.additem_tv).setOnClickListener(this);
|
|
findViewById(R.id.additem_tv).setOnClickListener(this);
|
|
|
findViewById(R.id.submit_btn).setOnClickListener(this);
|
|
findViewById(R.id.submit_btn).setOnClickListener(this);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -70,7 +90,7 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
Intent intent = null;
|
|
Intent intent = null;
|
|
|
switch (v.getId()) {
|
|
switch (v.getId()) {
|
|
|
case R.id.company_tv:
|
|
case R.id.company_tv:
|
|
|
- intent = new Intent(ct, SelectAimActivity.class);
|
|
|
|
|
|
|
+ intent = new Intent(ct, SelectAimActivity.class).putExtra("type", 1);
|
|
|
startActivityForResult(intent, SELECT_COMPANY);
|
|
startActivityForResult(intent, SELECT_COMPANY);
|
|
|
break;
|
|
break;
|
|
|
case R.id.remark_tv:
|
|
case R.id.remark_tv:
|
|
@@ -81,16 +101,22 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
break;
|
|
break;
|
|
|
case R.id.submit_btn:
|
|
case R.id.submit_btn:
|
|
|
- List<AddBusinessAdapter.Contact> contacts = adapter.getContacts();
|
|
|
|
|
- if (ListUtils.isEmpty(contacts)) return;
|
|
|
|
|
- for (AddBusinessAdapter.Contact e : contacts) {
|
|
|
|
|
- LogUtil.d("name=" + e.name);
|
|
|
|
|
- LogUtil.d("phone=" + e.phone);
|
|
|
|
|
|
|
+ if (canSubmit()) {
|
|
|
|
|
+ getIdByNet();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private boolean canSubmit() {
|
|
|
|
|
+ if (TextUtils.isEmpty(company_tv.getText())) return false;
|
|
|
|
|
+ if (adapter == null || ListUtils.getSize(adapter.getContacts()) <= 0) return false;
|
|
|
|
|
+ for (AddBusinessAdapter.Contact e : adapter.getContacts()) {
|
|
|
|
|
+ if (!StringUtils.isEmpty(e.name) && !StringUtils.isEmpty(e.phone)) return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
@@ -99,11 +125,17 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
switch (requestCode) {
|
|
switch (requestCode) {
|
|
|
case SELECT_COMPANY:
|
|
case SELECT_COMPANY:
|
|
|
SelectAimModel entity = data.getParcelableExtra("data");
|
|
SelectAimModel entity = data.getParcelableExtra("data");
|
|
|
|
|
+ AddBusinessActivity.this.latLng = entity.getLatLng();
|
|
|
PopupWindowHelper.create(this, getString(R.string.perfect_company_name), entity, new PopupWindowHelper.OnClickListener() {
|
|
PopupWindowHelper.create(this, getString(R.string.perfect_company_name), entity, new PopupWindowHelper.OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void result(SelectAimModel model) {
|
|
public void result(SelectAimModel model) {
|
|
|
company_tv.setText(model.getName());
|
|
company_tv.setText(model.getName());
|
|
|
company_add_tv.setText(model.getAddress());
|
|
company_add_tv.setText(model.getAddress());
|
|
|
|
|
+ if (new JsonValidator().validate(model.getObject())) {
|
|
|
|
|
+ JSONObject object = JSON.parseObject(model.getObject());
|
|
|
|
|
+ String code = OACheckUtil.getJson2Text(object, "CU_CODE");
|
|
|
|
|
+ company_tv.setTag(code);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
@@ -115,4 +147,167 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void getIdByNet() {
|
|
|
|
|
+ if (!MyApplication.getInstance().isNetworkActive()) {
|
|
|
|
|
+ ToastUtil.showToast(ct, R.string.networks_out);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ progressDialog.show();
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("seq", "VISITRECORD_SEQ");
|
|
|
|
|
+ Request request = new Request.Bulider()
|
|
|
|
|
+ .setWhat(LOAD_ID)
|
|
|
|
|
+ .setUrl("common/getId.action")
|
|
|
|
|
+ .setParam(param)
|
|
|
|
|
+ .setMode(Request.Mode.GET)
|
|
|
|
|
+ .bulid();
|
|
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void getCodeByNet(Bundle bundle) {
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("type", 2);
|
|
|
|
|
+ param.put("caller", "VisitRecord");
|
|
|
|
|
+ Request request = new Request.Bulider()
|
|
|
|
|
+ .setWhat(LOAD_CODE)
|
|
|
|
|
+ .setUrl("common/getCodeString.action")
|
|
|
|
|
+ .setParam(param)
|
|
|
|
|
+ .setBundle(bundle)
|
|
|
|
|
+ .setMode(Request.Mode.GET)
|
|
|
|
|
+ .bulid();
|
|
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void loadBusinessChanceStage(Bundle bundle) {
|
|
|
|
|
+ String url = "mobile/crm/getBusinessChanceStage.action";
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put(" condition", "1=1");
|
|
|
|
|
+ Request request = new Request.Bulider()
|
|
|
|
|
+ .setWhat(LOAD_BUSINESS_CHANCESTAGE)
|
|
|
|
|
+ .setParam(param)
|
|
|
|
|
+ .setUrl(url)
|
|
|
|
|
+ .setBundle(bundle)
|
|
|
|
|
+ .bulid();
|
|
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void saveBusiness(Bundle bundle) {
|
|
|
|
|
+ String url = "crm/chance/saveBusinessChance.action";
|
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
|
+ param.put("caller", "BusinessChance");
|
|
|
|
|
+ param.put("formStore", StringUtils.mapToJson(getFormStore(bundle)));
|
|
|
|
|
+ Request request = new Request.Bulider()
|
|
|
|
|
+ .setWhat(SAVE_BUSINESS)
|
|
|
|
|
+ .setParam(param)
|
|
|
|
|
+ .setUrl(url)
|
|
|
|
|
+ .bulid();
|
|
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void saveContact(List<AddBusinessAdapter.Contact> contacts) {
|
|
|
|
|
+ List<Map<String, Object>> formStores = new ArrayList<>();
|
|
|
|
|
+ String cuname = company_tv.getText().toString();
|
|
|
|
|
+ String cuCode = (String) company_tv.getTag();
|
|
|
|
|
+ for (AddBusinessAdapter.Contact e : contacts) {
|
|
|
|
|
+ if (!StringUtils.isEmpty(e.name))
|
|
|
|
|
+ formStores.add(CommonInterface.getInstance().getFormStoreContact(e.name, e.phone, cuname, cuCode, ""));
|
|
|
|
|
+ }
|
|
|
|
|
+ CommonInterface.getInstance().addContact(formStores, this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void result(int what, boolean isJSON, String message, Bundle bundle) {
|
|
|
|
|
+ if (!isJSON) return;
|
|
|
|
|
+ JSONObject object = JSON.parseObject(message);
|
|
|
|
|
+ if (bundle == null) bundle = new Bundle();
|
|
|
|
|
+ switch (what) {
|
|
|
|
|
+ case LOAD_ID:
|
|
|
|
|
+ int id = OACheckUtil.getJsonIntager(object, "id");
|
|
|
|
|
+ bundle.putInt("bc_id", id);
|
|
|
|
|
+ getCodeByNet(bundle);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case LOAD_CODE://获取编号
|
|
|
|
|
+ String code = object.getString("code");
|
|
|
|
|
+ bundle.putString("bc_code", code);
|
|
|
|
|
+ loadBusinessChanceStage(bundle);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case SAVE_BUSINESS:
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ if (object.containsKey("success") && object.getBoolean("success")) {
|
|
|
|
|
+ ToastUtil.showToast(ct, R.string.save_success);
|
|
|
|
|
+ finish();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case LOAD_BUSINESS_CHANCESTAGE:
|
|
|
|
|
+ JSONArray stages = object.getJSONArray("stages");
|
|
|
|
|
+ String bs_name = "";
|
|
|
|
|
+ if (ListUtils.getSize(stages) > 0)
|
|
|
|
|
+ bs_name = stages.getJSONObject(0).getString("BS_NAME");
|
|
|
|
|
+ bundle.putString("BS_NAME", bs_name);
|
|
|
|
|
+ saveBusiness(bundle);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void error(int what, String message, Bundle bundle) {
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Map<String, Object> getFormStore(Bundle bundle) {
|
|
|
|
|
+ String bc_contact = "";
|
|
|
|
|
+ String bc_tel = "";
|
|
|
|
|
+ String bc_currentprocess = "";
|
|
|
|
|
+ String bc_code = "";
|
|
|
|
|
+ int bc_id = 0;
|
|
|
|
|
+ if (bundle != null) {
|
|
|
|
|
+ bc_id = bundle.getInt("bc_id");
|
|
|
|
|
+ bc_code = bundle.getString("bc_code");
|
|
|
|
|
+ bc_currentprocess = bundle.getString("BS_NAME");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (adapter != null && ListUtils.getSize(adapter.getContacts()) > 0) {
|
|
|
|
|
+ saveContact(adapter.getContacts());
|
|
|
|
|
+ AddBusinessAdapter.Contact contact = adapter.getContacts().get(0);
|
|
|
|
|
+ bc_contact = contact.name;
|
|
|
|
|
+ bc_tel = contact.phone;
|
|
|
|
|
+ }
|
|
|
|
|
+ String name = CommonUtil.getName();
|
|
|
|
|
+ String company = company_tv.getText().toString();
|
|
|
|
|
+ String address = company_tv.getText().toString();
|
|
|
|
|
+ String time = TimeUtils.f_long_2_str(System.currentTimeMillis());
|
|
|
|
|
+ Map<String, Object> formStore = new HashMap<>();
|
|
|
|
|
+ formStore.put("bc_id", bc_id);
|
|
|
|
|
+ formStore.put("bc_code", bc_code);
|
|
|
|
|
+ formStore.put("bc_doman", name);
|
|
|
|
|
+ formStore.put("bc_domancode", CommonUtil.getEmcode());
|
|
|
|
|
+ formStore.put("bc_statuscode", "AUDITED");
|
|
|
|
|
+ formStore.put("bc_status", getString(R.string.status_approved));
|
|
|
|
|
+ formStore.put("bc_recorder", name);
|
|
|
|
|
+ formStore.put("bc_recorddate", time);
|
|
|
|
|
+ formStore.put("bc_lastdate", time);
|
|
|
|
|
+ formStore.put("bc_description", company);
|
|
|
|
|
+ formStore.put("bc_custname", company);
|
|
|
|
|
+ formStore.put("bc_address", address);
|
|
|
|
|
+ formStore.put("bc_desc6", address);
|
|
|
|
|
+ if (latLng != null) {
|
|
|
|
|
+ formStore.put("bc_longitude", latLng.longitude);
|
|
|
|
|
+ formStore.put("bc_latitude", latLng.latitude);
|
|
|
|
|
+ }
|
|
|
|
|
+ formStore.put("bc_contact", bc_contact);
|
|
|
|
|
+ formStore.put("bc_tel", bc_tel);
|
|
|
|
|
+ formStore.put("bc_currentprocess", bc_currentprocess);
|
|
|
|
|
+ formStore.put("bc_remark", remark_tv.getText().toString());
|
|
|
|
|
+ formStore.put("bc_date7", TimeUtils.s_long_2_str(System.currentTimeMillis()));
|
|
|
|
|
+ formStore.put("bc_desc8", "");//成本金额
|
|
|
|
|
+ formStore.put("bc_desc4", "");//部门
|
|
|
|
|
+ formStore.put("bc_desc5", "");//岗位
|
|
|
|
|
+ formStore.put("bc_from", "");// 商机来源
|
|
|
|
|
+ formStore.put("bc_nichehouse", "");//商机库
|
|
|
|
|
+ return formStore;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|