Explorar el Código

智能锁修改

liujh hace 3 años
padre
commit
0779453c6f
Se han modificado 25 ficheros con 711 adiciones y 350 borrados
  1. 3 0
      zd-common/zd-common-core/src/main/java/com/zd/common/core/domain/per/PerPrefix.java
  2. 8 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectController.java
  3. 7 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSubjectMapper.java
  4. 8 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabSubjectService.java
  5. 11 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectServiceImpl.java
  6. 9 1
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml
  7. 4 0
      zd-modules/zd-smartlock/pom.xml
  8. 7 7
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlApplyApprovalController.java
  9. 58 15
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlOpendoorApplyController.java
  10. 39 7
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlSubjectRelationController.java
  11. 36 6
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlOpendoorApply.java
  12. 22 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlSubjectRelation.java
  13. 7 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/api/SlLockOnline.java
  14. 19 9
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlOpendoorApplyVo.java
  15. 6 1
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlSubjectRelationVo.java
  16. 3 1
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlSubjectRelationMapper.java
  17. 8 0
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlOpendoorApplyService.java
  18. 1 1
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/ISlSubjectRelationService.java
  19. 28 13
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlApplyApprovalServiceImpl.java
  20. 21 5
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlOpendoorApplyServiceImpl.java
  21. 7 3
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlSubjectRelationServiceImpl.java
  22. 221 212
      zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/utils/SmartlockUtil.java
  23. 66 25
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlOpendoorApplyMapper.xml
  24. 72 26
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlSubjectRelationMapper.xml
  25. 40 18
      zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlUserRelationMapper.xml

+ 3 - 0
zd-common/zd-common-core/src/main/java/com/zd/common/core/domain/per/PerPrefix.java

@@ -701,4 +701,7 @@ public class PerPrefix {
 
     /**   ================================================气瓶申请流程的权限=====================================     */
     public static final String QP_USEGASAPPLY = "bottle:usegasapply:";
+
+    /*****************************智能门锁******************************/
+    public static final String SMARTLOCK_OPENDOORAPPLY = "smartlock:openDoorApply:";
 }

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectController.java

@@ -150,6 +150,14 @@ public class LabSubjectController extends BaseController {
     }
 
     /**
+     * 获取实验室详细信息
+     */
+    @GetMapping(value = "/vo/{id}")
+    public AjaxResult getVoInfo(@PathVariable("id") Long id) {
+        return AjaxResult.success(labSubjectService.selectLabSubjectVoById(id));
+    }
+
+    /**
      * 查询实验室
      *
      * @param id 实验室主键

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSubjectMapper.java

@@ -28,6 +28,13 @@ public interface LabSubjectMapper {
      */
     public LabSubject selectLabSubjectById(Long id);
 
+    /**
+     * 查询实验室
+     *
+     * @param id 实验室主键
+     * @return 实验室
+     */
+    public LabSubjectVO selectLabSubjectVoById(Long id);
 
     /**
      * 查询实验室

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabSubjectService.java

@@ -25,6 +25,14 @@ public interface ILabSubjectService {
     public LabSubject selectLabSubjectById(Long id);
 
     /**
+     * 查询实验室
+     *
+     * @param id 实验室主键
+     * @return 实验室
+     */
+    public LabSubjectVO selectLabSubjectVoById(Long id);
+
+    /**
      * 查询实验室检查项
      *
      * @param id 实验室主键

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectServiceImpl.java

@@ -65,6 +65,17 @@ public class LabSubjectServiceImpl implements ILabSubjectService {
         return labSubjectMapper.selectLabSubjectById(id);
     }
 
+    /**
+     * 查询实验室
+     *
+     * @param id 实验室主键
+     * @return 实验室
+     */
+    @Override
+    public LabSubjectVO selectLabSubjectVoById(Long id) {
+        return labSubjectMapper.selectLabSubjectVoById(id);
+    }
+
     @Override
     public LabSubject selectLabSubjectCheckById(Long id) {
         return labSubjectMapper.selectLabSubjectCheckById(id);

+ 9 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml

@@ -125,7 +125,10 @@
             create_by, update_time, update_by, remark, sub_dept,
             check_out, check_in, safe_user_id, safe_signs, hazard_category, risk_measure,
             outfire, qr_code,safe_user_id, skipped, check_count,sign_time,
-	        (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id, s.`safe_user_id`)) AS safeUserNames
+	        (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id, s.`safe_user_id`)) AS safeUserNames,
+            (select d.dept_name from sys_dept d where s.build_id = d.dept_id) build_name,
+            (select b.name from lab_building b where b.id = s.floor_id) floorName,
+            (SELECT l.room FROM lab_subject_layout l WHERE l.id = s.layout_id ) roomName
         from lab_subject s
     </sql>
     <sql id="selectLabSubjectListVo">
@@ -349,6 +352,11 @@
         where id = #{id}
     </select>
 
+    <select id="selectLabSubjectVoById" parameterType="Long" resultMap="LabSubjectResultVO">
+        <include refid="selectLabSubjectVo"/>
+        where id = #{id}
+    </select>
+
     <insert id="insertLabSubject" parameterType="com.zd.laboratory.domain.LabSubject">
         insert into lab_subject
         <trim prefix="(" suffix=")" suffixOverrides=",">

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

@@ -83,6 +83,10 @@
             <groupId>com.zd</groupId>
             <artifactId>zd-common-resultdata</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.zd</groupId>
+            <artifactId>zd-common-datascope</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

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

@@ -23,7 +23,7 @@ import java.io.IOException;
 import java.util.List;
 
 /**
- * 人员关联Controller
+ * 门锁申请审核Controller
  *
  * @author zd
  * @date 2022-09-02
@@ -39,7 +39,7 @@ public class SlApplyApprovalController extends BaseController
     /**
      * 查询申请审核列表
      */
-    @PreAuthorize(hasPermi = "laboratory:approval:list")
+    //@PreAuthorize(hasPermi = "laboratory:approval:list")
     @GetMapping("/list")
     @ApiOperation(value = "查询申请审核列表")
     public TableDataInfo<SlApplyApproval> list(SlApplyApproval slApplyApproval)
@@ -53,7 +53,7 @@ public class SlApplyApprovalController extends BaseController
      * 导出申请审核列表
      */
     @ApiOperation(value = "导出申请审核列表")
-    @PreAuthorize(hasPermi = "laboratory:approval:export")
+    //@PreAuthorize(hasPermi = "laboratory:approval:export")
     @Log(title = "申请审核", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, SlApplyApproval slApplyApproval) throws IOException
@@ -67,7 +67,7 @@ public class SlApplyApprovalController extends BaseController
      * 获取申请审核详细信息
      */
     @ApiOperation(value = "获取申请审核详细信息")
-    @PreAuthorize(hasPermi = "laboratory:approval:query")
+    //@PreAuthorize(hasPermi = "laboratory:approval:query")
     @GetMapping(value = "/{id}")
     public ResultData<SlApplyApproval> getInfo(@PathVariable("id") Long id)
     {
@@ -78,7 +78,7 @@ public class SlApplyApprovalController extends BaseController
      * 新增申请审核
      */
     @ApiOperation(value = "新增申请审核")
-    @PreAuthorize(hasPermi = "laboratory:approval:add")
+    //@PreAuthorize(hasPermi = "laboratory:approval:add")
     @Log(title = "申请审核", businessType = BusinessType.INSERT)
     @PostMapping
     public ResultData add(@RequestBody SlApplyApproval slApplyApproval)
@@ -90,7 +90,7 @@ public class SlApplyApprovalController extends BaseController
      * 修改申请审核
      */
     @ApiOperation(value = "修改申请审核")
-    @PreAuthorize(hasPermi = "laboratory:approval:edit")
+    //@PreAuthorize(hasPermi = "laboratory:approval:edit")
     @Log(title = "申请审核", businessType = BusinessType.UPDATE)
     @PutMapping
     public ResultData edit(@RequestBody SlApplyApproval slApplyApproval)
@@ -102,7 +102,7 @@ public class SlApplyApprovalController extends BaseController
      * 删除申请审核
      */
     @ApiOperation(value = "删除申请审核")
-    @PreAuthorize(hasPermi = "laboratory:approval:remove")
+    //@PreAuthorize(hasPermi = "laboratory:approval:remove")
     @Log(title = "申请审核", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public ResultData remove(@PathVariable Long[] ids)

+ 58 - 15
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlOpendoorApplyController.java

@@ -1,5 +1,8 @@
 package com.zd.smartlock.controller;
 
+import com.zd.common.core.domain.per.PerFun;
+import com.zd.common.core.domain.per.PerPrefix;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.utils.poi.ExcelUtil;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.common.core.web.page.TableDataInfo;
@@ -43,35 +46,62 @@ public class SlOpendoorApplyController extends BaseController
     /**
      * 查询申请开门列表
      */
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:list")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.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()))){
+                if(StringUtils.isNotEmpty(vo.getSafeUserId()) && vo.getSafeUserId().contains(String.valueOf(sysUser.getUserId()))){
                     vo.setSafe(true);
-                    break;
                 }else{
                     vo.setSafe(false);
                 }
-            }
         }
         return getDataTable(list);
     }
 
     /**
+     * 授权申请
+     */
+    //@PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ "applyList")
+    @GetMapping("/applyList")
+    @ApiOperation(value = "查询申请开门列表")
+    public TableDataInfo<SlOpendoorApplyVo> applylist(SlOpendoorApplyVo slOpendoorApply)
+    {
+        //获取登录用户
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        slOpendoorApply.setUserId(sysUser.getUserId());
+        startPage();
+        List<SlOpendoorApplyVo> list = slOpendoorApplyService.selectSlOpendoorApplyList(slOpendoorApply);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询申请开门列表(学生端)
+     */
+    @GetMapping("/listStudent")
+    @ApiOperation(value = "查询申请开门列表(学生端)")
+    public TableDataInfo<SlOpendoorApplyVo> listStudent(SlOpendoorApplyVo slOpendoorApply)
+    {
+        //获取登录用户
+        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+        slOpendoorApply.setUserId(sysUser.getUserId());
+
+        startPage();
+        List<SlOpendoorApplyVo> list = slOpendoorApplyService.selectSlOpendoorApplyListStudent(slOpendoorApply);
+        return getDataTable(list);
+    }
+
+    /**
      * 导出申请开门列表
      */
     @ApiOperation(value = "导出申请开门列表")
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:export")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.EXPORT)
     @Log(title = "申请开门", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, SlOpendoorApplyVo slOpendoorApply) throws IOException
@@ -85,7 +115,7 @@ public class SlOpendoorApplyController extends BaseController
      * 获取申请开门详细信息
      */
     @ApiOperation(value = "获取申请开门详细信息")
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:query")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.QUERY)
     @GetMapping(value = "/{id}")
     public ResultData<SlOpendoorApply> getInfo(@PathVariable("id") Long id)
     {
@@ -96,7 +126,7 @@ public class SlOpendoorApplyController extends BaseController
      * 新增申请开门
      */
     @ApiOperation(value = "新增申请开门")
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:add")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.ADD)
     @Log(title = "申请开门", businessType = BusinessType.INSERT)
     @PostMapping
     public ResultData add(@RequestBody SlOpendoorApply slOpendoorApply)
@@ -104,16 +134,30 @@ public class SlOpendoorApplyController extends BaseController
         /*user_id 申请人id
         user_id2 人员2 id
         subject_id 实验室id
-        subject_name 实验室名称 */
+        subject_name 实验室名称
+        position
+        */
+
+        return ResultData.result(slOpendoorApplyService.insertSlOpendoorApply(slOpendoorApply));
+    }
 
+    /**
+     * 新增申请开门
+     */
+    @ApiOperation(value = "新增申请开门")
+    @Log(title = "申请开门", businessType = BusinessType.INSERT)
+    @PostMapping("/addStudent")
+    public ResultData addStudent(@RequestBody SlOpendoorApply slOpendoorApply)
+    {
         return ResultData.result(slOpendoorApplyService.insertSlOpendoorApply(slOpendoorApply));
     }
 
+
     /**
      * 修改申请开门
      */
     @ApiOperation(value = "修改申请开门")
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:edit")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.EDIT)
     @Log(title = "申请开门", businessType = BusinessType.UPDATE)
     @PutMapping
     public ResultData edit(@RequestBody SlOpendoorApply slOpendoorApply)
@@ -125,7 +169,7 @@ public class SlOpendoorApplyController extends BaseController
      * 删除申请开门
      */
     @ApiOperation(value = "删除申请开门")
-    @PreAuthorize(hasPermi = "laboratory:openDoorApply:remove")
+    @PreAuthorize(hasPermi = PerPrefix.SMARTLOCK_OPENDOORAPPLY+ PerFun.REMOVE)
     @Log(title = "申请开门", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public ResultData remove(@PathVariable Long[] ids)
@@ -134,7 +178,6 @@ public class SlOpendoorApplyController extends BaseController
     }
 
     public static void main(String[] args) {
-        String str="9261403,9261430,9261402,9261416";
-        System.out.println(str.contains("9261403"));
+
     }
 }

+ 39 - 7
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/controller/SlSubjectRelationController.java

@@ -44,9 +44,20 @@ public class SlSubjectRelationController extends BaseController {
     @PreAuthorize(hasPermi = "laboratory:subjectRelation:list")
     @GetMapping("/list")
     @ApiOperation(value = "查询实验室关联列表")
-    public TableDataInfo<SlSubjectRelation> list(SlSubjectRelation slSubjectRelation) {
+    public TableDataInfo<SlSubjectRelationVo> list(SlSubjectRelationVo slSubjectRelation) {
         startPage();
-        List<SlSubjectRelation> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
+        List<SlSubjectRelationVo> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
+        return getDataTable(list);
+    }
+
+    /**
+     * 查询实验室关联列表-无权限
+     */
+    @GetMapping("/listSub")
+    @ApiOperation(value = "查询实验室关联列表")
+    public TableDataInfo<SlSubjectRelationVo> listSub(SlSubjectRelationVo slSubjectRelation) {
+        startPage();
+        List<SlSubjectRelationVo> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
         return getDataTable(list);
     }
 
@@ -57,9 +68,9 @@ public class SlSubjectRelationController extends BaseController {
     @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);
+    public void export(HttpServletResponse response, SlSubjectRelationVo slSubjectRelation) throws IOException {
+        List<SlSubjectRelationVo> list = slSubjectRelationService.selectSlSubjectRelationList(slSubjectRelation);
+        ExcelUtil<SlSubjectRelationVo> util = new ExcelUtil<SlSubjectRelationVo>(SlSubjectRelationVo.class);
         util.exportExcel(response, list, "实验室关联数据");
     }
 
@@ -92,6 +103,17 @@ public class SlSubjectRelationController extends BaseController {
     }
 
     /**
+     * 新增实验室关联-无权限
+     */
+    @ApiOperation(value = "新增实验室关联")
+    @Log(title = "实验室关联", businessType = BusinessType.INSERT)
+    @PostMapping("/addSub")
+    public ResultData addSub(@RequestBody SlSubjectRelationVo vo) {
+
+        return ResultData.result(slSubjectRelationService.insertSlSubjectRelation(vo));
+    }
+
+    /**
      * 修改实验室关联
      */
     @ApiOperation(value = "修改实验室关联")
@@ -106,6 +128,16 @@ public class SlSubjectRelationController extends BaseController {
      * 删除实验室关联
      */
     @ApiOperation(value = "删除实验室关联")
+    @Log(title = "实验室关联", businessType = BusinessType.DELETE)
+    @DeleteMapping("/removeSub/{ids}")
+    public ResultData removeSub(@PathVariable Long[] ids) {
+        return ResultData.result(slSubjectRelationService.deleteSlSubjectRelationByIds(ids));
+    }
+
+    /**
+     * 删除实验室关联
+     */
+    @ApiOperation(value = "删除实验室关联")
     @PreAuthorize(hasPermi = "laboratory:subjectRelation:remove")
     @Log(title = "实验室关联", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
@@ -131,9 +163,9 @@ public class SlSubjectRelationController extends BaseController {
     public TableDataInfo<SlLockOnline> lockListDetails(Long subjectId) {
         //List<SlRoom> list = SmartlockUtil.getRoom( slRoom);
         //查询实验室下绑定的门锁
-        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        SlSubjectRelationVo subjectRelation = new SlSubjectRelationVo();
         subjectRelation.setSubjectId(subjectId);
-        List<SlSubjectRelation> listrelation = slSubjectRelationService.selectSlSubjectRelationList(subjectRelation);
+        List<SlSubjectRelationVo> listrelation = slSubjectRelationService.selectSlSubjectRelationList(subjectRelation);
 
         List<SlLockOnline> onlineList = new ArrayList<>();
         for (SlSubjectRelation rl:listrelation) {

+ 36 - 6
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/SlOpendoorApply.java

@@ -67,7 +67,7 @@ public class SlOpendoorApply extends BaseEntity
     private Long applyNumber;
 
     /** 创建时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
     @ApiModelProperty(value = "创建时间")
     private Date creatTime;
@@ -111,7 +111,21 @@ public class SlOpendoorApply extends BaseEntity
     /** 审核完成时间 */
     @Excel(name = "审核完成时间 ")
     @ApiModelProperty(value = "审核完成时间 ")
-    private Date applyTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date approvalTime;
+
+    /** 审核人*/
+    @Excel(name = "审核人 ")
+    @ApiModelProperty(value = "审核人 ")
+    private String approvalUser;
+
+    /** 安全负责人*/
+    @Excel(name = "安全负责人 ")
+    @ApiModelProperty(value = "安全负责人 ")
+    private String safeUserName;
+
+    @ApiModelProperty(value = "实验室安全负责人ID集合")
+    private String safeUserId;
 
     public Long getId() {
         return id;
@@ -253,11 +267,27 @@ public class SlOpendoorApply extends BaseEntity
         this.phonenumber2 = phonenumber2;
     }
 
-    public Date getApplyTime() {
-        return applyTime;
+    public Date getApprovalTime() {
+        return approvalTime;
     }
 
-    public void setApplyTime(Date applyTime) {
-        this.applyTime = applyTime;
+    public void setApprovalTime(Date approvalTime) {
+        this.approvalTime = approvalTime;
     }
+
+    public String getApprovalUser() {
+        return approvalUser;
+    }
+
+    public void setApprovalUser(String approvalUser) {
+        this.approvalUser = approvalUser;
+    }
+
+    public String getSafeUserName() {        return safeUserName;    }
+
+    public void setSafeUserName(String safeUserName) {        this.safeUserName = safeUserName;    }
+
+    public String getSafeUserId() {        return safeUserId;    }
+
+    public void setSafeUserId(String safeUserId) {        this.safeUserId = safeUserId;    }
 }

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

@@ -59,6 +59,18 @@ public class SlSubjectRelation extends BaseEntity
     @ApiModelProperty(value = "房间名称")
     private String roomName;
 
+    /** 实验室位置 */
+    @Excel(name = "实验室位置")
+    @Length(message = "实验室位置长度不能超过255")
+    @ApiModelProperty(value = "实验室位置")
+    private String subjectLocation;
+
+    /** 学院 */
+    @Excel(name = "学院")
+    @Length(message = "学院长度不能超过255")
+    @ApiModelProperty(value = "学院")
+    private String college;
+
     private Long deptId;
 
     private String deptName;
@@ -142,4 +154,14 @@ public class SlSubjectRelation extends BaseEntity
 
     @Override
     public void setUserId(Long userId) {        this.userId = userId;    }
+
+    public String getSubjectLocation() {        return subjectLocation;    }
+
+    public void setSubjectLocation(String subjectLocation) {        this.subjectLocation = subjectLocation;    }
+
+    public String getCollege() {        return college;    }
+
+    public void setCollege(String college) {
+        this.college = college;
+    }
 }

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

@@ -14,6 +14,9 @@ public class SlLockOnline {
     @ApiModelProperty(value = "是否在线")
     private String onLine;
 
+    @ApiModelProperty(value = "1在线/0离线")
+    private Integer onLineStatus;
+
     @ApiModelProperty(value = "门锁编号")
     private String lockCode;
 
@@ -32,4 +35,8 @@ public class SlLockOnline {
     public void setLockCode(String lockCode) {
         this.lockCode = lockCode;
     }
+
+    public Integer getOnLineStatus() {        return onLineStatus;    }
+
+    public void setOnLineStatus(Integer onLineStatus) {        this.onLineStatus = onLineStatus;    }
 }

+ 19 - 9
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlOpendoorApplyVo.java

@@ -10,20 +10,17 @@ import io.swagger.annotations.ApiModelProperty;
  */
 public class SlOpendoorApplyVo extends SlOpendoorApply {
 
-    @ApiModelProperty(value = "实验室安全负责人集合")
-    private String safeUserId;
-
     @ApiModelProperty(value = "是否安全负责人")
     private Boolean safe;
 
+    @ApiModelProperty(value = "审批人集合")
+    private String examineName;
 
-    public String getSafeUserId() {
-        return safeUserId;
-    }
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
 
-    public void setSafeUserId(String safeUserId) {
-        this.safeUserId = safeUserId;
-    }
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
 
     public Boolean getSafe() {
         return safe;
@@ -32,4 +29,17 @@ public class SlOpendoorApplyVo extends SlOpendoorApply {
     public void setSafe(Boolean safe) {
         this.safe = safe;
     }
+
+    public String getExamineName() {        return examineName;    }
+
+    public void setExamineName(String examineName) {        this.examineName = examineName;    }
+
+
+    public String getStartTime() {        return startTime;    }
+
+    public void setStartTime(String startTime) {        this.startTime = startTime;    }
+
+    public String getEndTime() {        return endTime;    }
+
+    public void setEndTime(String endTime) {        this.endTime = endTime;    }
 }

+ 6 - 1
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/domain/vo/SlSubjectRelationVo.java

@@ -1,6 +1,7 @@
 package com.zd.smartlock.domain.vo;
 
 import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.api.SlLockOnline;
 
 import java.util.List;
 
@@ -13,9 +14,13 @@ public class SlSubjectRelationVo extends SlSubjectRelation {
 
     private List<SlSubjectRelation> slSubjectList;
 
-
+    private SlLockOnline slLockOnline;
 
     public List<SlSubjectRelation> getSlSubjectList() {        return slSubjectList;    }
 
     public void setSlSubjectList(List<SlSubjectRelation> slSubjectList) {        this.slSubjectList = slSubjectList;    }
+
+    public SlLockOnline getSlLockOnline() {        return slLockOnline;    }
+
+    public void setSlLockOnline(SlLockOnline slLockOnline) {        this.slLockOnline = slLockOnline;    }
 }

+ 3 - 1
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/mapper/SlSubjectRelationMapper.java

@@ -1,6 +1,8 @@
 package com.zd.smartlock.mapper;
 
 import com.zd.smartlock.domain.SlSubjectRelation;
+import com.zd.smartlock.domain.vo.SlSubjectRelationVo;
+
 import java.util.List;
 
 /**
@@ -24,7 +26,7 @@ public interface SlSubjectRelationMapper {
      * @param slSubjectRelation 实验室关联
      * @return 实验室关联集合
      */
-    List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation);
+    List<SlSubjectRelationVo> selectSlSubjectRelationList(SlSubjectRelationVo slSubjectRelation);
 
     /**
      * 根据主键集合查询实验室关联列表

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

@@ -31,6 +31,14 @@ public interface ISlOpendoorApplyService
     List<SlOpendoorApplyVo> selectSlOpendoorApplyList(SlOpendoorApplyVo slOpendoorApply);
 
     /**
+     * 查询申请开门列表-学生端
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 申请开门集合
+     */
+    List<SlOpendoorApplyVo> selectSlOpendoorApplyListStudent(SlOpendoorApplyVo slOpendoorApply);
+
+    /**
      * 根据主键集合查询申请开门列表
      *
      * @param ids 主键集合

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

@@ -27,7 +27,7 @@ public interface ISlSubjectRelationService
      * @param slSubjectRelation 实验室关联
      * @return 实验室关联集合
      */
-    List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation);
+    List<SlSubjectRelationVo> selectSlSubjectRelationList(SlSubjectRelationVo slSubjectRelation);
 
     /**
      * 根据主键集合查询实验室关联列表

+ 28 - 13
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlApplyApprovalServiceImpl.java

@@ -7,6 +7,7 @@ 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.domain.vo.SlSubjectRelationVo;
 import com.zd.smartlock.mapper.SlApplyApprovalMapper;
 import com.zd.smartlock.mapper.SlOpendoorApplyMapper;
 import com.zd.smartlock.mapper.SlSubjectRelationMapper;
@@ -108,21 +109,23 @@ public class SlApplyApprovalServiceImpl implements ISlApplyApprovalService
         //通过
         if(slApplyApproval.getApprovaStatus()==1){
             opendoorApply.setApplyNumber(opendoorApply.getApplyNumber()+1);
-
             //审核通过,下发密码(第二次,审核通过的情况下)
             if(opendoorApply.getApplyNumber()==2){
-                opendoorApply.setApplyTime(new Date());
+                //审核通过,刷新审核状态
+                opendoorApply.setApplyStatus(2L);
                 //审核通过后,添加人员并且授权
                 authPower(opendoorApply.getId());
             }
         }else if(slApplyApproval.getApprovaStatus()==2){
             //驳回
             opendoorApply.setApplyNumber(opendoorApply.getApplyNumber()+1);
-            opendoorApply.setApplyTime(new Date());
             //修改申请表状态
             opendoorApply.setApplyStatus(3L);
         }
         //申请表操作
+        opendoorApply.setApprovalTime(new Date());
+        opendoorApply.setApprovalUser(sysUser.getNickName());
+
         slOpendoorApplyMapper.updateSlOpendoorApply(opendoorApply);
         return slApplyApprovalMapper.insertSlApplyApproval(slApplyApproval);
     }
@@ -172,12 +175,16 @@ public class SlApplyApprovalServiceImpl implements ISlApplyApprovalService
      */
     public int authPower(Long applyId){
 
+        //人员1 授权结果
+        Boolean auths1=false;
+        //人员2授权结果
+        Boolean auths2=false;
         //查询申请记录
         SlOpendoorApply opendoorApply = slOpendoorApplyMapper.selectSlOpendoorApplyById(applyId);
 
-        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        SlSubjectRelationVo subjectRelation = new SlSubjectRelationVo();
         subjectRelation.setSubjectId(opendoorApply.getSubjectId());
-        List<SlSubjectRelation>  listsubRla = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+        List<SlSubjectRelationVo>  listsubRla = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
         if(listsubRla.size()!=2){
             throw  new ServiceException("该实验室暂未绑定双锁!");
         }
@@ -194,11 +201,13 @@ public class SlApplyApprovalServiceImpl implements ISlApplyApprovalService
         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");
+        if(!SmartlockUtil.resultMsg.equals(map1.get("resultMsg").toString())){
+            throw  new ServiceException("人员:"+opendoorApply.getUserName()+",授权失败,请联系管理员");
+        }else {
+            auths1=true;
         }
+
+
         //人员1 备注详情
         detalisMap.put("人员1",opendoorApply.getUserName());
         detalisMap.put("锁编1号",listsubRla.get(0).getLockCode());
@@ -214,10 +223,16 @@ public class SlApplyApprovalServiceImpl implements ISlApplyApprovalService
         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");
+        if(!SmartlockUtil.resultMsg.equals(map2.get("resultMsg").toString())){
+            throw  new ServiceException("人员:"+opendoorApply.getUserName()+",授权失败,请联系管理员");
+        }else {
+            auths2=true;
+        }
+
+        //人员入住办理成功,发送短信提示
+        if(auths1 && auths2){
+            String msg1="开门申请成功,门锁编号:"+listsubRla.get(0).getLockCode()+"密码:"+map1.get("password");
+            String msg2="开门申请成功,门锁编号:"+listsubRla.get(1).getLockCode()+"密码:"+map1.get("password");
         }
 
         //人员1 备注详情

+ 21 - 5
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlOpendoorApplyServiceImpl.java

@@ -1,13 +1,16 @@
 package com.zd.smartlock.service.impl;
 
 import com.zd.common.core.domain.R;
+import com.zd.common.core.domain.per.PerPrefix;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.StringUtils;
+import com.zd.common.datascope.annotation.DataScope;
 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.domain.vo.SlSubjectRelationVo;
 import com.zd.smartlock.mapper.SlOpendoorApplyMapper;
 import com.zd.smartlock.mapper.SlSubjectRelationMapper;
 import com.zd.smartlock.mapper.SlUserRelationMapper;
@@ -63,11 +66,23 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService
      * @return 申请开门
      */
     @Override
+    @DataScope(deptAlias = "d", userAlias = "u", permi = PerPrefix.SMARTLOCK_OPENDOORAPPLY)
     public List<SlOpendoorApplyVo> selectSlOpendoorApplyList(SlOpendoorApplyVo slOpendoorApply)
     {
         return slOpendoorApplyMapper.selectSlOpendoorApplyList(slOpendoorApply);
     }
 
+    /**
+     * 查询申请开门列表-学生端
+     *
+     * @param slOpendoorApply 申请开门
+     * @return 申请开门集合
+     */
+    @Override
+    public List<SlOpendoorApplyVo> selectSlOpendoorApplyListStudent(SlOpendoorApplyVo slOpendoorApply) {
+        return slOpendoorApplyMapper.selectSlOpendoorApplyList(slOpendoorApply);
+    }
+
     @Override
     public List<SlOpendoorApply> getListByIds(List<Long> ids){
         if (ids.isEmpty()){
@@ -87,18 +102,19 @@ public class SlOpendoorApplyServiceImpl implements ISlOpendoorApplyService
     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();
+        SlSubjectRelationVo subjectRelation = new SlSubjectRelationVo();
         subjectRelation.setSubjectId(slOpendoorApply.getSubjectId());
-        List<SlSubjectRelation> subjectList = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+        List<SlSubjectRelationVo> subjectList = slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
         if(subjectList.size()<2){
             throw new ServiceException("该实验室关联门锁不足2个!");
         }
         //2.校验人员电话是否为空
+        if(StringUtils.isEmpty(sysUser.getPhonenumber())){
+            throw new ServiceException("申请人:"+sysUser.getNickName()+"电话为空!");
+        }
+
         R<SysUser> r = remoteUserService.getUserInfoByUserId(slOpendoorApply.getUserId2(),"inner");
         if(StringUtils.isEmpty(r.getData().getPhonenumber())){
             throw new ServiceException("申请人:"+r.getData().getNickName()+"电话为空!");

+ 7 - 3
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/service/impl/SlSubjectRelationServiceImpl.java

@@ -2,6 +2,7 @@ package com.zd.smartlock.service.impl;
 
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.SecurityUtils;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.security.service.TokenService;
 import com.zd.common.security.utils.SaveUtil;
 import com.zd.smartlock.domain.SlSubjectRelation;
@@ -54,7 +55,7 @@ public class SlSubjectRelationServiceImpl implements ISlSubjectRelationService
      * @return 实验室关联
      */
     @Override
-    public List<SlSubjectRelation> selectSlSubjectRelationList(SlSubjectRelation slSubjectRelation)
+    public List<SlSubjectRelationVo> selectSlSubjectRelationList(SlSubjectRelationVo slSubjectRelation)
     {
         return slSubjectRelationMapper.selectSlSubjectRelationList(slSubjectRelation);
     }
@@ -83,10 +84,13 @@ public class SlSubjectRelationServiceImpl implements ISlSubjectRelationService
         }
         System.out.println(SecurityUtils.getUsername());
         //校验本次提交是否存在已绑定情况
-        SlSubjectRelation subjectRelation = new SlSubjectRelation();
+        SlSubjectRelationVo subjectRelation = new SlSubjectRelationVo();
         for (SlSubjectRelation sl:list ) {
+            if(StringUtils.isEmpty(sl.getLockCode())){
+                throw new ServiceException("房间: "+sl.getRoomName()+",位置: "+sl.getRoomLocation()+"未绑定门锁。");
+            }
             subjectRelation.setLockRoomId(sl.getLockRoomId());
-            List<SlSubjectRelation> sellist=  slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
+            List<SlSubjectRelationVo> sellist=  slSubjectRelationMapper.selectSlSubjectRelationList(subjectRelation);
             if(sellist.size()>0){
                 throw new ServiceException("房间: "+sl.getRoomName()+",位置: "+sl.getRoomLocation()+"已被绑定。");
             }

+ 221 - 212
zd-modules/zd-smartlock/src/main/java/com/zd/smartlock/utils/SmartlockUtil.java

@@ -22,32 +22,31 @@ import java.util.*;
 public class SmartlockUtil {
     private static final Logger logger = LoggerFactory.getLogger(SmartlockUtil.class);
 
-    private  static  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    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 serviceurl = "http://192.168.1.66/info";
 
     /**
      * 智能锁返回成功字符描述
      */
-    public final  static  String  resultMsg="ok";
+    public final static String resultMsg = "ok";
 
     /***
      * 登陆账户
      */
-    public final static String userlogin="admin";
+    public final static String userlogin = "admin";
 
     /***
      * 登陆密码
      */
-    public final static String password="admin123";
+    public final static String password = "admin123";
 
 
-
-    public static HttpRequest httpSendPost(String url,String json){
-       return HttpRequest.post(url)
+    public static HttpRequest httpSendPost(String url, String json) {
+        return HttpRequest.post(url)
                 .header("Content-Type", "application/json")
                 .body(json);
     }
@@ -57,158 +56,161 @@ public class SmartlockUtil {
      * 获取token
      * @return
      */
-    public  static  String getToken(){
-        String token=null;
-        String url =serviceurl+ "/login/1/gettoken?userlogin="+userlogin+"&password="+password;
+    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();
+            String resultMsg = JSON.parseObject(response.body()).get("resultMsg").toString();
             //请求是否成功
-            if(SmartlockUtil.resultMsg.equals(resultMsg)){
+            if (SmartlockUtil.resultMsg.equals(resultMsg)) {
                 token = JSON.parseObject(JSON.parseObject(response.body()).get("result").toString()).get("token").toString();
-            }else {
-                logger.error("智能锁获取token失败:"+resultMsg);
+            } else {
+                logger.error("智能锁获取token失败:" + resultMsg);
             }
-        }catch (Exception e){
-            logger.error("获取token失败:"+e);
+        } catch (Exception e) {
+            logger.error("获取token失败:" + e);
         }
         System.out.println(token);
-       return token;
+        return token;
     }
 
     /**
      * 获取顶级建筑
      */
-    public static SlBuild getTopBuild(){
+    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,"");
+            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);
+            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);
+        } catch (Exception e) {
+            logger.error("获取顶级建筑失败:" + e);
         }
         return slBuild;
     }
 
     /**
      * 查询房间
+     *
      * @param
      * @return
      */
-    public static List<SlRoom> getRoom(SlRoom room){
+    public static List<SlRoom> getRoom(SlRoom room) {
         SlBuild slBuild = null;
-        String token =  SmartlockUtil.getToken();
-        List<SlRoom> listRoom= new ArrayList<>();
+        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,"");
+            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);
+            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);
+            List<SlBuild> listLc = JSON.parseArray(data, SlBuild.class);
             System.out.println(listLc.size());
-            for (SlBuild build:listLc) {
-                if("3".equals(build.getBuildtype())){
+            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,"");
+            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);
+            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<>();
+    public static List<SlUser> getUser(SlUser sluser) {
+        List<SlUser> list = new ArrayList<>();
         try {
-            String token =  SmartlockUtil.getToken();
+            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,"");
+            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);
+            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);
+            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;
+    public static SlLockOnline getRoomDetails(String roomId) {
+        SlLockOnline lockOnline = new SlLockOnline();
         try {
-            if(StringUtils.isEmpty(roomId)){
+            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,"");
+            String token = SmartlockUtil.getToken();
+            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);
+            if (!SmartlockUtil.resultMsg.equals(resultMsg)) {
+                logger.error("获取房间详情失败1:" + resultMsg);
                 return lockOnline;
             }
             String str = response.body();
+            //System.out.println(str);
             //在线状态
             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);
+            lockOnline.setOnLineStatus("在线".equals(roomnetquality)?1:0);
+            System.out.println("房间详情,门锁状态 roomnetquality: " + roomnetquality + " lockCode: " + lockCode);
+        } catch (Exception e) {
+            logger.error("获取房间详情失败2:" + e);
         }
         return lockOnline;
     }
@@ -217,68 +219,69 @@ public class SmartlockUtil {
      * 开门记录
      * @param openDoorSearch
      */
-    public static List<SlOpenAndClosLog> getOpenDoorLog(SlOpenDoorSearch openDoorSearch){
-        List<SlOpenAndClosLog> list =new ArrayList<>();
+    public static List<SlOpenAndClosLog> getOpenDoorLog(SlOpenDoorSearch openDoorSearch) {
+        List<SlOpenAndClosLog> list = new ArrayList<>();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         try {
-            String token =  SmartlockUtil.getToken();
+            String token = SmartlockUtil.getToken();
 
-            if(StringUtils.isEmpty(openDoorSearch.getRoomid())){
-                logger.error("查询开门记录集合失败,roomid为空:"+resultMsg);
+            if (StringUtils.isEmpty(openDoorSearch.getRoomid())) {
+                logger.error("查询开门记录集合失败,roomid为空:" + resultMsg);
                 return list;
             }
-            if(StringUtils.isEmpty(openDoorSearch.getRecordtype())){
+            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";
+            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,"");
+            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);
+            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);
+            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();
+    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,"");
+            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);
+            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);
+            list = JSON.parseArray(data, SlGroup.class);
+        } catch (Exception e) {
+            logger.error("查询组织信息失败:" + e);
         }
         return list;
     }
@@ -287,27 +290,28 @@ public class SmartlockUtil {
      * 添加人员并且办理入住
      * 返回操作状态
      */
-    public static Map<String,Object> addUser(SlUser user,String roomId){
-        List<SlGroup> listgroup =  getGroup(new SlGroup());
-        Map<String,Object> map = new HashMap<>();
+    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();
+            String token = SmartlockUtil.getToken();
 
             /*roomId="109";
-            user.setPersoncode("C014");//学号、工号
-            user.setPersonname("姓名014");//姓名
+            user.setPersoncode("C016");//学号、工号
+            user.setPersonname("姓名016");//姓名
             user.setPersonsex("1");//性别 (0=女,1=男)
-            user.setPersontype("1");//人员类别(1=学生,2=教职工,3=临时人员)*/
+            user.setPersontype("1");//人员类别(1=学生,2=教职工,3=临时人员
+            user.setPersonmobile("13039856924");//电话*/
 
             //查询人员是否存在
-            Boolean flg =  checkUserExis(user.getPersoncode(),"1",token);
-            if(!flg) {
+            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;
+                        "&personmobile=" + user.getPersonmobile() + "&persontype=" + user.getPersontype() + "&pgid=" + pgid + "&token=" + token;
                 HttpRequest request = SmartlockUtil.httpSendPost(url, "");
                 HttpResponse response = request.execute();
                 System.out.println(response.body());
@@ -321,22 +325,22 @@ public class SmartlockUtil {
                 }
 
                 //添加授权
-                map = addUserAuths(token,user.getPersoncode(), roomId);
-            }else{
+                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);
-               }
+                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);
+            map.put("resultMsg", resultMsg);
+        } catch (Exception e) {
+            logger.error("添加人员并且办理入住异常:" + e);
         }
         return map;
     }
@@ -347,38 +351,40 @@ public class SmartlockUtil {
      * @param roomId
      * @param authid
      */
-    public  static Map<String,Object> updateAuths(String token,String roomId,Integer authid){
-        Map<String,Object> map = new HashMap<>();
+    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 ));
+            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);
+            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<>();
+    public static Map<String, Object> addUserAuths(String token, String personcode, String roomId) {
+        Map<String, Object> map = new HashMap<>();
         try {
             //入住办理
             JSONObject json = new JSONObject();
@@ -395,98 +401,99 @@ public class SmartlockUtil {
             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)));
+            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 ));
+            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);
+            if (!SmartlockUtil.resultMsg.equals(resultMsg)) {
+                logger.error("人员添加后办理入住失败1:" + resultMsg);
+                map.put("resultMsg", resultMsg);
                 return map;
             }
             //密码
