wangjianguo il y a 8 ans
Parent
commit
90f55622b9

+ 19 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/StatisticsBean.java

@@ -142,4 +142,23 @@ public class StatisticsBean {
 		}
     }
     
+    // 比较大小 1 小 , -1 大 
+    // 方法2
+    public int compare2To(StatisticsBean o2){
+    	double a = 1000.0 ,b=1000.0 ;
+		if(this.getChecked_num()!=0 ){
+			a = this.getAll_check_score() / (this.getChecked_num()+0.00);
+		}
+		if(o2.getChecked_num()!=0){
+			b = o2.getAll_check_score()/(o2.getChecked_num()+0.00);
+		}
+		if (a > b ) {
+			return 1;
+		} else if (a < b) {
+			return -1;
+		} else {
+			return 0;
+		}	
+    }
+    
 }

+ 1 - 19
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -877,25 +877,7 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 		lists.sort(new Comparator<StatisticsBean>() {
 			@Override
 			public int compare(StatisticsBean o1, StatisticsBean o2) {
-				if(o1.getChecked_num()!=0 && o2.getChecked_num()!=0){
-					double a = o1.getAll_check_score() / (o1.getChecked_num()+0.00);
-					double b = o2.getAll_check_score() /(o2.getChecked_num()+0.00);
-					if (a > b ) {
-						return 1;
-					} else if (a < b) {
-						return -1;
-					} else {
-						return 0;
-					}	
-				}else{
-					if(o1.getChecked_num() == 0){
-						return -1 ;
-					}else if(o2.getChecked_num() ==0){
-						return 1;
-					}else{
-						return 0;
-					}
-				}
+				return o1.compare2To(o2);
 			}
 		});