jeecg 3.6 自定义表单保存问题修复

jeecg-3.6.0
zhangdaiscott 9 years ago
parent 07385b3a0a
commit a902dbd532

@ -244,7 +244,11 @@ public class AutoFormController extends BaseController {
autoForm.setFormContent(html);
autoForm.setFormParse(autoForm.getFormContent());
}
//--update-begin-------------date:20151102---------for:check 表单编码不允许重复--------------------
//TODO 待实现
//--update-end-------------date:20151102---------for:check 表单编码不允许重复----------------------
autoFormService.save(autoForm);
attributes.put("id", autoForm.getId());
j.setAttributes(attributes);
@ -277,16 +281,18 @@ public class AutoFormController extends BaseController {
map.put(name, name);
}
}
Elements ids = doc.select("input[name$=.id]");
for (Element el: ids) {
String name = el.attr("name");
System.out.println(name);
if(map.get(name)!=null){
throw new BusinessException("主键ID有重复【"+name+"】,编辑器进入HTML模式删除重复的主键");
}else{
map.put(name, name);
}
}
//update---begin---author:zhoujf------date:20151207---------------for:大小写问题修改-------------------------------
// Elements ids = doc.select("input[name$=.id]");
// for (Element el: ids) {
// String name = el.attr("name");
// System.out.println(name);
// if(map.get(name)!=null){
// throw new BusinessException("主键ID有重复【"+name+"】,编辑器进入HTML模式删除重复的主键");
// }else{
// map.put(name, name);
// }
// }
//update---end---author:zhoujf------date:20151207---------------for:大小写问题修改-------------------------------
}
@ -377,7 +383,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbEntity dbForm:list){
map = new HashMap<String,Object>();
map.put("id", dbForm.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", dbForm.getDbChName()+"("+dbForm.getDbName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("dbCode", dbForm.getDbName());
map.put("pid", "0");
//增加父节点
@ -388,7 +396,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbFieldEntity field: fieldlist){
map = new HashMap<String,Object>();
map.put("id", field.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("pId", dbForm.getId());
map.put("nocheck",true);
dateList.add(map);
@ -400,7 +410,9 @@ public class AutoFormController extends BaseController {
for(AutoFormDbFieldEntity field: fieldlist){
map = new HashMap<String,Object>();
map.put("id", field.getId());
//update-begin--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("name", (StringUtils.isBlank(field.getFieldText())||"null".equals(field.getFieldText()))?field.getFieldName():field.getFieldText()+"("+field.getFieldName()+")");
//update-end--Author: jg_huangxg Date:20151106 for自定义表单时数据源树把数据源编码 和 字段属性名显示出来
map.put("pId", dbForm.getId());
map.put("nocheck",true);
dateList.add(map);
@ -449,11 +461,15 @@ public class AutoFormController extends BaseController {
dsData.put("dsName", db.getDbName());
dsList.add(dsData);
if("table".equals(db.getDbType())){
//update-begin--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?";
//update-end--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId);
dsData.put("columns", columns);
} else if("sql".equals(db.getDbType())){
//update-begin--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
String hql = "select new Map(t.fieldName as fieldName,t.fieldText as fieldText) from AutoFormDbFieldEntity t where t.autoFormDbId=?";
//update-end--Author: jg_huangxg Date:20151106 for增加字段文本的查询,当字段文本为空时,使用字段名称
List<Map<String,Object>> columns = this.systemService.findHql(hql, autoFormDbId);
if(columns.size()>0){
dsData.put("columns", columns);
@ -682,10 +698,13 @@ public class AutoFormController extends BaseController {
id = value.toString();
}
hqlTable.append(" where ID ='").append(id).append("'");
//update-start--Author:luobaoli Date:20150701 for如果数据源为空那么以当前上下文中的DB配置为准查询出表数据
if("".equals(formDb.getDbKey())){
//当前上下文中的DB环境获取数据库表中的所有数据
data = systemService.findForJdbc(hqlTable.toString());
}
//update-end--Author:luobaoli Date:20150701 for如果数据源为空那么以当前上下文中的DB配置为准查询出表数据
else{
DynamicDataSourceEntity dynamicDataSourceEntity = dynamicDataSourceServiceI.getDynamicDataSourceEntityForDbKey(formDb.getDbKey());
if(dynamicDataSourceEntity!=null){
@ -786,7 +805,9 @@ public class AutoFormController extends BaseController {
if(StringUtils.isNotBlank(dbForm.getAutoFormId())){
List<AutoFormDbEntity> dbFormList = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", dbForm.getAutoFormId());
if(dbFormList.size()>0){
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请选择数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
for(AutoFormDbEntity entity:dbFormList){
//根据数据源名称进行匹配数据
message += "<option value='"+entity.getDbName()+"'>"+(StringUtils.isBlank(entity.getDbChName())?entity.getDbName():entity.getDbChName())+"</option>";
@ -795,13 +816,17 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
} else{
j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message);
}
}else{
//2.如果ID为空则option拼接提示信息
j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message);
}
return j;
@ -821,10 +846,13 @@ public class AutoFormController extends BaseController {
//1.如果ID不为空则拼接option字符串
//根据数据源名称进行匹配数据
if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){
//update-begin--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?";
List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId());
if(list.size() ==1){
dbForm = list.get(0);
//update-end--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
//dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName());
List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>();
if("table".equals(dbForm.getDbType())){
@ -843,7 +871,9 @@ public class AutoFormController extends BaseController {
}
}
if(columns.size()>0){
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请选择字段</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
for(Map<String,Object> map:columns){
message += "<option value='"+map.get("fieldName")+"'>"+(StringUtils.isBlank((String)map.get("fieldText"))?map.get("fieldName"):map.get("fieldText")) +"</option>";
}
@ -851,18 +881,23 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
} else{
j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先添加字段</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message);
}
}else{
//2.如果ID为空则option拼接提示信息
j.setSuccess(false);
//update-begin--Author:jg_renjie Date:20150722 for设置默认选项的value值
message = "<option value='' selected='selected'>请先选择数据源</option>";
//update-end--Author:jg_renjie Date:20150722 for设置默认选项的value值
j.setMsg(message);
}
}
return j;
}
//add-begin--Author:jg_renjie Date:20150725 for数据源根据autoFormId与dbName取数据,并拼接成tr串
/**
* ,table
* @param dbForm
@ -880,6 +915,8 @@ public class AutoFormController extends BaseController {
Map<String, Object> attributes = new HashMap<String, Object>();
if(StringUtils.isNotBlank(dbForm.getDbName()) && StringUtils.isNotBlank(dbForm.getAutoFormId())){
//update-begin--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
String hqlList = "from AutoFormDbEntity t where t.dbName = ? and autoFormId = ?";
List<AutoFormDbEntity> list= this.systemService.findHql(hqlList, dbForm.getDbName(),dbForm.getAutoFormId());
if(list.size() ==1){
@ -891,6 +928,8 @@ public class AutoFormController extends BaseController {
} else {
attributes.put("dbName", dbForm.getDbName());
}
//update-end--Author:jg_renjie Date:20150723 for数据源根据autoFormId与dbName取数据
//dbForm = this.systemService.findUniqueByProperty(AutoFormDbEntity.class, "dbName", dbForm.getDbName());
List<Map<String,Object>> columns = new ArrayList<Map<String,Object>>();
if("table".equals(dbForm.getDbType())){
@ -908,6 +947,8 @@ public class AutoFormController extends BaseController {
}
}
}
//update-start--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
StringBuilder options = null;
StringBuilder trList = new StringBuilder();
String headStr = "";
@ -1049,6 +1090,7 @@ public class AutoFormController extends BaseController {
} else {
message = "<option value=\"\">无字段</option>";
}
//update-end--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
j.setSuccess(true);
//j.setMsg(message);
@ -1065,6 +1107,9 @@ public class AutoFormController extends BaseController {
}
return j;
}
//add-end--Author:jg_renjie Date:20150725 for数据源根据autoFormId与dbName取数据,并拼接成tr串
//update-start--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
/**
*
*/
@ -1093,6 +1138,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
return j;
}
//update-end--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
/**
*
@ -1198,6 +1244,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
return j;
}
//update-begin--Author:zzl Date:20151102 for表单编码唯一性验证
@RequestMapping(params = "checkTbCode")
@ResponseBody
@ -1221,6 +1268,8 @@ public class AutoFormController extends BaseController {
jsonObject.put("status", "y");
return jsonObject;
}
//update-end--Author:zzl Date:20151102 for表单编码唯一性验证
//update-begin--Author:zzl Date:20151110 for数据源级联删除
private void delFormDb(String autoFormId){
List<AutoFormDbEntity> list = this.systemService.findByProperty(AutoFormDbEntity.class, "autoFormId", autoFormId);
if(list!=null&&list.size()>0) {
@ -1230,4 +1279,5 @@ public class AutoFormController extends BaseController {
}
}
}
//update-end--Author:zzl Date:20151110 for数据源级联删除
}

Loading…
Cancel
Save