|
@ -19,6 +19,7 @@ import com.yihu.wlyy.repository.statistics.WlyyQuotaResultDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.system.SystemDictService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -936,6 +937,59 @@ public class StatisticsAllService extends BaseService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取过去某个日期某个区域一级指标的下级统计(单条记录)
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> getTodayBeforeLowLevelTotalSingle(String date, String area, int level, String index) throws Exception {
|
|
|
Map<String, Object> map = new HashedMap();
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
String areaField = "";
|
|
|
String lowLevelField = "";
|
|
|
String lowLevelName = "";
|
|
|
|
|
|
if (level == 4) {
|
|
|
// 市级别
|
|
|
areaField = "city";
|
|
|
lowLevelField = "city";
|
|
|
lowLevelName = "city_name";
|
|
|
} else if (level == 3) {
|
|
|
// 区、城镇级别
|
|
|
areaField = "town";
|
|
|
lowLevelField = "town";
|
|
|
lowLevelName = "town_name";
|
|
|
} else if (level == 2) {
|
|
|
// 机构级别
|
|
|
areaField = "org_code";
|
|
|
lowLevelField = "org_code";
|
|
|
lowLevelName = "org_name";
|
|
|
} else if (level == 1) {
|
|
|
throw new Exception("param level error");
|
|
|
}
|
|
|
|
|
|
// 查询语句
|
|
|
String sql = " select " +
|
|
|
" ifnull(" + lowLevelField + ",'') code " +
|
|
|
" ,ifnull(" + lowLevelName + ",'') 'name' " +
|
|
|
" ,ifnull(result,'0') amount" +
|
|
|
" from " +
|
|
|
" wlyy_quota_result " +
|
|
|
" where " +
|
|
|
" quato_code = '" + index + "' " +
|
|
|
" and level1_type = ? and del = '1'" +
|
|
|
" and quota_date = ? " +
|
|
|
" and " + areaField + " = ? ";
|
|
|
|
|
|
resultList = jdbcTemplate.queryForList(sql,level, date, area);
|
|
|
|
|
|
return resultList.get(0);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取今天及以后某个区域一级指标的下级统计
|
|
@ -1027,6 +1081,38 @@ public class StatisticsAllService extends BaseService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取今天某个区域一级指标的下级统计(单条记录)
|
|
|
*
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String, Object> getTodayLowLevelTotalSingle(String area, int level, String index) throws Exception {
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
String redisData = "";
|
|
|
try {
|
|
|
redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
redisData = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(redisData)) {
|
|
|
JSONObject json = new JSONObject(redisData);
|
|
|
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"))));
|
|
|
} else {
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
today.add(Calendar.DATE, -1);
|
|
|
String preDate = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime());
|
|
|
data = getTodayBeforeLowLevelTotalSingle(preDate, area, level, index);
|
|
|
}
|
|
|
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取今天某个区域一级指标的下级统计
|
|
|
*
|
|
@ -2455,6 +2541,36 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询某个级别的某个指标到达量(单条记录)
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject getLowLevelTotalSingle2(String date, String area, int level) throws Exception {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
//获取微信关注的未交费
|
|
|
Map<String, Object> expenseStatus0 = getByIndexSingle(date, area, level, "49",dateFormat);
|
|
|
//获取微信关注的已交费
|
|
|
Map<String, Object> expenseStatus1 = getByIndexSingle(date, area, level, "50",dateFormat);
|
|
|
//获取已缴费的签约数
|
|
|
Map<String, Object> expenseStatus1Sigjn = getByIndexSingle(date, area, level, "1",dateFormat);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("name", expenseStatus1Sigjn.get("name"));
|
|
|
jsonObject.put("code", area);
|
|
|
Long weChatAmount0 = (Long) expenseStatus0.get("amount");
|
|
|
Long weChatAmount1 = (Long) expenseStatus1.get("amount");
|
|
|
jsonObject.put("weChatAmount0", weChatAmount0);//微信关注未交费数
|
|
|
jsonObject.put("weChatAmount1", weChatAmount1);//微信关注已交费数
|
|
|
jsonObject.put("bindRate", getRangeDouuble(weChatAmount0.intValue(), weChatAmount1.intValue(), 2));//微信关注率
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取某个指标某一天某一level的值 到达量
|
|
|
*
|
|
@ -2484,6 +2600,27 @@ public class StatisticsAllService extends BaseService {
|
|
|
return returnMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取某个指标某一天某一level的值 到达量(单条记录)
|
|
|
*
|
|
|
* @param date
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @param index
|
|
|
* @param dateFormat
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private Map<String,Object> getByIndexSingle(String date, String area, int level, String index, SimpleDateFormat dateFormat) throws Exception {
|
|
|
Map<String,Object> map ;
|
|
|
if (date.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
map = getTodayLowLevelTotalSingle(area, level, index);
|
|
|
} else {
|
|
|
map = getTodayBeforeLowLevelTotalSingle(date, area, level, index);
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询签约人数
|
|
|
*
|