فهرست منبع

Merge branch 'master' of http://git_xt.jsxt.jsjtyxt.com/wenhongquan/VisualInspection

* 'master' of http://git_xt.jsxt.jsjtyxt.com/wenhongquan/VisualInspection:
  bug
  bug修改
温红权 8 سال پیش
والد
کامیت
fd9527369d

+ 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;
+			}
+		}	
+    }
+    
 }

+ 35 - 16
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -87,24 +87,43 @@
 		</if>
 		  ) y LEFT JOIN
 		
-		(SELECT  u.checked_person AS user_id , u.checked_dept AS dept_id,count(1) AS checked_num,sum(u.score) AS score  FROM (
-		SELECT t.checked_person , t.checked_dept,ci.parent_id, t.check_item_score AS score FROM check_score t 
-		LEFT JOIN check_item ci ON t.check_item_id = ci.id 
-		LEFT JOIN check_task ct ON ct.id = t.task_id
-		WHERE 1=1 and ct.check_status!=22 and ct.id not in <include refid="taskexclouddeleteUser"/>
-		<if test="start_date!=null and end_date != null">
-	        AND	 ct.start_time &gt;= #{start_date} AND ct.end_time &lt; #{end_date}
-		</if>
-		<if test="dept_id!=null">
-			AND t.checked_dept =#{dept_id}			
-		</if>
+		(
+		
+		SELECT  u.checked_person AS user_id , u.checked_dept AS dept_id,count(1) AS checked_num,sum(u.score) AS score  FROM (
+			SELECT IFNULL(t.checked_person,ct.checked_person) AS checked_person , IFNULL(t.checked_dept,ct.checked_dept) AS checked_dept  ,
+			IFNULL(t.check_item_score,0) AS score  FROM check_task ct 
+			LEFT JOIN check_score t ON  ct.id = t.task_id
+			WHERE 1=1 and ct.check_status!=22 and ct.id not in <include refid="taskexclouddeleteUser"/>
+			<if test="start_date!=null and end_date != null">
+		        AND	 ct.start_time &gt;= #{start_date} AND ct.end_time &lt; #{end_date}
+			</if>
+			<if test="dept_id!=null">
+				AND ct.checked_dept =#{dept_id}			
+			</if>
 		 ) 
-		u LEFT JOIN check_item s ON u.parent_id = s.id GROUP  BY checked_person) x
+		u  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>

+ 25 - 20
VisualInspection_server/src/main/java/com/xintong/visualinspection/service/impl/StatisticsServiceImpl.java

@@ -1905,20 +1905,20 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 			float avg = 0;
 			StatisticsBean value = station.getValue();
 			// 设置总平均扣分
-			if (value.getCompany_check_num() > 0) {
-				avg += value.getCompany_total_score() / value.getCompany_check_num()/4.0;
-			}
-			if (value.getThird_check_num() > 0) {
-				avg += value.getThird_total_score() / value.getThird_check_num()/4.0;
+			if (value.getCompany_check_num() > 0 || value.getThird_check_num() > 0) {
+				avg += (value.getCompany_total_score() +value.getThird_total_score())  /4.0/ (value.getCompany_check_num()+value.getThird_check_num());
 			}
+//			if (value.getThird_check_num() > 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++) {