hanzhengyi il y a 1 an
Parent
commit
e6ab433d94
23 fichiers modifiés avec 1307 ajouts et 1 suppressions
  1. 3 1
      pom.xml
  2. 20 0
      service-agbox/pom.xml
  3. 27 0
      service-agbox/service-agbox-api/pom.xml
  4. 28 0
      service-agbox/service-agbox-api/src/main/java/com/usky/agbox/RemoteUserService.java
  5. 105 0
      service-agbox/service-agbox-api/src/main/java/com/usky/agbox/domain/SysUserVO.java
  6. 48 0
      service-agbox/service-agbox-api/src/main/java/com/usky/agbox/factory/RemoteUserFallbackFactory.java
  7. 89 0
      service-agbox/service-agbox-biz/pom.xml
  8. 45 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/RuoYiSystemApplication.java
  9. 109 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/MybatisGeneratorUtils.java
  10. 65 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/web/patrolAgboxController.java
  11. 81 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/job/patrolAgbox.java
  12. 137 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/util/HttpClientUtils.java
  13. 34 0
      service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/vo/EventVO.java
  14. 25 0
      service-agbox/service-agbox-biz/src/main/resources/bootstrap.yml
  15. 108 0
      service-agbox/service-agbox-biz/src/main/resources/doc/index.adoc
  16. 94 0
      service-agbox/service-agbox-biz/src/main/resources/logback.xml
  17. 15 0
      service-agbox/service-agbox-biz/src/main/resources/smart-doc.json
  18. 43 0
      service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/BaseAppInfoController.java
  19. 106 0
      service-iot/service-iot-biz/src/main/java/com/usky/iot/domain/BaseAppInfo.java
  20. 16 0
      service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/BaseAppInfoMapper.java
  21. 22 0
      service-iot/service-iot-biz/src/main/java/com/usky/iot/service/BaseAppInfoService.java
  22. 62 0
      service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAppInfoServiceImpl.java
  23. 25 0
      service-iot/service-iot-biz/src/main/resources/mapper/iot/BaseAppInfoMapper.xml

+ 3 - 1
pom.xml

@@ -76,9 +76,11 @@
     <module>service-issue</module>
 
 
-
     <module>service-meeting</module>
 
+
+    <module>service-agbox</module>
+
   </modules>
           
   

+ 20 - 0
service-agbox/pom.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>usky-modules</artifactId>
+        <groupId>com.usky</groupId>
+        <version>0.0.1</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>service-agbox</artifactId>
+
+    <packaging>pom</packaging>
+    <version>0.0.1</version>
+
+    <modules>
+        <module>service-agbox-biz</module>
+        <module>service-agbox-api</module>
+    </modules>
+</project>

+ 27 - 0
service-agbox/service-agbox-api/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>service-agbox</artifactId>
+        <groupId>com.usky</groupId>
+        <version>0.0.1</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>service-agbox-api</artifactId>
+    <!-- SpringCloud Openfeign -->
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>usky-common-core</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+    </build>
+
+</project>

+ 28 - 0
service-agbox/service-agbox-api/src/main/java/com/usky/agbox/RemoteUserService.java

@@ -0,0 +1,28 @@
+package com.usky.agbox;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.agbox.domain.SysUserVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+@FeignClient(contextId = "remoteUserService", value = "usky-demo")
+public interface RemoteUserService {
+
+
+
+    @GetMapping("/byUserName")
+    ApiResult<List<SysUserVO>> getByUserName(@RequestParam("userName") String userName);
+
+
+    @PostMapping("/byUserName")
+    ApiResult<List<SysUserVO>> add(@RequestBody SysUserVO sysUserVO);
+
+
+    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    ApiResult<String> upload(@RequestPart(value = "file") MultipartFile file);
+}

+ 105 - 0
service-agbox/service-agbox-api/src/main/java/com/usky/agbox/domain/SysUserVO.java

