|
@@ -17,9 +17,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import com.xintong.visualinspection.bean.*;
|
|
import com.xintong.visualinspection.bean.*;
|
|
|
-import com.xintong.visualinspection.dao.master.CheckOtherDao;
|
|
|
|
|
-import com.xintong.visualinspection.dao.master.CheckTaskPeriodDao;
|
|
|
|
|
-import com.xintong.visualinspection.dao.master.CheckUserStatisticsDao;
|
|
|
|
|
|
|
+import com.xintong.visualinspection.dao.master.*;
|
|
|
import com.xintong.visualinspection.pojo.StatisiticPojo;
|
|
import com.xintong.visualinspection.pojo.StatisiticPojo;
|
|
|
import com.xintong.visualinspection.pojo.StatisticExUser;
|
|
import com.xintong.visualinspection.pojo.StatisticExUser;
|
|
|
import com.xintong.visualinspection.pojo.UserRankingData;
|
|
import com.xintong.visualinspection.pojo.UserRankingData;
|
|
@@ -32,7 +30,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import com.xintong.visualinspection.dao.cluster.DepartmentDao;
|
|
import com.xintong.visualinspection.dao.cluster.DepartmentDao;
|
|
|
import com.xintong.visualinspection.dao.cluster.UserInfoDao;
|
|
import com.xintong.visualinspection.dao.cluster.UserInfoDao;
|
|
|
-import com.xintong.visualinspection.dao.master.StatisticsDao;
|
|
|
|
|
import com.xintong.visualinspection.service.BaseService;
|
|
import com.xintong.visualinspection.service.BaseService;
|
|
|
import com.xintong.visualinspection.service.StatisticsService;
|
|
import com.xintong.visualinspection.service.StatisticsService;
|
|
|
import com.xintong.visualinspection.util.CacheUtil;
|
|
import com.xintong.visualinspection.util.CacheUtil;
|
|
@@ -66,6 +63,9 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CheckUserStatisticsDao checkUserStatisticsDao;
|
|
private CheckUserStatisticsDao checkUserStatisticsDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CheckDeptStatisticsDao checkDeptStatisticsDao;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ThreadTaskService threadTaskService;
|
|
private ThreadTaskService threadTaskService;
|
|
|
|
|
|
|
@@ -2574,5 +2574,134 @@ public class StatisticsServiceImpl extends BaseService implements StatisticsServ
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, List<DeptStatistic>> getDeptStatistic(DeptStatistic obj) {
|
|
|
|
|
+ List<CheckTaskPeriod> checkTaskPeriods = checkTaskPeriodDao.select(new CheckTaskPeriod());
|
|
|
|
|
+
|
|
|
|
|
+ for (CheckTaskPeriod p : checkTaskPeriods) {
|
|
|
|
|
+ if (obj.getStart_date() + 1 * 1000 * 60 * 60 == p.getEndtime().getTime()) {
|
|
|
|
|
+ obj.setStartperiod_id(p.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getEnd_date() + 1 * 1000 * 60 * 60 == p.getEndtime().getTime()) {
|
|
|
|
|
+ obj.setEndperiod_id(p.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(obj.getStart_date()>(checkTaskPeriods.get(checkTaskPeriods.size()-1).getEndtime().getTime()- 1 * 1000 * 60 * 60)){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(obj.getEnd_date()<(checkTaskPeriods.get(0).getEndtime().getTime()- 1 * 1000 * 60 * 60)){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(obj.getStart_date()<(checkTaskPeriods.get(0).getEndtime().getTime()- 1 * 1000 * 60 * 60)){
|
|
|
|
|
+ obj.setStartperiod_id(checkTaskPeriods.get(0).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(obj.getEnd_date()>(checkTaskPeriods.get(checkTaskPeriods.size()-1).getEndtime().getTime()- 1 * 1000 * 60 * 60)){
|
|
|
|
|
+ obj.setEndperiod_id(checkTaskPeriods.get(checkTaskPeriods.size()-1).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<DeptStatistic> deptStatistics = checkDeptStatisticsDao.selectdepts(obj);
|
|
|
|
|
+ if(deptStatistics.size()<1) return null;
|
|
|
|
|
+ Map<String,List<DeptStatistic>> listMap = new HashMap<>();
|
|
|
|
|
+ Map<Long,List<DeptStatistic>> listMap1 = new HashMap<>();
|
|
|
|
|
+ for (DeptStatistic s :deptStatistics
|
|
|
|
|
+ ) {
|
|
|
|
|
+
|
|
|
|
|
+ //按月统计
|
|
|
|
|
+ if(listMap.get(s.getPeriod_id()+"")==null){
|
|
|
|
|
+ List<DeptStatistic> t = new ArrayList<>();
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap.put(s.getPeriod_id()+"",t);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ List<DeptStatistic> t = listMap.get(s.getPeriod_id()+"");
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap.put(s.getPeriod_id()+"",t);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //按部门统计
|
|
|
|
|
+ if(listMap1.get(s.getDept_id())==null){
|
|
|
|
|
+ List<DeptStatistic> t = new ArrayList<>();
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap1.put(s.getDept_id(),t);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ List<DeptStatistic> t = listMap1.get(s.getDept_id());
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap1.put(s.getDept_id(),t);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// 按月划分
|
|
|
|
|
+ for (CheckTaskPeriod p :checkTaskPeriods) {
|
|
|
|
|
+ if(p.getId()>=obj.getStartperiod_id() && p.getId()<=obj.getEndperiod_id() ){
|
|
|
|
|
+ //符合要求的周期 计算得分
|
|
|
|
|
+ for (Long tp:listMap1.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ List<DeptStatistic> deptStatistics1 = listMap1.get(tp);
|
|
|
|
|
+ //该周期每一个部门
|
|
|
|
|
+ //计算累计
|
|
|
|
|
+ Integer s = 0;
|
|
|
|
|
+ for (DeptStatistic ss:deptStatistics1
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if(ss.getPeriod_id()<=p.getId()){
|
|
|
|
|
+ s+=ss.getIntegral();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SimpleDateFormat ff = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ //赋值
|
|
|
|
|
+ for (DeptStatistic ss:deptStatistics1
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if(ss.getPeriod_id()==p.getId()){
|
|
|
|
|
+ ss.setTotal_integral(s);
|
|
|
|
|
+ ss.setDept_name(CacheUtil.getOrgannameFromMap(ss.getDept_id()));
|
|
|
|
|
+ ss.setTime(ff.format(p.getEndtime()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //计算排名
|
|
|
|
|
+ List<DeptStatistic> deptStatistics1 = listMap.get(p.getId()+"");
|
|
|
|
|
+ if(deptStatistics1!=null) {
|
|
|
|
|
+ deptStatistics1.sort(new Comparator<DeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(DeptStatistic o1, DeptStatistic o2) {
|
|
|
|
|
+ return o1.getTotal_integral() > o2.getTotal_integral() ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ for (int i = 0; i < deptStatistics1.size(); i++) {
|
|
|
|
|
+ deptStatistics1.get(i).setTotal_ranking(i + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //排序
|
|
|
|
|
+ for (String i :listMap.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ listMap.get(i).sort(new Comparator<DeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(DeptStatistic o1, DeptStatistic o2) {
|
|
|
|
|
+ return o1.getDept_id()>o2.getDept_id()?1:-1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ listMap.clear();
|
|
|
|
|
+ for (Long s:listMap1.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ List<DeptStatistic> l = listMap1.get(s);
|
|
|
|
|
+ l.sort(new Comparator<DeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(DeptStatistic o1, DeptStatistic o2) {
|
|
|
|
|
+ return o1.getPeriod_id()> o2.getPeriod_id()?1:-1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ listMap.put(l.get(0).getDept_id()+"",l);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return listMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
}
|
|
}
|