|
@@ -3,15 +3,15 @@ package com.boman.web.core.service.save;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.boman.common.core.constant.CacheConstants;
|
|
import com.boman.common.core.constant.CacheConstants;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
import com.boman.common.core.utils.SecurityUtils;
|
|
-import com.boman.common.core.utils.obj.ObjectUtils;
|
|
|
|
import com.boman.common.redis.service.RedisService;
|
|
import com.boman.common.redis.service.RedisService;
|
|
import com.boman.common.security.service.TokenService;
|
|
import com.boman.common.security.service.TokenService;
|
|
-import com.boman.domain.constant.FormDataConstant;
|
|
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.GenTableColumn;
|
|
|
|
+import com.boman.domain.constant.FormDataConstant;
|
|
import com.boman.system.api.model.LoginUser;
|
|
import com.boman.system.api.model.LoginUser;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.TableContext;
|
|
import com.boman.web.core.domain.TableContext;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
|
|
+import com.boman.web.core.utils.BillRuleUtils;
|
|
import com.boman.web.core.utils.ColumnUtils;
|
|
import com.boman.web.core.utils.ColumnUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -21,6 +21,8 @@ import org.springframework.stereotype.Component;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+import static com.boman.common.core.utils.obj.ObjectUtils.*;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author shiqian
|
|
* @author shiqian
|
|
* @description
|
|
* @description
|
|
@@ -50,6 +52,8 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
|
|
ColumnUtils.packUpdateByAndTime(columns, commitData, new Timestamp(System.currentTimeMillis()), true);
|
|
ColumnUtils.packUpdateByAndTime(columns, commitData, new Timestamp(System.currentTimeMillis()), true);
|
|
// 处理默认值
|
|
// 处理默认值
|
|
handlerDefaultValue(commitData, columns);
|
|
handlerDefaultValue(commitData, columns);
|
|
|
|
+ // 如果有单据、按照单据编号规则
|
|
|
|
+ buildBillRule(context.getTableName(), commitData, columns);
|
|
|
|
|
|
commitData.put(context.getPkName(), maxId);
|
|
commitData.put(context.getPkName(), maxId);
|
|
int ret = mapper.insert(context.getTableName(), commitData);
|
|
int ret = mapper.insert(context.getTableName(), commitData);
|
|
@@ -75,9 +79,7 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
|
|
JSONObject userEnv = loginUser.getUserEnv();
|
|
JSONObject userEnv = loginUser.getUserEnv();
|
|
for (GenTableColumn column : columns) {
|
|
for (GenTableColumn column : columns) {
|
|
// 有默认值的列, 并且前台传过来的key中不包含
|
|
// 有默认值的列, 并且前台传过来的key中不包含
|
|
- if (ObjectUtils.isNotEmpty(column.getDefaultValue())
|
|
|
|
- && !commitData.containsKey(column.getColumnName().toLowerCase())
|
|
|
|
- && !commitData.containsKey(column.getColumnName().toUpperCase())) {
|
|
|
|
|
|
+ if (isNotEmpty(column.getDefaultValue()) && !commitData.containsKey(column.getColumnName())) {
|
|
String dbDefaultValue = column.getDefaultValue();
|
|
String dbDefaultValue = column.getDefaultValue();
|
|
String defaultValue = ColumnUtils.parseVariables(dbDefaultValue);
|
|
String defaultValue = ColumnUtils.parseVariables(dbDefaultValue);
|
|
String variables = dbDefaultValue.equalsIgnoreCase(defaultValue) ? dbDefaultValue : userEnv.getString(defaultValue);
|
|
String variables = dbDefaultValue.equalsIgnoreCase(defaultValue) ? dbDefaultValue : userEnv.getString(defaultValue);
|
|
@@ -86,5 +88,25 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * 功能描述: 单据规则
|
|
|
|
+ *
|
|
|
|
+ * @param commitData commitData
|
|
|
|
+ * @param allColumns allColumns
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ private void buildBillRule(String tableName, JSONObject commitData, List<GenTableColumn> allColumns) {
|
|
|
|
+ requireNonNull(tableName, "tableName is empty");
|
|
|
|
+ for (GenTableColumn column : allColumns) {
|
|
|
|
+ String columnName = column.getColumnName();
|
|
|
|
+ String seqName = column.getSeqName();
|
|
|
|
+ if (isEmpty(seqName)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String rule = BillRuleUtils.getRules(tableName, seqName, columnName);
|
|
|
|
+ commitData.put(columnName, rule);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|