@@ -0,0 +1,105 @@
+package com.usky.agbox.domain;
+
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class SysUserVO {
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 部门ID
+     */
+    private Long deptId;
+
+    /**
+     * 用户账号
+     */
+    private String userName;
+
+    /**
+     * 用户昵称
+     */
+    private String nickName;
+
+    /**
+     * 用户类型(00系统用户)
+     */
+    private String userType;
+
+    /**
+     * 用户邮箱
+     */
+    private String email;
+
+    /**
+     * 手机号码
+     */
+    private String phonenumber;
+
+    /**
+     * 用户性别(0男 1女 2未知)
+     */
+    private String sex;
+
+    /**
+     * 头像地址
+     */
+    private String avatar;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 帐号状态(0正常 1停用)
+     */
+    private String status;
+
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
+    private String delFlag;
+
+    /**
+     * 最后登录IP
+     */
+    private String loginIp;
+
+    /**
+     * 最后登录时间
+     */
+    private LocalDateTime loginDate;
+
+    /**
+     * 创建者
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新者
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+}

+ 48 - 0
service-agbox/service-agbox-api/src/main/java/com/usky/agbox/factory/RemoteUserFallbackFactory.java

@@ -0,0 +1,48 @@
+package com.usky.agbox.factory;
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.exception.BusinessException;
+import com.usky.agbox.RemoteUserService;
+import com.usky.agbox.domain.SysUserVO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+
+/**
+ * 用户服务降级处理
+ *
+ * @author ruoyi
+ */
+@Component
+public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService>
+{
+    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
+
+    @Override
+    public RemoteUserService create(Throwable throwable)
+    {
+        log.error("用户服务调用失败:{}", throwable.getMessage());
+        return new RemoteUserService() {
+            @Override
+            public ApiResult<List<SysUserVO>> getByUserName(String userName) {
+                throw new BusinessException(throwable.getMessage());
+            }
+
+            @Override
+            public ApiResult<List<SysUserVO>> add(SysUserVO sysUserVO) {
+                throw new BusinessException(throwable.getMessage());
+            }
+
+            @Override
+            public ApiResult<String> upload(MultipartFile file) {
+                throw new BusinessException(throwable.getMessage());
+            }
+        };
+    }
+}

+ 89 - 0
service-agbox/service-agbox-biz/pom.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>service-agbox</artifactId>
+        <groupId>com.usky</groupId>
+        <version>0.0.1</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>service-agbox-biz</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>common-cloud-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-spring-boot-starter</artifactId>
+            <version>4.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-core</artifactId>
+            <version>4.5.16</version>
+        </dependency>
+
+        <!--语音依赖-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-dyvmsapi</artifactId>
+            <version>1.2.2</version>
+        </dependency>
+
+        <!--短信依赖-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>aliyun-java-sdk-dysmsapi</artifactId>
+            <version>1.1.0</version>
+        </dependency>
+
+        <!--MQTT依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-integration</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+        </dependency>
+        <!--websocket依赖-->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-websocket</artifactId>
+            <version>5.2.8.RELEASE</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>${project.artifactId}</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>com.github.shalousun</groupId>
+                <artifactId>smart-doc-maven-plugin</artifactId>
+                <version>2.1.1</version>
+                <configuration>
+                    <!--指定生成文档的使用的配置文件,配置文件放在自己的项目中-->
+                    <configFile>./src/main/resources/smart-doc.json</configFile>
+                    <!--指定项目名称-->
+                    <projectName>test</projectName>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 45 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/RuoYiSystemApplication.java

@@ -0,0 +1,45 @@
+package com.usky.agbox;
+
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.core.env.Environment;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * 系统模块
+ * 
+ * @author ruoyi
+ */
+
+
+@EnableFeignClients(basePackages = "com.usky")
+@MapperScan(value = "com.usky.agbox.mapper")
+@ComponentScan("com.usky")
+@SpringBootApplication
+public class RuoYiSystemApplication
+{
+    private static final Logger LOGGER = LoggerFactory.getLogger(RuoYiSystemApplication.class);
+
+    public static void main(String[] args) throws UnknownHostException {
+        ConfigurableApplicationContext application = SpringApplication.run(RuoYiSystemApplication.class, args);
+        Environment env = application.getEnvironment();
+        String ip = InetAddress.getLocalHost().getHostAddress();
+        String port = env.getProperty("server.port");
+        String path = env.getProperty("server.servlet.context-path");
+        LOGGER.info("\n----------------------------------------------------------\n\t" +
+                "Application is running! Access URLs:\n\t" +
+                "Local: \t\thttp://localhost:" + port + (null==path?"":path) + "/\n\t" +
+                "External: \thttp://" + ip + ":" + port + (null==path?"":path) + "/\n\t" +
+                "Api: \t\thttp://" + ip + ":" + port + (null==path?"":path) + "/swagger-ui/index.html\n\t" +
+                "----------------------------------------------------------");
+    }
+}

+ 109 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/MybatisGeneratorUtils.java

@@ -0,0 +1,109 @@
+package com.usky.agbox.controller;//package com.usky.iot.controller;//package com.usky.dm.controller.web.business;
+// package com.usky.dm.controller.web;
+
+
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.InjectionConfig;
+import com.baomidou.mybatisplus.generator.config.*;
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author yq
+ * @date 2021/7/6 11:42
+ */
+public class MybatisGeneratorUtils {
+    public static void main(String[] args) {
+
+            shell("service-agbox","service-agbox-biz");
+    }
+
+    private static void shell(String parentName,String model) {
+
+        AutoGenerator mpg = new AutoGenerator();
+        //1、全局配置
+        GlobalConfig gc = new GlobalConfig();
+//        File file = new File(model);
+//        String path = file.getAbsolutePath();
+        String projectPath = System.getProperty("user.dir");
+        projectPath+="/"+parentName;
+        projectPath+="/"+model;
+        gc.setOutputDir(projectPath+ "/src/main/java");  //生成路径(一般都是生成在此项目的src/main/java下面)
+        //修改为自己的名字
+        gc.setAuthor("han"); //设置作者
+        gc.setOpen(false);
+        gc.setFileOverride(true); //第二次生成会把第一次生成的覆盖掉
+        gc.setServiceName("%sService"); //生成的service接口名字首字母是否为I,这样设置就没有
+        gc.setBaseResultMap(true); //生成resultMap
+        mpg.setGlobalConfig(gc);
+
+        //2、数据源配置
+        //修改数据源
+        DataSourceConfig dsc = new DataSourceConfig();
+        dsc.setUrl("jdbc:mysql://172.16.120.165:3306/usky-cloud?useUnicode=true&serverTimezone=GMT&useSSL=false&characterEncoding=utf8");
+        dsc.setDriverName("com.mysql.jdbc.Driver");
+        dsc.setUsername("usky");
+        dsc.setPassword("Yt#75Usky");
+        mpg.setDataSource(dsc);
+
+        // 3、包配置
+        PackageConfig pc = new PackageConfig();
+        pc.setParent("com.usky.agbox");
+        pc.setController("controller.web");
+        pc.setEntity("domain");
+        pc.setMapper("mapper");
+        pc.setService("service");
+        pc.setServiceImpl("service.impl");
+//        pc.setXml("mapper.demo");
+        //pc.setModuleName("test");
+        mpg.setPackageInfo(pc);
+
+        // 4、策略配置
+        StrategyConfig strategy = new StrategyConfig();
+        strategy.setNaming(NamingStrategy.underline_to_camel);
+        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+        strategy.setSuperMapperClass("com.usky.common.mybatis.core.CrudMapper");
+        strategy.setSuperServiceClass("com.usky.common.mybatis.core.CrudService");
+        strategy.setSuperServiceImplClass("com.usky.common.mybatis.core.AbstractCrudService");
+        // strategy.setTablePrefix("t_"); // 表名前缀
+        strategy.setEntityLombokModel(true); //使用lombok
+        //修改自己想要生成的表
+        strategy.setInclude("sys_user");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
+        mpg.setStrategy(strategy);
+
+        // 关闭默认 xml 生成,调整生成 至 根目录
+        //修改对应的模块名称
+        TemplateConfig tc = new TemplateConfig();
+        // 自定义配置
+        InjectionConfig cfg = new InjectionConfig() {
+            @Override
+            public void initMap() {
+                // to do nothing
+            }
+        };
+        //如果模板引擎是 velocity
+        String templatePath = "/templates/mapper.xml.vm";
+        // 自定义输出配置
+        List<FileOutConfig> focList = new ArrayList<>();
+        // 自定义配置会被优先输出
+        String finalProjectPath = projectPath;
+        focList.add(new FileOutConfig(templatePath) {
+            @Override
+            public String outputFile(TableInfo tableInfo) {
+                // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
+                return finalProjectPath + "/src/main/resources/mapper/agbox" + "/"
+                        + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
+            }
+        });
+        cfg.setFileOutConfigList(focList);
+        mpg.setCfg(cfg);
+        tc.setXml(null);
+        mpg.setTemplate(tc);
+        //5、执行
+        mpg.execute();
+    }
+}

+ 65 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/controller/web/patrolAgboxController.java

@@ -0,0 +1,65 @@
+package com.usky.agbox.controller.web;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
+import com.usky.agbox.service.job.patrolAgbox;
+import com.usky.agbox.service.vo.EventVO;
+import com.usky.common.core.bean.ApiResult;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author han
+ * @date 2024/03/22 16:20
+ */
+@RestController
+@RequestMapping("/patrolAgbox")
+public class patrolAgboxController {
+    /**
+     * 获取事件编码信息
+     * @return
+     */
+    @PostMapping("/getEventCode")
+    public ApiResult<JSONObject> getEventCode(){
+        return ApiResult.success(patrolAgbox.getEventCode());
+    }
+
+    /**
+     * 获取设备列表信息
+     * @return
+     */
+    @PostMapping("/getDeviceList")
+    public ApiResult<JSONObject> getDeviceList(){
+        return ApiResult.success(patrolAgbox.getDeviceList());
+    }
+
+    /**
+     * 添加事件信息
+     * @return
+     */
+    @PostMapping("/addEvent")
+    public ApiResult<JSONObject> addEvent(@RequestBody EventVO eventVO){
+        return ApiResult.success(patrolAgbox.addEvent(eventVO));
+    }
+
+    /**
+     * 更新心跳信息
+     * @return
+     */
+    @PostMapping("/updateHeart")
+    public ApiResult<JSONObject> updateHeart(@RequestBody EventVO eventVO){
+        return ApiResult.success(patrolAgbox.updateHeart(eventVO));
+    }
+
+    /**
+     * 获取事件信息
+     * @return
+     */
+    @PostMapping("/getEvent")
+    public ApiResult<JSONObject> getEvent(){
+        return ApiResult.success(patrolAgbox.getEvent());
+    }
+}

+ 81 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/job/patrolAgbox.java

@@ -0,0 +1,81 @@
+package com.usky.agbox.service.job;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
+import com.usky.agbox.service.util.HttpClientUtils;
+import com.usky.agbox.service.vo.EventVO;
+
+import java.util.HashMap;
+
+public class patrolAgbox {
+
+    private static String KEY = "44c2710b-f7ff-4487-a556-bfae08232a09";
+    private static String URL = "http://172.16.120.245/agbox/device/patrol";
+
+    /**
+     * 获取事件编码信息
+     * @return
+     */
+    public static JSONObject getEventCode() {
+        HashMap map = new HashMap();
+        map.put("key", KEY);
+        map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getPatrolEventCode\"}");
+        String resultString = HttpClientUtils.doPost(URL,map);
+        JSONObject resultVO = JSONObject.parseObject(resultString);
+        return resultVO;
+    }
+
+    /**
+     * 获取设备列表信息
+     * @return
+     */
+    public static JSONObject getDeviceList() {
+        HashMap map = new HashMap();
+        map.put("key", KEY);
+        map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getDeviceList\"}");
+        String resultString = HttpClientUtils.doPost(URL,map);
+        JSONObject resultVO = JSONObject.parseObject(resultString);
+        return resultVO;
+    }
+
+    /**
+     * 添加事件信息
+     * @return
+     */
+    public static JSONObject addEvent(EventVO eventVO) {
+        HashMap map = new HashMap();
+        map.put("key", KEY);
+        map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"addEvent\",\"params\":{\"deviceId\":\""+eventVO.getDeviceId()+"\"," +
+                "\"triggerTime\":\""+eventVO.getTriggerTime()+"\",\"eventCode\":"+eventVO.getEventCode()+",\"name" +
+                "\":\""+eventVO.getName()+"\",\"certifiedNo\":\""+eventVO.getCertifiedNo()+"\"}}");
+        String resultString = HttpClientUtils.doPost(URL,map);
+        JSONObject resultVO = JSONObject.parseObject(resultString);
+        return resultVO;
+    }
+
+    /**
+     * 更新心跳信息
+     * @return
+     */
+    public static JSONObject updateHeart(EventVO eventVO) {
+        HashMap map = new HashMap();
+        map.put("key", KEY);
+        map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"updateHeart\",\"params\":{\"deviceId\":\""+eventVO.getDeviceId()+"\"}}");
+        String resultString = HttpClientUtils.doPost(URL,map);
+        JSONObject resultVO = JSONObject.parseObject(resultString);
+        return resultVO;
+    }
+
+    /**
+     * 获取事件信息
+     * @return
+     */
+    public static JSONObject getEvent() {
+        HashMap map = new HashMap();
+        map.put("key", KEY);
+        map.put("json", "{\"jsonrpc\":\"2.0\",\"method\":\"getEvent\",\"params\":{\"eventId\":\"3af67e73-c393-42da-ab4c-96ad5dfb946d\"}}");
+        String resultString = HttpClientUtils.doPost(URL,map);
+        JSONObject resultVO = JSONObject.parseObject(resultString);
+        return resultVO;
+    }
+}

+ 137 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/util/HttpClientUtils.java

@@ -0,0 +1,137 @@
+package com.usky.agbox.service.util;
+
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ 1. 跨域请求工具类
+ */
+public class HttpClientUtils {
+
+    public static String doGet(String url, Map<String, String> param) {
+
+        // 创建Httpclient对象
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+
+        String resultString = "";
+        CloseableHttpResponse response = null;
+        try {
+            // 创建uri
+            URIBuilder builder = new URIBuilder(url);
+            if (param != null) {
+                for (String key : param.keySet()) {
+                    builder.addParameter(key, param.get(key));
+                }
+            }
+            URI uri = builder.build();
+
+            // 创建http GET请求
+            HttpGet httpGet = new HttpGet(uri);
+
+            // 执行请求
+            response = httpclient.execute(httpGet);
+            // 判断返回状态是否为200
+            if (response.getStatusLine().getStatusCode() == 200) {
+                resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                httpclient.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return resultString;
+    }
+
+    public static String doGet(String url) {
+        return doGet(url, null);
+    }
+
+    public static String doPost(String url, Map<String, String> param) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            httpPost.setHeader("Content-Type", "charset=utf-8");
+            // 创建参数列表
+            if (param != null) {
+                List<NameValuePair> paramList = new ArrayList<>();
+                for (String key : param.keySet()) {
+                    paramList.add(new BasicNameValuePair(key, param.get(key)));
+                }
+                // 模拟表单
+                UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
+                httpPost.setEntity(entity);
+            }
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return resultString;
+    }
+
+    public static String doPost(String url) {
+        return doPost(url, null);
+    }
+
+    public static String doPostJson(String url, String json) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            // 创建请求内容
+            StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
+            httpPost.setEntity(entity);
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        return resultString;
+    }
+}

