This commit is contained in:
2023-06-21 15:55:40 +08:00
parent 42975464b1
commit 2097566b9a
6 changed files with 60 additions and 3 deletions

View File

@@ -23,6 +23,8 @@ public class CacheConstants {
public static final int cache_expire_time_1d = 60 * 60 * 24;
public static final String GET_PILE_MODEL_INFO_BY_MODEL_ID = "get_pile_model_info_by_model_id:";
public static final String QUERY_BILLING_DETAIL_BY_ID = "query_billing_detail_by_id:";
//

View File

@@ -70,4 +70,6 @@ public interface PileModelInfoMapper {
* @return PileModelInfo对象
*/
List<PileModelInfoVO> getPileModelInfoByPileSnList(@Param("pileSnList") List<String> pileSns);
PileModelInfoVO getPileModelInfoByModelId(@Param("modelId") Long modelId);
}

View File

@@ -69,4 +69,6 @@ public interface IPileModelInfoService {
List<PileModelInfoVO> getPileModelInfoByPileSnList(List<String> pileSns);
PileModelInfoVO getPileModelInfoByPileSn(String pileSn);
PileModelInfoVO getPileModelInfoByModelId(Long modelId);
}

View File

@@ -1,6 +1,8 @@
package com.jsowell.pile.service.impl;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.domain.PileModelInfo;
import com.jsowell.pile.mapper.PileModelInfoMapper;
@@ -11,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* 充电桩型号信息Service业务层处理
@@ -23,6 +26,9 @@ public class PileModelInfoServiceImpl implements IPileModelInfoService {
@Autowired
private PileModelInfoMapper pileModelInfoMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询充电桩型号信息
*
@@ -66,6 +72,7 @@ public class PileModelInfoServiceImpl implements IPileModelInfoService {
@Override
public int updatePileModelInfo(PileModelInfo pileModelInfo) {
pileModelInfo.setUpdateTime(DateUtils.getNowDate());
cleanCache(new Long[]{pileModelInfo.getId()});
return pileModelInfoMapper.updatePileModelInfo(pileModelInfo);
}
@@ -77,6 +84,7 @@ public class PileModelInfoServiceImpl implements IPileModelInfoService {
*/
@Override
public int deletePileModelInfoByIds(Long[] ids) {
cleanCache(ids);
return pileModelInfoMapper.deletePileModelInfoByIds(ids);
}
@@ -88,6 +96,7 @@ public class PileModelInfoServiceImpl implements IPileModelInfoService {
*/
@Override
public int deletePileModelInfoById(Long id) {
cleanCache(new Long[]{id});
return pileModelInfoMapper.deletePileModelInfoById(id);
}
@@ -110,4 +119,25 @@ public class PileModelInfoServiceImpl implements IPileModelInfoService {
}
return null;
}
@Override
public PileModelInfoVO getPileModelInfoByModelId(Long modelId) {
String redisKey = CacheConstants.GET_PILE_MODEL_INFO_BY_MODEL_ID + modelId;
PileModelInfoVO modelInfoVO = redisCache.getCacheObject(redisKey);
if (Objects.isNull(modelInfoVO)) {
modelInfoVO = pileModelInfoMapper.getPileModelInfoByModelId(modelId);
if (Objects.nonNull(modelInfoVO)) {
redisCache.setCacheObject(redisKey, modelInfoVO, CacheConstants.cache_expire_time_1d);
}
}
return modelInfoVO;
}
private void cleanCache(Long[] modelIds) {
List<String> redisKeyList = Lists.newArrayList();
for (Long modelId : modelIds) {
redisKeyList.add(CacheConstants.GET_PILE_MODEL_INFO_BY_MODEL_ID + modelId);
}
redisCache.deleteObject(redisKeyList);
}
}

View File

@@ -143,5 +143,25 @@
</foreach>
</select>
<select id="getPileModelInfoByModelId" resultType="com.jsowell.pile.vo.web.PileModelInfoVO">
SELECT
t2.id as modelId,
t2.model_name as modelName,
t2.rated_power as ratedPower,
t2.rated_current as ratedCurrent,
t2.rated_voltage as ratedVoltage,
t2.speed_type as speedType,
t2.charger_pile_type as chargerPileType,
t2.connector_num as connectorNum,
t2.interface_standard as interfaceStandard,
t2.create_by as createBy,
t2.create_time as createTime,
t2.update_by as updateBy,
t2.update_time as updateTime
FROM
pile_model_info t2
WHERE
t2.del_flag = '0'
and t2.id = #{modelId,jdbcType=BIGINT}
</select>
</mapper>

View File

@@ -293,10 +293,11 @@ public class AMapServiceImpl implements AMapService {
info.setEquipmentID(pileBasicInfo.getSn());
info.setManufacturerName("举视");
// 查询型号
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileBasicInfo.getSn());
// PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileBasicInfo.getSn());
PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByModelId(pileBasicInfo.getModelId());
info.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType()));
info.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP));
info.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, RoundingMode.HALF_UP));
List<AMapConnectorInfo> aMapConnectorInfos = getConnectorListBySN(pileBasicInfo.getSn());