Commit b3d4bdbb authored by tianbo's avatar tianbo

refactor(ymt): 优化电梯代码生成和查询逻辑

- 修改 CategoryOtherInfoMapper.xml 中的排序逻辑,使用 CAST 将 CODE96333 转为无符号整数进行排序- 在 GenerateCodeServiceImpl 中增加对序列号前缀的处理,优化序列号生成逻辑 - 移除对电梯代码减少功能的使用 - 调整 JgVehicleInformationServiceImpl 中对设备列表的处理逻辑,不再限制必须选择相同充装介质的设备
parent d0e6fe5e
...@@ -236,9 +236,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -236,9 +236,9 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists"); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
if (SUBMIT_TYPE_FLOW.equals(submit)) { if (SUBMIT_TYPE_FLOW.equals(submit)) {
if (CollectionUtils.isEmpty(equipmentLists) || // 不限制一个车只能使用一个充装介质的气瓶
equipmentLists.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() != 1) { if (CollectionUtils.isEmpty(equipmentLists)) {
throw new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!"); throw new BadRequest("请选择设备信息!");
} }
// 检查设备是否已经在使用 // 检查设备是否已经在使用
// 个人主体的身份证(6600_620422199903010258) 特殊处理 只取_后的身份证号码 // 个人主体的身份证(6600_620422199903010258) 特殊处理 只取_后的身份证号码
...@@ -1878,10 +1878,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -1878,10 +1878,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
.convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() { .convertValue(map.get("equipmentLists"), new TypeReference<List<Map<String, Object>>>() {
}); });
// 设备列表判空 + 选择同一充装介质的设备 // 设备列表判空 + 选择同一充装介质的设备
// 20250801修改为不限制一个车只能使用一个充装介质的气瓶
Optional.ofNullable(equipmentLists) Optional.ofNullable(equipmentLists)
.filter(list -> !list.isEmpty()) .filter(list -> !list.isEmpty())
.filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1) // .filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1)
.orElseThrow(() -> new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!")); .orElseThrow(() -> new BadRequest("请选择设备信息!"));
// 确保车用气瓶使用信息中填写的【使用登记证编号】【车辆VIN】与列表所选择设备的一致 // 确保车用气瓶使用信息中填写的【使用登记证编号】【车辆VIN】与列表所选择设备的一致
Optional.of(equipmentLists) Optional.of(equipmentLists)
.filter(eqLists -> { .filter(eqLists -> {
...@@ -2230,10 +2231,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform ...@@ -2230,10 +2231,11 @@ public class JgVehicleInformationServiceImpl extends BaseService<JgVehicleInform
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class); ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())) + "", ReginParams.class);
JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class); JgVehicleInformationDto vehicleInfoDto = JSON.parseObject(JSON.toJSONString(map), JgVehicleInformationDto.class);
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists"); List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) map.get("equipmentLists");
// 20250801修改为不限制一个车只能使用一个充装介质的气瓶
Optional.ofNullable(equipmentLists) Optional.ofNullable(equipmentLists)
.filter(list -> !list.isEmpty()) .filter(list -> !list.isEmpty())
.filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1) // .filter(list -> list.stream().map(v -> (String) v.get("chargingMedium")).distinct().count() == 1)
.orElseThrow(() -> new BadRequest(CollectionUtils.isEmpty(equipmentLists) ? "请选择设备信息!" : "请选择相同充装介质设备!")); .orElseThrow(() -> new BadRequest("请选择设备信息!"));
CompanyBo company = reginParams.getCompany(); CompanyBo company = reginParams.getCompany();
vehicleInfoDto.setCreateDate(new Date()); vehicleInfoDto.setCreateDate(new Date());
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<if test="status != null and status != ''"> <if test="status != null and status != ''">
and status = #{status} and status = #{status}
</if> </if>
<if test="status != 2 ">ORDER BY CODE96333 DESC LIMIT 1 </if> <if test="status != 2 ">ORDER BY CAST(CODE96333 AS UNSIGNED) DESC LIMIT 1 </if>
<if test="status == 2 ">ORDER BY CODE96333 ASC LIMIT 1 </if> <if test="status == 2 ">ORDER BY CAST(CODE96333 AS UNSIGNED) ASC LIMIT 1 </if>
</select> </select>
<select id="selectElevatorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV"> <select id="selectElevatorCodeMaxValue" resultType="com.yeejoin.amos.boot.module.ymt.api.dto.KV">
......
...@@ -93,6 +93,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -93,6 +93,7 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
} }
@Override @Override
@Deprecated
public boolean reduceElevatorCode(String key) { public boolean reduceElevatorCode(String key) {
return reduceSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR); return reduceSequence(key, SEQUENCE_TYPE, LOCK_KEY_ELEVATOR);
} }
...@@ -294,13 +295,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -294,13 +295,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, initialCode); log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, initialCode);
return initialCode; return initialCode;
} }
// currentSequenceStr截取前两位作为prefix
Long currentSequence = Long.parseLong(currentSequenceStr); String prefix = currentSequenceStr.substring(0, 2);
// 截取剩余的数字作为顺序码
currentSequenceStr = currentSequenceStr.substring(2);
long currentSequence = Long.parseLong(currentSequenceStr);
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++; currentSequence++;
currentSequence = Long.parseLong(prefix + currentSequence);
// 生成顺序码 // 生成顺序码
String formattedSequence = String.format(sequenceType, currentSequence); String formattedSequence = String.format(sequenceType, currentSequence);
// 去除先导0字符
formattedSequence = formattedSequence.replaceFirst("^0+", "");
log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence); log.info("===================>更新《{}》顺序码:{}<===================", sequenceKey, formattedSequence);
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment