| | |
| | | @Resource(name = "sysSequenceDao") |
| | | SysSequenceDao sysSequenceDao; |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | private synchronized int getNextVal(String seqId) { |
| | | public synchronized int getNextVal(String seqName) { |
| | | int result = -1; |
| | | try { |
| | | if (StringUtils.isNotBlank(seqId)) { |
| | | SysSequence sequence = this.sysSequenceDao.getSysSequence(seqId); |
| | | if (seqName!=null) { |
| | | SysSequence sequence = this.sysSequenceDao.getSysSequenceByName(seqName); |
| | | int currentVal =0; |
| | | if (sequence == null) { |
| | | sequence = new SysSequence(); |
| | | sequence.setId(seqId); |
| | | sequence.setName(seqId); |
| | | sequence.setName(seqName); |
| | | sequence.setMinVal(0); |
| | | sequence.setMaxVal(99999); |
| | | sequence.setStep(1); |
| | | sequence.setCurrentVal(0); |
| | | currentVal = sequence.getStep(); |
| | | sequence.setCurrentVal(currentVal); |
| | | this.sysSequenceDao.insertSysSequence(sequence); |
| | | } |
| | | |
| | | int currentVal = sequence.getCurrentVal() + sequence.getStep(); |
| | | }else{ |
| | | currentVal = sequence.getCurrentVal() + sequence.getStep(); |
| | | if (currentVal > sequence.getMaxVal()) { |
| | | currentVal = sequence.getMinVal(); |
| | | } |
| | | |
| | | sequence.setCurrentVal(currentVal); |
| | | result = currentVal; |
| | | |
| | | this.sysSequenceDao.updateSysSequence(sequence); |
| | | } |
| | | result = currentVal; |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error(e.getMessage(), e); |
| | |
| | | return result.toString(); |
| | | } |
| | | |
| | | @Transactional(propagation = Propagation.REQUIRED) |
| | | public String getOrderCode() { |
| | | StringBuffer result = new StringBuffer(""); |
| | | result.append("OD"); |
| | |
| | | seqStr = String.format("%05d", seq); |
| | | } |
| | | } |
| | | |
| | | result.append(seqStr); |
| | | |
| | | return result.toString(); |
| | | } |
| | | } |