liujie
2025-07-15 8652e69d17ab0c1a5884c662a9f3f950ddf57948
springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/ComplaintServiceImpl.java
@@ -116,6 +116,7 @@
        SystemUser systemUser = identityInformationVO.getSystemUser();
        Integer identity = identityInformationVO.getIdentity();
        if (identity == 2) {
            loginUserInfoVO.setUserId(Long.valueOf(systemUser.getId()));
            accountLevel = systemUser.getAccountLevel();
            switch (accountLevel) {
                case 2:
@@ -124,8 +125,6 @@
                    complaint.setDistrictsCode(Integer.valueOf(systemUser.getDistrictsCode()));
                    complaint.setReportUserName(systemUser.getName());
                    complaint.setReportUserPhone(systemUser.getPhone());
                    complaint.setSuperiorId(Long.valueOf(systemUser.getDistrictsCode()));
                    break;
                case 3:
@@ -287,6 +286,7 @@
        if (systemUserByPhone.isPresent() && null != identity && identity == 2) {
            systemUser = systemUserByPhone.get();
            accountLevel = systemUser.getAccountLevel();
            query.setUserId(Long.valueOf(systemUser.getId()));
            switch (accountLevel) {
                case 2:
                    //区县级
@@ -716,6 +716,10 @@
                    }
                }else if (detail.getStatus() != 3 && detail.getStatus() != 8 && detail.getFirstStatus() == 0 && detail.getNowLevel()==2) {
                    detail.setStatus(5);
                }else if(detail.getStatus()==3 || detail.getStatus()==8){
                    detail.setStatus(detail.getStatus());
                }else {
                    detail.setStatus(0);
                }
@@ -731,7 +735,13 @@
                    }
                }else if (detail.getStatus() != 3 && detail.getStatus() != 8 &&  detail.getFirstStatus() == 0  && detail.getNowLevel()==3) {
                    detail.setStatus(5);
                }else if(detail.getStatus()==3 || detail.getStatus()==8){
                    detail.setStatus(detail.getStatus());
                }else {
                    detail.setStatus(0);
                }
            }
            if (systemUser.getAccountLevel() == 4) {
                if (detail.getStatus() != 3 && detail.getStatus() != 8 &&  detail.getNowLevel() == 4 && detail.getAssignStatus() == 0 &&  ((one != null && one.getAuditStatus() == 1)||(one != null && one.getAuditStatus() == 3)  || one==null )) {
@@ -743,7 +753,13 @@
                    }
                }else if (detail.getStatus() != 3 && detail.getStatus() != 8 &&  detail.getFirstStatus() == 0  && detail.getNowLevel()==4) {
                    detail.setStatus(5);
                }else if(detail.getStatus()==3 || detail.getStatus()==8){
                    detail.setStatus(detail.getStatus());
                }else {
                    detail.setStatus(0);
                }
            }
        } else {
            if (detail.getFirstStatus() == 1 && detail.getStatus() != 3 && detail.getStatus() != 8) {
@@ -1914,11 +1930,11 @@
        // 诉求单量总计
        vo.setAllTotal(complaints.size());
        // 诉求单量本月
        int thisMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).count();
        int thisMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).count();
        vo.setThisMonthTotal(thisMonthTotal);
        // 诉求单量同比上月
        int lastMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).count();
        int lastMonthTotal = (int) complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).count();
        vo.setLastMonthCompareTotal(thisMonthTotal - lastMonthTotal);
        // 正在办理
@@ -1942,11 +1958,11 @@
        vo.setOvertimeTransactTotal(overtimeComplaints.size());
        // 超时办理本月
        int thisMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).count();
        int thisMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).count();
        vo.setThisMonthOvertimeTransactTotal(thisMonthOvertimeTransactTotal);
        // 超时办理同比上月
        int lastMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).count();
        int lastMonthOvertimeTransactTotal = (int) overtimeComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).count();
        vo.setLastMonthOvertimeTransactCompareTotal(thisMonthOvertimeTransactTotal - lastMonthOvertimeTransactTotal);
        // 平均处理时长
@@ -1955,13 +1971,13 @@
            averageDay = BigDecimal.valueOf(averageDay).setScale(2, RoundingMode.HALF_UP).doubleValue();
            vo.setAverageTime(averageDay);
            List<Complaint> thisMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).collect(Collectors.toList());
            List<Complaint> thisMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).collect(Collectors.toList());
            if (thisMonthAverageTimeComplaints.size() > 0) {
                double thisMonthAverageTime = thisMonthAverageTimeComplaints.stream().mapToDouble(v -> v.getHandlingDay() == null ? 0 : v.getHandlingDay()).average().getAsDouble();
                thisMonthAverageTime = BigDecimal.valueOf(thisMonthAverageTime).setScale(2, RoundingMode.HALF_UP).doubleValue();
                vo.setThisMonthAverageTime(thisMonthAverageTime);
            }
            List<Complaint> lastMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).collect(Collectors.toList());
            List<Complaint> lastMonthAverageTimeComplaints = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).collect(Collectors.toList());
            if (lastMonthAverageTimeComplaints.size() > 0) {
                double lastMonthAverageTime = lastMonthAverageTimeComplaints.stream().mapToDouble(v -> v.getHandlingDay() == null ? 0 : v.getHandlingDay()).average().getAsDouble();
                BigDecimal lastMonthAverageTime1 = BigDecimal.valueOf(lastMonthAverageTime).setScale(2, RoundingMode.HALF_UP);
@@ -1981,7 +1997,7 @@
            BigDecimal multiply = BigDecimal.valueOf(count).divide(new BigDecimal(size), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
            vo.setSatisfactionRate(multiply.doubleValue());
            List<Complaint> nowMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nowYearMonth)).collect(Collectors.toList());
            List<Complaint> nowMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nowYearMonth)).collect(Collectors.toList());
            // 当月满意
            long count1 = nowMonth.stream().filter(e -> e.getCommentRate() > 1).count();
            // 当月的评价数
