|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.dto.MonitoringStationDTO; | 
|---|
|  |  |  | import com.moral.api.entity.MonitorPoint; | 
|---|
|  |  |  | import com.moral.api.pojo.form.device.MonitorPointQueryForm; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import com.moral.util.WebUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.*; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.collections4.CollectionUtils; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.poi.ss.formula.functions.T; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.CrossOrigin; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.GetMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  | 
|---|
|  |  |  | List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端参数 | 
|---|
|  |  |  | MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints); | 
|---|
|  |  |  | MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints,false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("queryMonitorPointsState") | 
|---|
|  |  |  | public ResultMessage queryMonitorPointsState(MonitorPointQueryForm form) { | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  | //处理查询业务 | 
|---|
|  |  |  | List<MonitorPoint> monitorPoints = monitorPointService.queryByOrgIdAndRegionCode(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端参数 | 
|---|
|  |  |  | MonitorPointsVO vo = MonitorPointsVO.convert(monitorPoints,true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @ApiImplicitParams(value = { | 
|---|
|  |  |  | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public void exlOut(HttpServletResponse response) { | 
|---|
|  |  |  | public void exlOut(HttpServletResponse response,@RequestBody Map<String, Object> params) { | 
|---|
|  |  |  | //导出字段集合 | 
|---|
|  |  |  | // List<ExcelHeader> excelHeaders = Arrays.asList(new ExcelHeader("phone", "手机号"), new ExcelHeader("sexStr", "性别")); | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | /* Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | params.put("macs", Arrays.asList("p5dnd7a0245446", "p5dnd7a0745450")); | 
|---|
|  |  |  | params.put("sensors", "a34004,a34002"); | 
|---|
|  |  |  | params.put("type", "hours"); | 
|---|
|  |  |  | params.put("times", Arrays.asList("2023-07-01 00", "2023-07-02 00")); | 
|---|
|  |  |  | params.put("times", Arrays.asList("2023-07-01 00", "2023-07-02 00"));*/ | 
|---|
|  |  |  | if (!params.containsKey("macs") || !params.containsKey("sensors") || !params.containsKey("times") || !params.containsKey("type")) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //数据集合 | 
|---|
|  |  |  | List<Map<String, Object>> resList = monitorPointService.getHourlyDataDataV3Excel(params); | 
|---|
|  |  |  | if (CollectionUtils.isEmpty(resList)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @PostMapping("listMonitoring") | 
|---|
|  |  |  | public ResultMessage listMonitoring(@RequestBody Map<String, Object> params) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /*@RequestParam @ApiParam(value = "mac",name = "mac号") List<String> mac, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "startTime",name = "开始时间") String startTime, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "reportType",name = "type") int reportType, | 
|---|
|  |  |  | @RequestParam @ApiParam(value = "endTime",name = "结束时间") String endTime*/ | 
|---|
|  |  |  | List<MonitoringStationDTO> resList = monitorPointService.listMonitoringStationDTO(params,Integer.parseInt(params.get("reportType").toString()),params.get("startTime").toString(),params.get("endTime").toString()); | 
|---|
|  |  |  | return ResultMessage.ok(resList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|