此方法为何会生成相同的单号?
public synchronized long getDailyNextVal(String seqName, boolean needNew)
throws BusinessException {
long ret = 1L;
int nowDay = Calendar.getInstance().get(Calendar.DATE);
try {
SequenceHome home = (SequenceHome)
ControlRepository.getInstance().getControlInstance(Names.SEQUENCE);
Sequence seq = (Sequence) home.findByPrimaryKey(seqName);
if (nowDay != seq.getDay()) {
this.updateSequence(seq, seq.getStartby() + seq.getStep(), nowDay);
return seq.getStartby();
}
ret = seq.getSequenceNo();
this.updateSequence(seq, seq.getSequenceNo() + seq.getStep(), nowDay);
} catch (BusinessException e) {
if (needNew) {
// createSequence(seqName, 1, 2, true);
createSequence(seqName, 1, 1, true, nowDay);
} else {
log.error("sequence with name " + seqName + " not found", e);
e.setDetailInfo("sequence with name " + seqName + " not found");
throw e;
}
}
return ret;
}