|
|
@@ -0,0 +1,91 @@
|
|
|
+package com.xintong.visualinspection.service.impl;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
+
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import com.xintong.visualinspection.bean.StatisticsBean;
|
|
|
+import com.xintong.visualinspection.bean.StatisticsBo;
|
|
|
+import com.xintong.visualinspection.bean.User;
|
|
|
+import com.xintong.visualinspection.dao.master.StatisticsDao;
|
|
|
+import com.xintong.visualinspection.service.BaseService;
|
|
|
+import com.xintong.visualinspection.service.StatisticsService;
|
|
|
+import com.xintong.visualinspection.util.CacheUtil;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 文件名:StatisticsServiceImpl
|
|
|
+ * 版本信息:日期:2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class StatisticsServiceImpl extends BaseService implements StatisticsService {
|
|
|
+
|
|
|
+ private static final org.slf4j.Logger logger = LoggerFactory.getLogger(StatisticsServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StatisticsDao statisticsDao ;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<StatisticsBo> getEmployeeCheckedInfo(StatisticsBean obj) {
|
|
|
+ // 查看是否有部门id
|
|
|
+ Long organId = obj.getDept_id();
|
|
|
+ // 将检索出来的数据放到如map中
|
|
|
+ List<StatisticsBean> list = statisticsDao.selectStatistics(obj);
|
|
|
+
|
|
|
+ List<StatisticsBean> timesList = statisticsDao.selectCheckedTimes(obj);
|
|
|
+
|
|
|
+ Map<Long,StatisticsBo> statisticBoMap = new HashMap<Long,StatisticsBo>();
|
|
|
+
|
|
|
+ for(User user:CacheUtil.userMap.values()){
|
|
|
+ if(user.getPositionid() ==1){
|
|
|
+ if(organId ==null || user.getOrganid()+0L == organId+0L ){
|
|
|
+ StatisticsBo tmp = new StatisticsBo();
|
|
|
+ tmp.setUser(user);
|
|
|
+ statisticBoMap.put(user.getId()+0L,tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for( StatisticsBean statisticsBean : list ){
|
|
|
+ if(statisticBoMap.containsKey(statisticsBean.getUser_id())){
|
|
|
+ StatisticsBo tmp = statisticBoMap.get(statisticsBean.getUser_id());
|
|
|
+ if(statisticsBean.getName()!=null && statisticsBean.getScore()!=null){
|
|
|
+ tmp.getChecked_socre_name().add(statisticsBean.getName());
|
|
|
+ tmp.getChecked_score().add(statisticsBean.getScore());
|
|
|
+ tmp.setCheck_all_score(tmp.getCheck_all_score()+statisticsBean.getScore() );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(StatisticsBean statisticsBean : timesList){
|
|
|
+ if(statisticBoMap.containsKey(statisticsBean.getUser_id())){
|
|
|
+ StatisticsBo tmp = statisticBoMap.get(statisticsBean.getUser_id());
|
|
|
+ tmp.setChecked_num(statisticsBean.getChecked_num());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StatisticsBo> lists = new ArrayList<>(statisticBoMap.values());
|
|
|
+ // 进行排序
|
|
|
+ lists.sort(new Comparator<StatisticsBo>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int compare(StatisticsBo o1, StatisticsBo o2) {
|
|
|
+ if(o1.getCheck_all_score() >= o2.getCheck_all_score() ){
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ return -1 ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|