|
@@ -1,5 +1,26 @@
|
|
package com.xy.controller;
|
|
package com.xy.controller;
|
|
|
|
|
|
|
|
+import com.xy.annotate.RestMappingController;
|
|
|
|
+import com.xy.dto.DeviceErrorsRecordDto;
|
|
|
|
+import com.xy.dto.DeviceNetRecordDto;
|
|
|
|
+import com.xy.dto.DeviceRecordsDto;
|
|
|
|
+import com.xy.dto.MiniDeviceRecordsDto;
|
|
|
|
+import com.xy.service.DeviceErrorsRecordService;
|
|
|
|
+import com.xy.service.DeviceNetRecordService;
|
|
|
|
+import com.xy.service.DeviceRecordsService;
|
|
|
|
+import com.xy.utils.MercAuthUtils;
|
|
|
|
+import com.xy.utils.PageBean;
|
|
|
|
+import com.xy.utils.R;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
*
|
|
*
|
|
@@ -8,5 +29,76 @@ package com.xy.controller;
|
|
* @author hechunping
|
|
* @author hechunping
|
|
* @since 2023/3/4
|
|
* @since 2023/3/4
|
|
*/
|
|
*/
|
|
|
|
+@RestMappingController("merc-mini/deviceRecords")
|
|
|
|
+@AllArgsConstructor
|
|
|
|
+@Api(tags = "小程序-设备记录")
|
|
public class MercMiniDeviceRecordsController {
|
|
public class MercMiniDeviceRecordsController {
|
|
|
|
+
|
|
|
|
+ private final static int INDEX_RECORDS_COUNT = 10;
|
|
|
|
+
|
|
|
|
+ private final DeviceRecordsService deviceRecordsService;
|
|
|
|
+
|
|
|
|
+ private final DeviceNetRecordService deviceNetRecordService;
|
|
|
|
+
|
|
|
|
+ private final DeviceErrorsRecordService deviceErrorsRecordService;
|
|
|
|
+
|
|
|
|
+ @ApiOperation("设备操作记录分页")
|
|
|
|
+ @PostMapping("deviceRecordsPage")
|
|
|
|
+ public R<PageBean<DeviceRecordsDto.Vo>> deviceRecordsPage(@RequestBody @Validated DeviceRecordsDto.Page dto) {
|
|
|
|
+ return deviceRecordsService.page(dto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("设备详情首页-设备操作记录")
|
|
|
|
+ @PostMapping("indexDeviceRecords")
|
|
|
|
+ public R<List<DeviceRecordsDto.Vo>> indexDeviceRecords(@RequestBody @Validated MiniDeviceRecordsDto.DeviceIdDto dto) {
|
|
|
|
+ DeviceRecordsDto.Page page = (DeviceRecordsDto.Page) new DeviceRecordsDto.Page().setMercId(MercAuthUtils.getMercId())
|
|
|
|
+ .setDeviceId(dto.getDeviceId());
|
|
|
|
+ page.setPage(getPageBean(INDEX_RECORDS_COUNT));
|
|
|
|
+ List<DeviceRecordsDto.Vo> recordsList = deviceRecordsPage(page).getData().getRecords();
|
|
|
|
+ return R.ok(recordsList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("联网记录分页")
|
|
|
|
+ @PostMapping("deviceNetRecordPage")
|
|
|
|
+ public R<PageBean<DeviceNetRecordDto.Vo>> deviceNetRecordPage(@RequestBody @Validated DeviceNetRecordDto.Page dto){
|
|
|
|
+ return deviceNetRecordService.page(dto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("设备详情首页-联网记录")
|
|
|
|
+ @PostMapping("indexDeviceNetRecords")
|
|
|
|
+ public R<List<DeviceNetRecordDto.Vo>> indexDeviceNetRecords(@RequestBody @Validated MiniDeviceRecordsDto.DeviceIdDto dto) {
|
|
|
|
+ DeviceNetRecordDto.Page page = (DeviceNetRecordDto.Page) new DeviceNetRecordDto.Page().setMercId(MercAuthUtils.getMercId())
|
|
|
|
+ .setDeviceId(dto.getDeviceId());
|
|
|
|
+ page.setPage(getPageBean(INDEX_RECORDS_COUNT));
|
|
|
|
+ List<DeviceNetRecordDto.Vo> recordsList = deviceNetRecordPage(page).getData().getRecords();
|
|
|
|
+ return R.ok(recordsList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("故障记录分页")
|
|
|
|
+ @PostMapping("deviceErrorPage")
|
|
|
|
+ public R<PageBean<DeviceErrorsRecordDto.Vo>> deviceErrorPage(@RequestBody DeviceErrorsRecordDto.Page page){
|
|
|
|
+ return deviceErrorsRecordService.page(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ApiOperation("设备详情首页-故障记录")
|
|
|
|
+ @PostMapping("indexDeviceError")
|
|
|
|
+ public R<List<DeviceErrorsRecordDto.Vo>> indexDeviceError(@RequestBody @Validated MiniDeviceRecordsDto.DeviceErrorPageDto dto) {
|
|
|
|
+ DeviceErrorsRecordDto.Page page = (DeviceErrorsRecordDto.Page) new DeviceErrorsRecordDto.Page().setMercId(MercAuthUtils.getMercId())
|
|
|
|
+ .setDeviceId(dto.getDeviceId()).setErrorType(dto.getErrorType());
|
|
|
|
+ page.setPage(getPageBean(INDEX_RECORDS_COUNT));
|
|
|
|
+ List<DeviceErrorsRecordDto.Vo> recordsList = deviceErrorPage(page).getData().getRecords();
|
|
|
|
+ return R.ok(recordsList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取分页信息
|
|
|
|
+ *
|
|
|
|
+ * @param count 显示条数
|
|
|
|
+ * @return {@link PageBean}
|
|
|
|
+ */
|
|
|
|
+ private PageBean getPageBean(int count){
|
|
|
|
+ List<PageBean.OrderItemBean> orderItemBeans = new ArrayList<>();
|
|
|
|
+ orderItemBeans.add(new PageBean.OrderItemBean().setColumn("id").setAsc(false));
|
|
|
|
+ return new PageBean<>().setSize(count).setSearchCount(false).setOrders(orderItemBeans);
|
|
|
|
+ }
|
|
}
|
|
}
|