|
@@ -1,11 +1,31 @@
|
|
|
package com.usky.meeting.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.lang.Snowflake;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.usky.common.core.bean.CommonPage;
|
|
|
+import com.usky.common.core.exception.BusinessException;
|
|
|
+import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.meeting.domain.MeetingDevice;
|
|
|
+import com.usky.meeting.domain.MeetingFloor;
|
|
|
import com.usky.meeting.mapper.MeetingDeviceMapper;
|
|
|
import com.usky.meeting.service.MeetingDeviceService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.meeting.service.vo.MeetingDeviceRequestVO;
|
|
|
+import net.bytebuddy.implementation.bytecode.Throw;
|
|
|
+import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
|
|
|
+import org.bouncycastle.jcajce.provider.symmetric.AES;
|
|
|
+import org.springframework.data.util.Optionals;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 设备表 服务实现类
|
|
@@ -17,4 +37,62 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class MeetingDeviceServiceImpl extends AbstractCrudService<MeetingDeviceMapper, MeetingDevice> implements MeetingDeviceService {
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonPage<MeetingDevice> meetingDeviceList(MeetingDeviceRequestVO requestVO){
|
|
|
+ Integer current = requestVO.getCurrent();
|
|
|
+ Integer size = requestVO.getSize();
|
|
|
+ IPage<MeetingDevice> page = new Page<>(current,size);
|
|
|
+ LambdaQueryWrapper<MeetingDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(requestVO.getDeviceName()),MeetingDevice::getDeviceName,requestVO.getDeviceName())
|
|
|
+ .like(StringUtils.isNotBlank(requestVO.getNameplate()),MeetingDevice::getNameplate,requestVO.getNameplate())
|
|
|
+ .like(StringUtils.isNotBlank(requestVO.getMaintainer()),MeetingDevice::getMaintainer,requestVO.getMaintainer())
|
|
|
+ .like(StringUtils.isNotBlank(requestVO.getContacts()),MeetingDevice::getContacts,requestVO.getContacts())
|
|
|
+ .like(StringUtils.isNotBlank(requestVO.getRemark()),MeetingDevice::getRemark,requestVO.getRemark())
|
|
|
+ .orderByAsc(MeetingDevice::getDeviceId);
|
|
|
+ page = this.page(page,queryWrapper);
|
|
|
+
|
|
|
+ return new CommonPage<>(page.getRecords(),page.getTotal(),size,current);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(MeetingDevice meetingDevice){
|
|
|
+ if(checkNameUnique(meetingDevice)){
|
|
|
+ throw new BusinessException("新增会议室设备失败,"+meetingDevice.getDeviceName()+"已经存在");
|
|
|
+ }
|
|
|
+// Snowflake snowflake = IdUtil.createSnowflake(1,1);
|
|
|
+// meetingDevice.setDeviceId(snowflake.nextId());
|
|
|
+ meetingDevice.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ meetingDevice.setCreateTime(LocalDateTime.now());
|
|
|
+ meetingDevice.setTenantId(SecurityUtils.getTenantId());
|
|
|
+ this.save(meetingDevice);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(MeetingDevice meetingDevice){
|
|
|
+ if(checkNameUnique(meetingDevice)){
|
|
|
+ throw new BusinessException("修改会议室设备失败,"+meetingDevice.getDeviceName()+"已经存在");
|
|
|
+ }
|
|
|
+ meetingDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ meetingDevice.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+ this.updateById(meetingDevice);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void remove(Long deviceId){
|
|
|
+ MeetingDevice meetingDevice = this.getById(deviceId);
|
|
|
+ Optional.ofNullable(meetingDevice).orElseThrow(() -> new BusinessException("该会议室设备不存在"));
|
|
|
+ this.removeById(deviceId);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean checkNameUnique(MeetingDevice meetingDevice){
|
|
|
+ Long deviceId = null == meetingDevice.getDeviceId()?-1:meetingDevice.getDeviceId();
|
|
|
+ LambdaQueryWrapper<MeetingDevice> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(MeetingDevice::getDeviceName,meetingDevice.getDeviceName())
|
|
|
+ .eq(MeetingDevice::getTenantId,SecurityUtils.getTenantId());
|
|
|
+ MeetingDevice one = this.getOne(queryWrapper);
|
|
|
+ return null != one && !Objects.equals(one.getDeviceId(),deviceId);
|
|
|
+ }
|
|
|
}
|