From 8e560d924cd1d6918b969b6b0978b613da0bdfb1 Mon Sep 17 00:00:00 2001 From: whyczh <hzjl@qq.com> Date: 星期三, 31 三月 2021 17:29:42 +0800 Subject: [PATCH] 调整试验数据返回数据结构 --- src/main/java/com/whyc/controller/TestDataController.java | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/whyc/controller/TestDataController.java b/src/main/java/com/whyc/controller/TestDataController.java index 7d20e7f..e8709c7 100644 --- a/src/main/java/com/whyc/controller/TestDataController.java +++ b/src/main/java/com/whyc/controller/TestDataController.java @@ -1,8 +1,11 @@ package com.whyc.controller; +import com.google.gson.JsonObject; import com.whyc.dto.Response; +import com.whyc.dto.TestDataDTO; import com.whyc.pojo.MotorState; import com.whyc.pojo.TestPlan; +import com.whyc.service.DeviceInfService; import com.whyc.service.MotorStateService; import com.whyc.service.TestPlanService; import io.swagger.annotations.Api; @@ -29,6 +32,8 @@ private TestPlanService testPlanService; @Resource private MotorStateService motorStateService; + @Autowired + private DeviceInfService deviceInfService; @GetMapping() @ApiOperation("鑾峰彇鍘嗗彶鏁版嵁") @@ -42,11 +47,16 @@ String startTime = dateFormat.format(testPlan.getStartTime()); String endTime = dateFormat.format(testPlan.getEndTime()); //閫氳繃璁惧鍜屽紑濮嬬粨鏉熸椂闂存潵鑾峰彇瀵瑰簲鐨勬暟鎹� - Map<String,List<MotorState>> map = new HashMap<>(); + List<TestDataDTO> list = new ArrayList<TestDataDTO>(); for (String deviceId: devIds) { List<MotorState> historyData = motorStateService.getHistoryData(deviceId,startTime,endTime); - map.put(deviceId,historyData); + String deviceName = deviceInfService.getOneByDeviceId(Integer.valueOf(deviceId)).getDeviceName(); + TestDataDTO testDataDTO = new TestDataDTO(); + testDataDTO.setDeviceId(deviceId); + testDataDTO.setDeviceName(deviceName); + testDataDTO.setData(historyData); + list.add(testDataDTO); } - return new Response().set(1,map); + return new Response().set(1,list); } } -- Gitblit v1.9.1