| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.pojo.dto.dataDisplay.MonitorPointDataDisplayDTO; |
| | | import com.moral.api.pojo.dto.dataDisplay.SensorComparisonDisplayDTO; |
| | | import com.moral.api.pojo.form.dataDisplay.MonitorPointDataDisplayForm; |
| | | import com.moral.api.pojo.form.dataDisplay.SensorComparisonDisplayForm; |
| | | import com.moral.api.service.DataDisplayService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.DateUtils; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @RequestMapping("/dataDisplay") |
| | | public class DataDisplayController { |
| | | |
| | | @Autowired |
| | | DataDisplayService dataDisplayService; |
| | | |
| | | @GetMapping("monitorPointDataDisplay") |
| | | public ResultMessage monitorPointDataDisplay(MonitorPointDataDisplayForm form){ |
| | | //判断是否缺少参数 |
| | |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | |
| | | MonitorPointDataDisplayDTO dto = new MonitorPointDataDisplayDTO(); |
| | | MonitorPointDataDisplayDTO dto1 = new MonitorPointDataDisplayDTO(); |
| | | MonitorPointDataDisplayDTO dto2 = new MonitorPointDataDisplayDTO(); |
| | | List<MonitorPointDataDisplayDTO> dtos = dataDisplayService.getMonitorPointDisplayData(form); |
| | | |
| | | dto.setDeviceName("模拟设备1"); |
| | | dto1.setDeviceName("模拟设备2"); |
| | | dto2.setDeviceName("模拟设备3"); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),dtos); |
| | | } |
| | | |
| | | dto.setTime("yyyy-MM-dd HH:mm:ss"); |
| | | dto1.setTime("yyyy-MM-dd HH:mm:ss"); |
| | | dto2.setTime("yyyy-MM-dd HH:mm:ss"); |
| | | @PostMapping("sensorComparisonDisplay") |
| | | public ResultMessage sensorComparisonDisplay(@RequestBody SensorComparisonDisplayForm form){ |
| | | //判断是否缺少参数 |
| | | if (!form.valid()) |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), |
| | | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | List<SensorComparisonDisplayDTO> dtos = dataDisplayService.getSensorComparisonDisplayData(form); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),dtos); |
| | | } |
| | | |
| | | dto.setOrganizationName("模拟组织1"); |
| | | dto1.setOrganizationName("模拟组织2"); |
| | | dto2.setOrganizationName("模拟组织3"); |
| | | |
| | | Map<String,Object> valueMap = new HashMap<>(); |
| | | valueMap.put("a21026",1); |
| | | valueMap.put("a21004",1); |
| | | valueMap.put("a34002",1); |
| | | valueMap.put("a34004",1); |
| | | valueMap.put("a21005",1); |
| | | valueMap.put("a05024",1); |
| | | valueMap.put("a99054",1); |
| | | valueMap.put("AQI",1); |
| | | |
| | | dto.setValues(valueMap); |
| | | dto1.setValues(valueMap); |
| | | dto2.setValues(valueMap); |
| | | |
| | | List<MonitorPointDataDisplayDTO> list = new ArrayList<>(); |
| | | list.add(dto); |
| | | list.add(dto1); |
| | | list.add(dto2); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),list); |
| | | @PostMapping("sensorComparisonDisplayV2") |
| | | public ResultMessage sensorComparisonDisplayV2(@RequestBody Map<String, Object> params){ |
| | | //判断是否缺少参数 |
| | | if (!params.containsKey("mac") || !params.containsKey("sensorCodes") || !params.containsKey("reportType") || !params.containsKey("times")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<SensorComparisonDisplayDTO> dtos = dataDisplayService.getSensorComparisonDisplayDataV2(params); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),dtos); |
| | | } |
| | | |
| | | } |