Summary of the invention
Based on this, be necessary for above-mentioned technical matters, the repetition rate that a kind of document encodes the method and apparatus generated, the document coding that reduction generates is provided.
The method that document coding generates, described method comprises:
Obtain document types, generate document prefix according to described document types;
Obtain the document coding rise time, generate serial number according to the described time;
Obtain the document encoded number that present terminal has generated, according to described document encoded number genesis sequence number;
Document coding is generated according to described document prefix, serial number and serial number.
Wherein in an embodiment, the described acquisition document coding rise time, the step generating serial number according to the described time comprises:
Obtain the year place value of described time, the moon place value, day place value, bit value, tantile and second place value;
By described year place value, the moon place value, day place value, bit value, tantile and second place value carry out permutation and combination and generate serial number.
Wherein in an embodiment, the described acquisition document coding rise time, the step generating serial number according to the described time is:
Obtain the described time year place value and the moon place value, by described year place value and the moon place value carry out permutation and combination and generate serial number;
Described method also comprises:
Obtain place value second of described time, search preset characters string according to place value described second and obtain document suffix;
Document coding is generated according to described document prefix, serial number, serial number and document suffix.
Wherein in an embodiment, described preset characters string is the character string of 60, and character on every is different, place value second of described acquisition described time, searches the step that preset characters string obtains document suffix comprise according to place value described second:
According to the position that sequential search is from front to back corresponding with place value described second;
Take out character on described position as document suffix.
Wherein in an embodiment, described method also comprises:
Obtain present terminal hardware identifier, described hardware identifier is used for unique identification present terminal;
Document coding is generated according to described document prefix, serial number, serial number and hardware identifier.
The device that document coding generates, described device comprises:
Prefix generation module, for obtaining document types, generates document prefix according to described document types;
Serial number generation module, for obtaining the document coding rise time, generates serial number according to the described time;
Serial number generation module, for obtaining the document encoded number that present terminal has generated, according to described document encoded number genesis sequence number;
Document coding generation module, for generating document coding according to described document prefix, serial number and serial number.
Wherein in an embodiment, described serial number generation module comprises:
Acquiring unit, for obtain the described time year place value, the moon place value, day place value, bit value, tantile and second place value;
Generation unit, for by described year place value, the moon place value, day place value, bit value, tantile and second place value carry out permutation and combination and generate serial number.
Wherein in an embodiment, described serial number generation module also for obtain the described time year place value and the moon place value, by described year place value and the moon place value carry out permutation and combination and generate serial number, described device also comprises:
Suffix generation module, for obtaining place value second of described time, searching preset characters string according to place value described second and obtaining document suffix;
Described document coding generation module, also for generating document coding according to described document prefix, serial number, serial number and document suffix.
Wherein in an embodiment, described preset characters string is the character string of 60, character on every is different, and described suffix generation module, also for according to the position corresponding with place value described second of sequential search from front to back, takes out character on described position as document suffix.
Wherein in an embodiment, described device also comprises:
Identifier acquisition module, for obtaining present terminal hardware identifier, described hardware identifier is used for unique identification present terminal;
Described document coding generation module, also for generating document coding according to described document prefix, serial number, serial number and hardware identifier.
The method and apparatus that above-mentioned document coding generates, by obtaining document types, document prefix is generated according to document types, obtain the document coding rise time, serial number is generated according to the time, obtain the document encoded number that present terminal has generated, according to described document encoded number genesis sequence number, generate document coding according to document prefix, serial number and serial number.The document coding consideration document types generated, document coding rise time, the document encoded number that generates, due to the difference of each terminal document types, with the difference of document coding rise time, and the document encoded number that each terminal has generated is also different, the document numbering generated when considering factor is in many ways often different, greatly reduces the repetition rate of the document coding of generation.
Embodiment
In one embodiment, as shown in Figure 1, provide the method that a kind of document coding generates, comprising:
Step S110, obtains document types, generates document prefix according to document types.
Concrete, document types refers to the classification belonging to document, as sales slip, receiving tally, charge slip, payment order etc.Generate different document prefixes according to document types, the particular content of generation can be self-defined as required, as sales slip may be defined as XSD etc.
Step S120, obtains the document coding rise time, generates serial number according to the time.
Concrete, can generating document coding when newly-built document, also can generate document coding when preserving document, document rise time of encoding can obtain from the terminal system time, and degree of accuracy can to second, also can obtain more precise time as being accurate to millisecond.Directly the time can be carried out sequence according to degree of accuracy size according to the time and generate serial number, also can self-defined clooating sequence, or generate serial number through computing.The document coding rise time as obtained is " 15: 30: 22 on the 3rd April in 2011 ", can directly using 20110403153022 as serial number, also can be searched character corresponding to data by the mode of tabling look-up, the character found out be carried out arrangement and generate serial number.
Step S130, obtains the document encoded number that present terminal has generated, according to document encoded number genesis sequence number.
Concrete, present terminal may generate multiple document and encode before generation current document coding, and often generating a document coding can add up, and is stored by the document of the generation encoded number of statistics.Use this document encoded number genesis sequence number, as present terminal document coding did not also generate, the document encoded number generated is 0, then can using 0 directly as serial number.Also can specify the scope of serial number, as from 0001-9999, if document encoded number exceedes this scope, then restart from 0001.
Step S140, generates document coding according to document prefix, serial number and serial number.
Concrete, document prefix, serial number and serial number are carried out assembled arrangement according to custom order and generates document coding.
In the present embodiment, by obtaining document types, document prefix is generated according to document types, obtain the document coding rise time, serial number is generated according to the time, obtain the document encoded number that present terminal has generated, according to described document encoded number genesis sequence number, generate document coding according to document prefix, serial number and serial number.The document coding consideration document types generated, document coding rise time, the document encoded number that generates, due to the difference of each terminal document types, with the difference of document coding rise time, and the document encoded number that each terminal has generated is also different, the document numbering generated when considering factor is in many ways often different, greatly reduces the repetition rate of the document coding of generation.
In one embodiment, as shown in Figure 2, step S120 comprises:
Step S121, the year place value of acquisition time, the moon place value, day place value, bit value, tantile and second place value.
Step S122, by year place value, the moon place value, day place value, bit value, tantile and second place value carry out permutation and combination generate serial number.
Concrete, the time is accurate to position second, the value in each degree of accuracy can be carried out permutation and combination according to custom order and generate serial number.Because the time is accurate to second, only otherwise same second generate document coding would not document coding identical, even and if just generate document coding in same second, go back documentary prefix and serial number coordinates, be difficult to generate identical document odd numbers.
In one embodiment, as shown in Figure 3, provide a kind of document coding generate method, step S120 is: acquisition time year place value and the moon place value, by year place value and the moon place value carry out permutation and combination generate serial number, described method comprises:
Step S210, obtains document types, generates document prefix according to document types.
Step S220, obtain document coding the rise time, acquisition time year place value and the moon place value, by year place value and the moon place value carry out permutation and combination generate serial number.
Concrete, only take out year place value and the moon place value carry out permutation and combination and generate serial number, decrease the character length that serial number takies, save storage space.
Step S230, obtains the document encoded number that present terminal has generated, according to document encoded number genesis sequence number.
Step S240, place value second of acquisition time, searches preset characters string according to place value second and obtains document suffix.
Concrete, preset characters string can be self-defined as required, as being defined as the different number of seconds character one to one from the time, as English alphabet, numeral, punctuation mark etc.Set up the corresponding relation of each second place value and preset characters string in advance, according to corresponding relation, the number of seconds value taking two storage spaces is converted to the character taking a storage space by the mode of tabling look-up, saves storage space further.
Step S250, generates document coding according to document prefix, serial number, serial number and document suffix.
Concrete, according to self-defining order, document prefix, serial number, serial number and document suffix are carried out permutation and combination and generate document coding.
In one embodiment, preset characters string is the character string of 60, and the character on every is different, and as shown in Figure 4, step S240 comprises:
Step S241, according to the position that sequential search is from front to back corresponding with place value second.
Step S242, takes out character on described position as document suffix.
Concrete, preset characters string is the character string of 60, character on every is different, if preset characters string is " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz9876 5432 ", if place value second is 5, then from A several 5, find E, then using E as document suffix.Simple and convenient by the mode of sequential search, improve the speed generating document coding.
In one embodiment, as shown in Figure 5, described method also comprises:
Step S310, obtains present terminal hardware identifier, and hardware identifier is used for unique identification present terminal.
Concrete, hardware identifier is the mark that terminal is built in terminal when dispatching from the factory, for unique identification present terminal.This mark is stored in terminal, and read this mark when generating document coding, each terminal producer is different, and terminal models is different, and this hardware identifier of different terminals is also different.
Step S320, generates document coding according to document prefix, serial number, serial number and hardware identifier.
Concrete, the probability repeated due to hardware identifier is very little, adopts hardware identifier to generate document coding in conjunction with document prefix, serial number, serial number, further reduces the probability that document coding repeats.
In one embodiment, as shown in Figure 6, provide the device that a kind of document coding generates, comprising:
Prefix generation module 410, for obtaining document types, generates document prefix according to document types.
Serial number generation module 420, for obtaining the document coding rise time, generates serial number according to the time.
Serial number generation module 430, for obtaining the document encoded number that present terminal has generated, according to document encoded number genesis sequence number.
Document coding generation module 440, for generating document coding according to document prefix, serial number and serial number.
In one embodiment, as shown in Figure 7, serial number generation module 420 comprises:
Acquiring unit 421, for acquisition time year place value, the moon place value, day place value, bit value, tantile and second place value.
Generation unit 422, for by year place value, the moon place value, day place value, bit value, tantile and second place value carry out permutation and combination generate serial number.
In one embodiment, as shown in Figure 8, serial number generation module 420 also for acquisition time year place value and the moon place value, by described year place value and the moon place value carry out permutation and combination and generate serial number, described device also comprises:
Suffix generation module 450, for place value second of acquisition time, searches preset characters string according to place value second and obtains document suffix.
Document coding generation module 440, also for generating document coding according to document prefix, serial number, serial number and document suffix.
In one embodiment, preset characters string is the character string of 60, and character on every is different, and suffix generation module 450 is also for according to the position corresponding with place value second of sequential search from front to back, and the character on extracting position is as document suffix.
In one embodiment, as shown in Figure 9, described device also comprises:
Identifier acquisition module 460, for obtaining present terminal hardware identifier, hardware identifier is used for unique identification present terminal;
Document coding generation module 440, also for generating document coding according to document prefix, serial number, serial number and hardware identifier.
Each technical characteristic of the above embodiment can combine arbitrarily, for making description succinct, the all possible combination of each technical characteristic in above-described embodiment is not all described, but, as long as the combination of these technical characteristics does not exist contradiction, be all considered to be the scope that this instructions is recorded.
The above embodiment only have expressed several embodiment of the present invention, and it describes comparatively concrete and detailed, but can not therefore be construed as limiting the scope of the patent.It should be pointed out that for the person of ordinary skill of the art, without departing from the inventive concept of the premise, can also make some distortion and improvement, these all belong to protection scope of the present invention.Therefore, the protection domain of patent of the present invention should be as the criterion with claims.