chenrj-PC\chenrj 8 anni fa
parent
commit
030bcc26df

+ 52 - 57
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -20,11 +20,10 @@
          
     <select id="selectMList"  parameterType="com.xintong.visualinspection.pojo.TaskAndScore" resultType="com.xintong.visualinspection.pojo.TaskAndScore">
    
-    SELECT * from check_task a LEFT JOIN check_score b on a.id=b.task_id where
-          a.monitor_user_id != -1 and a.monitor_user_id != 0 and 
-       a.start_time &gt;= #{start_time} and a.end_time &lt; #{end_time} and a.check_status !=22
-    
-    
+	    SELECT * from check_task a LEFT JOIN check_score b on a.id=b.task_id where
+	          a.monitor_user_id != -1 and a.monitor_user_id != 0 and 
+	       a.start_time &gt;= #{start_time} and a.end_time &lt; #{end_time} and a.check_status !=22
+	    
     </select>
     
     
@@ -97,29 +96,27 @@
 			check_num_t.checked_num , checked_score_t.mth, checked_score_t.checkd_all_score , checked_score_t.checked_person,checked_score_t.checked_dept
 		FROM
 			(
-				SELECT
-					monthfunc (t.start_time) AS mth,
-					sum(m.check_item_score) AS checkd_all_score,
-					t.*
-				FROM
-					check_task t,
-					check_score m
-				WHERE
-					t.id = m.task_id
-				AND t.check_status != 22
-				AND t.checked_person IS NOT NULL
-				<if test="start_date !=null">
-					AND t.start_time >= #{start_date}
-				</if>
-				<if test="end_date !=null">
-					AND t.end_time &lt; #{end_date}
-				</if>
-				<if test="mth!=null and mth!=''">
-					AND monthfunc (t.start_time) =#{mth}
-				</if>
-				GROUP BY
-					mth,
-					t.checked_person
+			SELECT 
+					monthfunc (t.start_time) AS mth, 
+				sum(m.check_item_score) AS checkd_all_score,t.* 
+				FROM 
+				check_score m INNER JOIN 
+				( select * From check_task t 
+						where t.check_status != 22 
+						<if test="start_date !=null">
+							AND t.start_time >= #{start_date}
+						</if>
+						<if test="end_date !=null">
+							AND t.end_time &lt; #{end_date}
+						</if> 
+						<if test="mth!=null and mth!=''">
+							AND monthfunc (t.start_time) =#{mth}
+						</if>
+						  ) t  
+			ON m.task_id = t.id
+				WHERE 1=1
+					GROUP BY mth , t.checked_person
+					
 			) checked_score_t
 		LEFT JOIN (
 			SELECT
@@ -194,7 +191,7 @@
      </select>
      
      <select id="selectCheckedItemScoreInfo" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
-     	SELECT count(m.check_item_score) AS checked_num , sum(m.check_item_score) AS all_check_score , m.parent_id,m.check_item_name AS name FROM check_task t INNER JOIN
+     	SELECT count(DISTINCT m.task_id) AS checked_num , sum(m.check_item_score) AS all_check_score , m.parent_id,m.check_item_name AS name FROM check_task t INNER JOIN
 		(
 			select ci.name AS check_item_name , t.* FROM
 			(  SELECT ci.parent_id, t.* from check_score t LEFT JOIN check_item  ci ON t.check_item_id = ci.id
@@ -223,36 +220,34 @@
 			check_num_t.checked_num , checked_score_t.mth, checked_score_t.checkd_all_score AS all_check_score , checked_score_t.checked_person,checked_score_t.checked_dept
 			FROM
 			(
-				SELECT
-					monthfunc (t.start_time) AS mth,
-					sum(m.check_item_score) AS checkd_all_score,
-					t.*
-				FROM
-					check_task t,
-					check_score m
-				WHERE
-					t.id = m.task_id
-				AND t.check_status != 22
-				AND t.checked_person IS NOT NULL
-				<if test="start_date !=null">
-					AND t.start_time >= #{start_date}
-				</if>
-				<if test="end_date !=null">
-					AND t.end_time &lt; #{end_date}
-				</if>
-				<if test="user_id !=null ">
-					AND m.checked_person = #{user_id}
-				</if>
-				GROUP BY mth
+				SELECT 
+					monthfunc (t.start_time) AS mth, 
+				sum(m.check_item_score) AS checkd_all_score,t.* 
+				FROM 
+				check_score m INNER JOIN 
+				( select * From check_task t 
+						where t.check_status != 22 
+						<if test="start_date !=null">
+							AND t.start_time >= #{start_date}
+						</if>
+						<if test="end_date !=null">
+							AND t.end_time &lt; #{end_date}
+						</if>   ) t  
+			ON m.task_id = t.id
+				WHERE 1=1
+					<if test="user_id !=null ">
+						AND m.checked_person = #{user_id}
+					</if>
+					GROUP BY mth
+				
 			) checked_score_t
 		LEFT JOIN (
 			SELECT
-				COUNT(t.checked_person) AS checked_num,
+				COUNT( t.id) AS checked_num,
 				t.checked_person,
-				monthfunc (t.start_time) AS mth,
-				t.id
+				monthfunc (t.start_time) AS mth
 			FROM
-				check_task t
+				check_task t 
 			WHERE
 				t.checked_person IS NOT NULL
 			AND t.check_status != 22
@@ -275,7 +270,7 @@
      </select>
      
      <select id="selectOneCheckedItemInfo" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
-     	SELECT count(m.check_item_score) AS checked_num , sum(m.check_item_score) AS all_check_score , m.parent_id,m.check_item_name AS name FROM check_task t INNER JOIN
+     	SELECT count(DISTINCT m.task_id) AS checked_num , sum(m.check_item_score) AS all_check_score , m.parent_id,m.check_item_name AS name FROM check_task t INNER JOIN
 		(
 			select ci.name AS check_item_name , t.* FROM
 			(  SELECT ci.parent_id, t.* from check_score t LEFT JOIN check_item  ci ON t.check_item_id = ci.id
@@ -302,10 +297,10 @@
      		LEFT JOIN (SELECT ci.* ,cp.name AS parent_name FROM check_item  ci LEFT JOIN check_item cp ON ci.parent_id = cp.id) ci ON ci.id = cs.check_item_id  
      		where   t.check_status !=22
      		<if test="queryType!=null and queryType==0">
-     			AND   t.checked_person = #{user_id}
+     			AND   cs.checked_person = #{user_id}
      		</if>
      		<if test="queryType!=null and queryType==1 and user_id!=null and user_id!=''">
-     			AND  t.checkman = #{user_id}
+     			AND  cs.checkman = #{user_id}
      		</if>
      		<if test="start_date !=null and end_date !=null and queryType ==1">
      			AND t.check_time >= #{start_date} AND t.check_time &lt; #{end_date}

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

@@ -66,6 +66,10 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 	public List<StatisticsBo> getEmployeeCheckedInfo(StatisticsBean obj) {
 		// 查看是否有部门id
 		Long organId = obj.getDept_id();
+		// 道管中心 id
+		Long parent_dept_id = obj.getParent_dept_id() ;
+		obj.setParent_dept_id(null);
+		obj.setDept_id(null);
 		// 将检索出来的数据放到如map中
 		List<StatisticsBean> list = statisticsDao.selectStatistics(obj);
 
@@ -201,7 +205,17 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 				lists.get(i).setCompany_ranking(i + 1);
 			}
 		}
-		return lists;
+		// 这边进行赛选一下;
+		List<StatisticsBo> reList = new ArrayList<>();
+		for(int i=0; i<lists.size(); i++ ){
+			if(parent_dept_id ==null || lists.get(i).getUser().getParent_organid() == parent_dept_id+0 ){
+				if(organId ==null || lists.get(i).getUser().getOrganid() == organId+0){
+					reList.add(lists.get(i));
+				}
+			}
+		}
+		
+		return reList;
 	}
 
 	@Override