jeecg 3.6.6提供oracle、sqlserver脚步,解决内存溢出问题

pull/4/merge
zhangdaihao 2017-02-19 23:00:02 +08:00
parent 52c001423f
commit f02b901e39
11 changed files with 33452 additions and 56 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jeecgframework</groupId>
<artifactId>jeecg</artifactId>
<artifactId>jeecgos</artifactId>
<version>3.6.6</version>
<packaging>war</packaging>
<properties>
@ -886,7 +886,7 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- huangzq add cxf webservice 20151231-->
<!-- huangzq add cxf webservice 20151231
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
@ -897,7 +897,7 @@
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
-->
<!-- jeecg plugin -->
<dependency>
<groupId>org.p3framework</groupId>

View File

@ -882,7 +882,9 @@ public abstract class GenericBaseCommonDao<T, PK extends Serializable>
*
*/
public Long getCountForJdbcParam(String sql, Object[] objs) {
//-- update-begin author xugj date:20160103 for: #851 controller 单元测试升级spring 版本 -->
return this.jdbcTemplate.queryForObject(sql, objs,Long.class);
//-- update-end author xugj date:20160103 for: #851 controller 单元测试升级spring 版本 -->
}
@ -906,8 +908,13 @@ public abstract class GenericBaseCommonDao<T, PK extends Serializable>
KeyHolder keyHolder = null;
SqlParameterSource sqlp = new MapSqlParameterSource(param);
//update-begin--Author: jg_huangxg Date: 20150625 for[bugfree号]oc时,录入数据在Oracle下 数据写入错误--------------------
if (StringUtil.isNotEmpty(param.get("id"))) {//表示已经生成过id(UUID),则表示是非序列或数据库自增的形式
this.namedParameterJdbcTemplate.update(sql,sqlp);
//--authorzhoujf---start------date:20170216--------for:自定义表单保存数据格sqlserver报错问题
}else if (StringUtil.isNotEmpty(param.get("ID"))) {//表示已经生成过id(UUID),则表示是非序列或数据库自增的形式
this.namedParameterJdbcTemplate.update(sql,sqlp);
//--authorzhoujf---end------date:20170216--------for:自定义表单保存数据格sqlserver报错问题
}else{//NATIVE or SEQUENCE
keyHolder = new GeneratedKeyHolder();
this.namedParameterJdbcTemplate.update(sql,sqlp, keyHolder, new String[]{"id"});
@ -916,11 +923,14 @@ public abstract class GenericBaseCommonDao<T, PK extends Serializable>
keyValue = keyHolder.getKey().longValue();
}
}
//update-end--Author: jg_huangxg Date: 20150625 for[bugfree号]oc时,录入数据在Oracle下 数据写入错误----------------------
return keyValue;
}
public Integer countByJdbc(String sql, Object... param) {
//-- update-begin author xugj date:20160103 for: #851 controller 单元测试升级spring 版本 -->
return this.jdbcTemplate.queryForObject(sql, param,Integer.class);
//-- update-end author xugj date:20160103 for: #851 controller 单元测试升级spring 版本 -->
}
@ -976,6 +986,7 @@ public abstract class GenericBaseCommonDao<T, PK extends Serializable>
return dc.getExecutableCriteria(getSession()).list();
}
//update-begin--Author:luobaoli Date:20150710 for增加执行存储过程方法
/**
*
*/
@ -989,4 +1000,5 @@ public abstract class GenericBaseCommonDao<T, PK extends Serializable>
return sqlQuery.list();
}
//update-end--Author:luobaoli Date:20150710 for增加执行存储过程方法
}

View File

