Showing
16 changed files
with
143 additions
and
90 deletions
@@ -70,6 +70,7 @@ COMMENT ON COLUMN "public"."qg_repair_order"."creator" IS '创建用户'; | @@ -70,6 +70,7 @@ COMMENT ON COLUMN "public"."qg_repair_order"."creator" IS '创建用户'; | ||
70 | 70 | ||
71 | CREATE TABLE "public"."qg_repair_record" ( | 71 | CREATE TABLE "public"."qg_repair_record" ( |
72 | "id" varchar(36) NOT NULL, | 72 | "id" varchar(36) NOT NULL, |
73 | + "code" varchar(50), | ||
73 | "order_id" varchar(36), | 74 | "order_id" varchar(36), |
74 | "repair_date" timestamp(6), | 75 | "repair_date" timestamp(6), |
75 | "repair_by" varchar(36), | 76 | "repair_by" varchar(36), |
@@ -927,6 +927,7 @@ CREATE TABLE IF NOT EXISTS qg_repair_order ( | @@ -927,6 +927,7 @@ CREATE TABLE IF NOT EXISTS qg_repair_order ( | ||
927 | 927 | ||
928 | CREATE TABLE IF NOT EXISTS qg_repair_record ( | 928 | CREATE TABLE IF NOT EXISTS qg_repair_record ( |
929 | "id" varchar(36) NOT NULL, | 929 | "id" varchar(36) NOT NULL, |
930 | + "code" varchar(50), | ||
930 | "order_id" varchar(36), | 931 | "order_id" varchar(36), |
931 | "repair_date" timestamp(6), | 932 | "repair_date" timestamp(6), |
932 | "repair_by" varchar(36), | 933 | "repair_by" varchar(36), |
@@ -53,13 +53,13 @@ public class TkRepairOrderController extends BaseController { | @@ -53,13 +53,13 @@ public class TkRepairOrderController extends BaseController { | ||
53 | 53 | ||
54 | if (StringUtils.isBlank(dto.getId())) { | 54 | if (StringUtils.isBlank(dto.getId())) { |
55 | TkRepairOrderDTO roInfo = tkRepairOrderService.loadByDeviceId(dto.getDeviceId()); | 55 | TkRepairOrderDTO roInfo = tkRepairOrderService.loadByDeviceId(dto.getDeviceId()); |
56 | - if (roInfo != null && RepairOrderStatusEnum.valueOf(roInfo.getStatus()) == RepairOrderStatusEnum.SCHEDULING) { | 56 | + if (roInfo != null && roInfo.getStatus().name().equals(RepairOrderStatusEnum.SCHEDULING.name())) { |
57 | throw new TkDataValidationException("该设备已报修!"); | 57 | throw new TkDataValidationException("该设备已报修!"); |
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | - if (StringUtils.isBlank(dto.getStatus())) { | ||
62 | - dto.setStatus(RepairOrderStatusEnum.DRAFT.name()); | 61 | + if (dto.getStatus() == null) { |
62 | + dto.setStatus(RepairOrderStatusEnum.DRAFT); | ||
63 | } | 63 | } |
64 | 64 | ||
65 | TkRepairOrderDTO deviceDTO = tkRepairOrderService.save(dto); | 65 | TkRepairOrderDTO deviceDTO = tkRepairOrderService.save(dto); |
@@ -103,7 +103,7 @@ public class TkRepairOrderController extends BaseController { | @@ -103,7 +103,7 @@ public class TkRepairOrderController extends BaseController { | ||
103 | throw new TkDataValidationException("工单不存在!"); | 103 | throw new TkDataValidationException("工单不存在!"); |
104 | } | 104 | } |
105 | 105 | ||
106 | - tkRepairOrderService.updateStatus(dto.getId(), dto.getStatus()); | 106 | + tkRepairOrderService.updateStatus(dto.getId(), dto.getStatus().name()); |
107 | return ResponseEntity.ok(orderInfo); | 107 | return ResponseEntity.ok(orderInfo); |
108 | } | 108 | } |
109 | } | 109 | } |
@@ -19,6 +19,8 @@ import org.thingsboard.server.dao.yunteng.service.TkRepairOrderService; | @@ -19,6 +19,8 @@ import org.thingsboard.server.dao.yunteng.service.TkRepairOrderService; | ||
19 | import org.thingsboard.server.dao.yunteng.service.TkRepairRecordService; | 19 | import org.thingsboard.server.dao.yunteng.service.TkRepairRecordService; |
20 | import org.thingsboard.server.queue.util.TbCoreComponent; | 20 | import org.thingsboard.server.queue.util.TbCoreComponent; |
21 | 21 | ||
22 | +import java.util.Map; | ||
23 | + | ||
22 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; | 24 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE; |
23 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE_SIZE; | 25 | import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant.PAGE_SIZE; |
24 | 26 | ||
@@ -74,10 +76,10 @@ public class TkRepairRecordController extends BaseController { | @@ -74,10 +76,10 @@ public class TkRepairRecordController extends BaseController { | ||
74 | public TkPageData<TkRepairRecordDTO> page( | 76 | public TkPageData<TkRepairRecordDTO> page( |
75 | @RequestParam(PAGE_SIZE) int pageSize, | 77 | @RequestParam(PAGE_SIZE) int pageSize, |
76 | @RequestParam(PAGE) int page, | 78 | @RequestParam(PAGE) int page, |
77 | - @RequestBody TkRepairRecordDTO params) | 79 | + @RequestBody Map<String, Object> params) |
78 | throws ThingsboardException { | 80 | throws ThingsboardException { |
79 | - params.setPage(page); | ||
80 | - params.setPageSize(pageSize); | ||
81 | - return tkRepairRecordService.page(getCurrentUser().getCurrentTenantId(), params); | 81 | + params.put(PAGE, page); |
82 | + params.put(PAGE_SIZE, pageSize); | ||
83 | + return tkRepairRecordService.page(params); | ||
82 | } | 84 | } |
83 | } | 85 | } |
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; | @@ -6,6 +6,7 @@ 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.RepairOrderStatusEnum; | ||
9 | 10 | ||
10 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
11 | 12 | ||
@@ -30,8 +31,8 @@ public class TkRepairOrderDTO extends TenantDTO { | @@ -30,8 +31,8 @@ public class TkRepairOrderDTO extends TenantDTO { | ||
30 | @ApiModelProperty(value = "报修人") | 31 | @ApiModelProperty(value = "报修人") |
31 | private String reportByName; | 32 | private String reportByName; |
32 | 33 | ||
33 | - @ApiModelProperty(value = "状态(RepairOrderStatusEnum) SCHEDULING排期中 REPAIRFINISH维修完成 ACCEPTANCEPASSED验收通过") | ||
34 | - private String status; | 34 | + @ApiModelProperty(value = "状态(DRAFT草稿 SCHEDULING排期中 REPAIRFINISH维修完成 ACCEPTANCEPASSED验收通过)") |
35 | + private RepairOrderStatusEnum status; | ||
35 | 36 | ||
36 | @ApiModelProperty(value = "是否紧急") | 37 | @ApiModelProperty(value = "是否紧急") |
37 | private Boolean emergency; | 38 | private Boolean emergency; |
@@ -43,7 +44,7 @@ public class TkRepairOrderDTO extends TenantDTO { | @@ -43,7 +44,7 @@ public class TkRepairOrderDTO extends TenantDTO { | ||
43 | private String description; | 44 | private String description; |
44 | 45 | ||
45 | @ApiModelProperty(value = "关联设备") | 46 | @ApiModelProperty(value = "关联设备") |
46 | - private DeviceDTO deviceInfo; | 47 | + private TkDeviceAccountDTO deviceInfo; |
47 | 48 | ||
48 | @ApiModelProperty(value = "查询开始时间") | 49 | @ApiModelProperty(value = "查询开始时间") |
49 | private LocalDateTime startDate; | 50 | private LocalDateTime startDate; |
@@ -16,6 +16,9 @@ public class TkRepairRecordDTO extends TenantDTO { | @@ -16,6 +16,9 @@ public class TkRepairRecordDTO extends TenantDTO { | ||
16 | @ApiModelProperty(value = "维修工单id") | 16 | @ApiModelProperty(value = "维修工单id") |
17 | private String orderId; | 17 | private String orderId; |
18 | 18 | ||
19 | + @ApiModelProperty(value = "维修编号") | ||
20 | + private String code; | ||
21 | + | ||
19 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | 22 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
20 | @ApiModelProperty(value = "维修时间") | 23 | @ApiModelProperty(value = "维修时间") |
21 | @JsonSerialize(using = LocalDateTimeSerializer.class) | 24 | @JsonSerialize(using = LocalDateTimeSerializer.class) |
@@ -33,6 +36,9 @@ public class TkRepairRecordDTO extends TenantDTO { | @@ -33,6 +36,9 @@ public class TkRepairRecordDTO extends TenantDTO { | ||
33 | @ApiModelProperty(value = "维修工单") | 36 | @ApiModelProperty(value = "维修工单") |
34 | private TkRepairOrderDTO tkRepairOrderDTO; | 37 | private TkRepairOrderDTO tkRepairOrderDTO; |
35 | 38 | ||
39 | + @ApiModelProperty(value = "设备名称") | ||
40 | + private String deviceAccountName; | ||
41 | + | ||
36 | @ApiModelProperty(value = "查询开始时间") | 42 | @ApiModelProperty(value = "查询开始时间") |
37 | private LocalDateTime startDate; | 43 | private LocalDateTime startDate; |
38 | 44 |
@@ -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.RepairOrderStatusEnum; | ||
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; |
@@ -23,7 +24,7 @@ public class TkRepairOrderEntity extends TenantBaseEntity { | @@ -23,7 +24,7 @@ public class TkRepairOrderEntity extends TenantBaseEntity { | ||
23 | 24 | ||
24 | private String reportBy; | 25 | private String reportBy; |
25 | 26 | ||
26 | - private String status; | 27 | + private RepairOrderStatusEnum status; |
27 | 28 | ||
28 | private Boolean emergency; | 29 | private Boolean emergency; |
29 | 30 |
@@ -17,6 +17,8 @@ public class TkRepairRecordEntity extends TenantBaseEntity { | @@ -17,6 +17,8 @@ public class TkRepairRecordEntity extends TenantBaseEntity { | ||
17 | 17 | ||
18 | private String orderId; | 18 | private String orderId; |
19 | 19 | ||
20 | + private String code; | ||
21 | + | ||
20 | private LocalDateTime repairDate; | 22 | private LocalDateTime repairDate; |
21 | 23 | ||
22 | private String repairBy; | 24 | private String repairBy; |
@@ -37,6 +37,7 @@ public class TkDeviceAccountServiceImpl extends AbstractBaseService<TkDeviceAcco | @@ -37,6 +37,7 @@ public class TkDeviceAccountServiceImpl extends AbstractBaseService<TkDeviceAcco | ||
37 | 37 | ||
38 | @Override | 38 | @Override |
39 | public TkPageData<TkDeviceAccountDTO> page(Map<String, Object> params) throws ThingsboardException { | 39 | public TkPageData<TkDeviceAccountDTO> page(Map<String, Object> params) throws ThingsboardException { |
40 | + params.put("tenantId", SpringBeanUtils.getTenantId().getId().toString()); | ||
40 | TkPageData<TkDeviceAccountDTO> result = new TkPageData<>(); | 41 | TkPageData<TkDeviceAccountDTO> result = new TkPageData<>(); |
41 | IPage<TkDeviceAccountEntity> page = | 42 | IPage<TkDeviceAccountEntity> page = |
42 | getPage(params, "create_time", false); | 43 | getPage(params, "create_time", false); |
@@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; | @@ -12,6 +12,7 @@ import org.thingsboard.server.common.data.exception.ThingsboardException; | ||
12 | import org.thingsboard.server.common.data.id.TenantId; | 12 | import org.thingsboard.server.common.data.id.TenantId; |
13 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | 13 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
14 | import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; | 14 | import org.thingsboard.server.common.data.yunteng.dto.DeviceDTO; |
15 | +import org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO; | ||
15 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO; | 16 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO; |
16 | import org.thingsboard.server.common.data.yunteng.enums.RepairOrderStatusEnum; | 17 | import org.thingsboard.server.common.data.yunteng.enums.RepairOrderStatusEnum; |
17 | import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; | 18 | import org.thingsboard.server.common.data.yunteng.utils.SpringBeanUtils; |
@@ -20,6 +21,7 @@ import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity; | @@ -20,6 +21,7 @@ import org.thingsboard.server.dao.yunteng.entities.TenantBaseEntity; | ||
20 | import org.thingsboard.server.dao.yunteng.entities.TkRepairOrderEntity; | 21 | import org.thingsboard.server.dao.yunteng.entities.TkRepairOrderEntity; |
21 | import org.thingsboard.server.dao.yunteng.mapper.TkRepairOrderMapper; | 22 | import org.thingsboard.server.dao.yunteng.mapper.TkRepairOrderMapper; |
22 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | 23 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
24 | +import org.thingsboard.server.dao.yunteng.service.TkDeviceAccountService; | ||
23 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; | 25 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; |
24 | import org.thingsboard.server.dao.yunteng.service.TkRepairOrderService; | 26 | import org.thingsboard.server.dao.yunteng.service.TkRepairOrderService; |
25 | 27 | ||
@@ -36,28 +38,16 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -36,28 +38,16 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
36 | 38 | ||
37 | private final TkDeviceService tkdeviceService; | 39 | private final TkDeviceService tkdeviceService; |
38 | 40 | ||
41 | + private final TkDeviceAccountService tkDeviceAccountService; | ||
42 | + | ||
39 | @Override | 43 | @Override |
40 | - public TkPageData<TkRepairOrderDTO> page(String tenantId, Map<String, Object> params) { | 44 | + public TkPageData<TkRepairOrderDTO> page(String tenantId, Map<String, Object> params) throws ThingsboardException { |
45 | + params.put("tenantId", SpringBeanUtils.getTenantId().getId().toString()); | ||
41 | TkPageData<TkRepairOrderDTO> result = new TkPageData<>(); | 46 | TkPageData<TkRepairOrderDTO> result = new TkPageData<>(); |
42 | IPage<TkRepairOrderEntity> page = | 47 | IPage<TkRepairOrderEntity> page = |
43 | getPage(params, "create_time", false); | 48 | getPage(params, "create_time", false); |
44 | 49 | ||
45 | IPage<TkRepairOrderDTO> pageData = baseMapper.getRepairOrderPage(page, params); | 50 | IPage<TkRepairOrderDTO> pageData = baseMapper.getRepairOrderPage(page, params); |
46 | - if (pageData != null && CollectionUtils.isNotEmpty(pageData.getRecords())) { | ||
47 | - Map<String, DeviceDTO> deviceMap = new HashMap<>(); | ||
48 | - pageData.getRecords().forEach(item -> { | ||
49 | - String deviceId = item.getDeviceId(); | ||
50 | - if (StringUtils.isNotBlank(deviceId)) { | ||
51 | - DeviceDTO deviceDTO = deviceMap.get(tenantId); | ||
52 | - if (deviceDTO == null) { | ||
53 | - deviceDTO = tkdeviceService.checkDeviceByTenantIdAndDeviceId(UUID.fromString(tenantId), UUID.fromString(deviceId)); | ||
54 | - deviceMap.put(tenantId, deviceDTO); | ||
55 | - } | ||
56 | - | ||
57 | - item.setDeviceInfo(deviceDTO); | ||
58 | - } | ||
59 | - }); | ||
60 | - } | ||
61 | if (pageData != null) { | 51 | if (pageData != null) { |
62 | result.setItems(pageData.getRecords()); | 52 | result.setItems(pageData.getRecords()); |
63 | } | 53 | } |
@@ -65,34 +55,6 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -65,34 +55,6 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
65 | return result; | 55 | return result; |
66 | } | 56 | } |
67 | 57 | ||
68 | - private QueryWrapper<TkRepairOrderEntity> getCondition(String tenantId, TkRepairOrderDTO params) { | ||
69 | - QueryWrapper<TkRepairOrderEntity> queryWrapper = new QueryWrapper<>(); | ||
70 | - LambdaQueryWrapper<TkRepairOrderEntity> lambda = queryWrapper.lambda(); | ||
71 | - lambda.eq(TenantBaseEntity::getTenantId, tenantId); | ||
72 | - if (StringUtils.isNotBlank(params.getDeviceId())) { | ||
73 | - lambda.eq(TkRepairOrderEntity::getDeviceId, params.getDeviceId()); | ||
74 | - } | ||
75 | - if (params.getStartDate() != null) { | ||
76 | - lambda.ge(TkRepairOrderEntity::getReportDate, params.getStartDate()); | ||
77 | - } | ||
78 | - if (params.getEndDate() != null) { | ||
79 | - lambda.le(TkRepairOrderEntity::getReportDate, params.getEndDate()); | ||
80 | - } | ||
81 | - | ||
82 | - if (StringUtils.isNotBlank(params.getReportBy())) { | ||
83 | - lambda.eq(TkRepairOrderEntity::getReportBy, params.getReportBy()); | ||
84 | - } | ||
85 | - | ||
86 | - if (StringUtils.isNotBlank(params.getStatus())) { | ||
87 | - lambda.eq(TkRepairOrderEntity::getStatus, params.getStatus()); | ||
88 | - } | ||
89 | - | ||
90 | - if (params.getEmergency() != null) { | ||
91 | - lambda.eq(TkRepairOrderEntity::getEmergency, params.getEmergency()); | ||
92 | - } | ||
93 | - return queryWrapper; | ||
94 | - } | ||
95 | - | ||
96 | 58 | ||
97 | @Override | 59 | @Override |
98 | public TkRepairOrderDTO save(TkRepairOrderDTO dto) throws ThingsboardException { | 60 | public TkRepairOrderDTO save(TkRepairOrderDTO dto) throws ThingsboardException { |
@@ -125,8 +87,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -125,8 +87,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
125 | entity.copyToDTO(detail); | 87 | entity.copyToDTO(detail); |
126 | String deviceId = entity.getDeviceId(); | 88 | String deviceId = entity.getDeviceId(); |
127 | if (StringUtils.isNotBlank(deviceId)) { | 89 | if (StringUtils.isNotBlank(deviceId)) { |
128 | - TenantId tenantInfo = SpringBeanUtils.getTenantId(); | ||
129 | - DeviceDTO deviceDTO = tkdeviceService.checkDeviceByTenantIdAndDeviceId(tenantInfo.getId(), UUID.fromString(deviceId)); | 90 | + TkDeviceAccountDTO deviceDTO = tkDeviceAccountService.load(deviceId); |
130 | detail.setDeviceInfo(deviceDTO); | 91 | detail.setDeviceInfo(deviceDTO); |
131 | } | 92 | } |
132 | 93 | ||
@@ -138,7 +99,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -138,7 +99,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
138 | TkRepairOrderDTO result = null; | 99 | TkRepairOrderDTO result = null; |
139 | TkRepairOrderEntity entity = baseMapper.selectById(id); | 100 | TkRepairOrderEntity entity = baseMapper.selectById(id); |
140 | if (entity != null) { | 101 | if (entity != null) { |
141 | - result=new TkRepairOrderDTO(); | 102 | + result = new TkRepairOrderDTO(); |
142 | entity.copyToDTO(result); | 103 | entity.copyToDTO(result); |
143 | } | 104 | } |
144 | return result; | 105 | return result; |
@@ -153,7 +114,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -153,7 +114,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
153 | lambda.eq(TkRepairOrderEntity::getDeviceId, deviceId); | 114 | lambda.eq(TkRepairOrderEntity::getDeviceId, deviceId); |
154 | TkRepairOrderEntity entity = baseMapper.selectOne(queryWrapper); | 115 | TkRepairOrderEntity entity = baseMapper.selectOne(queryWrapper); |
155 | if (entity != null) { | 116 | if (entity != null) { |
156 | - result=new TkRepairOrderDTO(); | 117 | + result = new TkRepairOrderDTO(); |
157 | entity.copyToDTO(result); | 118 | entity.copyToDTO(result); |
158 | } | 119 | } |
159 | return result; | 120 | return result; |
@@ -171,7 +132,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | @@ -171,7 +132,7 @@ public class TkRepairOrderServiceImpl extends AbstractBaseService<TkRepairOrderM | ||
171 | } | 132 | } |
172 | TkRepairOrderEntity entity = new TkRepairOrderEntity(); | 133 | TkRepairOrderEntity entity = new TkRepairOrderEntity(); |
173 | orderDTO.copyToEntity(entity); | 134 | orderDTO.copyToEntity(entity); |
174 | - entity.setStatus(statusEnum.name()); | 135 | + entity.setStatus(statusEnum); |
175 | LambdaQueryWrapper<TkRepairOrderEntity> filter = new QueryWrapper<TkRepairOrderEntity>().lambda() | 136 | LambdaQueryWrapper<TkRepairOrderEntity> filter = new QueryWrapper<TkRepairOrderEntity>().lambda() |
176 | .eq(TkRepairOrderEntity::getId, entity.getId()); | 137 | .eq(TkRepairOrderEntity::getId, entity.getId()); |
177 | baseMapper.update(entity, filter); | 138 | baseMapper.update(entity, filter); |
@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; | @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; | ||
8 | import org.apache.commons.lang3.StringUtils; | 8 | import org.apache.commons.lang3.StringUtils; |
9 | import org.springframework.stereotype.Service; | 9 | 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.yunteng.core.exception.TkDataValidationException; | 12 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
12 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO; | 13 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO; |
13 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO; | 14 | import org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO; |
@@ -40,14 +41,12 @@ public class TkRepairRecordServiceImpl extends AbstractBaseService<TkRepairRecor | @@ -40,14 +41,12 @@ public class TkRepairRecordServiceImpl extends AbstractBaseService<TkRepairRecor | ||
40 | private final TkUserService tkUserService; | 41 | private final TkUserService tkUserService; |
41 | 42 | ||
42 | @Override | 43 | @Override |
43 | - public TkPageData<TkRepairRecordDTO> page(String tenantId, TkRepairRecordDTO params) { | 44 | + public TkPageData<TkRepairRecordDTO> page(Map<String, Object> params) throws ThingsboardException { |
45 | + params.put("tenantId", SpringBeanUtils.getTenantId().getId().toString()); | ||
44 | TkPageData<TkRepairRecordDTO> result = new TkPageData<>(); | 46 | TkPageData<TkRepairRecordDTO> result = new TkPageData<>(); |
45 | - Map<String, Object> queryMap = new HashMap<>(); | ||
46 | - queryMap.put(PAGE, params.getPage()); | ||
47 | - queryMap.put(PAGE_SIZE, params.getPageSize()); | ||
48 | IPage<TkRepairRecordEntity> page = | 47 | IPage<TkRepairRecordEntity> page = |
49 | - getPage(queryMap, "rr.create_time", false); | ||
50 | - IPage<TkRepairRecordDTO> pageData = baseMapper.getRepairRecordPage(page, queryMap); | 48 | + getPage(params, "rr.create_time", false); |
49 | + IPage<TkRepairRecordDTO> pageData = baseMapper.getRepairRecordPage(page, params); | ||
51 | if (pageData != null) { | 50 | if (pageData != null) { |
52 | result.setItems(pageData.getRecords()); | 51 | result.setItems(pageData.getRecords()); |
53 | } | 52 | } |
@@ -103,6 +102,10 @@ public class TkRepairRecordServiceImpl extends AbstractBaseService<TkRepairRecor | @@ -103,6 +102,10 @@ public class TkRepairRecordServiceImpl extends AbstractBaseService<TkRepairRecor | ||
103 | String orderId = entity.getOrderId(); | 102 | String orderId = entity.getOrderId(); |
104 | if (StringUtils.isNotBlank(orderId)) { | 103 | if (StringUtils.isNotBlank(orderId)) { |
105 | TkRepairOrderDTO repairOrderDTO = tkRepairOrderService.load(orderId); | 104 | TkRepairOrderDTO repairOrderDTO = tkRepairOrderService.load(orderId); |
105 | + if (StringUtils.isNotBlank(repairOrderDTO.getReportBy())) { | ||
106 | + UserDTO reportInfo = tkUserService.findUserInfoById(repairOrderDTO.getReportBy()); | ||
107 | + repairOrderDTO.setReportByName(reportInfo.getRealName()); | ||
108 | + } | ||
106 | detail.setTkRepairOrderDTO(repairOrderDTO); | 109 | detail.setTkRepairOrderDTO(repairOrderDTO); |
107 | } | 110 | } |
108 | UserDTO userInfo = tkUserService.findUserInfoById(detail.getRepairBy()); | 111 | UserDTO userInfo = tkUserService.findUserInfoById(detail.getRepairBy()); |
@@ -10,7 +10,7 @@ import java.util.Map; | @@ -10,7 +10,7 @@ import java.util.Map; | ||
10 | 10 | ||
11 | public interface TkRepairOrderService extends BaseService<TkRepairOrderEntity> { | 11 | public interface TkRepairOrderService extends BaseService<TkRepairOrderEntity> { |
12 | 12 | ||
13 | - TkPageData<TkRepairOrderDTO> page(String tenantId,Map<String, Object> params); | 13 | + TkPageData<TkRepairOrderDTO> page(String tenantId,Map<String, Object> params) throws ThingsboardException; |
14 | 14 | ||
15 | TkRepairOrderDTO save(TkRepairOrderDTO dto) throws ThingsboardException; | 15 | TkRepairOrderDTO save(TkRepairOrderDTO dto) throws ThingsboardException; |
16 | 16 |
@@ -5,9 +5,11 @@ import org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO; | @@ -5,9 +5,11 @@ import org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO; | ||
5 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; | 5 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
6 | import org.thingsboard.server.dao.yunteng.entities.TkRepairRecordEntity; | 6 | import org.thingsboard.server.dao.yunteng.entities.TkRepairRecordEntity; |
7 | 7 | ||
8 | +import java.util.Map; | ||
9 | + | ||
8 | public interface TkRepairRecordService extends BaseService<TkRepairRecordEntity>{ | 10 | public interface TkRepairRecordService extends BaseService<TkRepairRecordEntity>{ |
9 | 11 | ||
10 | - TkPageData<TkRepairRecordDTO> page(String tenantId, TkRepairRecordDTO params); | 12 | + TkPageData<TkRepairRecordDTO> page(Map<String, Object> params) throws ThingsboardException; |
11 | 13 | ||
12 | TkRepairRecordDTO save(TkRepairRecordDTO dto) throws ThingsboardException; | 14 | TkRepairRecordDTO save(TkRepairRecordDTO dto) throws ThingsboardException; |
13 | 15 |
@@ -49,16 +49,16 @@ | @@ -49,16 +49,16 @@ | ||
49 | inner join qg_supplier sp on sp.id=o.supplier_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 | 50 | inner join qg_device_cagegory dc on dc.id=o.category_id |
51 | <where> | 51 | <where> |
52 | - <if test="queryMap.tenantId !=null "> | 52 | + <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> |
53 | AND o.tenant_id = #{queryMap.tenantId} | 53 | AND o.tenant_id = #{queryMap.tenantId} |
54 | </if> | 54 | </if> |
55 | - <if test="queryMap.code !=null "> | 55 | + <if test="queryMap.code !=null and queryMap.code !=''"> |
56 | AND o.code LIKE concat('%',#{queryMap.code}::TEXT,'%') | 56 | AND o.code LIKE concat('%',#{queryMap.code}::TEXT,'%') |
57 | </if> | 57 | </if> |
58 | - <if test="queryMap.status !=null "> | 58 | + <if test="queryMap.status !=null and queryMap.status !=''"> |
59 | AND o.status = #{queryMap.status} | 59 | AND o.status = #{queryMap.status} |
60 | </if> | 60 | </if> |
61 | - <if test="queryMap.directorId !=null "> | 61 | + <if test="queryMap.directorId !=null and queryMap.directorId !=''"> |
62 | AND o.director_id = #{queryMap.directorId} | 62 | AND o.director_id = #{queryMap.directorId} |
63 | </if> | 63 | </if> |
64 | <if test="queryMap.categoryIds !=null"> | 64 | <if test="queryMap.categoryIds !=null"> |
@@ -3,31 +3,69 @@ | @@ -3,31 +3,69 @@ | ||
3 | 3 | ||
4 | <mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TkRepairOrderMapper"> | 4 | <mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TkRepairOrderMapper"> |
5 | <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO" id="repairOrderMap"> | 5 | <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO" id="repairOrderMap"> |
6 | + <result property="orderCode" column="order_code"/> | ||
7 | + <result property="deviceId" column="device_id"/> | ||
8 | + <result property="reportDate" column="report_date"/> | ||
9 | + <result property="reportBy" column="report_by"/> | ||
10 | + <result property="status" column="status" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> | ||
11 | + <result property="emergency" column="emergency"/> | ||
12 | + <result property="situationImg" column="situation_img"/> | ||
13 | + <result property="description" column="description"/> | ||
14 | + <result property="tenantId" column="tenant_id"/> | ||
15 | + <result property="createTime" column="create_time"/> | ||
16 | + <result property="updater" column="updater"/> | ||
17 | + <result property="updateTime" column="update_time"/> | ||
18 | + <result property="creator" column="creator"/> | ||
6 | <result property="reportByName" column="reportByName"/> | 19 | <result property="reportByName" column="reportByName"/> |
20 | + <association property="deviceInfo" javaType="org.thingsboard.server.common.data.yunteng.dto.TkDeviceAccountDTO"> | ||
21 | + <id property="id" column="device_id"/> | ||
22 | + <result property="name" column="daName"/> | ||
23 | + <result property="code" column="daCode"/> | ||
24 | + <result property="categoryId" column="category_id"/> | ||
25 | + <result property="status" column="daStatus" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> | ||
26 | + <result property="directorId" column="director_id"/> | ||
27 | + <result property="isOnline" column="is_online"/> | ||
28 | + <result property="deviceImg" column="device_img"/> | ||
29 | + <result property="brand" column="brand"/> | ||
30 | + <result property="modelNum" column="model_num"/> | ||
31 | + <result property="specifications" column="specifications"/> | ||
32 | + <result property="manufacturer" column="manufacturer"/> | ||
33 | + <result property="buyDate" column="buy_date"/> | ||
34 | + <result property="price" column="price"/> | ||
35 | + <result property="productDate" column="product_date"/> | ||
36 | + <result property="receiveDate" column="receive_date"/> | ||
37 | + <result property="registeDate" column="registe_date"/> | ||
38 | + <result property="supplierId" column="supplier_id"/> | ||
39 | + <result property="description" column="daDescription"/> | ||
40 | + </association> | ||
7 | </resultMap> | 41 | </resultMap> |
8 | <select id="getRepairOrderPage" resultMap="repairOrderMap"> | 42 | <select id="getRepairOrderPage" resultMap="repairOrderMap"> |
9 | SELECT | 43 | SELECT |
10 | - o.id,o.device_id,o.order_code,o.report_date,o.report_by,o.status,o.emergency,o.situation_img,o.description | ||
11 | - ,o.tenant_id,o.create_time,o.updater,o.update_time,o.creator,su.real_name as reportByName | 44 | + o.id,o.device_id,o.order_code,o.report_date,o.report_by,o.status,o.emergency,o.situation_img,o.description, |
45 | + da.name as daName,da.code as daCode,da.category_id,da.status as daStatus,da.director_id,da.is_online, | ||
46 | + da.brand,da.model_num,da.specifications,da.manufacturer,da.buy_date,da.price,da.product_date, | ||
47 | + da.receive_date,da.registe_date,da.supplier_id,da.device_img,da.description as daDescription, | ||
48 | + o.tenant_id,o.create_time,o.updater,o.update_time,o.creator,su.real_name as reportByName | ||
12 | from qg_repair_order o | 49 | from qg_repair_order o |
13 | inner join sys_user su on su.id=o.report_by | 50 | inner join sys_user su on su.id=o.report_by |
51 | + inner join qg_device_account da on da.id=o.device_id | ||
14 | <where> | 52 | <where> |
15 | - <if test="queryMap.tenantId !=null "> | 53 | + <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> |
16 | AND o.tenant_id = #{queryMap.tenantId} | 54 | AND o.tenant_id = #{queryMap.tenantId} |
17 | </if> | 55 | </if> |
18 | - <if test="queryMap.status !=null "> | 56 | + <if test="queryMap.status !=null and queryMap.status !=''"> |
19 | AND o.status = #{queryMap.status} | 57 | AND o.status = #{queryMap.status} |
20 | </if> | 58 | </if> |
21 | - <if test="queryMap.deviceId !=null "> | 59 | + <if test="queryMap.deviceId !=null and queryMap.deviceId !=''"> |
22 | AND o.device_id = #{queryMap.deviceId} | 60 | AND o.device_id = #{queryMap.deviceId} |
23 | </if> | 61 | </if> |
24 | - <if test="queryMap.emergency !=null "> | 62 | + <if test="queryMap.emergency !=null and queryMap.emergency !=''"> |
25 | AND o.emergency = #{queryMap.emergency} | 63 | AND o.emergency = #{queryMap.emergency} |
26 | </if> | 64 | </if> |
27 | - <if test="queryMap.startDate !=null "> | 65 | + <if test="queryMap.startDate !=null and queryMap.startDate !=''"> |
28 | AND to_char(o.report_date, 'YYYY-MM-DD HH24:MI:SS') >= #{queryMap.startDate} | 66 | AND to_char(o.report_date, 'YYYY-MM-DD HH24:MI:SS') >= #{queryMap.startDate} |
29 | </if> | 67 | </if> |
30 | - <if test="queryMap.endDate !=null "> | 68 | + <if test="queryMap.endDate !=null and queryMap.endDate !=''"> |
31 | AND to_char(o.report_date, 'YYYY-MM-DD HH24:MI:SS') <= #{queryMap.endDate} | 69 | AND to_char(o.report_date, 'YYYY-MM-DD HH24:MI:SS') <= #{queryMap.endDate} |
32 | </if> | 70 | </if> |
33 | </where> | 71 | </where> |
@@ -3,17 +3,51 @@ | @@ -3,17 +3,51 @@ | ||
3 | 3 | ||
4 | <mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TkRepairRecordMapper"> | 4 | <mapper namespace="org.thingsboard.server.dao.yunteng.mapper.TkRepairRecordMapper"> |
5 | <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO" id="repairRecordMap"> | 5 | <resultMap type="org.thingsboard.server.common.data.yunteng.dto.TkRepairRecordDTO" id="repairRecordMap"> |
6 | - <result property="id" column="id" /> | ||
7 | - <result property="repairDate" column="repair_date" /> | ||
8 | - <result property="orderId" column="order_id" /> | ||
9 | - <result property="repairBy" column="repair_by" /> | ||
10 | - <result property="description" column="description" /> | ||
11 | - <result property="repairName" column="repairName" /> | 6 | + <result property="id" column="id"/> |
7 | + <result property="code" column="code"/> | ||
8 | + <result property="repairDate" column="repair_date"/> | ||
9 | + <result property="orderId" column="order_id"/> | ||
10 | + <result property="repairBy" column="repair_by"/> | ||
11 | + <result property="description" column="description"/> | ||
12 | + <result property="repairName" column="repairName"/> | ||
13 | + <result property="deviceAccountName" column="deviceAccountName"/> | ||
14 | + <association property="tkRepairOrderDTO" | ||
15 | + javaType="org.thingsboard.server.common.data.yunteng.dto.TkRepairOrderDTO"> | ||
16 | + <id property="id" column="order_id"/> | ||
17 | + <result property="orderCode" column="order_code"/> | ||
18 | + <result property="deviceId" column="device_id"/> | ||
19 | + <result property="reportDate" column="report_date"/> | ||
20 | + <result property="reportBy" column="report_by"/> | ||
21 | + <result property="status" column="roStatus" typeHandler="org.apache.ibatis.type.EnumTypeHandler"/> | ||
22 | + <result property="emergency" column="emergency"/> | ||
23 | + <result property="situationImg" column="situation_img"/> | ||
24 | + <result property="description" column="roDescription"/> | ||
25 | + <result property="reportByName" column="reportByName"/> | ||
26 | + </association> | ||
12 | </resultMap> | 27 | </resultMap> |
13 | - <select id="getRepairRecordPage" resultMap="repairRecordMap"> | ||
14 | - SELECT rr.id,rr.order_id,rr.repair_date,rr.repair_by,rr.description | ||
15 | - ,rr.tenant_id,rr.create_time,rr.updater,rr.update_time,rr.creator,su.real_name as repairName | 28 | + <select id="getRepairRecordPage" resultMap="repairRecordMap"> |
29 | + SELECT rr.id,rr.code,rr.order_id,rr.repair_date,rr.repair_by,rr.description,da.name as deviceAccountName, | ||
30 | + ro.order_code,ro.device_id,ro.report_date,ro.report_by,ro.status as roStatus, | ||
31 | + ro.emergency,ro.situation_img,ro.description as roDescription,su2.real_name as reportByName, | ||
32 | + rr.tenant_id,rr.create_time,rr.updater,rr.update_time,rr.creator,su.real_name as repairName | ||
16 | from qg_repair_record rr | 33 | from qg_repair_record rr |
34 | + inner join qg_repair_order ro on ro.id=rr.order_id | ||
17 | inner join sys_user su on su.id=rr.repair_by | 35 | inner join sys_user su on su.id=rr.repair_by |
36 | + inner join sys_user su2 on su2.id=ro.report_by | ||
37 | + inner join qg_device_account da on da.id=ro.device_id | ||
38 | + <where> | ||
39 | + <if test="queryMap.tenantId !=null and queryMap.tenantId !=''"> | ||
40 | + AND rr.tenant_id = #{queryMap.tenantId} | ||
41 | + </if> | ||
42 | + <if test="queryMap.repairBy !=null and queryMap.repairBy !=''"> | ||
43 | + AND rr.repair_by = #{queryMap.repairBy} | ||
44 | + </if> | ||
45 | + <if test="queryMap.reportBy !=null and queryMap.reportBy !=''"> | ||
46 | + AND ro.report_by = #{queryMap.reportBy} | ||
47 | + </if> | ||
48 | + <if test="queryMap.orderCode !=null and queryMap.orderCode !=''"> | ||
49 | + AND ro.order_code LIKE concat('%',#{queryMap.orderCode}::TEXT,'%') | ||
50 | + </if> | ||
51 | + </where> | ||
18 | </select> | 52 | </select> |
19 | </mapper> | 53 | </mapper> |