chenrj-PC\chenrj 8 лет назад
Родитель
Сommit
528fa89a0c

+ 1 - 1
VisualInspection/js/statistics/business_promotion_feedback.js

@@ -200,7 +200,7 @@ function getEmployeeInfosClick(url, param, start_score, end_score, start_num, en
                     "<td width='4%;'>" + filter(data[i].check_x_score, '0') + "</td><td width='4%'>" + filter(data[i].check_s_num, '0') + "</td><td width='4%;'>" +
                     filter(data[i].check_s_score, '0') + "</td><td width='4%;'>" + filter(data[i].check_all_num, '0') + "</td>" +
                     "<td width='4%;'>" +  filter(data[i].check_all_score, '0') + "</td><td width='4%;'>" + filterSlash(filterByZeroHandle(data[i].check_score_avg, '0'), filter(data[i].checked_num  + data[i].check_t_num  + data[i].check_x_num + data[i].check_s_num, '0')) + "</td>" +
-                    "<td width='4%;'>" + filterSlash(score.toFixed(2), filter(data[i].score + data[i].check_t_score + data[i].check_x_score + data[i].check_s_score, '0')) + "</td>" + "<td width='4%;'>" + "</td></tr>";
+                    "<td width='4%;'>" + filterSlash(score.toFixed(2), filter(data[i].check_all_num, '0')) + "</td>" + "<td width='4%;'>" + "</td></tr>";
                 count++;
             }
         }

+ 27 - 0
VisualInspection_server/src/main/java/com/xintong/visualinspection/bean/StatisticsBo.java

@@ -110,4 +110,31 @@ public class StatisticsBo {
 			}
 		}	
     }
+    
+    public int compareTo3(StatisticsBo o2){
+    	double a = 1000.0 ,b=1000.0 ;
+    	double a_c = this.getCheck_all_num() ;
+    	double b_c = o2.getCheck_all_num();
+		if(a_c!=0 ){
+			a = Double.parseDouble(this.getCheck_score_avg()) ;
+		}
+		if(b_c!=0){
+			b = Double.parseDouble(o2.getCheck_score_avg()) ;
+		}
+	
+		if (a > b ) {
+			return 1;
+		} else if (a < b) {
+			return -1;
+		} else {
+			if(a_c == 0 && b_c!=0 ){
+				return -1 ;
+			}else if(b_c ==0 && a_c != 0){
+				return 1;
+			}else{
+				return 0;
+			}
+		}	
+    }
+    
 }

+ 20 - 4
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -101,10 +101,26 @@
 		 ) 
 		u LEFT JOIN check_item s ON u.parent_id = s.id GROUP  BY checked_person) x
 		ON y.user_id = x.user_id AND y.dept_id =  x.dept_id
-		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_a_num,SUM(check_score) check_a_score FROM other_check WHERE check_type = 1 GROUP BY user_id,dept_id)  o1 ON o1.user_id = y.user_id AND y.dept_id = o1.dept_id
-		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_t_num,SUM(check_score) check_t_score FROM other_check WHERE check_type = 2 GROUP BY user_id,dept_id)  o2 ON o2.user_id = y.user_id AND y.dept_id = o2.dept_id
-		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_x_num,SUM(check_score) check_x_score FROM other_check WHERE check_type = 3 GROUP BY user_id,dept_id)  o3 ON o3.user_id = y.user_id AND y.dept_id = o3.dept_id
-		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_s_num,SUM(check_score) check_s_score FROM other_check WHERE check_type = 4 GROUP BY user_id,dept_id)  o4 ON o4.user_id = y.user_id AND y.dept_id = o4.dept_id
+		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_a_num,SUM(check_score) check_a_score FROM other_check WHERE check_type = 1 
+			<if test="start_date!=null and end_date != null">
+	        	AND	 check_time &gt;= #{start_date} AND check_time &lt; #{end_date}
+		 </if>
+		  GROUP BY user_id,dept_id)  o1 ON o1.user_id = y.user_id AND y.dept_id = o1.dept_id
+		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_t_num,SUM(check_score) check_t_score FROM other_check WHERE check_type = 2
+		<if test="start_date!=null and end_date != null">
+	        	AND	 check_time &gt;= #{start_date} AND check_time &lt; #{end_date}
+		 </if>
+		 GROUP BY user_id,dept_id)  o2 ON o2.user_id = y.user_id AND y.dept_id = o2.dept_id
+		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_x_num,SUM(check_score) check_x_score FROM other_check WHERE check_type = 3
+		<if test="start_date!=null and end_date != null">
+	        	AND	 check_time &gt;= #{start_date} AND check_time &lt; #{end_date}
+		 </if>
+		 GROUP BY user_id,dept_id)  o3 ON o3.user_id = y.user_id AND y.dept_id = o3.dept_id
+		LEFT JOIN (SELECT user_id,dept_id,COUNT(1) check_s_num,SUM(check_score) check_s_score FROM other_check WHERE check_type = 4 
+		<if test="start_date!=null and end_date != null">
+	        	AND	 check_time &gt;= #{start_date} AND check_time &lt; #{end_date}
+		 </if>
+		GROUP BY user_id,dept_id)  o4 ON o4.user_id = y.user_id AND y.dept_id = o4.dept_id
 		
 		
     </select>