+ 34 - 0
service-agbox/service-agbox-biz/src/main/java/com/usky/agbox/service/vo/EventVO.java

@@ -0,0 +1,34 @@
+package com.usky.agbox.service.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class EventVO {
+    /**
+     * 设备ID
+     */
+    private String deviceId;
+
+    /**
+     * 事件时间
+     */
+    private String triggerTime;
+
+    /**
+     * 事件编码
+     */
+    private Integer eventCode;
+
+    /**
+     * 人员姓名
+     */
+    private String name;
+
+    /**
+     * 证件编号
+     */
+    private String certifiedNo;
+
+}

+ 25 - 0
service-agbox/service-agbox-biz/src/main/resources/bootstrap.yml

@@ -0,0 +1,25 @@
+# Tomcat
+server:
+  port: 9893
+
+# Spring
+spring: 
+  application:
+    # 应用名称
+    name: service-agbox
+  profiles:
+    # 环境配置
+    active: dev
+  cloud:
+    nacos:
+      discovery:
+        # 服务注册地址
+        server-addr: 172.16.120.165:8848
+      config:
+        # 配置中心地址
+        server-addr: 172.16.120.165:8848
+        # 配置文件格式
+        file-extension: yml
+        # 共享配置
+        shared-configs:
+          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 108 - 0
service-agbox/service-agbox-biz/src/main/resources/doc/index.adoc

