mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 06:20:07 +08:00
update 新增桩时判断编号
This commit is contained in:
@@ -16,7 +16,7 @@ import com.jsowell.common.exception.BusinessException;
|
|||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
import com.jsowell.common.util.SecurityUtils;
|
import com.jsowell.common.util.SecurityUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.common.util.id.SnUtils;
|
import com.jsowell.pile.util.SnUtils;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.domain.MemberBasicInfo;
|
import com.jsowell.pile.domain.MemberBasicInfo;
|
||||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import com.jsowell.common.util.*;
|
|||||||
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
|
||||||
import com.jsowell.common.util.http.HttpUtils;
|
import com.jsowell.common.util.http.HttpUtils;
|
||||||
import com.jsowell.common.util.id.IdUtils;
|
import com.jsowell.common.util.id.IdUtils;
|
||||||
import com.jsowell.common.util.id.SnUtils;
|
import com.jsowell.pile.util.SnUtils;
|
||||||
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
||||||
import com.jsowell.common.util.ip.AddressUtils;
|
import com.jsowell.common.util.ip.AddressUtils;
|
||||||
import com.jsowell.netty.handler.HeartbeatRequestHandler;
|
import com.jsowell.netty.handler.HeartbeatRequestHandler;
|
||||||
|
|||||||
@@ -157,4 +157,10 @@ public interface PileBasicInfoMapper {
|
|||||||
* 批量修改充电桩运营商
|
* 批量修改充电桩运营商
|
||||||
*/
|
*/
|
||||||
void updatePileMerchantBatch(@Param("pileIdList") List<Long> pileIdList, @Param("newMerchantId") String newMerchantId);
|
void updatePileMerchantBatch(@Param("pileIdList") List<Long> pileIdList, @Param("newMerchantId") String newMerchantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新一条桩的数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PileBasicInfo getMaxNumPileInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,4 +177,9 @@ public interface IPileBasicInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<GroundLockInfoVO> getGroundLockInfo(String stationId);
|
List<GroundLockInfoVO> getGroundLockInfo(String stationId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新建一条桩的信息
|
||||||
|
*/
|
||||||
|
PileBasicInfo getMaxNumPileInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -788,4 +788,13 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService {
|
|||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取最新一条桩的数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PileBasicInfo getMaxNumPileInfo() {
|
||||||
|
return pileBasicInfoMapper.getMaxNumPileInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.jsowell.common.util.id;
|
package com.jsowell.pile.util;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
import com.jsowell.common.constant.CacheConstants;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
|
import com.jsowell.common.util.StringUtils;
|
||||||
|
import com.jsowell.pile.domain.PileBasicInfo;
|
||||||
|
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -20,7 +23,10 @@ public class SnUtils {
|
|||||||
private static Logger logger = LoggerFactory.getLogger(SnUtils.class);
|
private static Logger logger = LoggerFactory.getLogger(SnUtils.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPileBasicInfoService pileBasicInfoService;
|
||||||
|
|
||||||
private String prefix = "88";
|
private String prefix = "88";
|
||||||
|
|
||||||
@@ -35,6 +41,17 @@ public class SnUtils {
|
|||||||
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
||||||
String increResult = null;
|
String increResult = null;
|
||||||
try {
|
try {
|
||||||
|
String pileNum = redisCache.getCacheObject(key);
|
||||||
|
if (StringUtils.isBlank(pileNum)) {
|
||||||
|
// 缓存中没有,从数据库中取
|
||||||
|
PileBasicInfo pileInfo = pileBasicInfoService.getMaxNumPileInfo();
|
||||||
|
String pileSn = pileInfo.getSn();
|
||||||
|
// 将前四位截取,并将后面转为long
|
||||||
|
long pileSnNum = Long.parseLong(StringUtils.substring(pileSn, 4, pileSn.length()));
|
||||||
|
// 再将该值存入数据库
|
||||||
|
redisCache.setCacheObject(key, pileSnNum);
|
||||||
|
|
||||||
|
}
|
||||||
Long increNum = redisCache.increment(key, 1);
|
Long increNum = redisCache.increment(key, 1);
|
||||||
// 年份
|
// 年份
|
||||||
int year = LocalDate.now().getYear() - 2000;
|
int year = LocalDate.now().getYear() - 2000;
|
||||||
@@ -46,7 +63,13 @@ public class SnUtils {
|
|||||||
return increResult;
|
return increResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String pileSn = "88230000002060";
|
||||||
|
String substring = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||||
|
long l = Long.parseLong(substring);
|
||||||
|
System.out.println(substring);
|
||||||
|
System.out.println(l);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成sn号
|
* 生成sn号
|
||||||
@@ -399,4 +399,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getMaxNumPileInfo" resultMap="PileBasicInfoResult">
|
||||||
|
select
|
||||||
|
max(id),
|
||||||
|
sn
|
||||||
|
from
|
||||||
|
pile_basic_info
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.jsowell.thirdparty.amap.util;
|
package com.jsowell.thirdparty.amap.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.jsowell.common.util.id.SnUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|||||||
Reference in New Issue
Block a user