mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
新增 移动充电桩到另一个站点接口
This commit is contained in:
@@ -45,4 +45,14 @@ public class ReplaceMerchantStationDTO {
|
||||
|
||||
private String updateBy;
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 移动充电桩时有值,新运营商 id
|
||||
*/
|
||||
private String newMerchantId;
|
||||
|
||||
/**
|
||||
* 移动充电桩时有值,新站点 id
|
||||
*/
|
||||
private String newStationId;
|
||||
}
|
||||
|
||||
@@ -251,4 +251,11 @@ public interface PileBasicInfoService {
|
||||
void registrationEBikePile(EBikeMessageCmd20 message);
|
||||
|
||||
List<PileDetailInfoVO> getPileDetailInfoList(String stationId);
|
||||
|
||||
/**
|
||||
* 移动桩到其他站点
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
int movePile2AnotherStation(ReplaceMerchantStationDTO dto);
|
||||
}
|
||||
|
||||
@@ -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<String> 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
|
||||
|
||||
@@ -237,8 +237,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="replaceMerchantStationByPileIds">
|
||||
update pile_basic_info
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id = #{merchantId},</if>
|
||||
<if test="stationId != null">station_id = #{stationId},</if>
|
||||
<if test="newMerchantId != null">merchant_id = #{newMerchantId},</if>
|
||||
<if test="newStationId != null">station_id = #{newStationId},</if>
|
||||
<if test="chargerPileType != null">
|
||||
business_type = #{chargerPileType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user