|
|
@@ -5,11 +5,13 @@ import android.os.Bundle;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baidu.mapapi.model.LatLng;
|
|
|
+import com.common.LogUtil;
|
|
|
import com.common.data.DateFormatUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
@@ -23,20 +25,26 @@ import com.core.net.http.http.OnHttpResultListener;
|
|
|
import com.core.net.http.http.Request;
|
|
|
import com.core.utils.CommonInterface;
|
|
|
import com.core.utils.CommonUtil;
|
|
|
-import com.core.utils.TimeUtils;
|
|
|
import com.core.utils.ToastUtil;
|
|
|
import com.core.utils.helper.PopupWindowHelper;
|
|
|
import com.core.widget.MyListView;
|
|
|
import com.core.widget.view.Activity.SelectActivity;
|
|
|
import com.core.widget.view.model.SelectAimModel;
|
|
|
+import com.me.network.app.http.HttpClient;
|
|
|
+import com.me.network.app.http.Method;
|
|
|
+import com.me.network.app.http.rx.Result2Listener;
|
|
|
+import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
import com.uas.appworks.CRM.erp.adapter.AddBusinessAdapter;
|
|
|
import com.uas.appworks.OA.erp.model.EmployeesModel;
|
|
|
import com.uas.appworks.R;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 创建商机
|
|
|
@@ -50,6 +58,10 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
private final int SAVE_BUSINESS = 0x763;
|
|
|
private final int LOAD_BUSINESS_CHANCESTAGE = 0x764;
|
|
|
private final int UPDATE_BUSINESS = 0x765;
|
|
|
+ private final int JUDGE_APPROVERS = 0x766;
|
|
|
+ private final int SEND_SELECT = 0x767;
|
|
|
+ private final int SELECT_APPROVERS = 0x768;
|
|
|
+
|
|
|
private TextView company_tv;
|
|
|
private TextView company_add_tv;
|
|
|
private TextView remark_tv;
|
|
|
@@ -120,23 +132,23 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
Intent intent = null;
|
|
|
- if (v.getId() == R.id.company_tv){
|
|
|
+ if (v.getId() == R.id.company_tv) {
|
|
|
intent = new Intent("com.modular.form.SelectAimActivity").putExtra("title", getString(R.string.select) + getString(R.string.Company_Name));
|
|
|
startActivityForResult(intent, SELECT_COMPANY);
|
|
|
- }else if (v.getId() == R.id.remark_tv){
|
|
|
+ } else if (v.getId() == R.id.remark_tv) {
|
|
|
startActivityForResult(new Intent(ct, SearchSelectActivity.class), AppConstant.RESULT_CODE);
|
|
|
- }else if (v.getId() == R.id.additem_tv){
|
|
|
+ } else if (v.getId() == R.id.additem_tv) {
|
|
|
adapter.getContacts().add(new EmployeesModel());
|
|
|
adapter.notifyDataSetChanged();
|
|
|
- }else if (v.getId() == R.id.submit_btn){
|
|
|
+ } else if (v.getId() == R.id.submit_btn) {
|
|
|
if (canSubmit()) {
|
|
|
if (isUpdata) updateBusiness();
|
|
|
else
|
|
|
getIdByNet();
|
|
|
}
|
|
|
- }else if (v.getId() == R.id.business_Library_tv){
|
|
|
+ } else if (v.getId() == R.id.business_Library_tv) {
|
|
|
loadBusiness();
|
|
|
- }else if (v.getId() == R.id.business_stage_tv){
|
|
|
+ } else if (v.getId() == R.id.business_stage_tv) {
|
|
|
loadJieDuan();
|
|
|
}
|
|
|
}
|
|
|
@@ -162,7 +174,12 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
- if (data == null) return;
|
|
|
+ if (data == null) {
|
|
|
+ if (requestCode == SEND_SELECT) {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
switch (requestCode) {
|
|
|
case SELECT_COMPANY:
|
|
|
SelectAimModel entity = data.getParcelableExtra("data");
|
|
|
@@ -200,6 +217,11 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
SelectBean businessStage = data.getParcelableExtra("data");
|
|
|
business_stage_tv.setText(businessStage.getName());
|
|
|
break;
|
|
|
+ case SEND_SELECT:
|
|
|
+ SelectBean b = data.getParcelableExtra("data");
|
|
|
+ String name = StringUtil.isEmpty(b.getName()) ? "" : b.getName();
|
|
|
+ getEmnameByReturn(name);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -289,15 +311,63 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
String url = "crm/chance/saveBusinessChance.action";
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
param.put("caller", "BusinessChance");
|
|
|
- param.put("formStore", JSONUtil.map2JSON(getFormStore(bundle)));
|
|
|
+ param.put("formStore", JSONUtil.map2JSON(getFormStore(false, bundle)));
|
|
|
Request request = new Request.Bulider()
|
|
|
.setWhat(SAVE_BUSINESS)
|
|
|
.setParam(param)
|
|
|
.setUrl(url)
|
|
|
+ .setBundle(bundle)
|
|
|
.bulid();
|
|
|
OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
}
|
|
|
|
|
|
+ private void submit(final int mBcId) {
|
|
|
+ if (mBcId <= 0) return;
|
|
|
+ HttpClient httpClient = new HttpClient.Builder(CommonUtil.getAppBaseUrl(ct)).isDebug(true)
|
|
|
+ .connectTimeout(5000)
|
|
|
+ .readTimeout(5000)
|
|
|
+ .build();
|
|
|
+ httpClient.Api().send(new HttpClient.Builder()
|
|
|
+ .url("crm/chance/submitBusinessChance.action")
|
|
|
+ .add("id", mBcId)
|
|
|
+ .add("caller", "BusinessChance")
|
|
|
+ .header("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(MyApplication.getInstance(), "sessionId"))
|
|
|
+ .add("master", CommonUtil.getSharedPreferences(ct, "erp_master"))
|
|
|
+ .add("sessionUser", CommonUtil.getSharedPreferences(ct, "erp_username"))
|
|
|
+ .add("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"))
|
|
|
+ .method(Method.POST)
|
|
|
+ .build(), new ResultSubscriber<>(new Result2Listener<Object>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(Object t) {
|
|
|
+ String message = t.toString();
|
|
|
+ LogUtil.i("message=" + message);
|
|
|
+ judgeApprovers(mBcId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(Object t) {
|
|
|
+ String message = t.toString();
|
|
|
+ ToastUtil.showToast(ct, message);
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void judgeApprovers(int mBcId) {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = "common/getMultiNodeAssigns.action";
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("caller", "BusinessChance");
|
|
|
+ param.put("id", mBcId);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ Request request = new Request.Bulider()
|
|
|
+ .setWhat(JUDGE_APPROVERS)
|
|
|
+ .setMode(Request.Mode.POST)
|
|
|
+ .setParam(param)
|
|
|
+ .setUrl(url)
|
|
|
+ .bulid();
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
+ }
|
|
|
|
|
|
private void updateBusiness() {
|
|
|
String url = "crm/chance/updateBusinessChance.action";
|
|
|
@@ -308,10 +378,30 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
bundle.putString("bc_code", bc_code);
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
param.put("caller", "BusinessChance");
|
|
|
- param.put("formStore", JSONUtil.map2JSON(getFormStore(bundle)));
|
|
|
+ param.put("formStore", JSONUtil.map2JSON(getFormStore(true, bundle)));
|
|
|
Request request = new Request.Bulider()
|
|
|
.setWhat(UPDATE_BUSINESS)
|
|
|
.setParam(param)
|
|
|
+ .setBundle(bundle)
|
|
|
+ .setUrl(url)
|
|
|
+ .bulid();
|
|
|
+ OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void selectApprovers(String emName) {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = "common/takeOverTask.action";
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("em_code", emName);
|
|
|
+ params.put("nodeId", noid);
|
|
|
+ param.put("_noc", 1);
|
|
|
+ param.put("params", JSONUtil.map2JSON(params));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ Request request = new Request.Bulider()
|
|
|
+ .setWhat(SELECT_APPROVERS)
|
|
|
+ .setParam(param)
|
|
|
.setUrl(url)
|
|
|
.bulid();
|
|
|
OAHttpHelper.getInstance().requestHttp(request, this);
|
|
|
@@ -350,7 +440,11 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
progressDialog.dismiss();
|
|
|
if (object.containsKey("success") && object.getBoolean("success")) {
|
|
|
ToastUtil.showToast(ct, R.string.save_success);
|
|
|
- finish();
|
|
|
+// finish();
|
|
|
+ }
|
|
|
+ if (bundle != null) {
|
|
|
+ int bc_id = bundle.getInt("bc_id");
|
|
|
+ submit(bc_id);
|
|
|
}
|
|
|
break;
|
|
|
case LOAD_BUSINESS_CHANCESTAGE:
|
|
|
@@ -361,6 +455,14 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
bundle.putString("BS_NAME", bs_name);
|
|
|
saveBusiness(bundle);
|
|
|
break;
|
|
|
+ case JUDGE_APPROVERS:
|
|
|
+ handlerAssigns(object);
|
|
|
+ break;
|
|
|
+ case SELECT_APPROVERS:
|
|
|
+ progressDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ Toast.makeText(MyApplication.getInstance(), R.string.submit_success, Toast.LENGTH_SHORT).show();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -371,7 +473,7 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
- public Map<String, Object> getFormStore(Bundle bundle) {
|
|
|
+ public Map<String, Object> getFormStore(boolean update, Bundle bundle) {
|
|
|
String bc_contact = "";
|
|
|
String bc_tel = "";
|
|
|
String bc_currentprocess = "";
|
|
|
@@ -393,15 +495,21 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
String name = CommonUtil.getName();
|
|
|
String company = company_tv.getText().toString();
|
|
|
String address = company_add_tv.getText().toString();
|
|
|
- String time = TimeUtils.f_long_2_str(System.currentTimeMillis());
|
|
|
+ String time = DateFormatUtil.long2Str(DateFormatUtil.YMD_HMS);
|
|
|
+ String status = "在录入";
|
|
|
+ String statusCode = "ENTERING";
|
|
|
+// if (update){
|
|
|
+// status="已审核";
|
|
|
+// statusCode="COMMITED";
|
|
|
+// }
|
|
|
Map<String, Object> formStore = new HashMap<>();
|
|
|
formStore.put("bc_id", bc_id);
|
|
|
formStore.put("bc_code", bc_code);
|
|
|
// formStore.put("bc_custcode", "");
|
|
|
formStore.put("bc_doman", StringUtil.toHttpString(name));
|
|
|
formStore.put("bc_domancode", CommonUtil.getEmcode());
|
|
|
- formStore.put("bc_statuscode", "AUDITED");
|
|
|
- formStore.put("bc_status", "已审核");
|
|
|
+ formStore.put("bc_statuscode", statusCode);
|
|
|
+ formStore.put("bc_status", status);
|
|
|
formStore.put("bc_recorder", name);
|
|
|
formStore.put("bc_recorddate", time);
|
|
|
formStore.put("bc_lastdate", time);
|
|
|
@@ -426,5 +534,67 @@ public class AddBusinessActivity extends OABaseActivity implements View.OnClickL
|
|
|
return formStore;
|
|
|
}
|
|
|
|
|
|
+ private void handlerAssigns(JSONObject object) {
|
|
|
+ JSONArray assigns = JSONUtil.getJSONArray(object, "assigns");
|
|
|
+ if (!ListUtils.isEmpty(assigns)) {
|
|
|
+ JSONObject o = assigns.getJSONObject(0);
|
|
|
+ String noid = "";
|
|
|
+ if (o != null && o.containsKey("JP_NODEID")) {
|
|
|
+ noid = o.getString("JP_NODEID");
|
|
|
+ }
|
|
|
+ JSONArray data = null;
|
|
|
+ if (o != null && o.containsKey("JP_CANDIDATES")) {
|
|
|
+ data = o.getJSONArray("JP_CANDIDATES");
|
|
|
+ }
|
|
|
+ if (!StringUtil.isEmpty(noid) && data != null && data.size() > 0) {
|
|
|
+ sendToSelect(noid, data);
|
|
|
+ } else {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String noid;
|
|
|
|
|
|
+ private void sendToSelect(String noid, JSONArray data) {
|
|
|
+ this.noid = noid;
|
|
|
+ ArrayList<SelectBean> beans = new ArrayList<>();
|
|
|
+ SelectBean bean = null;
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ bean = new SelectBean();
|
|
|
+ bean.setName(data.getString(i));
|
|
|
+ bean.setClick(false);
|
|
|
+ beans.add(bean);
|
|
|
+ }
|
|
|
+ Intent intent = new Intent(ct, SelectActivity.class);
|
|
|
+ intent.putExtra("type", 2);
|
|
|
+ intent.putParcelableArrayListExtra("data", beans);
|
|
|
+ intent.putExtra("title", getString(R.string.select_approvel_people));
|
|
|
+ startActivityForResult(intent, SEND_SELECT);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getEmnameByReturn(String text) {
|
|
|
+ if (StringUtil.isEmpty(text)) {
|
|
|
+ finish();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Pattern pattern = Pattern.compile("(?<=\\()(.+?)(?=\\))");
|
|
|
+ Matcher matcher = pattern.matcher(text);
|
|
|
+ if (matcher.find()) {
|
|
|
+ String name = matcher.group();
|
|
|
+ if (!StringUtil.isEmpty(name)) {
|
|
|
+ selectApprovers(name);
|
|
|
+ } else {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|