Commit 800dced9 authored by huangcb's avatar huangcb

增加设备类型/设备实例功能接口

parent fe41d5ac
......@@ -43,7 +43,7 @@ public class DataModelAlarmRuleController {
public EResponse save(@RequestBody @Validated(ValidatorInsert.class) DataModelAlarmRuleForm form) throws EException {
// 模型ID有效性校验
if (!dataModelService.isModelExits(form.getModelId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型ID");
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型ID");
}
// 保存告警规则
......@@ -63,7 +63,7 @@ public class DataModelAlarmRuleController {
public EResponse list(@RequestBody @Validated(ValidatorList.class) DataModelAlarmRuleForm form) throws EException {
// 模型ID有效性校验
if (!dataModelService.isModelExits(form.getModelId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型ID");
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型ID");
}
return EResponse.ok(dataModelAlarmRuleService.getAlarmRuleList(form.getModelId()));
......
......@@ -155,7 +155,7 @@ public class DataModelController {
**/
private void checkIsValidModelId(Long modelId) {
if (!dataModelService.isModelExits(modelId)) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型id值");
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的模型ID");
}
}
......
......@@ -5,6 +5,7 @@ import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity;
import com.esv.datacenter.iot.module.datamodel.form.DataModelForm;
import com.esv.datacenter.iot.module.datamodel.vo.DataDataModelDetailVO;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelBriefVO;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelVO;
import java.util.List;
......@@ -65,11 +66,11 @@ public interface DataModelService extends IService<DataModelEntity> {
/**
* @description 获取所有模型列表
* @return java.util.List<com.esv.datacenter.iot.module.dmodel.vo.ModelVO>
* @return java.util.List<com.esv.datacenter.iot.module.dmodel.vo.DataModelBriefVO>
* @author huangChaobin@esvtek.com
* @createTime 2020/08/01 13:04
**/
List<DataModelVO> getAllModeList();
List<DataModelBriefVO> getAllModeList();
/**
* @description 判断模型是否存在
......
......@@ -122,6 +122,13 @@ public class DataModelPropertyServiceImpl extends ServiceImpl<DataModelPropertyD
throw new EException(ECode.PARAM_ERROR.code(), "无效的默认值["+propertyDefaultValue+"]");
}
break;
case "integer":
try {
Long.parseLong(propertyDefaultValue);
} catch (Exception e) {
throw new EException(ECode.PARAM_ERROR.code(), "无效的默认值["+propertyDefaultValue+"]");
}
break;
default:
break;
}
......
......@@ -17,6 +17,7 @@ import com.esv.datacenter.iot.module.datamodel.form.DataModelPropertyForm;
import com.esv.datacenter.iot.module.datamodel.service.DataModelPropertyService;
import com.esv.datacenter.iot.module.datamodel.service.DataModelService;
import com.esv.datacenter.iot.module.datamodel.vo.DataDataModelDetailVO;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelBriefVO;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelVO;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceDataMapService;
import org.springframework.beans.BeanUtils;
......@@ -168,15 +169,13 @@ public class DataModelServiceImpl extends ServiceImpl<DataModelDao, DataModelEnt
}
@Override
public List<DataModelVO> getAllModeList() {
public List<DataModelBriefVO> getAllModeList() {
List<DataModelEntity> modelEntityList = this.getBaseMapper().selectList(new LambdaQueryWrapper<DataModelEntity>()
.orderByAsc(DataModelEntity::getName));
List<DataModelVO> dataModelVOList = new ArrayList<>();
List<DataModelBriefVO> dataModelVOList = new ArrayList<>();
for (DataModelEntity entity : modelEntityList) {
DataModelVO vo = new DataModelVO();
DataModelBriefVO vo = new DataModelBriefVO();
BeanUtils.copyProperties(entity, vo);
vo.setCreateTime(entity.getCreateTime().getTime());
vo.setUpdateTime(entity.getUpdateTime().getTime());
dataModelVOList.add(vo);
}
......
package com.esv.datacenter.iot.module.datamodel.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/07/31 16:12
* @version:1.0
*/
@Data
public class DataModelBriefVO {
/**
*
*/
private Long id;
/**
* 模型名称
*/
private String name;
/**
* 模型描述
*/
private String description;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.datacenter.iot.common.exception.EException;
import com.esv.datacenter.iot.common.response.ECode;
import com.esv.datacenter.iot.common.response.EResponse;
import com.esv.datacenter.iot.common.validator.groups.ValidatorDelete;
import com.esv.datacenter.iot.common.validator.groups.ValidatorInsert;
import com.esv.datacenter.iot.common.validator.groups.ValidatorList;
import com.esv.datacenter.iot.common.validator.groups.ValidatorUpdate;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceInstanceService;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
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;
/**
* @description: 设备实例Controller
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 10:35
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/deviceModel/instance")
@Validated
public class DeviceInstanceController {
private DeviceTypeService deviceTypeService;
private DeviceInstanceService deviceInstanceService;
public DeviceInstanceController(DeviceTypeService deviceTypeService, DeviceInstanceService deviceInstanceService) {
this.deviceTypeService = deviceTypeService;
this.deviceInstanceService = deviceInstanceService;
}
/**
* @description 新增设备实例
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:36
**/
@PostMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) DeviceInstanceForm form) throws EException {
if (!deviceTypeService.isValidTypeId(form.getDeviceTypeId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备类型ID");
}
Long id = deviceInstanceService.insertDeviceInstance(form);
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
}
/**
* @description 删除设备实例
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:51
**/
@PostMapping("/delete")
public EResponse delete(@RequestBody @Validated(ValidatorDelete.class) DeviceInstanceForm form) throws EException {
if (!deviceInstanceService.isValidId(form.getId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备ID");
}
deviceInstanceService.deleteInstance(form.getId());
return EResponse.ok();
}
/**
* @description 编辑设备实例信息
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 11:03
**/
@PostMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) DeviceInstanceForm form) throws EException {
if (!deviceInstanceService.isValidId(form.getId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备ID");
}
deviceInstanceService.updateInstance(form);
return EResponse.ok();
}
/**
* @description 分页查询设备实例
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:08
**/
@PostMapping("/list")
public EResponse list(@RequestBody @Validated(ValidatorList.class) DeviceInstanceForm form) throws EException {
return EResponse.ok(deviceInstanceService.getInstance4Page(form));
}
}
package com.esv.datacenter.iot.module.devicemodel.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.datacenter.iot.common.exception.EException;
import com.esv.datacenter.iot.common.response.ECode;
import com.esv.datacenter.iot.common.response.EResponse;
import com.esv.datacenter.iot.common.validator.groups.*;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceDataMapForm;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceTypeForm;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceDataMapService;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceInstanceService;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceTypeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
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;
import java.util.Objects;
/**
* @description: 设备类型Controller
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/06 20:14
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/deviceModel")
@Validated
public class DeviceTypeController {
private DeviceTypeService deviceTypeService;
private DeviceInstanceService deviceInstanceService;
private DeviceDataMapService deviceDataMapService;
public DeviceTypeController(DeviceTypeService deviceTypeService, DeviceInstanceService deviceInstanceService,
DeviceDataMapService deviceDataMapService) {
this.deviceTypeService = deviceTypeService;
this.deviceInstanceService = deviceInstanceService;
this.deviceDataMapService = deviceDataMapService;
}
/**
* @description 新增设备类型
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:16
**/
@PostMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) DeviceTypeForm form) throws EException {
Long id = deviceTypeService.insertDeviceType(form);
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
}
/**
* @description 更新设备类型信息
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:20
**/
@PostMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) DeviceTypeForm form) throws EException {
if (!deviceTypeService.isValidTypeId(form.getId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备类型ID");
}
deviceTypeService.updateDeviceType(form);
return EResponse.ok();
}
/**
* @description 删除设备类型
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:35
**/
@PostMapping("/delete")
public EResponse delete(@RequestBody @Validated(ValidatorDelete.class) DeviceTypeForm form) throws EException {
if (!deviceTypeService.isValidTypeId(form.getId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备类型ID");
}
int deviceInstanceCount = deviceInstanceService.getInstanceCountByTypeId(form.getId());
if (0 < deviceInstanceCount) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "该设备类型有设备实例,不能删除");
}
deviceTypeService.deleteDeviceType(form.getId());
return EResponse.ok();
}
/**
* @description 分页查询设备类型
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:45
**/
@PostMapping("/list")
public EResponse list(@RequestBody @Validated(ValidatorList.class) DeviceTypeForm form) throws EException {
String name = StringUtils.trimToNull(form.getName());
if (Objects.isNull(name)) {
form.setName(null);
} else {
form.setName("%" + name + "%");
}
return EResponse.ok(deviceTypeService.getType4Page(form));
}
/**
* @description 获取设备类型列表
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:57
**/
@PostMapping("/all")
public EResponse all() throws EException {
return EResponse.ok(deviceTypeService.getTypeList());
}
/**
* @description 通过设备类型ID获取对应的数据模型列表
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:39
**/
@PostMapping("/getDataModelByDeviceTypeId")
public EResponse getDataModelByDeviceTypeId(@RequestBody @Validated(ValidatorDetail.class) DeviceTypeForm form) throws EException {
if (!deviceTypeService.isValidTypeId(form.getId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备类型ID");
}
return EResponse.ok(deviceTypeService.getDataModelByDeviceTypeId(form.getId()));
}
/**
* @description 保存设备类型与数据模型的映射记录
* @param form:
* @return com.esv.datacenter.iot.common.response.EResponse
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:46
**/
@PostMapping("/saveDataModelByDeviceTypeId")
public EResponse saveDataModelByDeviceTypeId(@RequestBody @Validated(ValidatorInsert.class) DeviceDataMapForm form) throws EException {
if (!deviceTypeService.isValidTypeId(form.getDeviceTypeId())) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "无效的设备类型ID");
}
deviceDataMapService.saveDeviceDataMap(form.getDeviceTypeId(), form.getDataModelId());
return EResponse.ok();
}
}
package com.esv.datacenter.iot.module.devicemodel.dao;
import com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceDataMapEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 设备类型-数据模型映射表
*
......@@ -13,5 +16,14 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface DeviceDataMapDao extends BaseMapper<DeviceDataMapEntity> {
/**
* @description 通过设备类型ID获取对应的数据模型列表
* @param entity:
* @return java.util.List<com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity>
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:31
**/
List<DataModelEntity> selectDataModelByDeviceTypeId(DeviceDataMapEntity entity);
}
package com.esv.datacenter.iot.module.devicemodel.dao;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm;
import org.apache.ibatis.annotations.Mapper;
/**
......@@ -13,5 +15,15 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface DeviceInstanceDao extends BaseMapper<DeviceInstanceEntity> {
/**
* @description 分页查询
* @param page:
* @param queryObj:
* @return com.baomidou.mybatisplus.core.metadata.IPage
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 13:37
**/
IPage select4Page(IPage page, DeviceInstanceForm queryObj);
}
package com.esv.datacenter.iot.module.devicemodel.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.esv.datacenter.iot.module.datamodel.form.DataModelForm;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceTypeForm;
import org.apache.ibatis.annotations.Mapper;
/**
......@@ -13,5 +16,14 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface DeviceTypeDao extends BaseMapper<DeviceTypeEntity> {
/**
* @description 分页查询
* @param page:
* @param queryObj:
* @return com.baomidou.mybatisplus.core.metadata.IPage
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:34
**/
IPage select4Page(IPage page, DeviceTypeForm queryObj);
}
package com.esv.datacenter.iot.module.devicemodel.dto;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 13:43
* @version:1.0
*/
@Data
public class DeviceInstanceDto {
/**
*
*/
private Long id;
/**
* 设备类型ID
*/
private Long deviceTypeId;
/**
* 设备类型名称
*/
private String deviceTypeName;
/**
* 设备名称
*/
private String name;
/**
* 设备描述
*/
private String description;
/**
* 设备业务ID
*/
private String businessId;
/**
* 设备型号
*/
private String deviceModel;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.form;
import com.esv.datacenter.iot.common.validator.groups.ValidatorInsert;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotNull;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 14:40
* @version:1.0
*/
@Data
public class DeviceDataMapForm {
/**
* 设备类型ID
*/
@NotNull(message = "[设备类型ID]不能为空", groups = {ValidatorInsert.class})
private Long deviceTypeId;
/**
* 数据模型ID
*/
private String dataModelId;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.form;
import com.esv.datacenter.iot.common.validator.groups.ValidatorDelete;
import com.esv.datacenter.iot.common.validator.groups.ValidatorInsert;
import com.esv.datacenter.iot.common.validator.groups.ValidatorList;
import com.esv.datacenter.iot.common.validator.groups.ValidatorUpdate;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 10:21
* @version:1.0
*/
@Data
public class DeviceInstanceForm {
/**
*
*/
@NotNull(message = "[设备ID]不能为空", groups = {ValidatorDelete.class, ValidatorUpdate.class})
private Long id;
/**
* 设备类型ID
*/
@NotNull(message = "[设备类型ID]不能为空", groups = {ValidatorInsert.class, ValidatorList.class})
private Long deviceTypeId;
/**
* 设备名称
*/
@Length(max = 50, message = "[设备名称]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorList.class})
@NotBlank(message = "[设备名称]不能为空", groups = {ValidatorInsert.class})
private String name;
/**
* 设备描述
*/
@Length(max = 200, message = "[设备描述]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "[设备描述]不能为空", groups = {ValidatorInsert.class})
private String description;
/**
* 设备业务ID
*/
@Length(max = 50, message = "[设备名称]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorList.class})
private String businessId;
/**
* 设备型号
*/
@Length(max = 200, message = "[设备型号]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorList.class})
private String deviceModel;
/**
* 页码
**/
@Range(min = 1, max = 65535, message = "无效的pageNum", groups = {ValidatorList.class})
@NotNull(message = "参数pageNum不能为空", groups = {ValidatorList.class})
private Integer pageNum;
/**
* 每页记录条数
**/
@Range(min = 1, max = 100, message = "pageSize", groups = {ValidatorList.class})
@NotNull(message = "参数pageSize不能为空", groups = {ValidatorList.class})
private Integer pageSize;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.from;
package com.esv.datacenter.iot.module.devicemodel.form;
import com.esv.datacenter.iot.common.validator.groups.ValidatorInsert;
import com.esv.datacenter.iot.common.validator.groups.ValidatorList;
import com.esv.datacenter.iot.common.validator.groups.*;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -23,18 +22,19 @@ public class DeviceTypeForm {
/**
*
*/
@NotNull(message = "[设备类型ID]不能为空", groups = {ValidatorUpdate.class, ValidatorDelete.class, ValidatorDetail.class})
private Long id;
/**
* 名称
*/
@Length(max = 50, message = "[设备名称]长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "[设备名称]不能为空", groups = {ValidatorInsert.class})
@Length(max = 50, message = "[设备类型名称]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorList.class})
@NotBlank(message = "[设备类型名称]不能为空", groups = {ValidatorInsert.class})
private String name;
/**
* 描述
*/
@Length(max = 200, message = "[设备描述]长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "[设备描述]不能为空", groups = {ValidatorInsert.class})
@Length(max = 200, message = "[设备类型描述]长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "[设备类型描述]不能为空", groups = {ValidatorInsert.class})
private String description;
/**
......
package com.esv.datacenter.iot.module.devicemodel.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceDataMapEntity;
import java.util.List;
/**
* 设备类型-数据模型映射Service
*
......@@ -21,5 +24,33 @@ public interface DeviceDataMapService extends IService<DeviceDataMapEntity> {
**/
int getCountByDataModelId(Long dataModelId);
/**
* @description 通过设备类型ID删除映射记录
* @param deviceTypeId:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:30
**/
void deleteByDeviceTypeId(Long deviceTypeId);
/**
* @description 保存设备类型与数据模型的映射记录
* @param deviceTypeId:
* @param dataModelIds:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:18
**/
void saveDeviceDataMap(Long deviceTypeId, String dataModelIds);
/**
* @description 通过设备类型ID获取对应的数据模型列表
* @param deviceTypeId:
* @return java.util.List<com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity>
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:26
**/
List<DataModelEntity> getDataModelByDeviceTypeId(Long deviceTypeId);
}
package com.esv.datacenter.iot.module.devicemodel.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm;
/**
* 设备实例Service
......@@ -12,5 +14,68 @@ import com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity;
*/
public interface DeviceInstanceService extends IService<DeviceInstanceEntity> {
/**
* @description 查询指定设备类型ID的设备实例数量
* @param deviceTypeId:
* @return int
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:25
**/
int getInstanceCountByTypeId(Long deviceTypeId);
/**
* @description 新增设备实例
* @param form:
* @return java.lang.Long
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:40
**/
Long insertDeviceInstance(DeviceInstanceForm form);
/**
* @description 删除设备实例
* @param id:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:49
**/
void deleteInstance(Long id);
/**
* @description 编辑设备实例信息
* @param form:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:58
**/
void updateInstance(DeviceInstanceForm form);
/**
* @description 判断是否有效实例ID
* @param id:
* @return java.lang.Boolean
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:47
**/
Boolean isValidId(Long id);
/**
* @description 通过ID获取设备实例
* @param id:
* @return com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 10:47
**/
DeviceInstanceEntity getInstanceById(Long id);
/**
* @description 分页查询
* @param form:
* @return com.esv.datacenter.iot.common.vo.PageResultVO
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 13:39
**/
PageResultVO getInstance4Page(DeviceInstanceForm form);
}
package com.esv.datacenter.iot.module.devicemodel.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelBriefVO;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceTypeForm;
import com.esv.datacenter.iot.module.devicemodel.vo.DeviceTypeBriefVO;
import lombok.Data;
import java.util.List;
/**
* 设备类型Service
......@@ -12,5 +19,76 @@ import com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity;
*/
public interface DeviceTypeService extends IService<DeviceTypeEntity> {
/**
* @description 新增设备类型
* @param form:
* @return java.lang.Long
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 19:55
**/
Long insertDeviceType(DeviceTypeForm form);
/**
* @description 更新设备类型
* @param form:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:08
**/
void updateDeviceType(DeviceTypeForm form);
/**
* @description 通过设备类型ID查询记录
* @param id:
* @return com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:22
**/
DeviceTypeEntity getDeviceTypeById(Long id);
/**
* @description 删除设备类型
* @param id:
* @return void
* @author huangChaobin@esvtek.com
* @createTime 2020/08/06 20:24
**/
void deleteDeviceType(Long id);
/**
* @description 分页查询
* @param form:
* @return com.esv.datacenter.iot.common.vo.PageResultVO
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:35
**/
PageResultVO getType4Page(DeviceTypeForm form);
/**
* @description 是否有效的设备类型ID
* @param id:
* @return java.lang.Boolean
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:48
**/
Boolean isValidTypeId(Long id);
/**
* @description 获取设备类型列表
* @return java.util.List<com.esv.datacenter.iot.module.devicemodel.vo.DeviceTypeBriefVO>
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 9:54
**/
List<DeviceTypeBriefVO> getTypeList();
/**
* @description 通过设备类型ID获取对应的数据模型列表
* @param deviceTypeId:
* @return java.util.List<com.esv.datacenter.iot.module.datamodel.vo.DataModelBriefVO>
* @author huangChaobin@esvtek.com
* @createTime 2020/08/07 14:34
**/
List<DataModelBriefVO> getDataModelByDeviceTypeId(Long deviceTypeId);
}
......@@ -2,10 +2,16 @@ package com.esv.datacenter.iot.module.devicemodel.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity;
import com.esv.datacenter.iot.module.devicemodel.dao.DeviceDataMapDao;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceDataMapEntity;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceDataMapService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
@Service("deviceDataMapService")
......@@ -16,4 +22,33 @@ public class DeviceDataMapServiceImpl extends ServiceImpl<DeviceDataMapDao, Devi
return this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceDataMapEntity>()
.eq(DeviceDataMapEntity::getDataModelId, dataModelId));
}
@Override
public void deleteByDeviceTypeId(Long deviceTypeId) {
this.getBaseMapper().delete(new LambdaQueryWrapper<DeviceDataMapEntity>()
.eq(DeviceDataMapEntity::getDeviceTypeId, deviceTypeId));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDeviceDataMap(Long deviceTypeId, String dataModelIds) {
this.getBaseMapper().delete(new LambdaQueryWrapper<DeviceDataMapEntity>().eq(DeviceDataMapEntity::getDeviceTypeId, deviceTypeId));
if (Objects.nonNull(StringUtils.trimToNull(dataModelIds))) {
String[] dataModelIdList = dataModelIds.split(",");
for (String dataModelId : dataModelIdList) {
DeviceDataMapEntity entity = new DeviceDataMapEntity();
entity.setDeviceTypeId(deviceTypeId);
entity.setDataModelId(Long.parseLong(dataModelId));
this.getBaseMapper().insert(entity);
}
}
}
@Override
public List<DataModelEntity> getDataModelByDeviceTypeId(Long deviceTypeId) {
DeviceDataMapEntity entity = new DeviceDataMapEntity();
entity.setDeviceTypeId(deviceTypeId);
return this.getBaseMapper().selectDataModelByDeviceTypeId(entity);
}
}
\ No newline at end of file
package com.esv.datacenter.iot.module.devicemodel.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.datacenter.iot.common.exception.EException;
import com.esv.datacenter.iot.common.response.ECode;
import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.devicemodel.dao.DeviceInstanceDao;
import com.esv.datacenter.iot.module.devicemodel.dto.DeviceInstanceDto;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceInstanceEntity;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceInstanceService;
import com.esv.datacenter.iot.module.devicemodel.vo.DeviceTypeVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service("deviceInstanceService")
public class DeviceInstanceServiceImpl extends ServiceImpl<DeviceInstanceDao, DeviceInstanceEntity> implements DeviceInstanceService {
@Override
public int getInstanceCountByTypeId(Long deviceTypeId) {
return this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceInstanceEntity>()
.eq(DeviceInstanceEntity::getDeviceTypeId, deviceTypeId));
}
@Override
public Long insertDeviceInstance(DeviceInstanceForm form) {
int count = this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceInstanceEntity>()
.eq(DeviceInstanceEntity::getName, form.getName()));
if (0 < count) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "设备名称[" + form.getName() + "]已存在");
}
DeviceInstanceEntity entity = new DeviceInstanceEntity();
BeanUtils.copyProperties(form, entity);
this.getBaseMapper().insert(entity);
return entity.getId();
}
@Override
public void deleteInstance(Long id) {
this.getBaseMapper().deleteById(id);
}
@Override
public void updateInstance(DeviceInstanceForm form) {
if (Objects.nonNull(StringUtils.trimToNull(form.getName()))) {
int count = this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceInstanceEntity>()
.ne(DeviceInstanceEntity::getId, form.getId())
.eq(DeviceInstanceEntity::getName, form.getName()));
if (0 < count) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "设备名称[" + form.getName() + "]已存在");
}
}
DeviceInstanceEntity entity = new DeviceInstanceEntity();
BeanUtils.copyProperties(form, entity);
this.getBaseMapper().updateById(entity);
}
@Override
public Boolean isValidId(Long id) {
DeviceInstanceEntity entity = this.getInstanceById(id);
if (Objects.isNull(entity)) {
return false;
} else {
return true;
}
}
@Override
public DeviceInstanceEntity getInstanceById(Long id) {
return this.getBaseMapper().selectById(id);
}
@Override
public PageResultVO getInstance4Page(DeviceInstanceForm form) {
IPage<DeviceInstanceDto> page = new Page<>(form.getPageNum(), form.getPageSize());
this.baseMapper.select4Page(page, form);
List<DeviceInstanceDto> entityList = page.getRecords();
List<DeviceTypeVO> voList = new ArrayList<>();
for (DeviceInstanceDto entity : entityList) {
DeviceTypeVO vo = new DeviceTypeVO();
BeanUtils.copyProperties(entity, vo);
vo.setCreateTime(entity.getCreateTime().getTime());
vo.setUpdateTime(entity.getUpdateTime().getTime());
voList.add(vo);
}
return new PageResultVO(page, voList);
}
}
\ No newline at end of file
package com.esv.datacenter.iot.module.devicemodel.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.datacenter.iot.common.exception.EException;
import com.esv.datacenter.iot.common.response.ECode;
import com.esv.datacenter.iot.common.vo.PageResultVO;
import com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity;
import com.esv.datacenter.iot.module.datamodel.vo.DataModelBriefVO;
import com.esv.datacenter.iot.module.devicemodel.dao.DeviceTypeDao;
import com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity;
import com.esv.datacenter.iot.module.devicemodel.form.DeviceTypeForm;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceDataMapService;
import com.esv.datacenter.iot.module.devicemodel.service.DeviceTypeService;
import com.esv.datacenter.iot.module.devicemodel.vo.DeviceTypeBriefVO;
import com.esv.datacenter.iot.module.devicemodel.vo.DeviceTypeVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service("deviceTypeService")
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeDao, DeviceTypeEntity> implements DeviceTypeService {
@Autowired
private DeviceDataMapService deviceDataMapService;
@Override
public Long insertDeviceType(DeviceTypeForm form) {
// 判断设备名称是否有重复
int count = this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceTypeEntity>()
.eq(DeviceTypeEntity::getName, form.getName()));
if (0 < count) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "设备类型[" + form.getName() + "]已存在");
}
DeviceTypeEntity entity = new DeviceTypeEntity();
BeanUtils.copyProperties(form, entity);
this.getBaseMapper().insert(entity);
return entity.getId();
}
@Override
public void updateDeviceType(DeviceTypeForm form) {
// 判断设备名称是否有重复
int count = this.getBaseMapper().selectCount(new LambdaQueryWrapper<DeviceTypeEntity>()
.ne(DeviceTypeEntity::getId, form.getId())
.eq(DeviceTypeEntity::getName, form.getName()));
if (0 < count) {
throw new EException(ECode.BIZ_PARAM_ERROR.code(), "设备类型[" + form.getName() + "]已存在");
}
DeviceTypeEntity entity = new DeviceTypeEntity();
BeanUtils.copyProperties(form, entity);
this.getBaseMapper().updateById(entity);
}
@Override
public DeviceTypeEntity getDeviceTypeById(Long id) {
return this.getBaseMapper().selectById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDeviceType(Long id) {
// 删除设备类型记录
this.getBaseMapper().deleteById(id);
// 删除设备类型与数据类型对应的映射记录
this.deviceDataMapService.deleteByDeviceTypeId(id);
}
@Override
public PageResultVO getType4Page(DeviceTypeForm form) {
IPage<DeviceTypeEntity> page = new Page<>(form.getPageNum(), form.getPageSize());
this.baseMapper.select4Page(page, form);
List<DeviceTypeEntity> entityList = page.getRecords();
List<DeviceTypeVO> voList = new ArrayList<>();
for (DeviceTypeEntity entity : entityList) {
DeviceTypeVO vo = new DeviceTypeVO();
BeanUtils.copyProperties(entity, vo);
vo.setCreateTime(entity.getCreateTime().getTime());
vo.setUpdateTime(entity.getUpdateTime().getTime());
voList.add(vo);
}
return new PageResultVO(page, voList);
}
@Override
public Boolean isValidTypeId(Long id) {
DeviceTypeEntity entity = this.getDeviceTypeById(id);
if (Objects.isNull(entity)) {
return false;
} else {
return true;
}
}
@Override
public List<DeviceTypeBriefVO> getTypeList() {
List<DeviceTypeEntity> entityList = this.getBaseMapper().selectList(new LambdaQueryWrapper<DeviceTypeEntity>()
.orderByAsc(DeviceTypeEntity::getName));
List<DeviceTypeBriefVO> voList = new ArrayList<>();
for (DeviceTypeEntity entity : entityList) {
DeviceTypeBriefVO vo = new DeviceTypeBriefVO();
BeanUtils.copyProperties(entity, vo);
voList.add(vo);
}
return voList;
}
@Override
public List<DataModelBriefVO> getDataModelByDeviceTypeId(Long deviceTypeId) {
List<DataModelEntity> entityList = deviceDataMapService.getDataModelByDeviceTypeId(deviceTypeId);
List<DataModelBriefVO> voList = new ArrayList<>();
for (DataModelEntity entity : entityList) {
DataModelBriefVO vo = new DataModelBriefVO();
BeanUtils.copyProperties(entity, vo);
voList.add(vo);
}
return voList;
}
}
\ No newline at end of file
package com.esv.datacenter.iot.module.devicemodel.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 13:41
* @version:1.0
*/
@Data
public class DeviceInstanceVO {
/**
*
*/
private Long id;
/**
* 设备类型ID
*/
private Long deviceTypeId;
/**
* 设备类型名称
*/
private String deviceTypeName;
/**
* 设备名称
*/
private String name;
/**
* 设备描述
*/
private String description;
/**
* 设备业务ID
*/
private String businessId;
/**
* 设备型号
*/
private String deviceModel;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Long createTime;
/**
* 修改时间
*/
private Long updateTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 9:39
* @version:1.0
*/
@Data
public class DeviceTypeBriefVO {
/**
*
*/
private Long id;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.devicemodel.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @author: huangchaobin@esvtek.com
* @createTime: 2020/08/07 9:39
* @version:1.0
*/
@Data
public class DeviceTypeVO {
/**
*
*/
private Long id;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Long createTime;
/**
* 修改时间
*/
private Long updateTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.datacenter.iot.module.test.controller;
import com.alibaba.fastjson.JSONArray;
import com.esv.datacenter.iot.common.component.RedisComponent;
import com.esv.datacenter.iot.common.response.EResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @description:
* @project: freight-base-service
......@@ -20,9 +26,30 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
public class TestController {
@Autowired
RedisComponent redisComponent;
@GetMapping("/ping")
public EResponse ping() {
return EResponse.ok();
}
@GetMapping("/getCache")
public EResponse getCache(HttpServletRequest request) {
String key = request.getParameter("key");
String str = (String) redisComponent.get(key);
log.info(str);
return EResponse.ok(str);
}
@GetMapping("/getCache4List")
public EResponse getCache4List(HttpServletRequest request) {
String key = request.getParameter("key");
String str = (String) redisComponent.get(key);
log.info(str);
JSONArray array = JSONArray.parseArray(str);
log.info(array.toJSONString());
return EResponse.ok(array);
}
}
......@@ -84,5 +84,5 @@ timescale:
maximum-pool-size: 1
max-lifetime: 0
table-field:
map: string-text,number-numeric,integer-int8,boolean-bit(1),date-date,time-timetz,datetime-timestamptz
map: string-text,number-numeric,integer-int8,boolean-bit(1),date-date,time-int,datetime-timestamptz
table-prefix: iot_data_model_
\ No newline at end of file
......@@ -22,7 +22,7 @@
<select id="selectAll" resultType="com.esv.datacenter.iot.module.datamodel.dto.DataModelAlarmRuleDto">
select a.id, a.model_id, a.property_id, a.rule_expression, a.alarm_level, a.threshold,
b.property_code, b.property_code, b.property_name, b.property_default_value, b.property_unit
b.property_code, b.property_name, b.property_type, b.property_default_value, b.property_unit
from data_model_alarm_rule a, data_model_property b
where a.model_id = b.model_id and a.property_id = b.id
ORDER BY model_id ASC
......
......@@ -16,5 +16,12 @@
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="selectDataModelByDeviceTypeId" parameterType="com.esv.datacenter.iot.module.devicemodel.entity.DeviceDataMapEntity"
resultType="com.esv.datacenter.iot.module.datamodel.entity.DataModelEntity">
select b.id, b.name, b.description
from device_data_map a, data_model b
where a.data_model_id = b.id and a.device_type_id = #{deviceTypeId}
ORDER BY b.name ASC
</select>
</mapper>
\ No newline at end of file
......@@ -20,5 +20,25 @@
<result property="updateTime" column="update_time"/>
</resultMap>
<!-- 分页查询 -->
<select id="select4Page" parameterType="com.esv.datacenter.iot.module.devicemodel.form.DeviceInstanceForm"
resultType="com.esv.datacenter.iot.module.devicemodel.dto.DeviceInstanceDto">
select a.*, b.name as deviceTypeName
from device_instance a, device_type b
where a.device_type_id = b.id and a.deleted = false
<if test="queryObj.deviceTypeId != null">
and device_type_id = #{queryObj.deviceTypeId}
</if>
<if test="queryObj.name != null">
and name like CONCAT('%', #{queryObj.name}, '%')
</if>
<if test="queryObj.businessId != null">
and business_id like CONCAT('%', #{queryObj.businessId}, '%')
</if>
<if test="queryObj.deviceModel != null">
and device_model like CONCAT('%', #{queryObj.deviceModel}, '%')
</if>
ORDER BY name ASC
</select>
</mapper>
\ No newline at end of file
......@@ -17,5 +17,16 @@
<result property="updateTime" column="update_time"/>
</resultMap>
<!-- 分页查询 -->
<select id="select4Page" parameterType="com.esv.datacenter.iot.module.devicemodel.form.DeviceTypeForm"
resultType="com.esv.datacenter.iot.module.devicemodel.entity.DeviceTypeEntity">
select *
from device_type
where deleted = false
<if test="queryObj.name != null">
and name like #{queryObj.name}
</if>
ORDER BY name ASC
</select>
</mapper>
\ No newline at end of file
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 to comment