@ -96,6 +96,7 @@ public class AuthInterceptor implements HandlerInterceptor {
}
//String functionId=oConvertUtils.getString(request.getParameter("clickFunctionId"));
String functionId="";
//update-begin--Author:JueYue Date:20140831 foronlinecodeing 的URL判断--------------------
//onlinecoding的访问地址有规律可循数据权限链接篡改
if(requestPath.equals("cgAutoListController.do?datagrid")) {
requestPath += "&configId=" + request.getParameter("configId");
@ -107,6 +108,7 @@ public class AuthInterceptor implements HandlerInterceptor {
requestPath += "&tableName=" + request.getParameter("tableName");
}
//update-begin--Author:许国杰 Date:20151219 for#813 【online表单】扩展出三个请求独立的添加、查看、编辑请求原来的保留
if(requestPath.equals("cgFormBuildController.do?goAddFtlForm")) {
requestPath += "&tableName=" + request.getParameter("tableName");
}
@ -116,8 +118,12 @@ public class AuthInterceptor implements HandlerInterceptor {
if(requestPath.equals("cgFormBuildController.do?goDatilFtlForm")) {
requestPath += "&tableName=" + request.getParameter("tableName");
}
//update-end--Author:许国杰 Date:20151219 for#813 【online表单】扩展出三个请求独立的添加、查看、编辑请求原来的保留
//update-end--Author:JueYue Date:20140831 foronlinecodeing 的URL判断--------------------
//这个地方用全匹配?应该是模糊查询吧
//TODO
//update-begin--Author:张忠亮 Date:20150717 for解决rest风格下 权限失效问题
String uri= request.getRequestURI().substring(request.getContextPath().length() + 1);
String realRequestPath = null;
if(uri.endsWith(".do")||uri.endsWith(".action")){
@ -126,6 +132,7 @@ public class AuthInterceptor implements HandlerInterceptor {
realRequestPath=uri;
}
List<TSFunction> functions = systemService.findByProperty(TSFunction.class, "functionUrl", realRequestPath);
//update-end--Author:张忠亮 Date:20150717 for解决rest风格下 权限失效问题
if (functions.size()>0){
functionId = functions.get(0).getId();
}
@ -137,6 +144,7 @@ public class AuthInterceptor implements HandlerInterceptor {
request.setAttribute(Globals.OPERATIONCODES, operationCodes);
}
if(!oConvertUtils.isEmpty(functionId)){
//update-begin--Author:anchao Date:20140822 for[bugfree号]字段级权限(表单,列表)--------------------
//List<String> allOperation=this.systemService.findListbySql("SELECT operationcode FROM t_s_operation WHERE functionid='"+functionId+"'");
List<TSOperation> allOperation=this.systemService.findByProperty(TSOperation.class, "TSFunction.id", functionId);
@ -146,9 +154,10 @@ public class AuthInterceptor implements HandlerInterceptor {
//s=s.replaceAll(" ", "");
newall.add(s);
}
//---author:jg_xugj----start-----date:20151210--------for#781 【oracle兼容】兼容问题fun.operation!='' 在oracle 数据下不正确
String hasOperSql="SELECT operation FROM t_s_role_function fun, t_s_role_user role WHERE " +
"fun.functionid='"+functionId+"' AND fun.operation is not null AND fun.roleid=role.roleid AND role.userid='"+client.getUser().getId()+"' ";
//---author:jg_xugj----end-----date:20151210--------for#781 【oracle兼容】兼容问题fun.operation!='' 在oracle 数据下不正确
List<String> hasOperList = this.systemService.findListbySql(hasOperSql);
for(String operationIds:hasOperList){
for(String operationId:operationIds.split(",")){
@ -203,9 +212,9 @@ public class AuthInterceptor implements HandlerInterceptor {
boolean bMgrUrl = false;
if (functionList == null) {
// functionList = systemService.loadAll(TSFunction.class);
// update-start--Author:zhoujf Date:20150521 for只查询菜单类型的权限
functionList = systemService.findHql("from TSFunction where functionType = ? ", (short)0);
// update---end--Author:zhoujf Date:20150521 for只查询菜单类型的权限
}
for (TSFunction function : functionList) {
if (function.getFunctionUrl() != null && function.getFunctionUrl().startsWith(requestPath)) {
@ -229,13 +238,16 @@ public class AuthInterceptor implements HandlerInterceptor {
"ru.userid='"+userid+"' AND f.functionurl like '"+requestPath+"%'";
List list = this.systemService.findListbySql(sql);
if(list.size()==0){
// update-start--Author:zhangguoming Date:20140821 for判断当前用户组织机构下角色所拥有的权限
// update-start--Author:zhangguoming Date:20140825 for获取当前用户登录时选择的组织机构代码
String orgId = currLoginUser.getCurrentDepart().getId();
// update-end--Author:zhangguoming Date:20140825 for获取当前用户登录时选择的组织机构代码
String functionOfOrgSql = "SELECT DISTINCT f.id from t_s_function f, t_s_role_function rf, t_s_role_org ro " +
"WHERE f.ID=rf.functionid AND rf.roleid=ro.role_id " +
"AND ro.org_id='" +orgId+ "' AND f.functionurl like '"+requestPath+"%'";
List functionOfOrgList = this.systemService.findListbySql(functionOfOrgSql);
return functionOfOrgList.size() > 0;
// update-end--Author:zhangguoming Date:20140821 for判断当前用户组织机构下角色所拥有的权限
}else{
return true;
}
@ -253,13 +265,14 @@ public class AuthInterceptor implements HandlerInterceptor {
}
private void forward(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//update-start--Author:scott Date:20160803 for无登陆情况跳转登陆页
//超时,未登陆页面跳转
//response.sendRedirect(request.getServletContext().getContextPath()+"/loginController.do?login");
response.sendRedirect(request.getServletContext().getContextPath()+"/webpage/login/timeout.jsp");
// update-start--Author:chenjin Date:20160828 forTASK #1324 【bug】Session超时后重新登录页面显示在标签里,让它重新显示登录页面
response.sendRedirect(request.getSession().getServletContext().getContextPath()+"/webpage/login/timeout.jsp");
// update-end--Author:chenjin Date:20160828 forTASK #1324 【bug】Session超时后重新登录页面显示在标签里,让它重新显示登录页面
//request.getRequestDispatcher("loginController.do?login").forward(request, response);
//update-start--Author:scott Date:20160803 for无登陆情况跳转登陆页
}
}

View File

@ -3,6 +3,7 @@ package org.jeecgframework.web.autoform.controller;
import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@ -19,6 +20,9 @@ import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.velocity.VelocityContext;
import org.jeecgframework.codegenerate.pojo.TableConvert;
import org.jeecgframework.codegenerate.util.CodeResourceUtil;
import org.jeecgframework.codegenerate.util.def.ConvertDef;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
@ -199,9 +203,11 @@ public class AutoFormController extends BaseController {
autoForm.setFormContent(html);
autoForm.setFormParse(autoForm.getFormContent());
}
//update-begin--Author:jg_renjie Date:20160131 for针对默认字段 create_name、create_by等获取系统上下文值进行处理
autoForm.setCreateDate(new Date());
autoForm.setCreateName(ResourceUtil.getSessionUserName().getRealName());
autoForm.setCreateBy(ResourceUtil.getSessionUserName().getUserName());
//update-end--Author:jg_renjie Date:20160131 for针对默认字段 create_name、create_by等获取系统上下文值进行处理
autoFormService.save(autoForm);
systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
}catch(Exception e){
@ -241,9 +247,11 @@ public class AutoFormController extends BaseController {
t.setFormContent(html);
t.setFormParse(autoForm.getFormContent());
}
//update-begin--Author:jg_renjie Date:20160131 for针对默认字段 create_name、create_by等获取系统上下文值进行处理
autoForm.setUpdateDate(new Date());
autoForm.setUpdateName(ResourceUtil.getSessionUserName().getRealName());
autoForm.setUpdateBy(ResourceUtil.getSessionUserName().getUserName());
//update-end--Author:jg_renjie Date:20160131 for针对默认字段 create_name、create_by等获取系统上下文值进行处理
autoFormService.saveOrUpdate(t);
attributes.put("id", t.getId());
j.setAttributes(attributes);
@ -263,7 +271,10 @@ public class AutoFormController extends BaseController {
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);
@ -296,6 +307,7 @@ public class AutoFormController extends BaseController {
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");
@ -306,6 +318,7 @@ public class AutoFormController extends BaseController {
// map.put(name, name);
// }
// }
//update---end---author:zhoujf------date:20151207---------------for:大小写问题修改-------------------------------
}
@ -396,7 +409,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");
//增加父节点
@ -407,7 +422,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);
@ -419,7 +436,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);
@ -468,11 +487,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);
@ -536,10 +559,11 @@ public class AutoFormController extends BaseController {
List<AutoFormDbEntity> autoList = systemService.findByProperty(AutoFormDbEntity.class, "dbName", autoForm.getMainTableSource());
if (autoList!=null&&autoList.size()>0) {
AutoFormDbEntity autoFormDbEntity = autoList.get(0);
//-- update-start author gengjiajia date:20160616 for: TASK #1110 传递动态数据源名称
//3.传递参数
//req.setAttribute("tbDbKey", autoFormDbEntity.getTbDbKey());
req.setAttribute("dbKey", autoFormDbEntity.getDbKey());
//-- update-end author gengjiajia date:20160616 for: TASK #1110 传递动态数据源名称
}
req.setAttribute("paramList", paramList);
req.setAttribute("autoFormPage", autoForm);
@ -608,6 +632,7 @@ public class AutoFormController extends BaseController {
for(String key :tem.keySet()){
paramMap.put(key, tem.get(key));
}
//-- update-end author xugj date:20160103 for: #851 controller 单元测试升级servlet-api 后req.getParameterMap() 返回值类型变化
String op = req.getParameter("op");
if(StringUtil.isEmpty(op)){
@ -703,7 +728,7 @@ public class AutoFormController extends BaseController {
if(autoFormDbFieldEntityList.size()>0){
StringBuffer hqlTable = new StringBuffer().append("select ");
for(AutoFormDbFieldEntity autoFormDbFieldEntity:autoFormDbFieldEntityList){
//author:jg_renjie----start-----date:20160228--------forTASK #704 【表单填报预览】针对特殊类型数据需要进行转换比如blob
boolean flag = false;
for(Map<String,Object> typeMap:typeList){
String dataType = typeMap.get("dataType").toString().toUpperCase();
@ -717,6 +742,7 @@ public class AutoFormController extends BaseController {
if(!flag){
hqlTable.append(autoFormDbFieldEntity.getFieldName()+",");
}
//author:jg_renjie----end-----date:20160228--------forTASK #704 【表单填报预览】针对特殊类型数据需要进行转换比如blob
}
hqlTable.deleteCharAt(hqlTable.length()-1).append(" from "+formDb.getDbTableName());
@ -730,10 +756,12 @@ public class AutoFormController extends BaseController {
}
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){
@ -770,7 +798,7 @@ public class AutoFormController extends BaseController {
throw new BusinessException(message);
} else {
try {
// update-start--Author:gengjiajia Date:20160616 for:TASK #1110 修改使用动态数据源查询数据
// data = systemService.findForJdbc(dbDynSql);
Object dbKeys = paramMap.get("dbKey");
if (oConvertUtils.isNotEmpty(dbKeys)) {
@ -789,7 +817,7 @@ public class AutoFormController extends BaseController {
} else {
data = systemService.findForJdbc(dbDynSql);
}
// update-start--Author:gengjiajia Date:20160616 for: #1110 修改使用动态数据源查询数据
} catch (Exception e) {
logger.info(e.getMessage());
message = "动态SQL数据查询失败";
@ -809,10 +837,38 @@ public class AutoFormController extends BaseController {
* @param dbTableNm
* @return
*/
//author:jg_renjie----start-----date:20160228--------forTASK #704 【表单填报预览】针对特殊类型数据需要进行转换比如blob
private List<Map<String, Object>> getColumnTypes(String dbTableNm,String dbkey){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
String sql = "select DATA_TYPE as dataType,COLUMN_NAME as columnNm from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm+"'";
String sql = "select DATA_TYPE as dataType,COLUMN_NAME as columnNm from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
//--authorzhoujf---start------date:20170216--------for:自定义表单获取列类型不同数据库获取问题
//---------------------------------------------------------------------------------------
//[DB SQL]
if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_MYSQL)){
//mysql
sql = "select COLUMN_NAME as columnNm,DATA_TYPE as dataType from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_ORACLE)){
//oracle
sql = " select colstable.column_name columnNm, colstable.data_type dataType"
+ " from user_tab_cols colstable "
+ " inner join user_col_comments commentstable "
+ " on colstable.column_name = commentstable.column_name "
+ " where colstable.table_name = commentstable.table_name "
+ " and colstable.table_name = '"+dbTableNm.toUpperCase()+"'";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_postgresql)){
//postgresql
sql = "SELECT a.attname AS columnNm,t.typname AS dataType"
+" FROM pg_class c,pg_attribute a,pg_type t "
+" WHERE c.relname = '"+dbTableNm.toUpperCase()+"' and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid "
+" ORDER BY a.attnum ";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_SQL_SERVER)){
//sqlserver
// sql = "select cast(a.name as varchar(50)) columnNm, cast(b.name as varchar(50)) dataType" +
// " from sys.columns a left join sys.types b on a.user_type_id=b.user_type_id left join sys.objects c on a.object_id=c.object_id and c.type='''U''' left join sys.extended_properties e on e.major_id=c.object_id and e.minor_id=a.column_id and e.class=1 where c.name='"+dbTableNm.toUpperCase()+"'";
sql = "select DATA_TYPE as dataType,COLUMN_NAME as columnNm from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
}
//---------------------------------------------------------------------------------------
//--authorzhoujf---end------date:20170216--------for:自定义表单获取列类型不同数据库获取问题
if(StringUtils.isNotBlank(dbkey)){
list= DynamicDBUtil.findList(dbkey,sql);
} else {
@ -850,6 +906,8 @@ public class AutoFormController extends BaseController {
}
return data;
}
//author:jg_renjie----end-----date:20160228--------forTASK #704 【表单填报预览】针对特殊类型数据需要进行转换比如blob
/**
*
* @param
@ -895,7 +953,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>";
@ -904,13 +964,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;
@ -931,10 +995,12 @@ public class AutoFormController extends BaseController {
//根据数据源名称进行匹配数据
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())){
@ -953,7 +1019,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>";
}
@ -961,19 +1029,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
@ -992,6 +1064,7 @@ public class AutoFormController extends BaseController {
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){
@ -1003,6 +1076,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())){
@ -1020,7 +1095,8 @@ public class AutoFormController extends BaseController {
}
}
}
//update-start--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
StringBuilder options = null;
StringBuilder trList = new StringBuilder();
String headStr = "";
@ -1162,6 +1238,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);
@ -1178,8 +1255,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优化根据数据源生成数据列
/**
*
*/
@ -1208,6 +1286,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
return j;
}
//update-end--Author:jg_renjie Date:20151107 for优化根据数据源生成数据列
/**
*
@ -1313,6 +1392,7 @@ public class AutoFormController extends BaseController {
j.setMsg(message);
return j;
}
//update-begin--Author:zzl Date:20151102 for表单编码唯一性验证
@RequestMapping(params = "checkTbCode")
@ResponseBody
@ -1336,6 +1416,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) {
@ -1345,7 +1427,10 @@ public class AutoFormController extends BaseController {
}
}
}
//update-end--Author:zzl Date:20151110 for数据源级联删除
//update-start--Author: jg_huangxg Date:2016年9月20日 forVM版请求
/**
*
*
@ -1401,10 +1486,11 @@ public class AutoFormController extends BaseController {
List<AutoFormDbEntity> autoList = systemService.findByProperty(AutoFormDbEntity.class, "dbName", autoForm.getMainTableSource());
if (autoList!=null&&autoList.size()>0) {
AutoFormDbEntity autoFormDbEntity = autoList.get(0);
//-- update-start author gengjiajia date:20160616 for: TASK #1110 传递动态数据源名称
//3.传递参数
//req.setAttribute("tbDbKey", autoFormDbEntity.getTbDbKey());
velocityContext.put("dbKey", autoFormDbEntity.getDbKey());
//-- update-end author gengjiajia date:20160616 for: TASK #1110 传递动态数据源名称
}
velocityContext.put("paramList", paramList);
velocityContext.put("autoFormPage", autoForm);
@ -1425,6 +1511,7 @@ public class AutoFormController extends BaseController {
for(String key :tem.keySet()){
paramMap.put(key, tem.get(key));
}
//-- update-end author xugj date:20160103 for: #851 controller 单元测试升级servlet-api 后req.getParameterMap() 返回值类型变化
String op = request.getParameter("op");
if(StringUtil.isEmpty(op)){
@ -1511,4 +1598,5 @@ public class AutoFormController extends BaseController {
velocityContext.put("message", message);
ViewVelocity.view(request,response,viewName,velocityContext);
}
//update-end--Author: jg_huangxg Date:2016年9月20日 forVM版请求
}

View File

@ -1,7 +1,11 @@
package org.jeecgframework.web.autoform.service.impl;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -10,16 +14,22 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.codegenerate.util.CodeResourceUtil;
import org.jeecgframework.codegenerate.util.def.ConvertDef;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import org.jeecgframework.core.constant.DataBaseConstant;
import org.jeecgframework.core.util.DateUtils;
import org.jeecgframework.core.util.DynamicDBUtil;
import org.jeecgframework.core.util.ResourceUtil;
import org.jeecgframework.core.util.StringUtil;
import org.jeecgframework.core.util.UUIDGenerator;
import org.jeecgframework.core.util.oConvertUtils;
import org.jeecgframework.web.autoform.entity.AutoFormDbEntity;
import org.jeecgframework.web.autoform.entity.AutoFormEntity;
import org.jeecgframework.web.autoform.service.AutoFormServiceI;
import org.jeecgframework.web.autoform.util.AutoFormTemplateParseUtil;
import org.jeecgframework.web.cgform.entity.config.CgFormFieldEntity;
import org.jeecgframework.web.cgform.exception.BusinessException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.jdbc.UncategorizedSQLException;
@ -152,7 +162,7 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
}
}
}
//add-start--Author:chenchunpeng Date:20160613 for自定义表单设定默认值
/**
*
* @param data
@ -198,7 +208,7 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
data.put(DataBaseConstant.UPDATE_NAME_TABLE, ResourceUtil.getUserSystemData(DataBaseConstant.SYS_USER_NAME));
}
}
//add-end--Author:chenchunpeng Date:chenchunpeng Date:20160613 for自定义表单设定默认值
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public String doUpdateTable(String formName,
@ -232,7 +242,7 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
}
String tbDbTableName = autoFormDbEntity.getTbDbTableName();
//系统上下文变量赋值
//add-start--Author:chenchunpeng Date:20160613 for自定义表单设定默认值
Object val=data.get("id");
//通过判断id是否有值确定是添加还是修改
if(StringUtil.isNotEmpty(val)){
@ -240,7 +250,7 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
}else{
fillInsertSysVar(data);
}
//add-end--Author:chenchunpeng Date:20160613 for自定义表单设定默认值
String id = null;
String comma = "";
StringBuffer updateSqlBuffer = new StringBuffer();
@ -301,7 +311,9 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
data.put(fkid, fkidValue);
}
}
//--authorzhoujf---start------date:20170216--------for:自定义表单保存数据格式不一致问题
dataAdapter(tbDbTableName,data);
//--authorzhoujf---end------date:20170216--------for:自定义表单保存数据格式不一致问题
//智能提交数据
if(isAdd){
if(id==null||id.toString().equals("")){
@ -344,6 +356,119 @@ public class AutoFormServiceImpl extends CommonServiceImpl implements AutoFormSe
}
/**
* -map-value
* @param tableName
* @param data
*/
private Map<String, Object> dataAdapter(String tableName,Map<String, Object> data) {
//step.1 获取表单的字段配置
Map<String, String> fieldConfigs =getColumnTypes(tableName);
//step.2 迭代将要持久化的数据
Iterator it = fieldConfigs.keySet().iterator();
for(;it.hasNext();){
Object key = it.next();
//根据表单配置的字段名 获取 前台数据
Object beforeV = data.get(key.toString().toLowerCase());
//如果值不为空
if(oConvertUtils.isNotEmpty(beforeV)){
//获取字段配置-字段类型
String type = fieldConfigs.get(key.toString().toLowerCase());
//根据类型进行值的适配
if("date".equalsIgnoreCase(type)){
//日期->java.util.Date
Object newV = String.valueOf(beforeV);
try {
String dateStr = String.valueOf(beforeV);
if (dateStr.indexOf(":") == -1 && dateStr.length() == 10) {
newV = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
} else if (dateStr.indexOf(":") > 0 && dateStr.length() == 19) {
newV = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
} else if (dateStr.indexOf(":") > 0 && dateStr.length() == 21) {
dateStr = dateStr.substring(0,dateStr.indexOf("."));
newV = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateStr);
}
if(data.containsKey(key)){
data.put(String.valueOf(key), newV);
}
} catch (ParseException e) {
e.printStackTrace();
}
}else if("int".equalsIgnoreCase(type)){
//int->java.lang.Integer
Object newV = null;
try{
newV = Integer.parseInt(String.valueOf(beforeV));
}catch (Exception e) {
e.printStackTrace();
}
if(data.containsKey(key)){
data.put(String.valueOf(key), newV);
}
}else if("double".equalsIgnoreCase(type)){
//double->java.lang.Double
Object newV = new Double(0);
try{
newV = Double.parseDouble(String.valueOf(beforeV));
}catch (Exception e) {
e.printStackTrace();
}
if(data.containsKey(key)){
data.put(String.valueOf(key), newV);
}
}
}
}
return data;
}
/**
*
* @param dbTableNm
* @return
*/
private Map<String,String> getColumnTypes(String dbTableNm){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
String sql = "select DATA_TYPE as dataType,COLUMN_NAME as columnNm from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
//---------------------------------------------------------------------------------------
//[DB SQL]
if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_MYSQL)){
//mysql
sql = "select COLUMN_NAME as columnNm,DATA_TYPE as dataType from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_ORACLE)){
//oracle
sql = " select colstable.column_name columnNm, colstable.data_type dataType"
+ " from user_tab_cols colstable "
+ " inner join user_col_comments commentstable "
+ " on colstable.column_name = commentstable.column_name "
+ " where colstable.table_name = commentstable.table_name "
+ " and colstable.table_name = '"+dbTableNm.toUpperCase()+"'";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_postgresql)){
//postgresql
sql = "SELECT a.attname AS columnNm,t.typname AS dataType"
+" FROM pg_class c,pg_attribute a,pg_type t "
+" WHERE c.relname = '"+dbTableNm.toUpperCase()+"' and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid "
+" ORDER BY a.attnum ";
}else if(CodeResourceUtil.DATABASE_TYPE.equals(ConvertDef.DATABASE_TYPE_SQL_SERVER)){
//sqlserver
// sql = "select cast(a.name as varchar(50)) columnNm, cast(b.name as varchar(50)) dataType" +
// " from sys.columns a left join sys.types b on a.user_type_id=b.user_type_id left join sys.objects c on a.object_id=c.object_id and c.type='''U''' left join sys.extended_properties e on e.major_id=c.object_id and e.minor_id=a.column_id and e.class=1 where c.name='"+dbTableNm.toUpperCase()+"'";
sql = "select DATA_TYPE as dataType,COLUMN_NAME as columnNm from information_schema.COLUMNS where TABLE_NAME='"+dbTableNm.toUpperCase()+"'";
}
//---------------------------------------------------------------------------------------
list = this.findForJdbc(sql);
Map<String,String> map = new HashMap<String, String>();
if(list!=null&&list.size()>0){
for(Map<String,Object> typeMap:list){
String dataType = typeMap.get("dataType").toString().toLowerCase();
String columnNm = typeMap.get("columnNm").toString().toLowerCase();
map.put(columnNm,dataType);
}
}
return map;
}
private String getDsPropertyValueNoGenerator(Map<String, Map<String, Object>> dataMap,String key){
String value = "";
String [] keys = key.split("\\.");

View File

@ -1,6 +1,5 @@
package org.jeecgframework.web.demo.ws.test;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
/**
*
@ -12,19 +11,19 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
*/
public class JeecgWServiceClient {
public static void main11(String[] args) {
JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
bean.setServiceClass(JeecgWServiceI.class);
bean.setAddress("http://localhost:8080/jeecg/cxf/JeecgWService");
JeecgWServiceI client = (JeecgWServiceI) bean.create();
System.out.println(client.sayHello());
}
public static void main(String[] args) {
JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
bean.setServiceClass(JeecgWServiceI.class);
bean.setAddress("http://localhost:8080/jeecg/cxf/JeecgWDemoService");
JeecgWServiceI client = (JeecgWServiceI) bean.create();
System.out.println(client.sayHello());
}
// public static void main11(String[] args) {
// JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
// bean.setServiceClass(JeecgWServiceI.class);
// bean.setAddress("http://localhost:8080/jeecg/cxf/JeecgWService");
// JeecgWServiceI client = (JeecgWServiceI) bean.create();
// System.out.println(client.sayHello());
// }
//
// public static void main(String[] args) {
// JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
// bean.setServiceClass(JeecgWServiceI.class);
// bean.setAddress("http://localhost:8080/jeecg/cxf/JeecgWDemoService");
// JeecgWServiceI client = (JeecgWServiceI) bean.create();
// System.out.println(client.sayHello());
// }
}

View File

@ -1,5 +1,13 @@
package org.jeecgframework.web.graphreport.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.jeecgframework.core.common.controller.BaseController;
import org.jeecgframework.core.common.exception.BusinessException;
@ -14,14 +22,12 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
import org.jeecgframework.tag.core.easyui.TagUtil;
import org.jeecgframework.web.demo.entity.test.CourseEntity;
import org.jeecgframework.web.graphreport.entity.core.JformGraphreportHeadEntity;
import org.jeecgframework.web.graphreport.entity.core.JformGraphreportItemEntity;
import org.jeecgframework.web.graphreport.page.core.JformGraphreportHeadPage;
import org.jeecgframework.web.graphreport.service.core.JformGraphreportHeadServiceI;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
@ -31,13 +37,6 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Title: Controller

View File

@ -124,8 +124,9 @@
<!-- 智能表单配置引入 -->
<import resource="classpath*:org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml" />
<!--集成cxf webservice接口-->
<!--集成cxf webservice接口
<import resource="classpath:cxf-servlet.xml" />
-->
<!-- jeecg plugin dev -->
<import resource="classpath:config/spring-config-p3.xml" />
</beans>

View File

@ -121,7 +121,7 @@
</servlet-mapping>
<!-- 集成cxf webservice接口 -->
<!-- 集成cxf webservice接口
<servlet>
<description>Apache CXF Endpoint</description>
<display-name>cxf</display-name>
@ -133,7 +133,8 @@
<servlet-name>cxf</servlet-name>
<url-pattern>/cxf/*</url-pattern>
</servlet-mapping>
-->
<!-- restUrl风格配置 -->
<servlet>
<servlet-name>restSpringMvc</servlet-name>