Commit e87bddc0 authored by hkl's avatar hkl

feat:1.单元编号划分

parent 961cb187
......@@ -41,20 +41,20 @@ public class UnitCodeUtil {
/**
* 钢轨单元编码:线别码+GG+流水号(5位流水号)
* 实例:SXGG00001
* SQX - 竖曲线
* 000001-流水号
* 实例:SXXGG00001
* GG - 钢轨编码
* 0001-流水号
*
* @param lineId 线别ID
*/
public static String railUnitCodeUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toLowerCase();
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
String unitCode = lineAliasPinyin + "SQX";
String unitCode = lineAliasPinyin + "GG";
RailManagement record = railManagementService.lambdaQuery()
.likeRight(RailManagement::getUnitCode, unitCode)
.orderByDesc(RailManagement::getUnitCode)
......@@ -66,7 +66,7 @@ public class UnitCodeUtil {
Integer serialNum = 1;
if (null != record && record.getUnitCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getUnitCode().substring(6)) + 1;
serialNum = Integer.parseInt(record.getUnitCode().substring(record.getUnitCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
......@@ -74,17 +74,15 @@ public class UnitCodeUtil {
}
/**
* 曲线代码生成: 01SQX0001
* 01 - 上行;02-表示下行
* SQX - 竖曲线
* 000001-流水号
* 0001-流水号
*
* @param lineId 线别ID
*/
public static String verticalCurveUnitCodeUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toLowerCase();
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
......@@ -100,7 +98,7 @@ public class UnitCodeUtil {
Integer serialNum = 1;
if (null != record && record.getUnitCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getUnitCode().substring(6)) + 1;
serialNum = Integer.parseInt(record.getUnitCode().substring(record.getUnitCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
......@@ -109,7 +107,6 @@ public class UnitCodeUtil {
/**
* 曲线代码生成: L201QX0001
* 01 - 上行;02-表示下行
* QX - 曲线
* 000001-流水号
*
......@@ -118,7 +115,7 @@ public class UnitCodeUtil {
public static String curveUnitCodeUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toLowerCase();
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
......@@ -133,7 +130,7 @@ public class UnitCodeUtil {
Integer serialNum = 1;
if (null != record && record.getUnitCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getUnitCode().substring(6)) + 1;
serialNum = Integer.parseInt(record.getUnitCode().substring(record.getUnitCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
......@@ -151,7 +148,7 @@ public class UnitCodeUtil {
public static String switchUnitCodeUtil(String lineId) {
// 获取线别拼音
LineAlias lineAlias = lineAliasService.getById(lineId);
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toLowerCase();
String lineAliasPinyin = PinyinUtil.getFirstLetter(lineAlias.getLineAliasName(), "").toUpperCase();
// 查询最大的编号
......@@ -166,7 +163,7 @@ public class UnitCodeUtil {
Integer serialNum = 1;
if (null != record && record.getUnitCode() != null) {
// 流水号+1
serialNum = Integer.parseInt(record.getUnitCode().substring(6)) + 1;
serialNum = Integer.parseInt(record.getUnitCode().substring(record.getUnitCode().length() - 4)) + 1;
}
String serialNumStr = supplementZero(4, serialNum);
......@@ -183,5 +180,4 @@ public class UnitCodeUtil {
public static String supplementZero(int numLength, int num) {
return String.format("%0" + numLength + "d", num);
}
}
\ No newline at end of file
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