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:
@@ -134,12 +134,13 @@ public class PileBillingTemplateController extends BaseController {
|
||||
}
|
||||
|
||||
private void publishBillingTemplate(CreateOrUpdateBillingTemplateDTO dto) {
|
||||
long l = System.currentTimeMillis();
|
||||
// 发布计费模板
|
||||
PublishBillingTemplateDTO publishBillingTemplateDTO = new PublishBillingTemplateDTO();
|
||||
publishBillingTemplateDTO.setTemplateId(dto.getBillingTemplateId());
|
||||
publishBillingTemplateDTO.setStationId(dto.getStationId());
|
||||
logger.info("新增或者更新后发布计费模板, param:{}", JSON.toJSONString(publishBillingTemplateDTO));
|
||||
pileRemoteService.publishBillingTemplate(publishBillingTemplateDTO);
|
||||
logger.info("新增或者更新后发布计费模板, param:{}, 耗时:{}", JSON.toJSONString(publishBillingTemplateDTO), System.currentTimeMillis() - l);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -162,6 +162,11 @@ public class CacheConstants {
|
||||
*/
|
||||
public static final String SELECT_PILE_CONNECTOR_INFO_LIST = "select_pile_connector_info_list:";
|
||||
|
||||
/**
|
||||
* 充电桩状态前缀
|
||||
*/
|
||||
public static final String PILE_STATUS_KEY = "pile_status:";
|
||||
|
||||
/**
|
||||
* 充电桩枪口状态前缀
|
||||
*/
|
||||
|
||||
@@ -264,7 +264,7 @@ public class PileRemoteService {
|
||||
* 下发充电桩计费模型
|
||||
*/
|
||||
public void publishPileBillingTemplate(String pileSn, BillingTemplateVO billingTemplateVO) {
|
||||
|
||||
log.info("下发充电桩计费模型, pileSn:{}, threadName:{}", pileSn, Thread.currentThread().getName());
|
||||
PublishPileBillingTemplateCommand command = PublishPileBillingTemplateCommand.builder()
|
||||
.billingTemplateVO(billingTemplateVO)
|
||||
.pileSn(pileSn)
|
||||
@@ -294,10 +294,11 @@ public class PileRemoteService {
|
||||
if (StringUtils.equals(billingTemplateVO.getDeviceType(), Constants.ONE)) {
|
||||
List<PileDetailVO> pileList = pileBasicInfoService.selectPileListByStationIds(Lists.newArrayList(Long.valueOf(dto.getStationId())));
|
||||
if (CollectionUtils.isNotEmpty(pileList)) {
|
||||
for (PileDetailVO pileInfoVO : pileList) {
|
||||
// 下发计费模板
|
||||
publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
|
||||
}
|
||||
// for (PileDetailVO pileInfoVO : pileList) {
|
||||
// // 下发计费模板
|
||||
// publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO);
|
||||
// }
|
||||
pileList.parallelStream().forEach(pileInfoVO -> publishPileBillingTemplate(pileInfoVO.getPileSn(), billingTemplateVO));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
@@ -493,16 +494,22 @@ public class PileBasicInfoServiceImpl implements PileBasicInfoService {
|
||||
|
||||
@Override
|
||||
public List<PileDetailVO> selectPileListByStationIds(List<Long> stationIdList) {
|
||||
StopWatch sw = new StopWatch("selectPileListByStationIds");
|
||||
// 加缓存
|
||||
sw.start("根据stationIdList查询桩列表");
|
||||
List<PileDetailVO> pileInfoVOS = pileBasicInfoMapper.selectPileListByStationIds(stationIdList);
|
||||
if (CollectionUtils.isEmpty(pileInfoVOS)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
sw.stop();
|
||||
sw.start("获取桩状态");
|
||||
List<String> pileSnList = pileInfoVOS.stream().map(PileDetailVO::getPileSn).collect(Collectors.toList());
|
||||
Map<String, String> pileStatusMap = pileConnectorInfoService.getPileStatus(pileSnList);
|
||||
for (PileDetailVO pileInfoVO : pileInfoVOS) {
|
||||
pileInfoVO.setStatus(pileStatusMap.get(pileInfoVO.getPileSn()));
|
||||
}
|
||||
sw.stop();
|
||||
log.info("selectPileListByStationIds 耗时:{}, 详细:{}", sw.getTotalTimeMillis(), sw.prettyPrint());
|
||||
return pileInfoVOS;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ 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;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -134,11 +133,10 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
pileConnectorInfo.setPileSn(pileSn);
|
||||
result = selectPileConnectorInfoList(pileConnectorInfo);
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
// 查询数据库不为空,存redis 2分钟
|
||||
// 查询数据库不为空,存redis 5分钟
|
||||
redisCache.setCacheObject(redisKey, result, 5, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
||||
// PileConnectorInfo pileConnectorInfo = new PileConnectorInfo();
|
||||
// pileConnectorInfo.setPileSn(pileSn);
|
||||
// List<PileConnectorInfo> result = selectPileConnectorInfoList(pileConnectorInfo);
|
||||
@@ -660,11 +658,9 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getPileStatus(List<String> pileSnList) {
|
||||
StopWatch watch = new StopWatch("批量获取桩状态");
|
||||
Map<String, String> resultMap = Maps.newHashMap();
|
||||
for (String pileSn : pileSnList) {
|
||||
String pileStatus = "";
|
||||
|
||||
// 标识桩故障或者离线
|
||||
boolean flag = false;
|
||||
// 判断故障状态
|
||||
@@ -675,13 +671,11 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
pileStatus = PileStatusEnum.FAULT.getValue();
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// 判断离线状态 显示优先级 离线>故障
|
||||
// if (checkPileOffLine(pileSn)) {
|
||||
// pileStatus = PileStatusEnum.OFF_LINE.getValue();
|
||||
// flag = true;
|
||||
// }
|
||||
|
||||
// 2023年1月10日11点32分 改成如果枪口离线,那么充电桩就是离线
|
||||
if (connectorStatusList.contains(PileConnectorDataBaseStatusEnum.OFF_NETWORK.getValue())) {
|
||||
pileStatus = PileStatusEnum.OFF_LINE.getValue();
|
||||
@@ -691,17 +685,24 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
orderBasicInfoService.updateOrderStatusAsAbnormal(pileSn);
|
||||
}, executor);
|
||||
}
|
||||
|
||||
// 没有故障或者离线,就是在线状态
|
||||
if (!flag) {
|
||||
pileStatus = PileStatusEnum.ON_LINE.getValue();
|
||||
}
|
||||
|
||||
resultMap.put(pileSn, pileStatus);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化批量获取桩状态
|
||||
* @param pileSnList 桩编号列表
|
||||
* @return key:桩编号; value:状态
|
||||
*/
|
||||
public Map<String, String> getPileStatusV2(List<String> pileSnList) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PileConnectorInfoVO getPileConnectorInfoByConnectorCode(String pileConnectorCode) {
|
||||
return pileConnectorInfoMapper.getPileConnectorInfoByConnectorCode(pileConnectorCode);
|
||||
@@ -713,6 +714,7 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
|
||||
* @param pileSn 桩编号
|
||||
* @return true离线
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPileOffLine(String pileSn) {
|
||||
// 获取桩最后连接时间,最后连接到平台的时间在3分钟之前,判定为离线
|
||||
String lastConnectionTime = redisCache.getCacheObject(CacheConstants.PILE_LAST_CONNECTION + pileSn);
|
||||
|
||||
@@ -424,9 +424,9 @@ public class YKCPushCommandServiceImpl implements YKCPushCommandService {
|
||||
// 发送
|
||||
if (messageBody != null) {
|
||||
try {
|
||||
this.supplySend(messageBody, pileSn, YKCFrameTypeCode.BILLING_TEMPLATE_SETTING_CODE);
|
||||
this.runSend(messageBody, pileSn, YKCFrameTypeCode.BILLING_TEMPLATE_SETTING_CODE);
|
||||
} catch (Exception e) {
|
||||
log.error("向充电桩发送计费模板error", e);
|
||||
log.error("向充电桩发送计费模板error: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user