|
@@ -503,18 +503,27 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
// 根据表单配置获取字典数据
|
|
|
Map<String, Map<String, Object>> formDicData = FormDataTransUtil.formConfigGetDicData(formDesignConfig);
|
|
|
|
|
|
+ int row = 1;
|
|
|
for (Map<String, Object> data : dataList) {
|
|
|
Entity where = Entity.create(tableName);
|
|
|
// 处理字段值
|
|
|
- Map<String, Object> toSaveFormData = handleFormDataForSave(data, formDesignConfig, tableName, new ArrayList<>(), formDicData);
|
|
|
-
|
|
|
- //formData 默认插入雪花Id主键
|
|
|
- pk.ifPresent(column -> toSaveFormData.put(column.getName(), IdUtil.getSnowflakeNextId()));
|
|
|
- where.putAll(toSaveFormData);
|
|
|
- //如果有审计字段 默认填充值
|
|
|
- putAuditEntityInsertData(where, columns);
|
|
|
-
|
|
|
- toSaveList.add(where);
|
|
|
+ try {
|
|
|
+ Map<String, Object> toSaveFormData = handleFormDataForSave(data, formDesignConfig, tableName, new ArrayList<>(), formDicData);
|
|
|
+ //formData 默认插入雪花Id主键
|
|
|
+ pk.ifPresent(column -> toSaveFormData.put(column.getName(), IdUtil.getSnowflakeNextId()));
|
|
|
+ where.putAll(toSaveFormData);
|
|
|
+ //如果有审计字段 默认填充值
|
|
|
+ putAuditEntityInsertData(where, columns);
|
|
|
+
|
|
|
+ toSaveList.add(where);
|
|
|
+ }catch (MyException e){
|
|
|
+ String msg = e.getMsg();
|
|
|
+ if(msg.toLowerCase().contains("字典值不匹配-".toLowerCase())){
|
|
|
+ String value = msg.substring(msg.indexOf('-') + 1);
|
|
|
+ throw new MyException("第" + row + "行的" + value + "值不属于可使用的值!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ row++;
|
|
|
}
|
|
|
try {
|
|
|
Boolean result = SqlRunnerAdapter.db().dynamicInsertBatch(tableName, toSaveList);
|
|
@@ -2366,6 +2375,9 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
List<Object> mapKey = FormDataTransUtil.getMapKey(dicData, formData.get(bindField));
|
|
|
if (!mapKey.isEmpty()) {
|
|
|
resultData.put(bindField, mapKey.stream().findFirst().get());
|
|
|
+ }else{
|
|
|
+ String label = config.getLabel();
|
|
|
+ throw new MyException("字典值不匹配-" + label);
|
|
|
}
|
|
|
}
|
|
|
}
|