Commit e9cdaa44 by 李小龙

设备

parent f78b115b
package com.makeit.controller.saas;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.service.platform.device.PlatDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "租户管理-租户设备管理")
@RestController
@RequestMapping("/saas/device")
public class SaasDeviceController {
@Autowired
private PlatDeviceService platDeviceService;
@ApiOperation("列表")
@PostMapping("page")
public ApiResponseEntity<PageVO<PlatDevice>> page(@RequestBody PageReqDTO<PlatDevice> pageReqDTO) {
return ApiResponseUtils.success(platDeviceService.page(pageReqDTO));
}
@ApiOperation("设备信息")
@PostMapping("detail")
public ApiResponseEntity<PlatDeviceDetailDTO> detail(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(platDeviceService.getDetailDTO(baseIdDTO.getId()));
}
@ApiOperation("设备编辑")
@PostMapping("edit")
public ApiResponseEntity<Void> edit(@RequestBody PlatDevice platDevice) {
return ApiResponseUtils.success(platDeviceService.edit(platDevice));
}
@ApiOperation("实时数据")
@PostMapping("realTimeDate")
public ApiResponseEntity<PlatDevice> realTimeDate(@RequestBody PlatDevice platDevice) {
//todo
return null;
}
@ApiOperation("数据分析")
@PostMapping("dataAnalysis")
public ApiResponseEntity<PlatDevice> dataAnalysis(@RequestBody PlatDevice platDevice) {
//todo
return null;
}
}
package com.makeit.dto.platform.device;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PlatDeviceDetailDTO {
@ApiModelProperty(value = "基本信息")
private PlatDevice platDevice;
@ApiModelProperty(value = "其他信息")
private PlatDeviceOther platDeviceOther;
}
package com.makeit.service.platform.device; package com.makeit.service.platform.device;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
/** /**
...@@ -13,4 +16,23 @@ import com.makeit.entity.platform.device.PlatDevice; ...@@ -13,4 +16,23 @@ import com.makeit.entity.platform.device.PlatDevice;
*/ */
public interface PlatDeviceService extends IService<PlatDevice> { public interface PlatDeviceService extends IService<PlatDevice> {
/**
* 分页-saas端
* @param pageReqDTO
* @return
*/
PageVO<PlatDevice> page(PageReqDTO<PlatDevice> pageReqDTO);
/**
* 设备信息
* @param deviceId
* @return
*/
PlatDeviceDetailDTO getDetailDTO(String deviceId);
/**
* 编辑
* @param platDevice
*/
void edit(PlatDevice platDevice);
} }
package com.makeit.service.platform.device.impl; package com.makeit.service.platform.device.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.dto.platform.device.PlatDeviceDetailDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.device.PlatDeviceOther;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.device.PlatDeviceMapper; import com.makeit.mapper.platform.device.PlatDeviceMapper;
import com.makeit.service.platform.device.PlatDeviceOtherService;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.old.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* <p> * <p>
...@@ -17,4 +33,65 @@ import org.springframework.stereotype.Service; ...@@ -17,4 +33,65 @@ import org.springframework.stereotype.Service;
@Service @Service
public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDevice> implements PlatDeviceService { public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDevice> implements PlatDeviceService {
@Autowired
private PlatDeviceOtherService platDeviceOtherService;
@Override
@TenantIdIgnore
public PageVO<PlatDevice> page(PageReqDTO<PlatDevice> pageReqDTO) {
PlatDevice param = pageReqDTO.getData();
Page<PlatDevice> page = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatDevice> lambdaQueryWrapper = getLambdaQueryWrapper(param);
Page<PlatDevice> devicePage = page(page, lambdaQueryWrapper);
return PageUtil.toPageVO(devicePage);
}
/**
* 设备信息
*
* @param deviceId
* @return
*/
@Override
public PlatDeviceDetailDTO getDetailDTO(String deviceId) {
PlatDevice platDevice = getById(deviceId);
if(platDevice == null ){
return null;
}
LambdaQueryWrapper<PlatDeviceOther> deviceOtherLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceOtherLambdaQueryWrapper.eq(PlatDeviceOther::getDeviceId,platDevice.getId());
PlatDeviceOther platDeviceOther = platDeviceOtherService.getOne(deviceOtherLambdaQueryWrapper, false);
PlatDeviceDetailDTO detailDTO = new PlatDeviceDetailDTO();
detailDTO.setPlatDevice(platDevice);
detailDTO.setPlatDeviceOther(platDeviceOther);
return detailDTO;
}
private LambdaQueryWrapper<PlatDevice> getLambdaQueryWrapper(PlatDevice param) {
return new LambdaQueryWrapper<PlatDevice>()
.eq(StringUtils.isNotBlank(param.getOriDeviceId()),PlatDevice::getOriDeviceId, param.getOriDeviceId())
.like(StringUtils.isNotBlank(param.getName()),PlatDevice::getName, param.getName())
.eq(StringUtils.isNotBlank(param.getStatus()),PlatDevice::getStatus, param.getStatus())
.like(StringUtils.isNotBlank(param.getProductName()),PlatDevice::getProductName, param.getProductName())
.eq(StringUtils.isNotBlank(param.getTenantId()), BaseBusEntity::getTenantId, param.getTenantId())
.orderByDesc(BaseEntity::getUpdateDate);
}
/**
* 编辑
*
* @param platDevice
*/
@Override
@Transactional
public void edit(PlatDevice platDevice) {
LambdaUpdateWrapper<PlatDevice> updateWrapper = Wrappers.lambdaUpdate(PlatDevice.class)
.eq(BaseEntity::getId, platDevice.getId())
.set(PlatDevice::getOriDeviceId, platDevice.getOriDeviceId())
.set(PlatDevice::getName, platDevice.getName())
.set(PlatDevice::getProductName, platDevice.getProductName())
.set(PlatDevice::getDescription, platDevice.getDescription());
this.update(updateWrapper);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment