|
@ -992,6 +992,51 @@ public class StatisticsAllService extends BaseService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取今天某个区域一级指标的下级统计
|
|
|
*
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param lowLevel
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getTodayLowLevelTotal2(String area, int level, String index, int sort, String lowLevel) throws Exception {
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
String redisData = "";
|
|
|
try {
|
|
|
redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + low_level + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
redisData = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(redisData)) {
|
|
|
JSONArray jsonArray = new JSONArray(redisData);
|
|
|
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
JSONObject json = jsonArray.getJSONObject(i);
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
|
|
|
data.put("code", String.valueOf(json.get("code")));
|
|
|
data.put("name", String.valueOf(json.get("name")));
|
|
|
data.put("amount", Long.valueOf(String.valueOf(json.get("num"))));
|
|
|
|
|
|
resultList.add(data);
|
|
|
}
|
|
|
} else {
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
today.add(Calendar.DATE, -1);
|
|
|
String preDate = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime());
|
|
|
resultList = getTodayBeforeLowLevelTotal(preDate, area, level, index, sort, lowLevel);
|
|
|
}
|
|
|
|
|
|
if (resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey2(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取下级统计key
|
|
@ -1075,6 +1120,88 @@ public class StatisticsAllService extends BaseService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取下级统计key
|
|
|
*
|
|
|
* @param level
|
|
|
* @param lowLevel
|
|
|
* @param area
|
|
|
* @return
|
|
|
*/
|
|
|
public List<Map<String, Object>> getLowLevelMapKey2(int level, String lowLevel, String area) {
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
if (lowLevel.equals("3")) {
|
|
|
List<Town> towns = townDao.findByCityCode(area);
|
|
|
if (towns != null) {
|
|
|
for (Town town : towns) {
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
obj.put("code", town.getCode());
|
|
|
obj.put("name", town.getName());
|
|
|
obj.put("amount", 0L);
|
|
|
resultList.add(obj);
|
|
|
}
|
|
|
}
|
|
|
} else if (lowLevel.equals("2")) {
|
|
|
List<Town> towns = new ArrayList<>();
|
|
|
if (level == 4) {
|
|
|
towns = townDao.findByCityCode(area);
|
|
|
} else if (level == 3) {
|
|
|
Town town = townDao.findByCode(area);
|
|
|
if(town != null) {
|
|
|
towns.add(town);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (towns != null && towns.size() > 0) {
|
|
|
for (Town town : towns) {
|
|
|
List<Hospital> hospitals = hospitalDao.findByTownCode(town.getCode());
|
|
|
|
|
|
for (Hospital hos : hospitals) {
|
|
|
if (hos.getCode().length() > 10) {
|
|
|
continue;
|
|
|
}
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
obj.put("code", hos.getCode());
|
|
|
obj.put("name", hos.getName());
|
|
|
obj.put("amount", 0L);
|
|
|
resultList.add(obj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (lowLevel.equals("1")) {
|
|
|
List<Hospital> hospitals = new ArrayList<>();
|
|
|
if (level == 4) {
|
|
|
hospitals = hospitalDao.findByCity(area);
|
|
|
} else if (level == 3) {
|
|
|
hospitals = hospitalDao.findByTownCode(area);
|
|
|
} else {
|
|
|
Hospital hos = hospitalDao.findByCode(area);
|
|
|
if (hos != null) {
|
|
|
hospitals.add(hos);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (hospitals != null && hospitals.size() > 0) {
|
|
|
for (Hospital hos : hospitals) {
|
|
|
if (hos.getCode().length() > 10) {
|
|
|
continue;
|
|
|
}
|
|
|
List<AdminTeam> teams = adminTeamDao.findByOrgCode(hos.getCode());
|
|
|
|
|
|
for (AdminTeam team : teams) {
|
|
|
Map<String, Object> obj = new HashMap<>();
|
|
|
obj.put("code", String.valueOf(team.getId()));
|
|
|
obj.put("name", team.getName());
|
|
|
obj.put("amount", 0L);
|
|
|
resultList.add(obj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取二级指标的到达量
|
|
@ -2316,19 +2443,28 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
//计算咨询总数
|
|
|
Long signCout = getQuoTaResult(level,area);
|
|
|
//计算签约人数
|
|
|
List<Map<String, Object>> signList = getTodayLowLevelTotal2(area, level, "1", sort, lowLevel);
|
|
|
Map<String,Object> signMap = new HashMap<>();
|
|
|
if(signList!=null&&signList.size()>0){
|
|
|
//将List转化为Map减小循环层数
|
|
|
for(Map<String, Object> sign :signList){
|
|
|
signMap.put(sign.get("code").toString(),sign);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for(Map<String, Object> map :resultList){
|
|
|
Long bindCout = (Long)map.get("amount");
|
|
|
Map<String, Object> sMap = (Map<String, Object>)signMap.get(map.get("code").toString());
|
|
|
Long signCout = (Long)sMap.get("amount");
|
|
|
if((signCout!=null&&signCout!=0)&&(bindCout!=null&&bindCout!=0)){
|
|
|
double rate = (double)bindCout/signCout*100;
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("0.00");
|
|
|
map.put("bindRate",decimalFormat.format(rate)+"%");
|
|
|
}else{
|
|
|
map.put("bindRate","0.00%");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return new JSONArray(resultList);
|
|
|
} else {
|
|
|
return new JSONArray();
|