| | |
| | | import com.moral.api.pojo.vo.monitorPoint.MonitorPointsVO; |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.moral.api.service.MonitorPointService; |
| | | import com.moral.api.utils.EasyExcelUtils; |
| | | import com.moral.api.utils.NoModelWriteData; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @ClassName DeviceController |
| | |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | String[] monitorPointIds = params.remove("monitorPointIds").toString().split(","); |
| | | if (monitorPointIds.length >3){ |
| | | if (monitorPointIds.length > 3) { |
| | | return ResultMessage.ok(); |
| | | } |
| | | params.put("monitorPointIds", monitorPointIds); |
| | |
| | | return ResultMessage.ok(resList); |
| | | } |
| | | |
| | | |
| | | @PostMapping("getHourlyDataExcelNew") |
| | | public ResultMessage getHourlyDataExcelNew(@RequestBody Map<String, Object> params) { |
| | | if (!params.containsKey("macs") || !params.containsKey("sensors") || !params.containsKey("times") || !params.containsKey("type")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<Map<String, Object>> resList = monitorPointService.getHourlyDataDataV3Excel(params); |
| | | return ResultMessage.ok(resList); |
| | | } |
| | | |
| | | @PostMapping("/exlOut") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") |
| | | }) |
| | | public void exlOut(HttpServletResponse response) { |
| | | //导出字段集合 |
| | | // List<ExcelHeader> excelHeaders = Arrays.asList(new ExcelHeader("phone", "手机号"), new ExcelHeader("sexStr", "性别")); |
| | | 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")); |
| | | //数据集合 |
| | | List<Map<String, Object>> resList = monitorPointService.getHourlyDataDataV3Excel(params); |
| | | if (CollectionUtils.isEmpty(resList)) { |
| | | return; |
| | | } |
| | | Map<String, Object> map = resList.get(0); |
| | | List<String> list = new ArrayList<>(); |
| | | for (String key : map.keySet()) { |
| | | list.add(key); |
| | | } |
| | | String[] s2 = new String[list.size()]; |
| | | list.toArray(s2); |
| | | NoModelWriteData d = new NoModelWriteData(); |
| | | d.setFileName("数据导出"); |
| | | d.setHeadMap(s2); |
| | | d.setDataStrMap(s2); |
| | | d.setDataList(resList); |
| | | try { |
| | | EasyExcelUtils easyExcelUtils = new EasyExcelUtils(); |
| | | easyExcelUtils.noModleWrite(d, response); |
| | | } catch (Exception e) { |
| | | int i = 0; |
| | | } |
| | | |
| | | } |
| | | } |