| | |
| | | |
| | | 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; |
| | | |
| | |
| | | @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()); |
| | | //判断是否存在:存在修改,不存在添加 |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("lock_id", lockBl.getLockId()); |
| | | wrapper.last("limit 1"); |
| | | LockBl bl = mapper.selectOne(wrapper); |
| | | if (bl == null) { |
| | | mapper.insert(lockBl); |
| | | } else { |
| | | UpdateWrapper wrapper1=new UpdateWrapper(); |
| | | wrapper1.set("start_time",lockBl.getStartTime()); |
| | | wrapper1.set("stop_time",lockBl.getStopTime()); |
| | | wrapper1.set("create_time",new Date()); |
| | | wrapper1.eq("lock_id",lockBl.getLockId()); |
| | | mapper.update((LockBl) ActionUtil.objeNull,wrapper1); |
| | | } |
| | | 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,"查询锁的蓝牙开启时间段记录"); |
| | | } |
| | | } |