From 5df6dd9d2044bda8302a0a352ace59d642183b51 Mon Sep 17 00:00:00 2001 From: Lemon Date: Thu, 30 Oct 2025 15:48:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=85=E7=94=B5=E6=A1=A9=E5=88=B0=E5=8F=A6=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=AB=99=E7=82=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pile/PileBasicInfoController.java | 8 +++ .../pile/dto/ReplaceMerchantStationDTO.java | 10 ++++ .../pile/service/PileBasicInfoService.java | 7 +++ .../impl/PileBasicInfoServiceImpl.java | 53 +++++++++++++++++++ .../mapper/pile/PileBasicInfoMapper.xml | 4 +- 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileBasicInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileBasicInfoController.java index 4d7c796c8..8694cfdb1 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileBasicInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileBasicInfoController.java @@ -162,6 +162,14 @@ public class PileBasicInfoController extends BaseController { return toAjax(pileBasicInfoService.replaceMerchantStationByPileIds(dto)); } + /** + * 移动充电桩到另一个站点 + */ + @PostMapping("/movePile2AnotherStation") + public AjaxResult movePile2AnotherStation(@RequestBody ReplaceMerchantStationDTO dto) { + logger.info("移动充电桩到另一个站点 param:{}", JSON.toJSONString(dto)); + return toAjax(pileBasicInfoService.movePile2AnotherStation(dto)); + } /** * 查询充电桩详情 * @return diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/ReplaceMerchantStationDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/ReplaceMerchantStationDTO.java index 39cd4dfd3..dad888676 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/dto/ReplaceMerchantStationDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/ReplaceMerchantStationDTO.java @@ -45,4 +45,14 @@ public class ReplaceMerchantStationDTO { private String updateBy; private Date updateTime; + + /** + * 移动充电桩时有值,新运营商 id + */ + private String newMerchantId; + + /** + * 移动充电桩时有值,新站点 id + */ + private String newStationId; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java index 15395db93..911f65db3 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/PileBasicInfoService.java @@ -251,4 +251,11 @@ public interface PileBasicInfoService { void registrationEBikePile(EBikeMessageCmd20 message); List getPileDetailInfoList(String stationId); + + /** + * 移动桩到其他站点 + * @param dto + * @return + */ + int movePile2AnotherStation(ReplaceMerchantStationDTO dto); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index cd6c9295b..534740ace 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -17,8 +17,10 @@ import com.jsowell.common.enums.ykc.PileStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.*; +import com.jsowell.common.util.spring.SpringUtils; import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.ebike.deviceupload.EBikeMessageCmd20; +import com.jsowell.pile.domain.ykcCommond.PublishPileBillingTemplateCommand; import com.jsowell.pile.dto.*; import com.jsowell.pile.mapper.PileBasicInfoMapper; import com.jsowell.pile.service.*; @@ -41,6 +43,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.RandomStringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; import org.springframework.util.StopWatch; @@ -48,6 +51,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -102,6 +106,15 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { @Autowired private PileMemberRelationService pileMemberRelationService; + @Autowired + private PileBillingTemplateService pileBillingTemplateService; + + @Autowired + private YKCPushCommandService ykcPushCommandService; + + // 引入线程池 + private ThreadPoolTaskExecutor executor = SpringUtils.getBean("threadPoolTaskExecutor"); + /** * 查询设备管理 * @@ -1301,6 +1314,46 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService { } /** + * 移动桩到其他站点 + * @param dto + * @return + */ + @Override + public int movePile2AnotherStation(ReplaceMerchantStationDTO dto) { + // 校验传过来的参数是否为空 + String newStationId = dto.getNewStationId(); + String stationId = dto.getStationId(); + List pileSnList = dto.getPileSnList(); + // 查询新站点正在使用中的计费模板 + BillingTemplateVO billingTemplateVO = pileBillingTemplateService.queryUsedBillingTemplateForEV(newStationId); + // 对比传来的新站点id与现在桩的站点id是否相等 + if (StringUtils.equals(newStationId, stationId)) { + // 相等,则不修改 + return 0; + } + dto.setUpdateBy(SecurityUtils.getUsername()); + dto.setUpdateTime(DateUtils.getNowDate()); + // 修改数据库中桩信息 + int num = pileBasicInfoMapper.replaceMerchantStationByPileIds(dto); + // 异步向桩下发新站点的计费模板 + for (String pileSn : pileSnList) { + CompletableFuture.runAsync(() -> { + PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder() + .pileSn(pileSn) + .billingTemplateVO(billingTemplateVO) + .build(); + // 发送请求 + try { + ykcPushCommandService.pushPublishPileBillingTemplate(command); + } catch (Exception e) { + log.error("向桩:{} 下发计费模板 error,", pileSn, e); + } + }, executor); + } + return num; + } + + /** * 获取枪口列表 * // * @param pileBasicInfo diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml index 5de888c20..7fc4d22b3 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileBasicInfoMapper.xml @@ -237,8 +237,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update pile_basic_info - merchant_id = #{merchantId}, - station_id = #{stationId}, + merchant_id = #{newMerchantId}, + station_id = #{newStationId}, business_type = #{chargerPileType,jdbcType=VARCHAR},