+ 22 - 17
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -1906,19 +1906,19 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			StatisticsBean value = station.getValue();
 			// 设置总平均扣分
 			if (value.getCompany_check_num() > 0) {
-				avg += value.getCompany_total_score() / value.getCompany_check_num()/4.0;
+				avg += value.getCompany_total_score() /4.0/ value.getCompany_check_num();
 			}
 			if (value.getThird_check_num() > 0) {
-				avg += value.getThird_total_score() / value.getThird_check_num()/4.0;
+				avg += value.getThird_total_score() /4.0/ value.getThird_check_num();
 			}
 			if (value.getSpecial_check_num() > 0) {
-				avg += value.getSpecial_total_score() / value.getSpecial_check_num()/4.0;
+				avg += value.getSpecial_total_score() /4.0/ value.getSpecial_check_num();
 			}
 			if (value.getOnsite_check_num() > 0) {
-				avg += value.getOnsite_total_score() / value.getOnsite_check_num()/4.0;
+				avg += value.getOnsite_total_score() /4.0/ value.getOnsite_check_num();
 			}
 			if (value.getData_check_num() > 0) {
-				avg += value.getData_total_score() / value.getData_check_num()/4.0;
+				avg += value.getData_total_score() / 4.0 / value.getData_check_num();
 			}
 //			value.setCheck_total_avg(df.format(avg / value.getPeople_num()));
 			value.setCheck_total_avg(df.format(avg ));
@@ -2108,27 +2108,32 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 		}
 		
 		List<StatisticsBo> lists = new ArrayList<>(statisticBoMap.values());
-		// 进行排序
-		lists.sort(new Comparator<StatisticsBo>() {
-			@Override
-			public int compare(StatisticsBo o1, StatisticsBo o2) {
-				return o1.compareTo2(o2);
-			}
-		});
-
 		for (int i = 0; i < lists.size(); i++) {
-
+			
 			StatisticsBo statisticsBo = lists.get(i);
 			if (statisticsBo.getCheck_all_num()== 0) {
 				continue;
 			}
 			// 计算平均扣分
 			DecimalFormat df = new DecimalFormat(".##");
-			double count = statisticsBo.getCheck_all_num();
-			Double sc = (statisticsBo.getCheck_all_score()) * 1.00
-					/ (count == 0 ? 1 : count);
+			Integer count = statisticsBo.getChecked_num() ;
+//			double count = statisticsBo.getCheck_all_num();
+//			Double sc = (statisticsBo.getCheck_all_score()) * 1.00
+//					/ (count == 0 ? 1 : count);
+			Double sc =  statisticsBo.getScore()/1.0 /  (count == 0 ? 1 : count)  + 
+					statisticsBo.getCheck_t_score()/1.0/ ( statisticsBo.getCheck_t_num()==0?1:statisticsBo.getCheck_t_num() ) +  
+					statisticsBo.getCheck_x_score()/1.0/ ( statisticsBo.getCheck_x_num()==0?1:statisticsBo.getCheck_x_num() ) + 
+					statisticsBo.getCheck_s_score()/1.0/ ( statisticsBo.getCheck_s_num()==0?1:statisticsBo.getCheck_s_num() );
 			statisticsBo.setCheck_score_avg(sc == 0 ? "0" : df.format(sc));
 		}
+		// 进行排序
+		lists.sort(new Comparator<StatisticsBo>() {
+			@Override
+			public int compare(StatisticsBo o1, StatisticsBo o2) {
+				return o1.compareTo3(o2);
+			}
+		});
+
 		// 这边进行赛选一下;
 		List<StatisticsBo> reList = new ArrayList<>();
 		for (int i = 0; i < lists.size(); i++) {