|
@ -2233,4 +2233,136 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 查询某个级别的某个指标到达量
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param sort
|
|
|
* @param lowLevel
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getLowLevelTotal2(String date, String area, int level, String index, int sort, String lowLevel) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
|
|
if (date.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
resultList = getTodayLowLevelTotal(area, level, index, sort, lowLevel);
|
|
|
} else {
|
|
|
resultList = getTodayBeforeLowLevelTotal(date, area, level, index, sort, lowLevel);
|
|
|
}
|
|
|
|
|
|
// 结果为空时,自建结果集
|
|
|
if (resultList == null || resultList.size() < 1) {
|
|
|
resultList = getLowLevelMapKey(level, low_level, area);
|
|
|
}
|
|
|
|
|
|
if (resultList != null) {
|
|
|
DecimalFormat df = new DecimalFormat("0.0000");
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
|
|
|
|
|
|
if (!low_level.equals("1")) {
|
|
|
String redisNum = "";
|
|
|
try {
|
|
|
redisNum = redisTemplate.opsForValue().get("people:num:" + map.get("code").toString());
|
|
|
} catch (Exception e) {
|
|
|
redisNum = "";
|
|
|
}
|
|
|
if (StringUtils.isEmpty(redisNum)) {
|
|
|
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));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
|
|
|
map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
|
|
|
map.put("rateString", map.get("amount") +"/"+ peopleNum.getNum());
|
|
|
map.put("taskRateString", map.get("amount")+"/"+ peopleNum.getTaskNum());
|
|
|
map.put("targetRateString",peopleNum.getTaskNum()+"/"+ peopleNum.getNum());
|
|
|
map.put("num", peopleNum.getNum());
|
|
|
map.put("task", peopleNum.getTaskNum());
|
|
|
}
|
|
|
} else {
|
|
|
JSONObject peopleNum = new JSONObject(redisNum);
|
|
|
if (peopleNum != null) {
|
|
|
map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("num") * 100));
|
|
|
map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getInt("taskNum") * 100));
|
|
|
map.put("targetRate", df.format(peopleNum.getInt("taskNum") * 1.0000 / peopleNum.getInt("num") * 100));
|
|
|
map.put("rateString", map.get("amount") +"/"+ peopleNum.getInt("num") );
|
|
|
map.put("taskRateString",map.get("amount") +"/"+peopleNum.getInt("taskNum") );
|
|
|
map.put("targetRateString",peopleNum.getInt("taskNum") +"/"+ peopleNum.getInt("num"));
|
|
|
map.put("num", peopleNum.getInt("num"));
|
|
|
map.put("task", peopleNum.getInt("taskNum"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Collections.sort(resultList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
long map1value = (long) o1.get("amount");
|
|
|
long map2value = (long) o2.get("amount");
|
|
|
|
|
|
if (map1value - map2value > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value - map2value < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
for(Map<String, Object> map :resultList){
|
|
|
Long signCout = getQuoTaResult(level,area);
|
|
|
Long bindCout = (Long)map.get("amount");
|
|
|
if((signCout!=null&&signCout!=0)&&(bindCout!=null&&bindCout!=0)){
|
|
|
double rate = (double)bindCout/signCout*100;
|
|
|
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();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询签约人数
|
|
|
* @param level
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
public Long getQuoTaResult(int level,String code){
|
|
|
StringBuffer sql = new StringBuffer("SELECT t.result FROM wlyy_quota_result t WHERE t.quato_code ='1'AND t.quota_date = DATE_SUB(curdate(),INTERVAL 1 DAY) AND t.level1_type ="+level);
|
|
|
if(level ==1){
|
|
|
//1:
|
|
|
sql.append(" AND t.qkdoctor_code = "+code);
|
|
|
}else if(level == 2){
|
|
|
//2社区机构
|
|
|
sql.append(" AND t.org_code = "+code);
|
|
|
}else if(level == 3){
|
|
|
//3区级
|
|
|
sql.append(" AND t.town = "+code);
|
|
|
}else if(level == 4){
|
|
|
//4市级
|
|
|
sql.append(" AND t.city = "+code);
|
|
|
}
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql.toString());
|
|
|
|
|
|
if(resultList!=null&&resultList.size()>0){
|
|
|
return Long.parseLong((String)resultList.get(0).get("result"));
|
|
|
}
|
|
|
|
|
|
return 0L;
|
|
|
}
|
|
|
|
|
|
}
|