|
@@ -1,5 +1,8 @@
|
|
|
package com.chuanghai.student_portrait.service.impl;
|
|
package com.chuanghai.student_portrait.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -11,7 +14,11 @@ import com.chuanghai.student_portrait.response.BaseResponse;
|
|
|
import com.chuanghai.student_portrait.response.enums.StatusEnum;
|
|
import com.chuanghai.student_portrait.response.enums.StatusEnum;
|
|
|
import com.chuanghai.student_portrait.service.*;
|
|
import com.chuanghai.student_portrait.service.*;
|
|
|
import com.chuanghai.student_portrait.utils.DateUtils;
|
|
import com.chuanghai.student_portrait.utils.DateUtils;
|
|
|
|
|
+import com.chuanghai.student_portrait.utils.JedisUtil;
|
|
|
import com.chuanghai.student_portrait.utils.LogUtils;
|
|
import com.chuanghai.student_portrait.utils.LogUtils;
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -46,11 +53,14 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
@Autowired
|
|
@Autowired
|
|
|
NewSchooluserServiceImpl newSchooluserService;
|
|
NewSchooluserServiceImpl newSchooluserService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ JedisUtil jedisUtil;
|
|
|
|
|
+
|
|
|
//健康
|
|
//健康
|
|
|
// 一月一次
|
|
// 一月一次
|
|
|
- @Scheduled(cron = "0 27 23 2 * ? ")
|
|
|
|
|
|
|
+ @Scheduled(cron = "0 25 23 2 * ? ")
|
|
|
public void saveHealthCapacity() {
|
|
public void saveHealthCapacity() {
|
|
|
-// DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
+ DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
String startTime = startTime();
|
|
String startTime = startTime();
|
|
|
String endTime = endTime();
|
|
String endTime = endTime();
|
|
|
LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
LocalDateTime start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
@@ -73,93 +83,127 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
LocalDateTime localDateTime5 = time.withHour(16).withMinute(0).withSecond(0);
|
|
LocalDateTime localDateTime5 = time.withHour(16).withMinute(0).withSecond(0);
|
|
|
LocalDateTime localDateTime6 = time.withHour(20).withMinute(0).withSecond(0);
|
|
LocalDateTime localDateTime6 = time.withHour(20).withMinute(0).withSecond(0);
|
|
|
|
|
|
|
|
- List<Consume> list1 = consumeService.list(Wrappers.<Consume>lambdaQuery().select(Consume::getIdCard).between(Consume::getConsumeTime, localDateTime1, localDateTime2).groupBy(Consume::getIdCard));
|
|
|
|
|
- List<Consume> list2 = consumeService.list(Wrappers.<Consume>lambdaQuery().select(Consume::getIdCard).between(Consume::getConsumeTime, localDateTime3, localDateTime4).groupBy(Consume::getIdCard));
|
|
|
|
|
- List<Consume> list3 = consumeService.list(Wrappers.<Consume>lambdaQuery().select(Consume::getIdCard).between(Consume::getConsumeTime, localDateTime5, localDateTime6).groupBy(Consume::getIdCard));
|
|
|
|
|
|
|
+// QueryWrapper<Consume> warpper=new QueryWrapper<>();
|
|
|
|
|
+// warpper.select("count(*) as count,id_card").between("consume_time",localDateTime1,localDateTime2).groupBy("id_card");
|
|
|
|
|
+// List<Consume> list1 = consumeService.list(warpper);
|
|
|
|
|
+//
|
|
|
|
|
+// QueryWrapper<Consume> warpper1=new QueryWrapper<>();
|
|
|
|
|
+// warpper1.select("count(*) as count,id_card").between("consume_time",localDateTime3,localDateTime4).groupBy("id_card");
|
|
|
|
|
+// List<Consume> list2 = consumeService.list(warpper1);
|
|
|
|
|
+//
|
|
|
|
|
+// QueryWrapper<Consume> warpper2=new QueryWrapper<>();
|
|
|
|
|
+// warpper2.select("count(*) as count,id_card").between("consume_time",localDateTime5,localDateTime6).groupBy("id_card");
|
|
|
|
|
+// List<Consume> list3 = consumeService.list(warpper2);
|
|
|
|
|
+ List<Consume> list1 = consumeService.list(Wrappers.<Consume>lambdaQuery()
|
|
|
|
|
+ .select(Consume::getIdCard)
|
|
|
|
|
+ .between(Consume::getConsumeTime, localDateTime1, localDateTime2)
|
|
|
|
|
+ .groupBy(Consume::getIdCard)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<Consume> list2 = consumeService.list(Wrappers.<Consume>lambdaQuery()
|
|
|
|
|
+ .select(Consume::getIdCard)
|
|
|
|
|
+ .between(Consume::getConsumeTime, localDateTime3, localDateTime4)
|
|
|
|
|
+ .groupBy(Consume::getIdCard));
|
|
|
|
|
+
|
|
|
|
|
+ List<Consume> list3 = consumeService.list(Wrappers.<Consume>lambdaQuery()
|
|
|
|
|
+ .select(Consume::getIdCard)
|
|
|
|
|
+ .between(Consume::getConsumeTime, localDateTime5, localDateTime6)
|
|
|
|
|
+ .groupBy(Consume::getIdCard));
|
|
|
|
|
+
|
|
|
|
|
+//第一个数据都是空的
|
|
|
for (Consume consume : list1) {
|
|
for (Consume consume : list1) {
|
|
|
- String idCard = consume.getIdCard();
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
- String capacityName = "健康";
|
|
|
|
|
- Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
- String units = capacity.getUnits();
|
|
|
|
|
- int i1 = Integer.parseInt(units);
|
|
|
|
|
- int un = i1 + 1;
|
|
|
|
|
- String s = String.valueOf(un);
|
|
|
|
|
- capacity.setUnits(s);
|
|
|
|
|
- this.updateById(capacity);
|
|
|
|
|
- } else {
|
|
|
|
|
- Capacity capacity1 = new Capacity();
|
|
|
|
|
- capacity1.setCapacityName(capacityName);
|
|
|
|
|
- capacity1.setSchooluserId(idCard);
|
|
|
|
|
- Date date = null;
|
|
|
|
|
- try {
|
|
|
|
|
- date = DateUtils.stringToDate(startTime);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- LogUtils.logError(e);
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(consume)) {
|
|
|
|
|
+ String idCard = consume.getIdCard();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
+ String capacityName = "健康";
|
|
|
|
|
+ Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
+ String units = capacity.getUnits();
|
|
|
|
|
+ int i1 = Integer.parseInt(units);
|
|
|
|
|
+ int un = i1 + 1;
|
|
|
|
|
+ String s = String.valueOf(un);
|
|
|
|
|
+ capacity.setUnits(s);
|
|
|
|
|
+ this.updateById(capacity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Capacity capacity1 = new Capacity();
|
|
|
|
|
+ capacity1.setCapacityName(capacityName);
|
|
|
|
|
+ capacity1.setSchooluserId(idCard);
|
|
|
|
|
+ Date date = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ date = DateUtils.stringToDate(startTime);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ LogUtils.logError(e);
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ capacity1.setDateTime(date);
|
|
|
|
|
+ capacity1.setUnits("1");
|
|
|
|
|
+ this.save(capacity1);
|
|
|
}
|
|
}
|
|
|
- capacity1.setDateTime(date);
|
|
|
|
|
- capacity1.setUnits("1");
|
|
|
|
|
- this.save(capacity1);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
for (Consume consume : list2) {
|
|
for (Consume consume : list2) {
|
|
|
- String idCard = consume.getIdCard();
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
- String capacityName = "健康";
|
|
|
|
|
- Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
- String units = capacity.getUnits();
|
|
|
|
|
- int i1 = Integer.parseInt(units);
|
|
|
|
|
- int un = i1 + 1;
|
|
|
|
|
- String s = String.valueOf(un);
|
|
|
|
|
- capacity.setUnits(s);
|
|
|
|
|
- this.updateById(capacity);
|
|
|
|
|
- } else {
|
|
|
|
|
- Capacity capacity1 = new Capacity();
|
|
|
|
|
- capacity1.setCapacityName(capacityName);
|
|
|
|
|
- capacity1.setSchooluserId(idCard);
|
|
|
|
|
- Date date = null;
|
|
|
|
|
- try {
|
|
|
|
|
- date = DateUtils.stringToDate(startTime);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- LogUtils.logError(e);
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(consume)) {
|
|
|
|
|
+ String idCard = consume.getIdCard();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
+ String capacityName = "健康";
|
|
|
|
|
+ Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
+ String units = capacity.getUnits();
|
|
|
|
|
+ int i1 = Integer.parseInt(units);
|
|
|
|
|
+ int un = i1 + 1;
|
|
|
|
|
+ String s = String.valueOf(un);
|
|
|
|
|
+ capacity.setUnits(s);
|
|
|
|
|
+ this.updateById(capacity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Capacity capacity1 = new Capacity();
|
|
|
|
|
+ capacity1.setCapacityName(capacityName);
|
|
|
|
|
+ capacity1.setSchooluserId(idCard);
|
|
|
|
|
+ Date date = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ date = DateUtils.stringToDate(startTime);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ LogUtils.logError(e);
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ capacity1.setDateTime(date);
|
|
|
|
|
+ capacity1.setUnits("1");
|
|
|
|
|
+ this.save(capacity1);
|
|
|
}
|
|
}
|
|
|
- capacity1.setDateTime(date);
|
|
|
|
|
- capacity1.setUnits("1");
|
|
|
|
|
- this.save(capacity1);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
for (Consume consume : list3) {
|
|
for (Consume consume : list3) {
|
|
|
- String idCard = consume.getIdCard();
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
- String capacityName = "健康";
|
|
|
|
|
- Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
- String units = capacity.getUnits();
|
|
|
|
|
- int i1 = Integer.parseInt(units);
|
|
|
|
|
- int un = i1 + 1;
|
|
|
|
|
- String s = String.valueOf(un);
|
|
|
|
|
- capacity.setUnits(s);
|
|
|
|
|
- this.updateById(capacity);
|
|
|
|
|
- } else {
|
|
|
|
|
- Capacity capacity1 = new Capacity();
|
|
|
|
|
- capacity1.setCapacityName(capacityName);
|
|
|
|
|
- capacity1.setSchooluserId(idCard);
|
|
|
|
|
- Date date = null;
|
|
|
|
|
- try {
|
|
|
|
|
- date = DateUtils.stringToDate(startTime);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- LogUtils.logError(e);
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(consume)) {
|
|
|
|
|
+ String idCard = consume.getIdCard();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(idCard)) {
|
|
|
|
|
+ String capacityName = "健康";
|
|
|
|
|
+ Capacity capacity = getCapacity(idCard, capacityName, startTime);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(capacity)) {
|
|
|
|
|
+ String units = capacity.getUnits();
|
|
|
|
|
+ int i1 = Integer.parseInt(units);
|
|
|
|
|
+ int un = i1 + 1;
|
|
|
|
|
+ String s = String.valueOf(un);
|
|
|
|
|
+ capacity.setUnits(s);
|
|
|
|
|
+ this.updateById(capacity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Capacity capacity1 = new Capacity();
|
|
|
|
|
+ capacity1.setCapacityName(capacityName);
|
|
|
|
|
+ capacity1.setSchooluserId(idCard);
|
|
|
|
|
+ Date date = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ date = DateUtils.stringToDate(startTime);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ LogUtils.logError(e);
|
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
|
+ }
|
|
|
|
|
+ capacity1.setDateTime(date);
|
|
|
|
|
+ capacity1.setUnits("1");
|
|
|
|
|
+ this.save(capacity1);
|
|
|
}
|
|
}
|
|
|
- capacity1.setDateTime(date);
|
|
|
|
|
- capacity1.setUnits("1");
|
|
|
|
|
- this.save(capacity1);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -382,7 +426,6 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
public static String startTime() {
|
|
public static String startTime() {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
@@ -390,6 +433,7 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
return start.minusMonths(1).format(pattern);
|
|
return start.minusMonths(1).format(pattern);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public static String endTime() {
|
|
public static String endTime() {
|
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
@@ -397,6 +441,20 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
return end.minusDays(1).format(pattern);
|
|
return end.minusDays(1).format(pattern);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static String dateTime() {
|
|
|
|
|
+ DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ int day = now.getDayOfMonth();
|
|
|
|
|
+ LocalDateTime start = null;
|
|
|
|
|
+ if (day <= 2) {
|
|
|
|
|
+ start = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).minusMonths(2);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ start = now.withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).minusMonths(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return start.format(pattern);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public Capacity getCapacity(String schooluserId, String capacityName, String startTime) {
|
|
public Capacity getCapacity(String schooluserId, String capacityName, String startTime) {
|
|
|
Capacity one = this.getOne(Wrappers.<Capacity>lambdaQuery()
|
|
Capacity one = this.getOne(Wrappers.<Capacity>lambdaQuery()
|
|
|
.eq(Capacity::getSchooluserId, schooluserId)
|
|
.eq(Capacity::getSchooluserId, schooluserId)
|
|
@@ -407,25 +465,30 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
|
|
|
|
|
// 健康,爱动,消费,关系的平均数
|
|
// 健康,爱动,消费,关系的平均数
|
|
|
public CapacityDto getAverage(String name) {
|
|
public CapacityDto getAverage(String name) {
|
|
|
- String s = startTime();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ String s = dateTime();
|
|
|
CapacityDto capacityDto = new CapacityDto();
|
|
CapacityDto capacityDto = new CapacityDto();
|
|
|
List<Capacity> list = this.list(Wrappers.<Capacity>lambdaQuery().eq(Capacity::getDateTime, s).eq(Capacity::getCapacityName, name));
|
|
List<Capacity> list = this.list(Wrappers.<Capacity>lambdaQuery().eq(Capacity::getDateTime, s).eq(Capacity::getCapacityName, name));
|
|
|
Double average = 0.0;
|
|
Double average = 0.0;
|
|
|
- for (Capacity capacity : list) {
|
|
|
|
|
- String units = capacity.getUnits();
|
|
|
|
|
- double v = Double.parseDouble(units);
|
|
|
|
|
- average = average + v;
|
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list) && list.size() > 0) {
|
|
|
|
|
+ for (Capacity capacity : list) {
|
|
|
|
|
+ String units = capacity.getUnits();
|
|
|
|
|
+ double v = Double.parseDouble(units);
|
|
|
|
|
+ average = average + v;
|
|
|
|
|
+ }
|
|
|
|
|
+ capacityDto.setMax(Math.ceil(average / list.size()));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ capacityDto.setMax(average);
|
|
|
}
|
|
}
|
|
|
capacityDto.setName(name);
|
|
capacityDto.setName(name);
|
|
|
- capacityDto.setMax(Math.ceil(average / list.size()));
|
|
|
|
|
-
|
|
|
|
|
return capacityDto;
|
|
return capacityDto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 大于等于平均数的人数
|
|
// 大于等于平均数的人数
|
|
|
public long getGeAverageCount(Double average, String name, String dateTime) {
|
|
public long getGeAverageCount(Double average, String name, String dateTime) {
|
|
|
- long count = this.count(Wrappers.<Capacity>lambdaQuery().eq(Capacity::getCapacityName, name).eq(Capacity::getDateTime, dateTime).ge(Capacity::getUnits, average));
|
|
|
|
|
|
|
+ long count = this.count(Wrappers.<Capacity>lambdaQuery()
|
|
|
|
|
+ .eq(Capacity::getCapacityName, name)
|
|
|
|
|
+ .eq(Capacity::getDateTime, dateTime)
|
|
|
|
|
+ .ge(Capacity::getUnits, average));
|
|
|
return count;
|
|
return count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -437,7 +500,7 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
|
|
|
|
|
// 单个学生总数
|
|
// 单个学生总数
|
|
|
public CapacityDto getCapacityDto(String id, String name) {
|
|
public CapacityDto getCapacityDto(String id, String name) {
|
|
|
- String s = startTime();
|
|
|
|
|
|
|
+ String s = dateTime();
|
|
|
Capacity capacity = this.getOne(Wrappers.<Capacity>lambdaQuery().eq(Capacity::getSchooluserId, id).eq(Capacity::getDateTime, s).eq(Capacity::getCapacityName, name));
|
|
Capacity capacity = this.getOne(Wrappers.<Capacity>lambdaQuery().eq(Capacity::getSchooluserId, id).eq(Capacity::getDateTime, s).eq(Capacity::getCapacityName, name));
|
|
|
CapacityDto capacityDto = new CapacityDto();
|
|
CapacityDto capacityDto = new CapacityDto();
|
|
|
capacityDto.setName(name);
|
|
capacityDto.setName(name);
|
|
@@ -449,11 +512,26 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
return capacityDto;
|
|
return capacityDto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public BaseResponse getOneStudent(String id) {
|
|
public BaseResponse getOneStudent(String id) {
|
|
|
|
|
+// ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+//
|
|
|
|
|
+// // redis 缓存
|
|
|
|
|
+// if (jedisUtil.exists("capacityOne"+id)) {
|
|
|
|
|
+// String capacityOne = jedisUtil.get("capacityOne"+id);
|
|
|
|
|
+// Map map1 = JSON.parseObject(capacityOne,Map.class);
|
|
|
|
|
+// return BaseResponse.ok(StatusEnum.SUCCESS, map1);
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
if (ObjectUtils.isEmpty(id)) {
|
|
if (ObjectUtils.isEmpty(id)) {
|
|
|
return BaseResponse.error(StatusEnum.FAIL, "参数异常");
|
|
return BaseResponse.error(StatusEnum.FAIL, "参数异常");
|
|
|
}
|
|
}
|
|
|
|
|
+ NewSchooluser byId = newSchooluserService.getById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(byId)) {
|
|
|
|
|
+ return BaseResponse.error(StatusEnum.FAIL, "该学生不存在");
|
|
|
|
|
+ }
|
|
|
String s = startTime();
|
|
String s = startTime();
|
|
|
String health = "健康";
|
|
String health = "健康";
|
|
|
String exercise = "爱动";
|
|
String exercise = "爱动";
|
|
@@ -485,7 +563,7 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
capacityDto.setMax(max + max1 + max2);
|
|
capacityDto.setMax(max + max1 + max2);
|
|
|
averages.add(capacityDto);
|
|
averages.add(capacityDto);
|
|
|
|
|
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
|
|
+
|
|
|
ArrayList<CapacityDto> capacityDtos = new ArrayList<>();
|
|
ArrayList<CapacityDto> capacityDtos = new ArrayList<>();
|
|
|
|
|
|
|
|
CapacityDto capacityDto1 = getCapacityDto(id, health);
|
|
CapacityDto capacityDto1 = getCapacityDto(id, health);
|
|
@@ -526,19 +604,37 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
|
|
|
|
|
map.put("average", averages);
|
|
map.put("average", averages);
|
|
|
map.put("list", capacityDtos);
|
|
map.put("list", capacityDtos);
|
|
|
|
|
+// String jsonStr = null;
|
|
|
|
|
+// try {
|
|
|
|
|
+// jsonStr = objectMapper.writeValueAsString(map); //areaList序列化为json字符串
|
|
|
|
|
+// } catch (JsonProcessingException e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+// jedisUtil.setnx("capacityOne"+id, jsonStr);
|
|
|
|
|
+
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, map);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, map);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public BaseResponse getAllStudents() {
|
|
public BaseResponse getAllStudents() {
|
|
|
- String s = startTime();
|
|
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
+
|
|
|
|
|
+ // redis 缓存
|
|
|
|
|
+ if (jedisUtil.exists("capacityAll")) {
|
|
|
|
|
+ String capacityAll = jedisUtil.get("capacityAll");
|
|
|
|
|
+ List<CapacityAllDto> listStr = JSON.parseArray(capacityAll, CapacityAllDto.class);
|
|
|
|
|
+ return BaseResponse.ok(StatusEnum.SUCCESS, listStr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String s = dateTime();
|
|
|
String health = "健康";
|
|
String health = "健康";
|
|
|
String exercise = "爱动";
|
|
String exercise = "爱动";
|
|
|
String consume = "消费";
|
|
String consume = "消费";
|
|
|
String affinityScore = "关系";
|
|
String affinityScore = "关系";
|
|
|
String safety = "安全";
|
|
String safety = "安全";
|
|
|
String conscientiousness = "尽责心";
|
|
String conscientiousness = "尽责心";
|
|
|
- ArrayList<CapacityAllDto> list = new ArrayList<>();
|
|
|
|
|
|
|
+ List<CapacityAllDto> list = new ArrayList<>();
|
|
|
|
|
|
|
|
// 健康
|
|
// 健康
|
|
|
CapacityDto average = getAverage(health);
|
|
CapacityDto average = getAverage(health);
|
|
@@ -609,7 +705,13 @@ public class CapacityServiceImpl extends ServiceImpl<CapacityMapper, Capacity> i
|
|
|
capacityAllDto5.setThreshold(totalCount5);
|
|
capacityAllDto5.setThreshold(totalCount5);
|
|
|
capacityAllDto5.setTruth(geAverageCount5);
|
|
capacityAllDto5.setTruth(geAverageCount5);
|
|
|
list.add(capacityAllDto5);
|
|
list.add(capacityAllDto5);
|
|
|
-
|
|
|
|
|
|
|
+ String jsonStr = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonStr = objectMapper.writeValueAsString(list); //areaList序列化为json字符串
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ jedisUtil.setnx("capacityAll", jsonStr);
|
|
|
|
|
|
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
return BaseResponse.ok(StatusEnum.SUCCESS, list);
|
|
|
}
|
|
}
|