|
|
@@ -31,8 +31,10 @@ import com.xzjmyk.pm.activity.audio.voicerecognition.JsonParser;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.adapter.DataInquiryFlexAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.adapter.DataInquirySchemeConditionAdapter;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.adapter.DataInquiryTotalAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.adapter.HistoricalRecordAdapter;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.bean.DataInquiryFlexBean;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.bean.DataInquiryTotalBean;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.bean.GridMenuDataInquiryBean;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.bean.SchemeConditionBean;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.database.HistoricalRecordBean;
|
|
|
@@ -70,7 +72,7 @@ import java.util.Map;
|
|
|
public class DataInquiryListActivity extends BaseActivity implements View.OnClickListener, TextView.OnEditorActionListener {
|
|
|
private final int GET_DATA_RESULT = 0X11;
|
|
|
private final int GET_QUERY_CRITERIA = 0X22;
|
|
|
- private ImageView mBackImageView, mFilterImageView, mVoiceImageView;
|
|
|
+ private ImageView mBackImageView, mFilterImageView, mVoiceImageView, mTotalHideImageView, mTotalSpreadImageView;
|
|
|
private ClearEditText mSearchEditText;
|
|
|
private GridMenuDataInquiryBean.QueryScheme mQueryScheme;
|
|
|
private String mCaller, mSchemeName, mSchemeId, mCondition;
|
|
|
@@ -80,8 +82,8 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
private LinearLayout mFuzzyHistoryLl;
|
|
|
private TextView mHistoryClearTv;
|
|
|
private MyListView mHistoryDataLv;
|
|
|
- private LinearLayout mExactWholeLl;
|
|
|
- private LinearLayout mExactOptionLl;
|
|
|
+ private ListView mTotalLv;
|
|
|
+ private LinearLayout mExactWholeLl, mExactOptionLl, mTotalLl;
|
|
|
private ListView mExactOptionLv;
|
|
|
private TextView mExactOptionCancelTv;
|
|
|
private TextView mExactOptionResetTv;
|
|
|
@@ -98,6 +100,9 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
private DataInquiryFlexAdapter mDataInquiryFlexAdapter;
|
|
|
private List<DataInquiryFlexBean.RowBean.RowChildBean> mAllRowChildBeans;
|
|
|
private EmptyLayout mEmptyLayout;
|
|
|
+ private int mOldPosition = -1;
|
|
|
+ private DataInquiryTotalAdapter mDataInquiryTotalAdapter;
|
|
|
+ private List<DataInquiryTotalBean> mDataInquiryTotalBeans;
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
@@ -106,245 +111,20 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
case GET_QUERY_CRITERIA:
|
|
|
if (mDataListView.isRefreshing())
|
|
|
mDataListView.onRefreshComplete();
|
|
|
- String result = msg.getData().getString("result");
|
|
|
- if (result != null) {
|
|
|
- LogUtil.prinlnLongMsg("querycriteria", msg.getData().getString("result"));
|
|
|
- try {
|
|
|
- JSONObject resultObject = new JSONObject(result);
|
|
|
- JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
- if (dataArray != null) {
|
|
|
- String fuzzyHint = "";
|
|
|
- for (int i = 0; i < dataArray.length(); i++) {
|
|
|
- JSONObject dataObject = dataArray.optJSONObject(i);
|
|
|
- if (dataObject != null) {
|
|
|
- SchemeConditionBean schemeConditionBean = new SchemeConditionBean();
|
|
|
- String position = optStringNotNull(dataObject, "position");
|
|
|
- String field = optStringNotNull(dataObject, "field");
|
|
|
- boolean appCondition = dataObject.optBoolean("appCondition");
|
|
|
- int width = (int) optLongNotNull(dataObject, "width");
|
|
|
- String caption = optStringNotNull(dataObject, "caption");
|
|
|
- String defaultValue = optStringNotNull(dataObject, "defaultValue");
|
|
|
- String type = optStringNotNull(dataObject, "type");
|
|
|
-
|
|
|
- if (appCondition && "S".equals(type)) {
|
|
|
- fuzzyHint = fuzzyHint + caption + "/";
|
|
|
- }
|
|
|
-
|
|
|
- if (!dataObject.isNull("properties")) {
|
|
|
- JSONArray properties = dataObject.optJSONArray("properties");
|
|
|
- if (properties != null) {
|
|
|
- List<SchemeConditionBean.Property> propertyList = new ArrayList<>();
|
|
|
- for (int j = 0; j < properties.length(); j++) {
|
|
|
- JSONObject propertyObject = properties.optJSONObject(j);
|
|
|
- SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
- String value = optStringNotNull(propertyObject, "value");
|
|
|
- String display = optStringNotNull(propertyObject, "display");
|
|
|
-
|
|
|
- property.setDisplay(display);
|
|
|
- property.setValue(value);
|
|
|
- property.setState(false);
|
|
|
-
|
|
|
- propertyList.add(property);
|
|
|
- }
|
|
|
- schemeConditionBean.setProperties(propertyList);
|
|
|
- }
|
|
|
- } else {
|
|
|
- ArrayList<SchemeConditionBean.Property> properties = new ArrayList<>();
|
|
|
- if ("N".equals(type)) {
|
|
|
- for (int m = 0; m < 2; m++) {
|
|
|
- SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
- properties.add(property);
|
|
|
- }
|
|
|
- } else if ("D".equals(type) || "CD".equals(type)) {
|
|
|
- for (int m = 0; m < 2; m++) {
|
|
|
- SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
- if (m == 0) {
|
|
|
- property.setDisplay(getMonthFirstDay());
|
|
|
- property.setValue(getMonthFirstDay());
|
|
|
- } else if (m == 1) {
|
|
|
- property.setDisplay(getMonthLastDay());
|
|
|
- property.setValue(getMonthLastDay());
|
|
|
- }
|
|
|
- properties.add(property);
|
|
|
- }
|
|
|
- } else if ("CBG".equals(type) || "EC".equals(type) || "C".equals(type) || "R".equals(type)) {
|
|
|
-
|
|
|
- } else {
|
|
|
- SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
- properties.add(property);
|
|
|
- }
|
|
|
- schemeConditionBean.setProperties(properties);
|
|
|
- }
|
|
|
-
|
|
|
- schemeConditionBean.setPosition(position);
|
|
|
- schemeConditionBean.setField(field);
|
|
|
- schemeConditionBean.setAppCondition(appCondition);
|
|
|
- schemeConditionBean.setWidth(width);
|
|
|
- schemeConditionBean.setCaption(caption);
|
|
|
- schemeConditionBean.setDefaultValue(defaultValue);
|
|
|
- schemeConditionBean.setType(type);
|
|
|
-
|
|
|
- mAllSchemeConditions.add(schemeConditionBean);
|
|
|
-
|
|
|
- if (schemeConditionBean.isAppCondition()) {
|
|
|
- mAppSchemeConditions.add(schemeConditionBean);
|
|
|
- if ("S".equals(type)) {
|
|
|
- mfuzzySchemeConditionBeans.add(schemeConditionBean);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Collections.sort(mAllSchemeConditions);
|
|
|
- Collections.sort(mAppSchemeConditions);
|
|
|
-
|
|
|
- try {
|
|
|
- mResetSchemeConditionBeans = deepCopy(mAppSchemeConditions);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (ClassNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- mDataInquirySchemeConditionAdapter.notifyDataSetChanged();
|
|
|
-
|
|
|
- if (fuzzyHint.length() > 0) {
|
|
|
- fuzzyHint = fuzzyHint.substring(0, fuzzyHint.length() - 1);
|
|
|
- mSearchEditText.setHint(fuzzyHint);
|
|
|
- } else {
|
|
|
- mSearchEditText.setHint("搜索");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ analysisCondition(msg);
|
|
|
getSchemeData();
|
|
|
break;
|
|
|
case GET_DATA_RESULT:
|
|
|
if (mDataListView.isRefreshing())
|
|
|
mDataListView.onRefreshComplete();
|
|
|
progressDialog.dismiss();
|
|
|
- result = msg.getData().getString("result");
|
|
|
- if (result != null) {
|
|
|
- if (mPageIndex == 1)
|
|
|
- mDataInquiryFlexBeans.clear();
|
|
|
- LogUtil.prinlnLongMsg("schemedata", msg.getData().getString("result"));
|
|
|
- try {
|
|
|
- JSONObject resultObject = new JSONObject(result);
|
|
|
- JSONArray listArray = resultObject.optJSONArray("listdata");
|
|
|
- if (listArray != null && listArray.length() > 0) {
|
|
|
- if (!TextUtils.isEmpty(mSearchField)) {
|
|
|
- HistoricalRecordBean historicalRecordBean = new HistoricalRecordBean();
|
|
|
- historicalRecordBean.setSchemeId(mSchemeId);
|
|
|
- historicalRecordBean.setSchemeName(mSchemeName);
|
|
|
- historicalRecordBean.setSearchField(mSearchField);
|
|
|
- HistoricalRecordDao.getInstance().saveToHistoricalRecord(historicalRecordBean);
|
|
|
-
|
|
|
- mHistoricalRecordBeans.clear();
|
|
|
- List<HistoricalRecordBean> historicalRecordBeansById = HistoricalRecordDao.getInstance().getHistoricalRecordBeansById(mSchemeId);
|
|
|
- if (historicalRecordBeansById.size() > 0) {
|
|
|
- for (int i = 0; i < historicalRecordBeansById.size(); i++) {
|
|
|
- if (i < 6) {
|
|
|
- mHistoricalRecordBeans.add(historicalRecordBeansById.get(i));
|
|
|
- }
|
|
|
- }
|
|
|
- mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (int i = 0; i < listArray.length(); i++) {
|
|
|
- mAllRowChildBeans = new ArrayList<>();
|
|
|
- JSONObject dataObject = listArray.optJSONObject(i);
|
|
|
- if (dataObject != null) {
|
|
|
- DataInquiryFlexBean dataInquiryFlexBean = new DataInquiryFlexBean();
|
|
|
- dataInquiryFlexBean.setIsFlex(false);
|
|
|
-
|
|
|
- List<DataInquiryFlexBean.RowBean> rowBeans = new ArrayList<>();
|
|
|
-
|
|
|
- for (int j = 0; j < mAllSchemeConditions.size(); j++) {
|
|
|
- String field = mAllSchemeConditions.get(j).getField();
|
|
|
- String type = mAllSchemeConditions.get(j).getType();
|
|
|
- String value = dataObject.getString(field);
|
|
|
- if (value != null) {
|
|
|
- DataInquiryFlexBean.RowBean.RowChildBean rowChildBean = new DataInquiryFlexBean.RowBean.RowChildBean();
|
|
|
- rowChildBean.setCaption(mAllSchemeConditions.get(j).getCaption());
|
|
|
- if ("null".equals(value)) {
|
|
|
- rowChildBean.setValue("");
|
|
|
- } else {
|
|
|
- if ("D".equals(type) || "CD".equals(type)) {
|
|
|
- value = value.substring(0, value.length() - 8);
|
|
|
- }
|
|
|
- rowChildBean.setValue(value);
|
|
|
- }
|
|
|
- rowChildBean.setWidth(mAllSchemeConditions.get(j).getWidth());
|
|
|
-
|
|
|
- mAllRowChildBeans.add(rowChildBean);
|
|
|
- }
|
|
|
- }
|
|
|
- List<DataInquiryFlexBean.RowBean.RowChildBean> shortChildBeans = new ArrayList<>();
|
|
|
- List<DataInquiryFlexBean.RowBean.RowChildBean> longChildBeans = new ArrayList<>();
|
|
|
- for (int k = 0; k < mAllRowChildBeans.size(); k++) {
|
|
|
- DataInquiryFlexBean.RowBean.RowChildBean rowChildBean = mAllRowChildBeans.get(k);
|
|
|
- if (rowChildBean.getWidth() <= 100) {
|
|
|
- shortChildBeans.add(rowChildBean);
|
|
|
- } else {
|
|
|
- longChildBeans.add(rowChildBean);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (int k = 0; k < (shortChildBeans.size() / 2); k++) {
|
|
|
- DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
-
|
|
|
- List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(shortChildBeans.get(k * 2));
|
|
|
- childBeans.add(shortChildBeans.get((k * 2) + 1));
|
|
|
-
|
|
|
- rowBean.setRowChildBeans(childBeans);
|
|
|
-
|
|
|
- rowBeans.add(rowBean);
|
|
|
- }
|
|
|
-
|
|
|
- if ((shortChildBeans.size() % 2) != 0) {
|
|
|
- DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
-
|
|
|
- List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(shortChildBeans.get(shortChildBeans.size() - 1));
|
|
|
-
|
|
|
- rowBean.setRowChildBeans(childBeans);
|
|
|
-
|
|
|
- rowBeans.add(rowBean);
|
|
|
- }
|
|
|
-
|
|
|
- for (int k = 0; k < longChildBeans.size(); k++) {
|
|
|
- DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
-
|
|
|
- List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
- childBeans.add(longChildBeans.get(k));
|
|
|
-
|
|
|
- rowBean.setRowChildBeans(childBeans);
|
|
|
-
|
|
|
- rowBeans.add(rowBean);
|
|
|
- }
|
|
|
-
|
|
|
- dataInquiryFlexBean.setRowBeans(rowBeans);
|
|
|
-
|
|
|
- mDataInquiryFlexBeans.add(dataInquiryFlexBean);
|
|
|
- }
|
|
|
- }
|
|
|
- mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
- } else {
|
|
|
- mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
- mEmptyLayout.showEmpty();
|
|
|
- }
|
|
|
-
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ analysisData(msg);
|
|
|
+ break;
|
|
|
+ case 0x88:
|
|
|
+ mTotalLl.setVisibility(View.GONE);
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ mTotalSpreadImageView.setVisibility(View.GONE);
|
|
|
if (mDataListView.isRefreshing())
|
|
|
mDataListView.onRefreshComplete();
|
|
|
progressDialog.dismiss();
|
|
|
@@ -423,6 +203,10 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mExactOptionCancelTv = (TextView) findViewById(R.id.data_inquiry_list_option_cancel_tv);
|
|
|
mExactOptionResetTv = (TextView) findViewById(R.id.data_inquiry_list_option_reset_tv);
|
|
|
mExactOptionConfirmTv = (TextView) findViewById(R.id.data_inquiry_list_option_confirm_tv);
|
|
|
+ mTotalLl = (LinearLayout) findViewById(R.id.data_inquiry_list_total_ll);
|
|
|
+ mTotalHideImageView = (ImageView) findViewById(R.id.data_inquiry_list_total_hide_iv);
|
|
|
+ mTotalSpreadImageView = (ImageView) findViewById(R.id.data_inquiry_list_total_spread_iv);
|
|
|
+ mTotalLv = (ListView) findViewById(R.id.data_inquiry_list_total_lv);
|
|
|
mFuzzyViewBg = findViewById(R.id.data_inquiry_list_fuzzy_bg);
|
|
|
mExactViewBg = findViewById(R.id.data_inquiry_list_exact_bg);
|
|
|
|
|
|
@@ -436,6 +220,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mResetSchemeConditionBeans = new ArrayList<>();
|
|
|
mDataInquiryFlexBeans = new ArrayList<>();
|
|
|
mAllRowChildBeans = new ArrayList<>();
|
|
|
+ mDataInquiryTotalBeans = new ArrayList<>();
|
|
|
mInAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popin);
|
|
|
mOutAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_search_popout);
|
|
|
|
|
|
@@ -451,6 +236,10 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mDataInquiryFlexAdapter = new DataInquiryFlexAdapter(this, mDataInquiryFlexBeans);
|
|
|
mDataListView.setAdapter(mDataInquiryFlexAdapter);
|
|
|
|
|
|
+ mDataInquiryTotalAdapter = new DataInquiryTotalAdapter(this, mDataInquiryTotalBeans);
|
|
|
+ mDataInquiryTotalAdapter.setHandler(mHandler);
|
|
|
+ mTotalLv.setAdapter(mDataInquiryTotalAdapter);
|
|
|
+
|
|
|
Intent intent = getIntent();
|
|
|
if (intent != null) {
|
|
|
mQueryScheme = (GridMenuDataInquiryBean.QueryScheme) intent.getSerializableExtra("scheme");
|
|
|
@@ -471,6 +260,22 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
|
|
|
mSearchEditText.setOnEditorActionListener(this);
|
|
|
|
|
|
+ mDataListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ int reallyPosition = (int) parent.getItemIdAtPosition(position);
|
|
|
+ if (CommonUtil.isRepeatClick()) {
|
|
|
+ if (mOldPosition == reallyPosition) {
|
|
|
+ mDataInquiryFlexAdapter.getObjects().get(reallyPosition).setIsFlex(!mDataInquiryFlexAdapter.getObjects().get(reallyPosition).isFlex());
|
|
|
+ mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ mOldPosition = reallyPosition;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mOldPosition = reallyPosition;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
mDataListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
@Override
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
@@ -561,33 +366,314 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mHistoryDataLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
- mHistoryDataLv.setEnabled(false);
|
|
|
- mSearchEditText.clearFocus();
|
|
|
HistoricalRecordBean historicalRecordBean = mHistoricalRecordAdapter.getObjects().get(position);
|
|
|
mSearchEditText.setText(historicalRecordBean.getSearchField());
|
|
|
- mSearchField = historicalRecordBean.getSearchField();
|
|
|
|
|
|
- if (!TextUtils.isEmpty(mSearchField)) {
|
|
|
- mCondition = "";
|
|
|
- for (int i = 0; i < mfuzzySchemeConditionBeans.size(); i++) {
|
|
|
- mCondition = mCondition + "(" + mfuzzySchemeConditionBeans.get(i).getField()
|
|
|
- + " like \'%" + mSearchField + "%\') or ";
|
|
|
+ searchEvent();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTotalHideImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (mTotalLl.getVisibility() == View.VISIBLE) {
|
|
|
+ mTotalLl.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ mTotalSpreadImageView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTotalSpreadImageView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ if (mTotalLl.getVisibility() == View.GONE) {
|
|
|
+ mTotalLl.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void analysisData(Message msg) {
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ if (result != null) {
|
|
|
+ mDataInquiryTotalBeans.clear();
|
|
|
+ if (mPageIndex == 1)
|
|
|
+ mDataInquiryFlexBeans.clear();
|
|
|
+ LogUtil.prinlnLongMsg("schemedata", msg.getData().getString("result"));
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(result);
|
|
|
+ JSONArray listArray = resultObject.optJSONArray("listdata");
|
|
|
+ JSONObject totalObject = resultObject.optJSONObject("summaryField");
|
|
|
+
|
|
|
+ if (totalObject != null) {
|
|
|
+ for (int j = 0; j < mAllSchemeConditions.size(); j++) {
|
|
|
+ String field = mAllSchemeConditions.get(j).getField();
|
|
|
+ String caption = mAllSchemeConditions.get(j).getCaption();
|
|
|
+
|
|
|
+ if (field != null) {
|
|
|
+ if (!totalObject.isNull(field)) {
|
|
|
+ DataInquiryTotalBean dataInquiryTotalBean = new DataInquiryTotalBean();
|
|
|
+ double total = totalObject.optDouble(field);
|
|
|
+ dataInquiryTotalBean.setCaption(caption);
|
|
|
+ dataInquiryTotalBean.setField(field);
|
|
|
+ dataInquiryTotalBean.setTotal(total);
|
|
|
+
|
|
|
+ mDataInquiryTotalBeans.add(dataInquiryTotalBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if (mCondition.length() >= 4) {
|
|
|
- mCondition = mCondition.substring(0, mCondition.length() - 4);
|
|
|
- mCondition = "(" + mCondition + ")";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mDataInquiryTotalBeans.size() > 0) {
|
|
|
+ mTotalLl.setVisibility(View.VISIBLE);
|
|
|
+ mTotalSpreadImageView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mTotalLl.setVisibility(View.GONE);
|
|
|
+ mTotalSpreadImageView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ mDataInquiryTotalAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ if (listArray != null && listArray.length() > 0) {
|
|
|
+ if (!TextUtils.isEmpty(mSearchField)) {
|
|
|
+ HistoricalRecordBean historicalRecordBean = new HistoricalRecordBean();
|
|
|
+ historicalRecordBean.setSchemeId(mSchemeId);
|
|
|
+ historicalRecordBean.setSchemeName(mSchemeName);
|
|
|
+ historicalRecordBean.setSearchField(mSearchField);
|
|
|
+ HistoricalRecordDao.getInstance().saveToHistoricalRecord(historicalRecordBean);
|
|
|
+
|
|
|
+ mHistoricalRecordBeans.clear();
|
|
|
+ List<HistoricalRecordBean> historicalRecordBeansById = HistoricalRecordDao.getInstance().getHistoricalRecordBeansById(mSchemeId);
|
|
|
+ if (historicalRecordBeansById.size() > 0) {
|
|
|
+ for (int i = 0; i < historicalRecordBeansById.size(); i++) {
|
|
|
+ if (i < 6) {
|
|
|
+ mHistoricalRecordBeans.add(historicalRecordBeansById.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
}
|
|
|
- Log.d("fuzzyCondition", mCondition);
|
|
|
|
|
|
- mPageIndex = 1;
|
|
|
- progressDialog.show();
|
|
|
- getSchemeData();
|
|
|
+ for (int i = 0; i < listArray.length(); i++) {
|
|
|
+ mAllRowChildBeans = new ArrayList<>();
|
|
|
+ JSONObject dataObject = listArray.optJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ DataInquiryFlexBean dataInquiryFlexBean = new DataInquiryFlexBean();
|
|
|
+ dataInquiryFlexBean.setIsFlex(false);
|
|
|
+
|
|
|
+ List<DataInquiryFlexBean.RowBean> rowBeans = new ArrayList<>();
|
|
|
+
|
|
|
+ for (int j = 0; j < mAllSchemeConditions.size(); j++) {
|
|
|
+ String field = mAllSchemeConditions.get(j).getField();
|
|
|
+ String type = mAllSchemeConditions.get(j).getType();
|
|
|
+ String caption = mAllSchemeConditions.get(j).getCaption();
|
|
|
+ String value = dataObject.getString(field);
|
|
|
+
|
|
|
+ if (value != null) {
|
|
|
+ DataInquiryFlexBean.RowBean.RowChildBean rowChildBean = new DataInquiryFlexBean.RowBean.RowChildBean();
|
|
|
+ rowChildBean.setCaption(caption);
|
|
|
+ if ("null".equals(value)) {
|
|
|
+ rowChildBean.setValue("");
|
|
|
+ } else {
|
|
|
+ if ("D".equals(type) || "CD".equals(type)) {
|
|
|
+ value = value.substring(0, value.length() - 8);
|
|
|
+ }
|
|
|
+ rowChildBean.setValue(value);
|
|
|
+ }
|
|
|
+ rowChildBean.setWidth(mAllSchemeConditions.get(j).getWidth());
|
|
|
+
|
|
|
+ mAllRowChildBeans.add(rowChildBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<DataInquiryFlexBean.RowBean.RowChildBean> shortChildBeans = new ArrayList<>();
|
|
|
+ List<DataInquiryFlexBean.RowBean.RowChildBean> longChildBeans = new ArrayList<>();
|
|
|
+ for (int k = 0; k < mAllRowChildBeans.size(); k++) {
|
|
|
+ DataInquiryFlexBean.RowBean.RowChildBean rowChildBean = mAllRowChildBeans.get(k);
|
|
|
+ if (rowChildBean.getWidth() <= 100) {
|
|
|
+ shortChildBeans.add(rowChildBean);
|
|
|
+ } else {
|
|
|
+ longChildBeans.add(rowChildBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int k = 0; k < (shortChildBeans.size() / 2); k++) {
|
|
|
+ DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
+
|
|
|
+ List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
+ childBeans.add(shortChildBeans.get(k * 2));
|
|
|
+ childBeans.add(shortChildBeans.get((k * 2) + 1));
|
|
|
+
|
|
|
+ rowBean.setRowChildBeans(childBeans);
|
|
|
+
|
|
|
+ rowBeans.add(rowBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((shortChildBeans.size() % 2) != 0) {
|
|
|
+ DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
+
|
|
|
+ List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
+ childBeans.add(shortChildBeans.get(shortChildBeans.size() - 1));
|
|
|
+
|
|
|
+ rowBean.setRowChildBeans(childBeans);
|
|
|
+
|
|
|
+ rowBeans.add(rowBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int k = 0; k < longChildBeans.size(); k++) {
|
|
|
+ DataInquiryFlexBean.RowBean rowBean = new DataInquiryFlexBean.RowBean();
|
|
|
+
|
|
|
+ List<DataInquiryFlexBean.RowBean.RowChildBean> childBeans = new ArrayList<>();
|
|
|
+ childBeans.add(longChildBeans.get(k));
|
|
|
+
|
|
|
+ rowBean.setRowChildBeans(childBeans);
|
|
|
+
|
|
|
+ rowBeans.add(rowBean);
|
|
|
+ }
|
|
|
+
|
|
|
+ dataInquiryFlexBean.setRowBeans(rowBeans);
|
|
|
+
|
|
|
+ mDataInquiryFlexBeans.add(dataInquiryFlexBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
}
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ mDataInquiryFlexAdapter.notifyDataSetChanged();
|
|
|
+ if (mDataInquiryFlexBeans.size() == 0)
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ private void analysisCondition(Message msg) {
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ if (result != null) {
|
|
|
+ LogUtil.prinlnLongMsg("querycriteria", msg.getData().getString("result"));
|
|
|
+ try {
|
|
|
+ JSONObject resultObject = new JSONObject(result);
|
|
|
+ JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
+ if (dataArray != null) {
|
|
|
+ String fuzzyHint = "";
|
|
|
+ for (int i = 0; i < dataArray.length(); i++) {
|
|
|
+ JSONObject dataObject = dataArray.optJSONObject(i);
|
|
|
+ if (dataObject != null) {
|
|
|
+ SchemeConditionBean schemeConditionBean = new SchemeConditionBean();
|
|
|
+ String position = optStringNotNull(dataObject, "position");
|
|
|
+ String field = optStringNotNull(dataObject, "field");
|
|
|
+ boolean appCondition = dataObject.optBoolean("appCondition");
|
|
|
+ int width = (int) optLongNotNull(dataObject, "width");
|
|
|
+ String caption = optStringNotNull(dataObject, "caption");
|
|
|
+ String defaultValue = optStringNotNull(dataObject, "defaultValue");
|
|
|
+ String type = optStringNotNull(dataObject, "type");
|
|
|
+ String table = optStringNotNull(dataObject, "table");
|
|
|
+
|
|
|
+ if (!dataObject.isNull("properties")) {
|
|
|
+ JSONArray properties = dataObject.optJSONArray("properties");
|
|
|
+ if (properties != null) {
|
|
|
+ List<SchemeConditionBean.Property> propertyList = new ArrayList<>();
|
|
|
+ for (int j = 0; j < properties.length(); j++) {
|
|
|
+ JSONObject propertyObject = properties.optJSONObject(j);
|
|
|
+ SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
+ String value = optStringNotNull(propertyObject, "value");
|
|
|
+ String display = optStringNotNull(propertyObject, "display");
|
|
|
+
|
|
|
+ property.setDisplay(display);
|
|
|
+ property.setValue(value);
|
|
|
+ property.setState(false);
|
|
|
+
|
|
|
+ propertyList.add(property);
|
|
|
+ }
|
|
|
+ schemeConditionBean.setProperties(propertyList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ArrayList<SchemeConditionBean.Property> properties = new ArrayList<>();
|
|
|
+ if ("N".equals(type)) {
|
|
|
+ for (int m = 0; m < 2; m++) {
|
|
|
+ SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
+ properties.add(property);
|
|
|
+ }
|
|
|
+ } else if ("D".equals(type) || "CD".equals(type)) {
|
|
|
+ for (int m = 0; m < 2; m++) {
|
|
|
+ SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
+ if (m == 0) {
|
|
|
+ property.setDisplay(getMonthFirstDay());
|
|
|
+ property.setValue(getMonthFirstDay());
|
|
|
+ } else if (m == 1) {
|
|
|
+ property.setDisplay(getMonthLastDay());
|
|
|
+ property.setValue(getMonthLastDay());
|
|
|
+ }
|
|
|
+ properties.add(property);
|
|
|
+ }
|
|
|
+ } else if ("CBG".equals(type) || "EC".equals(type) || "C".equals(type) || "R".equals(type)) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
+ property.setValue(defaultValue);
|
|
|
+ property.setDisplay(defaultValue);
|
|
|
+ properties.add(property);
|
|
|
+ }
|
|
|
+ schemeConditionBean.setProperties(properties);
|
|
|
+ }
|
|
|
+
|
|
|
+ schemeConditionBean.setPosition(position);
|
|
|
+ schemeConditionBean.setField(field);
|
|
|
+ schemeConditionBean.setAppCondition(appCondition);
|
|
|
+ schemeConditionBean.setWidth(width);
|
|
|
+ schemeConditionBean.setCaption(caption);
|
|
|
+ schemeConditionBean.setDefaultValue(defaultValue);
|
|
|
+ schemeConditionBean.setType(type);
|
|
|
+ schemeConditionBean.setTable(table);
|
|
|
+
|
|
|
+ mAllSchemeConditions.add(schemeConditionBean);
|
|
|
+
|
|
|
+ if (schemeConditionBean.isAppCondition()) {
|
|
|
+ mAppSchemeConditions.add(schemeConditionBean);
|
|
|
+ if ("S".equals(type)) {
|
|
|
+ mfuzzySchemeConditionBeans.add(schemeConditionBean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Collections.sort(mAllSchemeConditions);
|
|
|
+ Collections.sort(mAppSchemeConditions);
|
|
|
+
|
|
|
+ try {
|
|
|
+ mResetSchemeConditionBeans = deepCopy(mAppSchemeConditions);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ mDataInquirySchemeConditionAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ for (int i = 0; i < mAppSchemeConditions.size(); i++) {
|
|
|
+ if ("S".equals(mAppSchemeConditions.get(i).getType())) {
|
|
|
+ fuzzyHint = fuzzyHint + mAppSchemeConditions.get(i).getCaption() + "/";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fuzzyHint.length() > 0) {
|
|
|
+ fuzzyHint = fuzzyHint.substring(0, fuzzyHint.length() - 1);
|
|
|
+ mSearchEditText.setHint(fuzzyHint);
|
|
|
+ } else {
|
|
|
+ mSearchEditText.setHint("搜索");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()) {
|
|
|
@@ -655,23 +741,35 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
if ("N".equals(schemeConditionBean.getType()) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())
|
|
|
&& !TextUtils.isEmpty(schemeConditionBean.getProperties().get(1).getDisplay())) {
|
|
|
- mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " >= " + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
- + " and " + schemeConditionBean.getField()
|
|
|
+ + " and "
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " <= " + schemeConditionBean.getProperties().get(1).getDisplay() + ") and ";
|
|
|
|
|
|
} else if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())) {
|
|
|
- mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " >= " + schemeConditionBean.getProperties().get(0).getDisplay() + ") and ";
|
|
|
} else if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(1).getDisplay())) {
|
|
|
- mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " <= " + schemeConditionBean.getProperties().get(1).getDisplay() + ") and ";
|
|
|
}
|
|
|
|
|
|
} else if (("D".equals(schemeConditionBean.getType()) || "CD".equals(schemeConditionBean.getType())) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
- mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " >= to_date(\'" + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
- + "\',\'yyyy-MM-dd\') and " + schemeConditionBean.getField()
|
|
|
+ + "\',\'yyyy-MM-dd\') and "
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ " <= to_date(\'" + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
+ "\',\'yyyy-MM-dd\')) and ";
|
|
|
} else if ("CBG".equals(schemeConditionBean.getType()) || "C".equals(schemeConditionBean.getType())
|
|
|
@@ -681,7 +779,9 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
for (int j = 0; j < schemeConditionBean.getProperties().size(); j++) {
|
|
|
if (schemeConditionBean.getProperties().get(j).isState()) {
|
|
|
selectedCount++;
|
|
|
- gridCondition = gridCondition + schemeConditionBean.getField() + " = \'"
|
|
|
+ gridCondition = gridCondition
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField() + " = \'"
|
|
|
+ schemeConditionBean.getProperties().get(j).getValue() + "\' or ";
|
|
|
}
|
|
|
}
|
|
|
@@ -693,9 +793,11 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
} else {
|
|
|
if (schemeConditionBean.getProperties().size() == 1) {
|
|
|
if (!TextUtils.isEmpty(schemeConditionBean.getProperties().get(0).getDisplay())) {
|
|
|
- mCondition = mCondition + "(" + schemeConditionBean.getField()
|
|
|
- + " = \'" + schemeConditionBean.getProperties().get(0).getDisplay() + "\')"
|
|
|
- + " and ";
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ + " like \'%" + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
+ + "%\') and ";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -724,6 +826,8 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
String s = mSearchEditText.getText().toString() + CommonUtil.getPlaintext(text);
|
|
|
mSearchEditText.setText(s);
|
|
|
mSearchEditText.setSelection(s.length());
|
|
|
+
|
|
|
+ searchEvent();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -740,14 +844,27 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
if (actionId == EditorInfo.IME_ACTION_SEARCH
|
|
|
|| actionId == EditorInfo.IME_ACTION_SEND
|
|
|
|| (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
|
|
|
- if (!CommonUtil.isNetWorkConnected(this)) {
|
|
|
- ToastMessage(getString(R.string.networks_out));
|
|
|
- } else {
|
|
|
- String searchField = mSearchEditText.getText().toString().trim();
|
|
|
- if (!TextUtils.isEmpty(searchField)) {
|
|
|
+ searchEvent();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void searchEvent() {
|
|
|
+ if (!CommonUtil.isNetWorkConnected(this)) {
|
|
|
+ ToastMessage(getString(R.string.networks_out));
|
|
|
+ } else {
|
|
|
+ String searchField = mSearchEditText.getText().toString().trim();
|
|
|
+ if (!TextUtils.isEmpty(searchField)) {
|
|
|
+ if (mfuzzySchemeConditionBeans.size() == 0) {
|
|
|
+ ToastMessage("该方案没有可用于模糊查询的字段!");
|
|
|
+ mSearchEditText.setText("");
|
|
|
+ } else {
|
|
|
mCondition = "";
|
|
|
for (int i = 0; i < mfuzzySchemeConditionBeans.size(); i++) {
|
|
|
- mCondition = mCondition + "(" + mfuzzySchemeConditionBeans.get(i).getField()
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(mfuzzySchemeConditionBeans.get(i).getTable()) ? "" : (mfuzzySchemeConditionBeans.get(i).getTable() + "."))
|
|
|
+ + mfuzzySchemeConditionBeans.get(i).getField()
|
|
|
+ " like \'%" + searchField + "%\') or ";
|
|
|
}
|
|
|
if (mCondition.length() >= 4) {
|
|
|
@@ -756,22 +873,19 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
|
|
|
|
Log.d("fuzzyCondition", mCondition);
|
|
|
-
|
|
|
- } else {
|
|
|
- mCondition = "1 = 1";
|
|
|
}
|
|
|
- mPageIndex = 1;
|
|
|
- mSearchField = searchField;
|
|
|
- mSearchEditText.clearFocus();
|
|
|
- mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
- mHistoryDataLv.setEnabled(false);
|
|
|
- progressDialog.show();
|
|
|
- getSchemeData();
|
|
|
- }
|
|
|
|
|
|
- return true;
|
|
|
+ } else {
|
|
|
+ mCondition = "1 = 1";
|
|
|
+ }
|
|
|
+ mPageIndex = 1;
|
|
|
+ mSearchField = searchField;
|
|
|
+ mSearchEditText.clearFocus();
|
|
|
+ mFuzzyWholeLl.setVisibility(View.GONE);
|
|
|
+ mHistoryDataLv.setEnabled(false);
|
|
|
+ progressDialog.show();
|
|
|
+ getSchemeData();
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
private void getSchemeData() {
|