|
@@ -1,17 +1,21 @@
|
|
|
package com.xintong.visualinspection.visuallnspection_fjq.service.impl;
|
|
package com.xintong.visualinspection.visuallnspection_fjq.service.impl;
|
|
|
|
|
|
|
|
import com.alibaba.dubbo.config.annotation.Reference;
|
|
import com.alibaba.dubbo.config.annotation.Reference;
|
|
|
|
|
+import com.xintong.visualinspection.bean.CheckTaskPeriod;
|
|
|
import com.xintong.visualinspection.bean.FeeStation;
|
|
import com.xintong.visualinspection.bean.FeeStation;
|
|
|
|
|
+import com.xintong.visualinspection.bean.FwqDeptStatistic;
|
|
|
import com.xintong.visualinspection.bean.FwqStatisticsBean;
|
|
import com.xintong.visualinspection.bean.FwqStatisticsBean;
|
|
|
import com.xintong.visualinspection.bean.Organ;
|
|
import com.xintong.visualinspection.bean.Organ;
|
|
|
import com.xintong.visualinspection.service.CommonService;
|
|
import com.xintong.visualinspection.service.CommonService;
|
|
|
import com.xintong.visualinspection.service.StatisticsService_F;
|
|
import com.xintong.visualinspection.service.StatisticsService_F;
|
|
|
|
|
+import com.xintong.visualinspection.visuallnspection_fjq.dao.FwqCheckDeptStatisticsDao;
|
|
|
import com.xintong.visualinspection.visuallnspection_fjq.dao.FwqStatisticsDao;
|
|
import com.xintong.visualinspection.visuallnspection_fjq.dao.FwqStatisticsDao;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -20,7 +24,7 @@ import java.util.Map;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 文件名:OtherCheckServiceImpl_F
|
|
|
|
|
|
|
+ * 文件名:StatisticsServiceImpl
|
|
|
* 版本信息:日期:2017/4/7 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
|
|
* 版本信息:日期:2017/4/7 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
|
|
|
*
|
|
*
|
|
|
* @author wenhongquan
|
|
* @author wenhongquan
|
|
@@ -31,7 +35,8 @@ import java.util.Set;
|
|
|
version = "1.0.0",
|
|
version = "1.0.0",
|
|
|
application = "${dubbo.application.id}",
|
|
application = "${dubbo.application.id}",
|
|
|
protocol = "${dubbo.protocol.id}",
|
|
protocol = "${dubbo.protocol.id}",
|
|
|
- registry = "${dubbo.registry.id}"
|
|
|
|
|
|
|
+ registry = "${dubbo.registry.id}",
|
|
|
|
|
+ timeout = 3000
|
|
|
)
|
|
)
|
|
|
public class StatisticsServiceImpl implements StatisticsService_F {
|
|
public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
|
|
|
|
@@ -39,13 +44,14 @@ public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FwqStatisticsDao fwqStatisticsDao;
|
|
private FwqStatisticsDao fwqStatisticsDao;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FwqCheckDeptStatisticsDao fwqCheckDeptStatisticsDao;
|
|
|
|
|
|
|
|
@Reference(version = "1.0.0",
|
|
@Reference(version = "1.0.0",
|
|
|
application = "${dubbo.application.id}",
|
|
application = "${dubbo.application.id}",
|
|
|
registry = "${dubbo.registry.address}")
|
|
registry = "${dubbo.registry.address}")
|
|
|
private CommonService commonService;
|
|
private CommonService commonService;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<FwqStatisticsBean> getOperationInfo(FwqStatisticsBean obj) {
|
|
public List<FwqStatisticsBean> getOperationInfo(FwqStatisticsBean obj) {
|
|
|
|
|
|
|
@@ -67,12 +73,12 @@ public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
List<FwqStatisticsBean> onsite_beans = fwqStatisticsDao.getselectFeeStationOperationScoreDetail(obj);
|
|
List<FwqStatisticsBean> onsite_beans = fwqStatisticsDao.getselectFeeStationOperationScoreDetail(obj);
|
|
|
|
|
|
|
|
for (FwqStatisticsBean third_bean : third_beans) {
|
|
for (FwqStatisticsBean third_bean : third_beans) {
|
|
|
- mapStationInfos.get(third_bean.getDept_id()).setThird_check_num(third_bean.getChecked_num()>1?1:third_bean.getChecked_num());
|
|
|
|
|
|
|
+ mapStationInfos.get(third_bean.getDept_id()).setThird_check_num(third_bean.getChecked_num() > 1 ? 1 : third_bean.getChecked_num());
|
|
|
mapStationInfos.get(third_bean.getDept_id()).setThird_total_score(third_bean.getCheck_total_score());
|
|
mapStationInfos.get(third_bean.getDept_id()).setThird_total_score(third_bean.getCheck_total_score());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for (FwqStatisticsBean onsite_bean : onsite_beans) {
|
|
for (FwqStatisticsBean onsite_bean : onsite_beans) {
|
|
|
- mapStationInfos.get(onsite_bean.getDept_id()).setOnsite_check_num(onsite_bean.getChecked_num()>1?1:onsite_bean.getChecked_num());
|
|
|
|
|
|
|
+ mapStationInfos.get(onsite_bean.getDept_id()).setOnsite_check_num(onsite_bean.getChecked_num() > 1 ? 1 : onsite_bean.getChecked_num());
|
|
|
mapStationInfos.get(onsite_bean.getDept_id()).setOnsite_total_score(onsite_bean.getCheck_total_score());
|
|
mapStationInfos.get(onsite_bean.getDept_id()).setOnsite_total_score(onsite_bean.getCheck_total_score());
|
|
|
}
|
|
}
|
|
|
// 计算出每个收费站的总平均扣分和平均得分
|
|
// 计算出每个收费站的总平均扣分和平均得分
|
|
@@ -86,14 +92,14 @@ public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
value.setOnsite_check_num(1);
|
|
value.setOnsite_check_num(1);
|
|
|
// 设置总平均扣分
|
|
// 设置总平均扣分
|
|
|
if (value.getCompany_check_num() > 0 || value.getThird_check_num() > 0) {
|
|
if (value.getCompany_check_num() > 0 || value.getThird_check_num() > 0) {
|
|
|
- avg += (value.getCompany_total_score() +value.getThird_total_score()) /2.0/ (value.getCompany_check_num()+value.getThird_check_num());
|
|
|
|
|
|
|
+ avg += (value.getCompany_total_score() + value.getThird_total_score()) / 2.0 / (value.getCompany_check_num() + value.getThird_check_num());
|
|
|
}
|
|
}
|
|
|
if (value.getOnsite_check_num() > 0) {
|
|
if (value.getOnsite_check_num() > 0) {
|
|
|
- avg += value.getOnsite_total_score() /2.0/ value.getOnsite_check_num();
|
|
|
|
|
|
|
+ avg += value.getOnsite_total_score() / 2.0 / value.getOnsite_check_num();
|
|
|
}
|
|
}
|
|
|
- value.setCheck_total_avg(df.format(avg ));
|
|
|
|
|
|
|
+ value.setCheck_total_avg(df.format(avg));
|
|
|
// 设置平均得分
|
|
// 设置平均得分
|
|
|
- Float score_avg = (1000 - Float.valueOf(df.format(avg )));
|
|
|
|
|
|
|
+ Float score_avg = (1000 - Float.valueOf(df.format(avg)));
|
|
|
value.setScore_avg(score_avg.toString());
|
|
value.setScore_avg(score_avg.toString());
|
|
|
}
|
|
}
|
|
|
List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
|
|
List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
|
|
@@ -117,7 +123,7 @@ public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
}
|
|
}
|
|
|
sortList = temp;
|
|
sortList = temp;
|
|
|
|
|
|
|
|
- for(int j=0;j<sortList.size();j++){
|
|
|
|
|
|
|
+ for (int j = 0; j < sortList.size(); j++) {
|
|
|
FwqStatisticsBean statisticsBean = sortList.get(j);
|
|
FwqStatisticsBean statisticsBean = sortList.get(j);
|
|
|
// 公司排名
|
|
// 公司排名
|
|
|
if (j == 0) {
|
|
if (j == 0) {
|
|
@@ -132,8 +138,204 @@ public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// threadTaskService.saveDeptStatic(sortList,obj.getStart_date().getTime(),obj.getEnd_date().getTime());
|
|
|
|
|
|
|
+ CheckTaskPeriod period = commonService.getCheckTaskPeriod(obj.getStart_date().getTime(), obj.getEnd_date().getTime());
|
|
|
|
|
+
|
|
|
|
|
+ if (period != null) {
|
|
|
|
|
+ for (FwqStatisticsBean s : sortList) {
|
|
|
|
|
+ FwqDeptStatistic ss = new FwqDeptStatistic();
|
|
|
|
|
+ ss.setScore(Double.parseDouble(s.getScore_avg()));
|
|
|
|
|
+ ss.setIntegral(sortList.size() - s.getCompany_ranking2() + 1);
|
|
|
|
|
+ ss.setDept_id(s.getDept_id());
|
|
|
|
|
+ ss.setPeriod_id(period.getId());
|
|
|
|
|
+ fwqCheckDeptStatisticsDao.saveandupdate(ss);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return sortList;
|
|
return sortList;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, List<FwqDeptStatistic>> getDeptStatistic(FwqDeptStatistic obj) {
|
|
|
|
|
+
|
|
|
|
|
+ List<CheckTaskPeriod> checkTaskPeriods = commonService.getAllCheckTaskPeriod();
|
|
|
|
|
+ SimpleDateFormat ff = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ SimpleDateFormat ff1 = new SimpleDateFormat("MM月");
|
|
|
|
|
+
|
|
|
|
|
+ for (CheckTaskPeriod p : checkTaskPeriods) {
|
|
|
|
|
+ if (obj.getStart_date() == p.getEndtime().getTime()) {
|
|
|
|
|
+ obj.setStartperiod_id(p.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getEnd_date() == p.getEndtime().getTime()) {
|
|
|
|
|
+ obj.setEndperiod_id(p.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getStart_date() > (checkTaskPeriods.get(checkTaskPeriods.size() - 1).getEndtime().getTime())) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getEnd_date() < (checkTaskPeriods.get(0).getEndtime().getTime())) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getStart_date() < (checkTaskPeriods.get(0).getEndtime().getTime())) {
|
|
|
|
|
+ obj.setStartperiod_id(checkTaskPeriods.get(0).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj.getEnd_date() > (checkTaskPeriods.get(checkTaskPeriods.size() - 1).getEndtime().getTime())) {
|
|
|
|
|
+ obj.setEndperiod_id(checkTaskPeriods.get(checkTaskPeriods.size() - 1).getId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<FwqDeptStatistic> deptStatistics = fwqCheckDeptStatisticsDao.selectdepts(obj);
|
|
|
|
|
+ Map<String, List<FwqDeptStatistic>> listMap = new HashMap<>();
|
|
|
|
|
+ Map<Long, List<FwqDeptStatistic>> listMap1 = new HashMap<>();
|
|
|
|
|
+ if (deptStatistics.size() > 0) {
|
|
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
|
|
+ for (FwqDeptStatistic s : deptStatistics) {
|
|
|
|
|
+ //按月统计
|
|
|
|
|
+ if (listMap.get(s.getPeriod_id() + "") == null) {
|
|
|
|
|
+ List<FwqDeptStatistic> t = new ArrayList<>();
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap.put(s.getPeriod_id() + "", t);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<FwqDeptStatistic> t = listMap.get(s.getPeriod_id() + "");
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap.put(s.getPeriod_id() + "", t);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //按部门统计
|
|
|
|
|
+ if (listMap1.get(s.getDept_id()) == null) {
|
|
|
|
|
+ List<FwqDeptStatistic> t = new ArrayList<>();
|
|
|
|
|
+ t.add(s);
|
|
|
|
|
+ listMap1.put(s.getDept_id(), t);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<FwqDeptStatistic> 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<FwqDeptStatistic> deptStatistics1 = listMap1.get(tp);
|
|
|
|
|
+ //该周期每一个部门
|
|
|
|
|
+ //计算累计
|
|
|
|
|
+ Integer s = 0;
|
|
|
|
|
+ for (FwqDeptStatistic ss : deptStatistics1
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (ss.getPeriod_id() <= p.getId()) {
|
|
|
|
|
+ s += ss.getIntegral();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //赋值
|
|
|
|
|
+ for (FwqDeptStatistic ss : deptStatistics1
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (ss.getPeriod_id().equals(p.getId())) {
|
|
|
|
|
+ ss.setTotal_integral(s);
|
|
|
|
|
+ ss.setDept_name(deptMap.get(ss.getDept_id()).getOrganname());
|
|
|
|
|
+ ss.setTime(ff.format(p.getEndtime()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //计算排名
|
|
|
|
|
+ List<FwqDeptStatistic> deptStatistics1 = listMap.get(p.getId() + "");
|
|
|
|
|
+ if (deptStatistics1 != null) {
|
|
|
|
|
+ deptStatistics1.sort(new Comparator<FwqDeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(FwqDeptStatistic o1, FwqDeptStatistic 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<FwqDeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(FwqDeptStatistic o1, FwqDeptStatistic o2) {
|
|
|
|
|
+ return o1.getDept_id() > o2.getDept_id() ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ listMap.clear();
|
|
|
|
|
+ for (Long s : listMap1.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ List<FwqDeptStatistic> l = listMap1.get(s);
|
|
|
|
|
+ l.sort(new Comparator<FwqDeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(FwqDeptStatistic o1, FwqDeptStatistic o2) {
|
|
|
|
|
+ return o1.getPeriod_id() > o2.getPeriod_id() ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ listMap.put(l.get(0).getDept_id() + "", l);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (obj.getType() != null && obj.getType().equals(1)) {
|
|
|
|
|
+ //excel数据
|
|
|
|
|
+ for (CheckTaskPeriod p : checkTaskPeriods) {
|
|
|
|
|
+ if (p.getId() >= obj.getStartperiod_id() && p.getId() <= obj.getEndperiod_id()) {
|
|
|
|
|
+ //符合要求的周期 计算得分
|
|
|
|
|
+ for (String i : listMap.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ //单个部门的
|
|
|
|
|
+ List<FwqDeptStatistic> l = listMap.get(i);
|
|
|
|
|
+ FwqDeptStatistic temp = null;
|
|
|
|
|
+ if (l.size() < 1) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean isin = false;
|
|
|
|
|
+ for (FwqDeptStatistic s : l
|
|
|
|
|
+ ) {
|
|
|
|
|
+ if (s.getPeriod_id().equals(p.getId())) {
|
|
|
|
|
+ isin = true;
|
|
|
|
|
+ temp = s;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //不在里面
|
|
|
|
|
+ if (!isin) {
|
|
|
|
|
+ FwqDeptStatistic s = l.get(0).clone();
|
|
|
|
|
+ s.setScore((double) -1);
|
|
|
|
|
+ s.setPeriod_id(p.getId());
|
|
|
|
|
+ s.setIntegral(-1);
|
|
|
|
|
+ s.setTotal_integral(-1);
|
|
|
|
|
+ s.setTotal_ranking(-1);
|
|
|
|
|
+ temp = s;
|
|
|
|
|
+ l.add(s);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ temp.setMString(ff1.format(p.getEndtime()));
|
|
|
|
|
+ listMap.put(i, l);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //再次排序
|
|
|
|
|
+ for (String s : listMap.keySet()
|
|
|
|
|
+ ) {
|
|
|
|
|
+ List<FwqDeptStatistic> l = listMap.get(s);
|
|
|
|
|
+ l.sort(new Comparator<FwqDeptStatistic>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(FwqDeptStatistic o1, FwqDeptStatistic o2) {
|
|
|
|
|
+ return o1.getPeriod_id() > o2.getPeriod_id() ? 1 : -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ listMap.put(l.get(0).getDept_id() + "", l);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return listMap;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|