whyclxw
2025-03-24 c11c504814895116a71d8067c76b931fc9dd2ab9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.whyc.service;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.LockBlMapper;
import com.whyc.pojo.db_area.LockBl;
import com.whyc.pojo.db_area.LockInf;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Service
public class LockBlService {
    @Autowired(required = false)
    private LockBlMapper mapper;
 
    @Autowired(required = false)
    private AreaInfService areaInfService;
 
    //设定锁的蓝牙开启时间段
    public Response setLockBl( List<LockBl> list) {
        for (LockBl lockBl : list) {
            lockBl.setCreateTime(new Date());
            lockBl.setType(1);//默认开启
            mapper.insert(lockBl);
        }
        return new Response().set(1,true,"设定锁的蓝牙开启时间段");
    }
   //查询锁的蓝牙开启时间段记录
    public Response getLockBl(Integer areaId, String lockName, Integer type, Integer pageNum, Integer pageSize) {
        List<Integer> areaList=new ArrayList();
        areaList.add(areaId);
        areaInfService.getAllAreaId(areaId,areaList);
        PageHelper.startPage(pageNum,pageSize);
        List<LockBl> list=mapper.getLockBl(lockName,type,areaList);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询锁的蓝牙开启时间段记录");
    }
    //锁的蓝牙开启时间段取消
    public Response cancelLockBl(Integer num) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("type",2);//取消
        wrapper.eq("num",num);
        int flag=mapper.update((LockBl) ActionUtil.objeNull,wrapper);
        return new Response().set(1,flag>0,flag>0?"取消成功":"段取消失败");
    }
}