@@ -1991,7 +2007,7 @@
                vo.setThisMonthSatisfactionRate(multiply1.doubleValue());
            }
            List<Complaint> lastMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(lastYearMonth)).collect(Collectors.toList());
            List<Complaint> lastMonth = commentRateComplaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(lastYearMonth)).collect(Collectors.toList());
            // 当月满意
            long count2 = lastMonth.stream().filter(e -> e.getCommentRate() > 1).count();
            // 当月的评价数
@@ -2023,7 +2039,7 @@
                String[] split = time.split(" - ");
                Date parse = simpleDateFormat.parse(split[0] + " 00:00:00");
                Date parse1 = simpleDateFormat.parse(split[1] + " 23:59:59");
                complaints = complaints.stream().filter(e -> e.getCreateTime().getTime() <= parse1.getTime() && e.getCreateTime().getTime() >= parse.getTime()).collect(Collectors.toList());
                complaints = complaints.stream().filter(e -> e.getTime().getTime() <= parse1.getTime() && e.getTime().getTime() >= parse.getTime()).collect(Collectors.toList());
                int day = DateUtils.getDay(parse, parse1);
                if (day > 30) {
@@ -2033,7 +2049,7 @@
                for (int i = 0; i <= day; i++) {
                    AnalyticStatisticsTwoVo analyticStatisticsTwoVo = new AnalyticStatisticsTwoVo();
                    if (i == 0) {
                        List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(split[0])).collect(Collectors.toList());
                        List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(split[0])).collect(Collectors.toList());
                        analyticStatisticsTwoVo.setTime(split[0]);
                        analyticStatisticsTwoVo.setAllTotal(collect.size());
                        int count = (int) collect.stream().filter(e -> e.getStatus() == 3).count();
@@ -2041,7 +2057,7 @@
                        list.add(analyticStatisticsTwoVo);
                    } else {
                        String nextDay = DateUtils.getNextDay(parse, i);
                        List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(nextDay)).collect(Collectors.toList());
                        List<Complaint> collect = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(nextDay)).collect(Collectors.toList());
                        analyticStatisticsTwoVo.setTime(nextDay);
                        analyticStatisticsTwoVo.setAllTotal(collect.size());
                        int count = (int) collect.stream().filter(e -> e.getStatus() == 3).count();
@@ -2054,12 +2070,12 @@
                time = DateUtils.getBeforeDay(6) + " 00:00:00";
                Date parse = simpleDateFormat.parse(time);
                // 近7天数据
                complaints = complaints.stream().filter(e -> e.getCreateTime().getTime() <= new Date().getTime() && e.getCreateTime().getTime() >= parse.getTime()).collect(Collectors.toList());
                complaints = complaints.stream().filter(e -> e.getTime().getTime() <= new Date().getTime() && e.getTime().getTime() >= parse.getTime()).collect(Collectors.toList());
                for (int i = 6; i >= 0; i--) {
                    // 获取前7天的时间
                    String day = DateUtils.getBeforeDay(i);
                    List<Complaint> complaintList = complaints.stream().filter(e -> simpleDateFormat.format(e.getCreateTime()).contains(day)).collect(Collectors.toList());
                    List<Complaint> complaintList = complaints.stream().filter(e -> simpleDateFormat.format(e.getTime()).contains(day)).collect(Collectors.toList());
                    AnalyticStatisticsTwoVo analyticStatisticsTwoVo = new AnalyticStatisticsTwoVo();
                    analyticStatisticsTwoVo.setTime(day);
                    analyticStatisticsTwoVo.setAllTotal(complaintList.size());
@@ -2077,7 +2093,7 @@
    @Override
    public List<AnalyticStatisticsThreeVo> analyticStatisticsThree(Integer rank, List<Complaint> complaints) {
        Map<String, List<Complaint>> groupedByProblemType = complaints.stream()
        Map<String, List<Complaint>> groupedByProblemType = complaints.stream().filter(e->e.getProblemType()!=null)
                .collect(Collectors.groupingBy(Complaint::getProblemType));
        List<AnalyticStatisticsThreeVo> analyticStatisticsThreeVos = groupedByProblemType.entrySet().stream()
                .map(entry -> {
@@ -2295,7 +2311,7 @@
                complaint.setSuperiorId(systemUser.getCommunityId());
                break;
        }
        complaint.setCreateBy(Long.valueOf(systemUser.getId()));
        complaint.setReportType(accountLevel);
        complaint.setNowLevel(accountLevel);
        complaint.setLastLevel(accountLevel);
@@ -2337,6 +2353,7 @@
            String code = null;
            switch (accountLevel) {
                case 2:
                    code ="510403";
                    break;
                case 3:
                    code =systemUser.getStreetId();