Bladeren bron

经济运行数据修改

shilin 1 jaar geleden
bovenliggende
commit
60c033cb55

+ 14 - 3
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/service/WtAlysisDayService.java

@@ -4,11 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.runeconomy.model.auto.ProEconWtAlysisDay;
 import com.gyee.runeconomy.service.auto.IProEconWtAlysisDayService;
-import com.gyee.runeconomy.util.DateUtils;
 import com.gyee.runeconomy.util.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Date;
 
 @Service
@@ -29,8 +30,17 @@ public class WtAlysisDayService {
         //构造分页构造器
         Page<ProEconWtAlysisDay> pageInfo = new Page<>(pageNum, pageSize);
         if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
-            Date begin = DateUtils.parseDate(beginDate);
-            Date end = DateUtils.parseDate(endDate);
+            String format = "yyyy-MM-dd";
+            SimpleDateFormat df = new SimpleDateFormat(format);
+            Date begin = null;
+            Date end = null;
+            try {
+                begin = df.parse(beginDate);
+                end = df.parse(endDate);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+
 
             //构造条件构造器
             LambdaQueryWrapper<ProEconWtAlysisDay> queryWrapper = new LambdaQueryWrapper<>();
@@ -38,6 +48,7 @@ public class WtAlysisDayService {
             queryWrapper.eq(ProEconWtAlysisDay::getWindturbineId, wtId).
                     ge(ProEconWtAlysisDay::getRecordDate, begin).
                     le(ProEconWtAlysisDay::getRecordDate, end);
+            queryWrapper.orderByAsc(ProEconWtAlysisDay::getRecordDate);
             //执行查询
             proEconWtAlysisDayService.page(pageInfo, queryWrapper);
         }

+ 17 - 9
web/runeconomy-xk/src/main/java/com/gyee/runeconomy/util/DateUtils.java

@@ -21,45 +21,53 @@ public class DateUtils {
 
     // 获取线程的变量副本,如果不覆盖initialValue,第一次get返回null,故需要初始化一个SimpleDateFormat,并set到threadLocal中
 
+    public static String format(Date date, String pattern) {
+        if (date != null) {
+            SimpleDateFormat df = new SimpleDateFormat(pattern);
+            return df.format(date);
+        }
+        return null;
+    }
     public static SimpleDateFormat getFormat() {
 
-        SimpleDateFormat df = (SimpleDateFormat) threadLocal.get();
+        SimpleDateFormat df =new SimpleDateFormat();
 
         if (df == null) {
             df = new SimpleDateFormat(format);
-            threadLocal.set(df);
+
         }
-        df.setLenient(false);
+
         return df;
 
     }
 
     public static SimpleDateFormat getFormat1() {
 
-        SimpleDateFormat df1 = (SimpleDateFormat) threadLocal.get();
+        SimpleDateFormat df1 = new SimpleDateFormat();
 
         if (df1 == null) {
             df1 = new SimpleDateFormat(format1);
-            threadLocal.set(df1);
+
         }
-        df1.setLenient(false);
+
         return df1;
 
     }
 
     public static SimpleDateFormat getFormat2() {
 
-        SimpleDateFormat df2 = (SimpleDateFormat) threadLocal.get();
+        SimpleDateFormat df2 = new SimpleDateFormat();
 
         if (df2 == null) {
             df2 = new SimpleDateFormat(format2);
-            threadLocal.set(df2);
+
         }
-        df2.setLenient(false);
+
         return df2;
 
     }
 
+
     public static Date pareDateNoHours(String date) {
 
         SimpleDateFormat df2 = new SimpleDateFormat(format);