liujh лет назад: 3
Родитель
Сommit
c12310691e
45 измененных файлов с 4919 добавлено и 0 удалено
  1. 1 0
      zd-modules/pom.xml
  2. 105 0
      zd-modules/zd-smartlock/pom.xml
  3. 23 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/ZdSmartlockApplication.java
  4. 112 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlApplyApprovalController.java
  5. 140 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlOpendoorApplyController.java
  6. 147 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlSubjectRelationController.java
  7. 138 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlUserRelationController.java
  8. 70 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/BaseDomain.java
  9. 99 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlApplyApproval.java
  10. 263 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlOpendoorApply.java
  11. 145 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlSubjectRelation.java
  12. 89 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlUserRelation.java
  13. 104 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlBuild.java
  14. 84 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlDoorLock.java
  15. 58 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlGroup.java
  16. 35 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlLockOnline.java
  17. 80 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlOpenAndClosLog.java
  18. 82 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlOpenDoorSearch.java
  19. 123 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlPostUser.java
  20. 157 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlRoom.java
  21. 74 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlUser.java
  22. 32 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlupdateAuths.java
  23. 35 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlOpendoorApplyVo.java
  24. 21 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlSubjectRelationVo.java
  25. 69 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlApplyApprovalMapper.java
  26. 72 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlOpendoorApplyMapper.java
  27. 68 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlSubjectRelationMapper.java
  28. 69 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlUserRelationMapper.java
  29. 70 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlApplyApprovalService.java
  30. 72 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlOpendoorApplyService.java
  31. 71 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlSubjectRelationService.java
  32. 69 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlUserRelationService.java
  33. 231 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlApplyApprovalServiceImpl.java
  34. 162 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlOpendoorApplyServiceImpl.java
  35. 146 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlSubjectRelationServiceImpl.java
  36. 108 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlUserRelationServiceImpl.java
  37. 608 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/utils/SmartlockUtil.java
  38. 10 0
      zd-modules/zd-smartlock/src/main/resources/banner.txt
  39. 27 0
      zd-modules/zd-smartlock/src/main/resources/bootstrap.yml
  40. 74 0
      zd-modules/zd-smartlock/src/main/resources/logback.xml
  41. 125 0
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlApplyApprovalMapper.xml
  42. 236 0
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlOpendoorApplyMapper.xml
  43. 126 0
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlSubjectRelationMapper.xml
  44. 107 0
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlUserRelationMapper.xml
  45. 182 0
      zd-modules/zd-smartlock/wait-for-it.sh

+ 1 - 0
zd-modules/pom.xml

@@ -25,6 +25,7 @@
         <module>zd-speaker</module>
         <module>zd-speaker</module>
         <module>zd-message</module>
         <module>zd-message</module>
         <module>zd-netty</module>
         <module>zd-netty</module>
+        <module>zd-smartlock</module>
     </modules>
     </modules>
     <dependencies>
     <dependencies>
         <dependency>
         <dependency>

+ 105 - 0
zd-modules/zd-smartlock/pom.xml

@@ -0,0 +1,105 @@
+<?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>zd-modules</artifactId>
+        <groupId>com.zd</groupId>
+        <version>3.1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>zd-smartlock</artifactId>
+
+    <description>
+        zd-smartlock智能锁
+    </description>
+
+    <dependencies>
+        <!-- SpringCloud Alibaba Nacos -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+
+        <!-- SpringCloud Alibaba Nacos Config -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
+        <!-- SpringBoot Actuator -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+
+        <!-- Mysql Connector -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
+        <!-- zd Common DataSource -->
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-datasource</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <!-- zd Common Log -->
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-log</artifactId>
+        </dependency>
+
+        <!-- zd Common Swagger -->
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-swagger</artifactId>
+        </dependency>
+
+        <!--mqtt客户端链接服务-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-integration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-stream</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.integration</groupId>
+            <artifactId>spring-integration-mqtt</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-resultdata</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-resultdata</artifactId>
+        </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>
+        </plugins>
+    </build>
+
+</project>

+ 23 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/ZdSmartlockApplication.java

@@ -0,0 +1,23 @@
+package com.zd.smartlock;
+
+import com.zd.common.security.annotation.EnableCustomConfig;
+import com.zd.common.security.annotation.EnableRyFeignClients;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 智能锁启动类
+ * @author zp
+ */
+@EnableCustomConfig
+@EnableRyFeignClients
+@SpringBootApplication
+@Slf4j
+public class ZdSmartlockApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(ZdSmartlockApplication.class, args);
+        log.info("(♥◠‿◠)ノ゙  智能锁模块启动成功   ლ(´ڡ`ლ)゙");
+    }
+}

+ 112 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlApplyApprovalController.java

