|
@@ -0,0 +1,137 @@
|
|
|
|
|
+package com.studenthotel.services.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.studenthotel.mapper.RealTimeDataMapper;
|
|
|
|
|
+import com.studenthotel.mapper.SchoolUserMapper;
|
|
|
|
|
+import com.studenthotel.model.pojo.RealTimeData;
|
|
|
|
|
+import com.studenthotel.model.pojo.SchoolUser;
|
|
|
|
|
+import com.studenthotel.services.RealTimeDataService;
|
|
|
|
|
+import com.studenthotel.services.SchoolUserService;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.awt.*;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 实时数据实现类
|
|
|
|
|
+ * </p>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author xieli
|
|
|
|
|
+ * @since 2023-06-12
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+public class RealTimeDataServiceImpl extends ServiceImpl<RealTimeDataMapper, RealTimeData> implements RealTimeDataService {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询类型分类,1防摔跤2打架3抽烟4高空抛物5学情睡觉6学情玩手机7学情抬头8其它9查学情
|
|
|
|
|
+ * @param type
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map geXueQingData(String type) {
|
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtils.isEmpty(type)){
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String dataType = typeConvert(type);
|
|
|
|
|
+ List sleepList = new ArrayList();
|
|
|
|
|
+ List playList = new ArrayList();
|
|
|
|
|
+ List lookList = new ArrayList();
|
|
|
|
|
+ // 查询类型分类,1防摔跤2打架3抽烟4高空抛物5学情睡觉6学情玩手机7学情抬头8其它9查学情
|
|
|
|
|
+ if (type.equals("9"))
|
|
|
|
|
+ {
|
|
|
|
|
+ // 9查学情可分为5学情睡觉6学情玩手机7学情抬头三种情况
|
|
|
|
|
+ LambdaQueryWrapper<RealTimeData> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(RealTimeData::getDataType, typeConvert("5")).orderByDesc(RealTimeData::getDataCreateTime);
|
|
|
|
|
+ sleepList = this.list(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(RealTimeData::getDataType, typeConvert("6"));
|
|
|
|
|
+ playList = this.list(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(RealTimeData::getDataType, typeConvert("7")).orderByDesc(RealTimeData::getDataCreateTime);
|
|
|
|
|
+ lookList = this.list(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ int count = sleepList.size() + playList.size() + lookList.size();
|
|
|
|
|
+ map.put(typeConvert("5"),sleepList.size());
|
|
|
|
|
+ map.put(typeConvert("6"),playList.size());
|
|
|
|
|
+ map.put(typeConvert("7"),lookList.size());
|
|
|
|
|
+
|
|
|
|
|
+ if (count != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ double rateStr = (new BigDecimal((float) sleepList.size() / count).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100;
|
|
|
|
|
+ String sleepPercent = rateStr+"%";
|
|
|
|
|
+ rateStr = (new BigDecimal((float) playList.size() / count).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100;
|
|
|
|
|
+ String playPercent = rateStr+"%";
|
|
|
|
|
+ rateStr = (new BigDecimal((float) lookList.size() / count).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue()) * 100;
|
|
|
|
|
+ String lookPercent = rateStr+"%";
|
|
|
|
|
+
|
|
|
|
|
+ map.put(typeConvert("5")+ "百分比" ,sleepPercent);
|
|
|
|
|
+ map.put(typeConvert("6")+ "百分比",playList);
|
|
|
|
|
+ map.put(typeConvert("7")+ "百分比",lookPercent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return map;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<RealTimeData> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(RealTimeData::getDataType,dataType);
|
|
|
|
|
+ wrapper.orderByDesc(RealTimeData::getDataCreateTime);
|
|
|
|
|
+ List<RealTimeData> list = this.list(wrapper);
|
|
|
|
|
+ if (list.size() >= 0){
|
|
|
|
|
+ map.put(type,list);
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 1防摔跤2打架3抽烟4高空抛物5学情睡觉6学情玩手机7学情抬头8其它0全部
|
|
|
|
|
+ * @param type
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public String typeConvert(String type)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (ObjectUtils.isEmpty(type)){
|
|
|
|
|
+ return "防摔跤";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type.equals("1")) {
|
|
|
|
|
+ return "防摔跤";
|
|
|
|
|
+ }else if (type.equals("2")) {
|
|
|
|
|
+ return "打架";
|
|
|
|
|
+ }else if (type.equals("3")) {
|
|
|
|
|
+ return "抽烟";
|
|
|
|
|
+ }else if (type.equals("4")) {
|
|
|
|
|
+ return "高空抛物";
|
|
|
|
|
+ }else if (type.equals("5")) {
|
|
|
|
|
+ return "学情睡觉";
|
|
|
|
|
+ }else if (type.equals("6")) {
|
|
|
|
|
+ return "学情玩手机";
|
|
|
|
|
+ }else if (type.equals("7")) {
|
|
|
|
|
+ return "学情抬头";
|
|
|
|
|
+ }else if (type.equals("8")) {
|
|
|
|
|
+ return "其它";
|
|
|
|
|
+ }else if (type.equals("9")) {
|
|
|
|
|
+ return "查学情";
|
|
|
|
|
+ }
|
|
|
|
|
+ return "全部";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|