|
@@ -2,20 +2,32 @@ package com.sky.ioc.service.device.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.sky.ioc.entity.domain.device.DeviceType;
|
|
|
+import com.sky.ioc.entity.domain.device.SecurityDevice;
|
|
|
import com.sky.ioc.mapper.device.DeviceTypeMapper;
|
|
|
+import com.sky.ioc.mapper.device.SecurityDeviceMapper;
|
|
|
import com.sky.ioc.service.device.DeviceTypeService;
|
|
|
import com.sky.ioc.tool.ReturnMsg;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
@Service
|
|
|
public class DeviceTypeServiceImpl implements DeviceTypeService {
|
|
|
|
|
|
@Autowired
|
|
|
DeviceTypeMapper deviceTypeMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SecurityDeviceMapper securityDeviceMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public ReturnMsg batchDel(String device_ids, String device_type_id) {
|
|
|
if (StringUtils.isNotBlank(device_ids)&&StringUtils.isNotBlank(device_type_id)){
|
|
@@ -32,4 +44,70 @@ public class DeviceTypeServiceImpl implements DeviceTypeService {
|
|
|
return ReturnMsg.fail("设备id和设备类别不能为空");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getListByType(String id, Integer page, Integer page_size) {
|
|
|
+ List<DeviceType> typeList = deviceTypeMapper.selectList(new LambdaQueryWrapper<DeviceType>().eq(DeviceType::getId,id));
|
|
|
+ List<String> ids = typeList.stream().map(DeviceType::getDevice_ids).collect(Collectors.toList());
|
|
|
+ List<SecurityDevice> list = securityDeviceMapper.selectList(new LambdaQueryWrapper<SecurityDevice>().in(SecurityDevice::getDevice_id,ids));
|
|
|
+ PageHelper.startPage(page,page_size);
|
|
|
+ return ReturnMsg.ok(new PageInfo<>(list));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg editDeviceType(String id, String name) {
|
|
|
+ if(StringUtils.isNotBlank(id)&&StringUtils.isNotBlank(name)){
|
|
|
+ UpdateWrapper updateWrapper = new UpdateWrapper();
|
|
|
+ updateWrapper.eq("id",id);
|
|
|
+ updateWrapper.set("name",name);
|
|
|
+ deviceTypeMapper.update(null,updateWrapper);
|
|
|
+ return ReturnMsg.ok();
|
|
|
+ }else{
|
|
|
+ return ReturnMsg.fail("设备类别或设备类别id不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg delDeviceType(String id) {
|
|
|
+ if(StringUtils.isNotBlank(id)){
|
|
|
+ deviceTypeMapper.deleteById(id);
|
|
|
+ return ReturnMsg.ok();
|
|
|
+ }else {
|
|
|
+ return ReturnMsg.fail("设备类别id不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg addDeviceType(String name) {
|
|
|
+ if(StringUtils.isNotBlank(name)){
|
|
|
+ DeviceType deviceType = new DeviceType();
|
|
|
+ deviceType.setDevice_ids("[]");
|
|
|
+ deviceType.setType_name(name);
|
|
|
+ deviceTypeMapper.insert(deviceType);
|
|
|
+ return ReturnMsg.ok();
|
|
|
+ }else{
|
|
|
+ return ReturnMsg.fail("设备类别不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getDeviceType(String name) {
|
|
|
+ if(StringUtils.isNotBlank(name)){
|
|
|
+ name ="%"+name+"%";
|
|
|
+ List<DeviceType> lists =deviceTypeMapper.selectList(new LambdaQueryWrapper<DeviceType>().like(DeviceType::getType_name,name));
|
|
|
+ return ReturnMsg.ok(lists);
|
|
|
+ }else{
|
|
|
+ List<DeviceType> lists =deviceTypeMapper.selectList(null);
|
|
|
+ return ReturnMsg.ok(lists);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg importDeviceType(String group) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|