@@ -0,0 +1,112 @@
+package com.zd.smartlock.controller;
+
+import com.zd.common.core.utils.poi.ExcelUtil;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.common.core.web.page.TableDataInfo;
+import com.zd.common.log.annotation.Log;
+import com.zd.common.log.enums.BusinessType;
+import com.zd.common.response.ResultData;
+import com.zd.common.security.annotation.PreAuthorize;
+import com.zd.smartlock.domain.SlApplyApproval;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.api.SlUser;
+import com.zd.smartlock.service.ISlApplyApprovalService;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.smartlock.utils.SmartlockUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * 人员关联Controller
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@RestController
+@Api(tags = "【申请审核】")
+@RequestMapping("/approval")
+public class SlApplyApprovalController extends BaseController
+{
+    @Autowired
+    private ISlApplyApprovalService slApplyApprovalService;
+
+    /**
+     * 查询申请审核列表
+     */
+    @PreAuthorize(hasPermi = "laboratory:approval:list")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询申请审核列表")
+    public TableDataInfo<SlApplyApproval> list(SlApplyApproval slApplyApproval)
+    {
+        startPage();
+        List<SlApplyApproval> list = slApplyApprovalService.selectSlApplyApprovalList(slApplyApproval);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出申请审核列表
+     */
+    @ApiOperation(value = "导出申请审核列表")
+    @PreAuthorize(hasPermi = "laboratory:approval:export")
+    @Log(title = "申请审核", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SlApplyApproval slApplyApproval) throws IOException
+    {
+        List<SlApplyApproval> list = slApplyApprovalService.selectSlApplyApprovalList(slApplyApproval);
+        ExcelUtil<SlApplyApproval> util = new ExcelUtil<SlApplyApproval>(SlApplyApproval.class);
+        util.exportExcel(response, list, "申请审核数据");
+    }
+
+    /**
+     * 获取申请审核详细信息
+     */
+    @ApiOperation(value = "获取申请审核详细信息")
+    @PreAuthorize(hasPermi = "laboratory:approval:query")
+    @GetMapping(value = "/{id}")
+    public ResultData<SlApplyApproval> getInfo(@PathVariable("id") Long id)
+    {
+        return ResultData.success(slApplyApprovalService.selectSlApplyApprovalById(id));
+    }
+
+    /**
+     * 新增申请审核
+     */
+    @ApiOperation(value = "新增申请审核")
+    @PreAuthorize(hasPermi = "laboratory:approval:add")
+    @Log(title = "申请审核", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody SlApplyApproval slApplyApproval)
+    {
+        return ResultData.result(slApplyApprovalService.insertSlApplyApproval(slApplyApproval));
+    }
+
+    /**
+     * 修改申请审核
+     */
+    @ApiOperation(value = "修改申请审核")
+    @PreAuthorize(hasPermi = "laboratory:approval:edit")
+    @Log(title = "申请审核", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public ResultData edit(@RequestBody SlApplyApproval slApplyApproval)
+    {
+        return  ResultData.result(slApplyApprovalService.updateSlApplyApproval(slApplyApproval));
+    }
+
+    /**
+     * 删除申请审核
+     */
+    @ApiOperation(value = "删除申请审核")
+    @PreAuthorize(hasPermi = "laboratory:approval:remove")
+    @Log(title = "申请审核", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids)
+    {
+        return ResultData.result(slApplyApprovalService.deleteSlApplyApprovalByIds(ids));
+    }
+}

+ 140 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlOpendoorApplyController.java

@@ -0,0 +1,140 @@
+package com.zd.smartlock.controller;
+
+import com.zd.common.core.utils.poi.ExcelUtil;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.common.core.web.page.TableDataInfo;
+import com.zd.common.log.annotation.Log;
+import com.zd.common.log.enums.BusinessType;
+import com.zd.common.response.ResultData;
+import com.zd.common.security.annotation.PreAuthorize;
+import com.zd.common.security.service.TokenService;
+import com.zd.smartlock.domain.SlOpendoorApply;
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.vo.SlOpendoorApplyVo;
+import com.zd.smartlock.service.ISlOpendoorApplyService;
+import com.zd.smartlock.service.ISlSubjectRelationService;
+import com.zd.system.api.domain.SysUser;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * 申请开门Controller
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@RestController
+@Api(tags = "【申请开门】")
+@RequestMapping("/openDoorApply")
+public class SlOpendoorApplyController extends BaseController
+{
+    @Autowired
+    private ISlOpendoorApplyService slOpendoorApplyService;
+
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 查询申请开门列表
+     */
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:list")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询申请开门列表")
+    public TableDataInfo<SlOpendoorApplyVo> list(SlOpendoorApplyVo slOpendoorApply)
+    {
+        //获取登录用户
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+
+        startPage();
+        List<SlOpendoorApplyVo> list = slOpendoorApplyService.selectSlOpendoorApplyList(slOpendoorApply);
+        for (SlOpendoorApplyVo vo:list) {
+           String[] ids =  vo.getSafeUserId().split(",");
+            for (String str:ids) {
+                if(str.equals(String.valueOf(sysUser.getUserId()))){
+                    vo.setSafe(true);
+                    break;
+                }else{
+                    vo.setSafe(false);
+                }
+            }
+        }
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出申请开门列表
+     */
+    @ApiOperation(value = "导出申请开门列表")
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:export")
+    @Log(title = "申请开门", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SlOpendoorApplyVo slOpendoorApply) throws IOException
+    {
+        List<SlOpendoorApplyVo> list = slOpendoorApplyService.selectSlOpendoorApplyList(slOpendoorApply);
+        ExcelUtil<SlOpendoorApplyVo> util = new ExcelUtil<SlOpendoorApplyVo>(SlOpendoorApplyVo.class);
+        util.exportExcel(response, list, "申请开门数据");
+    }
+
+    /**
+     * 获取申请开门详细信息
+     */
+    @ApiOperation(value = "获取申请开门详细信息")
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:query")
+    @GetMapping(value = "/{id}")
+    public ResultData<SlOpendoorApply> getInfo(@PathVariable("id") Long id)
+    {
+        return ResultData.success(slOpendoorApplyService.selectSlOpendoorApplyById(id));
+    }
+
+    /**
+     * 新增申请开门
+     */
+    @ApiOperation(value = "新增申请开门")
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:add")
+    @Log(title = "申请开门", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody SlOpendoorApply slOpendoorApply)
+    {
+        /*user_id 申请人id
+        user_id2 人员2 id
+        subject_id 实验室id
+        subject_name 实验室名称 */
+
+        return ResultData.result(slOpendoorApplyService.insertSlOpendoorApply(slOpendoorApply));
+    }
+
+    /**
+     * 修改申请开门
+     */
+    @ApiOperation(value = "修改申请开门")
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:edit")
+    @Log(title = "申请开门", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public ResultData edit(@RequestBody SlOpendoorApply slOpendoorApply)
+    {
+        return  ResultData.result(slOpendoorApplyService.updateSlOpendoorApply(slOpendoorApply));
+    }
+
+    /**
+     * 删除申请开门
+     */
+    @ApiOperation(value = "删除申请开门")
+    @PreAuthorize(hasPermi = "laboratory:openDoorApply:remove")
+    @Log(title = "申请开门", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids)
+    {
+        return ResultData.result(slOpendoorApplyService.deleteSlOpendoorApplyByIds(ids));
+    }
+
+    public static void main(String[] args) {
+        String str="9261403,9261430,9261402,9261416";
+        System.out.println(str.contains("9261403"));
+    }
+}

+ 147 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlSubjectRelationController.java

@@ -0,0 +1,147 @@
+package com.zd.smartlock.controller;
+
+import com.zd.common.core.utils.poi.ExcelUtil;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.common.core.web.page.TableDataInfo;
+import com.zd.common.log.annotation.Log;
+import com.zd.common.log.enums.BusinessType;
+import com.zd.common.response.ResultData;
+import com.zd.common.security.annotation.PreAuthorize;
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.api.SlLockOnline;
+import com.zd.smartlock.domain.api.SlRoom;
+import com.zd.smartlock.domain.vo.SlSubjectRelationVo;
+import com.zd.smartlock.service.ISlSubjectRelationService;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.smartlock.utils.SmartlockUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 实验室关联Controller
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@RestController
+@Api(tags = "【实验室关联】")
+@RequestMapping("/subjectRelation")
+public class SlSubjectRelationController extends BaseController {
+    @Autowired
+    private ISlSubjectRelationService slSubjectRelationService;
+
+    /**
+     * 查询实验室关联列表
+     */
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:list")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询实验室关联列表")
+    public TableDataInfo<SlSubjectRelation> list(SlSubjectRelation slSubjectRelation) {
+        startPage();
+        List<SlSubjectRelation> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出实验室关联列表
+     */
+    @ApiOperation(value = "导出实验室关联列表")
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:export")
+    @Log(title = "实验室关联", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SlSubjectRelation slSubjectRelation) throws IOException {
+        List<SlSubjectRelation> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
+        ExcelUtil<SlSubjectRelation> util = new ExcelUtil<SlSubjectRelation>(SlSubjectRelation.class);
+        util.exportExcel(response, list, "实验室关联数据");
+    }
+
+    /**
+     * 获取实验室关联详细信息
+     */
+    @ApiOperation(value = "获取实验室关联详细信息")
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:query")
+    @GetMapping(value = "/{id}")
+    public ResultData<SlSubjectRelation> getInfo(@PathVariable("id") Long id) {
+        return ResultData.success(slSubjectRelationService.selectSlSubjectRelationById(id));
+    }
+
+    /**
+     * 新增实验室关联
+     */
+    @ApiOperation(value = "新增实验室关联")
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:add")
+    @Log(title = "实验室关联", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody SlSubjectRelationVo vo) {
+        /*`subjectId`  '实验室id',
+        `subjectName` '实验室名称',
+        `lockRoomId` '房间id', =roomid
+        `lockCode`  '门锁编号', = roomcode2
+        `roomLocation`  '房间位置 =roomlocation',
+        `roomName`   '房间名称' =roomname,
+        */
+        return ResultData.result(slSubjectRelationService.insertSlSubjectRelation(vo));
+    }
+
+    /**
+     * 修改实验室关联
+     */
+    @ApiOperation(value = "修改实验室关联")
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:edit")
+    @Log(title = "实验室关联", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public ResultData edit(@RequestBody SlSubjectRelation slSubjectRelation) {
+        return ResultData.result(slSubjectRelationService.updateSlSubjectRelation(slSubjectRelation));
+    }
+
+    /**
+     * 删除实验室关联
+     */
+    @ApiOperation(value = "删除实验室关联")
+    @PreAuthorize(hasPermi = "laboratory:subjectRelation:remove")
+    @Log(title = "实验室关联", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids) {
+        return ResultData.result(slSubjectRelationService.deleteSlSubjectRelationByIds(ids));
+    }
+
+    /**
+     * 查询智能锁房间列表
+     */
+    @GetMapping("/listLockRoom")
+    @ApiOperation(value = "查询实验室关联列表")
+    public TableDataInfo<SlRoom> listLockRoom(SlRoom slRoom) {
+        List<SlRoom> list = SmartlockUtil.getRoom( slRoom);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询实验室门锁状态
+     */
+    @GetMapping("/lockListDetails")
+    @ApiOperation(value = "查询实验室门锁状态")
+    public TableDataInfo<SlLockOnline> lockListDetails(Long subjectId) {
+        //List<SlRoom> list = SmartlockUtil.getRoom( slRoom);
+        //查询实验室下绑定的门锁
+        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        subjectRelation.setSubjectId(subjectId);
+        List<SlSubjectRelation> listrelation = slSubjectRelationService.selectSlSubjectRelationList(subjectRelation);
+
+        List<SlLockOnline> onlineList = new ArrayList<>();
+        for (SlSubjectRelation rl:listrelation) {
+            SlLockOnline lockOnline = SmartlockUtil.getRoomDetails(rl.getLockRoomId());
+            if(lockOnline!=null){
+                onlineList.add(lockOnline);
+            }
+        }
+        return getDataTable(onlineList);
+    }
+}

+ 138 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlUserRelationController.java

@@ -0,0 +1,138 @@
+package com.zd.smartlock.controller;
+
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+import com.zd.common.response.ResultData;
+import com.zd.common.security.service.TokenService;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.api.SlUser;
+import com.zd.smartlock.utils.SmartlockUtil;
+import com.zd.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.zd.common.log.annotation.Log;
+import com.zd.common.log.enums.BusinessType;
+import com.zd.common.security.annotation.PreAuthorize;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.common.core.web.domain.AjaxResult;
+import com.zd.common.core.utils.poi.ExcelUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.zd.common.core.web.page.TableDataInfo;
+
+/**
+ * 人员关联Controller
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@RestController
+@Api(tags = "【人员关联】")
+@RequestMapping("/userRelation")
+public class SlUserRelationController extends BaseController
+{
+    @Autowired
+    private ISlUserRelationService slUserRelationService;
+
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 查询人员关联列表
+     */
+    @PreAuthorize(hasPermi = "laboratory:relation:list")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询人员关联列表")
+    public TableDataInfo<SlUserRelation> list(SlUserRelation slUserRelation)
+    {
+        startPage();
+        List<SlUserRelation> list = slUserRelationService.selectSlUserRelationList(slUserRelation);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出人员关联列表
+     */
+    @ApiOperation(value = "导出人员关联列表")
+    @PreAuthorize(hasPermi = "laboratory:relation:export")
+    @Log(title = "人员关联", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SlUserRelation slUserRelation) throws IOException
+    {
+        List<SlUserRelation> list = slUserRelationService.selectSlUserRelationList(slUserRelation);
+        ExcelUtil<SlUserRelation> util = new ExcelUtil<SlUserRelation>(SlUserRelation.class);
+        util.exportExcel(response, list, "人员关联数据");
+    }
+
+    /**
+     * 获取人员关联详细信息
+     */
+    @ApiOperation(value = "获取人员关联详细信息")
+    @PreAuthorize(hasPermi = "laboratory:relation:query")
+    @GetMapping(value = "/{id}")
+    public ResultData<SlUserRelation> getInfo(@PathVariable("id") Long id)
+    {
+        return ResultData.success(slUserRelationService.selectSlUserRelationById(id));
+    }
+
+    /**
+     * 新增人员关联
+     */
+    @ApiOperation(value = "新增人员关联")
+    @PreAuthorize(hasPermi = "laboratory:relation:add")
+    @Log(title = "人员关联", businessType = BusinessType.INSERT)
+    @PostMapping
+    public ResultData add(@RequestBody SlUserRelation slUserRelation)
+    {
+        return ResultData.result(slUserRelationService.insertSlUserRelation(slUserRelation));
+    }
+
+    /**
+     * 修改人员关联
+     */
+    @ApiOperation(value = "修改人员关联")
+    @PreAuthorize(hasPermi = "laboratory:relation:edit")
+    @Log(title = "人员关联", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public ResultData edit(@RequestBody SlUserRelation slUserRelation)
+    {
+        return  ResultData.result(slUserRelationService.updateSlUserRelation(slUserRelation));
+    }
+
+    /**
+     * 删除人员关联
+     */
+    @ApiOperation(value = "删除人员关联")
+    @PreAuthorize(hasPermi = "laboratory:relation:remove")
+    @Log(title = "人员关联", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public ResultData remove(@PathVariable Long[] ids)
+    {
+        return ResultData.result(slUserRelationService.deleteSlUserRelationByIds(ids));
+    }
+
+    /**
+     * 查询智能锁人员列表
+     */
+    //@PreAuthorize(hasPermi = "laboratory:relation:list")
+    @GetMapping("/listLockUser")
+    @ApiOperation(value = "查询智能锁人员列表")
+    public TableDataInfo<SlUser> listLockUser(SlUser sluser)
+    {
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        System.out.println(sysUser.getNickName());
+        //List<SlUserRelation> list = slUserRelationService.selectSlUserRelationList(slUserRelation);
+        List<SlUser> list = SmartlockUtil.getUser(sluser);
+        return getDataTable(list);
+    }
+}

+ 70 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/BaseDomain.java

@@ -0,0 +1,70 @@
+package com.zd.smartlock.domain;
+
+import java.io.Serializable;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/08/30/16:33
+ * @Description:
+ */
+public class BaseDomain implements Serializable {
+
+    /**
+     * 每一页显示数量
+     */
+    public  String  pageSize;
+
+    /**
+     * 页码
+     */
+    public  String  pageNumber;
+
+    /**
+     * 总数
+     */
+    public Integer total;
+
+    /**
+     * token
+     */
+    public String token;
+
+    /**
+     * 搜索条件
+     */
+    public  String  search;
+
+    public String getPageSize() {
+        return pageSize= pageSize==null || "".equals(pageSize)?"20":pageSize;
+    }
+
+    public void setPageSize(String pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public String getPageNumber() {
+        return pageNumber =  "".equals(pageNumber) || pageNumber==null?"1":pageNumber;
+    }
+
+    public void setPageNumber(String pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public Integer getTotal() {        return total;    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public String getSearch() {        return search;    }
+
+    public void setSearch(String search) {        this.search = search;    }
+}

+ 99 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlApplyApproval.java

@@ -0,0 +1,99 @@
+package com.zd.smartlock.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.common.core.annotation.Excel;
+import com.zd.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * 人员关联对象 sl_user_relation
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@ApiModel("人员关联")
+public class SlApplyApproval extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+    /** 申请表主键 */
+    @Excel(name = "申请表主键")
+    @ApiModelProperty(value = "申请表主键")
+    private Long applyId;
+    /** 审核人id */
+    @Excel(name = "审核人id")
+    @ApiModelProperty(value = "审核人id")
+    private Long approvaId;
+    /** 审核人姓名 */
+    @Excel(name = "审核人姓名")
+    @Length(message = "审核人姓名长度不能超过50")
+    @ApiModelProperty(value = "审核人姓名")
+    private String approvaName;
+    /** 1通过 2驳回 */
+    @Excel(name = "1通过 2驳回")
+    @ApiModelProperty(value = "1通过 2驳回")
+    private Long approvaStatus;
+    /** $column.columnComment */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "1通过 2驳回", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "1通过 2驳回")
+    private Date cretaTime;
+
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getApplyId() {
+        return applyId;
+    }
+
+    public void setApplyId(Long applyId) {
+        this.applyId = applyId;
+    }
+
+    public Long getApprovaId() {
+        return approvaId;
+    }
+
+    public void setApprovaId(Long approvaId) {
+        this.approvaId = approvaId;
+    }
+
+    public String getApprovaName() {
+        return approvaName;
+    }
+
+    public void setApprovaName(String approvaName) {
+        this.approvaName = approvaName;
+    }
+
+    public Long getApprovaStatus() {
+        return approvaStatus;
+    }
+
+    public void setApprovaStatus(Long approvaStatus) {
+        this.approvaStatus = approvaStatus;
+    }
+
+    public Date getCretaTime() {
+        return cretaTime;
+    }
+
+    public void setCretaTime(Date cretaTime) {
+        this.cretaTime = cretaTime;
+    }
+
+}

+ 263 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlOpendoorApply.java

@@ -0,0 +1,263 @@
+package com.zd.smartlock.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.common.core.annotation.Excel;
+import com.zd.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * 申请开门对象 sl_opendoor_apply
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@ApiModel("申请开门")
+public class SlOpendoorApply extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+    /** 申请姓名 */
+    @Excel(name = "申请姓名")
+    @Length(message = "申请姓名长度不能超过50")
+    @ApiModelProperty(value = "申请姓名")
+    private String userName;
+    /** 人员2 id */
+    @Excel(name = "人员2 id")
+    @ApiModelProperty(value = "人员2 id")
+    private Long userId2;
+    /** $column.columnComment */
+    @Excel(name = "人员2 id")
+    @Length(message = "人员2 id长度不能超过50")
+    @ApiModelProperty(value = "人员2 id")
+    private String userName2;
+    /** 实验室id  */
+    @Excel(name = "实验室id ")
+    @ApiModelProperty(value = "实验室id ")
+    private Long subjectId;
+    /** 实验室名称  */
+    @Excel(name = "实验室名称 ")
+    @Length(message = "实验室名称 长度不能超过50")
+    @ApiModelProperty(value = "实验室名称 ")
+    private String subjectName;
+    /** 位置 */
+    @Excel(name = "位置")
+    @Length(message = "位置长度不能超过255")
+    @ApiModelProperty(value = "位置")
+    private String position;
+    /** 学院 */
+    @Excel(name = "学院")
+    @Length(message = "学院长度不能超过255")
+    @ApiModelProperty(value = "学院")
+    private String college;
+    /** 1审核中 2 通过 3驳回 */
+    @Excel(name = "1审核中 2 通过 3驳回")
+    @ApiModelProperty(value = "1审核中 2 通过 3驳回")
+    private Long applyStatus;
+
+    /** 审核次数 */
+    @Excel(name = "审核次数")
+    @ApiModelProperty(value = "审核次数")
+    private Long applyNumber;
+
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建时间")
+    private Date creatTime;
+
+
+    /** 人员1编号*/
+    @Excel(name = "人员1编号")
+    @ApiModelProperty(value = "人员1编号")
+    private String userCode;
+
+    /** 人员2编号*/
+    @Excel(name = "人员2编号")
+    @ApiModelProperty(value = "人员2编号")
+    private String userCode2;
+
+    /** 人员1性别*/
+    @Excel(name = "人员1性别")
+    @ApiModelProperty(value = "人员1性别")
+    private Integer userSex;
+
+    /** 人员2性别*/
+    @Excel(name = "人员2性别")
+    @ApiModelProperty(value = "人员2性别")
+    private Integer userSex2;
+
+    /** 人员1电话*/
+    @Excel(name = "人员1电话")
+    @ApiModelProperty(value = "人员1电话")
+    private String phonenumber;
+
+    /** 人员2电话*/
+    @Excel(name = "人员2电话")
+    @ApiModelProperty(value = "人员2电话")
+    private String phonenumber2;
+
+    /** 说明*/
+    @Excel(name = "说明")
+    @ApiModelProperty(value = "说明")
+    private String illustrate;
+
+    /** 审核完成时间 */
+    @Excel(name = "审核完成时间 ")
+    @ApiModelProperty(value = "审核完成时间 ")
+    private Date applyTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public Long getUserId2() {
+        return userId2;
+    }
+
+    public void setUserId2(Long userId2) {
+        this.userId2 = userId2;
+    }
+
+    public String getUserName2() {
+        return userName2;
+    }
+
+    public void setUserName2(String userName2) {
+        this.userName2 = userName2;
+    }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public String getPosition() {
+        return position;
+    }
+
+    public void setPosition(String position) {
+        this.position = position;
+    }
+
+    public String getCollege() {
+        return college;
+    }
+
+    public void setCollege(String college) {
+        this.college = college;
+    }
+
+    public Long getApplyStatus() {
+        return applyStatus;
+    }
+
+    public void setApplyStatus(Long applyStatus) {
+        this.applyStatus = applyStatus;
+    }
+
+    public Date getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(Date creatTime) {
+        this.creatTime = creatTime;
+    }
+
+    public Long getApplyNumber() {
+        return applyNumber;
+    }
+
+    public void setApplyNumber(Long applyNumber) {
+        this.applyNumber = applyNumber;
+    }
+
+    public String getUserCode() {
+        return userCode;
+    }
+
+    public void setUserCode(String userCode) {
+        this.userCode = userCode;
+    }
+
+    public String getUserCode2() {
+        return userCode2;
+    }
+
+    public void setUserCode2(String userCode2) {
+        this.userCode2 = userCode2;
+    }
+
+    public Integer getUserSex() {
+        return userSex;
+    }
+
+    public void setUserSex(Integer userSex) {
+        this.userSex = userSex;
+    }
+
+    public Integer getUserSex2() {
+        return userSex2;
+    }
+
+    public void setUserSex2(Integer userSex2) {
+        this.userSex2 = userSex2;
+    }
+
+    public String getIllustrate() {
+        return illustrate;
+    }
+
+    public void setIllustrate(String illustrate) {
+        this.illustrate = illustrate;
+    }
+
+    public String getPhonenumber() {        return phonenumber;    }
+
+    public void setPhonenumber(String phonenumber) {        this.phonenumber = phonenumber;    }
+
+    public String getPhonenumber2() {
+        return phonenumber2;
+    }
+
+    public void setPhonenumber2(String phonenumber2) {
+        this.phonenumber2 = phonenumber2;
+    }
+
+    public Date getApplyTime() {
+        return applyTime;
+    }
+
+    public void setApplyTime(Date applyTime) {
+        this.applyTime = applyTime;
+    }
+}

+ 145 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlSubjectRelation.java

@@ -0,0 +1,145 @@
+package com.zd.smartlock.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.common.core.annotation.Excel;
+import com.zd.common.core.web.domain.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Length;
+
+import java.util.Date;
+
+/**
+ * 实验室关联对象 sl_subject_relation
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@ApiModel("实验室关联")
+public class SlSubjectRelation extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+    /** 实验室id */
+    @Excel(name = "实验室id")
+    @ApiModelProperty(value = "实验室id")
+    private Long subjectId;
+    /** 实验室名称 */
+    @Excel(name = "实验室名称")
+    @Length(message = "实验室名称长度不能超过50")
+    @ApiModelProperty(value = "实验室名称")
+    private String subjectName;
+    /** 房间id */
+    @Excel(name = "房间id")
+    @Length(message = "房间id长度不能超过255")
+    @ApiModelProperty(value = "房间id")
+    private String lockRoomId;
+    /** 门锁编号 */
+    @Excel(name = "门锁编号")
+    @Length(message = "门锁编号长度不能超过255")
+    @ApiModelProperty(value = "门锁编号")
+    private String lockCode;
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建时间")
+    private Date creatTime;
+    /** 房间位置 */
+    @Excel(name = "房间位置")
+    @Length(message = "房间位置长度不能超过255")
+    @ApiModelProperty(value = "房间位置")
+    private String roomLocation;
+
+    /** 房间名称 */
+    @Excel(name = "房间名称")
+    @Length(message = "房间名称长度不能超过255")
+    @ApiModelProperty(value = "房间名称")
+    private String roomName;
+
+    private Long deptId;
+
+    private String deptName;
+
+    private Long userId;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public String getLockRoomId() {
+        return lockRoomId;
+    }
+
+    public void setLockRoomId(String lockRoomId) {
+        this.lockRoomId = lockRoomId;
+    }
+
+    public String getLockCode() {
+        return lockCode;
+    }
+
+    public void setLockCode(String lockCode) {
+        this.lockCode = lockCode;
+    }
+
+    public Date getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(Date creatTime) {
+        this.creatTime = creatTime;
+    }
+
+    @Override
+    public String getDeptName() {
+        return deptName;
+    }
+
+    @Override
+    public void setDeptName(String deptName) {
+        this.deptName = deptName;
+    }
+
+    public String getRoomLocation() {        return roomLocation;    }
+
+    public void setRoomLocation(String roomLocation) {        this.roomLocation = roomLocation;    }
+
+    public String getRoomName() {        return roomName;    }
+
+    public void setRoomName(String roomName) {        this.roomName = roomName;    }
+
+    @Override
+    public Long getDeptId() {        return deptId;    }
+
+    @Override
+    public void setDeptId(Long deptId) {        this.deptId = deptId;    }
+
+    @Override
+    public Long getUserId() {        return userId;    }
+
+    @Override
+    public void setUserId(Long userId) {        this.userId = userId;    }
+}

+ 89 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlUserRelation.java

@@ -0,0 +1,89 @@
+package com.zd.smartlock.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Length;
+import com.zd.common.core.web.domain.BaseEntity;
+
+/**
+ * 人员关联对象 sl_user_relation
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@ApiModel("人员关联")
+public class SlUserRelation extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+    /** 用户姓名 */
+    @Excel(name = "用户姓名")
+    @Length(message = "用户姓名长度不能超过50")
+    @ApiModelProperty(value = "用户姓名")
+    private String userName;
+    /** 门锁服务人员编号 */
+    @Excel(name = "门锁服务人员编号")
+    @Length(message = "门锁服务人员编号长度不能超过50")
+    @ApiModelProperty(value = "门锁服务人员编号")
+    private String lockUserCode;
+    /** $column.columnComment */
+    @Excel(name = "门锁服务人员编号")
+    @ApiModelProperty(value = "门锁服务人员编号")
+    private Long type;
+    /** 创建时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建时间")
+    private Date creatTime;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getLockUserCode() {
+        return lockUserCode;
+    }
+
+    public void setLockUserCode(String lockUserCode) {
+        this.lockUserCode = lockUserCode;
+    }
+
+    public Long getType() {
+        return type;
+    }
+
+    public void setType(Long type) {
+        this.type = type;
+    }
+
+    public Date getCreatTime() {
+        return creatTime;
+    }
+
+    public void setCreatTime(Date creatTime) {
+        this.creatTime = creatTime;
+    }
+}

+ 104 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlBuild.java

@@ -0,0 +1,104 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/08/29/14:29
+ * @Description:
+ */
+@ApiModel("建筑查询实体")
+public class SlBuild extends BaseDomain {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "建筑编号")
+    private String buildcode;
+
+    @ApiModelProperty(value = "父级建筑id")
+    private String buildfatherid;
+
+    @ApiModelProperty(value = "建筑id")
+    private Integer buildid;
+
+    @ApiModelProperty(value = "建筑名称")
+    private String buildname;
+
+    @ApiModelProperty(value = "建筑类型,1园区,2楼栋,3楼层,4房间,5楼梯,6装饰间,7门禁")
+    private String buildtype;
+
+    @ApiModelProperty(value = "建筑类型,1园区,2楼栋,3楼层,4房间,5楼梯,6装饰间,7门禁")
+    private String  buildtypename;
+
+    @ApiModelProperty(value = "区域房间类型,1宿舍区域,2公共区域,3随房间属性")
+    private String roomtype;
+
+    @ApiModelProperty(value = "区域房间类型,1宿舍区域,2公共区域,3随房间属性")
+    private String roomtypename;
+
+
+    public String getBuildcode() {
+        return buildcode;
+    }
+
+    public void setBuildcode(String buildcode) {
+        this.buildcode = buildcode;
+    }
+
+    public String getBuildfatherid() {
+        return buildfatherid;
+    }
+
+    public void setBuildfatherid(String buildfatherid) {
+        this.buildfatherid = buildfatherid;
+    }
+
+    public Integer getBuildid() {
+        return buildid;
+    }
+
+    public void setBuildid(Integer buildid) {
+        this.buildid = buildid;
+    }
+
+    public String getBuildname() {
+        return buildname;
+    }
+
+    public void setBuildname(String buildname) {
+        this.buildname = buildname;
+    }
+
+    public String getBuildtype() {
+        return buildtype;
+    }
+
+    public void setBuildtype(String buildtype) {
+        this.buildtype = buildtype;
+    }
+
+    public String getBuildtypename() {
+        return buildtypename;
+    }
+
+    public void setBuildtypename(String buildtypename) {
+        this.buildtypename = buildtypename;
+    }
+
+    public String getRoomtype() {
+        return roomtype;
+    }
+
+    public void setRoomtype(String roomtype) {
+        this.roomtype = roomtype;
+    }
+
+    public String getRoomtypename() {
+        return roomtypename;
+    }
+
+    public void setRoomtypename(String roomtypename) {
+        this.roomtypename = roomtypename;
+    }
+}

+ 84 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlDoorLock.java

@@ -0,0 +1,84 @@
+package com.zd.smartlock.domain.api;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/08/29/14:48
+ * @Description:
+ */
+@ApiModel("门锁中间表")
+public class SlDoorLock {
+
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @ApiModelProperty(value = "人员id")
+    private Long userId;
+
+    @ApiModelProperty(value = "人员姓名")
+    private String userName;
+
+    @ApiModelProperty(value = "人员卡号")
+    private String cardNum;
+
+    @ApiModelProperty(value = "实验室id")
+    private Long subjectId;
+
+    @ApiModelProperty(value = "实验室名称")
+    private String subjectName;
+
+    @ApiModelProperty(value = "部门id")
+    private Long deptId;
+
+    @ApiModelProperty(value = "部门名称")
+    private String deptName;
+
+    @ApiModelProperty(value = "门锁id")
+    private String doorLockid;
+
+    @ApiModelProperty(value = "人脸编号")
+    private String faceCode;
+
+    @ApiModelProperty(value = "人脸状态(1正常,0停用)")
+    private Long faceState;
+
+    @ApiModelProperty(value = "手指 1-10")
+    private Long finger;
+
+    @ApiModelProperty(value = "指纹编号")
+    private String fingerCode;
+
+    @ApiModelProperty(value = "指纹状态(1正常,0停用)")
+    private Long fingerState;
+
+    @ApiModelProperty(value = "卡片状态(1正常,0停用)")
+    private Long cardState;
+
+    @ApiModelProperty(value = "开始时间")
+    private Date cardBegintime;
+
+    @ApiModelProperty(value = "结束时间")
+    private Date cardEndtime;
+
+    @ApiModelProperty(value = "1人脸  2指纹 3门卡")
+    private Long dataType;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "修改人")
+    private String updateBy;
+
+    @ApiModelProperty(value = "创建人")
+    private String cereatBy;
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+}

+ 58 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlGroup.java

@@ -0,0 +1,58 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/05/15:36
+ * @Description:
+ */
+@ApiModel("组织信息")
+public class SlGroup extends BaseDomain {
+
+    @ApiModelProperty(value = "组织编号")
+    private String pgcode;
+
+    @ApiModelProperty(value = "父级组织id")
+    private String pgfatherid;
+
+    @ApiModelProperty(value = "父级组织id")
+    private String pgid;
+
+    @ApiModelProperty(value = "组织名称")
+    private String pgname;
+
+    public String getPgcode() {
+        return pgcode;
+    }
+
+    public void setPgcode(String pgcode) {
+        this.pgcode = pgcode;
+    }
+
+    public String getPgfatherid() {
+        return pgfatherid;
+    }
+
+    public void setPgfatherid(String pgfatherid) {
+        this.pgfatherid = pgfatherid;
+    }
+
+    public String getPgid() {
+        return pgid;
+    }
+
+    public void setPgid(String pgid) {
+        this.pgid = pgid;
+    }
+
+    public String getPgname() {
+        return pgname;
+    }
+
+    public void setPgname(String pgname) {
+        this.pgname = pgname;
+    }
+}

+ 35 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlLockOnline.java

@@ -0,0 +1,35 @@
+package com.zd.smartlock.domain.api;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/05/14:30
+ * @Description:
+ */
+@ApiModel("门锁状态")
+public class SlLockOnline {
+
+    @ApiModelProperty(value = "是否在线")
+    private String onLine;
+
+    @ApiModelProperty(value = "门锁编号")
+    private String lockCode;
+
+    public String getOnLine() {
+        return onLine;
+    }
+
+    public void setOnLine(String onLine) {
+        this.onLine = onLine;
+    }
+
+    public String getLockCode() {
+        return lockCode;
+    }
+
+    public void setLockCode(String lockCode) {
+        this.lockCode = lockCode;
+    }
+}

+ 80 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlOpenAndClosLog.java

@@ -0,0 +1,80 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/03/14:50
+ * @Description:
+ */
+@ApiModel("开关门记录")
+public class SlOpenAndClosLog extends BaseDomain {
+
+    @ApiModelProperty(value = "卡号/指纹号/人脸号/二维码编号")
+    private String cardcode;
+
+    @ApiModelProperty(value = "学/工号")
+    private String personcode;
+
+    @ApiModelProperty(value = "组织")
+    private String personlocation;
+
+    @ApiModelProperty(value = "姓名")
+    private String personname;
+
+    @ApiModelProperty(value = "开门日期")
+    private String unlockingdate;
+
+    @ApiModelProperty(value = "开门方式")
+    private String unlockingtype;
+
+    public String getCardcode() {
+        return cardcode;
+    }
+
+    public void setCardcode(String cardcode) {
+        this.cardcode = cardcode;
+    }
+
+    public String getPersoncode() {
+        return personcode;
+    }
+
+    public void setPersoncode(String personcode) {
+        this.personcode = personcode;
+    }
+
+    public String getPersonlocation() {
+        return personlocation;
+    }
+
+    public void setPersonlocation(String personlocation) {
+        this.personlocation = personlocation;
+    }
+
+    public String getPersonname() {
+        return personname;
+    }
+
+    public void setPersonname(String personname) {
+        this.personname = personname;
+    }
+
+    public String getUnlockingdate() {
+        return unlockingdate;
+    }
+
+    public void setUnlockingdate(String unlockingdate) {
+        this.unlockingdate = unlockingdate;
+    }
+
+    public String getUnlockingtype() {
+        return unlockingtype;
+    }
+
+    public void setUnlockingtype(String unlockingtype) {
+        this.unlockingtype = unlockingtype;
+    }
+}

+ 82 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlOpenDoorSearch.java

@@ -0,0 +1,82 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/03/15:04
+ * @Description:
+ */
+@ApiModel("开关门记录查询条件")
+public class SlOpenDoorSearch extends BaseDomain {
+
+    @ApiModelProperty(value = "房间id")
+    private String roomid;
+
+    @ApiModelProperty(value = "结束日期")
+    private String edate;
+
+    @ApiModelProperty(value = "类型(0或空=所有记录,1=报警记录,2=开门记录)")
+    private String recordtype;
+
+    @ApiModelProperty(value = "起始日期")
+    private String sdate;
+
+    @ApiModelProperty(value = "根据人员姓名/人员编号/卡号/指纹编号/人脸编号/二维码编号检索")
+    private String search;
+
+    @ApiModelProperty(value = "操作类型 (0或空=所有记录,1=报警记录,2=开门记录)")
+    private String unlockingtype;
+
+    public String getRoomid() {
+        return roomid;
+    }
+
+    public void setRoomid(String roomid) {
+        this.roomid = roomid;
+    }
+
+    public String getEdate() {
+        return edate;
+    }
+
+    public void setEdate(String edate) {
+        this.edate = edate;
+    }
+
+    public String getRecordtype() {
+        return recordtype;
+    }
+
+    public void setRecordtype(String recordtype) {
+        this.recordtype = recordtype;
+    }
+
+    public String getSdate() {
+        return sdate;
+    }
+
+    public void setSdate(String sdate) {
+        this.sdate = sdate;
+    }
+
+    @Override
+    public String getSearch() {
+        return search;
+    }
+
+    @Override
+    public void setSearch(String search) {
+        this.search = search;
+    }
+
+    public String getUnlockingtype() {
+        return unlockingtype;
+    }
+
+    public void setUnlockingtype(String unlockingtype) {
+        this.unlockingtype = unlockingtype;
+    }
+}

+ 123 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlPostUser.java

@@ -0,0 +1,123 @@
+package com.zd.smartlock.domain.api;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/05/16:01
+ * @Description:
+ */
+@ApiModel("添加人员信息")
+public class SlPostUser {
+
+    @ApiModelProperty(value = "卡号")
+    private String cardcode;
+
+    @ApiModelProperty(value = "是否下发人脸(1是,0否)")
+    private String issendface;
+
+    @ApiModelProperty(value = "是否下发指纹(1是,0否)")
+    private String issendfinger;
+
+    @ApiModelProperty(value = "是否下发密码(1是,0否)")
+    private String issendpass;
+
+    @ApiModelProperty(value = "权限类型(1管理权限,0使用权限,管理权限不占用入住人数)")
+    private Integer managertype;
+
+    @ApiModelProperty(value = "6位数字密码(不允许连续数字或连续三个及以上相同数字)")
+    private String password;
+
+    @ApiModelProperty(value = "学号")
+    private String personcode;
+
+    @ApiModelProperty(value = "房间id")
+    private String roomid;
+
+    @ApiModelProperty(value = "授权开始日期")
+    private String empsdate;
+
+    @ApiModelProperty(value = "授权结束日期")
+    private String empedate;
+
+    public String getCardcode() {
+        return cardcode;
+    }
+
+    public void setCardcode(String cardcode) {
+        this.cardcode = cardcode;
+    }
+
+    public String getIssendface() {
+        return issendface;
+    }
+
+    public void setIssendface(String issendface) {
+        this.issendface = issendface;
+    }
+
+    public String getIssendfinger() {
+        return issendfinger;
+    }
+
+    public void setIssendfinger(String issendfinger) {
+        this.issendfinger = issendfinger;
+    }
+
+    public String getIssendpass() {
+        return issendpass;
+    }
+
+    public void setIssendpass(String issendpass) {
+        this.issendpass = issendpass;
+    }
+
+    public Integer getManagertype() {
+        return managertype;
+    }
+
+    public void setManagertype(Integer managertype) {
+        this.managertype = managertype;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getPersoncode() {
+        return personcode;
+    }
+
+    public void setPersoncode(String personcode) {
+        this.personcode = personcode;
+    }
+
+    public String getRoomid() {
+        return roomid;
+    }
+
+    public void setRoomid(String roomid) {
+        this.roomid = roomid;
+    }
+
+    public String getEmpsdate() {
+        return empsdate;
+    }
+
+    public void setEmpsdate(String empsdate) {
+        this.empsdate = empsdate;
+    }
+
+    public String getEmpedate() {
+        return empedate;
+    }
+
+    public void setEmpedate(String empedate) {
+        this.empedate = empedate;
+    }
+}

+ 157 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlRoom.java

@@ -0,0 +1,157 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/08/30/10:42
+ * @Description:
+ */
+@ApiModel("房间信息")
+public class SlRoom extends BaseDomain {
+    @ApiModelProperty(value = "归属楼层建筑ID")
+    private String buildid;
+
+    @ApiModelProperty(value = "房间预约功能(-1不支持,0关闭,1打开)")
+    private Integer isbook;
+
+    @ApiModelProperty(value = "房间位置(1左侧2右侧)")
+    private Integer leftright;
+
+    @ApiModelProperty(value = "房间编号")
+    private String roomcode;
+
+    @ApiModelProperty(value = "门锁唯一ID")
+    private String roomcode2;
+
+    @ApiModelProperty(value = "房间id")
+    private Integer roomid;
+
+    @ApiModelProperty(value = "房间位置")
+    private String roomlocation;
+
+    @ApiModelProperty(value = "房间最大支持入住人数")
+    private  Integer roommaxperson;
+
+    @ApiModelProperty(value = "房间名称")
+    private  String roomname;
+
+    @ApiModelProperty(value = "公共房间类型(1教室,2办公室,3会议室,4实验室)")
+    private  Integer roomnexttype;
+
+    @ApiModelProperty(value = "房间类型(1宿舍,2公共房间,4酒店房间)")
+    private  Integer roomtype;
+
+    @ApiModelProperty(value = "房间类型2(1房间,2楼梯,3装饰房间)")
+    private  Integer roomtype2;
+
+    @ApiModelProperty(value = "排列顺序(从左到右由小到大排列)")
+    private  Integer sequence;
+
+
+    public String getBuildid() {
+        return buildid;
+    }
+
+    public void setBuildid(String buildid) {
+        this.buildid = buildid;
+    }
+
+    public Integer getIsbook() {
+        return isbook;
+    }
+
+    public void setIsbook(Integer isbook) {
+        this.isbook = isbook;
+    }
+
+    public Integer getLeftright() {
+        return leftright;
+    }
+
+    public void setLeftright(Integer leftright) {
+        this.leftright = leftright;
+    }
+
+    public String getRoomcode() {
+        return roomcode;
+    }
+
+    public void setRoomcode(String roomcode) {
+        this.roomcode = roomcode;
+    }
+
+    public String getRoomcode2() {
+        return roomcode2;
+    }
+
+    public void setRoomcode2(String roomcode2) {
+        this.roomcode2 = roomcode2;
+    }
+
+    public Integer getRoomid() {
+        return roomid;
+    }
+
+    public void setRoomid(Integer roomid) {
+        this.roomid = roomid;
+    }
+
+    public String getRoomlocation() {
+        return roomlocation;
+    }
+
+    public void setRoomlocation(String roomlocation) {
+        this.roomlocation = roomlocation;
+    }
+
+    public Integer getRoommaxperson() {
+        return roommaxperson;
+    }
+
+    public void setRoommaxperson(Integer roommaxperson) {
+        this.roommaxperson = roommaxperson;
+    }
+
+    public String getRoomname() {
+        return roomname;
+    }
+
+    public void setRoomname(String roomname) {
+        this.roomname = roomname;
+    }
+
+    public Integer getRoomnexttype() {
+        return roomnexttype;
+    }
+
+    public void setRoomnexttype(Integer roomnexttype) {
+        this.roomnexttype = roomnexttype;
+    }
+
+    public Integer getRoomtype() {
+        return roomtype;
+    }
+
+    public void setRoomtype(Integer roomtype) {
+        this.roomtype = roomtype;
+    }
+
+    public Integer getRoomtype2() {
+        return roomtype2;
+    }
+
+    public void setRoomtype2(Integer roomtype2) {
+        this.roomtype2 = roomtype2;
+    }
+
+    public Integer getSequence() {
+        return sequence;
+    }
+
+    public void setSequence(Integer sequence) {
+        this.sequence = sequence;
+    }
+}

+ 74 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlUser.java

@@ -0,0 +1,74 @@
+package com.zd.smartlock.domain.api;
+
+import com.zd.smartlock.domain.BaseDomain;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/03/13:37
+ * @Description:
+ */
+@ApiModel("查询人员信息")
+public class SlUser extends BaseDomain {
+
+    @ApiModelProperty(value = "身份证")
+    private String  personcard;
+
+    @ApiModelProperty(value = "学/工号")
+    private String personcode;
+
+    @ApiModelProperty(value = "手机号")
+    private String personmobile;
+
+    @ApiModelProperty(value = "姓名")
+    private String personname;
+
+    @ApiModelProperty(value = "性别")
+    private String personsex;
+
+    @ApiModelProperty(value = "人员类别(1=学生,2=教职工,3=临时人员)")
+    private String persontype;
+
+    public String getPersoncard() {
+        return personcard;
+    }
+
+    public void setPersoncard(String personcard) {
+        this.personcard = personcard;
+    }
+
+    public String getPersoncode() {
+        return personcode;
+    }
+
+    public void setPersoncode(String personcode) {
+        this.personcode = personcode;
+    }
+
+    public String getPersonmobile() {
+        return personmobile;
+    }
+
+    public void setPersonmobile(String personmobile) {
+        this.personmobile = personmobile;
+    }
+
+    public String getPersonname() {
+        return personname;
+    }
+
+    public void setPersonname(String personname) {
+        this.personname = personname;
+    }
+
+    public String getPersonsex() {        return personsex;    }
+
+    public void setPersonsex(String personsex) {        this.personsex = personsex;    }
+
+    public String getPersontype() {        return persontype;    }
+
+    public void setPersontype(String persontype) {
+        this.persontype = persontype;
+    }
+}

+ 32 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlupdateAuths.java

@@ -0,0 +1,32 @@
+package com.zd.smartlock.domain.api;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/06/19:18
+ * @Description:
+ */
+public class SlupdateAuths {
+
+    @ApiModelProperty(value = "授权id")
+    private Integer authid;
+    @ApiModelProperty(value = "授权类型(1卡片,2指纹,3密码,4蓝牙)")
+    private Integer rctype;
+
+    public Integer getAuthid() {
+        return authid;
+    }
+
+    public void setAuthid(Integer authid) {
+        this.authid = authid;
+    }
+
+    public Integer getRctype() {
+        return rctype;
+    }
+
+    public void setRctype(Integer rctype) {
+        this.rctype = rctype;
+    }
+}

+ 35 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlOpendoorApplyVo.java

@@ -0,0 +1,35 @@
+package com.zd.smartlock.domain.vo;
+
+import com.zd.smartlock.domain.SlOpendoorApply;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/06/15:01
+ * @Description:
+ */
+public class SlOpendoorApplyVo extends SlOpendoorApply {
+
+    @ApiModelProperty(value = "实验室安全负责人集合")
+    private String safeUserId;
+
+    @ApiModelProperty(value = "是否安全负责人")
+    private Boolean safe;
+
+
+    public String getSafeUserId() {
+        return safeUserId;
+    }
+
+    public void setSafeUserId(String safeUserId) {
+        this.safeUserId = safeUserId;
+    }
+
+    public Boolean getSafe() {
+        return safe;
+    }
+
+    public void setSafe(Boolean safe) {
+        this.safe = safe;
+    }
+}

+ 21 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlSubjectRelationVo.java

@@ -0,0 +1,21 @@
+package com.zd.smartlock.domain.vo;
+
+import com.zd.smartlock.domain.SlSubjectRelation;
+
+import java.util.List;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/05/11:05
+ * @Description:
+ */
+public class SlSubjectRelationVo extends SlSubjectRelation {
+
+    private List<SlSubjectRelation> slSubjectList;
+
+
+
+    public List<SlSubjectRelation> getSlSubjectList() {        return slSubjectList;    }
+
+    public void setSlSubjectList(List<SlSubjectRelation> slSubjectList) {        this.slSubjectList = slSubjectList;    }
+}

+ 69 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlApplyApprovalMapper.java

@@ -0,0 +1,69 @@
+package com.zd.smartlock.mapper;
+
+import com.zd.smartlock.domain.SlApplyApproval;
+
+import java.util.List;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/02/18:10
+ * @Description:
+ */
+public interface SlApplyApprovalMapper {
+
+    /**
+     * 查询申请审核
+     *
+     * @param id 申请审核主键
+     * @return 申请审核
+     */
+    SlApplyApproval selectSlApplyApprovalById(Long id);
+
+    /**
+     * 查询申请审核列表
+     *
+     * @param slApplyApproval 申请审核
+     * @return 申请审核集合
+     */
+    List<SlApplyApproval> selectSlApplyApprovalList(SlApplyApproval slApplyApproval);
+
+    /**
+     * 根据主键集合查询申请审核列表
+     *
+     * @param ids 主键集合
+     * @return 申请审核集合
+     */
+    List<SlApplyApproval> getListByIds(List<Long> ids);
+
+    /**
+     * 新增申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    int insertSlApplyApproval(SlApplyApproval slApplyApproval);
+
+    /**
+     * 修改申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    int updateSlApplyApproval(SlApplyApproval slApplyApproval);
+
+    /**
+     * 删除申请审核
+     *
+     * @param id 申请审核主键
+     * @return 结果
+     */
+    int deleteSlApplyApprovalById(Long id);
+
+    /**
+     * 批量删除申请审核
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteSlApplyApprovalByIds(Long[] ids);
+}

+ 72 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlOpendoorApplyMapper.java

@@ -0,0 +1,72 @@
+package com.zd.smartlock.mapper;
+
+import com.zd.smartlock.domain.SlOpendoorApply;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.vo.SlOpendoorApplyVo;
+
+import java.util.List;
+
+/**
+ * 申请开门Mapper接口
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+public interface SlOpendoorApplyMapper
+{
+    /**
+     * 查询申请开门
+     *
+     * @param id 申请开门主键
+     * @return 申请开门
+     */
+    SlOpendoorApply selectSlOpendoorApplyById(Long id);
+
+    /**
+     * 查询申请开门列表
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 申请开门集合
+     */
+    List<SlOpendoorApplyVo> selectSlOpendoorApplyList(SlOpendoorApplyVo slOpendoorApply);
+
+    /**
+     * 根据主键集合查询申请开门列表
+     *
+     * @param ids 主键集合
+     * @return 申请开门集合
+     */
+    List<SlOpendoorApply> getListByIds(List<Long> ids);
+
+    /**
+     * 新增申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    int insertSlOpendoorApply(SlOpendoorApply slOpendoorApply);
+
+    /**
+     * 修改申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    int updateSlOpendoorApply(SlOpendoorApply slOpendoorApply);
+
+    /**
+     * 删除申请开门
+     *
+     * @param id 申请开门主键
+     * @return 结果
+     */
+    int deleteSlOpendoorApplyById(Long id);
+
+    /**
+     * 批量删除申请开门
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteSlOpendoorApplyByIds(Long[] ids);
+}

+ 68 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlSubjectRelationMapper.java

@@ -0,0 +1,68 @@
+package com.zd.smartlock.mapper;
+
+import com.zd.smartlock.domain.SlSubjectRelation;
+import java.util.List;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/02/18:10
+ * @Description:
+ */
+public interface SlSubjectRelationMapper {
+
+    /**
+     * 查询实验室关联
+     *
+     * @param id 实验室关联主键
+     * @return 实验室关联
+     */
+    SlSubjectRelation selectSlSubjectRelationById(Long id);
+
+    /**
+     * 查询实验室关联列表
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 实验室关联集合
+     */
+    List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation);
+
+    /**
+     * 根据主键集合查询实验室关联列表
+     *
+     * @param ids 主键集合
+     * @return 实验室关联集合
+     */
+    List<SlSubjectRelation> getListByIds(List<Long> ids);
+
+    /**
+     * 新增实验室关联
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 结果
+     */
+    int insertSlSubjectRelation(SlSubjectRelation slSubjectRelation);
+
+    /**
+     * 修改实验室关联
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 结果
+     */
+    int updateSlSubjectRelation(SlSubjectRelation slSubjectRelation);
+
+    /**
+     * 删除实验室关联
+     *
+     * @param id 实验室关联主键
+     * @return 结果
+     */
+    int deleteSlSubjectRelationById(Long id);
+
+    /**
+     * 批量删除实验室关联
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteSlSubjectRelationByIds(Long[] ids);
+}

+ 69 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlUserRelationMapper.java

@@ -0,0 +1,69 @@
+package com.zd.smartlock.mapper;
+
+import com.zd.smartlock.domain.SlUserRelation;
+
+import java.util.List;
+
+/**
+ * @Author: liujh
+ * @Date: 2022/09/02/18:10
+ * @Description:
+ */
+public interface SlUserRelationMapper {
+
+    /**
+     * 查询人员关联
+     *
+     * @param id 人员关联主键
+     * @return 人员关联
+     */
+    SlUserRelation selectSlUserRelationById(Long id);
+
+    /**
+     * 查询人员关联列表
+     *
+     * @param slUserRelation 人员关联
+     * @return 人员关联集合
+     */
+    List<SlUserRelation> selectSlUserRelationList(SlUserRelation slUserRelation);
+
+    /**
+     * 根据主键集合查询人员关联列表
+     *
+     * @param ids 主键集合
+     * @return 人员关联集合
+     */
+    List<SlUserRelation> getListByIds(List<Long> ids);
+
+    /**
+     * 新增人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    int insertSlUserRelation(SlUserRelation slUserRelation);
+
+    /**
+     * 修改人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    int updateSlUserRelation(SlUserRelation slUserRelation);
+
+    /**
+     * 删除人员关联
+     *
+     * @param id 人员关联主键
+     * @return 结果
+     */
+    int deleteSlUserRelationById(Long id);
+
+    /**
+     * 批量删除人员关联
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    int deleteSlUserRelationByIds(Long[] ids);
+}

+ 70 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlApplyApprovalService.java

@@ -0,0 +1,70 @@
+package com.zd.smartlock.service;
+
+import com.zd.smartlock.domain.SlApplyApproval;
+
+import java.util.List;
+
+/**
+ * 申请审核Service接口
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+public interface ISlApplyApprovalService
+{
+    /**
+     * 查询申请审核
+     *
+     * @param id 申请审核主键
+     * @return 申请审核
+     */
+    SlApplyApproval selectSlApplyApprovalById(Long id);
+
+    /**
+     * 查询申请审核列表
+     *
+     * @param slApplyApproval 申请审核
+     * @return 申请审核集合
+     */
+    List<SlApplyApproval> selectSlApplyApprovalList(SlApplyApproval slApplyApproval);
+
+    /**
+     * 根据主键集合查询申请审核列表
+     *
+     * @param ids 主键集合
+     * @return 申请审核集合
+     */
+    List<SlApplyApproval> getListByIds(List<Long> ids);
+
+    /**
+     * 新增申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    int insertSlApplyApproval(SlApplyApproval slApplyApproval);
+
+    /**
+     * 修改申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    int updateSlApplyApproval(SlApplyApproval slApplyApproval);
+
+    /**
+     * 批量删除申请审核
+     *
+     * @param ids 需要删除的申请审核主键集合
+     * @return 结果
+     */
+    int deleteSlApplyApprovalByIds(Long[] ids);
+
+    /**
+     * 删除申请审核信息
+     *
+     * @param id 申请审核主键
+     * @return 结果
+     */
+    int deleteSlApplyApprovalById(Long id);
+}

+ 72 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlOpendoorApplyService.java

@@ -0,0 +1,72 @@
+package com.zd.smartlock.service;
+
+import com.zd.smartlock.domain.SlOpendoorApply;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.vo.SlOpendoorApplyVo;
+
+import java.util.List;
+
+/**
+ * 申请开门Service接口
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+public interface ISlOpendoorApplyService
+{
+    /**
+     * 查询申请开门
+     *
+     * @param id 申请开门主键
+     * @return 申请开门
+     */
+    SlOpendoorApply selectSlOpendoorApplyById(Long id);
+
+    /**
+     * 查询申请开门列表
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 申请开门集合
+     */
+    List<SlOpendoorApplyVo> selectSlOpendoorApplyList(SlOpendoorApplyVo slOpendoorApply);
+
+    /**
+     * 根据主键集合查询申请开门列表
+     *
+     * @param ids 主键集合
+     * @return 申请开门集合
+     */
+    List<SlOpendoorApply> getListByIds(List<Long> ids);
+
+    /**
+     * 新增申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    int insertSlOpendoorApply(SlOpendoorApply slOpendoorApply);
+
+    /**
+     * 修改申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    int updateSlOpendoorApply(SlOpendoorApply slOpendoorApply);
+
+    /**
+     * 批量删除申请开门
+     *
+     * @param ids 需要删除的申请开门主键集合
+     * @return 结果
+     */
+    int deleteSlOpendoorApplyByIds(Long[] ids);
+
+    /**
+     * 删除申请开门信息
+     *
+     * @param id 申请开门主键
+     * @return 结果
+     */
+    int deleteSlOpendoorApplyById(Long id);
+}

+ 71 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlSubjectRelationService.java

@@ -0,0 +1,71 @@
+package com.zd.smartlock.service;
+
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.vo.SlSubjectRelationVo;
+
+import java.util.List;
+
+/**
+ * 实验室关联Service接口
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+public interface ISlSubjectRelationService
+{
+    /**
+     * 查询实验室关联
+     *
+     * @param id 实验室关联主键
+     * @return 实验室关联
+     */
+    SlSubjectRelation selectSlSubjectRelationById(Long id);
+
+    /**
+     * 查询实验室关联列表
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 实验室关联集合
+     */
+    List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation);
+
+    /**
+     * 根据主键集合查询实验室关联列表
+     *
+     * @param ids 主键集合
+     * @return 实验室关联集合
+     */
+    List<SlSubjectRelation> getListByIds(List<Long> ids);
+
+    /**
+     * 新增实验室关联
+     *
+     * @param vo 实验室关联
+     * @return 结果
+     */
+    int insertSlSubjectRelation(SlSubjectRelationVo vo);
+
+    /**
+     * 修改实验室关联
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 结果
+     */
+    int updateSlSubjectRelation(SlSubjectRelation slSubjectRelation);
+
+    /**
+     * 批量删除实验室关联
+     *
+     * @param ids 需要删除的实验室关联主键集合
+     * @return 结果
+     */
+    int deleteSlSubjectRelationByIds(Long[] ids);
+
+    /**
+     * 删除实验室关联信息
+     *
+     * @param id 实验室关联主键
+     * @return 结果
+     */
+    int deleteSlSubjectRelationById(Long id);
+}

+ 69 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlUserRelationService.java

@@ -0,0 +1,69 @@
+package com.zd.smartlock.service;
+
+import java.util.List;
+import com.zd.smartlock.domain.SlUserRelation;
+
+/**
+ * 人员关联Service接口
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+public interface ISlUserRelationService
+{
+    /**
+     * 查询人员关联
+     *
+     * @param id 人员关联主键
+     * @return 人员关联
+     */
+    SlUserRelation selectSlUserRelationById(Long id);
+
+    /**
+     * 查询人员关联列表
+     *
+     * @param slUserRelation 人员关联
+     * @return 人员关联集合
+     */
+    List<SlUserRelation> selectSlUserRelationList(SlUserRelation slUserRelation);
+
+    /**
+     * 根据主键集合查询人员关联列表
+     *
+     * @param ids 主键集合
+     * @return 人员关联集合
+     */
+    List<SlUserRelation> getListByIds(List<Long> ids);
+
+    /**
+     * 新增人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    int insertSlUserRelation(SlUserRelation slUserRelation);
+
+    /**
+     * 修改人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    int updateSlUserRelation(SlUserRelation slUserRelation);
+
+    /**
+     * 批量删除人员关联
+     *
+     * @param ids 需要删除的人员关联主键集合
+     * @return 结果
+     */
+    int deleteSlUserRelationByIds(Long[] ids);
+
+    /**
+     * 删除人员关联信息
+     *
+     * @param id 人员关联主键
+     * @return 结果
+     */
+    int deleteSlUserRelationById(Long id);
+}

+ 231 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlApplyApprovalServiceImpl.java

@@ -0,0 +1,231 @@
+package com.zd.smartlock.service.impl;
+
+import com.zd.common.core.exception.ServiceException;
+import com.zd.common.security.service.TokenService;
+import com.zd.smartlock.domain.SlApplyApproval;
+import com.zd.smartlock.domain.SlOpendoorApply;
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.api.SlUser;
+import com.zd.smartlock.mapper.SlApplyApprovalMapper;
+import com.zd.smartlock.mapper.SlOpendoorApplyMapper;
+import com.zd.smartlock.mapper.SlSubjectRelationMapper;
+import com.zd.smartlock.mapper.SlUserRelationMapper;
+import com.zd.smartlock.service.ISlApplyApprovalService;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.smartlock.utils.SmartlockUtil;
+import com.zd.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+/**
+ * 人员关联Service业务层处理
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@Service
+public class SlApplyApprovalServiceImpl implements ISlApplyApprovalService
+{
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Autowired
+    private SlApplyApprovalMapper slApplyApprovalMapper;
+
+    @Autowired
+    private SlOpendoorApplyMapper slOpendoorApplyMapper;
+
+    @Autowired
+    private SlSubjectRelationMapper slSubjectRelationMapper;
+    /**
+     * 查询申请审核
+     *
+     * @param id 申请审核主键
+     * @return 申请审核
+     */
+    @Override
+    public SlApplyApproval selectSlApplyApprovalById(Long id)
+    {
+        return slApplyApprovalMapper.selectSlApplyApprovalById(id);
+    }
+
+    /**
+     * 查询申请审核列表
+     *
+     * @param slApplyApproval 申请审核
+     * @return 申请审核
+     */
+    @Override
+    public List<SlApplyApproval> selectSlApplyApprovalList(SlApplyApproval slApplyApproval)
+    {
+        return slApplyApprovalMapper.selectSlApplyApprovalList(slApplyApproval);
+    }
+
+    @Override
+    public List<SlApplyApproval> getListByIds(List<Long> ids){
+        if (ids.isEmpty()){
+            new ArrayList<>();
+        }
+        return slApplyApprovalMapper.getListByIds(ids);
+    }
+
+    /**
+     * 新增申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertSlApplyApproval(SlApplyApproval slApplyApproval)
+    {
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        //部门id
+        slApplyApproval.setDeptId(sysUser.getDept().getDeptId());
+        //部门名称
+        slApplyApproval.setDeptName(sysUser.getDept().getDeptName());
+        //审核人id
+        slApplyApproval.setApprovaId(sysUser.getUserId());
+        //审核人姓名
+        slApplyApproval.setApprovaName(sysUser.getNickName());
+        //审核时间
+        slApplyApproval.setCretaTime(new Date());
+
+        //查询申请记录
+        SlOpendoorApply opendoorApply = slOpendoorApplyMapper.selectSlOpendoorApplyById(slApplyApproval.getApplyId());
+
+        if(opendoorApply.getApplyStatus()==3){
+            throw new ServiceException("该记录已驳回,无需审核!");
+        }
+        if(opendoorApply.getApplyNumber()==2){
+            throw new ServiceException("该记录已有两次审核,无需再次审核!");
+        }
+        //通过
+        if(slApplyApproval.getApprovaStatus()==1){
+            opendoorApply.setApplyNumber(opendoorApply.getApplyNumber()+1);
+
+            //审核通过,下发密码(第二次,审核通过的情况下)
+            if(opendoorApply.getApplyNumber()==2){
+                opendoorApply.setApplyTime(new Date());
+                //审核通过后,添加人员并且授权
+                authPower(opendoorApply.getId());
+            }
+        }else if(slApplyApproval.getApprovaStatus()==2){
+            //驳回
+            opendoorApply.setApplyNumber(opendoorApply.getApplyNumber()+1);
+            opendoorApply.setApplyTime(new Date());
+            //修改申请表状态
+            opendoorApply.setApplyStatus(3L);
+        }
+        //申请表操作
+        slOpendoorApplyMapper.updateSlOpendoorApply(opendoorApply);
+        return slApplyApprovalMapper.insertSlApplyApproval(slApplyApproval);
+    }
+
+    /**
+     * 修改申请审核
+     *
+     * @param slApplyApproval 申请审核
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int updateSlApplyApproval(SlApplyApproval slApplyApproval)
+    {
+        return slApplyApprovalMapper.updateSlApplyApproval(slApplyApproval);
+    }
+
+    /**
+     * 批量删除申请审核
+     *
+     * @param ids 需要删除的申请审核主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlApplyApprovalByIds(Long[] ids)
+    {
+        return slApplyApprovalMapper.deleteSlApplyApprovalByIds(ids);
+    }
+
+    /**
+     * 删除申请审核信息
+     *
+     * @param id 申请审核主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlApplyApprovalById(Long id)
+    {
+        return slApplyApprovalMapper.deleteSlApplyApprovalById(id);
+    }
+
+    /***
+     * 审批通过后人员密码授权处理
+     * @param applyId 申请id
+     */
+    public int authPower(Long applyId){
+
+        //查询申请记录
+        SlOpendoorApply opendoorApply = slOpendoorApplyMapper.selectSlOpendoorApplyById(applyId);
+
+        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        subjectRelation.setSubjectId(opendoorApply.getSubjectId());
+        List<SlSubjectRelation>  listsubRla = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+        if(listsubRla.size()!=2){
+            throw  new ServiceException("该实验室暂未绑定双锁!");
+        }
+
+        Map<String,Object> detalisMap = new HashMap<>();
+        SlUser user = new SlUser();
+        //学号、工号
+        user.setPersoncode(opendoorApply.getUserCode());
+        //姓名
+        user.setPersonname(opendoorApply.getUserName());
+        //性别 (0=女,1=男)
+        user.setPersonsex(opendoorApply.getUserSex()==null?1+"":0+"");
+        //人员类别(1=学生,2=教职工,3=临时人员)
+        user.setPersontype("1");
+        Map<String,Object> map1= SmartlockUtil.addUser(user,listsubRla.get(0).getLockRoomId());
+
+        //人员1入住办理成功
+        if(SmartlockUtil.resultMsg.equals(map1.get("resultMsg"))){
+            //发送短信提示
+            String msg="开门申请成功,门锁编号:"+listsubRla.get(0).getLockCode()+"密码:"+map1.get("password");
+        }
+        //人员1 备注详情
+        detalisMap.put("人员1",opendoorApply.getUserName());
+        detalisMap.put("锁编1号",listsubRla.get(0).getLockCode());
+        detalisMap.put("人员1密码",map1.get("password"));
+
+        //学号、工号
+        user.setPersoncode(opendoorApply.getUserCode2());
+        //姓名
+        user.setPersonname(opendoorApply.getUserName2());
+        //性别 (0=女,1=男)
+        user.setPersonsex(opendoorApply.getUserSex2()==null?1+"":0+"");
+        //人员类别(1=学生,2=教职工,3=临时人员)
+        user.setPersontype("1");
+        Map<String,Object> map2= SmartlockUtil.addUser(user,listsubRla.get(1).getLockRoomId());
+
+        //人员2入住办理成功
+        if(SmartlockUtil.resultMsg.equals(map1.get("resultMsg"))){
+            //发送短信提示
+            String msg="开门申请成功,门锁编号:"+listsubRla.get(1).getLockCode()+"密码:"+map1.get("password");
+        }
+
+        //人员1 备注详情
+        detalisMap.put("人员2",opendoorApply.getUserName());
+        detalisMap.put("锁编2号",listsubRla.get(1).getLockCode());
+        detalisMap.put("人员2密码",map2.get("password"));
+
+        opendoorApply.setIllustrate(detalisMap.toString());
+       return slOpendoorApplyMapper.updateSlOpendoorApply(opendoorApply);
+    }
+}

+ 162 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlOpendoorApplyServiceImpl.java

@@ -0,0 +1,162 @@
+package com.zd.smartlock.service.impl;
+
+import com.zd.common.core.domain.R;
+import com.zd.common.core.exception.ServiceException;
+import com.zd.common.core.utils.StringUtils;
+import com.zd.common.security.service.TokenService;
+import com.zd.smartlock.domain.SlOpendoorApply;
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.vo.SlOpendoorApplyVo;
+import com.zd.smartlock.mapper.SlOpendoorApplyMapper;
+import com.zd.smartlock.mapper.SlSubjectRelationMapper;
+import com.zd.smartlock.mapper.SlUserRelationMapper;
+import com.zd.smartlock.service.ISlOpendoorApplyService;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.system.api.RemoteUserService;
+import com.zd.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 申请开门Service业务层处理
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@Service
+public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService
+{
+    @Autowired
+    private SlOpendoorApplyMapper slOpendoorApplyMapper;
+
+    @Autowired
+    private RemoteUserService remoteUserService;
+
+    @Autowired
+    private TokenService tokenService;
+
+    @Autowired
+    private SlSubjectRelationMapper slSubjectRelationMapper;
+
+    /**
+     * 查询申请开门
+     *
+     * @param id 申请开门主键
+     * @return 申请开门
+     */
+    @Override
+    public SlOpendoorApply selectSlOpendoorApplyById(Long id)
+    {
+        return slOpendoorApplyMapper.selectSlOpendoorApplyById(id);
+    }
+
+    /**
+     * 查询申请开门列表
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 申请开门
+     */
+    @Override
+    public List<SlOpendoorApplyVo> selectSlOpendoorApplyList(SlOpendoorApplyVo slOpendoorApply)
+    {
+        return slOpendoorApplyMapper.selectSlOpendoorApplyList(slOpendoorApply);
+    }
+
+    @Override
+    public List<SlOpendoorApply> getListByIds(List<Long> ids){
+        if (ids.isEmpty()){
+            new ArrayList<>();
+        }
+        return slOpendoorApplyMapper.getListByIds(ids);
+    }
+
+    /**
+     * 新增申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertSlOpendoorApply(SlOpendoorApply slOpendoorApply)
+    {
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        if(StringUtils.isEmpty(sysUser.getPhonenumber())){
+            throw new ServiceException("申请人:"+sysUser.getNickName()+"电话为空!");
+        }
+
+         //1.校验实验室是否配置并且关联双锁
+        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        subjectRelation.setSubjectId(slOpendoorApply.getSubjectId());
+        List<SlSubjectRelation> subjectList = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+        if(subjectList.size()<2){
+            throw new ServiceException("该实验室关联门锁不足2个!");
+        }
+        //2.校验人员电话是否为空
+        R<SysUser> r = remoteUserService.getUserInfoByUserId(slOpendoorApply.getUserId2(),"inner");
+        if(StringUtils.isEmpty(r.getData().getPhonenumber())){
+            throw new ServiceException("申请人:"+r.getData().getNickName()+"电话为空!");
+        }
+
+        slOpendoorApply.setUserId2(r.getData().getUserId());
+        slOpendoorApply.setUserName2(r.getData().getNickName());
+        slOpendoorApply.setUserCode2(r.getData().getUserName());
+        slOpendoorApply.setUserSex2(r.getData().getSex()==null?1:Integer.valueOf(sysUser.getSex()));
+        slOpendoorApply.setPhonenumber2(r.getData().getPhonenumber());
+
+        slOpendoorApply.setUserId(sysUser.getUserId());
+        slOpendoorApply.setUserName(sysUser.getNickName());
+        slOpendoorApply.setDeptId(sysUser.getDept().getDeptId());
+        slOpendoorApply.setDeptName(sysUser.getDept().getDeptName());
+        slOpendoorApply.setUserCode(sysUser.getUserName());
+        slOpendoorApply.setUserSex(sysUser.getSex()==null?1:Integer.valueOf(sysUser.getSex()));
+        slOpendoorApply.setPhonenumber(sysUser.getPhonenumber());
+        slOpendoorApply.setCreatTime(new Date());
+        return slOpendoorApplyMapper.insertSlOpendoorApply(slOpendoorApply);
+    }
+
+    /**
+     * 修改申请开门
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int updateSlOpendoorApply(SlOpendoorApply slOpendoorApply)
+    {
+        return slOpendoorApplyMapper.updateSlOpendoorApply(slOpendoorApply);
+    }
+
+    /**
+     * 批量删除申请开门
+     *
+     * @param ids 需要删除的申请开门主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlOpendoorApplyByIds(Long[] ids)
+    {
+        return slOpendoorApplyMapper.deleteSlOpendoorApplyByIds(ids);
+    }
+
+    /**
+     * 删除申请开门信息
+     *
+     * @param id 申请开门主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlOpendoorApplyById(Long id)
+    {
+        return slOpendoorApplyMapper.deleteSlOpendoorApplyById(id);
+    }
+}

+ 146 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlSubjectRelationServiceImpl.java

@@ -0,0 +1,146 @@
+package com.zd.smartlock.service.impl;
+
+import com.zd.common.core.exception.ServiceException;
+import com.zd.common.core.utils.SecurityUtils;
+import com.zd.common.security.service.TokenService;
+import com.zd.common.security.utils.SaveUtil;
+import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.domain.vo.SlSubjectRelationVo;
+import com.zd.smartlock.mapper.SlSubjectRelationMapper;
+import com.zd.smartlock.mapper.SlUserRelationMapper;
+import com.zd.smartlock.service.ISlSubjectRelationService;
+import com.zd.smartlock.service.ISlUserRelationService;
+import com.zd.system.api.domain.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 实验室关联Service业务层处理
+ *
+ * @author zd
+ * @date 2022-09-03
+ */
+@Service
+public class SlSubjectRelationServiceImpl implements ISlSubjectRelationService
+{
+    @Autowired
+    private SlSubjectRelationMapper slSubjectRelationMapper;
+
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 查询实验室关联
+     *
+     * @param id 实验室关联主键
+     * @return 实验室关联
+     */
+    @Override
+    public SlSubjectRelation selectSlSubjectRelationById(Long id)
+    {
+        return slSubjectRelationMapper.selectSlSubjectRelationById(id);
+    }
+
+    /**
+     * 查询实验室关联列表
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 实验室关联
+     */
+    @Override
+    public List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation)
+    {
+        return slSubjectRelationMapper.selectSlSubjectRelationList(slSubjectRelation);
+    }
+
+    @Override
+    public List<SlSubjectRelation> getListByIds(List<Long> ids){
+        if (ids.isEmpty()){
+            new ArrayList<>();
+        }
+        return slSubjectRelationMapper.getListByIds(ids);
+    }
+
+    /**
+     * 新增实验室关联
+     *
+     * @param vo 实验室关联
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertSlSubjectRelation(SlSubjectRelationVo vo)
+    {
+        List<SlSubjectRelation> list = vo.getSlSubjectList();
+        if(list==null || list.size()==0){
+            throw new ServiceException("没有要关联的数据!");
+        }
+        System.out.println(SecurityUtils.getUsername());
+        //校验本次提交是否存在已绑定情况
+        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        for (SlSubjectRelation sl:list ) {
+            subjectRelation.setLockRoomId(sl.getLockRoomId());
+            List<SlSubjectRelation> sellist=  slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+            if(sellist.size()>0){
+                throw new ServiceException("房间: "+sl.getRoomName()+",位置: "+sl.getRoomLocation()+"已被绑定。");
+            }
+        }
+
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        //关系绑定
+        for (SlSubjectRelation slsub:list ) {
+            slsub.setDeptId(sysUser.getDept().getDeptId());
+            slsub.setDeptName(sysUser.getDept().getDeptName());
+            slsub.setUserId(sysUser.getUserId());
+            slsub.setCreateBy(sysUser.getNickName());
+            slsub.setCreatTime(new Date());
+            slSubjectRelationMapper.insertSlSubjectRelation(slsub);
+        }
+        return 1;
+    }
+
+    /**
+     * 修改实验室关联
+     *
+     * @param slSubjectRelation 实验室关联
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int updateSlSubjectRelation(SlSubjectRelation slSubjectRelation)
+    {
+        return slSubjectRelationMapper.updateSlSubjectRelation(slSubjectRelation);
+    }
+
+    /**
+     * 批量删除实验室关联
+     *
+     * @param ids 需要删除的实验室关联主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlSubjectRelationByIds(Long[] ids)
+    {
+        return slSubjectRelationMapper.deleteSlSubjectRelationByIds(ids);
+    }
+
+    /**
+     * 删除实验室关联信息
+     *
+     * @param id 实验室关联主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlSubjectRelationById(Long id)
+    {
+        return slSubjectRelationMapper.deleteSlSubjectRelationById(id);
+    }
+}

+ 108 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlUserRelationServiceImpl.java

@@ -0,0 +1,108 @@
+package com.zd.smartlock.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.zd.smartlock.mapper.SlUserRelationMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import com.zd.smartlock.domain.SlUserRelation;
+import com.zd.smartlock.service.ISlUserRelationService;
+
+/**
+ * 人员关联Service业务层处理
+ *
+ * @author zd
+ * @date 2022-09-02
+ */
+@Service
+public class SlUserRelationServiceImpl implements ISlUserRelationService
+{
+    @Autowired
+    private SlUserRelationMapper slUserRelationMapper;
+
+    /**
+     * 查询人员关联
+     *
+     * @param id 人员关联主键
+     * @return 人员关联
+     */
+    @Override
+    public SlUserRelation selectSlUserRelationById(Long id)
+    {
+        return slUserRelationMapper.selectSlUserRelationById(id);
+    }
+
+    /**
+     * 查询人员关联列表
+     *
+     * @param slUserRelation 人员关联
+     * @return 人员关联
+     */
+    @Override
+    public List<SlUserRelation> selectSlUserRelationList(SlUserRelation slUserRelation)
+    {
+        return slUserRelationMapper.selectSlUserRelationList(slUserRelation);
+    }
+
+    @Override
+    public List<SlUserRelation> getListByIds(List<Long> ids){
+        if (ids.isEmpty()){
+            new ArrayList<>();
+        }
+        return slUserRelationMapper.getListByIds(ids);
+    }
+
+    /**
+     * 新增人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insertSlUserRelation(SlUserRelation slUserRelation)
+    {
+        return slUserRelationMapper.insertSlUserRelation(slUserRelation);
+    }
+
+    /**
+     * 修改人员关联
+     *
+     * @param slUserRelation 人员关联
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int updateSlUserRelation(SlUserRelation slUserRelation)
+    {
+        return slUserRelationMapper.updateSlUserRelation(slUserRelation);
+    }
+
+    /**
+     * 批量删除人员关联
+     *
+     * @param ids 需要删除的人员关联主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlUserRelationByIds(Long[] ids)
+    {
+        return slUserRelationMapper.deleteSlUserRelationByIds(ids);
+    }
+
+    /**
+     * 删除人员关联信息
+     *
+     * @param id 人员关联主键
+     * @return 结果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteSlUserRelationById(Long id)
+    {
+        return slUserRelationMapper.deleteSlUserRelationById(id);
+    }
+}

+ 608 - 0
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/utils/SmartlockUtil.java

@@ -0,0 +1,608 @@
+package com.zd.smartlock.utils;
+
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.zd.common.core.utils.StringUtils;
+import com.zd.smartlock.domain.api.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * @Author: liujh
+ * @Date: 2022/08/29/11:30
+ * @Description:
+ */
+public class SmartlockUtil {
+    private static final Logger logger = LoggerFactory.getLogger(SmartlockUtil.class);
+
+    private  static  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 服务访问地址
+     */
+    public  final  static String serviceurl="http://192.168.1.66/info";
+
+    /**
+     * 智能锁返回成功字符描述
+     */
+    public final  static  String  resultMsg="ok";
+
+    /***
+     * 登陆账户
+     */
+    public final static String userlogin="admin";
+
+    /***
+     * 登陆密码
+     */
+    public final static String password="admin123";
+
+
+
+    public static HttpRequest httpSendPost(String url,String json){
+       return HttpRequest.post(url)
+                .header("Content-Type", "application/json")
+                .body(json);
+    }
+
+
+    /***
+     * 获取token
+     * @return
+     */
+    public  static  String getToken(){
+        String token=null;
+        String url =serviceurl+ "/login/1/gettoken?userlogin="+userlogin+"&password="+password;
+        JSONObject json = new JSONObject();
+        try {
+            HttpRequest request = HttpRequest.post(url)
+                    .header("Content-Type", "application/json")
+                    .body(json.toString());
+            HttpResponse response = request.execute();
+            String resultMsg =  JSON.parseObject(response.body()).get("resultMsg").toString();
+            //请求是否成功
+            if(SmartlockUtil.resultMsg.equals(resultMsg)){
+                token = JSON.parseObject(JSON.parseObject(response.body()).get("result").toString()).get("token").toString();
+            }else {
+                logger.error("智能锁获取token失败:"+resultMsg);
+            }
+        }catch (Exception e){
+            logger.error("获取token失败:"+e);
+        }
+        System.out.println(token);
+       return token;
+    }
+
+    /**
+     * 获取顶级建筑
+     */
+    public static SlBuild getTopBuild(){
+        SlBuild slBuild = null;
+        try {
+            String token =  SmartlockUtil.getToken();
+            String url = SmartlockUtil.serviceurl+"/build/1/getbuild?buildfatherid=0&page=1&rows=10&token="+token;
+            HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+            HttpResponse response = request.execute();
+            System.out.println(response.body());
+            String resultMsg = JSON.parseObject(response.body().toString()).get("resultMsg").toString();
+            if(SmartlockUtil.resultMsg.equals(resultMsg)){
+                List<SlBuild> list = JSON.parseArray(JSON.parseObject(response.body().toString()).get("result").toString(),SlBuild.class);
+                slBuild= list.get(0);
+            }
+        }catch (Exception e){
+            logger.error("获取顶级建筑失败:"+e);
+        }
+        return slBuild;
+    }
+
+    /**
+     * 查询房间
+     * @param
+     * @return
+     */
+    public static List<SlRoom> getRoom(SlRoom room){
+        SlBuild slBuild = null;
+        String token =  SmartlockUtil.getToken();
+        List<SlRoom> listRoom= new ArrayList<>();
+        System.out.println(token);
+        try {
+            //获取楼层建筑id
+            String urlLc = SmartlockUtil.serviceurl+"/build/1/getbuild?buildid=0&page=1&rows=30&token="+token;
+            HttpRequest requestLc = SmartlockUtil.httpSendPost(urlLc,"");
+            HttpResponse responseLc = requestLc.execute();
+            String str = responseLc.body();
+            //查询失败直接返回
+            String resultMsg = JSON.parseObject(str).get("resultMsg").toString();
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("获取楼层建筑id失败:"+resultMsg);
+                return listRoom;
+            }
+            String data = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("data").toString();
+            List<SlBuild> listLc = JSON.parseArray(data,SlBuild.class);
+            System.out.println(listLc.size());
+            for (SlBuild build:listLc) {
+                if("3".equals(build.getBuildtype())){
+                    slBuild = build;
+                    break;
+                }
+            }
+
+            //查询房间 不支持条件搜索
+            String urlroom = SmartlockUtil.serviceurl+"/build/2/getroom?buildid="+slBuild.getBuildid()+"&page="+slBuild.getPageNumber()+"&rows="+slBuild.getPageSize()+"&token="+token;
+            HttpRequest requestRoom = SmartlockUtil.httpSendPost(urlroom,"");
+            HttpResponse response = requestRoom.execute();
+            String strRoom = response.body();
+            String dataRoom = JSON.parseObject(JSON.parseObject(strRoom).get("result").toString()).get("data").toString();
+            listRoom = JSON.parseArray(dataRoom,SlRoom.class);
+        }catch (Exception e){
+            logger.error("查询房间失败:"+e);
+        }
+        return listRoom;
+    }
+
+    /**
+     * 查询用户集合
+     * @param sluser
+     */
+    public  static List<SlUser> getUser(SlUser sluser){
+        List<SlUser> list =new ArrayList<>();
+        try {
+            String token =  SmartlockUtil.getToken();
+            //sluser.getSearch() 该查询条件支持:人员编号/人员姓名/手机号检索
+            String url = SmartlockUtil.serviceurl+"/card/save/8/getcardperson?persontype=1&page="+sluser.getPageNumber()+"&rows="+sluser.getPageSize()+"&search="+sluser.getSearch()+"&token="+token;
+            HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+            HttpResponse response = request.execute();
+            //查询失败直接返回
+            String resultMsg = JSON.parseObject(response.body().toString()).get("resultMsg").toString();
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("查询用户集合失败1:"+resultMsg);
+                return list;
+            }
+            String str = response.body();
+            String data = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("data").toString();
+            list = JSON.parseArray(data,SlUser.class);
+        }catch (Exception e){
+            logger.error("查询用户集合失败2:"+e);
+        }
+        return list;
+    }
+
+    /**
+     * 获取房间详情
+     * @param roomId 房间roomid
+     * 返回参数根据后期需求 扩展,
+     * @return
+     */
+    public static SlLockOnline getRoomDetails(String roomId){
+        //Map<String,Object> map = new HashMap<>();
+        SlLockOnline lockOnline =null;
+        try {
+            if(StringUtils.isEmpty(roomId)){
+                logger.error("获取房间详情失败,参数roomid为空:");
+                return lockOnline;
+            }
+            String token =  SmartlockUtil.getToken();
+            //sluser.getSearch() 该查询条件支持:人员编号/人员姓名/手机号检索
+            String url = SmartlockUtil.serviceurl+"/lockauth/operate/1/getroominfo?roomid="+roomId+"&token="+token;
+            HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+            HttpResponse response = request.execute();
+            //查询失败直接返回
+            String resultMsg = JSON.parseObject(response.body()).get("resultMsg").toString();
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("获取房间详情失败1:"+resultMsg);
+                return lockOnline;
+            }
+            String str = response.body();
+            //在线状态
+            String roomnetquality = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("roomnetquality").toString();
+            //门锁编号
+            String lockCode = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("roomcode2").toString();
+            lockOnline.setOnLine(roomnetquality);
+            lockOnline.setLockCode(lockCode);
+            System.out.println("房间详情,门锁状态 roomnetquality: "+ roomnetquality+" lockCode: "+lockCode);
+        }catch (Exception e){
+            logger.error("获取房间详情失败2:"+e);
+        }
+        return lockOnline;
+    }
+
+    /***
+     * 开门记录
+     * @param openDoorSearch
+     */
+    public static List<SlOpenAndClosLog> getOpenDoorLog(SlOpenDoorSearch openDoorSearch){
+        List<SlOpenAndClosLog> list =new ArrayList<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            String token =  SmartlockUtil.getToken();
+
+            if(StringUtils.isEmpty(openDoorSearch.getRoomid())){
+                logger.error("查询开门记录集合失败,roomid为空:"+resultMsg);
+                return list;
+            }
+            if(StringUtils.isEmpty(openDoorSearch.getRecordtype())){
+                //0或空=所有记录,1=报警记录,2=开门记录)
+                openDoorSearch.setRecordtype("2");
+            }
+            String sdate=sdf.format(new Date())+" 00:00:00";
+            String edate=sdf.format(new Date())+" 23:59:59";
+
+            //sluser.getSearch() 该查询条件支持:人员编号/人员姓名/手机号检索
+            String url = SmartlockUtil.serviceurl+"/lockauth/operate/2/getlockinfo?persontype=1&page="+openDoorSearch.getPageNumber()+"&rows="+openDoorSearch.getPageSize()+
+                    "&roomid="+openDoorSearch.getRoomid()+"&token="+token+"&recordtype="+openDoorSearch.getRecordtype()
+                    +"&search="+openDoorSearch.getSearch()+"&sdate="+sdate+"&edate="+edate;
+            HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+            HttpResponse response = request.execute();
+            System.out.println(response.body());
+            //查询失败直接返回
+            String resultMsg = JSON.parseObject(response.body()).get("resultMsg").toString();
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("查询开门记录集合失败1:"+resultMsg);
+                return list;
+            }
+            String str = response.body();
+            String data = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("data").toString();
+            list = JSON.parseArray(data,SlOpenAndClosLog.class);
+        }catch (Exception e){
+            logger.error("查询开门记录集合失败2:"+e);
+        }
+        return list;
+    }
+
+    /**
+     * 获取组织信息
+     * @param group
+     */
+    public  static  List<SlGroup> getGroup(SlGroup group){
+        List<SlGroup> list =new ArrayList<>();
+        String token =  SmartlockUtil.getToken();
+        try {
+            String url = SmartlockUtil.serviceurl+"/group/1/getgroup?&token="+token
+                    +"&page="+group.getPageNumber()+"&rows="+group.getPageSize()+"&pgfatherid=0";
+            HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+            HttpResponse response = request.execute();
+            //查询失败直接返回
+            String resultMsg = JSON.parseObject(response.body()).get("resultMsg").toString();
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("查询开门记录集合失败1:"+resultMsg);
+                return list;
+            }
+            String str = response.body();
+            String data = JSON.parseObject(JSON.parseObject(str).get("result").toString()).get("data").toString();
+            list = JSON.parseArray(data,SlGroup.class);
+        }catch (Exception e){
+            logger.error("查询组织信息失败:"+e);
+        }
+        return list;
+    }
+
+    /***
+     * 添加人员并且办理入住
+     * 返回操作状态
+     */
+    public static Map<String,Object> addUser(SlUser user,String roomId){
+        List<SlGroup> listgroup =  getGroup(new SlGroup());
+        Map<String,Object> map = new HashMap<>();
+        try {
+            //获取组织id
+            String pgid = listgroup.get(0).getPgid();
+            String token =  SmartlockUtil.getToken();
+
+            /*roomId="109";
+            user.setPersoncode("C014");//学号、工号
+            user.setPersonname("姓名014");//姓名
+            user.setPersonsex("1");//性别 (0=女,1=男)
+            user.setPersontype("1");//人员类别(1=学生,2=教职工,3=临时人员)*/
+
+            //查询人员是否存在
+            Boolean flg =  checkUserExis(user.getPersoncode(),"1",token);
+            if(!flg) {
+                //新增人员
+                String url = SmartlockUtil.serviceurl + "/person/save/1/saveperson?" +
+                        "personcode=" + user.getPersoncode() + "&personname=" + user.getPersonname() + "&personsex=" + user.getPersonsex() +
+                        "&persontype=" + user.getPersontype() + "&pgid=" + pgid + "&token=" + token;
+                HttpRequest request = SmartlockUtil.httpSendPost(url, "");
+                HttpResponse response = request.execute();
+                System.out.println(response.body());
+                //查询失败直接返回
+                String resultMsg = JSON.parseObject(response.body().toString()).get("resultMsg").toString();
+                System.out.println(resultMsg);
+                if (!SmartlockUtil.resultMsg.equals(resultMsg)) {
+                    logger.error("人员添加失败1:" + resultMsg);
+                    map.put("resultMsg", resultMsg);
+                    return map;
+                }
+
+                //添加授权
+                map = addUserAuths(token,user.getPersoncode(), roomId);
+            }else{
+                //查询用户是否存在授权
+               String authis= checkUserAuthExis(user.getPersoncode(),token);
+               if(StringUtils.isNotEmpty(authis)){
+                   //修改授权
+                   map = updateAuths( token, roomId,Integer.valueOf(authis) );
+               }else {
+                   //添加授权
+                   map = addUserAuths(token,user.getPersoncode(), roomId);
+               }
+            }
+            //操作结果
+            map.put("resultMsg",resultMsg);
+        }catch (Exception e){
+            logger.error("添加人员并且办理入住异常:"+e);
+        }
+        return map;
+    }
+
+    /***
+     * 修改用户授权
+     * @param token
+     * @param roomId
+     * @param authid
+     */
+    public  static Map<String,Object> updateAuths(String token,String roomId,Integer authid){
+        Map<String,Object> map = new HashMap<>();
+        try {
+            List<SlupdateAuths> list = new ArrayList<>();
+            SlupdateAuths slupdateAuths = new SlupdateAuths();
+            slupdateAuths.setAuthid(authid);
+            slupdateAuths.setRctype(3);
+            list.add(slupdateAuths);
+            String  pw = getRandom(6);
+            String url2= SmartlockUtil.serviceurl+"/lockauth/operate/7/updateauths?token="+token+"&roomid="+roomId+"&password="+pw;
+            HttpRequest request2 = SmartlockUtil.httpSendPost(url2,JSONObject.toJSONString( list ));
+            HttpResponse response2 = request2.execute();
+            String resultMsg = JSON.parseObject(response2.body().toString()).get("resultMsg").toString();
+            System.out.println(response2.body());
+            System.out.println(pw);
+            map.put("password",pw);
+            map.put("resultMsg",resultMsg);
+        }catch (Exception e){
+            logger.error("修改用户授权失败"+e);
+            System.out.println("修改用户授权失败:"+resultMsg);
+        }
+        return map;
+    }
+    /**
+     * 添加授权
+     * @param token
+     * @param personcode
+     * @param roomId
+     * @return
+     */
+    public static Map<String,Object> addUserAuths(String token,String personcode,String roomId){
+        Map<String,Object> map = new HashMap<>();
+        try {
+            //入住办理
+            JSONObject json = new JSONObject();
+            String pw = getRandom(6);
+            System.out.println(pw);
+            List<SlPostUser> postlist = new ArrayList<>();
+            SlPostUser postUser = new SlPostUser();
+            postUser.setPersoncode(personcode);//学号、工号
+            postUser.setIssendface("1");//是否下发人脸(1是,0否)
+            postUser.setIssendfinger("1");//是否下发指纹(1是,0否)
+            postUser.setIssendpass("1");//是否下发密码(1是,0否)
+            postUser.setManagertype(1);//权限类型(1管理权限,0使用权限,管理权限不占用入住人数)
+            postUser.setPassword(pw);//6位数字密码(不允许连续数字或连续三个及以上相同数字)
+            postUser.setEmpsdate(sdf.format(new Date()));//授权开始时间
+            postUser.setEmpedate(sdf.format(getTime(1)));  //授权结束时间,当前时间加1小时
+            postlist.add(postUser);
+            System.out.println("开始时间:"+sdf.format(new Date())+"结束时间:"+sdf.format(getTime(1)));
+
+            //将对象转为json
+            //JSONObject jsonStr = JSON.parseObject(JSONObject.toJSONString( postlist ));
+            String url2 = SmartlockUtil.serviceurl+"/lockauth/save/4/saveauths?token="+token+"&roomid="+roomId;
+            HttpRequest request2 = SmartlockUtil.httpSendPost(url2,JSONObject.toJSONString( postlist ));
+            HttpResponse response2 = request2.execute();
+            System.out.println(response2.body());
+            //查询失败直接返回
+            if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                logger.error("人员添加后办理入住失败1:"+resultMsg);
+                map.put("resultMsg",resultMsg);
+                return map;
+            }
+            //密码
+            map.put("password",pw);
+        }catch (Exception e){
+
+        }
+        return map;
+    }
+    /***
+     * 入住-授权
+     * @param user 用户参数
+     * @param roomId  房间id
+     * @return
+     */
+    public static void AuthCheckInTest(SlUser user,String roomId){
+
+        List<SlGroup> listgroup =  getGroup(new SlGroup());
+        Map<String,Object> map = new HashMap<>();
+        String token =  SmartlockUtil.getToken();
+        roomId="109";
+
+            //获取组织id
+            String pgid = listgroup.get(0).getPgid();
+            //roomId="109";
+            user.setPersoncode("C010");//学号、工号
+            user.setPersonname("姓名c10");//姓名
+            user.setPersonsex("1");//性别 (0=女,1=男)
+            user.setPersontype("1");//人员类别(1=学生,2=教职工,3=临时人员)
+
+            //查询人员是否存在
+            Boolean flg =  checkUserExis(user.getPersoncode(),"1",token);
+            if(!flg){
+                String url = SmartlockUtil.serviceurl+"/person/save/1/saveperson?" +
+                        "personcode="+user.getPersoncode()+"&personname="+user.getPersonname()+"&personsex="+user.getPersonsex()+
+                        "&persontype="+user.getPersontype()+"&pgid="+pgid+"&token="+token;
+                HttpRequest request = SmartlockUtil.httpSendPost(url,"");
+                HttpResponse response = request.execute();
+                System.out.println(response.body());
+                //查询失败直接返回
+                String resultMsg = JSON.parseObject(response.body().toString()).get("resultMsg").toString();
+                System.out.println(resultMsg);
+                if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+                    logger.error("人员添加失败1:"+resultMsg);
+                    map.put("resultMsg",resultMsg);
+                }
+            }
+
+
+            //入住办理
+            String pw = getRandom(6);
+            System.out.println(pw);
+            List<SlPostUser> postlist = new ArrayList<>();
+            SlPostUser postUser = new SlPostUser();
+            postUser.setPersoncode("C010");//学号、工号
+            postUser.setIssendface("1");//是否下发人脸(1是,0否)
+            postUser.setIssendfinger("1");//是否下发指纹(1是,0否)
+            postUser.setIssendpass("1");//是否下发密码(1是,0否)
+            postUser.setManagertype(1);//权限类型(1管理权限,0使用权限,管理权限不占用入住人数)
+            postUser.setPassword(pw);//6位数字密码(不允许连续数字或连续三个及以上相同数字)
+            postUser.setRoomid(roomId);
+            postUser.setEmpsdate(sdf.format(new Date()));//授权开始时间
+            postUser.setEmpedate(sdf.format(getTime(1)));  //授权结束时间,当前时间加1小时
+            postlist.add(postUser);
+
+        //将对象转为json
+        //JSONObject jsonStr = JSON.parseObject(JSONObject.toJSONString( postlist ));
+        String url2 = SmartlockUtil.serviceurl+"/lockauth/operate/9/batchauths?token="+token;
+        HttpRequest request2 = SmartlockUtil.httpSendPost(url2,JSONObject.toJSONString( postlist ));
+        HttpResponse response2 = request2.execute();
+        System.out.println(response2.body());
+        //查询失败直接返回
+        if(!SmartlockUtil.resultMsg.equals(resultMsg)){
+            logger.error("人员添加后办理入住失败1:"+resultMsg);
+            map.put("resultMsg",resultMsg);
+        }
+        //密码
+        map.put("password",pw);
+        //操作结果
+        map.put("resultMsg",resultMsg);
+
+
+    }
+
+    /***
+     * 查询人员是否存在
+     * @param personcode 人员编码
+     * @param cardtype 1(学生卡)/2(职工卡)/3(管理卡)/6(临时卡)/7(身份证)
+     */
+    public static Boolean checkUserExis(String personcode,String cardtype,String token){
+        Boolean flg=false;
+        //String token =  SmartlockUtil.getToken();
+        String urlexis = SmartlockUtil.serviceurl+"/card/save/8/getcardperson?token="+token+"&cardtype="+cardtype+"&page=1&rows=20&search="+personcode;
+        HttpRequest requestexis = SmartlockUtil.httpSendPost(urlexis,"");
+        HttpResponse responseexis = requestexis.execute();
+        System.out.println(responseexis.body());
+        String data = JSON.parseObject(JSON.parseObject(responseexis.body()).get("result").toString()).get("data").toString();
+        JSONArray array = JSON.parseArray(data);
+        if(array.size()>0){
+            flg=true;
+        }
+        return flg;
+    }
+
+
+    /***
+     * 查询用户是否存在授权
+     * @param personcode
+     * @return
+     */
+    public static String checkUserAuthExis(String personcode,String token){
+        String authid=null;
+        //查询用户授权信息
+        //String token =  SmartlockUtil.getToken();
+        String urlauth = SmartlockUtil.serviceurl+"/person/2/getpersonauth?" +
+                "personcode="+personcode+"&page=1"+"&rows=50&token="+token;
+        HttpRequest requestauth = SmartlockUtil.httpSendPost(urlauth,"");
+        HttpResponse responseauth = requestauth.execute();
+        System.out.println(responseauth.body());
+
+        String data = JSON.parseObject(JSON.parseObject(responseauth.body()).get("result").toString()).get("data").toString();
+        JSONArray array = JSON.parseArray(data);
+        for (int i=0;i<array.size();i++){
+            System.out.println(array.get(i)+"");
+            String empedate =  JSON.parseObject(array.get(i).toString()).get("empedate").toString();
+            String authtype =  JSON.parseObject(array.get(i).toString()).get("authtype").toString();
+            if("3".equals(authtype) ){
+                authid=JSON.parseObject(array.get(i).toString()).get("authid").toString();
+                break;
+            }
+        }
+        return authid;
+    }
+
+    /**
+     * 当前时间加 N 小时
+     * @param num
+     * @return
+     */
+    public static Date getTime(int num){
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Date());
+        cal.add(Calendar.HOUR, num);
+        return cal.getTime();
+    }
+
+    /**
+     * 获取6位随机数
+     * @param length
+     * @return
+     */
+    public static String getRandom(int length){
+        String val = "";
+        Random random = new Random();
+        for (int i = 0; i < length; i++) {
+            val += String.valueOf(random.nextInt(10));
+        }
+        return val;
+    }
+
+    public static void main(String[] args) {
+        //getTopBuild();//获取顶级建筑
+        /*List<SlRoom> listRoom =  getRoom( new SlRoom());
+        System.out.println(listRoom.size());
+        for (SlRoom slroom:listRoom ) {
+            System.out.println(slroom.getRoomid()+"== "+slroom.getRoomcode());
+        }*/
+
+        /*List<SlUser> listUser  = getUser(new SlUser());
+        for (SlUser user:listUser ) {
+            System.out.println(user.getPersoncode()+"== "+user.getPersonname());
+        }*/
+
+        //getRoomDetails("109");
+
+       /* SlOpenDoorSearch  search = new SlOpenDoorSearch();
+        search.setRoomid("109");
+        List<SlOpenAndClosLog> list = getOpenDoorLog(search);
+        for (SlOpenAndClosLog oplog:list) {
+            System.out.println(oplog.getPersonname()+"=="+oplog.getUnlockingtype()+" =="+oplog.getUnlockingdate());
+        }*/
+
+        //getGroup(new SlGroup());
+
+        //addUser(new SlUser() , "");
+
+       // AuthCheckIn(new SlUser() , "");
+
+        addUser(new SlUser() , "");
+
+        // System.out.println(checkUserExis("C008","1"));
+
+        //String token =  SmartlockUtil.getToken();
+        //updateAuths( token,"109", 32);
+
+
+
+    }
+}

