Showing
9 changed files
with
524 additions
and
0 deletions
... | ... | @@ -427,3 +427,43 @@ COMMENT ON TABLE "public"."qg_brain_device_position" IS '存放位置表'; |
427 | 427 | COMMENT ON COLUMN "public"."qg_brain_device_position"."position" IS '存放位置'; |
428 | 428 | COMMENT ON COLUMN "public"."qg_brain_device_position"."status" IS '状态'; |
429 | 429 | COMMENT ON COLUMN "public"."qg_brain_device_position"."notes" IS '备注'; |
430 | + | |
431 | +--设备台账 | |
432 | +CREATE TABLE "public"."qg_brain_device" ( | |
433 | + "id" varchar(36) NOT NULL, | |
434 | + "name" varchar(100), | |
435 | + "code" varchar(100), | |
436 | + "model" varchar(100), | |
437 | + "category_id" varchar(36), | |
438 | + "position_id" varchar(36), | |
439 | + "notes" varchar(1000), | |
440 | + "status" varchar(20), | |
441 | + "use_dep" varchar(36), | |
442 | + "service_dep" varchar(36), | |
443 | + "contact_info" varchar(50), | |
444 | + "enable_time" timestamp(6), | |
445 | + "pictures" varchar(500), | |
446 | + "files" varchar(500), | |
447 | + "tenant_id" varchar(36), | |
448 | + "create_time" timestamp(6), | |
449 | + "creator" varchar(36), | |
450 | + "updater" varchar(36), | |
451 | + "update_time" timestamp(6), | |
452 | + CONSTRAINT "qg_brain_device_pkey" PRIMARY KEY ("id") | |
453 | +); | |
454 | + | |
455 | +COMMENT ON TABLE "public"."qg_brain_device" IS '设备台账'; | |
456 | +COMMENT ON COLUMN "public"."qg_brain_device"."name" IS '设备名称'; | |
457 | +COMMENT ON COLUMN "public"."qg_brain_device"."code" IS '设备编码'; | |
458 | +COMMENT ON COLUMN "public"."qg_brain_device"."model" IS '规格型号'; | |
459 | +COMMENT ON COLUMN "public"."qg_brain_device"."category_id" IS '设备类型id'; | |
460 | +COMMENT ON COLUMN "public"."qg_brain_device"."position_id" IS '存放位置id'; | |
461 | +COMMENT ON COLUMN "public"."qg_brain_device"."notes" IS '备注'; | |
462 | +COMMENT ON COLUMN "public"."qg_brain_device"."status" IS '当前状态'; | |
463 | +COMMENT ON COLUMN "public"."qg_brain_device"."use_dep" IS '使用部门id'; | |
464 | +COMMENT ON COLUMN "public"."qg_brain_device"."service_dep" IS '维保部门id'; | |
465 | +COMMENT ON COLUMN "public"."qg_brain_device"."contact_info" IS '联系方式'; | |
466 | +COMMENT ON COLUMN "public"."qg_brain_device"."enable_time" IS '启用日期'; | |
467 | +COMMENT ON COLUMN "public"."qg_brain_device"."pictures" IS '图片ids'; | |
468 | +COMMENT ON COLUMN "public"."qg_brain_device"."pictures" IS '文件ids'; | |
469 | + | ... | ... |
1 | +package org.thingsboard.server.controller; | |
2 | + | |
3 | +import io.swagger.annotations.Api; | |
4 | +import io.swagger.annotations.ApiOperation; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import lombok.extern.slf4j.Slf4j; | |
7 | +import org.apache.commons.lang3.StringUtils; | |
8 | +import org.springframework.http.ResponseEntity; | |
9 | +import org.springframework.security.access.prepost.PreAuthorize; | |
10 | +import org.springframework.validation.annotation.Validated; | |
11 | +import org.springframework.web.bind.annotation.*; | |
12 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | |
13 | +import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | |
14 | +import org.thingsboard.server.common.data.yunteng.dto.BrainDeviceDTO; | |
15 | +import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult; | |
16 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
17 | +import org.thingsboard.server.dao.yunteng.service.BrainDeviceService; | |
18 | +import org.thingsboard.server.queue.util.TbCoreComponent; | |
19 | + | |
20 | +import java.util.HashMap; | |
21 | +import java.util.Map; | |
22 | + | |
23 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; | |
24 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE_SIZE; | |
25 | + | |
26 | +@RestController | |
27 | +@TbCoreComponent | |
28 | +@RequiredArgsConstructor | |
29 | +@RequestMapping("api/yt/brain/device") | |
30 | +@Api(tags = {"设备台账"}) | |
31 | +@Slf4j | |
32 | +public class BrainDeviceController extends BaseController { | |
33 | + private final BrainDeviceService brainDeviceService; | |
34 | + | |
35 | + @PostMapping("/pageData") | |
36 | + @ApiOperation("分页查询") | |
37 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
38 | + public TkPageData<BrainDeviceDTO> page( | |
39 | + @RequestParam(PAGE_SIZE) int pageSize, | |
40 | + @RequestParam(PAGE) int page, | |
41 | + @RequestBody BrainDeviceDTO dto | |
42 | + ) throws ThingsboardException { | |
43 | + Map<String, Object> queryMap = new HashMap<>(); | |
44 | + queryMap.put(PAGE_SIZE, pageSize); | |
45 | + queryMap.put(PAGE, page); | |
46 | + if (StringUtils.isNotBlank(dto.getName())) { | |
47 | + queryMap.put("name", dto.getName()); | |
48 | + } | |
49 | + return brainDeviceService.page(queryMap); | |
50 | + } | |
51 | + | |
52 | + @PostMapping("/save") | |
53 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
54 | + public ResponseEntity<BrainDeviceDTO> save(@RequestBody BrainDeviceDTO brainDeviceDTO) throws ThingsboardException { | |
55 | + BrainDeviceDTO dto = brainDeviceService.save(brainDeviceDTO); | |
56 | + return ResponseEntity.ok(dto); | |
57 | + } | |
58 | + | |
59 | + @GetMapping("/detail") | |
60 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
61 | + public ResponseEntity<BrainDeviceDTO> detail(@RequestParam("id") String id) throws ThingsboardException { | |
62 | + return ResponseEntity.ok(brainDeviceService.detail(id)); | |
63 | + } | |
64 | + | |
65 | + @GetMapping("/delete") | |
66 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
67 | + public ResponseEntity<Boolean> delete(@RequestParam("id") String id) throws ThingsboardException { | |
68 | + return ResponseEntity.ok(brainDeviceService.delete(id)); | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * 批量删除 | |
73 | + * | |
74 | + * @param brainDeviceDTO | |
75 | + * @return | |
76 | + */ | |
77 | + @DeleteMapping | |
78 | + @PreAuthorize("hasAnyAuthority('SYS_ADMIN','PLATFORM_ADMIN','TENANT_ADMIN')") | |
79 | + public ResponseResult<Boolean> deleteBath( | |
80 | + @Validated({DeleteGroup.class}) @RequestBody BrainDeviceDTO brainDeviceDTO) throws ThingsboardException { | |
81 | + brainDeviceDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
82 | + return ResponseResult.success(brainDeviceService.deleteBath(brainDeviceDTO)); | |
83 | + } | |
84 | + | |
85 | + @PostMapping("/updateStatus") | |
86 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
87 | + @ApiOperation("批量启用停用作废") | |
88 | + public ResponseResult<Boolean> updateStatus(@RequestBody BrainDeviceDTO brainDeviceDTO) throws ThingsboardException { | |
89 | + brainDeviceService.updateStatus(brainDeviceDTO); | |
90 | + return ResponseResult.success(true); | |
91 | + } | |
92 | + | |
93 | +} | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/BrainDeviceDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | |
2 | + | |
3 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
4 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; | |
5 | +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | |
6 | +import io.swagger.annotations.ApiModelProperty; | |
7 | +import lombok.Data; | |
8 | +import lombok.EqualsAndHashCode; | |
9 | +import org.thingsboard.server.common.data.yunteng.common.DeleteGroup; | |
10 | +import org.thingsboard.server.common.data.yunteng.enums.BrainDeviceStatusEnum; | |
11 | + | |
12 | +import javax.validation.constraints.Size; | |
13 | +import java.util.Set; | |
14 | + | |
15 | +@EqualsAndHashCode(callSuper = true) | |
16 | +@Data | |
17 | +public class BrainDeviceDTO extends TenantDTO { | |
18 | + | |
19 | + @ApiModelProperty(value = "状态") | |
20 | + private BrainDeviceStatusEnum status; | |
21 | + @ApiModelProperty(value = "设备编号") | |
22 | + private String code; | |
23 | + @ApiModelProperty(value = "设备名称") | |
24 | + private String name; | |
25 | + @ApiModelProperty(value = "规格型号") | |
26 | + private String model; | |
27 | + @ApiModelProperty(value = "备注") | |
28 | + private String notes; | |
29 | + @ApiModelProperty(value = "设备类型") | |
30 | + private String categoryName; | |
31 | + @ApiModelProperty(value = "存放位置") | |
32 | + private String positionName; | |
33 | + @ApiModelProperty(value = "使用部门") | |
34 | + private String useDepName; | |
35 | + @ApiModelProperty(value = "维保部门") | |
36 | + private String serviceDepName; | |
37 | + @ApiModelProperty(value = "联系方式") | |
38 | + private String contactInfo; | |
39 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |
40 | + @ApiModelProperty(value = "启用时间") | |
41 | + @JsonSerialize(using = LocalDateTimeSerializer.class) | |
42 | + private String enableTime; | |
43 | + @ApiModelProperty(value = "创建人") | |
44 | + private String creatorName; | |
45 | + | |
46 | + @Size( | |
47 | + min = 1, | |
48 | + message = "删除至少需要一个id", | |
49 | + groups = {DeleteGroup.class}) | |
50 | + @ApiModelProperty(value = "删除ID列表", required = true) | |
51 | + private Set<String> ids; | |
52 | +} | ... | ... |
... | ... | @@ -700,6 +700,7 @@ public class ModelConstants { |
700 | 700 | */ |
701 | 701 | public static final String BRAINDEVICECAGEGORY_TABLE_NAME = "qg_brain_device_category";//设备类型 |
702 | 702 | public static final String BRAINDEVICEPOSITION_TABLE_NAME = "qg_brain_device_position";//存放位置 |
703 | + public static final String BRAINDEVICE_TABLE_NAME = "qg_brain_device_position";//设备台账 | |
703 | 704 | |
704 | 705 | protected static final String[] NONE_AGGREGATION_COLUMNS = new String[]{LONG_VALUE_COLUMN, DOUBLE_VALUE_COLUMN, BOOLEAN_VALUE_COLUMN, STRING_VALUE_COLUMN, JSON_VALUE_COLUMN, KEY_COLUMN, TS_COLUMN}; |
705 | 706 | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.entities; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
4 | +import lombok.Data; | |
5 | +import lombok.EqualsAndHashCode; | |
6 | +import org.thingsboard.server.common.data.yunteng.enums.BrainDeviceStatusEnum; | |
7 | +import org.thingsboard.server.dao.model.ModelConstants; | |
8 | + | |
9 | +import java.time.LocalDateTime; | |
10 | + | |
11 | +/** | |
12 | + * 设备台账 | |
13 | + */ | |
14 | +@Data | |
15 | +@EqualsAndHashCode(callSuper = true) | |
16 | +@TableName(value = ModelConstants.BRAINDEVICE_TABLE_NAME, autoResultMap = true) | |
17 | +public class BrainDeviceEntity extends TenantBaseEntity { | |
18 | + /** | |
19 | + * 设备名称 | |
20 | + */ | |
21 | + private String name; | |
22 | + | |
23 | + /** | |
24 | + * 设备编码 | |
25 | + */ | |
26 | + private String code; | |
27 | + | |
28 | + /** | |
29 | + * 规格型号 | |
30 | + */ | |
31 | + private String model; | |
32 | + | |
33 | + /** | |
34 | + * 设备类型id | |
35 | + */ | |
36 | + private String categoryId; | |
37 | + | |
38 | + /** | |
39 | + * 存放位置id | |
40 | + */ | |
41 | + private String positionId; | |
42 | + | |
43 | + /** | |
44 | + * 备注 | |
45 | + */ | |
46 | + private String notes; | |
47 | + | |
48 | + /** | |
49 | + * 当前状态 | |
50 | + */ | |
51 | + private BrainDeviceStatusEnum status; | |
52 | + | |
53 | + /** | |
54 | + * 使用部门 | |
55 | + */ | |
56 | + private String useDep; | |
57 | + | |
58 | + /** | |
59 | + * 维保部门 | |
60 | + */ | |
61 | + private String serviceDep; | |
62 | + | |
63 | + /** | |
64 | + * 联系方式 | |
65 | + */ | |
66 | + private String contactInfo; | |
67 | + | |
68 | + /** | |
69 | + * 启用日期 | |
70 | + */ | |
71 | + private LocalDateTime enableTime; | |
72 | + | |
73 | + /** | |
74 | + * 设备图片 | |
75 | + */ | |
76 | + private String pictures; | |
77 | + | |
78 | + /** | |
79 | + * 关联文档 | |
80 | + */ | |
81 | + private String files; | |
82 | + | |
83 | + | |
84 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
6 | +import lombok.RequiredArgsConstructor; | |
7 | +import lombok.extern.slf4j.Slf4j; | |
8 | +import org.apache.commons.collections4.CollectionUtils; | |
9 | +import org.apache.commons.lang3.StringUtils; | |
10 | +import org.springframework.stereotype.Service; | |
11 | +import org.springframework.transaction.annotation.Transactional; | |
12 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | |
13 | +import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; | |
14 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | |
15 | +import org.thingsboard.server.common.data.yunteng.dto.BrainDeviceDTO; | |
16 | +import org.thingsboard.server.common.data.yunteng.dto.UserDTO; | |
17 | +import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; | |
18 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
19 | +import org.thingsboard.server.dao.yunteng.entities.BrainDeviceEntity; | |
20 | +import org.thingsboard.server.dao.yunteng.mapper.BrainDeviceMapper; | |
21 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | |
22 | +import org.thingsboard.server.dao.yunteng.service.BrainDeviceService; | |
23 | +import org.thingsboard.server.dao.yunteng.service.TkUserService; | |
24 | + | |
25 | +import javax.annotation.Resource; | |
26 | +import java.util.List; | |
27 | +import java.util.Map; | |
28 | +import java.util.UUID; | |
29 | +import java.util.stream.Collectors; | |
30 | + | |
31 | +@Service | |
32 | +@RequiredArgsConstructor | |
33 | +@Slf4j | |
34 | +public class BrainDeviceServiceImpl extends AbstractBaseService<BrainDeviceMapper, BrainDeviceEntity> | |
35 | + implements BrainDeviceService { | |
36 | + | |
37 | + @Resource | |
38 | + private TkUserService tkUserService; | |
39 | + | |
40 | + @Override | |
41 | + public TkPageData<BrainDeviceDTO> page(Map<String, Object> params) throws ThingsboardException { | |
42 | + params.put("tenantId", SpringBeanUtils.getTenantId().getId().toString()); | |
43 | + TkPageData<BrainDeviceDTO> result = new TkPageData<>(); | |
44 | + IPage<BrainDeviceEntity> page = | |
45 | + getPage(params, "create_time", false); | |
46 | + IPage<BrainDeviceDTO> pageData = baseMapper.getDataPage(page, params); | |
47 | + if (pageData != null) { | |
48 | + List<String> creatorIds = pageData.getRecords().stream().map(BrainDeviceDTO::getCreator).collect(Collectors.toList()); | |
49 | + Map<String, UserDTO> userMap = tkUserService.findUserByUserIdListMap(creatorIds); | |
50 | + pageData.getRecords().forEach(item -> { | |
51 | + UserDTO userInfo = userMap.get(item.getCreator()); | |
52 | + if (userInfo != null) { | |
53 | + item.setCreatorName(userInfo.getRealName()); | |
54 | + } | |
55 | + }); | |
56 | + result.setItems(pageData.getRecords()); | |
57 | + } | |
58 | + result.setTotal(Long.valueOf(pageData.getTotal()).intValue()); | |
59 | + return result; | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + public BrainDeviceDTO save(BrainDeviceDTO brainDeviceDTO) throws ThingsboardException { | |
64 | + checkDto(brainDeviceDTO); | |
65 | + if (StringUtils.isBlank(brainDeviceDTO.getId()) && checkDuplicateData(brainDeviceDTO)) { | |
66 | + throw new TkDataValidationException("设备编号重复!"); | |
67 | + } | |
68 | + BrainDeviceEntity entity = new BrainDeviceEntity(); | |
69 | + if (StringUtils.isBlank(brainDeviceDTO.getId())) { | |
70 | + brainDeviceDTO.copyToEntity(entity); | |
71 | + String id = UUID.randomUUID().toString(); | |
72 | + entity.setId(id); | |
73 | + baseMapper.insert(entity); | |
74 | + } else { | |
75 | + LambdaQueryWrapper<BrainDeviceEntity> filter = new QueryWrapper<BrainDeviceEntity>().lambda() | |
76 | + .eq(BrainDeviceEntity::getId, brainDeviceDTO.getId()); | |
77 | + entity = brainDeviceDTO.getEntity(BrainDeviceEntity.class); | |
78 | + baseMapper.update(entity, filter); | |
79 | + } | |
80 | + | |
81 | + | |
82 | + entity.copyToDTO(brainDeviceDTO); | |
83 | + return brainDeviceDTO; | |
84 | + } | |
85 | + | |
86 | + private void checkDto(BrainDeviceDTO dto) throws ThingsboardException { | |
87 | + if (StringUtils.isBlank(dto.getName())) { | |
88 | + throw new TkDataValidationException("设备名称不能为空!"); | |
89 | + } | |
90 | + | |
91 | + if (StringUtils.isBlank(dto.getCode())) { | |
92 | + throw new TkDataValidationException("设备编码不能为空!"); | |
93 | + } | |
94 | + if (StringUtils.isBlank(dto.getTenantId())) { | |
95 | + dto.setTenantId(SpringBeanUtils.getTenantId().getId().toString()); | |
96 | + } | |
97 | + } | |
98 | + | |
99 | + private boolean checkDuplicateData(BrainDeviceDTO BrainDeviceDTO) throws ThingsboardException { | |
100 | + Boolean result = false; | |
101 | + QueryWrapper<BrainDeviceEntity> queryWrapper = new QueryWrapper(); | |
102 | + LambdaQueryWrapper<BrainDeviceEntity> lambda = queryWrapper.lambda(); | |
103 | + lambda.eq(BrainDeviceEntity::getCode, BrainDeviceDTO.getCode()); | |
104 | + List<BrainDeviceEntity> entityList = baseMapper.selectList(queryWrapper); | |
105 | + if (CollectionUtils.isNotEmpty(entityList)) { | |
106 | + return true; | |
107 | + } | |
108 | + | |
109 | + return result; | |
110 | + } | |
111 | + | |
112 | + @Override | |
113 | + public BrainDeviceDTO detail(String id) throws ThingsboardException { | |
114 | + BrainDeviceDTO result = null; | |
115 | + BrainDeviceEntity entity = baseMapper.selectById(id); | |
116 | + if (entity != null) { | |
117 | + result = new BrainDeviceDTO(); | |
118 | + entity.copyToDTO(result); | |
119 | + } | |
120 | + String creatorId = entity.getCreator(); | |
121 | + if (StringUtils.isNotBlank(creatorId)) { | |
122 | + UserDTO userInfo = tkUserService.findUserInfoById(creatorId); | |
123 | + result.setCreatorName(userInfo.getRealName()); | |
124 | + } | |
125 | + return result; | |
126 | + } | |
127 | + | |
128 | + @Override | |
129 | + public boolean delete(String id) throws ThingsboardException { | |
130 | + int count = baseMapper.deleteById(id); | |
131 | + return count > 0; | |
132 | + } | |
133 | + | |
134 | + @Override | |
135 | + @Transactional | |
136 | + public boolean deleteBath(BrainDeviceDTO brainDeviceDTO) { | |
137 | + return baseMapper.delete( | |
138 | + new LambdaQueryWrapper<BrainDeviceEntity>() | |
139 | + .eq(BrainDeviceEntity::getTenantId, brainDeviceDTO.getTenantId()) | |
140 | + .in(BrainDeviceEntity::getId, brainDeviceDTO.getIds())) | |
141 | + > FastIotConstants.MagicNumber.ZERO; | |
142 | + } | |
143 | + | |
144 | + @Override | |
145 | + public void updateStatus(BrainDeviceDTO brainDeviceDTO) throws ThingsboardException { | |
146 | + if (CollectionUtils.isEmpty(brainDeviceDTO.getIds())) { | |
147 | + return; | |
148 | + } | |
149 | + for (String id : brainDeviceDTO.getIds()) { | |
150 | + BrainDeviceEntity entity = baseMapper.selectById(id); | |
151 | + if (entity == null) { | |
152 | + continue; | |
153 | + } | |
154 | + entity.setStatus(brainDeviceDTO.getStatus()); | |
155 | + LambdaQueryWrapper<BrainDeviceEntity> filter = new QueryWrapper<BrainDeviceEntity>().lambda() | |
156 | + .eq(BrainDeviceEntity::getId, entity.getId()); | |
157 | + baseMapper.update(entity, filter); | |
158 | + } | |
159 | + } | |
160 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.mapper; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
4 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
5 | +import org.apache.ibatis.annotations.Mapper; | |
6 | +import org.apache.ibatis.annotations.Param; | |
7 | +import org.thingsboard.server.common.data.yunteng.dto.BrainDeviceDTO; | |
8 | +import org.thingsboard.server.dao.yunteng.entities.BrainDeviceEntity; | |
9 | + | |
10 | +import java.util.Map; | |
11 | + | |
12 | +@Mapper | |
13 | +public interface BrainDeviceMapper extends BaseMapper<BrainDeviceEntity> { | |
14 | + | |
15 | + IPage<BrainDeviceDTO> getDataPage(IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); | |
16 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.service; | |
2 | + | |
3 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | |
4 | +import org.thingsboard.server.common.data.yunteng.dto.BrainDeviceDTO; | |
5 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
6 | +import org.thingsboard.server.dao.yunteng.entities.BrainDeviceEntity; | |
7 | + | |
8 | +import java.util.Map; | |
9 | + | |
10 | +public interface BrainDeviceService extends BaseService<BrainDeviceEntity> { | |
11 | + | |
12 | + TkPageData<BrainDeviceDTO> page(Map<String, Object> params) throws ThingsboardException; | |
13 | + | |
14 | + BrainDeviceDTO save(BrainDeviceDTO BrainDeviceDTO) throws ThingsboardException; | |
15 | + | |
16 | + BrainDeviceDTO detail(String id) throws ThingsboardException; | |
17 | + | |
18 | + boolean delete(String id) throws ThingsboardException; | |
19 | + | |
20 | + | |
21 | + /** | |
22 | + * 批量删除 | |
23 | + * | |
24 | + * @param BrainDeviceDTO 删除IDS | |
25 | + */ | |
26 | + boolean deleteBath(BrainDeviceDTO BrainDeviceDTO) throws ThingsboardException; | |
27 | + | |
28 | + /** | |
29 | + * 批量更新状态 | |
30 | + * | |
31 | + * @param BrainDeviceDTO 更新状态 | |
32 | + */ | |
33 | + void updateStatus(BrainDeviceDTO BrainDeviceDTO) throws ThingsboardException; | |
34 | +} | ... | ... |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
3 | + | |
4 | +<mapper namespace="org.thingsboard.server.dao.yunteng.mapper.BrainDeviceMapper"> | |
5 | + <resultMap type="org.thingsboard.server.common.data.yunteng.dto.BrainDeviceDTO" id="brainDeviceMap"> | |
6 | + <result property="id" column="id"/> | |
7 | + <result property="status" column="status"/> | |
8 | + <result property="name" column="name"/> | |
9 | + <result property="code" column="code"/> | |
10 | + <result property="model" column="model"/> | |
11 | + <result property="notes" column="notes"/> | |
12 | + <result property="categoryName" column="categoryName"/> | |
13 | + <result property="positionName" column="positionName"/> | |
14 | + <result property="useDepName" column="useDepName"/> | |
15 | + <result property="serviceDepName" column="serviceDepName"/> | |
16 | + <result property="contactInfo" column="contact_info"/> | |
17 | + <result property="enableTime" column="enable_time"/> | |
18 | + <result property="tenantId" column="tenant_id"/> | |
19 | + <result property="createTime" column="create_time"/> | |
20 | + <result property="updater" column="updater"/> | |
21 | + <result property="updateTime" column="update_time"/> | |
22 | + <result property="creator" column="creator"/> | |
23 | + </resultMap> | |
24 | + <select id="getDataPage" resultMap="brainDeviceMap"> | |
25 | + SELECT | |
26 | + o.id,o.name,o.code,o.model,o.status,o.notes,o.contact_info,o.enable_time,o.create_time,o.updater,o.update_time,o.creator,c.name as categoryName,p.name as positionName,u.name as useDepName,s.name as serviceDepName | |
27 | + from qg_brain_device o | |
28 | + left join qg_barin_device_category c on o.category_id = c.id | |
29 | + left join qg_brain_device_position p on o.position_id = p.id | |
30 | + left join tk_organization u on o.use_dep = t.id | |
31 | + left join tk_organization s on o.service_dep = s.id | |
32 | + <where> | |
33 | + <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> | |
34 | + AND o.tenant_id = #{queryMap.tenantId} | |
35 | + </if> | |
36 | + <if test="queryMap.name !=null and queryMap.name !=''"> | |
37 | + AND (o.name ILIKE concat('%',#{queryMap.name}::TEXT,'%') OR o.code ILIKE concat('%',#{queryMap.name}::TEXT,'%')) | |
38 | + </if> | |
39 | + <if test="queryMap.status !=null and queryMap.status !=''"> | |
40 | + AND o.status = #{queryMap.status} | |
41 | + </if> | |
42 | + </where> | |
43 | + </select> | |
44 | +</mapper> | |
\ No newline at end of file | ... | ... |