Просмотр исходного кода

数据查询,YM和YMV类型字段处理

raomeng 8 лет назад
Родитель
Сommit
783f5d223c

+ 41 - 13
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/datainquiry/activity/DataInquiryListActivity.java

@@ -167,7 +167,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
                 }
                 mHistoricalRecordAdapter.notifyDataSetChanged();
             }
-        }catch (Exception e){
+        } catch (Exception e) {
 
         }
 
@@ -478,7 +478,7 @@ public class DataInquiryListActivity extends BaseActivity implements View.OnClic
                                 }
                                 mHistoricalRecordAdapter.notifyDataSetChanged();
                             }
-                        }catch (Exception e){
+                        } catch (Exception e) {
 
                         }
                     }
@@ -504,7 +504,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);
@@ -626,15 +626,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 +811,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 +914,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 = "";
@@ -961,25 +989,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());
     }
 

+ 4 - 1
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/datainquiry/activity/PDFDownloadActivity.java

@@ -214,7 +214,10 @@ public class PDFDownloadActivity extends BaseActivity implements View.OnClickLis
 
     @Override
     public void onError(Throwable t) {
-
+        mErrorLinearLayout.setVisibility(View.VISIBLE);
+        mStateTextView.setText("报表文件加载失败!");
+        mDownloadProgressBar.setProgress(0);
+        mRemainTextView.setText(100 + "");
     }
 
     @Override

+ 42 - 16
WeiChat/src/main/java/com/xzjmyk/pm/activity/ui/erp/activity/datainquiry/adapter/DataInquirySchemeConditionAdapter.java

@@ -3,6 +3,7 @@ package com.xzjmyk.pm.activity.ui.erp.activity.datainquiry.adapter;
 import android.app.Activity;
 import android.content.Context;
 import android.text.Editable;
+import android.text.TextUtils;
 import android.text.TextWatcher;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -180,12 +181,15 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
                 break;
             case "D":
             case "CD":
+            case "YM":
+            case "YMV":
                 holder.stringEdittext.setVisibility(View.GONE);
                 holder.numEdittextLl.setVisibility(View.GONE);
                 holder.textviewLl.setVisibility(View.VISIBLE);
                 holder.gridview.setVisibility(View.GONE);
 
                 mProperties = object.getProperties();
+                String type = object.getType();
 
                 if (mProperties != null && mProperties.size() == 2) {
                     holder.textview1.setText(mProperties.get(0).getDisplay());
@@ -197,10 +201,12 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
                     public void onClick(View v) {
                         String time1 = holder.textview1.getText().toString();
                         String[] times1 = time1.split("-");
-                        if (times1.length >= 3) {
-                            showDateDialog(times1[0], times1[1], times1[2], holder.textview1, object, 0);
+                        if (("YM".equals(type) || "YMV".equals(type)) && time1.length() == 6) {
+                            showDateDialog(time1.substring(0, 4), time1.substring(4, 6), null, holder.textview1, type, object, 0);
+                        } else if (times1.length >= 3) {
+                            showDateDialog(times1[0], times1[1], times1[2], holder.textview1, type, object, 0);
                         } else {
-                            showDateDialog(null, null, null, holder.textview1, object, 0);
+                            showDateDialog(null, null, null, holder.textview1, type, object, 0);
                         }
                     }
                 });
@@ -210,10 +216,12 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
                     public void onClick(View v) {
                         String time2 = holder.textview2.getText().toString();
                         String[] times2 = time2.split("-");
-                        if (times2.length >= 3) {
-                            showDateDialog(times2[0], times2[1], times2[2], holder.textview2, object, 1);
+                        if (("YM".equals(type) || "YMV".equals(type)) && time2.length() == 6) {
+                            showDateDialog(time2.substring(0, 4), time2.substring(4, 6), null, holder.textview2, type, object, 1);
+                        } else if (times2.length >= 3) {
+                            showDateDialog(times2[0], times2[1], times2[2], holder.textview2, type, object, 1);
                         } else {
-                            showDateDialog(null, null, null, holder.textview2, object, 1);
+                            showDateDialog(null, null, null, holder.textview2, type, object, 1);
                         }
                     }
                 });
@@ -223,10 +231,12 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
                     public void onClick(View v) {
                         String time1 = holder.textview1.getText().toString();
                         String[] times1 = time1.split("-");
-                        if (times1.length >= 3) {
-                            showDateDialog(times1[0], times1[1], times1[2], holder.textview1, object, 0);
+                        if (("YM".equals(type) || "YMV".equals(type)) && time1.length() == 6) {
+                            showDateDialog(time1.substring(0, 4), time1.substring(4, 6), null, holder.textview1, type, object, 0);
+                        } else if (times1.length >= 3) {
+                            showDateDialog(times1[0], times1[1], times1[2], holder.textview1, type, object, 0);
                         } else {
-                            showDateDialog(null, null, null, holder.textview1, object, 0);
+                            showDateDialog(null, null, null, holder.textview1, type, object, 0);
                         }
                     }
                 });
