mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-03 05:28:03 +08:00
update 电单车
This commit is contained in:
@@ -8,6 +8,7 @@ import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.SoftwareProtocolEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
@@ -107,8 +108,17 @@ public class PileService {
|
||||
}
|
||||
|
||||
public int batchCreatePile(BatchCreatePileDTO dto) {
|
||||
String softwareProtocol = dto.getSoftwareProtocol();
|
||||
if (StringUtils.isBlank(softwareProtocol)) {
|
||||
throw new BusinessException(ReturnCodeEnum.valueOf("软件协议不能为空"));
|
||||
}
|
||||
// 批量生成sn号
|
||||
List<String> snList = snUtils.generateSN(dto.getNum());
|
||||
List<String> snList = null;
|
||||
if (StringUtils.equals(SoftwareProtocolEnum.YOU_DIAN.getValue(), softwareProtocol)) {
|
||||
snList = snUtils.generateSN(dto.getNum());
|
||||
} else {
|
||||
snList = snUtils.generateSN(dto.getNum());
|
||||
}
|
||||
|
||||
//
|
||||
List<PileBasicInfo> basicInfoList = Lists.newArrayList();
|
||||
@@ -125,7 +135,7 @@ public class PileService {
|
||||
String secretKey = RandomStringUtils.randomAlphanumeric(8).toUpperCase(Locale.ROOT);
|
||||
basicInfo.setSecretKey(secretKey);
|
||||
}
|
||||
basicInfo.setSoftwareProtocol(dto.getSoftwareProtocol()); // 软件协议
|
||||
basicInfo.setSoftwareProtocol(softwareProtocol); // 软件协议
|
||||
basicInfo.setMerchantId(Long.valueOf(dto.getMerchantId())); // 运营商id
|
||||
basicInfo.setStationId(Long.valueOf(dto.getStationId())); // 站点id
|
||||
basicInfo.setModelId(Long.valueOf(dto.getModelId())); // 型号id
|
||||
|
||||
@@ -279,6 +279,11 @@ public class CacheConstants {
|
||||
*/
|
||||
public static final String PILE_SN_GENERATE_KEY = "pile_sn_generate_";
|
||||
|
||||
/**
|
||||
* 充电桩sn生成 key
|
||||
*/
|
||||
public static final String PILE_SN_EBIKE_GENERATE_KEY = "pile_sn_ebike_generate_";
|
||||
|
||||
/**
|
||||
* 充电桩详情key
|
||||
*/
|
||||
|
||||
@@ -6,6 +6,7 @@ package com.jsowell.common.enums;
|
||||
public enum SoftwareProtocolEnum {
|
||||
YUN_KUAI_CHONG("1", "云快充"),
|
||||
YONG_LIAN("2", "永联"),
|
||||
YOU_DIAN("3", "友电"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class BatchCreatePileDTO {
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 软件协议(1-云快充;2-永联)
|
||||
* 软件协议(1-云快充;2-永联; 3-友电)
|
||||
*/
|
||||
private String softwareProtocol;
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public class ReplaceMerchantStationDTO {
|
||||
// 经营类型(1-运营桩;2-个人桩)
|
||||
private String chargerPileType;
|
||||
|
||||
// 软件协议 1-云快充 2-永联 3-友电
|
||||
private String softwareProtocol;
|
||||
|
||||
private String updateBy;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Component
|
||||
public class PileSnGenerateService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(PileSnGenerateService.class);
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
@@ -27,16 +27,15 @@ public class PileSnGenerateService {
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
private String prefix = "88";
|
||||
private final String prefix = "88";
|
||||
|
||||
/**
|
||||
* 获取递增的序列号
|
||||
* 获取递增的序列号 汽车桩
|
||||
* 充电桩编号定义为14位: 固定位88 + 年份23 + 10位自增数字不足补0
|
||||
* @param prefix 生成序列号的前缀
|
||||
* @return
|
||||
*/
|
||||
public String getPileSn(String prefix) {
|
||||
//序列号前缀加特定标识,如系统模块名之类的 防止重复
|
||||
public synchronized String getEVPileSn(String prefix) {
|
||||
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
||||
String increResult = null;
|
||||
try {
|
||||
@@ -64,15 +63,6 @@ public class PileSnGenerateService {
|
||||
return increResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成sn号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<String> generateSN() {
|
||||
return generateSN(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量生成sn号
|
||||
*
|
||||
@@ -85,9 +75,54 @@ public class PileSnGenerateService {
|
||||
return resultList;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
resultList.add(getPileSn(prefix));
|
||||
resultList.add(getEVPileSn(prefix));
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public List<String> generateEBikeSN(int size) {
|
||||
List<String> resultList = Lists.newArrayList();
|
||||
if (size <= 0) {
|
||||
return resultList;
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
resultList.add(getEBikePileSn(prefix));
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取递增的序列号 汽车桩
|
||||
* 充电桩编号定义为14位: 固定位88 + 年份23 + 10位自增数字不足补0
|
||||
* @param prefix 生成序列号的前缀
|
||||
* @return
|
||||
*/
|
||||
public synchronized String getEBikePileSn(String prefix) {
|
||||
String key = CacheConstants.PILE_SN_GENERATE_KEY + prefix;
|
||||
String increResult = null;
|
||||
try {
|
||||
// 取缓存
|
||||
Integer pileNum = redisCache.getCacheObject(key);
|
||||
if (pileNum == null) {
|
||||
// 缓存中没有,从数据库中取
|
||||
PileBasicInfo pileInfo = pileBasicInfoService.getMaxNumPileInfo();
|
||||
String pileSn = pileInfo.getSn();
|
||||
// 将前四位截取,并将后面转为long
|
||||
Long pileSnNum = Long.parseLong(StringUtils.substring(pileSn, 4, pileSn.length()));
|
||||
// String pileSnNum = StringUtils.substring(pileSn, 4, pileSn.length());
|
||||
// 再将该值存入数据库
|
||||
redisCache.setCacheObject(key, pileSnNum.intValue());
|
||||
|
||||
}
|
||||
Long increNum = redisCache.increment(key, 1);
|
||||
// 年份
|
||||
int year = LocalDate.now().getYear() - 2000;
|
||||
//不足补位
|
||||
increResult = prefix + year + String.format("%1$010d", increNum);
|
||||
} catch (Exception e) {
|
||||
logger.error("获取序列号失败", e);
|
||||
}
|
||||
return increResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,15 +107,25 @@
|
||||
<el-input v-model="updateData.connectorNum" placeholder="请输入枪口数量" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="桩类型" prop="modelId">
|
||||
<el-select v-model="updateData.chargerPileType" placeholder="请选择桩类型">
|
||||
<el-option label="运营桩" value="1" />
|
||||
<el-option label="个人桩" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="桩类型" prop="modelId">
|
||||
<el-select v-model="updateData.chargerPileType" placeholder="请选择桩类型">
|
||||
<el-option label="运营桩" value="1" />
|
||||
<el-option label="个人桩" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="软件协议" prop="softwareProtocol">
|
||||
<el-select v-model="updateData.softwareProtocol" placeholder="软件协议" clearable>
|
||||
<el-option v-for="dict in dict.type.software_protocol" :key="dict.value"
|
||||
:label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="batchUpdate">确 定</el-button>
|
||||
@@ -264,6 +274,7 @@ export default {
|
||||
pileSnList: [],
|
||||
connectorNum: null,
|
||||
modelId: null,
|
||||
softwareProtocol: null,
|
||||
chargerPileType: null
|
||||
},
|
||||
// 型号列表
|
||||
|
||||
Reference in New Issue
Block a user