Browse Source

学情预警

Administrator 2 years ago
parent
commit
16150397c9

+ 5 - 0
.idea/jarRepositories.xml

@@ -4,6 +4,11 @@
     <remote-repository>
     <remote-repository>
       <option name="id" value="central" />
       <option name="id" value="central" />
       <option name="name" value="Central Repository" />
       <option name="name" value="Central Repository" />
+      <option name="url" value="https://repo.maven.apache.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
       <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/central/" />
       <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/central/" />
     </remote-repository>
     </remote-repository>
     <remote-repository>
     <remote-repository>

+ 82 - 0
src/main/java/com/studenthotel/controller/RealTimeDataController.java

@@ -0,0 +1,82 @@
+package com.studenthotel.controller;
+
+
+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.studenthotel.model.pojo.ContrastFailure;
+import com.studenthotel.model.pojo.RealTimeData;
+import com.studenthotel.model.utils.CommonResult;
+import com.studenthotel.services.RealTimeDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * <p>
+ *  控制器,实时数据报表接口
+ * </p>
+ *
+ * @author xieli
+ * @since 2023-06-12
+ */
+@RestController
+@RequestMapping("/auto/realTimeData")
+public class RealTimeDataController {
+
+
+    @Autowired
+    RealTimeDataService realTimeDataService;
+
+    @GetMapping("/getDataList")
+    public CommonResult getDataList(String type, Integer page, Integer size) {
+        if (ObjectUtils.isEmpty(type)) {
+            return CommonResult.fail();
+        }
+        if (ObjectUtils.isEmpty(page) || page <= 0) {
+            page = 1;
+        }
+        if (ObjectUtils.isEmpty(size) || size <= 0) {
+            size = 5;
+        }
+
+        String dataType = realTimeDataService.typeConvert(type);
+        LambdaQueryWrapper<RealTimeData> wrapper = new LambdaQueryWrapper<>();
+
+        wrapper.select(RealTimeData::getDataId,RealTimeData::getDataType,RealTimeData::getDataAdd,RealTimeData::getDataNumber,RealTimeData::getDataInfo,RealTimeData::getForewarning)
+        .eq(RealTimeData::getDataType,dataType)
+        .orderByDesc(RealTimeData::getDataCreateTime);
+
+        IPage<RealTimeData> page1 = realTimeDataService.page(new Page<>(page, size), wrapper);
+        return CommonResult.ok(page1);
+    }
+
+    @GetMapping("/geXueQingData")
+    public CommonResult geXueQingData(String type)
+    {
+        if (ObjectUtils.isEmpty(type)) {
+            return CommonResult.fail();
+        }
+        Map map = realTimeDataService.geXueQingData(type);
+        return CommonResult.ok(map);
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+

+ 1 - 1
src/main/java/com/studenthotel/core/JwtlnterceptorConfig.java

@@ -14,7 +14,7 @@ public class JwtlnterceptorConfig implements WebMvcConfigurer {
         //目前测试下来 使用 /**所有的话,response.sendError浏览器获取不到响应的信息
         //目前测试下来 使用 /**所有的话,response.sendError浏览器获取不到响应的信息
         //默认拦截所有路径
         //默认拦截所有路径
         registry.addInterceptor(authenticationInterceptor())
         registry.addInterceptor(authenticationInterceptor())
-                .addPathPatterns("/auto/**");
+                .addPathPatterns("/auto0/**");
         //endregion
         //endregion
     }
     }
 
 

+ 3 - 2
src/main/java/com/studenthotel/core/SwaggerConfiguration.java

@@ -18,13 +18,14 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 /*
 /*
 * 两种方式控制生产环境是否显示swagger
 * 两种方式控制生产环境是否显示swagger
 * */
 * */
-//@Profile("!prod")
-@Profile({"dev","test"})
+@Profile("!prod")
+//@Profile({"dev","test"})
 public class SwaggerConfiguration {
 public class SwaggerConfiguration {
     /**
     /**
      * 创建Docket类型的对象。并使用spring容器管理。
      * 创建Docket类型的对象。并使用spring容器管理。
      * Docket是Swagger中的全局配置对象。
      * Docket是Swagger中的全局配置对象。
      * 请求方式:http://ip地址:端口/项目名/swagger-ui.html#/
      * 请求方式:http://ip地址:端口/项目名/swagger-ui.html#/
+     * http://localhost:5555/swagger-ui.html#/
      */
      */
     @Bean
     @Bean
     public Docket createRestApi() {
     public Docket createRestApi() {

+ 19 - 0
src/main/java/com/studenthotel/mapper/RealTimeDataMapper.java

@@ -0,0 +1,19 @@
+package com.studenthotel.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.studenthotel.model.pojo.RealTimeData;
+import com.studenthotel.model.pojo.SchoolUser;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author xieli
+ * @since 2023-06-12
+ */
+@Mapper
+public interface RealTimeDataMapper extends BaseMapper<RealTimeData> {
+
+}

+ 58 - 0
src/main/java/com/studenthotel/model/pojo/RealTimeData.java

@@ -0,0 +1,58 @@
+package com.studenthotel.model.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author xieli
+ *
+ * @since 2023-06-12
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="RealTimeData对象", description="实时数据表")
+public class RealTimeData implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "id")
+    @TableId(value = "dataId", type = IdType.AUTO)
+    private Long dataId;
+
+    @ApiModelProperty(value = "'数据类型:防摔跤、打架、人流密度、抽烟、高空抛物、学情睡觉、学情玩手机、学情抬头、其它'")
+    private String dataType;
+
+    @ApiModelProperty(value = "'数据地址'")
+    private String dataAdd;
+
+    @ApiModelProperty(value = "数据存储信息,视频图片等")
+    private String dataInfo;
+
+    @ApiModelProperty(value = "数据数量")
+    private String dataNumber;
+
+    @ApiModelProperty(value = "创建时间")
+    private String dataCreateTime;
+
+    @ApiModelProperty(value = "数据更新时间")
+    private String dataUpdateTime;
+
+    @ApiModelProperty(value = "预警信息")
+    private String forewarning;
+
+    @ApiModelProperty(value = "备注")
+    private String remake;
+
+}

+ 25 - 0
src/main/java/com/studenthotel/services/RealTimeDataService.java

@@ -0,0 +1,25 @@
+package com.studenthotel.services;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.studenthotel.model.pojo.RealTimeData;
+import com.studenthotel.model.pojo.SchoolUser;
+
+import java.util.Map;
+
+/**
+ * <p>
+ *  实时数据业务层
+ * </p>
+ *
+ * @author liu
+ * @since 2023-06-12
+ */
+public interface RealTimeDataService extends IService<RealTimeData> {
+
+    // 获取学性相关数据
+    public Map geXueQingData(String type);
+
+
+    // 数据类型转换
+    public String typeConvert(String type);
+}

+ 137 - 0
src/main/java/com/studenthotel/services/impl/RealTimeDataServiceImpl.java

@@ -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 "全部";
+    }
+}

