1、用户数据迁移时,必须在表t_s_base_user和t_s_user中都插入数据才会在页面显示。
2、执行sql语句:
String sql = "select count(id) from orderb where merchanttrnno like '"+nowYear+"%"+"'"; count = jeecgJdbcService.getCountForJdbcParam(sql, new Object[]{});
3、获取当前登录用户 :
TSUser user = ResourceUtil.getSessionUserName();
String name = user.getUserName();
4、配置多个数据源
1、在spring中添加多个数据源
2、在项目中获取数据源,并且执行操作
DataSourceContextHolder.setDataSourceType(org.jeecgframework.core.extend.datasource.DataSourceType.dataSource_jinli); String sql = "insert into person(id,name) values('002','李四')"; jeecgJdbcService.executeSql(sql, new Object[]{}); System.out.println(DataSourceContextHolder.getDataSourceType());
DataSourceContextHolder 这个类可以改变上下文的数据源
你在spring-mvc-hibernate.xml中配置多种数据源就可以切换了
5、用户删除失败,
设置 t_s_log 外键 级联删除
6、curdtool.js 中包含了很多js控制,限制方法
eg: //sql 增强 function doDopay(title,url,id){ var rowData = $('#'+id).datagrid('getSelected'); var rowsData = $('#'+id).datagrid('getSelections'); if (!rowData) { tip('请选择付款项目'); return; } if (rowsData.length>1) { tip('请选择一个付款项目'); return; } }
7、修改模糊查询: StringParseImpl 类
8、执行SQL语句的方式:
// Map<String,Object> map = new HashMap<String, Object>(); // System.out.println("map"); // map = jeecgJdbcService.findOneForJdbc(findOrderc); // map = systemService.findOneForJdbc(findOrderc); // map = jdbcTemplate.queryForMap(findOrderc);
9、读取方式:
String sql = SqlUtil.getMethodSql(SqlUtil.getMethodUrl());
10、手动添加查询中的日期控件
$(document).ready(function(){ $("input[name='createTime_begin']").attr("class","easyui-datebox"); $("input[name='createTime_end']").attr("class","easyui-datebox"); });
11、上传附件大小控制 : UploadTag 类 进行修改
12、数据权限的帖子:
http://www.jeecg.org/forum.php?mod=viewthread&tid=1776&extra=page%3D1
13、Jeecg 查询条件拼装-代码解读
http://www.jeecg.org/forum.php?mod=viewthread&tid=1760&extra=page%3D4
数据源设计
http://www.jeecg.org/forum.php?mod=viewthread&tid=2328&page=1&extra=#pid6366
14、replace 用法 参见 userList.jsp 部门字段
15、easyui.tld 自定义标签,
16、自己写弹出选择页 choose 重写代码
//重写方法 function listChoose(title,url){ $.dialog({ content: 'url:'+url, zIndex: 2022, title: title, lock : true, width :400, height :350, left :'65%', top :'45%', opacity : 0.4, button : [ { name : '确认', callback : function() { iframe = this.iframe.contentWindow; var locDeptCode = ""; locDeptCode = iframe.getmedi calInslocalDeptsListSelections('locDeptCode'); $('#locDeptCode').val(locDeptCode); var locDeptName = ""; locDeptName = iframe.getmedicalInslocalDeptsListSelections('locDeptName'); $('#locDeptName').val(locDeptName); return true; }, focus : true }, { name : '取消', callback : function() {} } ] }); } //重写方法 function clearsChoose(hiddenid,hiddenName,toname,textname){ var textnamearr; if(textname){ if(toname){ textname = toname; } textnamearr = textname.split(","); for(var i=0; i<textnamearr.length;i++ ){ if(textnamearr[i]){ $('#' + textnamearr[i]).val(""); //$('#' + textnamearr[i]).blur(); } } } if(hiddenid!== undefined && hiddenid!=""){ $('#'+ hiddenid).val(""); }else{ $('#'+ hiddenName).val(""); } }
17、指向同一个表需要在后面加
cgAutoListController.do?list&id=center_user&isIframe=true
18、
roleSet.jsp ajax 提交
function mysubmit() { var roleId = $("#rid").val(); var s = GetNode(); //doSubmit("roleController.do?updateAuthority&rolefunctions=" + s + "&roleId=" + roleId); var obj = new Object(); obj.rolefunctions =s; obj.roleId =roleId; //保存 $.ajax({ url : 'roleController.do?updateAuthority', // 请求的action路径 async : false, cache : false, type : 'POST', dataType:'json', data:obj, error : function() {// 请求失败处理函数 }, success : function(data) { var d = jq.parseJSON(data); if (d.success) { jq.dialog.tips('操作成功', 2); } } }); }
19、查询加上时间控件
$(document).ready(function(){ //给时间控件加上样式 //给时间控件加上样式 $("#contractMainListtb").find("input[name='signDate_begin']").attr( "class", "Wdate").attr("style", "height:20px;width:90px;") .click(function() { WdatePicker( { dateFmt : 'yyyy-MM-dd' }); }); $("#contractMainListtb").find("input[name='signDate_end']").attr( "class", "Wdate").attr("style", "height:20px;width:90px;") .click(function() { WdatePicker( { dateFmt : 'yyyy-MM-dd' }); }); });
contractMainListtb是datagrid的name值
name='signDate_begin'的signDate是dgCol的field值
修改查询 HqlGenerateUtil.java
20、导出Excel 问题:
导出是需要配置entity 注解
导出Excel时,查询中带汉字的导出时为空,需要修改tomcat 配置文件编码。
21、jeecg 执行存储过程
Session session = jeecgJdbcService.getSession(); SQLQuery query = session.createSQLQuery("{Call EXEC_YSKD_ZD("+YSKD01+",'"+GSXX01+"')}"); query.executeUpdate(); session.close(); 使用时切换数据源: // DataSourceContextHolder.setDataSourceType(org.jeecgframework.core.extend.datasource.DataSourceType.dataSource_jinli); // String sql = "insert into person(id,name) values('002','李四')"; // jeecgJdbcService.executeSql(sql, new Object[]{}); // System.out.println(DataSourceContextHolder.getDataSourceType()); 执行带参数的存储过程 : Session session = systemService.getSession(); CallableStatement procCall = SessionFactoryUtils.getDataSource(session.getSessionFactory()).getConnection().prepareCall("{call GET_BH(?,?,?,?,?,?,?,?)}"); procCall.setString(1, companyNo); procCall.setBigDecimal(2, new BigDecimal(0)); procCall.setString(3, unitNo); procCall.setInt(4, 0);
22、tomcat 启动maven项目
http://wenku.baidu.com/view/36d6d4671eb91a37f1115ca5.html
23、根据id获取 数据
systemService.getEntity(TSDepart.class,pid)
24.弹出窗口的"确认"与"关闭"那两个按钮,代码放在curdtools.js里面的createwindow方法
25.
jsp页面里column字标签扩展
extend="{data-options:{required:false,groupSeparator:\"','\"},class:{value:'easyui-numberbox'}}"
extendJson="{required:'true'}"
extendJson="{disable:'true'}"
26 mysql调用存储过程实例
package service; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; public class TestMysqlProcedure { String url = "jdbc:mysql://127.0.0.1:3306/mydate"; String userName = "root"; String password = "root"; public Connection getConnection() { Connection con=null; try{ DriverManager.registerDriver(new com.mysql.jdbc.Driver()); con = DriverManager.getConnection(url, this.userName, this.password); }catch(SQLException sw){ } return con; } //读取OUT型的存储过程(计算记录总数) public void testProc_Out(){ Connection conn = getConnection(); CallableStatement stmt = null; try{ //调取OUT型的存储过程P(计算记录总数) stmt = conn.prepareCall("{call p(?)}"); //读取所有OUT型的存储过程的返回参数数据 stmt.registerOutParameter(1, Types.INTEGER); stmt.execute(); int i= stmt.getInt(1); System.out.println("count = " + i); }catch(Exception e){ System.out.println("hahad = "+e.toString()); }finally{ try { stmt.close(); conn.close(); }catch (Exception ex) { System.out.println("ex : "+ ex.getMessage()); } } } //读取IN型的存储过程(条件查询) public void testProc_In(){ Connection conn = getConnection(); CallableStatemen t stmt = null; ResultSet rs=null; try{ //调取IN型的存储过程P2,(条件查询) stmt = conn.prepareCall("{call p2(?)}"); //设置IN型的存储过程参数值 stmt.setInt(1, 3); //执行语句,并返回值 rs=stmt.executeQuery(); if(rs.next()){ System.out.println("rs ---------- " + rs.getInt(1)); System.out.println("rs ---------- " + rs.getString(2)); } }catch(Exception e){ System.out.println("hahad --------- "+e.toString()); }finally{ try { rs.close(); stmt.close(); conn.close(); }catch (Exception ex) { System.out.println("ex ----------: "+ ex.getMessage()); } } } public static void main(String[] args) { TestMysqlProcedure tmp=new TestMysqlProcedure(); tmp.testProc_Out(); tmp.testProc_In(); } }