-            map.put("password",pw);
-        }catch (Exception e){
+            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);
-                }
+    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);
+        //入住办理
+        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 ));
+        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);
+        if (!SmartlockUtil.resultMsg.equals(resultMsg)) {
+            logger.error("人员添加后办理入住失败1:" + resultMsg);
+            map.put("resultMsg", resultMsg);
         }
         //密码
-        map.put("password",pw);
+        map.put("password", pw);
         //操作结果
-        map.put("resultMsg",resultMsg);
+        map.put("resultMsg", resultMsg);
 
 
     }
@@ -496,17 +503,17 @@ public class SmartlockUtil {
      * @param personcode 人员编码
      * @param cardtype 1(学生卡)/2(职工卡)/3(管理卡)/6(临时卡)/7(身份证)
      */
-    public static Boolean checkUserExis(String personcode,String cardtype,String token){
-        Boolean flg=false;
+    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,"");
+        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;
+        if (array.size() > 0) {
+            flg = true;
         }
         return flg;
     }
@@ -517,24 +524,24 @@ public class SmartlockUtil {
      * @param personcode
      * @return
      */
-    public static String checkUserAuthExis(String personcode,String token){
-        String authid=null;
+    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,"");
+        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();
+        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;
             }
         }
@@ -543,10 +550,11 @@ public class SmartlockUtil {
 
     /**
      * 当前时间加 N 小时
+     *
      * @param num
      * @return
      */
-    public static Date getTime(int num){
+    public static Date getTime(int num) {
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
         cal.add(Calendar.HOUR, num);
@@ -555,10 +563,11 @@ public class SmartlockUtil {
 
     /**
      * 获取6位随机数
+     *
      * @param length
      * @return
      */
-    public static String getRandom(int length){
+    public static String getRandom(int length) {
         String val = "";
         Random random = new Random();
         for (int i = 0; i < length; i++) {
@@ -593,16 +602,16 @@ public class SmartlockUtil {
 
         //addUser(new SlUser() , "");
 
-       // AuthCheckIn(new SlUser() , "");
+        // AuthCheckIn(new SlUser() , "");
 
-        addUser(new SlUser() , "");
+         addUser(new SlUser() , "");
 
         // System.out.println(checkUserExis("C008","1"));
 
         //String token =  SmartlockUtil.getToken();
         //updateAuths( token,"109", 32);
 
-
+        //getRoomDetails("109");
 
     }
 }

+ 66 - 25
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlOpendoorApplyMapper.xml

@@ -20,12 +20,15 @@
         <result property="phonenumber2" column="phonenumber2"/>
         <result property="subjectId" column="subject_id"/>
         <result property="subjectName" column="subject_name"/>
+        <result property="safeUserId" column="safe_user_id"/>
+        <result property="safeUserName" column="safe_user_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="approvalUser" column="approval_user"/>
+        <result property="approvalTime" column="approval_time"/>
         <result property="creatTime" column="creat_time"/>
     </resultMap>
 
@@ -45,14 +48,17 @@
                phonenumber2,
                subject_id,
                subject_name,
+               safe_user_id,
+               safe_user_name,
                position,
                college,
                apply_status,
                apply_number,
                illustrate,
-               apply_time,
+               approval_user,
+               approval_time,
                creat_time
-        from sl_opendoor_apply
+        from sl_opendoor_apply t
     </sql>
     <sql id="selectSlOpendoorApplyListVo">
         select t.id,
@@ -70,44 +76,63 @@
                t.phonenumber,
                t.subject_id,
                t.subject_name,
+               t.safe_user_id,
+               t.safe_user_name,
                t.position,
                t.college,
                t.apply_status,
                t.apply_number,
                t.illustrate,
-               t.apply_time,
+               t.approval_user,
+               t.approval_time,
                t.creat_time,
-               (select safe_user_id from lab_subject s where s.id=t.subject_id) safe_user_id
+               (SELECT GROUP_CONCAT(aa.approva_name) FROM sl_apply_approval aa WHERE aa.apply_id=t.id) AS examineName
         from sl_opendoor_apply as t
+        LEFT JOIN   sys_dept d on   t.dept_id=d.dept_id
+        LEFT JOIN sys_user u on  t.user_id=u.user_id
     </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="userId != null ">and t.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 test="deptId != null ">and t.dept_id = #{deptId}</if>
+            <if test="deptName != null ">and t.dept_name = #{deptName}</if>
+            <if test="userCode != null ">and t.user_code = #{userCode}</if>
+            <if test="userSex != null ">and t.user_sex = #{userSex}</if>
+            <if test="phonenumber != null ">and t.phonenumber = #{phonenumber}</if>
+            <if test="userId2 != null ">and t.user_id2 = #{userId2}</if>
+            <if test="userName2 != null  and userName2 != ''">and t.user_name2 = #{userName2}</if>
+            <if test="userCode2 != null ">and t.user_code2 = #{userCode2}</if>
+            <if test="userSex2 != null ">and t.user_sex2 = #{userSex2}</if>
+            <if test="phonenumber2 != null ">and t.phonenumber2 = #{phonenumber2}</if>
+            <if test="subjectId != null ">and t.subject_id = #{subjectId}</if>
+            <if test="subjectName != null  and subjectName != ''">and t.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>
+            <if test="safeUserId != null  and position != ''">and t.safe_user_id = #{safeUserId}</if>
+            <if test="safeUserName != null  and position != ''">and t.safe_user_name = #{safeUserName}</if>
+            <if test="position != null  and position != ''">and t.position = #{position}</if>
+            <if test="college != null  and college != ''">and t.college = #{college}</if>
+            <if test="applyStatus != null ">and t.apply_status = #{applyStatus}</if>
+            <if test="applyNumber != null ">and t.apply_number = #{applyNumber}</if>
+            <if test="illustrate != null ">and t.illustrate = #{illustrate}</if>
+            <if test="approvalUser != null ">and t.approval_user = #{approvalUser}</if>
+            <if test="approvalTime != null ">and t.approval_time = #{approvalTime}</if>
+            <if test="creatTime != null ">and t.creat_time = #{creatTime}</if>
+            <if test="searchValue != null and searchValue != ''">
+                and
+                (t.user_name like concat('%', #{searchValue}, '%') or
+                t.user_name2 like concat('%', #{searchValue}, '%') or
+                t.subject_name like concat('%', #{searchValue}, '%')
+                )
+            </if>
+            <if test="startTime != null "> and date_format(t.creat_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')</if>
+            <if test="endTime != null "> and date_format(t.creat_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')</if>
         </where>
+        <!-- 数据范围过滤 -->
+        ${params.dataScope}
     </select>
 
     <select id="getListByIds" resultMap="SlOpendoorApplyResult">
@@ -157,6 +182,10 @@
 
             <if test="subjectName != null">subject_name,</if>
 
+            <if test="safeUserId != null">safe_user_id,</if>
+
+            <if test="safeUserName != null">safe_user_name,</if>
+
             <if test="position != null">position,</if>
 
             <if test="college != null">college,</if>
@@ -167,6 +196,10 @@
 
             <if test="illustrate != null">illustrate,</if>
 
+            <if test="approvalUser != null">approval_user,</if>
+
+            <if test="approvalTime != null">approval_time,</if>
+
             <if test="creatTime != null">creat_time,</if>
 
         </trim>
@@ -185,11 +218,15 @@
             <if test="phonenumber2 != null">#{phonenumber2},</if>
             <if test="subjectId != null">#{subjectId},</if>
             <if test="subjectName != null">#{subjectName},</if>
+            <if test="safeUserId != null">#{safeUserId},</if>
+            <if test="safeUserName != null">#{safeUserName},</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="approvalUser != null">#{approval_user},</if>
+            <if test="approvalTime != null">#{approval_time},</if>
             <if test="creatTime != null">#{creatTime},</if>
         </trim>
     </insert>
@@ -211,11 +248,15 @@
             <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="safeUserId != null">safe_user_id = #{safeUserId},</if>
+            <if test="safeUserName != null">safe_user_name = #{safeUserName},</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="approvalUser != null">approval_user = #{approvalUser},</if>
+            <if test="approvalTime != null">approval_time = #{approvalTime},</if>
             <if test="creatTime != null">creat_time = #{creatTime},</if>
         </trim>
         where id = #{id}

+ 72 - 26
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlSubjectRelationMapper.xml

@@ -4,38 +4,73 @@
         "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 type="com.zd.smartlock.domain.vo.SlSubjectRelationVo" id="SlSubjectRelationResult">
+        <result property="id" column="id"/>
+        <result property="subjectId" column="subject_id"/>
+        <result property="subjectName" column="subject_name"/>
+        <result property="subjectLocation" column="subject_location"/>
+        <result property="college" column="college"/>
+        <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
+        select id,
+               subject_id,
+               subject_name,
+               subject_location,
+               college,
+               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
+        select t.id,
+               t.subject_id,
+               t.subject_name,
+               t.subject_location,
+               t.college,
+               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">
+    <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>
+            <if test="subjectId != null ">and subject_id = #{subjectId}</if>
+            <if test="subjectName != null  and subjectName != ''">and subject_name like concat('%', #{subjectName},
+                '%')
+            </if>
+            <if test="subjectLocation != null  and subjectLocation != ''">and subject_location = #{subjectLocation}</if>
+            <if test="college != null  and college != ''">and college = #{college}</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>
 
@@ -54,13 +89,18 @@
         where id = #{id}
     </select>
 
-    <insert id="insertSlSubjectRelation" parameterType="com.zd.smartlock.domain.SlSubjectRelation" useGeneratedKeys="true" keyProperty="id">
+    <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="subjectLocation != null">subject_location,</if>
+
+            <if test="college != null">college,</if>
+
             <if test="deptId != null">dept_id,</if>
 
             <if test="deptName != null">dept_name,</if>
@@ -83,6 +123,8 @@
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="subjectId != null">#{subjectId},</if>
             <if test="subjectName != null">#{subjectName},</if>
+            <if test="subjectLocation != null">#{subjectLocation},</if>
+            <if test="college != null">#{college},</if>
             <if test="deptId != null">#{deptId},</if>
             <if test="deptName != null">#{deptName},</if>
             <if test="lockRoomId != null">#{lockRoomId},</if>
@@ -100,6 +142,8 @@
         <trim prefix="SET" suffixOverrides=",">
             <if test="subjectId != null">subject_id = #{subjectId},</if>
             <if test="subjectName != null">subject_name = #{subjectName},</if>
+            <if test="subjectLocation != null">subject_location = #{subjectLocation},</if>
+            <if test="college != null">college = #{college},</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>
@@ -114,7 +158,9 @@
     </update>
 
     <delete id="deleteSlSubjectRelationById">
-        delete from sl_subject_relation where id = #{id}
+        delete
+        from sl_subject_relation
+        where id = #{id}
     </delete>
 
     <delete id="deleteSlSubjectRelationByIds">

+ 40 - 18
zd-modules/zd-smartlock/src/main/resources/mapper/smartlock/SlUserRelationMapper.xml

@@ -5,30 +5,49 @@
 <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"    />
+        <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
+        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
+        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">
+    <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>
+            <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>
 
@@ -47,7 +66,8 @@
         where id = #{id}
     </select>
 
-    <insert id="insertSlUserRelation" parameterType="com.zd.smartlock.domain.SlUserRelation" useGeneratedKeys="true" keyProperty="id">
+    <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>
@@ -95,7 +115,9 @@
     </update>
 
     <delete id="deleteSlUserRelationById">
-        delete from sl_user_relation where id = #{id}
+        delete
+        from sl_user_relation
+        where id = #{id}
     </delete>
 
     <delete id="deleteSlUserRelationByIds">