+ 4 - 3
src/main/resources/application.yml

@@ -3,14 +3,15 @@ server:
 # \u8BBE\u7F6E\u5F00\u53D1\u73AF\u5883
 # \u8BBE\u7F6E\u5F00\u53D1\u73AF\u5883
 spring:
 spring:
   profiles:
   profiles:
-      active: dev
+#      active: dev
   main:
   main:
     allow-circular-references: true
     allow-circular-references: true
   #\u6570\u636E\u5E93\u914D\u7F6E\u94FE\u63A5
   #\u6570\u636E\u5E93\u914D\u7F6E\u94FE\u63A5
   datasource:
   datasource:
     username: root
     username: root
-    password: root
-    url: jdbc:mysql://localhost:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    password: HuaWei@2022
+#    url: jdbc:mysql://localhost:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://172.16.20.72:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
     cache:
       type: redis
       type: redis

+ 4 - 3
target/classes/application.yml

@@ -3,14 +3,15 @@ server:
 # \u8BBE\u7F6E\u5F00\u53D1\u73AF\u5883
 # \u8BBE\u7F6E\u5F00\u53D1\u73AF\u5883
 spring:
 spring:
   profiles:
   profiles:
-      active: dev
+#      active: dev
   main:
   main:
     allow-circular-references: true
     allow-circular-references: true
   #\u6570\u636E\u5E93\u914D\u7F6E\u94FE\u63A5
   #\u6570\u636E\u5E93\u914D\u7F6E\u94FE\u63A5
   datasource:
   datasource:
     username: root
     username: root
-    password: root
-    url: jdbc:mysql://localhost:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    password: HuaWei@2022
+#    url: jdbc:mysql://localhost:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://172.16.20.72:3306/studenthotel_houtai?characterEncoding=UTF-8&share_videosuseSSL=false&useUnicode=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
     cache:
       type: redis
       type: redis

BIN
target/classes/com/studenthotel/core/JwtlnterceptorConfig.class


BIN
target/classes/com/studenthotel/core/SwaggerConfiguration.class