@@ -0,0 +1,108 @@
+= 安防项目
+
+[width="100%",options="header"]
+[stripes=even]
+|====================
+|Version |  Update Time  | Status | Author |  Description
+|v2022-04-21 16:57:08|2022-04-21 16:57:08|auto|@yq|Created by smart-doc
+|====================
+
+
+== &lt;p&gt;参数配置表 前端控制器&lt;/p&gt;
+== &lt;p&gt;部门信息&lt;/p&gt;
+=== 查看部门信息
+*URL:* http:10.23.39.1:8082/sysDept/list
+
+*Type:* POST
+
+*Author:* ya
+
+*Content-Type:* application/json; charset=utf-8
+
+
+
+
+*Body-parameters:*
+
+[width="100%",options="header"]
+[stripes=even]
+|====================
+|Parameter | Type|Description|Required|Since
+|deptId|int64|部门id|false|-
+|parentId|int64|父部门id|false|-
+|ancestors|string|祖级列表|false|-
+|deptName|string|部门名称|false|-
+|orderNum|int32|显示顺序|false|-
+|leader|string|负责人|false|-
+|phone|string|联系电话|false|-
+|email|string|邮箱|false|-
+|status|string|部门状态(0正常 1停用)|false|-
+|delFlag|string|删除标志(0代表存在 2代表删除)|false|-
+|createBy|string|创建者|false|-
+|createTime|string|创建时间|false|-
+|updateBy|string|更新者|false|-
+|updateTime|string|更新时间|false|-
+|bId|int64|建筑id|false|-
+|====================
+
+*Response-fields:*
+
+[width="100%",options="header"]
+[stripes=even]
+|====================
+|Field | Type|Description|Since
+|status|object|No comments found.|-
+|code|string|No comments found.|-
+|msg|string|No comments found.|-
+|data|object|No comments found.|-
+|└─deptId|int64|部门id|-
+|└─parentId|int64|父部门id|-
+|└─ancestors|string|祖级列表|-
+|└─deptName|string|部门名称|-
+|└─orderNum|int32|显示顺序|-
+|└─leader|string|负责人|-
+|└─phone|string|联系电话|-
+|└─email|string|邮箱|-
+|└─status|string|部门状态(0正常 1停用)|-
+|└─delFlag|string|删除标志(0代表存在 2代表删除)|-
+|└─createBy|string|创建者|-
+|└─createTime|string|创建时间|-
+|└─updateBy|string|更新者|-
+|└─updateTime|string|更新时间|-
+|└─bId|int64|建筑id|-
+|exception|string|No comments found.|-
+|====================
+
+*Response-example:*
+----
+{
+	"status": {
+		
+	},
+	"code": "97564",
+	"msg": "wnr5qt",
+	"data": [
+		{
+			"deptId": 540,
+			"parentId": 858,
+			"ancestors": "o5lg60",
+			"deptName": "文.沈",
+			"orderNum": 260,
+			"leader": "ufz93p",
+			"phone": "17852835049",
+			"email": "智渊.徐@yahoo.com",
+			"status": "nu6cnp",
+			"delFlag": "72oiji",
+			"createBy": "5fxr6j",
+			"createTime": "2022-04-21 16:57:10",
+			"updateBy": "4kcs4e",
+			"updateTime": "2022-04-21 16:57:10",
+			"bId": 977
+		}
+	],
+	"exception": "53u6bg"
+}
+----
+
+== &lt;p&gt;用户信息表 前端控制器&lt;/p&gt;
+

