Package util;Import Java. Util. Date;Import Java. Util. Random;Import Java. Util. UUID;/** * Generate Order ID * */public class Orderinfoidutil {public static String getorderinfoid () {random rd=new random ();int M1=rd. Nextint( -);//Generate a random number of 0-23int M2=rd. Nextint( -);String s="ABCDEGHIJKLMNOPQRSTUVWXYZ";Char Rdstring1=s. CharAt(M1)//Get random characters based on random indexChar Rdstring2=s. CharAt(m2);string ss = String. ValueOf(9999-(System. Currenttimemillis()/1000000)%10000);while (SS. Length() <4) {SS ="0"+ss;} string u0 = string. ValueOf(SS. CharAt(0));String u1 = string. ValueOf(SS. CharAt(1));String U2 = String. ValueOf(SS. CharAt(2));String U3 = string. ValueOf(SS. CharAt(3));int iu1 = Integer. parseint(U1);Char Rdstringiu1=s. CharAt(IU1);int IU2 = Integer. parseint(U2);Char Rdstringiu2=s. CharAt(iu2+ One);StringBuffer s0 = new StringBuffer ();S0. Append(String. ValueOf(RDSTRINGIU1));S0. Append(String. ValueOf(RDSTRINGIU2));S0. Append(u0);S0. Append(U3);S0. Append(String. ValueOf(RDSTRING1));S0. Append(String. ValueOf(RDSTRING2));S0. Append(String. ValueOf(System. Currenttimemillis()%1000000));System. out. println(S0);return S0. toString();} public static string Getorderinfid () {String sa ="So";Date d = new Date ();String u = dateutil. getcurdatestring(d);u = u. Replace("-","");SA + = u;Redisutils rs = redisutils. getinstance();Rs. setString("OrderInfo", -);if (RS. getString("Orderinfoday") ==null) {RS. setString("Orderinfoday", u);Rs. setString("OrderInfo",1);}else{if (!rs. getString("Orderinfoday"). Equals(u)) {RS. setString("Orderinfoday", u);Rs. setString("OrderInfo",1);}else{RS. incrstring("OrderInfo");}} String UU = rs. getString("OrderInfo");while (UU. Length() <3) {UU ="0"+uu;} return Sa+uu; } public static void Main (string[] args) {String i = Getorderinfid ();System. out. println(i);String Uuid=uuid. Randomuuid(). toString();System. out. println(UUID);}}
Generate orders based on time