| | |
| | | import com.ruoyi.chargingPile.dto.ChargingGunCountMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingGunMonitoring; |
| | | import com.ruoyi.chargingPile.dto.GetChargingGunMonitoring; |
| | | import com.ruoyi.chargingPile.dto.ChargingPileBatchBuildDTO; |
| | | import com.ruoyi.chargingPile.dto.ChargingPileImportDTO; |
| | | import com.ruoyi.chargingPile.dto.ChargingPileImportResultDTO; |
| | | import com.ruoyi.chargingPile.export.ChargingPileExport; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | import com.ruoyi.chargingPile.service.TFaultMessageService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | return chargingPileService.addChargingPile(chargingPile); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/export", "/chargingPile"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PutMapping("/export") |
| | | @Log(title = "【充电桩信息】导出充电桩数据", businessType = BusinessType.EXPORT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "导出充电桩数据", tags = {"管理后台-充电桩信息"}) |
| | | public void export(@RequestBody PageChargingPileList page, HttpServletResponse response){ |
| | | List<PageChargingPileListDTO> records = chargingPileService.listChargingPileForExport(page); |
| | | Set<Integer> pileIds = records.stream() |
| | | .map(PageChargingPileListDTO::getId) |
| | | .filter(id -> id != null) |
| | | .collect(Collectors.toSet()); |
| | | Map<Integer, TChargingPile> pileMap = pileIds.isEmpty() |
| | | ? Collections.emptyMap() |
| | | : chargingPileService.listByIds(pileIds).stream() |
| | | .collect(Collectors.toMap(TChargingPile::getId, item -> item, (left, right) -> left)); |
| | | List<TChargingGunVO> guns = pileIds.isEmpty() |
| | | ? Collections.emptyList() |
| | | : chargingGunService.exportQRCodeList(new TChargingGunQuery()).stream() |
| | | .filter(gun -> pileIds.contains(gun.getChargingPileId())) |
| | | .collect(Collectors.toList()); |
| | | Map<Integer, List<TChargingGunVO>> gunsByPile = guns.stream() |
| | | .collect(Collectors.groupingBy(TChargingGunVO::getChargingPileId)); |
| | | List<ChargingPileExport> exports = new ArrayList<>(); |
| | | for (PageChargingPileListDTO record : records) { |
| | | List<TChargingGunVO> pileGuns = gunsByPile.getOrDefault(record.getId(), Collections.emptyList()); |
| | | if (pileGuns.isEmpty()) { |
| | | exports.add(ChargingPileExport.from(record, pileMap.get(record.getId()), null)); |
| | | continue; |
| | | } |
| | | for (TChargingGunVO gun : pileGuns) { |
| | | exports.add(ChargingPileExport.from(record, pileMap.get(record.getId()), gun)); |
| | | } |
| | | } |
| | | ExcelUtil<ChargingPileExport> util = new ExcelUtil<>(ChargingPileExport.class); |
| | | util.exportExcel(response, exports, "充电桩数据"); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/add"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/importTemplate") |
| | | @ApiOperation(value = "下载充电桩导入模板", tags = {"管理后台-充电桩信息"}) |
| | | public void importTemplate(HttpServletResponse response){ |
| | | ExcelUtil<ChargingPileImportDTO> util = new ExcelUtil<>(ChargingPileImportDTO.class); |
| | | util.importTemplateExcel(response, "充电桩导入模板"); |
| | | } |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/add"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/import") |
| | | @Log(title = "【充电桩信息】批量导入充电桩", businessType = BusinessType.IMPORT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "批量导入充电桩", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult importChargingPile(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "cover", defaultValue = "false") Boolean cover) throws Exception{ |
| | | ChargingPileImportResultDTO result = chargingPileService.importChargingPile(file, cover); |
| | | if(Boolean.TRUE.equals(result.getNeedConfirm())){ |
| | | return AjaxResult.warn("检测到重复设备编码,是否覆盖?", result); |
| | | } |
| | | if(result.getErrorCount() != null && result.getErrorCount() > 0){ |
| | | return AjaxResult.error("导入失败,请检查错误信息", result); |
| | | } |
| | | return AjaxResult.success("导入成功", result); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingPile/add"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @PostMapping("/batchBuild") |
| | | @Log(title = "【充电桩信息】批量建桩", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "批量建桩", tags = {"管理后台-充电桩信息"}) |
| | | public AjaxResult batchBuild(@RequestBody ChargingPileBatchBuildDTO dto){ |
| | | return AjaxResult.success("批量建桩成功", chargingPileService.batchBuildChargingPile(dto)); |
| | | } |
| | | @RequiresPermissions(value = {"/chargingPile/select", "/chargingPile/update"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingPile/{id}") |
| | |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring"}, logical = Logical.OR) |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring", "/generalBigScreen", "/dataCockpit"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/chargeMonitoring/{siteId}") |
| | | @ApiOperation(value = "获取充电设施监控数据", tags = {"管理后台-充电设备监控"}) |
| | |
| | | ChargeMonitoring chargeMonitoring = chargingPileService.chargeMonitoring(siteId); |
| | | return AjaxResult.success(chargeMonitoring); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingMonitoringSiteList") |
| | | @ApiOperation(value = "获取当前账号允许监控的站点", tags = {"管理后台-充电设备监控"}) |
| | | public AjaxResult<List<Site>> getChargingMonitoringSiteList() { |
| | | return AjaxResult.success(chargingPileService.getChargingMonitoringSiteList()); |
| | | } |
| | | |
| | | |
| | | @RequiresPermissions(value = {"/chargingEquipmentMonitoring", "/generalBigScreen", "/dataCockpit"}, logical = Logical.OR) |
| | | @ResponseBody |
| | | @GetMapping("/getChargingGunCountMonitoring/{siteId}") |
| | | @ApiOperation(value = "获取充电枪各种状态汇总监控数据", tags = {"管理后台-充电设备监控"}) |
| | | public AjaxResult<ChargingGunCountMonitoring> getChargingGunCountMonitoring(@PathVariable Integer siteId){ |