+ 10 - 0
zd-modules/zd-smartlock/src/main/resources/banner.txt

@@ -0,0 +1,10 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
+                            _                           _                    
+                           (_)                         | |                   
+ _ __  _   _   ___   _   _  _  ______  ___  _   _  ___ | |_   ___  _ __ ___  
+| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ 
+| |   | |_| || (_) || |_| || |        \__ \| |_| |\__ \| |_ |  __/| | | | | |
+|_|    \__,_| \___/  \__, ||_|        |___/ \__, ||___/ \__| \___||_| |_| |_|
+                      __/ |                  __/ |                           
+                     |___/                  |___/                            

+ 27 - 0
zd-modules/zd-smartlock/src/main/resources/bootstrap.yml

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

+ 74 - 0
zd-modules/zd-smartlock/src/main/resources/logback.xml

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="60 seconds" debug="false">
+    <!-- 日志存放路径 -->
+    <property name="log.path" value="logs/zd-alarm"/>
+    <!-- 日志输出格式 -->
+    <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
+
+    <!-- 控制台输出 -->
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <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>60</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.zd" level="debug"/>
+    <!-- Spring日志级别控制  -->
+    <logger name="org.springframework" level="info"/>
+
+    <root level="debug">
+        <appender-ref ref="console"/>
+    </root>
+
+    <!--系统操作日志-->
+    <root level="info">
+        <appender-ref ref="file_info"/>
+        <appender-ref ref="file_error"/>
+    </root>
+</configuration>

+ 125 - 0
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlApplyApprovalMapper.xml

@@ -0,0 +1,125 @@
+<?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.zd.smartlock.mapper.SlApplyApprovalMapper">
+
+    <resultMap type="com.zd.smartlock.domain.SlApplyApproval" id="SlApplyApprovalResult">
+        <result property="id" column="id"/>
+        <result property="applyId" column="apply_id"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="approvaId" column="approva_id"/>
+        <result property="approvaName" column="approva_name"/>
+        <result property="approvaStatus" column="approva_status"/>
+        <result property="cretaTime" column="creta_time"/>
+    </resultMap>
+
+    <sql id="selectSlApplyApprovalVo">
+        select id,
+               apply_id,
+               dept_id,
+               dept_name,
+               approva_id,
+               approva_name,
+               approva_status,
+               creta_time
+        from sl_apply_approval
+    </sql>
+    <sql id="selectSlApplyApprovalListVo">
+        select t.id,
+               t.apply_id,
+               t.dept_id,
+               t.dept_name,
+               t.approva_id,
+               t.approva_name,
+               t.approva_status,
+               t.creta_time
+        from sl_apply_approval as t
+    </sql>
+    <select id="selectSlApplyApprovalList" parameterType="com.zd.smartlock.domain.SlApplyApproval"
+            resultMap="SlApplyApprovalResult">
+        <include refid="selectSlApplyApprovalVo"/>
+        <where>
+            <if test="applyId != null ">and apply_id = #{applyId}</if>
+            <if test="approvaId != null ">and approva_id = #{approvaId}</if>
+            <if test="approvaName != null  and approvaName != ''">and approva_name like concat('%', #{approvaName},
+                '%')
+            </if>
+            <if test="approvaStatus != null ">and approva_status = #{approvaStatus}</if>
+            <if test="cretaTime != null ">and creta_time = #{cretaTime}</if>
+        </where>
+    </select>
+
+    <select id="getListByIds" resultMap="SlApplyApprovalResult">
+        <include refid="selectSlApplyApprovalVo"/>
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="selectSlApplyApprovalById" resultMap="SlApplyApprovalResult">
+        <include refid="selectSlApplyApprovalVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertSlApplyApproval" parameterType="com.zd.smartlock.domain.SlApplyApproval" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into sl_apply_approval
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="applyId != null">apply_id,</if>
+
+            <if test="deptId != null">dept_id,</if>
+
+            <if test="deptName != null">dept_name,</if>
+
+            <if test="approvaId != null">approva_id,</if>
+
+            <if test="approvaName != null">approva_name,</if>
+
+            <if test="approvaStatus != null">approva_status,</if>
+
+            <if test="cretaTime != null">creta_time,</if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="applyId != null">#{applyId},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="deptName != null">#{deptName},</if>
+            <if test="approvaId != null">#{approvaId},</if>
+            <if test="approvaName != null">#{approvaName},</if>
+            <if test="approvaStatus != null">#{approvaStatus},</if>
+            <if test="cretaTime != null">#{cretaTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSlApplyApproval" parameterType="com.zd.smartlock.domain.SlApplyApproval">
+        update sl_apply_approval
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="applyId != null">apply_id = #{applyId},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="deptName != null">dept_name = #{deptName},</if>
+            <if test="approvaId != null">approva_id = #{approvaId},</if>
+            <if test="approvaName != null">approva_name = #{approvaName},</if>
+            <if test="approvaStatus != null">approva_status = #{approvaStatus},</if>
+            <if test="cretaTime != null">creta_time = #{cretaTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSlApplyApprovalById">
+        delete
+        from sl_apply_approval
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteSlApplyApprovalByIds">
+        delete from sl_apply_approval where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 236 - 0
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlOpendoorApplyMapper.xml

