| | |
| | | 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 com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.integration.api.elutong.model.ConnectorStatusInfo; |
| | | import com.ruoyi.integration.api.elutong.model.ConnectorStatusReq; |
| | | import com.ruoyi.integration.api.feignClient.ChengDuJianGuanClient; |
| | | import com.ruoyi.integration.api.feignClient.ELuTongClient; |
| | | import com.ruoyi.integration.api.feignClient.TCECClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | private ELuTongClient eLuTongClient; |
| | | |
| | | @Resource |
| | | private ISiteService siteService; |
| | | private ChengDuJianGuanClient chengDuJianGuanClient; |
| | | |
| | | |
| | | |
| | |
| | | this.chargingPileService = chargingPileService; |
| | | this.chargingGunService = chargingGunService; |
| | | } |
| | | |
| | | /** |
| | | * 临时添加充电桩 |
| | | */ |
| | | @PostMapping(value = "/addPileTemp") |
| | | @ResponseBody |
| | | public R<Integer> addPileTemp(@RequestBody TChargingPile chargingPile){ |
| | | chargingPileService.save(chargingPile); |
| | | return R.ok(chargingPile.getId()); |
| | | } |
| | | /** |
| | | * 查询充电桩列表 |
| | | */ |
| | |
| | | @PostMapping(value = "/getChargingPileBySiteIds") |
| | | public R<List<TChargingPile>> getChargingPileBySiteIds(@RequestParam("siteIds") List<Integer> siteIds) { |
| | | return R.ok(chargingPileService.list(Wrappers.lambdaQuery(TChargingPile.class) |
| | | .in(!siteIds.isEmpty(),TChargingPile::getSiteId,siteIds))); |
| | | .in(!siteIds.isEmpty(),TChargingPile::getSiteId,siteIds).eq(TChargingPile::getDelFlag, 0))); |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/screenChargeMonitoring/{siteId}") |
| | | @ApiOperation(value = "获取智慧充电大屏监控数据", tags = {"管理后台-智慧充电大屏"}) |
| | | public AjaxResult<ChargeMonitoring> screenChargeMonitoring(@PathVariable Integer siteId){ |
| | | return AjaxResult.success(chargingPileService.chargeMonitoringForScreen(siteId)); |
| | | } |
| | | |
| | | @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 = {"管理后台-充电设备监控"}) |
| | |
| | | TChargingGun tChargingGun = chargingGunService.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getFullNumber, (pile_code + gun_code)).eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != tChargingGun){ |
| | | redisTemplate.opsForHash().put("charging_gun_online", tChargingGun.getFullNumber(), System.currentTimeMillis()); |
| | | |
| | | //上传成都监管 |
| | | chengDuJianGuanClient.notificationStationStatus(tChargingGun.getId()); |
| | | TChargingPile chargingPile = chargingPileService.getById(tChargingGun.getChargingPileId()); |
| | | //枪处于离线或者故障,返回状态为正常,则修改其状态 |
| | | if(0 == status && tChargingGun.getStatus() != 2){ |
| | |
| | | faultMessage.setContent("设备故障"); |
| | | faultMessageService.save(faultMessage); |
| | | } |
| | | if(2 == status){ |
| | | if(2 == status && !Arrays.asList(3, 4, 5).contains(tChargingGun.getStatus())){ |
| | | TChargingOrderVo order = new TChargingOrderVo(); |
| | | order.setChargingPileId(tChargingGun.getChargingPileId()); |
| | | order.setChargingGunId(tChargingGun.getId()); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/getAllPile") |
| | | public R<List<TChargingPile>> getAllPile(){ |
| | | List<TChargingPile> pileList = chargingPileService.list(); |
| | | return R.ok(pileList); |
| | | } |
| | | |
| | | /** |
| | | * 推送设备接口状态信息 |
| | |
| | | |
| | | private ConnectorStatusInfo buildConnectorStatus(TChargingGun chargingGun){ |
| | | ConnectorStatusInfo connectorStatusInfo = new ConnectorStatusInfo(); |
| | | connectorStatusInfo.setConnectorId(chargingGun.getCode()); |
| | | connectorStatusInfo.setConnectorId(chargingGun.getFullNumber()); |
| | | switch (chargingGun.getStatus()){ |
| | | case 1: |
| | | connectorStatusInfo.setStatus(0); |