|
|
@@ -105,15 +105,18 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
private int mOldPosition = -1;
|
|
|
private DataInquiryTotalAdapter mDataInquiryTotalAdapter;
|
|
|
private List<DataInquiryTotalBean> mDataInquiryTotalBeans;
|
|
|
+ private boolean isConditionSuccess = false;
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
case GET_QUERY_CRITERIA:
|
|
|
+ isConditionSuccess = true;
|
|
|
if (mDataListView.isRefreshing())
|
|
|
mDataListView.onRefreshComplete();
|
|
|
- analysisCondition(msg);
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ analysisCondition(result);
|
|
|
getSchemeData();
|
|
|
break;
|
|
|
case GET_DATA_RESULT:
|
|
|
@@ -167,7 +170,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
|
mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -176,16 +179,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
mEmptyLayout.showError();
|
|
|
} else {
|
|
|
- if (mQueryScheme != null) {
|
|
|
- progressDialog.show();
|
|
|
- String url = CommonUtil.getAppBaseUrl(this) + "mobile/qry/schemeCondition.action";
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("caller", mQueryScheme.getCaller());
|
|
|
- params.put("id", mQueryScheme.getSchemeId());
|
|
|
- LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
- headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
- ViewUtil.httpSendRequest(this, url, params, mHandler, headers, GET_QUERY_CRITERIA, null, null, "post");
|
|
|
- }
|
|
|
+ getQueryCriteria();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -291,8 +285,17 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
if (CommonUtil.isNetWorkConnected(DataInquiryListActivity.this)) {
|
|
|
mPageIndex = 1;
|
|
|
- getSchemeData();
|
|
|
+ if (isConditionSuccess)
|
|
|
+ getSchemeData();
|
|
|
+ else
|
|
|
+ getQueryCriteria();
|
|
|
} else {
|
|
|
+ mDataListView.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mDataListView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ },500);
|
|
|
mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
mEmptyLayout.showError();
|
|
|
}
|
|
|
@@ -301,11 +304,23 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
@Override
|
|
|
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
if (!CommonUtil.isNetWorkConnected(DataInquiryListActivity.this)) {
|
|
|
+ mDataListView.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mDataListView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ },500);
|
|
|
mEmptyLayout.setErrorMessage(getString(R.string.networks_out));
|
|
|
mEmptyLayout.showError();
|
|
|
} else {
|
|
|
- mPageIndex++;
|
|
|
- getSchemeData();
|
|
|
+ if (isConditionSuccess) {
|
|
|
+ mPageIndex++;
|
|
|
+ getSchemeData();
|
|
|
+ } else {
|
|
|
+ mPageIndex = 1;
|
|
|
+ getQueryCriteria();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -426,6 +441,9 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
JSONArray listArray = resultObject.optJSONArray("listdata");
|
|
|
JSONObject totalObject = resultObject.optJSONObject("summaryField");
|
|
|
|
|
|
+ if ((listArray == null || listArray.length() < mPagesize) && mPageIndex > 1) {
|
|
|
+ ToastMessage("已加载全部数据");
|
|
|
+ }
|
|
|
if (totalObject != null) {
|
|
|
for (int j = 0; j < mAllSchemeConditions.size(); j++) {
|
|
|
String field = mAllSchemeConditions.get(j).getField();
|
|
|
@@ -478,7 +496,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
|
mHistoricalRecordAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
@@ -504,7 +522,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
if ("null".equals(value)) {
|
|
|
rowChildBean.setValue("");
|
|
|
} else {
|
|
|
- if ("D".equals(type) || "CD".equals(type)) {
|
|
|
+ if (("D".equals(type) || "CD".equals(type)) && value.length() > 8) {
|
|
|
value = value.substring(0, value.length() - 8);
|
|
|
}
|
|
|
rowChildBean.setValue(value);
|
|
|
@@ -579,10 +597,9 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void analysisCondition(Message msg) {
|
|
|
- String result = msg.getData().getString("result");
|
|
|
+ private void analysisCondition(String result) {
|
|
|
if (result != null) {
|
|
|
- LogUtil.prinlnLongMsg("querycriteria", msg.getData().getString("result"));
|
|
|
+ LogUtil.prinlnLongMsg("querycriteria", result);
|
|
|
try {
|
|
|
JSONObject resultObject = new JSONObject(result);
|
|
|
JSONArray dataArray = resultObject.optJSONArray("data");
|
|
|
@@ -626,15 +643,25 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
properties.add(property);
|
|
|
}
|
|
|
- } else if ("D".equals(type) || "CD".equals(type)) {
|
|
|
+ } else if ("D".equals(type) || "CD".equals(type) || "YM".equals(type) || "YMV".equals(type)) {
|
|
|
for (int m = 0; m < 2; m++) {
|
|
|
SchemeConditionBean.Property property = new SchemeConditionBean.Property();
|
|
|
if (m == 0) {
|
|
|
- property.setDisplay(getMonthFirstDay());
|
|
|
- property.setValue(getMonthFirstDay());
|
|
|
+ if ("YM".equals(type) || "YMV".equals(type)) {
|
|
|
+ property.setDisplay(getMonthFirstDay("yyyyMM"));
|
|
|
+ property.setValue(getMonthFirstDay("yyyyMM"));
|
|
|
+ } else {
|
|
|
+ property.setDisplay(getMonthFirstDay("yyyy-MM-dd"));
|
|
|
+ property.setValue(getMonthFirstDay("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
} else if (m == 1) {
|
|
|
- property.setDisplay(getMonthLastDay());
|
|
|
- property.setValue(getMonthLastDay());
|
|
|
+ if ("YM".equals(type) || "YMV".equals(type)) {
|
|
|
+ property.setDisplay(getMonthLastDay("yyyyMM"));
|
|
|
+ property.setValue(getMonthLastDay("yyyyMM"));
|
|
|
+ } else {
|
|
|
+ property.setDisplay(getMonthLastDay("yyyy-MM-dd"));
|
|
|
+ property.setValue(getMonthLastDay("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
}
|
|
|
properties.add(property);
|
|
|
}
|
|
|
@@ -801,6 +828,24 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
+ schemeConditionBean.getField()
|
|
|
+ " <= to_date(\'" + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
+ "\',\'yyyy-MM-dd\')) and ";
|
|
|
+ } else if ("YMV".equals(schemeConditionBean.getType()) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
+ mCondition = mCondition + "(ym_view_param.set_from("
|
|
|
+ + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
+ + ") = " + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
+ + " and ym_view_param.set_to("
|
|
|
+ + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
+ + ") = " + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
+ + ") and ";
|
|
|
+ } else if ("YM".equals(schemeConditionBean.getType()) && schemeConditionBean.getProperties().size() == 2) {
|
|
|
+ mCondition = mCondition + "("
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ + " >= \'" + schemeConditionBean.getProperties().get(0).getDisplay()
|
|
|
+ + "\' and "
|
|
|
+ + (TextUtils.isEmpty(schemeConditionBean.getTable()) ? "" : (schemeConditionBean.getTable() + "."))
|
|
|
+ + schemeConditionBean.getField()
|
|
|
+ + " <= \'" + schemeConditionBean.getProperties().get(1).getDisplay()
|
|
|
+ + "\') and ";
|
|
|
} else if ("CBG".equals(schemeConditionBean.getType()) || "C".equals(schemeConditionBean.getType())
|
|
|
|| "R".equals(schemeConditionBean.getType()) || "EC".equals(schemeConditionBean.getType())) {
|
|
|
String gridCondition = "";
|
|
|
@@ -886,7 +931,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
String searchField = mSearchEditText.getText().toString().trim();
|
|
|
if (!TextUtils.isEmpty(searchField)) {
|
|
|
if (mfuzzySchemeConditionBeans.size() == 0) {
|
|
|
- ToastMessage("该方案没有可用于模糊查询的字段!");
|
|
|
+ ToastMessage("请前往系统配置模糊搜索字段,或尝试高级查询方式");
|
|
|
mSearchEditText.setText("");
|
|
|
} else {
|
|
|
mCondition = "";
|
|
|
@@ -917,6 +962,19 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void getQueryCriteria() {
|
|
|
+ if (mQueryScheme != null) {
|
|
|
+ progressDialog.show();
|
|
|
+ String url = CommonUtil.getAppBaseUrl(this) + "mobile/qry/schemeCondition.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("caller", mQueryScheme.getCaller());
|
|
|
+ params.put("id", mQueryScheme.getSchemeId());
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(this, url, params, mHandler, headers, GET_QUERY_CRITERIA, null, null, "post");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void getSchemeData() {
|
|
|
String url = CommonUtil.getAppBaseUrl(this) + "mobile/qry/schemeResult.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -961,25 +1019,25 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
|
|
|
/**
|
|
|
* 得到本月的第一天
|
|
|
*/
|
|
|
- public static String getMonthFirstDay() {
|
|
|
+ public static String getMonthFirstDay(String pattern) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar
|
|
|
.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
// calendar.set( Calendar.DATE, 1);
|
|
|
- SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat simpleFormate = new SimpleDateFormat(pattern);
|
|
|
return simpleFormate.format(calendar.getTime());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 得到本月的最后一天
|
|
|
*/
|
|
|
- public static String getMonthLastDay() {
|
|
|
+ public static String getMonthLastDay(String pattern) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar
|
|
|
.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
// calendar.set( Calendar.DATE, 1);
|
|
|
// calendar.roll(Calendar.DATE, - 1);
|
|
|
- SimpleDateFormat simpleFormate = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat simpleFormate = new SimpleDateFormat(pattern);
|
|
|
return simpleFormate.format(calendar.getTime());
|
|
|
}
|
|
|
|