+ 94 - 0
service-agbox/service-agbox-biz/src/main/resources/logback.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 日志存放路径 -->
+    <property name="log.path" value="/var/log/uskycloud/service-alarm" />
+    <!-- 日志输出格式 -->
+    <property name="log.pattern" value="%d{MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{26}:%line: %msg%n" />
+    <!--    	<property name="log.pattern" value="%gray(%d{MM-dd HH:mm:ss.SSS}) %highlight(%-5level) &#45;&#45; [%gray(%thread)] %cyan(%logger{26}:%line): %msg%n" />-->
+
+
+    <property name="SQL_PACKAGE" value="com.usky.alarm.mapper"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="file_sql" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/sql.log</file>
+        <!-- 循环政策:基于时间创建日志文件 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+            <fileNamePattern>${log.path}/sql.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>3</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+
+    <!-- 系统日志输出 -->
+    <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/info.log</file>
+        <!-- 循环政策:基于时间创建日志文件 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+            <fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>3</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 过滤的级别 -->
+            <level>INFO</level>
+            <!-- 匹配时的操作:接收(记录) -->
+            <onMatch>ACCEPT</onMatch>
+            <!-- 不匹配时的操作:拒绝(不记录) -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${log.path}/error.log</file>
+        <!-- 循环政策:基于时间创建日志文件 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志文件名格式 -->
+            <fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <!-- 日志最大的历史 60天 -->
+            <maxHistory>60</maxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <!-- 过滤的级别 -->
+            <level>ERROR</level>
+            <!-- 匹配时的操作:接收(记录) -->
+            <onMatch>ACCEPT</onMatch>
+            <!-- 不匹配时的操作:拒绝(不记录) -->
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 系统模块日志级别控制  -->
+    <!--	<logger name="com.usky" level="info" />-->
+    <!-- Spring日志级别控制  -->
+    <!--	<logger name="org.springframework" level="warn" />-->
+
+    <logger name="${SQL_PACKAGE}" additivity="false" level="debug">
+        <appender-ref ref="console"/>
+        <appender-ref ref="file_sql"/>
+    </logger>
+
+    <!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="file_info" />
+        <appender-ref ref="file_error" />
+        <appender-ref ref="console" />
+    </root>
+</configuration>

