Преглед на файлове

加入条件查询 开始时间和结束时间

吴学文 преди 6 години
родител
ревизия
1db2f4f43e

+ 17 - 1
Api/src/main/java/com/java110/api/listener/fee/QueryFeeDetailListener.java

@@ -3,7 +3,9 @@ package com.java110.api.listener.fee;
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.api.listener.AbstractServiceApiDataFlowListener;
+import com.java110.common.constant.ResponseConstant;
 import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.exception.ListenerExecuteException;
 import com.java110.common.util.Assert;
 import com.java110.common.util.BeanConvertUtil;
 import com.java110.common.util.DateUtil;
@@ -59,8 +61,22 @@ public class QueryFeeDetailListener extends AbstractServiceApiDataFlowListener {
 
         //查询总记录数
         ApiFeeDetailVo apiFeeDetailVo = new ApiFeeDetailVo();
+        FeeDetailDto feeDetailDto = BeanConvertUtil.covertBean(reqJson, FeeDetailDto.class);
 
-        int total = feeDetailInnerServiceSMOImpl.queryFeeDetailsCount(BeanConvertUtil.covertBean(reqJson, FeeDetailDto.class));
+        try {
+            if (reqJson.containsKey("startTime")) {
+                feeDetailDto.setStartTime(DateUtil.getDateFromString(reqJson.getString("startTime"), DateUtil.DATE_FORMATE_STRING_B));
+            }
+
+            if (reqJson.containsKey("endTime")) {
+                feeDetailDto.setStartTime(DateUtil.getDateFromString(reqJson.getString("endTime"), DateUtil.DATE_FORMATE_STRING_B));
+            }
+        } catch (Exception e) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, e.getMessage() + "传入开始时间或结束时间格式错误 c");
+        }
+
+
+        int total = feeDetailInnerServiceSMOImpl.queryFeeDetailsCount(feeDetailDto);
         apiFeeDetailVo.setTotal(total);
         if (total > 0) {
             List<FeeDetailDto> feeDetailDtos = feeDetailInnerServiceSMOImpl.queryFeeDetails(BeanConvertUtil.covertBean(reqJson, FeeDetailDto.class));

+ 3 - 1
WebService/src/main/resources/components/property-fee/propertyFee.js

@@ -39,7 +39,9 @@
                         page:_page,
                         row:_row,
                         communityId:vc.getCurrentCommunity().communityId,
-                        feeId:vc.component.feeDetailInfo.feeId
+                        feeId:vc.component.feeDetailInfo.feeId,
+                        startTime:vc.component.feeDetailInfo.startTime,
+                        startTime:vc.component.feeDetailInfo.endTime
                     }
                 }
                //发送get请求

+ 18 - 0
java110-bean/src/main/java/com/java110/dto/FeeDetailDto.java

@@ -24,6 +24,8 @@ private String feeId;
 
 
     private Date createTime;
+    private Date startTime;
+    private Date endTime;
 
     private String statusCd = "0";
 
@@ -93,4 +95,20 @@ public void setFeeId(String feeId) {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
 }

+ 50 - 70
java110-common/src/main/java/com/java110/common/util/DateUtil.java

