Jelajahi Sumber

下级添加签约率

lyr 8 tahun lalu
induk
melakukan
4ae8326060

+ 13 - 4
src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -415,6 +415,8 @@ public class StatisticsService extends BaseService {
            }
        }
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel);
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
@ -439,7 +441,7 @@ public class StatisticsService extends BaseService {
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (level == 4) {
            if (low_level.equals("3")) {
                List<Town> towns = townDao.findByCityCode(area);
                if (towns != null) {
                    for (Town town : towns) {
@ -447,9 +449,10 @@ public class StatisticsService extends BaseService {
                        obj.put("code", town.getCode());
                        obj.put("name", town.getName());
                        obj.put("amount", Double.valueOf("0.0"));
                        obj.put("rate", Double.valueOf("0.0000"));
                    }
                }
            } else if (level == 3) {
            } else if (low_level.equals("2")) {
                List<Hospital> hospitals = hospitalDao.findByTownCode(area);
                if (hospitals != null) {
                    for (Hospital hos : hospitals) {
@ -457,9 +460,10 @@ public class StatisticsService extends BaseService {
                        obj.put("code", hos.getCode());
                        obj.put("name", hos.getName());
                        obj.put("amount", Double.valueOf("0.0"));
                        obj.put("rate", Double.valueOf("0.0000"));
                    }
                }
            } else if (level == 2) {
            } else if (low_level.equals("1")) {
                List<Doctor> doctors = doctorDao.findDoctorByLevelAndHospital(area, 2);
                if (doctors != null) {
                    for (Doctor doc : doctors) {
@ -473,18 +477,23 @@ public class StatisticsService extends BaseService {
        }
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Math.round((double) map.get("amount")) : 0);
                // 截止日期包含当天,则从redis查询当天统计数据
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + (StringUtils.isEmpty(lowLevel)?(level - 1):lowLevel) + ":" + code);
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
                    PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(map.get("code").toString(),Calendar.getInstance().get(Calendar.YEAR));
                    if(peopleNum != null) {
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                    }
                }
            }