From 7d64716cb0d406f21cde03976fd273bd07fdc06f Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期二, 28 九月 2021 11:44:28 +0800 Subject: [PATCH] 更新用户-角色-菜单-权限 --- src/main/java/com/whyc/controller/TestDataController.java | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/whyc/controller/TestDataController.java b/src/main/java/com/whyc/controller/TestDataController.java index 7d20e7f..6ba5e61 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; @@ -16,19 +19,26 @@ import javax.annotation.Resource; import java.text.DateFormat; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @RestController @RequestMapping("testData") -@Api(tags = "瀹為獙鏁版嵁") +@Api(tags = "璇曢獙鏁版嵁") @Slf4j public class TestDataController { @Autowired private TestPlanService testPlanService; @Resource private MotorStateService motorStateService; + @Autowired + private DeviceInfService deviceInfService; + + @GetMapping("ws") + @ApiOperation(value="鏌ヨwebSocket",protocols = "ws",notes = "鎺ュ彛:ws://localhost:8090/testData,鍙戦�佹秷鎭负testPlanId") + public Response doc(){ + return new Response().setMsg(1,"鏌ョ湅鎺ュ彛鎻忚堪"); + } @GetMapping() @ApiOperation("鑾峰彇鍘嗗彶鏁版嵁") @@ -42,11 +52,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