@@ -30,8 +30,7 @@ public class DateUtil {
     public static final String DATE_FORMATE_STRING_J = "yyyyMMddHHmmss.SSS";
     public static final String DATE_FORMATE_STRING_K = "yyyyMMddHHmmssSSS";
 
-    static
-    {
+    static {
         formats.put("yyyyMMddHHmmss", new SimpleDateFormat("yyyyMMddHHmmss"));
         formats.put("yyyy-MM-dd HH:mm:ss", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
         formats.put("yyyy-MM-dd", new SimpleDateFormat("yyyy-MM-dd"));
@@ -49,57 +48,62 @@ public class DateUtil {
 
     /**
      * 返回 yyyyMMddhhmmss 格式的日期串
+     *
      * @return
      */
-    public static String getyyyyMMddhhmmssDateString(){
+    public static String getyyyyMMddhhmmssDateString() {
         return dateFormat.format(new Date());
     }
 
 
     /**
      * 获取当前时间
+     *
      * @return
      */
-    public static Date getCurrentDate(){
+    public static Date getCurrentDate() {
         Calendar calendar = Calendar.getInstance();
         return calendar.getTime();
     }
 
     /**
      * 获取当前月
+     *
      * @return
      */
-    public static int getCurrentMonth(){
+    public static int getCurrentMonth() {
         Calendar calendar = Calendar.getInstance();
-        return calendar.get(Calendar.MONTH)+1;
+        return calendar.get(Calendar.MONTH) + 1;
     }
 
     public static Date getLastDate() throws ParseException {
-        return getDateFromString("3000-01-01",DATE_FORMATE_STRING_B);
+        return getDateFromString("3000-01-01", DATE_FORMATE_STRING_B);
     }
 
     /**
      * 转TimeStamp
+     *
      * @param date
      * @return
      */
-    public static Timestamp getTimestamp(Date date){
+    public static Timestamp getTimestamp(Date date) {
         Timestamp timestamp = new Timestamp(date.getTime());
         return timestamp;
     }
+
     /**
      * 获取未来时间
+     *
      * @param second 秒
      * @return
      */
-    public static Date getFutureDate(int second){
+    public static Date getFutureDate(int second) {
         Calendar calendar = Calendar.getInstance();
-        calendar.add(Calendar.SECOND,second);
+        calendar.add(Calendar.SECOND, second);
         return calendar.getTime();
     }
 
-    public static String getFormatTimeString(Date date, String pattern)
-    {
+    public static String getFormatTimeString(Date date, String pattern) {
         SimpleDateFormat sDateFormat = getDateFormat(pattern);
 
         synchronized (sDateFormat) {
@@ -107,14 +111,12 @@ public class DateUtil {
         }
     }
 
-    public static String getDefaultFormateTimeString(Date date)
-    {
+    public static String getDefaultFormateTimeString(Date date) {
         return getFormatTimeString(date, "yyyyMMddHHmmss");
     }
 
-    public static SimpleDateFormat getDateFormat(String pattern)
-    {
-        SimpleDateFormat sDateFormat = (SimpleDateFormat)formats.get(pattern);
+    public static SimpleDateFormat getDateFormat(String pattern) {
+        SimpleDateFormat sDateFormat = (SimpleDateFormat) formats.get(pattern);
         if (sDateFormat == null) {
             sDateFormat = new SimpleDateFormat(pattern);
             formats.put(pattern, sDateFormat);
@@ -123,8 +125,7 @@ public class DateUtil {
     }
 
     public static Date getDateFromString(String date, String pattern)
-            throws ParseException
-    {
+            throws ParseException {
         SimpleDateFormat sDateFormat = getDateFormat(pattern);
 
         synchronized (sDateFormat) {
@@ -133,87 +134,76 @@ public class DateUtil {
     }
 
     public static Date getDefaultDateFromString(String date)
-            throws ParseException
-    {
+            throws ParseException {
         return getDateFromString(date, "yyyyMMddHHmmss");
     }
 
-    public static String getNowDefault()
-    {
+    public static String getNowDefault() {
         return getNow("yyyyMMddHHmmss");
     }
 
-    public static String getNow(String pattern)
-    {
+    public static String getNow(String pattern) {
         return getFormatTimeString(new Date(), pattern);
     }
 
-    public static String getNowII()
-    {
+    public static String getNowII() {
         return getFormatTimeString(new Date(), "yyyyMMdd");
     }
 
     public static long dateString2Long(String str, String pattern)
-            throws ParseException
-    {
+            throws ParseException {
         return getDateFromString(str, pattern).getTime();
     }
 
     /**
      * 校验字符串是否可以格式化为时间
+     *
      * @param str
      * @param pattern
      * @return
      */
-    public static boolean judgeDate(String str,String pattern){
-        try{
-            dateString2Long(str,pattern);
-        }catch (Exception e){
+    public static boolean judgeDate(String str, String pattern) {
+        try {
+            dateString2Long(str, pattern);
+        } catch (Exception e) {
             return false;
         }
         return true;
     }
 
-    public static String longToDateStringDefault(long time)
-    {
+    public static String longToDateStringDefault(long time) {
         return getFormatTimeString(new Date(time), "yyyyMMddHHmmss");
     }
 
-    public static String longToDateString(long time, String pattern)
-    {
+    public static String longToDateString(long time, String pattern) {
         return getFormatTimeString(new Date(time), pattern);
     }
 
-    public static long date2Long(Date date)
-    {
+    public static long date2Long(Date date) {
         return date.getTime();
     }
 
-    public static Date longToDate(long time)
-    {
+    public static Date longToDate(long time) {
         return new Date(time);
     }
 
     public static Date getDateFromStringAdaptTwoPattern(String date)
-            throws ParseException
-    {
-        try
-        {
-            return getDateFromString(date, "yyyy-MM-dd HH:mm:ss"); } catch (ParseException e) {
+            throws ParseException {
+        try {
+            return getDateFromString(date, "yyyy-MM-dd HH:mm:ss");
+        } catch (ParseException e) {
         }
         return getDateFromString(date, "yyyy-MM-dd");
     }
 
     public static String changeNumDateToDate(String numdate, String inFormat, String outFormat)
-            throws ParseException
-    {
+            throws ParseException {
         Date date = getDateFromString(numdate, inFormat);
         return getFormatTimeString(date, outFormat);
     }
 
     public static String getNextMonthFistDay(String nowdate, String inFormat, String outFormat)
-            throws ParseException
-    {
+            throws ParseException {
         Date date = getDateFromString(nowdate, inFormat);
 
         Calendar cl = Calendar.getInstance();
@@ -225,12 +215,10 @@ public class DateUtil {
         return getFormatTimeString(date, outFormat);
     }
 
-    public static boolean isLeapYear(int year)
-    {
+    public static boolean isLeapYear(int year) {
         if (year % 400 == 0)
             return true;
-        if (year % 4 == 0)
-        {
+        if (year % 4 == 0) {
             return (year % 100 != 0);
         }
 
@@ -238,16 +226,14 @@ public class DateUtil {
     }
 
     public static String getLastDay(String nowdate, String inFormat, String outFormat)
-            throws ParseException
-    {
+            throws ParseException {
         String returndate = "";
 
         Date date = getDateFromString(nowdate, inFormat);
 
         Calendar cl = Calendar.getInstance();
         cl.setTime(date);
-        switch (cl.get(2))
-        {
+        switch (cl.get(2)) {
             case 0:
                 cl.set(5, 31);
                 break;
@@ -298,13 +284,11 @@ public class DateUtil {
         return returndate;
     }
 
-    public static String getMonthLastDay(String fmt)
-    {
+    public static String getMonthLastDay(String fmt) {
         String returndate = "";
         Date date = null;
         Calendar cl = Calendar.getInstance();
-        switch (cl.get(2))
-        {
+        switch (cl.get(2)) {
             case 0:
                 cl.set(5, 31);
                 break;
@@ -355,8 +339,7 @@ public class DateUtil {
         return returndate;
     }
 
-    public static String getNextMonthFirstDay(String fmt)
-    {
+    public static String getNextMonthFirstDay(String fmt) {
         String returndate = "";
         Date date = null;
 
@@ -372,8 +355,7 @@ public class DateUtil {
     }
 
     public static boolean compareDate(String fistDate, String secondDate, String format)
-            throws ParseException
-    {
+            throws ParseException {
         boolean flag = false;
 
         Date fist = null;
@@ -389,10 +371,8 @@ public class DateUtil {
         return flag;
     }
 
-    public static boolean isRightDate(String value, String varValue)
-    {
-        try
-        {
+    public static boolean isRightDate(String value, String varValue) {
+        try {
             SimpleDateFormat format = new SimpleDateFormat(varValue);
             format.setLenient(false);
             format.parse(value);

+ 13 - 1
java110-db/src/main/resources/mapper/fee/FeeDetailServiceDaoImplMapper.xml

@@ -131,6 +131,12 @@ where 1 =1
 <if test="feeId !=null and feeId != ''">
    and t.fee_id= #{feeId}
 </if>
+        <if test="startTime !=null ">
+            and t.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime !=null ">
+            and t.create_time &lt;= #{endTime}
+        </if>
    order by t.create_time desc
 <if test="page != -1 and page != null ">
    limit #{page}, #{row}
@@ -212,7 +218,13 @@ where 1 =1
 </if> 
 <if test="feeId !=null and feeId != ''">
    and t.fee_id= #{feeId}
-</if> 
+</if>
+         <if test="startTime !=null ">
+             and t.create_time &gt;= #{startTime}
+         </if>
+         <if test="endTime !=null ">
+             and t.create_time &lt;= #{endTime}
+         </if>
 
 
      </select>