JeecgBoot 2.4.2 积木报表版本发布,基于SpringBoot的低代码平台

This commit is contained in:
zhangdaiscott 2021-01-25 18:35:40 +08:00
parent 7fbc47e77e
commit c1ea85fe01
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package org.jeecg.modules.system.rule;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.jeecg.common.handler.IFillRuleHandler;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 填值规则Demo生成订单号
* 测试示例
*/
public class OrderNumberRule implements IFillRuleHandler {
@Override
public Object execute(JSONObject params, JSONObject formData) {
String prefix = "CN";
//订单前缀默认为CN 如果规则参数不为空则取自定义前缀
if (params != null) {
Object obj = params.get("prefix");
if (obj != null) prefix = obj.toString();
}
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
int random = RandomUtils.nextInt(90) + 10;
String value = prefix + format.format(new Date()) + random;
// 根据formData的值的不同生成不同的订单号
String name = formData.getString("name");
if (!StringUtils.isEmpty(name)) {
value += name;
}
return value;
}
}