|
|
@@ -0,0 +1,225 @@
|
|
|
+package com.uas.appworks.activity.businessManage.businessDetailActivity;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.os.Bundle;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.common.LogUtil;
|
|
|
+import com.common.data.JSONUtil;
|
|
|
+import com.core.base.presenter.BaseMvpPresenter;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
+import com.me.network.app.base.HttpCallback;
|
|
|
+import com.me.network.app.base.HttpParams;
|
|
|
+import com.me.network.app.http.HttpRequest;
|
|
|
+import com.me.network.app.http.Method;
|
|
|
+import com.uas.appworks.model.bean.BusinessStageBean;
|
|
|
+import com.uas.appworks.model.bean.CommonFormBean;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author RaoMeng
|
|
|
+ * @describe
|
|
|
+ * @date 2018/9/18 14:09
|
|
|
+ */
|
|
|
+public class BusinessDetailPresenterImpl extends BaseMvpPresenter<BusinessDetailContract.BusinessDetailView>
|
|
|
+ implements BusinessDetailContract.BusinessDetailPresenter, HttpCallback {
|
|
|
+ public static final int REQUEST_BUSINESS_DETAIL = 744;
|
|
|
+ public static final int REQUEST_BUSINESS_STAGE = 745;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMvpAttachView(BusinessDetailContract.BusinessDetailView view, Bundle savedInstanceState) {
|
|
|
+ super.onMvpAttachView(view, savedInstanceState);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMvpResume() {
|
|
|
+ super.onMvpResume();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void requestMainDetail(Context context, int ID, String caller) {
|
|
|
+ getMvpView().showLoading("");
|
|
|
+ HttpRequest.getInstance().sendRequest(CommonUtil.getAppBaseUrl(context),
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url("mobile/getformandgriddetail.action")
|
|
|
+ .method(Method.GET)
|
|
|
+ .flag(REQUEST_BUSINESS_DETAIL)
|
|
|
+ .addParam("caller", caller)
|
|
|
+ .addParam("condition", "1=1")
|
|
|
+ .addParam("id", ID)
|
|
|
+ .addParam("sessionId", CommonUtil.getSharedPreferences(context, "sessionId"))
|
|
|
+ .addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(context, "sessionId"))
|
|
|
+ .build(), this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void requestStageList(Context context) {
|
|
|
+ getMvpView().showLoading("");
|
|
|
+
|
|
|
+ HttpRequest.getInstance().sendRequest(CommonUtil.getAppBaseUrl(context),
|
|
|
+ new HttpParams.Builder()
|
|
|
+ .url("mobile/crm/getBusinessChanceStage.action")
|
|
|
+ .flag(REQUEST_BUSINESS_STAGE)
|
|
|
+ .method(Method.POST)
|
|
|
+ .addParam("master", CommonUtil.getMaster())
|
|
|
+ .addParam("sessionId", CommonUtil.getSharedPreferences(context, "sessionId"))
|
|
|
+ .addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(context, "sessionId"))
|
|
|
+ .build(), this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(int flag, Object o) throws Exception {
|
|
|
+ getMvpView().hideLoading();
|
|
|
+ switch (flag) {
|
|
|
+ case REQUEST_BUSINESS_DETAIL:
|
|
|
+ try {
|
|
|
+ analysisBusinessDetail(o);
|
|
|
+ } catch (Exception e) {
|
|
|
+ getMvpView().requestMainDetailSucess(new ArrayList<CommonFormBean>(), new ArrayList<CommonFormBean>());
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case REQUEST_BUSINESS_STAGE:
|
|
|
+ try {
|
|
|
+ analysisBusinessStage(o);
|
|
|
+ } catch (Exception e) {
|
|
|
+ getMvpView().requestStageSuccess(new ArrayList<BusinessStageBean>());
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail(int flag, String failStr) throws Exception {
|
|
|
+ getMvpView().hideLoading();
|
|
|
+ LogUtil.prinlnLongMsg("raoDetailFail", failStr);
|
|
|
+ getMvpView().requestFail(flag, failStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void analysisBusinessStage(Object o) {
|
|
|
+ String result = o.toString();
|
|
|
+ List<BusinessStageBean> businessStageBeans = new ArrayList<>();
|
|
|
+ if (!JSONUtil.validate(result)) {
|
|
|
+ getMvpView().requestStageSuccess(businessStageBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ if (resultObject == null) {
|
|
|
+ getMvpView().requestStageSuccess(businessStageBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray stageArray = resultObject.getJSONArray("stages");
|
|
|
+ if (stageArray == null) {
|
|
|
+ getMvpView().requestStageSuccess(businessStageBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < stageArray.size(); i++) {
|
|
|
+ JSONObject stageObject = stageArray.getJSONObject(i);
|
|
|
+ if (stageObject != null) {
|
|
|
+ BusinessStageBean businessStageBean = new BusinessStageBean();
|
|
|
+ businessStageBean.setBS_ID(JSONUtil.getInt(stageObject, "BS_ID"));
|
|
|
+ businessStageBean.setBS_CODE(JSONUtil.getText(stageObject, "BS_CODE"));
|
|
|
+ businessStageBean.setBS_NAME(JSONUtil.getText(stageObject, "BS_NAME"));
|
|
|
+ businessStageBean.setBS_REMARK(JSONUtil.getText(stageObject, "BS_REMARK"));
|
|
|
+ businessStageBean.setBS_RELATIVEITEM(JSONUtil.getText(stageObject, "BS_RELATIVEITEM"));
|
|
|
+ businessStageBean.setBS_COLOR(JSONUtil.getText(stageObject, "BS_COLOR"));
|
|
|
+ businessStageBean.setBS_DETNO(JSONUtil.getInt(stageObject, "BS_DETNO"));
|
|
|
+ businessStageBean.setBS_DAYS(JSONUtil.getInt(stageObject, "BS_DAYS"));
|
|
|
+ businessStageBean.setBS_ACTIVEDATE(JSONUtil.getInt(stageObject, "BS_ACTIVEDATE"));
|
|
|
+ businessStageBean.setBS_POINT(JSONUtil.getText(stageObject, "BS_POINT"));
|
|
|
+ businessStageBean.setBS_POINTFLAG(JSONUtil.getText(stageObject, "BS_POINTFLAG"));
|
|
|
+ businessStageBean.setBS_POINTDETNO(JSONUtil.getText(stageObject, "BS_POINTDETNO"));
|
|
|
+ businessStageBean.setBS_CANTURNCUST(JSONUtil.getText(stageObject, "BS_CANTURNCUST"));
|
|
|
+ businessStageBean.setBS_TYPE(JSONUtil.getText(stageObject, "BS_TYPE"));
|
|
|
+ businessStageBean.setBS_ENDSTATUS(JSONUtil.getText(stageObject, "BS_ENDSTATUS"));
|
|
|
+ businessStageBean.setBS_ENDNODE(JSONUtil.getText(stageObject, "BS_ENDNODE"));
|
|
|
+ businessStageBean.setBS_EQUITYEDGE(JSONUtil.getText(stageObject, "BS_EQUITYEDGE"));
|
|
|
+
|
|
|
+ businessStageBeans.add(businessStageBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ getMvpView().requestStageSuccess(businessStageBeans);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void analysisBusinessDetail(Object o) {
|
|
|
+ String result = o.toString();
|
|
|
+ List<CommonFormBean> allFormBeans = new ArrayList<>();
|
|
|
+ List<CommonFormBean> visibleFormBeans = new ArrayList<>();
|
|
|
+ if (!JSONUtil.validate(result)) {
|
|
|
+ getMvpView().requestMainDetailSucess(allFormBeans, visibleFormBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject resultObject = JSON.parseObject(result);
|
|
|
+ if (resultObject == null) {
|
|
|
+ getMvpView().requestMainDetailSucess(allFormBeans, visibleFormBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
+ if (dataObject == null) {
|
|
|
+ getMvpView().requestMainDetailSucess(allFormBeans, visibleFormBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray formdetailArray = dataObject.getJSONArray("formdetail");
|
|
|
+ if (formdetailArray == null || formdetailArray.size() == 0) {
|
|
|
+ getMvpView().requestMainDetailSucess(allFormBeans, visibleFormBeans);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, List<CommonFormBean>> stringListMap = new LinkedHashMap<>();
|
|
|
+ for (int i = 0; i < formdetailArray.size(); i++) {
|
|
|
+ JSONObject formdetailObject = formdetailArray.getJSONObject(i);
|
|
|
+ if (formdetailObject != null) {
|
|
|
+ CommonFormBean commonFormBean = new CommonFormBean();
|
|
|
+
|
|
|
+ commonFormBean.setCaption(JSONUtil.getText(formdetailObject, "fd_caption"));
|
|
|
+ commonFormBean.setMcaption(JSONUtil.getText(formdetailObject, "mfd_caption"));
|
|
|
+ commonFormBean.setField(JSONUtil.getText(formdetailObject, "fd_field"));
|
|
|
+ commonFormBean.setValue(JSONUtil.getText(formdetailObject, "fd_value"));
|
|
|
+ commonFormBean.setMaxlength(JSONUtil.getInt(formdetailObject, "fd_maxlength"));
|
|
|
+ commonFormBean.setDetno(JSONUtil.getInt(formdetailObject, "fd_detno"));
|
|
|
+ commonFormBean.setType(JSONUtil.getText(formdetailObject, "fd_type"));
|
|
|
+ commonFormBean.setReadonly(JSONUtil.getText(formdetailObject, "fd_readonly"));
|
|
|
+ commonFormBean.setId(JSONUtil.getInt(formdetailObject, "fd_id"));
|
|
|
+ commonFormBean.setItemType(CommonFormBean.COMMON_FORM_CONTENT_ITEM);
|
|
|
+ int mfd_isdefault = JSONUtil.getInt(formdetailObject, "mfd_isdefault");
|
|
|
+ commonFormBean.setIsdefault(mfd_isdefault);
|
|
|
+ String fd_group = JSONUtil.getText(formdetailObject, "fd_group");
|
|
|
+ commonFormBean.setGroup(fd_group);
|
|
|
+
|
|
|
+ if (mfd_isdefault == -1) {
|
|
|
+ if (stringListMap.containsKey(fd_group)) {
|
|
|
+ List<CommonFormBean> cacheFormBeans = stringListMap.get(fd_group);
|
|
|
+ if (cacheFormBeans != null) {
|
|
|
+ cacheFormBeans.add(commonFormBean);
|
|
|
+ }
|
|
|
+ stringListMap.put(fd_group, cacheFormBeans);
|
|
|
+ } else {
|
|
|
+ List<CommonFormBean> mapFormBeans = new ArrayList<>();
|
|
|
+ mapFormBeans.add(commonFormBean);
|
|
|
+ stringListMap.put(fd_group, mapFormBeans);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ allFormBeans.add(commonFormBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Iterator<Map.Entry<String, List<CommonFormBean>>> iterator = stringListMap.entrySet().iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ Map.Entry<String, List<CommonFormBean>> next = iterator.next();
|
|
|
+ List<CommonFormBean> value = next.getValue();
|
|
|
+
|
|
|
+ CommonFormBean commonFormBean = new CommonFormBean();
|
|
|
+ commonFormBean.setItemType(CommonFormBean.COMMON_FORM_GRAY_LINE);
|
|
|
+ visibleFormBeans.add(commonFormBean);
|
|
|
+ visibleFormBeans.addAll(value);
|
|
|
+ }
|
|
|
+ getMvpView().requestMainDetailSucess(allFormBeans, visibleFormBeans);
|
|
|
+ }
|
|
|
+}
|