| | |
| | | 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; |
| | |
| | | private TestPlanService testPlanService; |
| | | @Resource |
| | | private MotorStateService motorStateService; |
| | | @Autowired |
| | | private DeviceInfService deviceInfService; |
| | | |
| | | @GetMapping() |
| | | @ApiOperation("获取历史数据") |
| | |
| | | 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); |
| | | } |
| | | } |