@@ -0,0 +1,236 @@
+<?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.zd.smartlock.mapper.SlOpendoorApplyMapper">
+
+    <resultMap type="com.zd.smartlock.domain.vo.SlOpendoorApplyVo" id="SlOpendoorApplyResult">
+        <result property="id" column="id"/>
+        <result property="userId" column="user_id"/>
+        <result property="userName" column="user_name"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="deptName" column="dept_name"/>
+        <result property="userCode" column="user_code"/>
+        <result property="userSex" column="user_sex"/>
+        <result property="phonenumber" column="phonenumber"/>
+        <result property="userId2" column="user_id2"/>
+        <result property="userName2" column="user_name2"/>
+        <result property="userCode2" column="user_code2"/>
+        <result property="userSex2" column="user_sex2"/>
+        <result property="phonenumber2" column="phonenumber2"/>
+        <result property="subjectId" column="subject_id"/>
+        <result property="subjectName" column="subject_name"/>
+        <result property="position" column="position"/>
+        <result property="college" column="college"/>
+        <result property="applyStatus" column="apply_status"/>
+        <result property="applyNumber" column="apply_number"/>
+        <result property="illustrate" column="illustrate"/>
+        <result property="applyTime" column="apply_time"/>
+        <result property="creatTime" column="creat_time"/>
+    </resultMap>
+
+    <sql id="selectSlOpendoorApplyVo">
+        select id,
+               user_id,
+               user_name,
+               dept_id,
+               dept_name,
+               user_code,
+               user_sex,
+               phonenumber,
+               user_id2,
+               user_name2,
+               user_code2,
+               user_sex2,
+               phonenumber2,
+               subject_id,
+               subject_name,
+               position,
+               college,
+               apply_status,
+               apply_number,
+               illustrate,
+               apply_time,
+               creat_time
+        from sl_opendoor_apply
+    </sql>
+    <sql id="selectSlOpendoorApplyListVo">
+        select t.id,
+               t.user_id,
+               t.user_name,
+               t.dept_id,
+               t.dept_name,
+               t.user_code,
+               t.user_sex,
+               t.phonenumber,
+               t.user_id2,
+               t.user_name2,
+               t.user_code2,
+               t.user_sex2,
+               t.phonenumber,
+               t.subject_id,
+               t.subject_name,
+               t.position,
+               t.college,
+               t.apply_status,
+               t.apply_number,
+               t.illustrate,
+               t.apply_time,
+               t.creat_time,
+               (select safe_user_id from lab_subject s where s.id=t.subject_id) safe_user_id
+        from sl_opendoor_apply as t
+    </sql>
+    <select id="selectSlOpendoorApplyList" parameterType="com.zd.smartlock.domain.vo.SlOpendoorApplyVo"
+            resultMap="SlOpendoorApplyResult">
+        <include refid="selectSlOpendoorApplyListVo"/>
+        <where>
+            <if test="userId != null ">and user_id = #{userId}</if>
+            <if test="userName != null  and userName != ''">and user_name like concat('%', #{userName}, '%')</if>
+            <if test="deptId != null ">and dept_id = #{deptId}</if>
+            <if test="deptName != null ">and dept_name = #{deptName}</if>
+            <if test="userCode != null ">and user_code = #{userCode}</if>
+            <if test="userSex != null ">and user_sex = #{userSex}</if>
+            <if test="phonenumber != null ">and phonenumber = #{phonenumber}</if>
+            <if test="userId2 != null ">and user_id2 = #{userId2}</if>
+            <if test="userName2 != null  and userName2 != ''">and user_name2 = #{userName2}</if>
+            <if test="userCode2 != null ">and user_code2 = #{userCode2}</if>
+            <if test="userSex2 != null ">and user_sex2 = #{userSex2}</if>
+            <if test="phonenumber2 != null ">and phonenumber2 = #{phonenumber2}</if>
+            <if test="subjectId != null ">and subject_id = #{subjectId}</if>
+            <if test="subjectName != null  and subjectName != ''">and subject_name like concat('%', #{subjectName},
+                '%')
+            </if>
+            <if test="position != null  and position != ''">and position = #{position}</if>
+            <if test="college != null  and college != ''">and college = #{college}</if>
+            <if test="applyStatus != null ">and apply_status = #{applyStatus}</if>
+            <if test="applyNumber != null ">and apply_number = #{applyNumber}</if>
+            <if test="illustrate != null ">and illustrate = #{illustrate}</if>
+            <if test="applyTime != null ">and apply_time = #{applyTime}</if>
+            <if test="creatTime != null ">and creat_time = #{creatTime}</if>
+        </where>
+    </select>
+
+    <select id="getListByIds" resultMap="SlOpendoorApplyResult">
+        <include refid="selectSlOpendoorApplyVo"/>
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="selectSlOpendoorApplyById" resultMap="SlOpendoorApplyResult">
+        <include refid="selectSlOpendoorApplyVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertSlOpendoorApply" parameterType="com.zd.smartlock.domain.SlOpendoorApply" useGeneratedKeys="true"
+            keyProperty="id">
+        insert into sl_opendoor_apply
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+
+            <if test="userName != null">user_name,</if>
+
+            <if test="deptId != null">dept_id,</if>
+
+            <if test="deptName != null">dept_name,</if>
+
+            <if test="userCode != null">user_code,</if>
+
+            <if test="userSex != null">user_sex,</if>
+
+            <if test="phonenumber != null">phonenumber,</if>
+
+            <if test="userId2 != null">user_id2,</if>
+
+            <if test="userName2 != null">user_name2,</if>
+
+            <if test="userCode2 != null">user_code2,</if>
+
+            <if test="userSex2 != null">user_sex2,</if>
+
+            <if test="phonenumber2 != null">phonenumber2,</if>
+
+            <if test="subjectId != null">subject_id,</if>
+
+            <if test="subjectName != null">subject_name,</if>
+
+            <if test="position != null">position,</if>
+
+            <if test="college != null">college,</if>
+
+            <if test="applyStatus != null">apply_status,</if>
+
+            <if test="applyNumber != null">apply_number,</if>
+
+            <if test="illustrate != null">illustrate,</if>
+
+            <if test="creatTime != null">creat_time,</if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="deptName != null">#{deptName},</if>
+            <if test="userCode != null">#{userCode},</if>
+            <if test="userSex != null">#{userSex},</if>
+            <if test="phonenumber != null">#{phonenumber},</if>
+            <if test="userId2 != null">#{userId2},</if>
+            <if test="userName2 != null">#{userName2},</if>
+            <if test="userCode2 != null">#{userCode2},</if>
+            <if test="userSex2 != null">#{userSex2},</if>
+            <if test="phonenumber2 != null">#{phonenumber2},</if>
+            <if test="subjectId != null">#{subjectId},</if>
+            <if test="subjectName != null">#{subjectName},</if>
+            <if test="position != null">#{position},</if>
+            <if test="college != null">#{college},</if>
+            <if test="applyStatus != null">#{applyStatus},</if>
+            <if test="applyNumber != null">#{applyNumber},</if>
+            <if test="illustrate != null">#{illustrate},</if>
+            <if test="creatTime != null">#{creatTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSlOpendoorApply" parameterType="com.zd.smartlock.domain.SlOpendoorApply">
+        update sl_opendoor_apply
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="deptName != null">dept_name = #{deptName},</if>
+            <if test="userCode != null">user_code = #{userCode},</if>
+            <if test="userSex != null">user_sex = #{userSex},</if>
+            <if test="phonenumber != null">phonenumber = #{phonenumber},</if>
+            <if test="userId2 != null">user_id2 = #{userId2},</if>
+            <if test="userName2 != null">user_name2 = #{userName2},</if>
+            <if test="userCode2 != null">user_code2 = #{userCode2},</if>
+            <if test="userSex2 != null">user_sex2 = #{userSex2},</if>
+            <if test="phonenumber2 != null">phonenumber2 = #{phonenumber2},</if>
+            <if test="subjectId != null">subject_id = #{subjectId},</if>
+            <if test="subjectName != null">subject_name = #{subjectName},</if>
+            <if test="position != null">position = #{position},</if>
+            <if test="college != null">college = #{college},</if>
+            <if test="applyStatus != null">apply_status = #{applyStatus},</if>
+            <if test="applyNumber != null">apply_number = #{applyNumber},</if>
+            <if test="illustrate != null">illustrate = #{illustrate},</if>
+            <if test="creatTime != null">creat_time = #{creatTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSlOpendoorApplyById">
+        delete
+        from sl_opendoor_apply
+        where id = #{id}
+    </delete>
+
+    <delete id="deleteSlOpendoorApplyByIds">
+        delete from sl_opendoor_apply where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 126 - 0
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlSubjectRelationMapper.xml

@@ -0,0 +1,126 @@
+<?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.zd.smartlock.mapper.SlSubjectRelationMapper">
+
+    <resultMap type="com.zd.smartlock.domain.SlSubjectRelation" id="SlSubjectRelationResult">
+        <result property="id"    column="id"    />
+        <result property="subjectId"    column="subject_id"    />
+        <result property="subjectName"    column="subject_name"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="deptName"    column="dept_name"    />
+        <result property="lockRoomId"    column="lock_room_id"    />
+        <result property="lockCode"    column="lock_code"    />
+        <result property="roomLocation"    column="room_location"    />
+        <result property="roomName"    column="room_name"    />
+        <result property="userId"    column="user_id"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="creatTime"    column="creat_time"    />
+    </resultMap>
+
+    <sql id="selectSlSubjectRelationVo">
+        select id, subject_id, subject_name, dept_id, dept_name, lock_room_id, lock_code, room_location,room_name,user_id, create_by, creat_time from sl_subject_relation
+    </sql>
+    <sql id="selectSlSubjectRelationListVo">
+        select t.id, t.subject_id, t.subject_name, t.dept_id, t.dept_name, t.lock_room_id, t.lock_code, t.room_location, t.room_name, t.user_id, t.create_by, t.creat_time from sl_subject_relation as t
+    </sql>
+    <select id="selectSlSubjectRelationList" parameterType="com.zd.smartlock.domain.SlSubjectRelation" resultMap="SlSubjectRelationResult">
+        <include refid="selectSlSubjectRelationVo"/>
+        <where>
+            <if test="subjectId != null "> and subject_id = #{subjectId}</if>
+            <if test="subjectName != null  and subjectName != ''"> and subject_name like concat('%', #{subjectName}, '%')</if>
+            <if test="lockRoomId != null  and lockRoomId != ''"> and lock_room_id = #{lockRoomId}</if>
+            <if test="lockCode != null  and lockCode != ''"> and lock_code = #{lockCode}</if>
+            <if test="roomLocation != null  and roomLocation != ''"> and room_location = #{roomLocation}</if>
+            <if test="roomName != null  and roomName != ''"> and room_name = #{roomName}</if>
+            <if test="userId != null  "> and user_id = #{userId}</if>
+            <if test="creatTime != null "> and creat_time = #{creatTime}</if>
+        </where>
+    </select>
+
+    <select id="getListByIds" resultMap="SlSubjectRelationResult">
+        <include refid="selectSlSubjectRelationVo"/>
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="selectSlSubjectRelationById" resultMap="SlSubjectRelationResult">
+        <include refid="selectSlSubjectRelationVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertSlSubjectRelation" parameterType="com.zd.smartlock.domain.SlSubjectRelation" useGeneratedKeys="true" keyProperty="id">
+        insert into sl_subject_relation
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="subjectId != null">subject_id,</if>
+
+            <if test="subjectName != null">subject_name,</if>
+
+            <if test="deptId != null">dept_id,</if>
+
+            <if test="deptName != null">dept_name,</if>
+
+            <if test="lockRoomId != null">lock_room_id,</if>
+
+            <if test="lockCode != null">lock_code,</if>
+
+            <if test="roomLocation != null">room_location,</if>
+
+            <if test="roomName != null">room_name,</if>
+
+            <if test="userId != null">user_id,</if>
+
+            <if test="createBy != null">create_by,</if>
+
+            <if test="creatTime != null">creat_time,</if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="subjectId != null">#{subjectId},</if>
+            <if test="subjectName != null">#{subjectName},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="deptName != null">#{deptName},</if>
+            <if test="lockRoomId != null">#{lockRoomId},</if>
+            <if test="lockCode != null">#{lockCode},</if>
+            <if test="roomLocation != null">#{roomLocation},</if>
+            <if test="roomName != null">#{roomName},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="creatTime != null">#{creatTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSlSubjectRelation" parameterType="com.zd.smartlock.domain.SlSubjectRelation">
+        update sl_subject_relation
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="subjectId != null">subject_id = #{subjectId},</if>
+            <if test="subjectName != null">subject_name = #{subjectName},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="deptName != null">dept_name = #{deptName},</if>
+            <if test="lockRoomId != null">lock_room_id = #{lockRoomId},</if>
+            <if test="lockCode != null">lock_code = #{lockCode},</if>
+            <if test="roomLocation != null">room_location = #{roomLocation},</if>
+            <if test="roomName != null">room_name = #{roomName},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="creatTime != null">creat_time = #{creatTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSlSubjectRelationById">
+        delete from sl_subject_relation where id = #{id}
+    </delete>
+
+    <delete id="deleteSlSubjectRelationByIds">
+        delete from sl_subject_relation where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 107 - 0
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlUserRelationMapper.xml

@@ -0,0 +1,107 @@
+<?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.zd.smartlock.mapper.SlUserRelationMapper">
+
+    <resultMap type="com.zd.smartlock.domain.SlUserRelation" id="SlUserRelationResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="userName"    column="user_name"    />
+        <result property="deptId"    column="dept_id"    />
+        <result property="deptName"    column="dept_name"    />
+        <result property="lockUserCode"    column="lock_user_code"    />
+        <result property="type"    column="type"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="creatTime"    column="creat_time"    />
+    </resultMap>
+
+    <sql id="selectSlUserRelationVo">
+        select id, user_id, user_name, dept_id, dept_name, lock_user_code, type, create_by, creat_time from sl_user_relation
+    </sql>
+    <sql id="selectSlUserRelationListVo">
+        select t.id, t.user_id, t.user_name, t.dept_id, t.dept_name, t.lock_user_code, t.type, t.create_by, t.creat_time from sl_user_relation as t
+    </sql>
+    <select id="selectSlUserRelationList" parameterType="com.zd.smartlock.domain.SlUserRelation" resultMap="SlUserRelationResult">
+        <include refid="selectSlUserRelationVo"/>
+        <where>
+            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
+            <if test="lockUserCode != null  and lockUserCode != ''"> and lock_user_code = #{lockUserCode}</if>
+            <if test="type != null "> and type = #{type}</if>
+            <if test="creatTime != null "> and creat_time = #{creatTime}</if>
+        </where>
+    </select>
+
+    <select id="getListByIds" resultMap="SlUserRelationResult">
+        <include refid="selectSlUserRelationVo"/>
+        <where>
+            id in
+            <foreach item="id" collection="list" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
+    <select id="selectSlUserRelationById" resultMap="SlUserRelationResult">
+        <include refid="selectSlUserRelationVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertSlUserRelation" parameterType="com.zd.smartlock.domain.SlUserRelation" useGeneratedKeys="true" keyProperty="id">
+        insert into sl_user_relation
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+
+            <if test="userName != null">user_name,</if>
+
+            <if test="deptId != null">dept_id,</if>
+
+            <if test="deptName != null">dept_name,</if>
+
+            <if test="lockUserCode != null">lock_user_code,</if>
+
+            <if test="type != null">type,</if>
+
+            <if test="createBy != null">create_by,</if>
+
+            <if test="creatTime != null">creat_time,</if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="userName != null">#{userName},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="deptName != null">#{deptName},</if>
+            <if test="lockUserCode != null">#{lockUserCode},</if>
+            <if test="type != null">#{type},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="creatTime != null">#{creatTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateSlUserRelation" parameterType="com.zd.smartlock.domain.SlUserRelation">
+        update sl_user_relation
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="userName != null">user_name = #{userName},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="deptName != null">dept_name = #{deptName},</if>
+            <if test="lockUserCode != null">lock_user_code = #{lockUserCode},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="creatTime != null">creat_time = #{creatTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteSlUserRelationById">
+        delete from sl_user_relation where id = #{id}
+    </delete>
+
+    <delete id="deleteSlUserRelationByIds">
+        delete from sl_user_relation where id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>

+ 182 - 0
zd-modules/zd-smartlock/wait-for-it.sh

@@ -0,0 +1,182 @@
+#!/usr/bin/env bash
+# Use this script to test if a given TCP host/port are available
+
+WAITFORIT_cmdname=${0##*/}
+
+echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
+
+usage()
+{
+    cat << USAGE >&2
+Usage:
+    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
+    -h HOST | --host=HOST       Host or IP under test
+    -p PORT | --port=PORT       TCP port under test
+                                Alternatively, you specify the host and port as host:port
+    -s | --strict               Only execute subcommand if the test succeeds
+    -q | --quiet                Don't output any status messages
+    -t TIMEOUT | --timeout=TIMEOUT
+                                Timeout in seconds, zero for no timeout
+    -- COMMAND ARGS             Execute command with args after the test finishes
+USAGE
+    exit 1
+}
+
+wait_for()
+{
+    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
+        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
+    else
+        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
+    fi
+    WAITFORIT_start_ts=$(date +%s)
+    while :
+    do
+        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
+            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
+            WAITFORIT_result=$?
+        else
+            (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
+            WAITFORIT_result=$?
+        fi
+        if [[ $WAITFORIT_result -eq 0 ]]; then
+            WAITFORIT_end_ts=$(date +%s)
+            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
+            break
+        fi
+        sleep 1
+    done
+    return $WAITFORIT_result
+}
+
+wait_for_wrapper()
+{
+    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
+    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
+        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
+    else
+        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
+    fi
+    WAITFORIT_PID=$!
+    trap "kill -INT -$WAITFORIT_PID" INT
+    wait $WAITFORIT_PID
+    WAITFORIT_RESULT=$?
+    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
+        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
+    fi
+    return $WAITFORIT_RESULT
+}
+
+# process arguments
+while [[ $# -gt 0 ]]
+do
+    case "$1" in
+        *:* )
+        WAITFORIT_hostport=(${1//:/ })
+        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
+        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
+        shift 1
+        ;;
+        --child)
+        WAITFORIT_CHILD=1
+        shift 1
+        ;;
+        -q | --quiet)
+        WAITFORIT_QUIET=1
+        shift 1
+        ;;
+        -s | --strict)
+        WAITFORIT_STRICT=1
+        shift 1
+        ;;
+        -h)
+        WAITFORIT_HOST="$2"
+        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
+        shift 2
+        ;;
+        --host=*)
+        WAITFORIT_HOST="${1#*=}"
+        shift 1
+        ;;
+        -p)
+        WAITFORIT_PORT="$2"
+        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
+        shift 2
+        ;;
+        --port=*)
+        WAITFORIT_PORT="${1#*=}"
+        shift 1
+        ;;
+        -t)
+        WAITFORIT_TIMEOUT="$2"
+        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
+        shift 2
+        ;;
+        --timeout=*)
+        WAITFORIT_TIMEOUT="${1#*=}"
+        shift 1
+        ;;
+        --)
+        shift
+        WAITFORIT_CLI=("$@")
+        break
+        ;;
+        --help)
+        usage
+        ;;
+        *)
+        echoerr "Unknown argument: $1"
+        usage
+        ;;
+    esac
+done
+
+if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
+    echoerr "Error: you need to provide a host and port to test."
+    usage
+fi
+
+WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
+WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
+WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
+WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
+
+# Check to see if timeout is from busybox?
+WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
+WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
+
+WAITFORIT_BUSYTIMEFLAG=""
+if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
+    WAITFORIT_ISBUSY=1
+    # Check if busybox timeout uses -t flag
+    # (recent Alpine versions don't support -t anymore)
+    if timeout &>/dev/stdout | grep -q -e '-t '; then
+        WAITFORIT_BUSYTIMEFLAG="-t"
+    fi
+else
+    WAITFORIT_ISBUSY=0
+fi
+
+if [[ $WAITFORIT_CHILD -gt 0 ]]; then
+    wait_for
+    WAITFORIT_RESULT=$?
+    exit $WAITFORIT_RESULT
+else
+    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
+        wait_for_wrapper
+        WAITFORIT_RESULT=$?
+    else
+        wait_for
+        WAITFORIT_RESULT=$?
+    fi
+fi
+
+if [[ $WAITFORIT_CLI != "" ]]; then
+    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
+        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
+        exit $WAITFORIT_RESULT
+    fi
+    exec "${WAITFORIT_CLI[@]}"
+else
+    exit $WAITFORIT_RESULT
+fi