+ 15 - 0
service-agbox/service-agbox-biz/src/main/resources/smart-doc.json

@@ -0,0 +1,15 @@
+{
+  "outPath":"./src/main/resources/doc",
+  "serverUrl": "http:10.23.39.1:9887/",
+  "isStrict": false,
+  "coverOld": true,
+  "allInOne": true,
+  "packageFilters": "com.usky.iot.controller.web",
+  "requestExample":"false",
+  "responseExample":"true",
+  "projectName": "iot项目",
+  "appKey": "20211216921084883495813120",
+  "appToken":"967031b0cc6f474aaf73616cbf2b25c2",
+  "secret": "N@Pd,KXAHki*BW3=zK.XPNykf!=CM79J",
+  "openUrl": "http://101.133.214.75:7700/api"
+}

+ 43 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/BaseAppInfoController.java

@@ -0,0 +1,43 @@
+package com.usky.iot.controller.web;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.iot.domain.BaseAlarmType;
+import com.usky.iot.domain.BaseAppInfo;
+import com.usky.iot.service.BaseAlarmTypeService;
+import com.usky.iot.service.BaseAppInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * APP用户心跳信息 前端控制器
+ * </p>
+ *
+ * @author han
+ * @since 2024-03-29
+ */
+@RestController
+@RequestMapping("/baseAppInfo")
+public class BaseAppInfoController {
+    @Autowired
+    private BaseAppInfoService baseAppInfoService;
+
+    /**
+     * 新增
+     * @param baseAppInfo
+     * @return
+     */
+    @PostMapping("add")
+    public ApiResult<Void> add(@RequestBody BaseAppInfo baseAppInfo){
+        baseAppInfoService.add(baseAppInfo);
+        return ApiResult.success();
+    }
+
+}
+

+ 106 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/domain/BaseAppInfo.java

