oms发单
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.mhd.oms.util;
|
||||
|
||||
import com.mhd.common.core.domain.po.SysMultistageDictPo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MultistageDictUtils {
|
||||
|
||||
public SysMultistageDictPo getMultistageDictByCode(String type, String code) {
|
||||
// 实现多级字典获取逻辑
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.mhd.oms.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 运单号生成规则
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
public class OrderSequence {
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 生成唯一运单号
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
public static String getOrderCode(){
|
||||
return new StringBuffer()
|
||||
.append(getSecondPart())
|
||||
.append(getThreePart())
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 生成唯一运单号
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
public static String getOrderCodeByDate(Date date){
|
||||
return new StringBuffer()
|
||||
.append(getSecondPartByDate(date))
|
||||
.append(getThreePart())
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 生成唯一运单号(带前缀)
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
public static String getOrderCode(String prefix){
|
||||
return new StringBuffer().append(getFirstPart(prefix))
|
||||
.append(getSecondPart())
|
||||
.append(getThreePart())
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 带前缀
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
private static String getFirstPart(String prefix) {
|
||||
return prefix.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 生成时间戳
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
private static String getSecondPart() {
|
||||
String temp_current_time = DateUtil.format(new Date(), datePattern());
|
||||
return temp_current_time.substring(2, temp_current_time.length());
|
||||
}
|
||||
|
||||
private static String getSecondPartByDate(Date date) {
|
||||
if (date == null) {
|
||||
date = new Date();
|
||||
}
|
||||
String temp_current_time = DateUtil.format(date, datePattern());
|
||||
return temp_current_time.substring(2, temp_current_time.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author Alex
|
||||
* @Description 生成4为随机数字
|
||||
* @Date 2020/2/2 11:06
|
||||
* @Param
|
||||
* @return
|
||||
*/
|
||||
private static String getThreePart() {
|
||||
return RandomUtil.randomNumbers(4);
|
||||
}
|
||||
|
||||
private static String datePattern() {
|
||||
return "yyyyMMddHHmmss";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
for( int i=0; i<10; i++ ){
|
||||
System.out.println(OrderSequence.getOrderCode());
|
||||
}
|
||||
}
|
||||
/***
|
||||
* 生成单号
|
||||
* @param letter 需要传入的字母开头和时间
|
||||
* @return
|
||||
*/
|
||||
public static String createOddNum(Date createTime,String letter, Integer length){
|
||||
if( null == createTime ){
|
||||
createTime = new Date();
|
||||
}
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String createTimestr = sf.format(createTime);
|
||||
String timeCode = createTimestr.substring(2,4)+
|
||||
createTimestr.substring(5,7);
|
||||
|
||||
String randomCode = RandomUtil.randomNumbers(length);
|
||||
String oddNumber = letter + timeCode+randomCode;
|
||||
return oddNumber;
|
||||
}
|
||||
/***
|
||||
* 生成单号
|
||||
* @param letter 需要传入的字母开头
|
||||
* @return
|
||||
*/
|
||||
public static String createOddNum(String letter, Integer length){
|
||||
Date createTime = new Date();
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String createTimestr = sf.format(createTime);
|
||||
String timeCode = createTimestr.substring(2,4)+
|
||||
createTimestr.substring(5,7) + createTimestr.substring(8,10);
|
||||
|
||||
String randomCode = RandomUtil.randomNumbers(length);
|
||||
return letter + timeCode+randomCode + "/00-01-01";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user