/** * Copyright 2018 人人开源 https://www.renren.io *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.epmet.controller; import com.epmet.common.token.annotation.Login; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.CategoryCountListFormDTO; import com.epmet.dto.form.StatsResiListFormDTO; import com.epmet.dto.form.StatsResiWarnCountFormDTO; import com.epmet.dto.form.StatsResiWarnFormDTO; import com.epmet.dto.result.CategoryCountListResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; import com.epmet.service.IcStatsResiWarnService; import com.epmet.service.StatsResiWarnService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; 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 java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 预警统计表 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-11-04 */ @RestController @RequestMapping("statsresiwarn") public class StatsResiWarnController { @Autowired private IcStatsResiWarnService icStatsResiWarnService; @Autowired private StatsResiWarnService statsResiWarnService; @PostMapping("list") public Result> list(@LoginUser TokenDto tokenDto,@RequestBody StatsResiListFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO); String customerId = tokenDto.getCustomerId(); List icStatsResiResultDTOList = statsResiWarnService.list(customerId,formDTO.getId(),formDTO.getLevel()); return new Result>().ok(icStatsResiResultDTOList); } /** * @Description 内部调了list * @param formDTO * @author zxc * @date 2022/1/20 2:11 下午 */ @PostMapping("list2") public Result> list2(@RequestBody CategoryCountListFormDTO formDTO){ return new Result>().ok(statsResiWarnService.list2(formDTO)); } @PostMapping("buildingwarnlist") public Result buildingWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedBuilding.class); String customerId = tokenDto.getCustomerId(); String agencyID = formDTO.getAgencyId(); List icStatsResiWarnBuildingResultDTOS = statsResiWarnService.buildingwWarnList(customerId,agencyID); return new Result().ok(icStatsResiWarnBuildingResultDTOS); } @PostMapping("userwarnlist") public Result userWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedUser.class); String customerId = tokenDto.getCustomerId(); List buildingIdList = formDTO.getBuildingIdList(); if(CollectionUtils.isEmpty(buildingIdList)){ Map map = new HashMap<>(); map.put("total",0); map.put("list",new ArrayList<>()); return new Result().ok(map); } return new Result().ok(statsResiWarnService.userWarnList(customerId,formDTO.getConfigId(), formDTO.getBuildingIdList(),formDTO.getPageNo(),formDTO.getPageSize())); } /** * 统计所有 * @return */ @PostMapping("resiwarn") public Result resiWarn(@LoginUser TokenDto tokenDto){ statsResiWarnService.resiWarn(tokenDto.getCustomerId()); return new Result(); } @PostMapping("resiWarnByOne") public Result resiWarnByOne(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnCountFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO); statsResiWarnService.resiWarnByOne(tokenDto.getCustomerId(),formDTO.getUserId()); return new Result(); } }