Showing
11 changed files
with
160 additions
and
31 deletions
... | ... | @@ -100,6 +100,7 @@ CREATE TABLE "public"."qg_inspection_plan" |
100 | 100 | "status" varchar(50) NOT NULL, |
101 | 101 | "start_time" timestamp(6), |
102 | 102 | "end_time" timestamp(6), |
103 | + "tenant_id" varchar(36), | |
103 | 104 | "create_time" timestamp(6), |
104 | 105 | "creator" varchar(36), |
105 | 106 | "updater" varchar(36), |
... | ... | @@ -114,6 +115,7 @@ COMMENT ON COLUMN "public"."qg_inspection_plan"."name" IS '计划名称'; |
114 | 115 | COMMENT ON COLUMN "public"."qg_inspection_plan"."status" IS '计划状态'; |
115 | 116 | COMMENT ON COLUMN "public"."qg_inspection_plan"."start_time" IS '开始日期'; |
116 | 117 | COMMENT ON COLUMN "public"."qg_inspection_plan"."end_time" IS '结束日期'; |
118 | +COMMENT ON COLUMN "public"."qg_inspection_plan"."tenant_id" IS '租户ID'; | |
117 | 119 | COMMENT ON COLUMN "public"."qg_inspection_plan"."remark" IS '计划备注'; |
118 | 120 | |
119 | 121 | CREATE TABLE "public"."qg_check_plan" |
... | ... | @@ -124,6 +126,7 @@ CREATE TABLE "public"."qg_check_plan" |
124 | 126 | "type" varchar(50), |
125 | 127 | "status" varchar(50), |
126 | 128 | "plan_details" varchar(255), |
129 | + "tenant_id" varchar(36), | |
127 | 130 | "create_time" timestamp(6), |
128 | 131 | "creator" varchar(36), |
129 | 132 | "updater" varchar(36), |
... | ... | @@ -137,6 +140,7 @@ COMMENT ON COLUMN "public"."qg_check_plan"."name" IS '方案名称'; |
137 | 140 | COMMENT ON COLUMN "public"."qg_check_plan"."type" IS '方案类型'; |
138 | 141 | COMMENT ON COLUMN "public"."qg_check_plan"."status" IS '状态'; |
139 | 142 | COMMENT ON COLUMN "public"."qg_check_plan"."plan_details" IS '方案明细'; |
143 | +COMMENT ON COLUMN "public"."qg_check_plan"."tenant_id" IS '租户ID'; | |
140 | 144 | |
141 | 145 | CREATE TABLE "public"."qg_check_details" |
142 | 146 | ( |
... | ... | @@ -146,6 +150,7 @@ CREATE TABLE "public"."qg_check_details" |
146 | 150 | "check_plan_id" varchar(36), |
147 | 151 | "inspection_plan_id" varchar(36), |
148 | 152 | "plan_details" varchar(255), |
153 | + "tenant_id" varchar(36), | |
149 | 154 | "create_time" timestamp(6), |
150 | 155 | "creator" varchar(36), |
151 | 156 | "updater" varchar(36), |
... | ... | @@ -159,15 +164,17 @@ COMMENT ON COLUMN "public"."qg_check_details"."check_device_id" IS '巡检设备 |
159 | 164 | COMMENT ON COLUMN "public"."qg_check_details"."check_plan_id" IS '巡检方案'; |
160 | 165 | COMMENT ON COLUMN "public"."qg_check_details"."inspection_plan_id" IS '巡检计划'; |
161 | 166 | COMMENT ON COLUMN "public"."qg_check_details"."plan_details" IS '方案明细'; |
167 | +COMMENT ON COLUMN "public"."qg_check_details"."tenant_id" IS '租户ID'; | |
162 | 168 | |
163 | 169 | CREATE TABLE "public"."qg_inspection_record" |
164 | 170 | ( |
165 | 171 | "id" varchar(36) PRIMARY KEY, |
166 | 172 | "code" varchar(50) NOT NULL, |
167 | 173 | "inspection_plan_id" varchar(36), |
168 | - "tenant_id" varchar(36), | |
174 | + "inspector_id" varchar(36), | |
169 | 175 | "check_date" timestamp(6), |
170 | 176 | "record_result" bool, |
177 | + "tenant_id" varchar(36), | |
171 | 178 | "create_time" timestamp(6), |
172 | 179 | "creator" varchar(36), |
173 | 180 | "updater" varchar(36), |
... | ... | @@ -178,9 +185,10 @@ COMMENT ON TABLE "public"."qg_inspection_record" IS '巡检记录'; |
178 | 185 | COMMENT ON COLUMN "public"."qg_inspection_record"."id" IS '主键ID'; |
179 | 186 | COMMENT ON COLUMN "public"."qg_inspection_record"."code" IS '记录编号'; |
180 | 187 | COMMENT ON COLUMN "public"."qg_inspection_record"."inspection_plan_id" IS '巡检计划'; |
181 | -COMMENT ON COLUMN "public"."qg_inspection_record"."tenant_id" IS '巡检人'; | |
188 | +COMMENT ON COLUMN "public"."qg_inspection_record"."inspector_id" IS '巡检人'; | |
182 | 189 | COMMENT ON COLUMN "public"."qg_inspection_record"."check_date" IS '巡检日期'; |
183 | 190 | COMMENT ON COLUMN "public"."qg_inspection_record"."record_result" IS '巡检结果'; |
191 | +COMMENT ON COLUMN "public"."qg_inspection_record"."tenant_id" IS '租户ID'; | |
184 | 192 | |
185 | 193 | CREATE TABLE "public"."qg_inspection_details" |
186 | 194 | ( |
... | ... | @@ -188,6 +196,7 @@ CREATE TABLE "public"."qg_inspection_details" |
188 | 196 | "check_device_id" varchar(36), |
189 | 197 | "plan_details" varchar(255), |
190 | 198 | "record_result" bool, |
199 | + "tenant_id" varchar(36), | |
191 | 200 | "create_time" timestamp(6), |
192 | 201 | "creator" varchar(36), |
193 | 202 | "updater" varchar(36), |
... | ... | @@ -198,4 +207,5 @@ COMMENT ON TABLE "public"."qg_inspection_details" IS '巡检记录明细'; |
198 | 207 | COMMENT ON COLUMN "public"."qg_inspection_details"."id" IS '主键ID'; |
199 | 208 | COMMENT ON COLUMN "public"."qg_inspection_details"."check_device_id" IS '巡检设备'; |
200 | 209 | COMMENT ON COLUMN "public"."qg_inspection_details"."plan_details" IS '巡检内容'; |
201 | -COMMENT ON COLUMN "public"."qg_inspection_details"."record_result" IS '巡检结果'; | |
\ No newline at end of file | ||
210 | +COMMENT ON COLUMN "public"."qg_inspection_details"."record_result" IS '巡检结果'; | |
211 | +COMMENT ON COLUMN "public"."qg_inspection_details"."tenant_id" IS '租户ID'; | |
\ No newline at end of file | ... | ... |
application/src/main/java/org/thingsboard/server/controller/yunteng/TkCheckDetailsController.java
deleted
100644 → 0
1 | -package org.thingsboard.server.controller.yunteng; | |
2 | - | |
3 | -import io.swagger.annotations.Api; | |
4 | -import lombok.RequiredArgsConstructor; | |
5 | -import lombok.extern.slf4j.Slf4j; | |
6 | -import org.springframework.web.bind.annotation.*; | |
7 | -import org.thingsboard.server.controller.BaseController; | |
8 | -import org.thingsboard.server.dao.yunteng.service.TkCheckDetailsService; | |
9 | -import org.thingsboard.server.queue.util.TbCoreComponent; | |
10 | - | |
11 | -@RestController | |
12 | -@TbCoreComponent | |
13 | -@RequiredArgsConstructor | |
14 | -@RequestMapping("api/yt/checkDetails") | |
15 | -@Api(tags = {"巡检/保养方案"}) | |
16 | -@Slf4j | |
17 | -public class TkCheckDetailsController extends BaseController { | |
18 | - private final TkCheckDetailsService tkCheckDetailsService; | |
19 | - | |
20 | -} |
application/src/main/java/org/thingsboard/server/controller/yunteng/TkCheckPlanController.java
0 → 100644
1 | +package org.thingsboard.server.controller.yunteng; | |
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.web.bind.annotation.*; | |
11 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | |
12 | +import org.thingsboard.server.common.data.yunteng.dto.TkCheckPlanDTO; | |
13 | +import org.thingsboard.server.common.data.yunteng.enums.TkCheckPlanStatusEnum; | |
14 | +import org.thingsboard.server.common.data.yunteng.enums.TkCheckPlanTypeEnum; | |
15 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
16 | +import org.thingsboard.server.controller.BaseController; | |
17 | +import org.thingsboard.server.dao.yunteng.service.TkCheckPlanService; | |
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/checkPlan") | |
30 | +@Api(tags = {"巡检/保养方案"}) | |
31 | +@Slf4j | |
32 | +public class TkCheckPlanController extends BaseController { | |
33 | + private final TkCheckPlanService tkCheckPlanService; | |
34 | + | |
35 | + @GetMapping(params = {PAGE_SIZE, PAGE}) | |
36 | + @ApiOperation("分页查询") | |
37 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
38 | + public TkPageData<TkCheckPlanDTO> page( | |
39 | + @RequestParam(PAGE_SIZE) int pageSize, | |
40 | + @RequestParam(PAGE) int page, | |
41 | + @RequestParam(value = "name", required = false) String name, | |
42 | + @RequestParam(value = "type", required = false) TkCheckPlanTypeEnum type | |
43 | + ) throws ThingsboardException { | |
44 | + Map<String, Object> queryMap = new HashMap<>(); | |
45 | + queryMap.put(PAGE_SIZE, pageSize); | |
46 | + queryMap.put(PAGE, page); | |
47 | + if (StringUtils.isNotBlank(name)) { | |
48 | + queryMap.put("name", name); | |
49 | + } | |
50 | + | |
51 | + if (type != null) { | |
52 | + queryMap.put("type", type); | |
53 | + } | |
54 | + | |
55 | + return tkCheckPlanService.page(queryMap, getCurrentUser().isTenantAdmin()); | |
56 | + } | |
57 | + | |
58 | + @PostMapping("/save") | |
59 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
60 | + public ResponseEntity<TkCheckPlanDTO> save(@RequestBody TkCheckPlanDTO tkCheckPlanDTO) { | |
61 | + if (tkCheckPlanDTO.getStatus() == null) { | |
62 | + tkCheckPlanDTO.setStatus(TkCheckPlanStatusEnum.ENABLE); | |
63 | + } | |
64 | + | |
65 | + TkCheckPlanDTO dto = tkCheckPlanService.save(tkCheckPlanDTO); | |
66 | + return ResponseEntity.ok(dto); | |
67 | + } | |
68 | + | |
69 | + @GetMapping("/delete") | |
70 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | |
71 | + public ResponseEntity<Boolean> delete(@RequestParam("id") String id) throws ThingsboardException { | |
72 | + return ResponseEntity.ok(tkCheckPlanService.delete(id)); | |
73 | + } | |
74 | + | |
75 | +} | ... | ... |
... | ... | @@ -5,11 +5,11 @@ import lombok.Data; |
5 | 5 | import lombok.EqualsAndHashCode; |
6 | 6 | |
7 | 7 | /** |
8 | - * 巡检/保养方案 | |
8 | + * 巡检明细 | |
9 | 9 | */ |
10 | 10 | @EqualsAndHashCode(callSuper = true) |
11 | 11 | @Data |
12 | -public class TkCheckDetailsDTO extends BaseDTO { | |
12 | +public class TkCheckDetailsDTO extends TenantDTO { | |
13 | 13 | |
14 | 14 | @ApiModelProperty("明细编号") |
15 | 15 | private String code; | ... | ... |
... | ... | @@ -7,11 +7,11 @@ import org.thingsboard.server.common.data.yunteng.enums.TkCheckPlanStatusEnum; |
7 | 7 | import org.thingsboard.server.common.data.yunteng.enums.TkCheckPlanTypeEnum; |
8 | 8 | |
9 | 9 | /** |
10 | - * 巡检明细 | |
10 | + * 巡检/保养方案 | |
11 | 11 | */ |
12 | 12 | @EqualsAndHashCode(callSuper = true) |
13 | 13 | @Data |
14 | -public class TkCheckPlanDTO extends BaseDTO { | |
14 | +public class TkCheckPlanDTO extends TenantDTO { | |
15 | 15 | |
16 | 16 | @ApiModelProperty("方案编号") |
17 | 17 | private String code; | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkInspectionDetailsDTO.java
... | ... | @@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode; |
9 | 9 | */ |
10 | 10 | @EqualsAndHashCode(callSuper = true) |
11 | 11 | @Data |
12 | -public class TkInspectionDetailsDTO extends BaseDTO { | |
12 | +public class TkInspectionDetailsDTO extends TenantDTO { | |
13 | 13 | |
14 | 14 | @ApiModelProperty("巡检设备") |
15 | 15 | private String checkDeviceId; | ... | ... |
... | ... | @@ -15,7 +15,7 @@ import java.time.LocalDateTime; |
15 | 15 | */ |
16 | 16 | @EqualsAndHashCode(callSuper = true) |
17 | 17 | @Data |
18 | -public class TkInspectionPlanDTO extends BaseDTO { | |
18 | +public class TkInspectionPlanDTO extends TenantDTO { | |
19 | 19 | |
20 | 20 | @ApiModelProperty("计划编号") |
21 | 21 | private String code; | ... | ... |
... | ... | @@ -6,7 +6,6 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; |
6 | 6 | import io.swagger.annotations.ApiModelProperty; |
7 | 7 | import lombok.Data; |
8 | 8 | import lombok.EqualsAndHashCode; |
9 | -import org.thingsboard.server.common.data.yunteng.enums.TkInspectionPlanStatusEnum; | |
10 | 9 | |
11 | 10 | import java.time.LocalDateTime; |
12 | 11 | |
... | ... | @@ -15,7 +14,7 @@ import java.time.LocalDateTime; |
15 | 14 | */ |
16 | 15 | @EqualsAndHashCode(callSuper = true) |
17 | 16 | @Data |
18 | -public class TkInspectionRecordDTO extends BaseDTO { | |
17 | +public class TkInspectionRecordDTO extends TenantDTO { | |
19 | 18 | |
20 | 19 | @ApiModelProperty("记录编号") |
21 | 20 | private String code; |
... | ... | @@ -23,6 +22,9 @@ public class TkInspectionRecordDTO extends BaseDTO { |
23 | 22 | @ApiModelProperty("巡检计划") |
24 | 23 | private String inspectionPlanId; |
25 | 24 | |
25 | + @ApiModelProperty("巡检人") | |
26 | + private String inspectorId; | |
27 | + | |
26 | 28 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
27 | 29 | @ApiModelProperty(value = "巡检日期") |
28 | 30 | @JsonSerialize(using = LocalDateTimeSerializer.class) | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.impl; |
2 | 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; | |
3 | 6 | import lombok.RequiredArgsConstructor; |
4 | 7 | import lombok.extern.slf4j.Slf4j; |
8 | +import org.apache.commons.lang3.StringUtils; | |
5 | 9 | import org.springframework.stereotype.Service; |
10 | +import org.thingsboard.server.common.data.yunteng.dto.TkCheckPlanDTO; | |
11 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
6 | 12 | import org.thingsboard.server.dao.yunteng.entities.TkCheckPlanEntity; |
7 | 13 | import org.thingsboard.server.dao.yunteng.mapper.TkCheckPlanMapper; |
8 | 14 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
9 | 15 | import org.thingsboard.server.dao.yunteng.service.TkCheckPlanService; |
10 | 16 | |
17 | +import java.util.Map; | |
18 | + | |
11 | 19 | @Service |
12 | 20 | @RequiredArgsConstructor |
13 | 21 | @Slf4j |
14 | 22 | public class TkCheckPlanServiceImpl extends AbstractBaseService<TkCheckPlanMapper, TkCheckPlanEntity> |
15 | 23 | implements TkCheckPlanService { |
24 | + @Override | |
25 | + public TkPageData<TkCheckPlanDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin) { | |
26 | + QueryWrapper<TkCheckPlanEntity> wrapper = new QueryWrapper<>(); | |
27 | + LambdaQueryWrapper<TkCheckPlanEntity> lambda = wrapper.lambda(); | |
28 | + if (queryMap != null && queryMap.get("name") != null) { | |
29 | + lambda.eq(TkCheckPlanEntity::getName, queryMap.get("code").toString()); | |
30 | + } | |
31 | + | |
32 | + if (queryMap != null && queryMap.get("type") != null) { | |
33 | + lambda.eq(TkCheckPlanEntity::getType, queryMap.get("type").toString()); | |
34 | + } | |
35 | + | |
36 | + IPage<TkCheckPlanEntity> page = baseMapper.selectPage(getPage(queryMap, "create_time", false), | |
37 | + wrapper); | |
38 | + | |
39 | + return getPageData(page, TkCheckPlanDTO.class); | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public TkCheckPlanDTO save(TkCheckPlanDTO tkCheckPlanDTO) { | |
44 | + TkCheckPlanEntity entity = new TkCheckPlanEntity(); | |
45 | + if (StringUtils.isBlank(tkCheckPlanDTO.getId())) { | |
46 | + tkCheckPlanDTO.copyToEntity(entity); | |
47 | + baseMapper.insert(entity); | |
48 | + } else { | |
49 | + LambdaQueryWrapper<TkCheckPlanEntity> filter = new QueryWrapper<TkCheckPlanEntity>().lambda() | |
50 | + .eq(TkCheckPlanEntity::getId, tkCheckPlanDTO.getId()); | |
51 | + entity = tkCheckPlanDTO.getEntity(TkCheckPlanEntity.class); | |
52 | + baseMapper.update(entity, filter); | |
53 | + } | |
54 | + | |
55 | + entity.copyToDTO(tkCheckPlanDTO); | |
56 | + return tkCheckPlanDTO; | |
57 | + } | |
58 | + | |
59 | + @Override | |
60 | + public boolean delete(String id) { | |
61 | + int count = baseMapper.deleteById(id); | |
62 | + return count > 0; | |
63 | + } | |
16 | 64 | } | ... | ... |
1 | 1 | package org.thingsboard.server.dao.yunteng.service; |
2 | 2 | |
3 | +import org.thingsboard.server.common.data.yunteng.dto.TkCheckPlanDTO; | |
4 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | |
3 | 5 | import org.thingsboard.server.dao.yunteng.entities.TkCheckPlanEntity; |
4 | 6 | |
7 | +import java.util.Map; | |
8 | + | |
5 | 9 | public interface TkCheckPlanService extends BaseService<TkCheckPlanEntity> { |
10 | + TkPageData<TkCheckPlanDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin); | |
11 | + | |
12 | + TkCheckPlanDTO save(TkCheckPlanDTO tkCheckPlanDTO); | |
13 | + | |
14 | + boolean delete(String id); | |
6 | 15 | } | ... | ... |