Преглед изворни кода

考核问题分布报表导出功能

huangchengzdm пре 8 година
родитељ
комит
4efa6a1a44

+ 1 - 1
VisualInspection/fwq/js/statistics/assess_type.js

@@ -378,5 +378,5 @@ function exportExcel() {
         // start.setDate(start.getDate() - 1);
         start_date = start.Format("yyyy-MM-dd HH:mm:ss");
     }
-    window.open(getserveraddr() + "f/file/score/item/info?start_date=" + start_date + "&end_date=" + end_date);
+    window.open(getExcelServeraddr() + "f/file/score/item/info?start_date=" + start_date + "&end_date=" + end_date);
 }

+ 15 - 0
Visuallnspection_fjq/visuallnspection_fjq/src/main/java/com/xintong/visualinspection/visuallnspection_fjq/controller/FileExcelController_F.java

@@ -87,4 +87,19 @@ public class FileExcelController_F extends BaseController {
         return super.returnSuccessResult(null);
     }
 
+    /**
+     * 考核问题分布报表
+     */
+    @RequestMapping(value = "/score/item/info",method=RequestMethod.GET)
+    public String getScoreItemInfo(HttpServletRequest req,HttpServletResponse resp,
+                                   @RequestParam String start_date,@RequestParam String end_date){
+        FwqStatisticsBean obj = new FwqStatisticsBean();
+        Date start = DateUtil.strParseDate(start_date);
+        Date end = DateUtil.strParseDate(end_date);
+        obj.setStart_date(start);
+        obj.setEnd_date(end);
+        statisticsService_f.getFeeStationCheckItemScore(obj, req, resp);
+        return super.returnSuccessResult(null);
+    }
+
 }

+ 2 - 0
Visuallnspection_fjq/visuallnspection_fjq/src/main/java/com/xintong/visualinspection/visuallnspection_fjq/service/StatisticsService_F.java

@@ -11,4 +11,6 @@ public interface StatisticsService_F {
     void getOperationInfo(FwqStatisticsBean obj, HttpServletRequest req, HttpServletResponse resp);
 
     void getDeptStatisticExcel(FwqDeptStatistic fwqDeptStatistic, HttpServletRequest req, HttpServletResponse resp);
+
+    void getFeeStationCheckItemScore(FwqStatisticsBean obj, HttpServletRequest req, HttpServletResponse resp);
 }

+ 238 - 12
Visuallnspection_fjq/visuallnspection_fjq/src/main/java/com/xintong/visualinspection/visuallnspection_fjq/service/impl/StatisticsService_FImpl.java

@@ -5,6 +5,7 @@ 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.Item;
 import com.xintong.visualinspection.bean.Organ;
 import com.xintong.visualinspection.service.CommonService;
 import com.xintong.visualinspection.visuallnspection_fjq.dao.FwqCheckDeptStatisticsDao;
@@ -78,12 +79,12 @@ public class StatisticsService_FImpl implements StatisticsService_F {
         List<FwqStatisticsBean> onsite_beans = fwqStatisticsDao.getselectFeeStationOperationScoreDetail(obj);
 
         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());
         }
 
         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());
         }
         // 计算出每个收费站的总平均扣分和平均得分
@@ -97,14 +98,14 @@ public class StatisticsService_FImpl implements StatisticsService_F {
             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());
+                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();
+                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());
         }
         List<FwqStatisticsBean> sortList = new ArrayList<>(mapStationInfos.values());
@@ -128,7 +129,7 @@ public class StatisticsService_FImpl implements StatisticsService_F {
         }
         sortList = temp;
 
-        for(int j=0;j<sortList.size();j++){
+        for (int j = 0; j < sortList.size(); j++) {
             FwqStatisticsBean statisticsBean = sortList.get(j);
             // 公司排名
             if (j == 0) {
@@ -150,14 +151,14 @@ public class StatisticsService_FImpl implements StatisticsService_F {
 
     @Override
     public void getOperationInfo(FwqStatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
-        List<FwqStatisticsBean> lists= getOperationInfo(obj);
+        List<FwqStatisticsBean> lists = getOperationInfo(obj);
         int totalCompanyNum = 0,
                 totalCompanyScore = 0,
                 totalThirdNum = 0,
                 totalThirdScore = 0,
                 totalOnsiteNum = 0,
                 totalOnsiteScore = 0;
-        for(FwqStatisticsBean bean:lists){
+        for (FwqStatisticsBean bean : lists) {
             totalCompanyNum += bean.getCompany_check_num();
             totalCompanyScore += bean.getCompany_total_score();
             totalThirdNum += bean.getThird_check_num();
@@ -165,7 +166,7 @@ public class StatisticsService_FImpl implements StatisticsService_F {
             totalOnsiteNum += bean.getOnsite_check_num();
             totalOnsiteScore += bean.getOnsite_total_score();
         }
-        Map<String,Object> map = new HashMap<>(5);
+        Map<String, Object> map = new HashMap<>(5);
         map.put("list", lists);
         map.put("totalCompanyNum", totalCompanyNum);
         map.put("totalCompanyScore", totalCompanyScore);
@@ -366,17 +367,228 @@ public class StatisticsService_FImpl implements StatisticsService_F {
         Map<String, List<FwqDeptStatistic>> listMap = this.getDeptStatistic(obj);
         SimpleDateFormat d = new SimpleDateFormat("yyyy/MM");
         List<Integer> temp = new ArrayList<>();
-        for(int i=1;i<=listMap.keySet().size();i++){
+        for (int i = 1; i <= listMap.keySet().size(); i++) {
             temp.add(i);
         }
 
         Map<String, Object> map = new HashMap<>();
         map.put("datas", listMap);
         map.put("list", temp);
-        map.put("title","服务区-营运管理提升综合成绩汇总表"+"("+d.format(obj.getStart_date())+"---"+d.format(obj.getEnd_date())+")");
+        map.put("title", "服务区-营运管理提升综合成绩汇总表" + "(" + d.format(obj.getStart_date()) + "---" + d.format(obj.getEnd_date()) + ")");
         exportExcel("服务区-营运管理提升综合成绩汇总表", "fwq_dept_statistic", map, resp);
     }
 
+    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(), obj.getEnd_date().getTime());
+            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 void getFeeStationCheckItemScore(FwqStatisticsBean obj, HttpServletRequest req, HttpServletResponse resp) {
+        List<FwqStatisticsBean> list = getFeeStationCheckItemScore(obj);
+        int totalcheckedCount = 0, totalAll = 0;
+        float lygScore = 0.00f, ycScore = 0.00f, ntScore = 0.00f;
+        int lygCheckNum = 0, ycCheckNum = 0, ntCheckNum = 0;
+        Map<String, Integer> scoreTypeMap = new HashMap<>();
+        List<String> itemAll = commonService.getCheckItemName(28L);
+        Map<Long, Organ> deptMap = commonService.getDeptMap();
+        // 处理数据
+        for (FwqStatisticsBean st : list) {
+            // id值设置 seq_checked_score
+            // 平均值
+            st.setCheck_score_avg(
+                    (st.getChecked_num() != 0) ? st.getAll_check_score() / (st.getChecked_num() + 0.00f) : 0.00f);
+            for (String i : itemAll) {
+                st.getSeq_checked_score().add(getItemScore2(st, i));
+            }
+            st.setParent_dept_id(deptMap.get(st.getDept_id()).getParentid().longValue());
+            totalcheckedCount += st.getChecked_num();
+            totalAll += st.getAll_check_score();
+            if (st.getParent_dept_id() == 30) {
+                lygScore += st.getAll_check_score();
+                lygCheckNum += st.getChecked_num();
+            }
+            if (st.getParent_dept_id() == 31) {
+                ycScore += st.getAll_check_score();
+                ycCheckNum += st.getChecked_num();
+            }
+            if (st.getParent_dept_id() == 32) {
+                ntScore += st.getAll_check_score();
+                ntCheckNum += st.getChecked_num();
+            }
+            st.setCheck_total_avg("");
+            st.setParent_name("");
+            List<String> names = st.getChecked_socre_name();
+            List<Integer> scores = st.getChecked_score();
+            for (int j = 0; j < names.size(); j++) {
+                Integer score = scoreTypeMap.get(names.get(j));
+                if (score == null) {
+                    score = 0;
+                }
+                score += scores.get(j);
+                scoreTypeMap.put(names.get(j), score);
+            }
+        }
+        boolean lyg = false, yc = false, nt = false;
+        float lygTemp = 0.00f, ycTemp = 0.00f, ntTemp = 0.00f;
+        for (int i = 0; i < list.size(); i++) {
+            if (list.get(i).getParent_dept_id() == 30 && !lyg) {
+                list.get(i).setParent_name(deptMap.get(deptMap.get(list.get(i).getDept_id()).getParentid().longValue()).getOrganname());
+                list.get(i).setCheck_total_avg(String.format("%.2f", lygCheckNum != 0 ? lygScore / (lygCheckNum + 0.00f) : 0.00));
+                lygTemp = lygCheckNum != 0 ? lygScore / (lygCheckNum + 0.00f) : 0.00f;
+                lyg = true;
+            } else if (list.get(i).getParent_dept_id() == 31 && !yc) {
+                list.get(i).setParent_name(deptMap.get(deptMap.get(list.get(i).getDept_id()).getParentid().longValue()).getOrganname());
+                list.get(i).setCheck_total_avg(String.format("%.2f", ycCheckNum != 0 ? ycScore / (ycCheckNum + 0.00f) : 0.00));
+                ycTemp = ycCheckNum != 0 ? ycScore / (ycCheckNum + 0.00f) : 0.00f;
+                yc = true;
+            } else if (list.get(i).getParent_dept_id() == 32 && !nt) {
+                list.get(i).setParent_name(deptMap.get(deptMap.get(list.get(i).getDept_id()).getParentid().longValue()).getOrganname());
+                list.get(i).setCheck_total_avg(String.format("%.2f", ntCheckNum != 0 ? ntScore / (ntCheckNum + 0.00f) : 0.00));
+                ntTemp = ntCheckNum != 0 ? ntScore / (ntCheckNum + 0.00f) : 0.00f;
+                nt = true;
+            }
+        }
+        int lygOrder = 1, ycOrder = 1, ntOrder = 1;
+        for (int i = 0; i < list.size(); i++) {
+            if (!"".equals(list.get(i).getParent_name()) && list.get(i).getParent_dept_id() == 30) {
+                if (lygTemp > ycTemp) {
+                    lygOrder += 1;
+                }
+                if (lygTemp > ntTemp) {
+                    lygOrder += 1;
+                }
+                list.get(i).setFee_station_ranking2(lygOrder);
+            }
+            if (!"".equals(list.get(i).getParent_name()) && list.get(i).getParent_dept_id() == 31) {
+                if (ycTemp > lygTemp) {
+                    ycOrder += 1;
+                }
+                if (ycTemp > ntTemp) {
+                    ycOrder += 1;
+                }
+                list.get(i).setFee_station_ranking2(ycOrder);
+            }
+            if (!"".equals(list.get(i).getParent_name()) && list.get(i).getParent_dept_id() == 32) {
+                if (ntTemp > lygTemp) {
+                    ntOrder += 1;
+                }
+                if (ntTemp > ycTemp) {
+                    ntOrder += 1;
+                }
+                list.get(i).setFee_station_ranking2(ntOrder);
+            }
+        }
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("list", list);
+        map.put("itemList", itemAll);
+        exportExcel("温馨服务检查情况统计表", "fwq_checked_item_info", map, resp);
+    }
+
     private void exportExcel(String fileName, String excelTemplateName, Map<String, Object> map,
                              HttpServletResponse resp) {
         String path = "./" + fileName + ".xls";
@@ -420,4 +632,18 @@ public class StatisticsService_FImpl implements StatisticsService_F {
             logger.error(e.toString());
         }
     }
+
+    private Integer getItemScore2(FwqStatisticsBean obj, String name) {
+        List<String> names = obj.getChecked_socre_name();
+        List<Integer> scores = obj.getChecked_score();
+        for (int i = 0; i < names.size(); i++) {
+            if (names.get(i) == null) {
+                continue;
+            }
+            if (names.get(i).contains(name)) {
+                return scores.get(i);
+            }
+        }
+        return 0;
+    }
 }

BIN
Visuallnspection_fjq/visuallnspection_fjq/src/main/resources/fwq_checked_item_info.xls