|
|
@@ -0,0 +1,1152 @@
|
|
|
+package com.xintong.visualinspection.visuallnspection_qzd.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.dubbo.config.annotation.Reference;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.xintong.visualinspection.bean.CheckTaskPeriod;
|
|
|
+import com.xintong.visualinspection.bean.FeeStation;
|
|
|
+import com.xintong.visualinspection.bean.FwqDeptStatistic;
|
|
|
+import com.xintong.visualinspection.bean.FwqStatisticsBean;
|
|
|
+import com.xintong.visualinspection.bean.FwqStatisticsBo;
|
|
|
+import com.xintong.visualinspection.bean.Item;
|
|
|
+import com.xintong.visualinspection.bean.Organ;
|
|
|
+import com.xintong.visualinspection.pojo.fwq.FwqRankingData;
|
|
|
+import com.xintong.visualinspection.pojo.fwq.FwqStatisiticPojo;
|
|
|
+import com.xintong.visualinspection.pojo.fwq.ServiceAreaStatistic;
|
|
|
+import com.xintong.visualinspection.service.CommonService;
|
|
|
+import com.xintong.visualinspection.service.StatisticsService_F;
|
|
|
+import com.xintong.visualinspection.visuallnspection_qzd.dao.FwqCheckDeptStatisticsDao;
|
|
|
+import com.xintong.visualinspection.visuallnspection_qzd.dao.FwqStatisticsDao;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 文件名:StatisticsServiceImpl
|
|
|
+ * 版本信息:日期:2017/4/7 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
|
|
|
+ *
|
|
|
+ * @author huangcheng
|
|
|
+ * @date 2018/05/02
|
|
|
+ */
|
|
|
+
|
|
|
+@com.alibaba.dubbo.config.annotation.Service(
|
|
|
+ version = "1.0.0",
|
|
|
+ application = "${dubbo.application.id}",
|
|
|
+ protocol = "${dubbo.protocol.id}",
|
|
|
+ registry = "${dubbo.registry.id}",
|
|
|
+ timeout = 3000
|
|
|
+)
|
|
|
+public class StatisticsServiceImpl implements StatisticsService_F {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(StatisticsServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FwqStatisticsDao fwqStatisticsDao;
|
|
|
+ @Autowired
|
|
|
+ private FwqCheckDeptStatisticsDao fwqCheckDeptStatisticsDao;
|
|
|
+
|
|
|
+ @Reference(version = "1.0.0",
|
|
|
+ application = "${dubbo.application.id}",
|
|
|
+ registry = "${dubbo.registry.address}")
|
|
|
+ private CommonService commonService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getOperationInfo(FwqStatisticsBean obj) {
|
|
|
+
|
|
|
+ // 获得所有服务区数据
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ Map<Long, FwqStatisticsBean> mapStationInfos = new HashMap<>();
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBean obj2 = new FwqStatisticsBean();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ mapStationInfos.put(Long.valueOf(sta.getDeptid()), obj2);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取公司检查的某个收费站的受检次数和扣分合计
|
|
|
+ List<FwqStatisticsBean> company_beans = getFeeStationCheckItemScore(obj);
|
|
|
+ // 获取第三方暗访稽查的某个服务区的受检次数和扣分合计
|
|
|
+ obj.setCheck_type(8);
|
|
|
+ List<FwqStatisticsBean> third_beans = fwqStatisticsDao.getselectFeeStationOperationScoreDetail(obj);
|
|
|
+ // 获取现场稽查的某个服务区的受检次数和扣分合计
|
|
|
+ obj.setCheck_type(9);
|
|
|
+ List<FwqStatisticsBean> onsite_beans = fwqStatisticsDao.getselectFeeStationOperationScoreDetail(obj);
|
|
|
+
|
|
|
+ for (FwqStatisticsBean company_bean : company_beans) {
|
|
|
+ mapStationInfos.get(company_bean.getDept_id()).setCompany_check_num(company_bean.getChecked_num());
|
|
|
+ mapStationInfos.get(company_bean.getDept_id()).setCompany_total_score(company_bean.getAll_check_score());
|
|
|
+ }
|
|
|
+ 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_total_score(third_bean.getCheck_total_score());
|
|
|
+ }
|
|
|
+
|
|
|
+ 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_total_score(onsite_bean.getCheck_total_score());
|
|
|
+ }
|
|
|
+ // 计算出每个收费站的总平均扣分和平均得分
|
|
|
+ Set<Map.Entry<Long, FwqStatisticsBean>> stationInfos = mapStationInfos.entrySet();
|
|
|
+ // 保留二位小数
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ for (Map.Entry<Long, FwqStatisticsBean> station : stationInfos) {
|
|
|
+ float avg = 0;
|
|
|
+ FwqStatisticsBean value = station.getValue();
|
|
|
+ value.setThird_check_num(1);
|
|
|
+ value.setOnsite_check_num(1);
|
|
|
+ // 设置总平均扣分
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ if (value.getOnsite_check_num() > 0) {
|
|
|
+ avg += value.getOnsite_total_score() / 2.0 / value.getOnsite_check_num();
|
|
|
+ }
|
|
|
+ value.setCheck_total_avg(df.format(avg));
|
|
|
+ // 设置平均得分
|
|
|
+ Float score_avg = (1000 - Float.valueOf(df.format(avg)));
|
|
|
+ value.setScore_avg(score_avg.toString());
|
|
|
+ }
|
|
|
+ List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
|
|
|
+ sortList.sort(new Comparator<FwqStatisticsBean>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBean o1, FwqStatisticsBean o2) {
|
|
|
+ return o1.compare3To(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> temp = new ArrayList<>();
|
|
|
+ temp.addAll(sortList);
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
+ for (FwqStatisticsBean aSortList : sortList) {
|
|
|
+ if (deptMap.get(aSortList.getDept_id()) != null) {
|
|
|
+ if (deptMap.get(aSortList.getDept_id()).getCreattime().getTime() > obj.getEnd_date().getTime()) {
|
|
|
+ temp.remove(aSortList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ sortList = temp;
|
|
|
+
|
|
|
+ for (int j = 0; j < sortList.size(); j++) {
|
|
|
+ FwqStatisticsBean statisticsBean = sortList.get(j);
|
|
|
+ // 公司排名
|
|
|
+ if (j == 0) {
|
|
|
+ statisticsBean.setCompany_ranking2(1);
|
|
|
+ } else {
|
|
|
+ FwqStatisticsBean bean = sortList.get(j - 1);
|
|
|
+ if (statisticsBean.compare3To(bean) == 0) {
|
|
|
+ statisticsBean.setCompany_ranking2(bean.getCompany_ranking2());
|
|
|
+ } else {
|
|
|
+ statisticsBean.setCompany_ranking2(j + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ CheckTaskPeriod period = commonService.getCheckTaskPeriod(obj.getStart_date().getTime()+1 * 1000 * 60 * 60, obj.getEnd_date().getTime()+1 * 1000 * 60 * 60);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @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() + 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<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 j = 0; j < deptStatistics1.size(); j++) {
|
|
|
+ FwqDeptStatistic statisticsBean = deptStatistics1.get(j);
|
|
|
+ // 排名
|
|
|
+ if (j == 0) {
|
|
|
+ statisticsBean.setTotal_ranking(1);
|
|
|
+ } else {
|
|
|
+ FwqDeptStatistic bean = deptStatistics1.get(j - 1);
|
|
|
+ if (statisticsBean.getTotal_integral().equals(bean.getTotal_integral())) {
|
|
|
+ statisticsBean.setTotal_ranking(bean.getTotal_ranking());
|
|
|
+ } else {
|
|
|
+ statisticsBean.setTotal_ranking(j + 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getFeeStationCheckItemScore(FwqStatisticsBean obj) {
|
|
|
+
|
|
|
+ // 获得所有服务区数据
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+ Map<Long, FwqStatisticsBean> mapStationInfos = new HashMap<>();
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBean obj2 = new FwqStatisticsBean();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ // 30:连云港道管;31:盐城道管;32:南通道管
|
|
|
+ if ("30".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(1);
|
|
|
+ } else if ("31".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(2);
|
|
|
+ } else if ("32".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(3);
|
|
|
+ }
|
|
|
+ mapStationInfos.put(Long.valueOf(sta.getDeptid()), obj2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getStart_date() != null && obj.getEnd_date() != null) {
|
|
|
+ CheckTaskPeriod p = commonService.getCheckTaskPeriod(obj.getStart_date().getTime()+1 * 1000 * 60 * 60, obj.getEnd_date().getTime()+1 * 1000 * 60 * 60);
|
|
|
+ if (p != null) {
|
|
|
+ obj.setPeriod_id(p.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //服务区检查次数
|
|
|
+ List<FwqStatisticsBean> listCheckNum = fwqStatisticsDao.selectFeeStationCheckNum(obj);
|
|
|
+ for (FwqStatisticsBean sta : listCheckNum) {
|
|
|
+ if (mapStationInfos.containsKey(sta.getDept_id())) {
|
|
|
+ mapStationInfos.get(sta.getDept_id()).setChecked_num(sta.getChecked_num());
|
|
|
+// mapStationInfos.get(sta.getDept_id()).setChecked_people_num(sta.getChecked_people_num());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> listCheckedScore = fwqStatisticsDao.selectFeeStationCheckedPersonScoreDetail(obj);
|
|
|
+
|
|
|
+ // 处理同一个服务区中,如果item的parent_id是一样的话,将这些数据结合在一起
|
|
|
+ for (FwqStatisticsBean sta : listCheckedScore) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ }
|
|
|
+ for (int i = 0; i < listCheckedScore.size(); i++) {
|
|
|
+ for (int j = listCheckedScore.size() - 1; j > i; j--) {
|
|
|
+ if (listCheckedScore.get(j).getDept_id().equals(listCheckedScore.get(i).getDept_id()) && listCheckedScore.get(j).getItem_id().equals(listCheckedScore.get(i).getItem_id())) {
|
|
|
+ listCheckedScore.get(i).setScore(listCheckedScore.get(i).getScore() + listCheckedScore.get(j).getScore());
|
|
|
+ listCheckedScore.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FwqStatisticsBean sta : listCheckedScore) {
|
|
|
+ if (mapStationInfos.containsKey(sta.getDept_id())) {
|
|
|
+ FwqStatisticsBean statis = mapStationInfos.get(sta.getDept_id());
|
|
|
+ statis.setAll_check_score(statis.getAll_check_score() + sta.getScore());
|
|
|
+ // 组装扣分类型内容
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()).getParent_id() != null) {
|
|
|
+ sta.setId(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()).getScore() == null) {
|
|
|
+ sta.setName(itemMap.get(sta.getCheck_item_id().longValue()).getName());
|
|
|
+ } else {
|
|
|
+ sta.setName(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ statis.getChecked_socre_name().add(sta.getName());
|
|
|
+ statis.getChecked_score().add(sta.getScore());
|
|
|
+ statis.getChecked_score_ids().add(sta.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
|
|
|
+
|
|
|
+ sortList.sort(new Comparator<FwqStatisticsBean>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBean o1, FwqStatisticsBean o2) {
|
|
|
+ if (o1.getId() > o2.getId()) {
|
|
|
+ return 1;
|
|
|
+ } else if (o1.getId().equals(o2.getId())) {
|
|
|
+ if (o1.getChecked_num() != 0 && o2.getChecked_num() != 0) {
|
|
|
+ if (o1.getAll_check_score() / (o1.getChecked_num() + 0.0) > o2.getAll_check_score()
|
|
|
+ / (o2.getChecked_num() + 0.0)) {
|
|
|
+ return 1;
|
|
|
+ } else if (o1.getAll_check_score() / (o1.getChecked_num() + 0.0) < o2.getAll_check_score()
|
|
|
+ / (o2.getChecked_num() + 0.0)) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (o1.getChecked_num() == 0) {
|
|
|
+ return -1;
|
|
|
+ } else if (o2.getChecked_num() == 0) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return sortList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FwqRankingData getEmployeeRankingData(FwqStatisticsBean obj) {
|
|
|
+ FwqRankingData data = new FwqRankingData();
|
|
|
+
|
|
|
+ CheckTaskPeriod lastTaskPeriod = commonService.getCheckTaskPeriod(obj.getStart_date().getTime()+1 * 1000 * 60 * 60, obj.getEnd_date().getTime()+1 * 1000 * 60 * 60);
|
|
|
+ if (lastTaskPeriod != null) {
|
|
|
+ FwqStatisticsBean temp = new FwqStatisticsBean();
|
|
|
+ temp.setStart_date(new Date(lastTaskPeriod.getStarttime().getTime() - 1 * 1000 * 60 * 60));
|
|
|
+ temp.setEnd_date(new Date(lastTaskPeriod.getEndtime().getTime() - 1 * 1000 * 60 * 60));
|
|
|
+ List<FwqStatisticsBo> list = getEmployeeCheckedInfo(temp);
|
|
|
+ if (list == null || list.size() < 1) {
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ for (FwqStatisticsBo b : list) {
|
|
|
+ if (b.getDept_id().intValue() == obj.getDept_id().intValue()) {
|
|
|
+ data.setLastP(b);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<FwqStatisticsBo> list = getEmployeeCheckedInfo(obj);
|
|
|
+ if (list == null || list.size() < 1) {
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ for (FwqStatisticsBo b : list) {
|
|
|
+ if (b.getDept_id().intValue() == obj.getDept_id().intValue()) {
|
|
|
+ data.setCurrentP(b);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getOneCheckedDetailInfo(Integer page, Integer size, FwqStatisticsBean obj) {
|
|
|
+ if (!(page.equals(0) && size.equals(0))) {
|
|
|
+ PageHelper.startPage(page, size);
|
|
|
+ }
|
|
|
+ List<FwqStatisticsBean> list = fwqStatisticsDao.selectOneCheckedDetailInfo(obj);
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+
|
|
|
+ for (FwqStatisticsBean sta : list) {
|
|
|
+ // 组装扣分类型内容
|
|
|
+ if (sta.getCheck_item_id() != null) {
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()) != null) {
|
|
|
+ sta.setName(itemMap.get(sta.getCheck_item_id().longValue()).getName());
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()).getParent_id() != null) {
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()).getScore() == null) {
|
|
|
+ sta.setParent_name(itemMap.get(sta.getCheck_item_id().longValue()).getName());
|
|
|
+ } else {
|
|
|
+ sta.setParent_name(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getQueryType() == 0) {
|
|
|
+ for (FwqStatisticsBean sta : list) {
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ SimpleDateFormat formatter2 = new SimpleDateFormat("- HH:mm");
|
|
|
+ sta.setCheck_task_time_name(
|
|
|
+ formatter.format(sta.getStart_date()) + formatter2.format(sta.getEnd_date()));
|
|
|
+// if (sta.getDept_id() != null && obj.getDept_id() != null) {
|
|
|
+// sta.setChecked_name(CacheUtil.getUserFromMap(sta.getUser_id()).getTruename()
|
|
|
+// + (obj.getUser_id().intValue() == sta.getUser_id().intValue() ? "" : "(组员)"));
|
|
|
+//
|
|
|
+// }
|
|
|
+ }
|
|
|
+ } /*else if (obj.getQueryType() == 1) {
|
|
|
+ for (FwqStatisticsBean sta : list) {
|
|
|
+ sta.setCheckman_name(CacheUtil.getUserFromMap(sta.getCheckman_id() + 0L).getTruename());
|
|
|
+ sta.setChecked_name(CacheUtil.getUserFromMap(sta.getUser_id() + 0L).getTruename());
|
|
|
+ sta.setFeeStationName(CacheUtil.getOrganFromMap(sta.getDept_id()).getOrganname());
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ SimpleDateFormat formatter2 = new SimpleDateFormat("- HH:mm");
|
|
|
+ sta.setCheck_task_time_name(
|
|
|
+ formatter.format(sta.getStart_date()) + formatter2.format(sta.getEnd_date()));
|
|
|
+
|
|
|
+ if (sta.getUser_id() != null && obj.getUser_id() != null && obj.getQueryType() != null
|
|
|
+ && obj.getQueryType().intValue() == 0) {
|
|
|
+ sta.setChecked_name(CacheUtil.getUserFromMap(sta.getUser_id()).getTruename()
|
|
|
+ + (obj.getUser_id().intValue() == sta.getUser_id().intValue() ? "" : "(组员)"));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if (!(page.equals(0) && size.equals(0))) {
|
|
|
+ return new PageInfo<FwqStatisticsBean>(list);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getOneSACheckedInfo(FwqStatisticsBean obj) {
|
|
|
+ return fwqStatisticsDao.selectOneCheckedInfoData(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getOneCheckedItemInfo(FwqStatisticsBean obj) {
|
|
|
+ List<FwqStatisticsBean> listCheckedScore = fwqStatisticsDao.selectOneCheckedItemInfo(obj);
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+ // 处理同一个服务区中,如果item的parent_id是一样的话,将这些数据结合在一起
|
|
|
+ for (FwqStatisticsBean sta : listCheckedScore) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ if (itemMap.get(sta.getCheck_item_id().longValue()).getScore() == null) {
|
|
|
+ sta.setName(itemMap.get(sta.getCheck_item_id().longValue()).getName());
|
|
|
+ } else {
|
|
|
+ sta.setName(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < listCheckedScore.size(); i++) {
|
|
|
+ for (int j = listCheckedScore.size() - 1; j > i; j--) {
|
|
|
+ if (listCheckedScore.get(j).getDept_id().equals(listCheckedScore.get(i).getDept_id()) && listCheckedScore.get(j).getItem_id().equals(listCheckedScore.get(i).getItem_id())) {
|
|
|
+ listCheckedScore.get(i).setAll_check_score(listCheckedScore.get(i).getAll_check_score() + listCheckedScore.get(j).getAll_check_score());
|
|
|
+ listCheckedScore.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return listCheckedScore;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBo> getEmployeeCheckedInfo(FwqStatisticsBean obj) {
|
|
|
+
|
|
|
+ // 将检索出来的数据放到如map中
|
|
|
+ List<FwqStatisticsBean> list = fwqStatisticsDao.selectStatistics(obj);
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
+ // 将list中的数据找到项目的父项目,然后去除重复的
|
|
|
+ for (FwqStatisticsBean sta : list) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ }
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ for (int j = list.size() - 1; j > i; j--) {
|
|
|
+ if (list.get(j).getDept_id().equals(list.get(i).getDept_id()) && list.get(j).getItem_id().equals(list.get(i).getItem_id())) {
|
|
|
+ list.get(i).setScore(list.get(i).getScore() + list.get(j).getScore());
|
|
|
+ list.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询服务区受检次数
|
|
|
+ List<FwqStatisticsBean> timesList = fwqStatisticsDao.selectCheckedTimes(obj);
|
|
|
+
|
|
|
+ Map<Long, FwqStatisticsBo> statisticBoMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 获得所有服务区数据,将服务区数据保存在map中
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBo obj2 = new FwqStatisticsBo();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ // 30:连云港道管;31:盐城道管;32:南通道管
|
|
|
+ if ("30".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(1);
|
|
|
+ } else if ("31".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(2);
|
|
|
+ } else if ("32".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(3);
|
|
|
+ }
|
|
|
+ statisticBoMap.put(Long.valueOf(sta.getDeptid()), obj2);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FwqStatisticsBean statisticsBean : list) {
|
|
|
+ if (statisticBoMap.containsKey(statisticsBean.getDept_id())) {
|
|
|
+ FwqStatisticsBo tmp = statisticBoMap.get(statisticsBean.getDept_id());
|
|
|
+ // 组装扣分类型内容
|
|
|
+ if (itemMap.get(statisticsBean.getCheck_item_id().longValue()).getParent_id() != null) {
|
|
|
+ statisticsBean.setId(itemMap.get(statisticsBean.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ if (itemMap.get(statisticsBean.getCheck_item_id().longValue()).getScore() == null) {
|
|
|
+ statisticsBean.setName(itemMap.get(statisticsBean.getCheck_item_id().longValue()).getName());
|
|
|
+ } else {
|
|
|
+ statisticsBean.setName(itemMap.get(itemMap.get(statisticsBean.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmp.getChecked_socre_name().add(statisticsBean.getName());
|
|
|
+ tmp.getChecked_score().add(statisticsBean.getScore());
|
|
|
+ tmp.setCheck_all_score(tmp.getCheck_all_score() + statisticsBean.getScore());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FwqStatisticsBean statisticsBean : timesList) {
|
|
|
+ if (statisticBoMap.containsKey(statisticsBean.getDept_id())) {
|
|
|
+ FwqStatisticsBo tmp = statisticBoMap.get(statisticsBean.getDept_id());
|
|
|
+ tmp.setChecked_num(statisticsBean.getChecked_num());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBo> lists = new ArrayList<>(statisticBoMap.values());
|
|
|
+ // 进行排序
|
|
|
+ lists.sort(new Comparator<FwqStatisticsBo>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBo o1, FwqStatisticsBo o2) {
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 道管Map
|
|
|
+ // 排名
|
|
|
+// Map<String, Integer> center_ranking = new HashMap<>();
|
|
|
+ // 留last
|
|
|
+// Map<String, FwqStatisticsBo> center_ranking2 = new HashMap<>();
|
|
|
+// center_ranking.put("30", 1);
|
|
|
+// center_ranking.put("31", 1);
|
|
|
+// center_ranking.put("32", 1);
|
|
|
+//
|
|
|
+// center_ranking2.put("30", null);
|
|
|
+// center_ranking2.put("31", null);
|
|
|
+// center_ranking2.put("32", null);
|
|
|
+
|
|
|
+// Map<String, Integer> service_area_ranking = new HashMap<>();
|
|
|
+// Map<String, FwqStatisticsBo> service_area_ranking2 = new HashMap<>();
|
|
|
+ // 这边需要对道管和服务区进行排名
|
|
|
+// for (FeeStation fee : saList) {
|
|
|
+// service_area_ranking.put(fee.getDeptid(), 1);
|
|
|
+// service_area_ranking2.put(fee.getDeptid(), null);
|
|
|
+// }
|
|
|
+
|
|
|
+ for (int i = 0; i < lists.size(); i++) {
|
|
|
+
|
|
|
+ FwqStatisticsBo statisticsBo = lists.get(i);
|
|
|
+ if (statisticsBo.getChecked_num() + statisticsBo.getChecked_m_num() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 计算平均扣分
|
|
|
+ DecimalFormat df = new DecimalFormat(".##");
|
|
|
+ double count = statisticsBo.getChecked_num() + statisticsBo.getChecked_m_num();
|
|
|
+ Double sc = (statisticsBo.getCheck_all_score() + statisticsBo.getCheck_all_m_score()) * 1.00
|
|
|
+ / (count == 0 ? 1 : count);
|
|
|
+ statisticsBo.setCheck_score_avg(sc == 0 ? "0" : df.format(sc));
|
|
|
+
|
|
|
+ // 累计道管排名
|
|
|
+ // 获取道管id
|
|
|
+// String centerId = deptMap.get(statisticsBo.getDept_id()).getParentid().toString();
|
|
|
+//
|
|
|
+// if (center_ranking2.get(centerId) == null) {
|
|
|
+// statisticsBo.setCenter_ranking(center_ranking.get(centerId));
|
|
|
+// } else {
|
|
|
+// center_ranking.put(centerId, center_ranking.get(centerId) + 1);
|
|
|
+// if (statisticsBo.compareTo(center_ranking2.get(centerId)) == 0) {
|
|
|
+// statisticsBo.setCenter_ranking(center_ranking2.get(centerId).getCenter_ranking());
|
|
|
+// } else {
|
|
|
+// statisticsBo.setCenter_ranking(center_ranking.get(centerId));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// center_ranking2.put(centerId, statisticsBo);
|
|
|
+
|
|
|
+ // 累计服务区的排名
|
|
|
+// String serviceAreaId = statisticsBo.getDept_id().toString();
|
|
|
+
|
|
|
+// if (service_area_ranking2.get(serviceAreaId) == null) {
|
|
|
+// statisticsBo.setService_area_ranking(service_area_ranking.get(serviceAreaId));
|
|
|
+// } else {
|
|
|
+// service_area_ranking.put(serviceAreaId, service_area_ranking.get(serviceAreaId) + 1);
|
|
|
+// if (statisticsBo.compareTo(service_area_ranking2.get(serviceAreaId)) == 0) {
|
|
|
+// statisticsBo.setService_area_ranking(service_area_ranking2.get(serviceAreaId).getService_area_ranking());
|
|
|
+// } else {
|
|
|
+// statisticsBo.setService_area_ranking(service_area_ranking.get(serviceAreaId));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// service_area_ranking2.put(serviceAreaId, statisticsBo);
|
|
|
+
|
|
|
+ // 公司排名s
|
|
|
+ if (i == 0) {
|
|
|
+ statisticsBo.setCompany_ranking(1);
|
|
|
+ } else {
|
|
|
+ FwqStatisticsBo lastbo = lists.get(i - 1);
|
|
|
+ if (statisticsBo.compareTo(lastbo) == 0) {
|
|
|
+ statisticsBo.setCompany_ranking(lastbo.getCompany_ranking());
|
|
|
+ } else {
|
|
|
+ statisticsBo.setCompany_ranking(i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return lists;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getYearScoreChange(FwqStatisticsBean obj) {
|
|
|
+ List<FwqStatisticsBean> list = fwqStatisticsDao.selectYearScoreInfo(obj);
|
|
|
+ return list;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getFeeStationCheckedScore(FwqStatisticsBean obj) {
|
|
|
+
|
|
|
+ Map<Long, FwqStatisticsBean> mapStationInfos = new HashMap<>();
|
|
|
+ // 获得所有服务区数据,将服务区数据保存在map中
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBean obj2 = new FwqStatisticsBean();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ // 30:连云港道管;31:盐城道管;32:南通道管
|
|
|
+ if ("30".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(1);
|
|
|
+ } else if ("31".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(2);
|
|
|
+ } else if ("32".equals(sta.getParentid())) {
|
|
|
+ obj2.setId(3);
|
|
|
+ }
|
|
|
+ mapStationInfos.put(Long.valueOf(sta.getDeptid()), obj2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj.getStart_date() != null && obj.getEnd_date() != null) {
|
|
|
+ CheckTaskPeriod p = commonService.getCheckTaskPeriod(obj.getStart_date().getTime()+1 * 1000 * 60 * 60, obj.getEnd_date().getTime()+1 * 1000 * 60 * 60);
|
|
|
+ if (p != null) {
|
|
|
+ obj.setPeriod_id(p.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查次数
|
|
|
+ List<FwqStatisticsBean> listCheckNum = fwqStatisticsDao.selectFeeStationCheckNum(obj);
|
|
|
+ for (FwqStatisticsBean sta : listCheckNum) {
|
|
|
+ if (mapStationInfos.containsKey(sta.getDept_id())) {
|
|
|
+ mapStationInfos.get(sta.getDept_id()).setChecked_num(sta.getChecked_num());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBo> list = getEmployeeCheckedInfo(obj);
|
|
|
+ Map<Integer, FwqStatisticsBo> listmap = new HashMap<>();
|
|
|
+ for (FwqStatisticsBo b : list) {
|
|
|
+ listmap.put(b.getDept_id().intValue(), b);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> listCheckedScore = fwqStatisticsDao.selectFeeStationCheckedScore(obj);
|
|
|
+ for (FwqStatisticsBean sta : listCheckedScore) {
|
|
|
+ if (mapStationInfos.containsKey(sta.getDept_id())) {
|
|
|
+
|
|
|
+ FwqStatisticsBean statis = mapStationInfos.get(sta.getDept_id());
|
|
|
+ statis.setAll_check_score(statis.getAll_check_score() + sta.getScore());
|
|
|
+
|
|
|
+ FwqStatisticsBo b = listmap.get(sta.getDept_id().intValue());
|
|
|
+
|
|
|
+ if (b == null || b.getCheck_score_avg() == 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
|
|
|
+
|
|
|
+ sortList.sort(new Comparator<FwqStatisticsBean>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBean o1, FwqStatisticsBean o2) {
|
|
|
+ if (o1.getId() > o2.getId()) {
|
|
|
+ return 1;
|
|
|
+ } else if (o1.getId().equals(o2.getId())) {
|
|
|
+ if (o1.getChecked_num() != 0 && o2.getChecked_num() != 0) {
|
|
|
+ if (o1.getAll_check_score() / (o1.getChecked_num() + 0.0) > o2.getAll_check_score()
|
|
|
+ / (o2.getChecked_num() + 0.0)) {
|
|
|
+ return 1;
|
|
|
+ } else if (o1.getAll_check_score() / (o1.getChecked_num() + 0.0) < o2.getAll_check_score()
|
|
|
+ / (o2.getChecked_num() + 0.0)) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (o1.getChecked_num() == 0) {
|
|
|
+ return -1;
|
|
|
+ } else if (o2.getChecked_num() == 0) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return sortList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getCenterManageScoreInfo(FwqStatisticsBean obj) {
|
|
|
+ // 道管中心
|
|
|
+ List<FwqStatisticsBean> centerManageList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 3; i++) {
|
|
|
+ FwqStatisticsBean e = new FwqStatisticsBean();
|
|
|
+ centerManageList.add(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisticsBean> scoreList = reFeeStationScoreInfo(obj);
|
|
|
+ Map<Long, FwqStatisticsBean> centerManageMap = new HashMap<>();
|
|
|
+ for (FwqStatisticsBean sta : scoreList) {
|
|
|
+ if (!centerManageMap.containsKey(sta.getDept_id())) {
|
|
|
+ centerManageMap.put(sta.getDept_id(), sta);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有的服务区
|
|
|
+ List<FwqStatisticsBean> lists = new ArrayList<>();
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBean obj2 = new FwqStatisticsBean();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ obj2.setParent_dept_id(Long.valueOf(sta.getParentid()));
|
|
|
+ lists.add(obj2);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (FwqStatisticsBean sta : lists) {
|
|
|
+ if (sta.getParent_dept_id() == 30) {
|
|
|
+ centerManageList.get(0).setAll_check_score(centerManageList.get(0).getAll_check_score()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getAll_check_score());
|
|
|
+ centerManageList.get(0).setChecked_num(centerManageList.get(0).getChecked_num()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getChecked_num());
|
|
|
+ centerManageList.get(0).setFeeStationName("连云港");
|
|
|
+ } else if (sta.getParent_dept_id() == 31) {
|
|
|
+ centerManageList.get(1).setAll_check_score(centerManageList.get(1).getAll_check_score()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getAll_check_score());
|
|
|
+ centerManageList.get(1).setChecked_num(centerManageList.get(1).getChecked_num()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getChecked_num());
|
|
|
+ centerManageList.get(1).setFeeStationName("盐城");
|
|
|
+ } else if (sta.getParent_dept_id() == 32) {
|
|
|
+ centerManageList.get(2).setAll_check_score(centerManageList.get(2).getAll_check_score()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getAll_check_score());
|
|
|
+ centerManageList.get(2).setChecked_num(centerManageList.get(2).getChecked_num()
|
|
|
+ + centerManageMap.get(sta.getDept_id()).getChecked_num());
|
|
|
+ centerManageList.get(2).setFeeStationName("南通");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 进行排序
|
|
|
+ centerManageList.sort(new Comparator<FwqStatisticsBean>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBean o1, FwqStatisticsBean o2) {
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return centerManageList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getFeeStationScoreInfo(FwqStatisticsBean obj) {
|
|
|
+ List<FwqStatisticsBean> scoreList = reFeeStationScoreInfo(obj);
|
|
|
+
|
|
|
+ scoreList.sort(new Comparator<FwqStatisticsBean>() {
|
|
|
+ @Override
|
|
|
+ public int compare(FwqStatisticsBean o1, FwqStatisticsBean o2) {
|
|
|
+ return o1.compareTo(o2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return scoreList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisticsBean> getCheckedItemScoreInfo(FwqStatisticsBean obj) {
|
|
|
+ List<FwqStatisticsBean> list = fwqStatisticsDao.selectCheckedItemScoreInfo(obj);
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
+ for (FwqStatisticsBean sta : list) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ sta.setName(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ sta.setParent_dept_id(deptMap.get(sta.getDept_id()).getParentid().longValue());
|
|
|
+ }
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ for (int j = list.size() - 1; j > i; j--) {
|
|
|
+ if (list.get(j).getDept_id().equals(list.get(i).getDept_id()) && list.get(j).getItem_id().equals(list.get(i).getItem_id())) {
|
|
|
+ list.get(i).setAll_check_score(list.get(i).getAll_check_score() + list.get(j).getAll_check_score());
|
|
|
+ list.get(i).setChecked_num(list.get(i).getChecked_num() + list.get(j).getChecked_num());
|
|
|
+ list.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, List<FwqStatisticsBean>> get2CheckedItemScoreInfo(FwqStatisticsBean obj) {
|
|
|
+
|
|
|
+ Map<String, List<FwqStatisticsBean>> map = new HashMap<>();
|
|
|
+ List<FwqStatisticsBean> objList = fwqStatisticsDao.selectCheckedItemScoreInfo(obj);
|
|
|
+ Map<Long, Item> itemMap = commonService.getItemMap();
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
+ for (FwqStatisticsBean sta : objList) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ sta.setName(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ sta.setFeeStationName(deptMap.get(sta.getDept_id()).getOrganname());
|
|
|
+ sta.setPfeeStationName(deptMap.get(deptMap.get(sta.getDept_id()).getParentid().longValue()).getOrganname());
|
|
|
+ sta.setParent_dept_id(deptMap.get(sta.getDept_id()).getParentid().longValue());
|
|
|
+ }
|
|
|
+ for (int i = 0; i < objList.size(); i++) {
|
|
|
+ for (int j = objList.size() - 1; j > i; j--) {
|
|
|
+ if (objList.get(j).getDept_id().equals(objList.get(i).getDept_id()) && objList.get(j).getItem_id().equals(objList.get(i).getItem_id())) {
|
|
|
+ objList.get(i).setAll_check_score(objList.get(i).getAll_check_score() + objList.get(j).getAll_check_score());
|
|
|
+ objList.get(i).setChecked_num(objList.get(i).getChecked_num() + objList.get(j).getChecked_num());
|
|
|
+ objList.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("Tmth", objList);
|
|
|
+ obj.setMth(obj.getPrev_mth());
|
|
|
+ objList = fwqStatisticsDao.selectCheckedItemScoreInfo(obj);
|
|
|
+
|
|
|
+ for (FwqStatisticsBean sta : objList) {
|
|
|
+ sta.setItem_id(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id().intValue());
|
|
|
+ sta.setName(itemMap.get(itemMap.get(sta.getCheck_item_id().longValue()).getParent_id()).getName());
|
|
|
+ sta.setFeeStationName(deptMap.get(sta.getDept_id()).getOrganname());
|
|
|
+ sta.setPfeeStationName(deptMap.get(deptMap.get(sta.getDept_id()).getParentid().longValue()).getOrganname());
|
|
|
+ sta.setParent_dept_id(deptMap.get(sta.getDept_id()).getParentid().longValue());
|
|
|
+ }
|
|
|
+ for (int i = 0; i < objList.size(); i++) {
|
|
|
+ for (int j = objList.size() - 1; j > i; j--) {
|
|
|
+ if (objList.get(j).getDept_id().equals(objList.get(i).getDept_id()) && objList.get(j).getItem_id().equals(objList.get(i).getItem_id())) {
|
|
|
+ objList.get(i).setAll_check_score(objList.get(i).getAll_check_score() + objList.get(j).getAll_check_score());
|
|
|
+ objList.get(i).setChecked_num(objList.get(i).getChecked_num() + objList.get(j).getChecked_num());
|
|
|
+ objList.remove(j);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("Pmth", objList);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FwqStatisiticPojo> getFwqStatistic(ServiceAreaStatistic obj) {
|
|
|
+
|
|
|
+ List<CheckTaskPeriod> checkTaskPeriods = commonService.getAllCheckTaskPeriod();
|
|
|
+ Map<Long, Organ> deptMap = commonService.getDeptMap();
|
|
|
+
|
|
|
+ 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 new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (obj.getEnd_date() < (checkTaskPeriods.get(0).getEndtime().getTime() - 1 * 1000 * 60 * 60)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ 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<CheckTaskPeriod> temp_p = new ArrayList<>();
|
|
|
+ for (CheckTaskPeriod p : checkTaskPeriods) {
|
|
|
+ if (p.getId() >= obj.getStartperiod_id() && p.getId() <= obj.getEndperiod_id()) {
|
|
|
+ temp_p.add(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM");
|
|
|
+ //获取满足条件的服务区
|
|
|
+ List<ServiceAreaStatistic> fwqStatistics = fwqStatisticsDao.selectlimituser(obj);
|
|
|
+
|
|
|
+ HashMap<Integer, List<ServiceAreaStatistic>> usm = new HashMap<>();
|
|
|
+
|
|
|
+ for (ServiceAreaStatistic c : fwqStatistics
|
|
|
+ ) {
|
|
|
+ List<ServiceAreaStatistic> s = usm.get(c.getDept_id());
|
|
|
+ if (s == null) {
|
|
|
+ s = new ArrayList<>();
|
|
|
+ }
|
|
|
+ s.add(c);
|
|
|
+ usm.put(c.getDept_id(), s);
|
|
|
+ for (CheckTaskPeriod p : checkTaskPeriods) {
|
|
|
+ if (c.getPeriod_id().equals(p.getId())) {
|
|
|
+ c.setP_str(simpleDateFormat.format(p.getEndtime()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FwqStatisiticPojo> fwq_ids = new ArrayList<>();
|
|
|
+
|
|
|
+ //判断是否连续
|
|
|
+ for (Integer k : usm.keySet()) {
|
|
|
+ List<ServiceAreaStatistic> user_temp = new ArrayList<>();
|
|
|
+ boolean isM = false;
|
|
|
+
|
|
|
+ List<ServiceAreaStatistic> pp = new ArrayList<>();
|
|
|
+ //获取得分
|
|
|
+ List<ServiceAreaStatistic> ll = usm.get(k);
|
|
|
+ int count = 0;
|
|
|
+ for (CheckTaskPeriod p : temp_p) {
|
|
|
+ boolean isfond = false;
|
|
|
+ for (ServiceAreaStatistic s : ll) {
|
|
|
+ if (s.getPeriod_id().equals(p.getId())) {
|
|
|
+ isfond = true;
|
|
|
+ pp.add(s);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isfond) {
|
|
|
+ count++;
|
|
|
+ if (count >= obj.getLimitnumber()) {
|
|
|
+ isM = true;
|
|
|
+ user_temp.addAll(pp);
|
|
|
+ pp.clear();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (count >= obj.getLimitnumber()) {
|
|
|
+ isM = true;
|
|
|
+ user_temp.addAll(pp);
|
|
|
+ }
|
|
|
+ count = 0;
|
|
|
+ pp.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isM) {
|
|
|
+ FwqStatisiticPojo p = new FwqStatisiticPojo();
|
|
|
+ p.setDept_id(k.longValue());
|
|
|
+ p.setDept(deptMap.get(k.longValue()).getOrganname());
|
|
|
+ p.setFwqStatistics(user_temp);
|
|
|
+ fwq_ids.add(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return fwq_ids;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<FwqStatisticsBean> reFeeStationScoreInfo(FwqStatisticsBean obj) {
|
|
|
+ List<FwqStatisticsBean> scoreList = fwqStatisticsDao.selectFeeStationScoreInfo(obj);
|
|
|
+ Map<Long, FwqStatisticsBean> feeStationMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (FwqStatisticsBean feeObj : scoreList) {
|
|
|
+ if (!feeStationMap.containsKey(feeObj.getDept_id())) {
|
|
|
+ feeStationMap.put(feeObj.getDept_id(), feeObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 需要补充的
|
|
|
+ List<FwqStatisticsBean> reList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 获取所有的服务区
|
|
|
+ List<FwqStatisticsBean> feeStationList = new ArrayList<>();
|
|
|
+ List<FeeStation> saList = commonService.getAllDeptByLayer("SA");
|
|
|
+ for (FeeStation sta : saList) {
|
|
|
+ FwqStatisticsBean obj2 = new FwqStatisticsBean();
|
|
|
+ obj2.setDept_id(Long.valueOf(sta.getDeptid()));
|
|
|
+ obj2.setName(sta.getName());
|
|
|
+ feeStationList.add(obj2);
|
|
|
+ }
|
|
|
+ for (FwqStatisticsBean sta : feeStationList) {
|
|
|
+ if (feeStationMap.containsKey(sta.getDept_id())) {
|
|
|
+ feeStationMap.get(sta.getDept_id()).setFeeStationName(sta.getName());
|
|
|
+ } else {
|
|
|
+ sta.setAll_check_score(0);
|
|
|
+ sta.setChecked_num(0);
|
|
|
+ sta.setFeeStationName(sta.getName());
|
|
|
+ reList.add(sta);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scoreList.addAll(reList);
|
|
|
+ return scoreList;
|
|
|
+ }
|
|
|
+}
|