chenrj-PC\chenrj 8 years ago
parent
commit
e3a0e8954a

+ 15 - 12
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -87,20 +87,23 @@
 		</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 
 			<if test="start_date!=null and end_date != null">
 	        	AND	 check_time &gt;= #{start_date} AND check_time &lt; #{end_date}

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

@@ -1905,12 +1905,12 @@ 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() /4.0/ value.getCompany_check_num();
-			}
-			if (value.getThird_check_num() > 0) {
-				avg += value.getThird_total_score() /4.0/ value.getThird_check_num();
+			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() /4.0/ value.getSpecial_check_num();
 			}