Explorar el Código

Merge branch 'dev' of liubing/wlyy2.0 into dev

liubing hace 2 años
padre
commit
57d372a107

+ 75 - 4
business/base-service/src/main/java/com/yihu/jw/dailyReport/service/DailyReportUploadService.java

@ -2365,12 +2365,34 @@ public class DailyReportUploadService {
            throw new Exception("查询失败,请检查传入参数");
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        //计算平均值和占比
        if (list.size()>0){
            Set<String> resultTimeList = new HashSet<>();
            Date startDateTmp = DateUtil.strToDate(startDate);
            Date endDateTmp = DateUtil.strToDate(endDate);
            if (type==1){
                for (;!startDateTmp.after(endDateTmp);){
                    resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM_DD));
                    startDateTmp = DateUtil.getNextDay1(startDateTmp,1);
                }
            } else if (type==2) {
                for (;!startDateTmp.after(endDateTmp);){
                    resultTimeList.add(DateUtil.getSundayOfThisWeek(startDateTmp));
                    startDateTmp = DateUtil.getNextWeek(startDateTmp,1);
                }
            }else if (type==3){
                for (;!startDateTmp.after(endDateTmp);){
                    resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM));
                    startDateTmp = DateUtil.getNextMonthReturnDate(startDateTmp,1);
                }
            }
            OptionalDouble avg =  list.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
            Double totalHour =  list.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
            Double avgValue = avg.getAsDouble();
            for (Map<String,Object>tmp :list){
            Iterator<Map<String,Object>> it = list.iterator();
            //计算平均值和占比
            while (it.hasNext()){
                Map<String, Object> tmp = it.next();
                tmp.put("avgValue",avgValue);
                Double completionHour = Double.valueOf(tmp.get("completionHour").toString());
                tmp.put("timeRange",getRangeDouble(completionHour,totalHour));
@ -2379,7 +2401,20 @@ public class DailyReportUploadService {
                    String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
                    tmp.put("time",sunday);
                }
                String tmpTime =  tmp.get("time").toString();
                if (resultTimeList.contains(tmpTime)){
                    resultTimeList.remove(tmpTime);
                }
            }
            for (String tmpTime:resultTimeList){
                Map<String, Object> tmp =  new HashMap<>();
                tmp.put("avgValue",avgValue);
                tmp.put("time",tmpTime);
                tmp.put("completionHour","0");
                tmp.put("doctorTotal","0");
                list.add(tmp);
            }
            list.sort(Comparator.comparing(obj -> obj.get("time").toString()));
        }
        return list;
    }
@ -2451,6 +2486,28 @@ public class DailyReportUploadService {
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        //计算平均值和占比
        if (list.size()>0){
            Set<String> resultTimeList = new HashSet<>();
            Date startDateTmp = DateUtil.strToDate(startDate);
            Date endDateTmp = DateUtil.strToDate(endDate);
            if (type==1){
                for (;!startDateTmp.after(endDateTmp);){
                    resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM_DD));
                    startDateTmp = DateUtil.getNextDay1(startDateTmp,1);
                }
            } else if (type==2) {
                for (;!startDateTmp.after(endDateTmp);){
                    startDateTmp = DateUtil.strToDate(DateUtil.getSundayOfThisWeek(startDateTmp));
                    resultTimeList.add(DateUtil.getSundayOfThisWeek(startDateTmp));
                    startDateTmp = DateUtil.getNextWeek(startDateTmp,1);
                }
            }else if (type==3){
                for (;!startDateTmp.after(endDateTmp);){
                    resultTimeList.add(DateUtil.dateToStr(startDateTmp,DateUtil.YYYY_MM));
                    startDateTmp = DateUtil.getNextMonthReturnDate(startDateTmp,1);
                }
            }
            OptionalDouble avg =  list.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).average();
            Double totalHour =  list.stream().mapToDouble(t -> t.get("completionHour") == null ? 0.0 :Double.parseDouble(t.get("completionHour").toString())).sum();
            Double avgValue = avg.getAsDouble();
@ -2464,13 +2521,27 @@ public class DailyReportUploadService {
                        "where  de.report_item_id='"+item_id+"' and up.doctor_id='"+doctorId+"' " +
                        "GROUP BY "+searchTimeFormat+" ORDER BY report_date asc ";
                List<Map<String,Object>> timeUseList = jdbcTemplate.queryForList(sql);
                if(2==type){//获取周的最后一天
                    for (Map<String,Object>timeUseTmp :timeUseList){
                Set searchTimeList = new HashSet();
                for (Map<String,Object>timeUseTmp :timeUseList){
                    if (2==type){
                        String time = timeUseTmp.get("report_date").toString();
                        String sunday = DateUtil.getSundayOfThisWeek(DateUtil.strToDate(time));
                        timeUseTmp.put("report_date",sunday);
                    }
                    String time = timeUseTmp.get("report_date").toString();
                    searchTimeList.add(time);
                }
                if (type!=0){
                    for (String tmpTime:resultTimeList){
                        if (!searchTimeList.contains(tmpTime)){
                            Map<String,Object> mapTmp = new HashMap<>();
                            mapTmp.put("report_date",tmpTime);
                            mapTmp.put("completionHour",0);
                            timeUseList.add(mapTmp);
                        }
                    }
                }
                timeUseList.sort(Comparator.comparing(obj -> obj.get("report_date").toString()));
                tmp.put("timeUseList",timeUseList);
            }

+ 7 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -611,6 +611,13 @@ public class DateUtil {
        return c.getTime();
    }
    public static Date getNextWeek(Date d, int weeks) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        c.add(Calendar.DAY_OF_WEEK, weeks);
        return c.getTime();
    }
    public static String getNextMonth(Date d, int months) {
        Calendar c = Calendar.getInstance();
        c.setTime(d);