@@ -0,0 +1,106 @@
+package com.usky.iot.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * APP用户心跳信息
+ * </p>
+ *
+ * @author han
+ * @since 2024-03-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class BaseAppInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 设备ID
+     */
+    private String deviceId;
+
+    /**
+     * 用户账号
+     */
+    private String userName;
+
+    /**
+     * 设备型号
+     */
+    private String deviceModel;
+
+    /**
+     * 访问IP
+     */
+    private String accessIp;
+
+    /**
+     * 网络类型
+     */
+    private String networkType;
+
+    /**
+     * 网络服务商
+     */
+    private String networkService;
+
+    /**
+     * 操作系统
+     */
+    private String operateSystem;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 更新人
+     */
+    private String updateBy;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 组织机构ID
+     */
+    private Integer deptId;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+
+}

+ 16 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/BaseAppInfoMapper.java

@@ -0,0 +1,16 @@
+package com.usky.iot.mapper;
+
+import com.usky.iot.domain.BaseAppInfo;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ * APP用户心跳信息 Mapper 接口
+ * </p>
+ *
+ * @author han
+ * @since 2024-03-29
+ */
+public interface BaseAppInfoMapper extends CrudMapper<BaseAppInfo> {
+
+}

+ 22 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/BaseAppInfoService.java

@@ -0,0 +1,22 @@
+package com.usky.iot.service;
+
+import com.usky.iot.domain.BaseAlarmType;
+import com.usky.iot.domain.BaseAppInfo;
+import com.usky.common.mybatis.core.CrudService;
+
+/**
+ * <p>
+ * APP用户心跳信息 服务类
+ * </p>
+ *
+ * @author han
+ * @since 2024-03-29
+ */
+public interface BaseAppInfoService extends CrudService<BaseAppInfo> {
+    /**
+     * 新增
+     * @param baseAppInfo
+     * @return
+     */
+    void add(BaseAppInfo baseAppInfo);
+}

+ 62 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/BaseAppInfoServiceImpl.java

@@ -0,0 +1,62 @@
+package com.usky.iot.service.impl;
+
+import com.usky.common.core.exception.BusinessException;
+import com.usky.common.security.utils.SecurityUtils;
+import com.usky.iot.domain.BaseAlarmType;
+import com.usky.iot.domain.BaseAppInfo;
+import com.usky.iot.mapper.BaseAppInfoMapper;
+import com.usky.iot.service.BaseAppInfoService;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * APP用户心跳信息 服务实现类
+ * </p>
+ *
+ * @author han
+ * @since 2024-03-29
+ */
+@Service
+public class BaseAppInfoServiceImpl extends AbstractCrudService<BaseAppInfoMapper, BaseAppInfo> implements BaseAppInfoService {
+
+    public String getIpAddress(HttpServletRequest request) {
+        String ip = request.getHeader("X-Forwarded-For");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        return ip;
+    }
+
+    public static HttpServletRequest getHttpServletRequest() {
+        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        if(requestAttributes == null){
+            return null;
+        }
+
+        return ((ServletRequestAttributes) requestAttributes).getRequest();
+    }
+
+    @Override
+    public void add(BaseAppInfo baseAppInfo){
+        HttpServletRequest request = getHttpServletRequest();
+        String accessIp = getIpAddress(request);
+        baseAppInfo.setAccessIp(accessIp);
+        baseAppInfo.setCreateBy(SecurityUtils.getUsername());
+        baseAppInfo.setCreateTime(LocalDateTime.now());
+        baseAppInfo.setTenantId(SecurityUtils.getTenantId());
+        this.save(baseAppInfo);
+    }
+}

+ 25 - 0
service-iot/service-iot-biz/src/main/resources/mapper/iot/BaseAppInfoMapper.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.usky.iot.mapper.BaseAppInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.iot.domain.BaseAppInfo">
+        <id column="id" property="id" />
+        <result column="device_id" property="deviceId" />
+        <result column="user_name" property="userName" />
+        <result column="device_model" property="deviceModel" />
+        <result column="access_ip" property="accessIp" />
+        <result column="network_type" property="networkType" />
+        <result column="network_service" property="networkService" />
+        <result column="operate_system" property="operateSystem" />
+        <result column="longitude" property="longitude" />
+        <result column="latitude" property="latitude" />
+        <result column="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+        <result column="update_by" property="updateBy" />
+        <result column="create_by" property="createBy" />
+        <result column="dept_id" property="deptId" />
+        <result column="tenant_id" property="tenantId" />
+    </resultMap>
+
+</mapper>