Browse Source

智慧检修首页优化

wangchangsheng 3 years ago
parent
commit
0fafe1bd36

+ 38 - 1
src/main/java/com/gyee/frame/model/auto/ShutdowneventExample.java

@@ -188,6 +188,13 @@ public class ShutdowneventExample {
             criteria.add(new Criterion(condition, value));
         }
 
+        protected void addCriterion2(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion("date",condition, value));
+        }
+
         protected void addCriterion(String condition, Object value1, Object value2, String property) {
             if (value1 == null || value2 == null) {
                 throw new RuntimeException("Between values for " + property + " cannot be null");
@@ -435,6 +442,12 @@ public class ShutdowneventExample {
             return (Criteria) this;
         }
 
+        public Criteria andStoptimeGreaterThanOrEqualTo2(String value) {
+            addCriterion2("stopTime >=", value, "stoptime");
+            return (Criteria) this;
+        }
+
+
         public Criteria andStoptimeLessThan(Date value) {
             addCriterion("stopTime <", value, "stoptime");
             return (Criteria) this;
@@ -444,6 +457,11 @@ public class ShutdowneventExample {
             addCriterion("stopTime <=", value, "stoptime");
             return (Criteria) this;
         }
+        public Criteria andStoptimeLessThanOrEqualTo2(String value) {
+            addCriterion2("stopTime <=", value, "stoptime");
+            return (Criteria) this;
+        }
+
 
         public Criteria andStoptimeIn(List<Date> values) {
             addCriterion("stopTime in", values, "stoptime");
@@ -1490,6 +1508,8 @@ public class ShutdowneventExample {
 
         private boolean listValue;
 
+        private boolean dateValue;
+
         private String typeHandler;
 
         public String getCondition() {
@@ -1520,6 +1540,10 @@ public class ShutdowneventExample {
             return listValue;
         }
 
+        public boolean isDateValue() {
+            return dateValue;
+        }
+
         public String getTypeHandler() {
             return typeHandler;
         }
@@ -1538,15 +1562,28 @@ public class ShutdowneventExample {
             this.typeHandler = typeHandler;
             if (value instanceof List<?>) {
                 this.listValue = true;
-            } else {
+            }else {
                 this.singleValue = true;
             }
+
+
         }
 
         protected Criterion(String condition, Object value) {
             this(condition, value, null);
         }
 
+        protected Criterion(String type,String condition, Object value) {
+
+            super();
+            this.value = value;
+            this.condition = condition;
+            if (type.equals("date")) {
+                this.dateValue = true;
+            }else {
+                this.singleValue = true;
+            }
+        }
         protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
             super();
             this.condition = condition;

+ 6 - 2
src/main/java/com/gyee/frame/service/ShutdowneventService.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 
@@ -275,7 +276,7 @@ public class ShutdowneventService implements BaseService<Shutdownevent, Shutdown
 	 * @param wtIds
 	 * @return
 	 */
-	public Map<String,Object> queryMttrAndMtbf(List<String> wtIds,Date recodedate) {
+	public Map<String,Object> queryMttrAndMtbf(List<String> wtIds,Date recodedate) throws Exception {
 
 		Map<String,Object> map=new HashMap<>();
 
@@ -322,7 +323,10 @@ public class ShutdowneventService implements BaseService<Shutdownevent, Shutdown
 			{
 				criteria.andWindturbineidIn(wtIds);
 			}
-			criteria.andStoptimeGreaterThanOrEqualTo(beginDate).andStoptimeLessThanOrEqualTo(endDate);
+			SimpleDateFormat formatter  = new SimpleDateFormat("yyyy-MM-dd");
+			String  bString = formatter.format(beginDate);
+			String  eString = formatter.format(endDate);
+			criteria.andStoptimeGreaterThanOrEqualTo2(bString).andStoptimeLessThanOrEqualTo2(eString);
 			criteria.andStophoursIsNotNull();
 		//	criteria.andStoptypeidNotEqualTo("wh");
 		//	criteria.andStoptypeidNotEqualTo("other");

+ 5 - 0
src/main/resources/mybatis/auto/ShutdowneventMapper.xml

@@ -50,6 +50,11 @@
                 <when test="criterion.singleValue">
                   and ${criterion.condition} #{criterion.value}
                 </when>
+
+                <when test="criterion.dateValue">
+                  and ${criterion.condition} to_date(#{criterion.value},'yyyy-MM-dd')
+                </when>
+
                 <when test="criterion.betweenValue">
                   and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                 </when>