|
发表于 2017-8-31 14:42:35
|
显示全部楼层
这个底层封装的不提供源码,就是java标准去计算的,不是js中计算的,下面贴的主要的实现逻辑,需要自己进步修改实现newSequence就是最后算出来的值
就是定义两个变量一个最大值和一个序号格式的
private static final String SEQUENCE_CODE_FORMAT = "%03d";
private static final int SEQUENCE_CODE_MAX = 999;
然后java定义方法去通过格式和最大值进行计算
private static String formatSequenceString(int sequence) {
return String.format(SEQUENCE_CODE_FORMAT, sequence);
}
private static void checkSequenceMaxSize(String parentID, int inc) {
String maxSequence = getMaxSequence(parentID, null, false);
if (Utils.isEmptyString(maxSequence))
return;
int maxSequenceNumber = getSequenceNumber(maxSequence);
if ((maxSequenceNumber + inc) > SEQUENCE_CODE_MAX)
resequenceAll(parentID);
}
private static String getNewSequence(String parentID, String parentSequence, String orgKindID) {
String maxSequence = getMaxSequence(parentID, orgKindID, true);
if (Utils.isEmptyString(maxSequence))
maxSequence = OpmUtils.createFileFullName(parentSequence, formatSequenceString(1), "");
else
maxSequence = incSequence(maxSequence);
return maxSequence;
}
String newSequence = getNewSequence(parentID, parentSequence, orgKindID);
如果是自己输入的要拼接可以参考http://docs.wex5.com/bex5-ui-question-list-10160/中全路径的维护
|
|