@@ -236,10 +246,12 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
                     public void onClick(View v) {
                         String time2 = holder.textview2.getText().toString();
                         String[] times2 = time2.split("-");
-                        if (times2.length >= 3) {
-                            showDateDialog(times2[0], times2[1], times2[2], holder.textview2, object, 1);
+                        if (("YM".equals(type) || "YMV".equals(type)) && time2.length() == 6) {
+                            showDateDialog(time2.substring(0, 4), time2.substring(4, 6), null, holder.textview2, type, object, 1);
+                        } else if (times2.length >= 3) {
+                            showDateDialog(times2[0], times2[1], times2[2], holder.textview2, type, object, 1);
                         } else {
-                            showDateDialog(null, null, null, holder.textview2, object, 1);
+                            showDateDialog(null, null, null, holder.textview2, type, object, 1);
                         }
                     }
                 });
@@ -369,18 +381,32 @@ public class DataInquirySchemeConditionAdapter extends BaseAdapter {
         }
     }
 
-    private void showDateDialog(String year, String month, String day, final TextView tv, SchemeConditionBean object, int i) {
-        OASigninPicker picker = new OASigninPicker((Activity) context, 2000, 2030);
+    private void showDateDialog(String year, String month, String day, final TextView tv, String type, SchemeConditionBean object, int i) {
+        boolean haveDay = true;
+        if (("YM".equals(type) || "YMV".equals(type))) {
+            haveDay = false;
+        }
+        OASigninPicker picker = new OASigninPicker((Activity) context, 2000, 2030, haveDay);
         picker.setRange(2030, 12, 31);
         try {
-            picker.setSelectedItem(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
+            if (haveDay && !TextUtils.isEmpty(day))
+                picker.setSelectedItem(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
+            else
+                picker.setSelectedItem(Integer.parseInt(year), Integer.parseInt(month));
         } catch (Exception e) {
-            picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay());
+            if (haveDay)
+                picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth(), CalendarUtil.getDay());
+            else
+                picker.setSelectedItem(CalendarUtil.getYear(), CalendarUtil.getMonth());
         }
+
         picker.setOnDateTimePickListener(new OASigninPicker.OnDateTimePickListener() {
             @Override
             public void setTime(String year, String month, String day) {
                 String time = year + "-" + month + "-" + day;
+                if (TextUtils.isEmpty(day)) {
+                    time = year + month;
+                }
                 tv.setText(time);
                 if (object.getProperties().size() == 2) {
                     object.getProperties().get(i).setDisplay(time);

+ 60 - 26
WeiChat/src/main/java/com/xzjmyk/pm/activity/view/wheel/OASigninPicker.java

@@ -32,6 +32,7 @@ public class OASigninPicker extends WheelPicker {
     private int selectedYearIndex = 0, selectedMonthIndex = 0, selectedDayIndex = 0;
     private OnDateTimePickListener onDateTimePickListener;
     private int year, month, day = 0;
+    private boolean mHaveDay = true;
 
     @IntDef(flag = false, value = {YEAR_MONTH_DAY})
     @Retention(RetentionPolicy.SOURCE)
@@ -66,6 +67,22 @@ public class OASigninPicker extends WheelPicker {
         }
     }
 
+    public OASigninPicker(Activity activity, int startYear, int endYear, boolean haveDay) {
+        super(activity);
+        mHaveDay = haveDay;
+        textSize = 16;//年月日时分,比较宽,设置字体小一点才能显示完整
+        for (int i = startYear; i <= endYear; i++) {
+            years.add(String.valueOf(i));
+        }
+        for (int i = 1; i <= 12; i++) {
+            months.add(DateUtils.fillZero(i));
+        }
+        if (haveDay)
+            for (int i = 1; i <= 31; i++) {
+                days.add(DateUtils.fillZero(i));
+            }
+    }
+
     @NonNull
     @Override
     protected View makeCenterView() {
@@ -121,7 +138,10 @@ public class OASigninPicker extends WheelPicker {
         if (!TextUtils.isEmpty(dayLabel)) {
             dayTextView.setText(dayLabel);
         }
-        layout.addView(dayTextView);
+        if (mHaveDay) {
+            layout.addView(dayTextView);
+        }
+
         yearView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
             @Override
             public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
@@ -139,15 +159,18 @@ public class OASigninPicker extends WheelPicker {
                     maxDays = DateUtils.calculateDaysInMonth(stringToYearMonthDay(item), stringToYearMonthDay(months.get(selectedMonthIndex)));
                 }
 
-                days.clear();
-                for (int i = 1; i <= maxDays; i++) {
-                    days.add(DateUtils.fillZero(i));
-                }
-                if (selectedDayIndex >= maxDays) {
-                    //年或月变动时,保持之前选择的日不动:如果之前选择的日是之前年月的最大日,则日自动为该年月的最大日
-                    selectedDayIndex = days.size() - 1;
+                if (mHaveDay) {
+                    days.clear();
+                    for (int i = 1; i <= maxDays; i++) {
+                        days.add(DateUtils.fillZero(i));
+                    }
+                    if (selectedDayIndex >= maxDays) {
+                        //年或月变动时,保持之前选择的日不动:如果之前选择的日是之前年月的最大日,则日自动为该年月的最大日
+                        selectedDayIndex = days.size() - 1;
+                    }
+                    dayView.setItems(days, selectedDayIndex);
                 }
-                dayView.setItems(days, selectedDayIndex);
+
                 months.clear();
                 for (int i = 1; i <= maxMonth; i++) {
                     months.add(DateUtils.fillZero(i));
@@ -169,26 +192,31 @@ public class OASigninPicker extends WheelPicker {
                     maxDays = day;
                 } else
                     maxDays = DateUtils.calculateDaysInMonth(stringToYearMonthDay(years.get(selectedYearIndex)), stringToYearMonthDay(item));
-                days.clear();
-                for (int i = 1; i <= maxDays; i++) {
-                    days.add(DateUtils.fillZero(i));
-                }
-                if (selectedDayIndex >= maxDays) {
-                    //年或月变动时,保持之前选择的日不动:如果之前选择的日是之前年月的最大日,则日自动为该年月的最大日
-                    selectedDayIndex = days.size() - 1;
+                if (mHaveDay) {
+                    days.clear();
+                    for (int i = 1; i <= maxDays; i++) {
+                        days.add(DateUtils.fillZero(i));
+                    }
+                    if (selectedDayIndex >= maxDays) {
+                        //年或月变动时,保持之前选择的日不动:如果之前选择的日是之前年月的最大日,则日自动为该年月的最大日
+                        selectedDayIndex = days.size() - 1;
+                    }
+                    dayView.setItems(days, selectedDayIndex);
                 }
-                dayView.setItems(days, selectedDayIndex);
-            }
-        });
-        dayView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
-            @Override
-            public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
-                selectedDayIndex = selectedIndex;
+
             }
         });
+        if (mHaveDay)
+            dayView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
+                @Override
+                public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
+                    selectedDayIndex = selectedIndex;
+                }
+            });
         yearView.setItems(years, selectedYearIndex);
         monthView.setItems(months, selectedMonthIndex);
-        dayView.setItems(days, selectedDayIndex);
+        if (mHaveDay)
+            dayView.setItems(days, selectedDayIndex);
         return layout;
     }
 
@@ -203,7 +231,7 @@ public class OASigninPicker extends WheelPicker {
         if (onDateTimePickListener != null) {
             String year = getSelectedYear();
             String month = getSelectedMonth();
-            String day = getSelectedDay();
+            String day = mHaveDay ? getSelectedDay() : "";
             onDateTimePickListener.setTime(year, month, day);
         }
     }
@@ -286,10 +314,16 @@ public class OASigninPicker extends WheelPicker {
         return index;
     }
 
+    public void setSelectedItem(int yeas, int month) {
+        selectedYearIndex = findItemIndex(years, yeas);
+        selectedMonthIndex = findItemIndex(months, month);
+//        selectedDayIndex = findItemIndex(days, day);
+    }
+
     public void setSelectedItem(int yeas, int month, int day) {
+        selectedYearIndex = findItemIndex(years, yeas);
         selectedMonthIndex = findItemIndex(months, month);
         selectedDayIndex = findItemIndex(days, day);
-        selectedYearIndex = findItemIndex(years, yeas);
     }
 
     /**

+ 1 - 0
app_core/common/src/main/java/com/core/utils/CommonUtil.java

@@ -53,6 +53,7 @@ public class CommonUtil {
         if (ct == null) return "";
         String baseUrl = getSharedPreferences(ct, "erp_baseurl");
         return baseUrl;
+//        return "http://192.168.253.58:8080/ERP/";
     }
 
     /**