温红权 8 éve
szülő
commit
efeb84ad05

+ 5 - 6
VisualInspection_server/src/main/java/com/xintong/visualinspection/mapper/master/StatisticsMapper.xml

@@ -119,13 +119,12 @@
     </select>
     
     <select id="selectFeeStationCheckedScore" parameterType="com.xintong.visualinspection.bean.StatisticsBean" resultType="com.xintong.visualinspection.bean.StatisticsBean">
-    	SELECT sum(t.check_item_score) AS score ,t.checked_dept AS dept_id ,t.checked_person AS user_id
-    		FROM check_score t 
-    		LEFT JOIN check_item c ON t.check_item_id = c.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"/>
+    	SELECT IFNULL(sum(ct.check_item_score),0) AS score ,t.checked_dept AS dept_id ,t.checked_person AS user_id
+    		FROM check_task t
+    		LEFT JOIN check_score ct ON t.id = ct.task_id
+    		WHERE 1=1 and t.check_status!=22 and  t.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}
+		        AND	 t.start_time &gt;= #{start_date} AND t.end_time &lt; #{end_date}
 			</if>
     		GROUP BY t.checked_dept,t.checked_person
     </select>

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

@@ -330,28 +330,36 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 
         List<StatisticsBo> list = getEmployeeCheckedInfo(obj);
         Map<Integer,StatisticsBo> listmap = new HashMap<>();
-		for(StatisticsBo b:list){
-            listmap.put(b.getUser().getId(),b);
+		for(StatisticsBo b:list) {
+            listmap.put(b.getUser().getId(), b);
         }
 
 
+
 		List<StatisticsBean> listCheckedScore = statisticsDao.selectFeeStationCheckedScore(obj);
 		for (StatisticsBean sta : listCheckedScore) {
 			if (mapStationInfos.containsKey(sta.getDept_id())) {
 
-                StatisticsBo bo= listmap.get(sta.getUser_id().intValue());
-
 				StatisticsBean statis = mapStationInfos.get(sta.getDept_id());
 				statis.setAll_check_score(statis.getAll_check_score() + sta.getScore());
-				double sc = Double.parseDouble(bo.getCheck_score_avg());
-				if (sc <= 15) {
-					statis.setScore_fifteen(statis.getScore_fifteen() + 1);
-				} else if (sc <= 50) {
-					statis.setScore_fifty(statis.getScore_fifty() + 1);
-				} else {
-					statis.setScore_over_fifty(statis.getScore_over_fifty() + 1);
-				}
-			}
+
+                StatisticsBo b = listmap.get(sta.getUser_id().intValue());
+
+                if(b == null || b.getCheck_score_avg() == null ||  statis == null) continue;
+                double sc = Double.parseDouble(b.getCheck_score_avg());
+                if(sc==0){
+                    statis.setScore(statis.getScore()+1);
+                }else
+                if (sc <= 15) {
+                    statis.setScore_fifteen(statis.getScore_fifteen() + 1);
+                } else if (sc <= 50) {
+                    statis.setScore_fifty(statis.getScore_fifty() + 1);
+                } else {
+                    statis.setScore_over_fifty(statis.getScore_over_fifty() + 1);
+                }
+
+
+            }
 		}
 
 
@@ -972,18 +980,64 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
 //			}
 			people_num = statisticsDao.selectCheckedNum(obj);
 		}
+		if(obj.getStart_date()==null && obj.getMth()!=null){
+            Calendar cal = Calendar.getInstance();
+            Date d = DateUtil.strParseDate(obj.getMth(), "yyyy/MM");
+            cal.setTime(d);
+            cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 25, 23, 0, 0);
+            obj.setEnd_date(cal.getTime());
+            cal.add(Calendar.MONTH, -1);
+            obj.setStart_date(cal.getTime());
+        }
 
-		List<StatisticsBean> userLostScoreInfoList = statisticsDao.selectCheckedScoreList(obj);
+//		List<StatisticsBean> userLostScoreInfoList = statisticsDao.selectCheckedScoreList(obj);
 
-		for (StatisticsBean sta : userLostScoreInfoList) {
-			if (sta.getAll_check_score()  <= 15) {
-				returnObj.setScore_fifteen(returnObj.getScore_fifteen() + 1);
-			} else if (sta.getAll_check_score() <= 50) {
-				returnObj.setScore_fifty(returnObj.getScore_fifty() + 1);
-			} else {
-				returnObj.setScore_over_fifty(returnObj.getScore_over_fifty() + 1);
-			}
-		}
+        Long deptid=obj.getDept_id();
+        List<StatisticsBo> list = getEmployeeCheckedInfo(obj);
+        Map<Integer,StatisticsBo> listmap = new HashMap<>();
+        for(StatisticsBo b:list){
+            listmap.put(b.getUser().getId(),b);
+        }
+
+        List<StatisticsBean> listCheckedScore = statisticsDao.selectFeeStationCheckedScore(obj);
+        for (StatisticsBean sta : listCheckedScore) {
+            if (deptid!=null && sta.getDept_id().intValue()==deptid.intValue()) {
+
+                StatisticsBo b=listmap.get(sta.getUser_id().intValue());
+
+                if (b == null || b.getCheck_score_avg() == null ) continue;
+                double sc = Double.parseDouble(b.getCheck_score_avg());
+                if (sc == 0) {
+                    returnObj.setScore(returnObj.getScore() + 1);
+                } else if (sc <= 15) {
+                    returnObj.setScore_fifteen(returnObj.getScore_fifteen() + 1);
+                } else if (sc <= 50) {
+                    returnObj.setScore_fifty(returnObj.getScore_fifty() + 1);
+                } else {
+                    returnObj.setScore_over_fifty(returnObj.getScore_over_fifty() + 1);
+                }
+
+
+            }
+        }
+
+
+//        for (StatisticsBean sta : userLostScoreInfoList) {
+//            if (listmap.containsKey(sta.getUser_id().intValue())) {
+//                StatisticsBo bo = listmap.get(sta.getUser_id().intValue());
+//                double score =  Double.parseDouble(bo.getCheck_score_avg());
+//                if(score==0){
+//                    continue;
+//                }else
+//                if (score  <= 15) {
+//                    returnObj.setScore_fifteen(returnObj.getScore_fifteen() + 1);
+//                } else if (score <= 50 ) {
+//                    returnObj.setScore_fifty(returnObj.getScore_fifty() + 1);
+//                } else {
+//                    returnObj.setScore_over_fifty(returnObj.getScore_over_fifty() + 1);
+//                }
+//            }
+//		}
 		returnObj.setPeople_num(people_num);
 
 		return returnObj;