|  | @ -146,12 +146,76 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取一级指标达到量
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate 截止日期
 | 
	
		
			
				|  |  |      * @param area    区域
 | 
	
		
			
				|  |  |      * @param index   指标
 | 
	
		
			
				|  |  |      * @param level   级别
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public long getIndexTotal(String endDate,String area, int level , String index) {
 | 
	
		
			
				|  |  |         int todayAmount = 0;
 | 
	
		
			
				|  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  |         String dateCon = endDate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
 | 
	
		
			
				|  |  |             Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  |             calendar.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |             dateCon = dateFormat.format(calendar.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 查询语句
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(result,'0') amount" +
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
		
			
				|  |  |                 "     quato_code = ? " +
 | 
	
		
			
				|  |  |                 "   and level1_type = ? and del = '1'" +
 | 
	
		
			
				|  |  |                 "   and quota_date = ? ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
		
			
				|  |  |             sql += " and city = ? ";
 | 
	
		
			
				|  |  |         } else if (level == 3) {
 | 
	
		
			
				|  |  |             // 区、城镇级别
 | 
	
		
			
				|  |  |             sql += " and town = ? ";
 | 
	
		
			
				|  |  |         } else if (level == 2) {
 | 
	
		
			
				|  |  |             // 机构级别
 | 
	
		
			
				|  |  |             sql += " and org_code = ? ";
 | 
	
		
			
				|  |  |         } else if (level == 1) {
 | 
	
		
			
				|  |  |             sql += " and qkdoctor_code = ?";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 截止日期包含当天,则从redis查询当天统计数据
 | 
	
		
			
				|  |  |         if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
 | 
	
		
			
				|  |  |             String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(val)) {
 | 
	
		
			
				|  |  |                 JSONObject valJson = new JSONObject(val);
 | 
	
		
			
				|  |  |                 if (valJson.has("num") && valJson.getInt("num") > 0) {
 | 
	
		
			
				|  |  |                     todayAmount = valJson.getInt("num");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{index,level, dateCon, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (result != null && result.size() > 0) {
 | 
	
		
			
				|  |  |             return (result.get(0).get("amount") != null ? (Long.valueOf(result.get(0).get("amount").toString()) + todayAmount) : todayAmount);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return 0;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取缴费
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate 截止日期
 | 
	
		
			
				|  |  |      * @param area 区域
 | 
	
		
			
				|  |  |      * @param level 级别
 | 
	
		
			
				|  |  |      * @param area    区域
 | 
	
		
			
				|  |  |      * @param level   级别
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public long getWeiJiaoFei(String endDate, String area, int level) {
 | 
	
	
		
			
				|  | @ -171,7 +235,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
		
			
				|  |  |                 "     quato_code = '14' " +
 | 
	
		
			
				|  |  |                 "     quato_code = '16' " +
 | 
	
		
			
				|  |  |                 "   and level1_type = ? and del = '1'" +
 | 
	
		
			
				|  |  |                 "   and level2_type = '0' " +
 | 
	
		
			
				|  |  |                 "   and quota_date = ? ";
 | 
	
	
		
			
				|  | @ -192,7 +256,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 截止日期包含当天,则从redis查询当天统计数据
 | 
	
		
			
				|  |  |         if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
 | 
	
		
			
				|  |  |             String val = redisTemplate.opsForValue().get("quota:14:" + level + ":" + area);
 | 
	
		
			
				|  |  |             String val = redisTemplate.opsForValue().get("quota:16:" + level + ":" + area);
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(val)) {
 | 
	
		
			
				|  |  |                 JSONObject valJson = new JSONObject(val);
 | 
	
		
			
				|  |  |                 if (valJson.has("num") && valJson.getInt("num") > 0) {
 | 
	
	
		
			
				|  | @ -220,7 +284,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject getSignRate(String endDate, String area, int level) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  |         long signAmount = getTotalAmount(endDate, area, level, SIGN);
 | 
	
		
			
				|  |  |         long signAmount = getIndexTotal(endDate, area, level, "13");
 | 
	
		
			
				|  |  |         PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.0000");
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -247,7 +311,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONObject getSignTaskRate(String endDate, String area, int level) throws Exception {
 | 
	
		
			
				|  |  |         JSONObject json = new JSONObject();
 | 
	
		
			
				|  |  |         long signAmount = getTotalAmount(endDate, area, level, SIGN);
 | 
	
		
			
				|  |  |         long signAmount = getIndexTotal(endDate, area, level, "13");
 | 
	
		
			
				|  |  |         PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
 | 
	
		
			
				|  |  |         DecimalFormat df = new DecimalFormat("0.0000");
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -264,19 +328,6 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |         return json;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询截止某个日期累计建档率
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate 截止日期
 | 
	
		
			
				|  |  |      * @param area    区域或机构代码
 | 
	
		
			
				|  |  |      * @param level   级别
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getFilingRate(String endDate, String area, int level) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return "";
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取某个指标在某个期间的增长量
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -333,134 +384,6 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询截止某个日期某个区域后机构各下级累计签约情况
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate 截止日期
 | 
	
		
			
				|  |  |      * @param area    区域或机构代码
 | 
	
		
			
				|  |  |      * @param level   级别
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getLowLevelSignDetail(String endDate, String area, int level) {
 | 
	
		
			
				|  |  |         String areaField = "";
 | 
	
		
			
				|  |  |         String lowLevelField = "";
 | 
	
		
			
				|  |  |         String lowLevelName = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
		
			
				|  |  |             areaField = "city";
 | 
	
		
			
				|  |  |             lowLevelField = "town";
 | 
	
		
			
				|  |  |             lowLevelName = "town_name";
 | 
	
		
			
				|  |  |         } else if (level == 3) {
 | 
	
		
			
				|  |  |             // 区、城镇级别
 | 
	
		
			
				|  |  |             areaField = "town";
 | 
	
		
			
				|  |  |             lowLevelField = "org_code";
 | 
	
		
			
				|  |  |             lowLevelName = "org_name";
 | 
	
		
			
				|  |  |         } else if (level == 2) {
 | 
	
		
			
				|  |  |             // 机构级别
 | 
	
		
			
				|  |  |             areaField = "org_code";
 | 
	
		
			
				|  |  |             lowLevelField = "qkdoctor_code";
 | 
	
		
			
				|  |  |             lowLevelName = "qkdoctor_name";
 | 
	
		
			
				|  |  |         } else if (level == 1) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // 查询语句
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(a." + lowLevelField + ",'') code " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(a." + lowLevelName + ",'') 'name' " +
 | 
	
		
			
				|  |  |                 "     ,sum(a.result) amount ";
 | 
	
		
			
				|  |  | //        if(level > 3) {
 | 
	
		
			
				|  |  | //            sql += "     ,sum(a.result)*1.00/b.num*100 rate";
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         sql += " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result a";
 | 
	
		
			
				|  |  | //        if(level > 3) {
 | 
	
		
			
				|  |  | //            sql += "  inner join " +
 | 
	
		
			
				|  |  | //                    "     wlyy_people_num b" +
 | 
	
		
			
				|  |  | //                    "  on a." + lowLevelField + " = b.code ";
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         sql += " where " +
 | 
	
		
			
				|  |  |                 "     a.quato_code = '" + SIGN + "' " +
 | 
	
		
			
				|  |  |                 "   and a.level1_type = ? and a.del = '1'" +
 | 
	
		
			
				|  |  |                 "   and a.quota_date <= ? " +
 | 
	
		
			
				|  |  |                 "   and a." + areaField + " = ? " +
 | 
	
		
			
				|  |  |                 " group by a." + lowLevelField + ",a." + lowLevelName;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{level - 1, endDate, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList != null) {
 | 
	
		
			
				|  |  |             DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  |             for (Map<String, Object> map : resultList) {
 | 
	
		
			
				|  |  |                 map.put("amount", map.get("amount") != null ? Math.round(Double.valueOf(map.get("amount").toString())) : 0);
 | 
	
		
			
				|  |  | //                if(level > 3){
 | 
	
		
			
				|  |  | //                    map.put("rate",df.format(map.get("rate") != null ? map.get("rate") : 0));
 | 
	
		
			
				|  |  | //                }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return new JSONArray(resultList);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return new JSONArray();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询截止某个日期某个区域后机构各下级累计建档情况
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate 截止日期
 | 
	
		
			
				|  |  |      * @param area    区域或机构代码
 | 
	
		
			
				|  |  |      * @param level   级别
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getLowLevelFilingDetail(String endDate, String area, int level) {
 | 
	
		
			
				|  |  |         String areaField = "";
 | 
	
		
			
				|  |  |         String lowLevelField = "";
 | 
	
		
			
				|  |  |         String lowLevelName = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
		
			
				|  |  |             areaField = "city";
 | 
	
		
			
				|  |  |             lowLevelField = "town";
 | 
	
		
			
				|  |  |             lowLevelName = "town_name";
 | 
	
		
			
				|  |  |         } else if (level == 3) {
 | 
	
		
			
				|  |  |             // 区、城镇级别
 | 
	
		
			
				|  |  |             areaField = "town";
 | 
	
		
			
				|  |  |             lowLevelField = "org_code";
 | 
	
		
			
				|  |  |             lowLevelName = "org_name";
 | 
	
		
			
				|  |  |         } else if (level == 2) {
 | 
	
		
			
				|  |  |             // 机构级别
 | 
	
		
			
				|  |  |             areaField = "org_code";
 | 
	
		
			
				|  |  |             lowLevelField = "qkdoctor_code";
 | 
	
		
			
				|  |  |             lowLevelName = "qkdoctor_name";
 | 
	
		
			
				|  |  |         } else if (level == 1) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // 查询语句
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(" + lowLevelField + ",'') code " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(" + lowLevelName + ",'') 'name' " +
 | 
	
		
			
				|  |  |                 "     ,sum(result) amount" +
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
		
			
				|  |  |                 "     quato_code = '' " +
 | 
	
		
			
				|  |  |                 "   and level1_type = '1' and del = '1'" +
 | 
	
		
			
				|  |  |                 "   and quota_date <= ? " +
 | 
	
		
			
				|  |  |                 "   and " + areaField + " = ? " +
 | 
	
		
			
				|  |  |                 " group by " + lowLevelField + "," + lowLevelName;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{endDate, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList != null) {
 | 
	
		
			
				|  |  |             for (Map<String, Object> map : resultList) {
 | 
	
		
			
				|  |  |                 map.put("amount", map.get("amount") != null ? Math.round(Double.valueOf(map.get("amount").toString())) : 0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             return new JSONArray(resultList);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return new JSONArray();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询截止某个日期某个区域后机构各下级指标累计情况
 | 
	
		
			
				|  |  |      *
 | 
	
	
		
			
				|  | @ -1456,7 +1379,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> manbing = new HashMap<>();
 | 
	
		
			
				|  |  |                 manbing.put("code", "2");
 | 
	
		
			
				|  |  |                 manbing.put("name", "慢病人群65岁以下");
 | 
	
		
			
				|  |  |                 manbing.put("name", "慢病人群");
 | 
	
		
			
				|  |  |                 manbing.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(manbing);
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1483,12 +1406,6 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 tnbGxy.put("name", "高血压和糖尿病");
 | 
	
		
			
				|  |  |                 tnbGxy.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(tnb);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> mn65LowGxy = new HashMap<>();
 | 
	
		
			
				|  |  |                 mn65LowGxy.put("code", "7");
 | 
	
		
			
				|  |  |                 mn65LowGxy.put("name", "慢病人群65岁以上");
 | 
	
		
			
				|  |  |                 mn65LowGxy.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(mn65LowGxy);
 | 
	
		
			
				|  |  |             } else if (index.equals(AGE)) {
 | 
	
		
			
				|  |  |                 Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map1.put("code", "1");
 | 
	
	
		
			
				|  | @ -1597,7 +1514,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 if (index.equals(GROUP)) {
 | 
	
		
			
				|  |  |                     // 分组指标总数算法
 | 
	
		
			
				|  |  |                     String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
 | 
	
		
			
				|  |  |                     if (code.equals("1") || code.equals("2") || code.equals("7") || code.equals("3")) {
 | 
	
		
			
				|  |  |                     if (code.equals("1") || code.equals("2") || code.equals("3")) {
 | 
	
		
			
				|  |  |                         total += (long) map.get("amount");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else if (index.equals("16")) {
 | 
	
	
		
			
				|  | @ -1645,14 +1562,21 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 统计65以上人群数据
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param startDate
 | 
	
		
			
				|  |  |      * @param endDate
 | 
	
		
			
				|  |  |      * @param area
 | 
	
		
			
				|  |  |      * @param level
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getSixFiveStatistics(String startDate, String endDate, String area, int level) {
 | 
	
		
			
				|  |  |     public JSONArray getSixFiveStatistics(String endDate, String area, int level) {
 | 
	
		
			
				|  |  |         String areaField = "";
 | 
	
		
			
				|  |  |         SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  |         String dateCon = endDate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (endDate.compareTo(datef.format(new Date())) == 0) {
 | 
	
		
			
				|  |  |             Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  |             calendar.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |             dateCon = datef.format(calendar.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
	
		
			
				|  | @ -1672,7 +1596,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(level3_type,'') code " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(level3_type_name,'') 'name' " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(sum(result),0.0) amount" +
 | 
	
		
			
				|  |  |                 "     ,ifnull(result,0.0) amount" +
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
	
		
			
				|  | @ -1681,21 +1605,13 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 "   and level1_type = ? and del = '1'";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
 | 
	
		
			
				|  |  |             sql += "   and quota_date >= ? ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += "   and quota_date <= ? " +
 | 
	
		
			
				|  |  |         sql += "   and quota_date = ? " +
 | 
	
		
			
				|  |  |                 "   and " + areaField + " = ? " +
 | 
	
		
			
				|  |  |                 " group by level3_type,level3_type_name";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
 | 
	
		
			
				|  |  |             resultList = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             resultList = jdbcTemplate.queryForList(sql, new Object[]{level, startDate, endDate, area});
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         resultList = jdbcTemplate.queryForList(sql, new Object[]{level, dateCon, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList == null || resultList.size() < 1) {
 | 
	
		
			
				|  |  |             resultList = new ArrayList<>();
 | 
	
	
		
			
				|  | @ -1730,7 +1646,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 map.put("amount", map.get("amount") == null ? 0 : Math.round(Double.valueOf(map.get("amount").toString())));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 当天数据统计
 | 
	
		
			
				|  |  |                 if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
 | 
	
		
			
				|  |  |                 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:12:" + level + ":6:" + code + ":" + area);
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(val)) {
 | 
	
	
		
			
				|  | @ -1743,7 +1659,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             // 65岁以上人群总数统计
 | 
	
		
			
				|  |  |             long sixFiveTotal = getSixFiveTotal(startDate, endDate, area, level);
 | 
	
		
			
				|  |  |             long sixFiveTotal = getSixFiveTotal(endDate, area, level);
 | 
	
		
			
				|  |  |             Map<String, Object> sixFive = new HashMap<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             sixFive.put("code", "0");
 | 
	
	
		
			
				|  | @ -1760,15 +1676,22 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取65岁以上人群总数
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param startDate
 | 
	
		
			
				|  |  |      * @param endDate
 | 
	
		
			
				|  |  |      * @param area
 | 
	
		
			
				|  |  |      * @param level
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public long getSixFiveTotal(String startDate, String endDate, String area, int level) {
 | 
	
		
			
				|  |  |     public long getSixFiveTotal(String endDate, String area, int level) {
 | 
	
		
			
				|  |  |         String areaField = "";
 | 
	
		
			
				|  |  |         long total = 0;
 | 
	
		
			
				|  |  |         SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  |         String dateCon = endDate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (endDate.compareTo(datef.format(new Date())) == 0) {
 | 
	
		
			
				|  |  |             Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  |             calendar.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |             dateCon = datef.format(calendar.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
	
		
			
				|  | @ -1786,7 +1709,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         // 查询语句
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(sum(result),0.0) amount" +
 | 
	
		
			
				|  |  |                 "     ifnull(result,0.0) amount" +
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
	
		
			
				|  | @ -1795,31 +1718,25 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 "   and level1_type = ? and del = '1'";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (!org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
 | 
	
		
			
				|  |  |             sql += "   and quota_date >= ? ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += "   and quota_date <= ? " +
 | 
	
		
			
				|  |  |         sql += "   and quota_date = ? " +
 | 
	
		
			
				|  |  |                 "   and " + areaField + " = ? ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> result = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
 | 
	
		
			
				|  |  |             result = jdbcTemplate.queryForMap(sql, new Object[]{level, endDate, area});
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             result = jdbcTemplate.queryForMap(sql, new Object[]{level, startDate, endDate, area});
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         result = jdbcTemplate.queryForMap(sql, new Object[]{level, dateCon, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (result != null && result.containsKey("amount")) {
 | 
	
		
			
				|  |  |             total += (result.get("amount") == null ? 0 : Math.round(Double.valueOf(result.get("amount").toString())));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String code = "6";
 | 
	
		
			
				|  |  |         String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + code + ":" + area);
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(val)) {
 | 
	
		
			
				|  |  |             JSONObject valJson = new JSONObject(val);
 | 
	
		
			
				|  |  |             if (valJson.has("num") && valJson.getInt("num") > 0) {
 | 
	
		
			
				|  |  |                 total += valJson.getInt("num");
 | 
	
		
			
				|  |  |         if (endDate.compareTo(datef.format(new Date())) == 0) {
 | 
	
		
			
				|  |  |             String code = "6";
 | 
	
		
			
				|  |  |             String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + code + ":" + area);
 | 
	
		
			
				|  |  |             if (!StringUtils.isEmpty(val)) {
 | 
	
		
			
				|  |  |                 JSONObject valJson = new JSONObject(val);
 | 
	
		
			
				|  |  |                 if (valJson.has("num") && valJson.getInt("num") > 0) {
 | 
	
		
			
				|  |  |                     total += valJson.getInt("num");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -1982,7 +1899,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                 map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 截止日期包含当天,则从redis查询当天统计数据
 | 
	
		
			
				|  |  |                 if (date.compareTo(dateFormat.format(new Date())) >= 0) {
 | 
	
		
			
				|  |  |                 if (date.compareTo(dateFormat.format(new Date())) == 0) {
 | 
	
		
			
				|  |  |                     String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
 | 
	
		
			
				|  |  |                     String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
 | 
	
		
			
				|  |  |                     if (!StringUtils.isEmpty(val)) {
 | 
	
	
		
			
				|  | @ -2176,10 +2093,10 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             countResult.put(startStr, range);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(startDate.equals(df.format(new Date()))){
 | 
	
		
			
				|  |  |         if (startDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |             Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |             preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             startDate = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -2201,10 +2118,10 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |         if (resultList != null) {
 | 
	
		
			
				|  |  |             String preStr = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (endDate.equals(df.format(new Date()))){
 | 
	
		
			
				|  |  |             if (endDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |                 Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |                 preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 preStr = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -2216,10 +2133,10 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |                     long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
 | 
	
		
			
				|  |  |                     range.put("amount", amount + resultAmount);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if(org.apache.commons.lang3.StringUtils.isNotEmpty(preStr) &&
 | 
	
		
			
				|  |  |                         preStr.equals(map.get("range").toString())){
 | 
	
		
			
				|  |  |                 if (org.apache.commons.lang3.StringUtils.isNotEmpty(preStr) &&
 | 
	
		
			
				|  |  |                         preStr.equals(map.get("range").toString())) {
 | 
	
		
			
				|  |  |                     JSONObject range = (JSONObject) countResult.get(endDate);
 | 
	
		
			
				|  |  |                     if(range != null) {
 | 
	
		
			
				|  |  |                     if (range != null) {
 | 
	
		
			
				|  |  |                         long amount = range.getLong("amount");
 | 
	
		
			
				|  |  |                         long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
 | 
	
		
			
				|  |  |                         range.put("amount", amount + resultAmount);
 | 
	
	
		
			
				|  | @ -2374,10 +2291,10 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             countResult.put(endStr, range);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(startDate.equals(df.format(new Date()))){
 | 
	
		
			
				|  |  |         if (startDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |             Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |             preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             startDate = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -2402,7 +2319,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             if (endDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |                 Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |                 preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |                 pre = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2571,10 +2488,10 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             countResult.put(endStr, range);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(startDate.equals(df.format(new Date()))){
 | 
	
		
			
				|  |  |         if (startDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |             Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |             preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |             preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             startDate = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -2599,7 +2516,7 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |             if (endDate.equals(df.format(new Date()))) {
 | 
	
		
			
				|  |  |                 Calendar preDate = Calendar.getInstance();
 | 
	
		
			
				|  |  |                 preDate.setTime(df.parse(endDate));
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE,-1);
 | 
	
		
			
				|  |  |                 preDate.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |                 pre = df.format(preDate.getTime());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             // 计算结果
 | 
	
	
		
			
				|  | @ -2645,4 +2562,267 @@ public class StatisticsService extends BaseService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取二级指标的到达量
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param endDate
 | 
	
		
			
				|  |  |      * @param area
 | 
	
		
			
				|  |  |      * @param level
 | 
	
		
			
				|  |  |      * @param index
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getIndexLevelTwototal(String endDate, String area, int level, String index) {
 | 
	
		
			
				|  |  |         String areaField = "";
 | 
	
		
			
				|  |  |         SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  |         String dateCon = endDate;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (endDate.compareTo(datef.format(new Date())) == 0) {
 | 
	
		
			
				|  |  |             Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  |             calendar.add(Calendar.DATE, -1);
 | 
	
		
			
				|  |  |             dateCon = datef.format(calendar.getTime());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (level == 4) {
 | 
	
		
			
				|  |  |             // 市级别
 | 
	
		
			
				|  |  |             areaField = "city";
 | 
	
		
			
				|  |  |         } else if (level == 3) {
 | 
	
		
			
				|  |  |             // 区、城镇级别
 | 
	
		
			
				|  |  |             areaField = "town";
 | 
	
		
			
				|  |  |         } else if (level == 2) {
 | 
	
		
			
				|  |  |             // 机构级别
 | 
	
		
			
				|  |  |             areaField = "org_code";
 | 
	
		
			
				|  |  |         } else if (level == 1) {
 | 
	
		
			
				|  |  |             // 团队
 | 
	
		
			
				|  |  |             areaField = "qkdoctor_code";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // 查询语句
 | 
	
		
			
				|  |  |         String sql = " select " +
 | 
	
		
			
				|  |  |                 "     ifnull(level2_type,'') code " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(level2_type_name,'') 'name' " +
 | 
	
		
			
				|  |  |                 "     ,ifnull(result,0.0) amount" +
 | 
	
		
			
				|  |  |                 " from  " +
 | 
	
		
			
				|  |  |                 "     wlyy_quota_result " +
 | 
	
		
			
				|  |  |                 " where " +
 | 
	
		
			
				|  |  |                 "     quato_code = '" + index + "' " +
 | 
	
		
			
				|  |  |                 "   and level1_type = ? and del = '1'";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += "   and quota_date = ? " +
 | 
	
		
			
				|  |  |                 "   and " + areaField + " = ? " +
 | 
	
		
			
				|  |  |                 " group by level2_type,level2_type_name";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<Map<String, Object>> resultList = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         resultList = jdbcTemplate.queryForList(sql, new Object[]{level, dateCon, area});
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList == null || resultList.size() < 1) {
 | 
	
		
			
				|  |  |             resultList = new ArrayList<>();
 | 
	
		
			
				|  |  |             if (index.equals(SEX)) {
 | 
	
		
			
				|  |  |                 Map<String, Object> women = new HashMap<>();
 | 
	
		
			
				|  |  |                 women.put("code", "1");
 | 
	
		
			
				|  |  |                 women.put("name", "女");
 | 
	
		
			
				|  |  |                 women.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(women);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> man = new HashMap<>();
 | 
	
		
			
				|  |  |                 man.put("code", "2");
 | 
	
		
			
				|  |  |                 man.put("name", "男");
 | 
	
		
			
				|  |  |                 man.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(man);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> unknown = new HashMap<>();
 | 
	
		
			
				|  |  |                 unknown.put("code", "3");
 | 
	
		
			
				|  |  |                 unknown.put("name", "未知");
 | 
	
		
			
				|  |  |                 unknown.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(unknown);
 | 
	
		
			
				|  |  |             } else if (index.equals(GROUP)) {
 | 
	
		
			
				|  |  |                 Map<String, Object> normal = new HashMap<>();
 | 
	
		
			
				|  |  |                 normal.put("code", "1");
 | 
	
		
			
				|  |  |                 normal.put("name", "普通人群");
 | 
	
		
			
				|  |  |                 normal.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(normal);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> manbing = new HashMap<>();
 | 
	
		
			
				|  |  |                 manbing.put("code", "2");
 | 
	
		
			
				|  |  |                 manbing.put("name", "慢病人群");
 | 
	
		
			
				|  |  |                 manbing.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(manbing);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> upsixfive = new HashMap<>();
 | 
	
		
			
				|  |  |                 upsixfive.put("code", "3");
 | 
	
		
			
				|  |  |                 upsixfive.put("name", "65岁以上人群");
 | 
	
		
			
				|  |  |                 upsixfive.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(upsixfive);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> gxy = new HashMap<>();
 | 
	
		
			
				|  |  |                 gxy.put("code", "4");
 | 
	
		
			
				|  |  |                 gxy.put("name", "高血压");
 | 
	
		
			
				|  |  |                 gxy.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(gxy);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> tnb = new HashMap<>();
 | 
	
		
			
				|  |  |                 tnb.put("code", "5");
 | 
	
		
			
				|  |  |                 tnb.put("name", "糖尿病");
 | 
	
		
			
				|  |  |                 tnb.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(tnb);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> tnbGxy = new HashMap<>();
 | 
	
		
			
				|  |  |                 tnbGxy.put("code", "6");
 | 
	
		
			
				|  |  |                 tnbGxy.put("name", "高血压和糖尿病");
 | 
	
		
			
				|  |  |                 tnbGxy.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(tnb);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //                Map<String, Object> mn65LowGxy = new HashMap<>();
 | 
	
		
			
				|  |  | //                mn65LowGxy.put("code", "7");
 | 
	
		
			
				|  |  | //                mn65LowGxy.put("name", "慢病人群65岁以上");
 | 
	
		
			
				|  |  | //                mn65LowGxy.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  | //                resultList.add(mn65LowGxy);
 | 
	
		
			
				|  |  |             } else if (index.equals(AGE)) {
 | 
	
		
			
				|  |  |                 Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map1.put("code", "1");
 | 
	
		
			
				|  |  |                 map1.put("name", "0~6");
 | 
	
		
			
				|  |  |                 map1.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map2 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map2.put("code", "2");
 | 
	
		
			
				|  |  |                 map2.put("name", "7~18");
 | 
	
		
			
				|  |  |                 map2.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map2);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map3 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map3.put("code", "3");
 | 
	
		
			
				|  |  |                 map3.put("name", "18~30");
 | 
	
		
			
				|  |  |                 map3.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map3);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map4 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map4.put("code", "4");
 | 
	
		
			
				|  |  |                 map4.put("name", "30~50");
 | 
	
		
			
				|  |  |                 map4.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map4);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map5 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map5.put("code", "5");
 | 
	
		
			
				|  |  |                 map5.put("name", "50~65");
 | 
	
		
			
				|  |  |                 map5.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map5);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map6 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map6.put("code", "6");
 | 
	
		
			
				|  |  |                 map6.put("name", "50~65");
 | 
	
		
			
				|  |  |                 map6.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map6);
 | 
	
		
			
				|  |  |             } else if (index.equals("16")) {
 | 
	
		
			
				|  |  |                 Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map1.put("code", "0");
 | 
	
		
			
				|  |  |                 map1.put("name", "未缴费人数");
 | 
	
		
			
				|  |  |                 map1.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map2 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map2.put("code", "1");
 | 
	
		
			
				|  |  |                 map2.put("name", "已缴费人数");
 | 
	
		
			
				|  |  |                 map2.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map2);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map3 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map3.put("code", "2");
 | 
	
		
			
				|  |  |                 map3.put("name", "已退费人数");
 | 
	
		
			
				|  |  |                 map3.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map3);
 | 
	
		
			
				|  |  |             } else if (index.equals("15")) {
 | 
	
		
			
				|  |  |                 Map<String, Object> map1 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map1.put("code", "0");
 | 
	
		
			
				|  |  |                 map1.put("name", "未标注");
 | 
	
		
			
				|  |  |                 map1.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map2 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map2.put("code", "1");
 | 
	
		
			
				|  |  |                 map2.put("name", "健康人群");
 | 
	
		
			
				|  |  |                 map2.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map2);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map3 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map3.put("code", "2");
 | 
	
		
			
				|  |  |                 map3.put("name", "患病人群");
 | 
	
		
			
				|  |  |                 map3.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map3);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map4 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map4.put("code", "3");
 | 
	
		
			
				|  |  |                 map4.put("name", "高危人群");
 | 
	
		
			
				|  |  |                 map4.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map4);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 Map<String, Object> map5 = new HashMap<>();
 | 
	
		
			
				|  |  |                 map5.put("code", "4");
 | 
	
		
			
				|  |  |                 map5.put("name", "恢复期人群");
 | 
	
		
			
				|  |  |                 map5.put("amount", Double.valueOf("0.0"));
 | 
	
		
			
				|  |  |                 resultList.add(map5);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (resultList != null) {
 | 
	
		
			
				|  |  |             long total = 0;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             for (Map<String, Object> map : resultList) {
 | 
	
		
			
				|  |  |                 map.put("amount", map.get("amount") == null ? 0 : Math.round(Double.valueOf(map.get("amount").toString())));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 当天数据统计
 | 
	
		
			
				|  |  |                 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 + ":" + level + ":" + code + ":" + area);
 | 
	
		
			
				|  |  |                     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"));
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (index.equals(GROUP)) {
 | 
	
		
			
				|  |  |                     // 分组指标总数算法
 | 
	
		
			
				|  |  |                     String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
 | 
	
		
			
				|  |  |                     if (code.equals("1") || code.equals("2") || code.equals("3")) {
 | 
	
		
			
				|  |  |                         total += (long) map.get("amount");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else if (index.equals("16")) {
 | 
	
		
			
				|  |  |                     String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     if (!code.equals("2")) {
 | 
	
		
			
				|  |  |                         total += (long) map.get("amount");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     total += (long) map.get("amount");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!index.equals(AGE)) {
 | 
	
		
			
				|  |  |                 DecimalFormat df = new DecimalFormat("0.0000");
 | 
	
		
			
				|  |  |                 for (Map<String, Object> map : resultList) {
 | 
	
		
			
				|  |  |                     double rateG = (total > 0 ? ((long) map.get("amount")) * 1.0000 / total * 100 : 0);
 | 
	
		
			
				|  |  |                     map.put("rate", df.format(rateG));
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (index.equals(SEX) && resultList.size() > 0) {
 | 
	
		
			
				|  |  |                 int i = 0;
 | 
	
		
			
				|  |  |                 boolean flag = false;
 | 
	
		
			
				|  |  |                 for (; i < resultList.size(); i++) {
 | 
	
		
			
				|  |  |                     if (resultList.get(i).get("code") != null && String.valueOf(resultList.get(i).get("code")).equals("3")
 | 
	
		
			
				|  |  |                             && String.valueOf(resultList.get(i).get("amount")).equals("0")) {
 | 
	
		
			
				|  |  |                         flag = true;
 | 
	
		
			
				|  |  |                         break;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (flag) {
 | 
	
		
			
				|  |  |                     resultList.remove(i);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             return new JSONArray(resultList);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return new JSONArray();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |