|
@ -72,7 +72,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
String preDate = endDate;
|
|
|
|
|
|
if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -136,7 +141,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
String preDate = endDate;
|
|
|
|
|
|
if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:16:" + level + ":" + area + ":0:" + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:16:" + level + ":" + area + ":0:" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -258,7 +268,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
String preDate = endDate;
|
|
|
|
|
|
if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:7:" + level + ":" + area + ":" + lowCode + ":" + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:7:" + level + ":" + area + ":" + lowCode + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -684,8 +699,13 @@ public class StatisticsAllService extends BaseService {
|
|
|
boolean flag = false;
|
|
|
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + String.valueOf(map.get("code")) + ":" + lowCode + ":" + getQuotaTimeStamp());
|
|
|
|
|
|
//String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + String.valueOf(map.get("code")) + ":" + lowCode + ":" + getQuotaTimeStamp());
|
|
|
String redisData = "";
|
|
|
try {
|
|
|
redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + String.valueOf(map.get("code")) + ":" + lowCode + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
redisData = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(redisData)) {
|
|
|
JSONObject json = new JSONObject(redisData);
|
|
|
map.put("amount", Long.valueOf(String.valueOf(json.get("num"))));
|
|
@ -696,11 +716,11 @@ public class StatisticsAllService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(flag) {
|
|
|
if (flag) {
|
|
|
Calendar today = Calendar.getInstance();
|
|
|
today.add(Calendar.DATE, -1);
|
|
|
String preDate = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime());
|
|
|
resultList = getLevelTwoTodayBeforeLowLevelTotal(preDate, area, level, index, sort, lowLevel,lowCode);
|
|
|
resultList = getLevelTwoTodayBeforeLowLevelTotal(preDate, area, level, index, sort, lowLevel, lowCode);
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
@ -718,8 +738,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
public List<Map<String, Object>> getTodayLowLevelTotal(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 = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + low_level + ":" + getQuotaTimeStamp());
|
|
|
|
|
|
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);
|
|
|
|
|
@ -855,18 +879,6 @@ public class StatisticsAllService extends BaseService {
|
|
|
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 + ":" + getQuotaTimeStamp());
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
|
map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (index.equals("7")) {
|
|
|
// 分组指标总数算法
|
|
|
String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
|
|
@ -975,8 +987,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
*/
|
|
|
public List<Map<String, Object>> getTodayLevelTwoTotal(String area, int level, String index) {
|
|
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
String redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
|
|
|
|
|
|
String redisData = "";
|
|
|
try {
|
|
|
redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
redisData = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(redisData)) {
|
|
|
JSONArray jsonArray = new JSONArray(redisData);
|
|
|
|
|
@ -1184,8 +1200,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
String preDate = endDate;
|
|
|
|
|
|
if (endDate.compareTo(datef.format(new Date())) >= 0) {
|
|
|
String redisData = redisTemplate.opsForValue().get("quota:12:" + level + ":" + area + ":6:" + getQuotaTimeStamp());
|
|
|
|
|
|
String redisData = "";
|
|
|
try {
|
|
|
redisData = redisTemplate.opsForValue().get("quota:12:" + level + ":" + area + ":6:" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
redisData = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(redisData)) {
|
|
|
JSONArray jsonArray = new JSONArray(redisData);
|
|
|
|
|
@ -1309,7 +1329,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
|
|
|
if (endDate.compareTo(datef.format(new Date())) >= 0) {
|
|
|
String code = "6";
|
|
|
String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + area + ":" + code + ":" + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + area + ":" + code + ":" + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -1516,7 +1541,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
|
|
|
// 当前范围包含当天,则需添加当天的统计数据
|
|
|
if (startStr.compareTo(df.format(new Date())) == 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -1697,7 +1727,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
|
|
|
// 当前范围包含当天,则需添加当天的统计数据
|
|
|
if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|
|
@ -1875,7 +1910,12 @@ public class StatisticsAllService extends BaseService {
|
|
|
|
|
|
// 当天数据计算
|
|
|
if (startStr.compareTo(df.format(new Date())) <= 0 && endStr.compareTo(df.format(new Date())) >= 0) {
|
|
|
String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
String val = "";
|
|
|
try {
|
|
|
val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area + ":" + (!StringUtils.isEmpty(lowCode) ? (lowCode + ":") : "") + getQuotaTimeStamp());
|
|
|
} catch (Exception e) {
|
|
|
val = "";
|
|
|
}
|
|
|
if (!StringUtils.isEmpty(val)) {
|
|
|
JSONObject valJson = new JSONObject(val);
|
|
|
if (valJson.has("num")) {
|