Showing
19 changed files
with
671 additions
and
22 deletions
@@ -292,6 +292,7 @@ CREATE TABLE "public"."qg_device_cagegory" ( | @@ -292,6 +292,7 @@ CREATE TABLE "public"."qg_device_cagegory" ( | ||
292 | "name" varchar(50), | 292 | "name" varchar(50), |
293 | "parent_id" varchar(36), | 293 | "parent_id" varchar(36), |
294 | "cagegory_order" int4, | 294 | "cagegory_order" int4, |
295 | + "path_id" varchar(500), | ||
295 | "tenant_id" varchar(36), | 296 | "tenant_id" varchar(36), |
296 | "create_time" timestamp(6), | 297 | "create_time" timestamp(6), |
297 | "creator" varchar(36), | 298 | "creator" varchar(36), |
@@ -946,6 +946,7 @@ CREATE TABLE IF NOT EXISTS qg_inspection_plan ( | @@ -946,6 +946,7 @@ CREATE TABLE IF NOT EXISTS qg_inspection_plan ( | ||
946 | "status" varchar(50) NOT NULL, | 946 | "status" varchar(50) NOT NULL, |
947 | "start_time" timestamp(6), | 947 | "start_time" timestamp(6), |
948 | "end_time" timestamp(6), | 948 | "end_time" timestamp(6), |
949 | + "tenant_id" varchar(36), | ||
949 | "create_time" timestamp(6), | 950 | "create_time" timestamp(6), |
950 | "creator" varchar(36), | 951 | "creator" varchar(36), |
951 | "updater" varchar(36), | 952 | "updater" varchar(36), |
@@ -961,6 +962,7 @@ CREATE TABLE IF NOT EXISTS qg_check_plan | @@ -961,6 +962,7 @@ CREATE TABLE IF NOT EXISTS qg_check_plan | ||
961 | "type" varchar(50), | 962 | "type" varchar(50), |
962 | "status" varchar(50), | 963 | "status" varchar(50), |
963 | "plan_details" varchar(255), | 964 | "plan_details" varchar(255), |
965 | + "tenant_id" varchar(36), | ||
964 | "create_time" timestamp(6), | 966 | "create_time" timestamp(6), |
965 | "creator" varchar(36), | 967 | "creator" varchar(36), |
966 | "updater" varchar(36), | 968 | "updater" varchar(36), |
@@ -975,6 +977,8 @@ CREATE TABLE IF NOT EXISTS qg_check_details | @@ -975,6 +977,8 @@ CREATE TABLE IF NOT EXISTS qg_check_details | ||
975 | "check_plan_id" varchar(36), | 977 | "check_plan_id" varchar(36), |
976 | "inspection_plan_id" varchar(36), | 978 | "inspection_plan_id" varchar(36), |
977 | "plan_details" varchar(255), | 979 | "plan_details" varchar(255), |
980 | + "show_order" int4, | ||
981 | + "tenant_id" varchar(36), | ||
978 | "create_time" timestamp(6), | 982 | "create_time" timestamp(6), |
979 | "creator" varchar(36), | 983 | "creator" varchar(36), |
980 | "updater" varchar(36), | 984 | "updater" varchar(36), |
@@ -986,9 +990,10 @@ CREATE TABLE IF NOT EXISTS qg_inspection_record | @@ -986,9 +990,10 @@ CREATE TABLE IF NOT EXISTS qg_inspection_record | ||
986 | "id" varchar(36) PRIMARY KEY, | 990 | "id" varchar(36) PRIMARY KEY, |
987 | "code" varchar(50) NOT NULL, | 991 | "code" varchar(50) NOT NULL, |
988 | "inspection_plan_id" varchar(36), | 992 | "inspection_plan_id" varchar(36), |
989 | - "tenant_id" varchar(36), | 993 | + "inspector_id" varchar(36), |
990 | "check_date" timestamp(6), | 994 | "check_date" timestamp(6), |
991 | "record_result" bool, | 995 | "record_result" bool, |
996 | + "tenant_id" varchar(36), | ||
992 | "create_time" timestamp(6), | 997 | "create_time" timestamp(6), |
993 | "creator" varchar(36), | 998 | "creator" varchar(36), |
994 | "updater" varchar(36), | 999 | "updater" varchar(36), |
@@ -997,14 +1002,17 @@ CREATE TABLE IF NOT EXISTS qg_inspection_record | @@ -997,14 +1002,17 @@ CREATE TABLE IF NOT EXISTS qg_inspection_record | ||
997 | 1002 | ||
998 | CREATE TABLE IF NOT EXISTS qg_inspection_details | 1003 | CREATE TABLE IF NOT EXISTS qg_inspection_details |
999 | ( | 1004 | ( |
1000 | - "id" varchar(36) PRIMARY KEY, | ||
1001 | - "check_device_id" varchar(36), | ||
1002 | - "plan_details" varchar(255), | ||
1003 | - "record_result" bool, | ||
1004 | - "create_time" timestamp(6), | ||
1005 | - "creator" varchar(36), | ||
1006 | - "updater" varchar(36), | ||
1007 | - "update_time" timestamp(6) | 1005 | + "id" varchar(36) PRIMARY KEY, |
1006 | + "check_device_id" varchar(36), | ||
1007 | + "plan_details" varchar(255), | ||
1008 | + "record_result" bool, | ||
1009 | + "show_order" int4, | ||
1010 | + "inspection_record_id" varchar(36), | ||
1011 | + "tenant_id" varchar(36), | ||
1012 | + "create_time" timestamp(6), | ||
1013 | + "creator" varchar(36), | ||
1014 | + "updater" varchar(36), | ||
1015 | + "update_time" timestamp(6) | ||
1008 | ); | 1016 | ); |
1009 | 1017 | ||
1010 | CREATE TABLE IF NOT EXISTS qg_preserve_detail ( | 1018 | CREATE TABLE IF NOT EXISTS qg_preserve_detail ( |
@@ -1058,6 +1066,7 @@ CREATE TABLE IF NOT EXISTS qg_device_cagegory ( | @@ -1058,6 +1066,7 @@ CREATE TABLE IF NOT EXISTS qg_device_cagegory ( | ||
1058 | "name" varchar(50), | 1066 | "name" varchar(50), |
1059 | "parent_id" varchar(36), | 1067 | "parent_id" varchar(36), |
1060 | "cagegory_order" int4, | 1068 | "cagegory_order" int4, |
1069 | + "path_id" varchar(500), | ||
1061 | "tenant_id" varchar(36), | 1070 | "tenant_id" varchar(36), |
1062 | "create_time" timestamp(6), | 1071 | "create_time" timestamp(6), |
1063 | "creator" varchar(36), | 1072 | "creator" varchar(36), |
@@ -33,8 +33,8 @@ public class TkDeviceCagegoryController extends BaseController { | @@ -33,8 +33,8 @@ public class TkDeviceCagegoryController extends BaseController { | ||
33 | @PostMapping("/getAllCagegory") | 33 | @PostMapping("/getAllCagegory") |
34 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | 34 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") |
35 | @ApiOperation("根据父类型获取设备类别") | 35 | @ApiOperation("根据父类型获取设备类别") |
36 | - public List<TkDeviceCagegoryDTO> getAllCagegory() throws ThingsboardException { | ||
37 | - return tkDeviceCagegoryService.getAllCagegory(); | 36 | + public List<TkDeviceCagegoryDTO> getAllCagegory(@RequestBody TkDeviceCagegoryDTO dto) throws ThingsboardException { |
37 | + return tkDeviceCagegoryService.getAllCagegory(dto); | ||
38 | } | 38 | } |
39 | 39 | ||
40 | @PostMapping("/save") | 40 | @PostMapping("/save") |
application/src/main/java/org/thingsboard/server/controller/yunteng/TkDeviceAccountController.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.core.exception.TkDataValidationException; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO; | ||
14 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceCagegoryDTO; | ||
15 | +import org.thingsboard.server.common.data.yunteng.dto.TkSupplierDTO; | ||
16 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | ||
17 | +import org.thingsboard.server.controller.BaseController; | ||
18 | +import org.thingsboard.server.dao.yunteng.service.TkDeviceAccountService; | ||
19 | +import org.thingsboard.server.dao.yunteng.service.TkDeviceCagegoryService; | ||
20 | +import org.thingsboard.server.dao.yunteng.service.TkSupplierService; | ||
21 | +import org.thingsboard.server.queue.util.TbCoreComponent; | ||
22 | + | ||
23 | +import java.util.Map; | ||
24 | + | ||
25 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; | ||
26 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE_SIZE; | ||
27 | + | ||
28 | +@RestController | ||
29 | +@TbCoreComponent | ||
30 | +@RequiredArgsConstructor | ||
31 | +@RequestMapping("api/yt/da") | ||
32 | +@Api(tags = {"设备台账管理"}) | ||
33 | +@Slf4j | ||
34 | +public class TkDeviceAccountController extends BaseController { | ||
35 | + private final TkDeviceAccountService tkDeviceAccountService; | ||
36 | + private final TkSupplierService tkSupplierService; | ||
37 | + private final TkDeviceCagegoryService tkDeviceCagegoryService; | ||
38 | + | ||
39 | + | ||
40 | + @PostMapping("/save") | ||
41 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
42 | + @ApiOperation("设备台账保存") | ||
43 | + public ResponseEntity<TkDeviceAccountDTO> save(@RequestBody TkDeviceAccountDTO dto) throws ThingsboardException { | ||
44 | + if (StringUtils.isNotBlank(dto.getSupplierId())) { | ||
45 | + TkSupplierDTO supplierDTO = tkSupplierService.detail(dto.getSupplierId()); | ||
46 | + if (supplierDTO == null) { | ||
47 | + throw new TkDataValidationException("供应商不存在!"); | ||
48 | + } | ||
49 | + } | ||
50 | + | ||
51 | + if (StringUtils.isNotBlank(dto.getCategoryId())) { | ||
52 | + TkDeviceCagegoryDTO cagegoryDTO = tkDeviceCagegoryService.detail(dto.getCategoryId()); | ||
53 | + if (cagegoryDTO == null) { | ||
54 | + throw new TkDataValidationException("设备类型不存在!"); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + TkDeviceAccountDTO deviceAccountDTO = tkDeviceAccountService.save(dto); | ||
59 | + return ResponseEntity.ok(deviceAccountDTO); | ||
60 | + } | ||
61 | + | ||
62 | + @GetMapping("/delete") | ||
63 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
64 | + @ApiOperation("设备台账删除") | ||
65 | + public ResponseEntity<Boolean> delete(@RequestParam("id") String id) throws ThingsboardException { | ||
66 | + return ResponseEntity.ok(tkDeviceAccountService.delete(id)); | ||
67 | + } | ||
68 | + | ||
69 | + @GetMapping("/detail") | ||
70 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
71 | + @ApiOperation("设备台账详情") | ||
72 | + public ResponseEntity<TkDeviceAccountDTO> detail(@RequestParam("id") String id) throws ThingsboardException { | ||
73 | + TkDeviceAccountDTO deviceDTO = tkDeviceAccountService.detail(id); | ||
74 | + return ResponseEntity.ok(deviceDTO); | ||
75 | + } | ||
76 | + | ||
77 | + @PostMapping("/pageData") | ||
78 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
79 | + @ApiOperation("设备台账列表") | ||
80 | + public TkPageData<TkDeviceAccountDTO> pageMalfunctionReason( | ||
81 | + @RequestParam(PAGE_SIZE) int pageSize, | ||
82 | + @RequestParam(PAGE) int page, | ||
83 | + @RequestBody Map<String, Object> params) | ||
84 | + throws ThingsboardException { | ||
85 | + params.put(PAGE, page); | ||
86 | + params.put(PAGE_SIZE, pageSize); | ||
87 | + return tkDeviceAccountService.page(params); | ||
88 | + } | ||
89 | +} |
@@ -31,7 +31,7 @@ public class TkMalfunctionReasonController extends BaseController { | @@ -31,7 +31,7 @@ public class TkMalfunctionReasonController extends BaseController { | ||
31 | 31 | ||
32 | @PostMapping("/pageData") | 32 | @PostMapping("/pageData") |
33 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | 33 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") |
34 | - @ApiOperation("获取满足条件的所有设备") | 34 | + @ApiOperation("故障原因分页") |
35 | public TkPageData<TkMalfunctionReasonDTO> pageMalfunctionReason( | 35 | public TkPageData<TkMalfunctionReasonDTO> pageMalfunctionReason( |
36 | @RequestParam(PAGE_SIZE) int pageSize, | 36 | @RequestParam(PAGE_SIZE) int pageSize, |
37 | @RequestParam(PAGE) int page, | 37 | @RequestParam(PAGE) int page, |
@@ -44,7 +44,7 @@ public class TkMalfunctionReasonController extends BaseController { | @@ -44,7 +44,7 @@ public class TkMalfunctionReasonController extends BaseController { | ||
44 | 44 | ||
45 | @PostMapping("/list") | 45 | @PostMapping("/list") |
46 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | 46 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") |
47 | - @ApiOperation("获取满足条件的所有设备") | 47 | + @ApiOperation("故障原因列表") |
48 | public List<TkMalfunctionReasonDTO> list( | 48 | public List<TkMalfunctionReasonDTO> list( |
49 | @RequestBody TkMalfunctionReasonDTO queryMap) throws ThingsboardException { | 49 | @RequestBody TkMalfunctionReasonDTO queryMap) throws ThingsboardException { |
50 | return tkMalfunctionReasonService.list(queryMap); | 50 | return tkMalfunctionReasonService.list(queryMap); |
@@ -66,7 +66,7 @@ public class TkMalfunctionReasonController extends BaseController { | @@ -66,7 +66,7 @@ public class TkMalfunctionReasonController extends BaseController { | ||
66 | 66 | ||
67 | @GetMapping("/detail") | 67 | @GetMapping("/detail") |
68 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | 68 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") |
69 | - @ApiOperation("保养计划详情") | 69 | + @ApiOperation("故障原因详情") |
70 | public ResponseEntity<TkMalfunctionReasonDTO> detail(@RequestParam("id") String id) throws ThingsboardException { | 70 | public ResponseEntity<TkMalfunctionReasonDTO> detail(@RequestParam("id") String id) throws ThingsboardException { |
71 | TkMalfunctionReasonDTO dto = tkMalfunctionReasonService.detail(id); | 71 | TkMalfunctionReasonDTO dto = tkMalfunctionReasonService.detail(id); |
72 | return ResponseEntity.ok(dto); | 72 | return ResponseEntity.ok(dto); |
@@ -74,11 +74,11 @@ public class TkMalfunctionReasonController extends BaseController { | @@ -74,11 +74,11 @@ public class TkMalfunctionReasonController extends BaseController { | ||
74 | 74 | ||
75 | @PostMapping("/updateStatus") | 75 | @PostMapping("/updateStatus") |
76 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | 76 | @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") |
77 | - @ApiOperation("更新保养计划状态") | 77 | + @ApiOperation("更新故障原因状态") |
78 | public ResponseEntity<TkMalfunctionReasonDTO> updateStatus(@RequestBody TkMalfunctionReasonDTO dto) throws ThingsboardException { | 78 | public ResponseEntity<TkMalfunctionReasonDTO> updateStatus(@RequestBody TkMalfunctionReasonDTO dto) throws ThingsboardException { |
79 | TkMalfunctionReasonDTO orderInfo = tkMalfunctionReasonService.detail(dto.getId()); | 79 | TkMalfunctionReasonDTO orderInfo = tkMalfunctionReasonService.detail(dto.getId()); |
80 | if (orderInfo == null) { | 80 | if (orderInfo == null) { |
81 | - throw new TkDataValidationException("保养计划不存在!"); | 81 | + throw new TkDataValidationException("故障原因不存在!"); |
82 | } | 82 | } |
83 | 83 | ||
84 | tkMalfunctionReasonService.updateStatus(dto.getId(), dto.getStatus()); | 84 | tkMalfunctionReasonService.updateStatus(dto.getId(), dto.getStatus()); |
application/src/main/java/org/thingsboard/server/controller/yunteng/TkSupplierController.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.springframework.http.ResponseEntity; | ||
8 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
9 | +import org.springframework.web.bind.annotation.*; | ||
10 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
11 | +import org.thingsboard.server.common.data.yunteng.dto.TkSupplierDTO; | ||
12 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | ||
13 | +import org.thingsboard.server.controller.BaseController; | ||
14 | +import org.thingsboard.server.dao.yunteng.service.TkSupplierService; | ||
15 | +import org.thingsboard.server.queue.util.TbCoreComponent; | ||
16 | + | ||
17 | +import java.util.List; | ||
18 | + | ||
19 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; | ||
20 | +import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE_SIZE; | ||
21 | + | ||
22 | +@RestController | ||
23 | +@TbCoreComponent | ||
24 | +@RequiredArgsConstructor | ||
25 | +@RequestMapping("api/yt/supplier") | ||
26 | +@Api(tags = {"供应商管理"}) | ||
27 | +@Slf4j | ||
28 | +public class TkSupplierController extends BaseController { | ||
29 | + private final TkSupplierService tkSupplierService; | ||
30 | + | ||
31 | + | ||
32 | + @PostMapping("/pageData") | ||
33 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
34 | + @ApiOperation("供应商分页") | ||
35 | + public TkPageData<TkSupplierDTO> pageMalfunctionReason( | ||
36 | + @RequestParam(PAGE_SIZE) int pageSize, | ||
37 | + @RequestParam(PAGE) int page, | ||
38 | + @RequestBody TkSupplierDTO dto) | ||
39 | + throws ThingsboardException { | ||
40 | + dto.setPage(page); | ||
41 | + dto.setPageSize(pageSize); | ||
42 | + return tkSupplierService.page(dto); | ||
43 | + } | ||
44 | + | ||
45 | + @PostMapping("/list") | ||
46 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
47 | + @ApiOperation("供应商列表") | ||
48 | + public List<TkSupplierDTO> list( | ||
49 | + @RequestBody TkSupplierDTO queryMap) throws ThingsboardException { | ||
50 | + return tkSupplierService.list(queryMap); | ||
51 | + } | ||
52 | + | ||
53 | + @PostMapping("/save") | ||
54 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
55 | + @ApiOperation("供应商保存") | ||
56 | + public ResponseEntity<TkSupplierDTO> save(@RequestBody TkSupplierDTO param) throws ThingsboardException { | ||
57 | + TkSupplierDTO deviceDTO = tkSupplierService.save(param); | ||
58 | + return ResponseEntity.ok(deviceDTO); | ||
59 | + } | ||
60 | + | ||
61 | + @PostMapping("/delete") | ||
62 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
63 | + public ResponseEntity<Boolean> delete(@RequestBody TkSupplierDTO param) throws ThingsboardException { | ||
64 | + return ResponseEntity.ok(tkSupplierService.delete(param.getIds())); | ||
65 | + } | ||
66 | + | ||
67 | + @GetMapping("/detail") | ||
68 | + @PreAuthorize("hasAnyAuthority('TENANT_ADMIN','CUSTOMER_USER')") | ||
69 | + @ApiOperation("供应商详情") | ||
70 | + public ResponseEntity<TkSupplierDTO> detail(@RequestParam("id") String id) throws ThingsboardException { | ||
71 | + TkSupplierDTO dto = tkSupplierService.detail(id); | ||
72 | + return ResponseEntity.ok(dto); | ||
73 | + } | ||
74 | +} |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkDeviceAccountDTO.java
renamed from
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkDeviceAccountEntityDTO.java
@@ -6,12 +6,13 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | @@ -6,12 +6,13 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | ||
6 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
7 | import lombok.Data; | 7 | import lombok.Data; |
8 | import lombok.EqualsAndHashCode; | 8 | import lombok.EqualsAndHashCode; |
9 | +import org.thingsboard.server.common.data.yunteng.enums.TkDeviceAccountEnum; | ||
9 | 10 | ||
10 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
11 | 12 | ||
12 | @EqualsAndHashCode(callSuper = true) | 13 | @EqualsAndHashCode(callSuper = true) |
13 | @Data | 14 | @Data |
14 | -public class TkDeviceAccountEntityDTO extends TenantDTO { | 15 | +public class TkDeviceAccountDTO extends TenantDTO { |
15 | @ApiModelProperty(value = "设备名称") | 16 | @ApiModelProperty(value = "设备名称") |
16 | private String name; | 17 | private String name; |
17 | 18 | ||
@@ -22,7 +23,7 @@ public class TkDeviceAccountEntityDTO extends TenantDTO { | @@ -22,7 +23,7 @@ public class TkDeviceAccountEntityDTO extends TenantDTO { | ||
22 | private String categoryId; | 23 | private String categoryId; |
23 | 24 | ||
24 | @ApiModelProperty(value = "状态(FAULT故障,NORMAL正常,SCRAP报废)") | 25 | @ApiModelProperty(value = "状态(FAULT故障,NORMAL正常,SCRAP报废)") |
25 | - private String status; | 26 | + private TkDeviceAccountEnum status; |
26 | 27 | ||
27 | @ApiModelProperty(value = "负责人id") | 28 | @ApiModelProperty(value = "负责人id") |
28 | private String directorId; | 29 | private String directorId; |
@@ -79,4 +80,7 @@ public class TkDeviceAccountEntityDTO extends TenantDTO { | @@ -79,4 +80,7 @@ public class TkDeviceAccountEntityDTO extends TenantDTO { | ||
79 | 80 | ||
80 | @ApiModelProperty(value = "类别名称") | 81 | @ApiModelProperty(value = "类别名称") |
81 | private String categoryName; | 82 | private String categoryName; |
83 | + | ||
84 | + @ApiModelProperty(value = "供应商信息") | ||
85 | + private TkSupplierDTO supplierInfo; | ||
82 | } | 86 | } |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkSupplierDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | +import lombok.Data; | ||
5 | +import lombok.EqualsAndHashCode; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +@EqualsAndHashCode(callSuper = true) | ||
10 | +@Data | ||
11 | +public class TkSupplierDTO extends TenantDTO { | ||
12 | + @ApiModelProperty(value = "供应商名称") | ||
13 | + private String name; | ||
14 | + @ApiModelProperty(value = "供应商编号") | ||
15 | + private String code; | ||
16 | + @ApiModelProperty(value = "供应商联系人") | ||
17 | + private String contacts; | ||
18 | + @ApiModelProperty(value = "供应商联系人手机号") | ||
19 | + private String contactsMobile; | ||
20 | + | ||
21 | + @ApiModelProperty(value = "页号") | ||
22 | + private Integer page; | ||
23 | + | ||
24 | + @ApiModelProperty(value = "页码") | ||
25 | + private Integer pageSize; | ||
26 | + | ||
27 | + private List<String> ids; | ||
28 | +} |
@@ -686,7 +686,7 @@ public class ModelConstants { | @@ -686,7 +686,7 @@ public class ModelConstants { | ||
686 | public static final String TKDEVICECAGEGORY_TABLE_NAME = "qg_device_cagegory";//设备类别 | 686 | public static final String TKDEVICECAGEGORY_TABLE_NAME = "qg_device_cagegory";//设备类别 |
687 | public static final String TKDEVICEACCOUNT_TABLE_NAME = "qg_device_account";//设备台账 | 687 | public static final String TKDEVICEACCOUNT_TABLE_NAME = "qg_device_account";//设备台账 |
688 | public static final String TKINSTALLLOCATION_TABLE_NAME = "qg_install_location";//设备台账 | 688 | public static final String TKINSTALLLOCATION_TABLE_NAME = "qg_install_location";//设备台账 |
689 | - public static final String TKSUPPLIER_TABLE_NAME = "qg_supplier";//设备台账 | 689 | + public static final String TKSUPPLIER_TABLE_NAME = "qg_supplier";//供应商 |
690 | 690 | ||
691 | public static final String TKINSPECTIONPLAN_TABLE_NAME= "qg_inspection_plan"; // 巡检计划 | 691 | public static final String TKINSPECTIONPLAN_TABLE_NAME= "qg_inspection_plan"; // 巡检计划 |
692 | public static final String TKCHECKPLAN_TABLE_NAME= "qg_check_plan"; // 巡检/保养方案 | 692 | public static final String TKCHECKPLAN_TABLE_NAME= "qg_check_plan"; // 巡检/保养方案 |
@@ -3,6 +3,7 @@ package org.thingsboard.server.dao.yunteng.entities; | @@ -3,6 +3,7 @@ package org.thingsboard.server.dao.yunteng.entities; | ||
3 | import com.baomidou.mybatisplus.annotation.TableName; | 3 | import com.baomidou.mybatisplus.annotation.TableName; |
4 | import lombok.Data; | 4 | import lombok.Data; |
5 | import lombok.EqualsAndHashCode; | 5 | import lombok.EqualsAndHashCode; |
6 | +import org.thingsboard.server.common.data.yunteng.enums.TkDeviceAccountEnum; | ||
6 | import org.thingsboard.server.dao.model.ModelConstants; | 7 | import org.thingsboard.server.dao.model.ModelConstants; |
7 | 8 | ||
8 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
@@ -17,7 +18,7 @@ public class TkDeviceAccountEntity extends TenantBaseEntity { | @@ -17,7 +18,7 @@ public class TkDeviceAccountEntity extends TenantBaseEntity { | ||
17 | private String name; | 18 | private String name; |
18 | private String code; | 19 | private String code; |
19 | private String categoryId; | 20 | private String categoryId; |
20 | - private String status; | 21 | + private TkDeviceAccountEnum status; |
21 | private String directorId; | 22 | private String directorId; |
22 | private Boolean isOnline; | 23 | private Boolean isOnline; |
23 | private String brand; | 24 | private String brand; |
dao/src/main/java/org/thingsboard/server/dao/yunteng/impl/TkDeviceAccountServiceImpl.java
0 → 100644
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.lang3.StringUtils; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | +import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
11 | +import org.thingsboard.server.common.data.id.TenantId; | ||
12 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | ||
13 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO; | ||
14 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceCagegoryDTO; | ||
15 | +import org.thingsboard.server.common.data.yunteng.dto.TkSupplierDTO; | ||
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.TkDeviceAccountEntity; | ||
20 | +import org.thingsboard.server.dao.yunteng.mapper.TkDeviceAccountMapper; | ||
21 | +import org.thingsboard.server.dao.yunteng.service.*; | ||
22 | + | ||
23 | +import java.util.Map; | ||
24 | + | ||
25 | +@Service | ||
26 | +@RequiredArgsConstructor | ||
27 | +@Slf4j | ||
28 | +public class TkDeviceAccountServiceImpl extends AbstractBaseService<TkDeviceAccountMapper, TkDeviceAccountEntity> | ||
29 | + implements TkDeviceAccountService { | ||
30 | + | ||
31 | + private final TkSupplierService tkSupplierService; | ||
32 | + | ||
33 | + private final TkDeviceCagegoryService tkDeviceCagegoryService; | ||
34 | + | ||
35 | + private final TkUserService tkUserService; | ||
36 | + | ||
37 | + @Override | ||
38 | + public TkPageData<TkDeviceAccountDTO> page(Map<String, Object> params) { | ||
39 | + TkPageData<TkDeviceAccountDTO> result = new TkPageData<>(); | ||
40 | + IPage<TkDeviceAccountEntity> page = | ||
41 | + getPage(params, "create_time", false); | ||
42 | + | ||
43 | + IPage<TkDeviceAccountDTO> pageData = baseMapper.getDataPage(page, params); | ||
44 | + if (pageData != null) { | ||
45 | + result.setItems(pageData.getRecords()); | ||
46 | + } | ||
47 | + result.setTotal(Long.valueOf(pageData.getTotal()).intValue()); | ||
48 | + return result; | ||
49 | + } | ||
50 | + | ||
51 | + @Override | ||
52 | + public TkDeviceAccountDTO save(TkDeviceAccountDTO dto) throws ThingsboardException { | ||
53 | + checkDto(dto); | ||
54 | + | ||
55 | + TkDeviceAccountEntity entity = new TkDeviceAccountEntity(); | ||
56 | + if (StringUtils.isBlank(dto.getId())) { | ||
57 | + dto.copyToEntity(entity); | ||
58 | + baseMapper.insert(entity); | ||
59 | + } else { | ||
60 | + LambdaQueryWrapper<TkDeviceAccountEntity> filter = new QueryWrapper<TkDeviceAccountEntity>().lambda() | ||
61 | + .eq(TkDeviceAccountEntity::getId, dto.getId()); | ||
62 | + entity = dto.getEntity(TkDeviceAccountEntity.class); | ||
63 | + baseMapper.update(entity, filter); | ||
64 | + } | ||
65 | + entity.copyToDTO(dto); | ||
66 | + return dto; | ||
67 | + } | ||
68 | + | ||
69 | + private void checkDto(TkDeviceAccountDTO dto) throws ThingsboardException { | ||
70 | + if (StringUtils.isBlank(dto.getName())) { | ||
71 | + throw new TkDataValidationException("名称不能为空!"); | ||
72 | + } | ||
73 | + | ||
74 | + if (StringUtils.isBlank(dto.getCategoryId())) { | ||
75 | + throw new TkDataValidationException("设备类型不能为空!"); | ||
76 | + } | ||
77 | + | ||
78 | + if (dto.getStatus() == null) { | ||
79 | + throw new TkDataValidationException("状态不能为空!"); | ||
80 | + } | ||
81 | + | ||
82 | + if (StringUtils.isBlank(dto.getDirectorId())) { | ||
83 | + throw new TkDataValidationException("负责人不能为空!"); | ||
84 | + } | ||
85 | + | ||
86 | + if (StringUtils.isBlank(dto.getTenantId())) { | ||
87 | + dto.setTenantId(SpringBeanUtils.getTenantId().getId().toString()); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + @Override | ||
92 | + public TkDeviceAccountDTO detail(String id) throws ThingsboardException { | ||
93 | + TkDeviceAccountDTO detail = new TkDeviceAccountDTO(); | ||
94 | + TkDeviceAccountEntity entity = baseMapper.selectById(id); | ||
95 | + if (entity == null) { | ||
96 | + throw new TkDataValidationException("数据不存在!"); | ||
97 | + } | ||
98 | + entity.copyToDTO(detail); | ||
99 | + String supplierId = entity.getSupplierId(); | ||
100 | + if (StringUtils.isNotBlank(supplierId)) { | ||
101 | + TkSupplierDTO supplierDTO = tkSupplierService.detail(supplierId); | ||
102 | + detail.setSupplierInfo(supplierDTO); | ||
103 | + } | ||
104 | + | ||
105 | + String categoryId = entity.getCategoryId(); | ||
106 | + if (StringUtils.isNotBlank(categoryId)) { | ||
107 | + TkDeviceCagegoryDTO cagegoryDTO = tkDeviceCagegoryService.detail(categoryId); | ||
108 | + detail.setCategoryName(cagegoryDTO.getName()); | ||
109 | + } | ||
110 | + | ||
111 | + String directorId = entity.getDirectorId(); | ||
112 | + if (StringUtils.isNotBlank(directorId)) { | ||
113 | + UserDTO userInfo = tkUserService.findUserInfoById(directorId); | ||
114 | + detail.setDirectorName(userInfo.getRealName()); | ||
115 | + } | ||
116 | + | ||
117 | + return detail; | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public TkDeviceAccountDTO load(String id) throws ThingsboardException { | ||
122 | + TkDeviceAccountDTO result = null; | ||
123 | + TkDeviceAccountEntity entity = baseMapper.selectById(id); | ||
124 | + if (entity != null) { | ||
125 | + result = new TkDeviceAccountDTO(); | ||
126 | + entity.copyToDTO(result); | ||
127 | + } | ||
128 | + return result; | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public boolean delete(String id) { | ||
133 | + int count = baseMapper.deleteById(id); | ||
134 | + return count > 0; | ||
135 | + } | ||
136 | +} |
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; | @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; | ||
10 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 10 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
11 | import org.thingsboard.server.common.data.id.TenantId; | 11 | import org.thingsboard.server.common.data.id.TenantId; |
12 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | 12 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
13 | +import org.thingsboard.server.common.data.yunteng.dto.BaseDTO; | ||
13 | import org.thingsboard.server.common.data.yunteng.dto.TkDeviceCagegoryDTO; | 14 | import org.thingsboard.server.common.data.yunteng.dto.TkDeviceCagegoryDTO; |
14 | import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; | 15 | import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; |
15 | import org.thingsboard.server.dao.util.TkDeviceCagegoryUtil; | 16 | import org.thingsboard.server.dao.util.TkDeviceCagegoryUtil; |
@@ -18,7 +19,9 @@ import org.thingsboard.server.dao.yunteng.mapper.TkDeviceCagegoryMapper; | @@ -18,7 +19,9 @@ import org.thingsboard.server.dao.yunteng.mapper.TkDeviceCagegoryMapper; | ||
18 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | 19 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
19 | import org.thingsboard.server.dao.yunteng.service.TkDeviceCagegoryService; | 20 | import org.thingsboard.server.dao.yunteng.service.TkDeviceCagegoryService; |
20 | 21 | ||
22 | +import java.util.ArrayList; | ||
21 | import java.util.List; | 23 | import java.util.List; |
24 | +import java.util.Map; | ||
22 | import java.util.Optional; | 25 | import java.util.Optional; |
23 | import java.util.stream.Collectors; | 26 | import java.util.stream.Collectors; |
24 | 27 | ||
@@ -75,14 +78,40 @@ public class TkDeviceCagegoryServiceImpl extends AbstractBaseService<TkDeviceCag | @@ -75,14 +78,40 @@ public class TkDeviceCagegoryServiceImpl extends AbstractBaseService<TkDeviceCag | ||
75 | } | 78 | } |
76 | 79 | ||
77 | @Override | 80 | @Override |
78 | - public List<TkDeviceCagegoryDTO> getAllCagegory() throws ThingsboardException { | 81 | + public List<TkDeviceCagegoryDTO> getAllCagegory(TkDeviceCagegoryDTO dto) throws ThingsboardException { |
79 | List<TkDeviceCagegoryDTO> topMenuList = getCagegoryByParentid(null); | 82 | List<TkDeviceCagegoryDTO> topMenuList = getCagegoryByParentid(null); |
80 | List<TkDeviceCagegoryDTO> subMenu = getSubCategory(); | 83 | List<TkDeviceCagegoryDTO> subMenu = getSubCategory(); |
84 | + if (CollectionUtils.isEmpty(subMenu)) { | ||
85 | + return topMenuList; | ||
86 | + } | ||
87 | + | ||
88 | + if (StringUtils.isNotBlank(dto.getName())) { | ||
89 | + Map<String, String> idMap = subMenu.stream().collect(Collectors.toMap(BaseDTO::getId, TkDeviceCagegoryDTO::getParentId)); | ||
90 | + List<String> filterIdList = subMenu.stream().filter(e -> e.getName().contains(dto.getName())).map(BaseDTO::getId).collect(Collectors.toList()); | ||
91 | + List<String> fullTreeIdList = getFullTreeId(filterIdList, idMap); | ||
92 | + subMenu = subMenu.stream().filter(e -> fullTreeIdList.contains(e.getId())).collect(Collectors.toList()); | ||
93 | + } | ||
81 | TkDeviceCagegoryUtil utils = new TkDeviceCagegoryUtil(topMenuList, subMenu); | 94 | TkDeviceCagegoryUtil utils = new TkDeviceCagegoryUtil(topMenuList, subMenu); |
82 | List<TkDeviceCagegoryDTO> result = utils.getTree(); | 95 | List<TkDeviceCagegoryDTO> result = utils.getTree(); |
83 | return result; | 96 | return result; |
84 | } | 97 | } |
85 | 98 | ||
99 | + private List<String> getFullTreeId(List<String> filterIdList, Map<String, String> idMap) { | ||
100 | + List<String> result = new ArrayList<>(); | ||
101 | + for (String id : filterIdList) { | ||
102 | + String parentId = idMap.get(id); | ||
103 | + while (StringUtils.isNotBlank(parentId)) { | ||
104 | + if (!result.contains(parentId)) { | ||
105 | + result.add(parentId); | ||
106 | + } | ||
107 | + parentId = idMap.get(parentId); | ||
108 | + } | ||
109 | + } | ||
110 | + result.addAll(filterIdList); | ||
111 | + return result; | ||
112 | + } | ||
113 | + | ||
114 | + | ||
86 | private List<TkDeviceCagegoryDTO> getSubCategory() throws ThingsboardException { | 115 | private List<TkDeviceCagegoryDTO> getSubCategory() throws ThingsboardException { |
87 | QueryWrapper<TkDeviceCagegoryEntity> queryWrapper = new QueryWrapper(); | 116 | QueryWrapper<TkDeviceCagegoryEntity> queryWrapper = new QueryWrapper(); |
88 | LambdaQueryWrapper<TkDeviceCagegoryEntity> lambda = queryWrapper.lambda(); | 117 | LambdaQueryWrapper<TkDeviceCagegoryEntity> lambda = queryWrapper.lambda(); |
@@ -115,4 +144,10 @@ public class TkDeviceCagegoryServiceImpl extends AbstractBaseService<TkDeviceCag | @@ -115,4 +144,10 @@ public class TkDeviceCagegoryServiceImpl extends AbstractBaseService<TkDeviceCag | ||
115 | return Optional.ofNullable(entityList).map(all -> all.stream().map(item -> item.getDTO(TkDeviceCagegoryDTO.class)) | 144 | return Optional.ofNullable(entityList).map(all -> all.stream().map(item -> item.getDTO(TkDeviceCagegoryDTO.class)) |
116 | .collect(Collectors.toList())).orElse(null); | 145 | .collect(Collectors.toList())).orElse(null); |
117 | } | 146 | } |
147 | + | ||
148 | + @Override | ||
149 | + public List<String> getCategoryIdParentid(String parentId) { | ||
150 | + List<String> result=new ArrayList<>(); | ||
151 | + return null; | ||
152 | + } | ||
118 | } | 153 | } |
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.extension.plugins.pagination.Page; | ||
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.thingsboard.server.common.data.exception.ThingsboardException; | ||
12 | +import org.thingsboard.server.common.data.id.TenantId; | ||
13 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | ||
14 | +import org.thingsboard.server.common.data.yunteng.dto.TkSupplierDTO; | ||
15 | +import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; | ||
16 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | ||
17 | +import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity; | ||
18 | +import org.thingsboard.server.dao.yunteng.entities.TkSupplierEntity; | ||
19 | +import org.thingsboard.server.dao.yunteng.mapper.TkSupplierMapper; | ||
20 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | ||
21 | +import org.thingsboard.server.dao.yunteng.service.TkSupplierService; | ||
22 | + | ||
23 | +import java.util.List; | ||
24 | +import java.util.Optional; | ||
25 | +import java.util.stream.Collectors; | ||
26 | + | ||
27 | +@Service | ||
28 | +@RequiredArgsConstructor | ||
29 | +@Slf4j | ||
30 | +public class TkSupplierServiceImpl extends AbstractBaseService<TkSupplierMapper, TkSupplierEntity> | ||
31 | + implements TkSupplierService { | ||
32 | + @Override | ||
33 | + public TkPageData<TkSupplierDTO> page(TkSupplierDTO condition) throws ThingsboardException { | ||
34 | + QueryWrapper<TkSupplierEntity> wrapper = new QueryWrapper<>(); | ||
35 | + LambdaQueryWrapper<TkSupplierEntity> lambda = wrapper.lambda(); | ||
36 | + TenantId tenantId = SpringBeanUtils.getTenantId(); | ||
37 | + lambda.eq(TkSupplierEntity::getTenantId, tenantId.getId().toString()); | ||
38 | + if (StringUtils.isNotBlank(condition.getCode())) { | ||
39 | + lambda.like(TkSupplierEntity::getCode, condition.getCode()); | ||
40 | + } | ||
41 | + | ||
42 | + if (StringUtils.isNotBlank(condition.getName())) { | ||
43 | + lambda.like(TkSupplierEntity::getName, condition.getName()); | ||
44 | + } | ||
45 | + | ||
46 | + lambda.orderByDesc(TenantBaseEntity::getCreateTime); | ||
47 | + | ||
48 | + Page<TkSupplierEntity> page = new Page<>(); | ||
49 | + page.setCurrent(condition.getPage()); | ||
50 | + page.setSize(condition.getPageSize()); | ||
51 | + page = baseMapper.selectPage(page, wrapper); | ||
52 | + return getPageData(page, TkSupplierDTO.class); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public List<TkSupplierDTO> list(TkSupplierDTO condition) throws ThingsboardException { | ||
57 | + QueryWrapper<TkSupplierEntity> wrapper = new QueryWrapper<>(); | ||
58 | + LambdaQueryWrapper<TkSupplierEntity> lambda = wrapper.lambda(); | ||
59 | + TenantId tenantId = SpringBeanUtils.getTenantId(); | ||
60 | + lambda.eq(TkSupplierEntity::getTenantId, tenantId.getId().toString()); | ||
61 | + if (StringUtils.isNotBlank(condition.getCode())) { | ||
62 | + lambda.like(TkSupplierEntity::getCode, condition.getCode()); | ||
63 | + } | ||
64 | + | ||
65 | + if (StringUtils.isNotBlank(condition.getName())) { | ||
66 | + lambda.like(TkSupplierEntity::getName, condition.getName()); | ||
67 | + } | ||
68 | + | ||
69 | + lambda.orderByDesc(TenantBaseEntity::getCreateTime); | ||
70 | + | ||
71 | + List<TkSupplierEntity> entitys = baseMapper.selectList(wrapper); | ||
72 | + return Optional.ofNullable(entitys).map(all -> all.stream().map(item -> item.getDTO(TkSupplierDTO.class)) | ||
73 | + .collect(Collectors.toList())).orElse(null); | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public TkSupplierDTO save(TkSupplierDTO dto) throws ThingsboardException { | ||
78 | + checkDto(dto); | ||
79 | + TkSupplierEntity entity = new TkSupplierEntity(); | ||
80 | + if (StringUtils.isBlank(dto.getId())) { | ||
81 | + dto.copyToEntity(entity); | ||
82 | + baseMapper.insert(entity); | ||
83 | + } else { | ||
84 | + LambdaQueryWrapper<TkSupplierEntity> filter = new QueryWrapper<TkSupplierEntity>().lambda() | ||
85 | + .eq(TkSupplierEntity::getId, dto.getId()); | ||
86 | + entity = dto.getEntity(TkSupplierEntity.class); | ||
87 | + baseMapper.update(entity, filter); | ||
88 | + } | ||
89 | + | ||
90 | + | ||
91 | + entity.copyToDTO(dto); | ||
92 | + return dto; | ||
93 | + } | ||
94 | + | ||
95 | + private void checkDto(TkSupplierDTO dto) throws ThingsboardException { | ||
96 | + if (StringUtils.isBlank(dto.getName())) { | ||
97 | + throw new TkDataValidationException("供应商名称不能为空!"); | ||
98 | + } | ||
99 | + | ||
100 | + if (StringUtils.isBlank(dto.getTenantId())) { | ||
101 | + dto.setTenantId(SpringBeanUtils.getTenantId().getId().toString()); | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + public TkSupplierDTO detail(String id) throws ThingsboardException { | ||
107 | + TkSupplierDTO result = null; | ||
108 | + TkSupplierEntity entity = baseMapper.selectById(id); | ||
109 | + if (entity != null) { | ||
110 | + result = new TkSupplierDTO(); | ||
111 | + entity.copyToDTO(result); | ||
112 | + } | ||
113 | + return result; | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public boolean delete(String id) { | ||
118 | + int count = baseMapper.deleteById(id); | ||
119 | + return count > 0; | ||
120 | + } | ||
121 | + | ||
122 | + @Override | ||
123 | + public boolean delete(List<String> ids) { | ||
124 | + if (CollectionUtils.isEmpty(ids)) { | ||
125 | + throw new TkDataValidationException("id 不能为空!"); | ||
126 | + } | ||
127 | + int count = baseMapper.deleteBatchIds(ids); | ||
128 | + return count > 0; | ||
129 | + } | ||
130 | +} |
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.TkDeviceAccountDTO; | ||
8 | +import org.thingsboard.server.dao.yunteng.entities.TkDeviceAccountEntity; | ||
9 | + | ||
10 | +import java.util.Map; | ||
11 | + | ||
12 | +@Mapper | ||
13 | +public interface TkDeviceAccountMapper extends BaseMapper<TkDeviceAccountEntity> { | ||
14 | + IPage<TkDeviceAccountDTO> getDataPage(IPage<?> page, @Param("queryMap") Map<String, Object> queryMap); | ||
15 | +} |
1 | +package org.thingsboard.server.dao.yunteng.mapper; | ||
2 | + | ||
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
4 | +import org.apache.ibatis.annotations.Mapper; | ||
5 | +import org.thingsboard.server.dao.yunteng.entities.TkSupplierEntity; | ||
6 | + | ||
7 | +@Mapper | ||
8 | +public interface TkSupplierMapper extends BaseMapper<TkSupplierEntity> { | ||
9 | +} |
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.TkDeviceAccountDTO; | ||
5 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | ||
6 | +import org.thingsboard.server.dao.yunteng.entities.TkDeviceAccountEntity; | ||
7 | + | ||
8 | +import java.util.Map; | ||
9 | + | ||
10 | +public interface TkDeviceAccountService extends BaseService<TkDeviceAccountEntity> { | ||
11 | + TkPageData<TkDeviceAccountDTO> page(Map<String, Object> params); | ||
12 | + | ||
13 | + TkDeviceAccountDTO save(TkDeviceAccountDTO dto) throws ThingsboardException; | ||
14 | + | ||
15 | + TkDeviceAccountDTO detail(String id) throws ThingsboardException; | ||
16 | + | ||
17 | + TkDeviceAccountDTO load(String id) throws ThingsboardException; | ||
18 | + | ||
19 | + boolean delete(String id); | ||
20 | + | ||
21 | +} |
@@ -14,7 +14,9 @@ public interface TkDeviceCagegoryService extends BaseService<TkDeviceCagegoryEn | @@ -14,7 +14,9 @@ public interface TkDeviceCagegoryService extends BaseService<TkDeviceCagegoryEn | ||
14 | 14 | ||
15 | boolean delete(String id) throws ThingsboardException; | 15 | boolean delete(String id) throws ThingsboardException; |
16 | 16 | ||
17 | - List<TkDeviceCagegoryDTO> getAllCagegory() throws ThingsboardException; | 17 | + List<TkDeviceCagegoryDTO> getAllCagegory(TkDeviceCagegoryDTO condition) throws ThingsboardException; |
18 | 18 | ||
19 | List<TkDeviceCagegoryDTO> getCagegoryByParentid(String parentId) throws ThingsboardException; | 19 | List<TkDeviceCagegoryDTO> getCagegoryByParentid(String parentId) throws ThingsboardException; |
20 | + | ||
21 | + List<String> getCategoryIdParentid(String parentId); | ||
20 | } | 22 | } |
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.TkSupplierDTO; | ||
5 | +import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | ||
6 | +import org.thingsboard.server.dao.yunteng.entities.TkSupplierEntity; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +public interface TkSupplierService extends BaseService<TkSupplierEntity> { | ||
11 | + TkPageData<TkSupplierDTO> page(TkSupplierDTO condition) throws ThingsboardException; | ||
12 | + | ||
13 | + List<TkSupplierDTO> list(TkSupplierDTO condition) throws ThingsboardException; | ||
14 | + | ||
15 | + TkSupplierDTO save(TkSupplierDTO tkMalfunctionReasonDTO) throws ThingsboardException; | ||
16 | + | ||
17 | + TkSupplierDTO detail(String id) throws ThingsboardException; | ||
18 | + | ||
19 | + boolean delete(String id); | ||
20 | + | ||
21 | + boolean delete(List<String> ids); | ||
22 | +} |
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.TkDeviceAccountMapper"> | ||
5 | + <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO" id="deviceAccountMap"> | ||
6 | + <result property="id" column="id"/> | ||
7 | + <result property="name" column="name"/> | ||
8 | + <result property="code" column="code"/> | ||
9 | + <result property="categoryId" column="category_id"/> | ||
10 | + <result property="status" column="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> | ||
11 | + <result property="directorId" column="director_id"/> | ||
12 | + <result property="isOnline" column="is_online"/> | ||
13 | + <result property="deviceImg" column="device_img"/> | ||
14 | + <result property="brand" column="brand"/> | ||
15 | + <result property="modelNum" column="model_num"/> | ||
16 | + <result property="specifications" column="specifications"/> | ||
17 | + <result property="manufacturer" column="manufacturer"/> | ||
18 | + <result property="buyDate" column="buy_date"/> | ||
19 | + <result property="price" column="price"/> | ||
20 | + <result property="productDate" column="product_date"/> | ||
21 | + <result property="receiveDate" column="receive_date"/> | ||
22 | + <result property="registeDate" column="registe_date"/> | ||
23 | + <result property="supplierId" column="supplier_id"/> | ||
24 | + <result property="description" column="description"/> | ||
25 | + <result property="categoryName" column="categoryName"/> | ||
26 | + <result property="tenantId" column="tenant_id"/> | ||
27 | + <result property="createTime" column="create_time"/> | ||
28 | + <result property="updater" column="updater"/> | ||
29 | + <result property="updateTime" column="update_time"/> | ||
30 | + <result property="creator" column="creator"/> | ||
31 | + <result property="directorName" column="directorName"/> | ||
32 | + <association property="supplierInfo" javaType="org.thingsboard.server.common.data.yunteng.dto.TkSupplierDTO"> | ||
33 | + <id property="id" column="director_id"/> | ||
34 | + <result property="name" column="supplierName"/> | ||
35 | + <result property="code" column="supplierCode"/> | ||
36 | + <result property="contacts" column="contacts"/> | ||
37 | + <result property="contactsMobile" column="contactsMobile"/> | ||
38 | + </association> | ||
39 | + </resultMap> | ||
40 | + <select id="getDataPage" resultMap="deviceAccountMap"> | ||
41 | + SELECT | ||
42 | + o.id,o.name,o.code,o.category_id,o.status,o.director_id,o.is_online,o.device_img,o.brand, | ||
43 | + o.model_num,o.specifications,o.manufacturer,o.buy_date,o.price,o.product_date,o.receive_date, | ||
44 | + o.registe_date,o.supplier_id,o.description,dc.name as categoryName, | ||
45 | + sp.name as supplierName,sp.code as supplierCode,sp.contacts,sp.contacts_mobile ascontactsMobile, | ||
46 | + o.tenant_id,o.create_time,o.updater,o.update_time,o.creator,su.real_name as directorName | ||
47 | + from qg_device_account o | ||
48 | + inner join sys_user su on su.id=o.director_id | ||
49 | + inner join qg_supplier sp on sp.id=o.supplier_id | ||
50 | + inner join qg_device_cagegory dc on dc.id=o.category_id | ||
51 | + <where> | ||
52 | + <if test="queryMap.tenantId !=null "> | ||
53 | + AND o.tenant_id = #{queryMap.tenantId} | ||
54 | + </if> | ||
55 | + <if test="queryMap.code !=null "> | ||
56 | + AND o.code LIKE concat('%',#{queryMap.code}::TEXT,'%') | ||
57 | + </if> | ||
58 | + <if test="queryMap.status !=null "> | ||
59 | + AND o.status = #{queryMap.status} | ||
60 | + </if> | ||
61 | + <if test="queryMap.directorId !=null "> | ||
62 | + AND o.director_id = #{queryMap.directorId} | ||
63 | + </if> | ||
64 | + <if test="queryMap.categoryIds !=null"> | ||
65 | + AND o.category_id in | ||
66 | + <foreach collection="categoryIds" item="item" index="index" | ||
67 | + separator="," open="(" close=")"> | ||
68 | + #{item} | ||
69 | + </foreach> | ||
70 | + </if> | ||
71 | + </where> | ||
72 | + </select> | ||
73 | +</mapper> |