之前用年月日+四位隨機數---》當導入數量巨大時,會出現,主鍵沖突,
建議:換成,HHmmssSSS 時分秒毫秒形式
提示:更嚴謹的,還有訂單號生成,會出現高並發,牽扯到多線程問題。往上有例子,可以查看
代碼貼出,直接掉用
public static Integer nextItemNo(){
Date date = new Date();
sdformat = new SimpleDateFormat("HHmmssSSS");
String id = sdformat.format(date);
Integer integer = Integer.parseInt(id);
return integer;
}