• 奈何喬
    了解作者
  • Java
    开发工具
  • 5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 2
    下载次数
  • 2018-07-23 16:59
    上传日期
通过java来实现kettle的案例,其他问题可留言交流
java_kettle.zip
  • java_kettle
  • KettleExecu.java
    2.2KB
  • accountDataSyn.jsp
    2.3KB
  • AccountsAction.xml
    1.8KB
  • AccountsAction.java
    9.7KB
内容介绍
package com.hdpi.bpm.action.accounts; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import com.hdpi.bpm.action.base.BaseAction; import com.hdpi.bpm.model.accounts.HdpiAccounts; import com.hdpi.bpm.service.accounts.HdpiAccountsService; import com.hdpi.common.util.ContextTool; import com.hdpi.common.util.Page; import com.hdpi.common.util.SessionTool; import com.hdpi.common.util.StringUtil; import com.hdpi.util.KettleExecu; public class AccountsAction extends BaseAction { /** * */ private static final long serialVersionUID = 6086727054204601144L; private HdpiAccountsService hdpiAccountsService; private HdpiAccounts hdpiAccounts; private List<HdpiAccounts> hdpiAccountsList; //设置分页 private Page page=new Page(); private Object json; public Object getJson() { return json; } public void setJson(Object json) { this.json = json; } /** * 跳转同步页面 * @return */ public String getAccountDataJsp(){ return "getAccountDataJsp"; } /** * 客户数据手动同步 * @return */ public String synItemData(){ try { HttpServletRequest request = ContextTool.getRequest(); HttpServletResponse response = ContextTool.getResponse(); String filePath = request.getSession().getServletContext().getRealPath("/kettle/uatest.ktr"); KettleExecu.runTrans(filePath); String url = request.getContextPath()+"/accountsAction/accountsAction_queryList.action"; request.getRequestDispatcher(url).forward(request, response); json = "{\"returnJson\":true}"; } catch (Exception e) { json = "{\"returnJson\":false}"; } return "success"; } /** * 列表查询方法 * @return */ public String queryList(){ String state=ContextTool.getRequest().getParameter("state"); DetachedCriteria qc=DetachedCriteria.forClass(HdpiAccounts.class); if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getAccountCode())){ qc.add(Restrictions.like("accountCode", hdpiAccounts.getAccountCode().trim()+"%")); //去掉空格并且忽略大小写 } if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getAccountDesc())){ qc.add(Restrictions.like("accountDesc", "%"+hdpiAccounts.getAccountDesc().trim()+"%")); } if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getAccountCategory())&&!"--".equals(hdpiAccounts.getAccountCategory())){ qc.add(Restrictions.like("accountCategory", "%"+hdpiAccounts.getAccountCategory().trim()+"%")); } if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getAccountType())&&!"--".equals(hdpiAccounts.getAccountType())){ qc.add(Restrictions.like("accountType", "%"+hdpiAccounts.getAccountType().trim()+"%")); } if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getParentFlag())&&!"--".equals(hdpiAccounts.getParentFlag())){ qc.add(Restrictions.eq("parentFlag", hdpiAccounts.getParentFlag())); } if(hdpiAccounts!=null&&!StringUtil.isNull(hdpiAccounts.getEnableFlag())){ qc.add(Restrictions.like("enableFlag", "%"+hdpiAccounts.getEnableFlag().trim()+"%")); } SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try{ if (!StringUtil.isNull(hdpiAccounts.getStartDate())){ qc.add(Restrictions.ge("creationDate", simpledateformat.parse(hdpiAccounts.getStartDate()+" 00:00:00"))); } if (!StringUtil.isNull(hdpiAccounts.getEndDate())){ qc.add(Restrictions.le("creationDate", simpledateformat.parse(hdpiAccounts.getEndDate()+" 23:59:59"))); } }catch(Exception e){ } int recordTotal=0; try { recordTotal=ContextTool.getCount((DetachedCriteria)ContextTool.cloneObject(qc)); } catch (Exception e) { e.printStackTrace(); } qc.addOrder(Order.asc("accountCode")); page=Page.forInstance(page.getCurrentPageNo(), recordTotal, ContextTool.getCurrentURL("accountsAction/accountsAction_queryList.action")); hdpiAccountsList=this.hdpiAccountsService.findListByCriteria(qc, page); HdpiAccounts tempHdpiAccounts = null; String empno = null; for(int i=0;i<hdpiAccountsList.size();i++){ tempHdpiAccounts = hdpiAccountsList.get(i); empno = tempHdpiAccounts.getCreatedBy(); if(empno!=null){ tempHdpiAccounts.setCreatedName(ContextTool.getUserName(empno)); } } if(state!=null&&"radio".equals(state)){ return "radioQueryList"; }else return "queryList"; } /** * 新建申请界面 * @return */ public String newAppUI(){ String orgId = SessionTool.getCurrOrgan().getOrganizationCode(); HttpServletRequest req = ContextTool.getRequest(); req.setAttribute("currUser", SessionTool.getCurrUser().getId()+" "+SessionTool.getCurrUserName()); req.setAttribute("currOrg",ContextTool.getOrgName(orgId)); req.setAttribute("nowDate",new SimpleDateFormat("yyyy-MM-dd").format(new Date())); //hdpiAccounts = new HdpiAccounts(); hdpiAccounts.setEffectiveDateFrom(new Date()); return "newAppUI"; } /** * 保存 and 提交 * @return */ public String addAccounts(){ try { String btnValue=ContextTool.getRequest().getParameter("butValue"); hdpiAccounts.setCreationDate(new Date()); //hdpiAccounts.setCreatedBy(SessionTool.getCurrUser().getId()); if("save".equals(btnValue)){//保存 this.hdpiAccountsService.save(hdpiAccounts); } return SUCCESS; } catch (Exception e) { e.printStackTrace(); return ERROR; } } /** * 查看详情 and 修改界面 * @return */ public String viewAccounts(){ String type=ContextTool.getRequest().getParameter("type"); String orgId = SessionTool.getCurrOrgan().getOrganizationCode(); HttpServletRequest req = ContextTool.getRequest(); req.setAttribute("currUser", SessionTool.getCurrUser().getId()+" "+SessionTool.getCurrUserName()); req.setAttribute("currOrg",ContextTool.getOrgName(orgId)); try { hdpiAccounts=this.hdpiAccountsService.findById(hdpiAccounts.getAccountId()+""); if(hdpiAccounts.getCreatedBy()!=null) hdpiAccounts.setCreatedName(ContextTool.getUserName(hdpiAccounts.getCreatedBy())); return type;//列表明细 }catch (RuntimeException e) { e.printStackTrace(); return ERROR; } catch (Exception e) { e.printStackTrace(); return ERROR; } } /** * 删除 * @return */ public String delAccounts(){ try{ this.hdpiAccountsService.delete(hdpiAccounts.getAccountId()+""); return SUCCESS; }catch(Exception e){ e.printStackTrace(); return ERROR; } } /** * 修改 * @return */ public String modAccounts(){ try { if(hdpiAccounts!=null&&hdpiAccounts.getAccountId()!=null&&!"".equals(hdpiAccounts.getAccountId())){ HdpiAccounts tempHdpiAccounts=this.hdpiAccountsService.findById(hdpiAccounts.getAccountId()+""); tempHdpiAccounts.setAccountCode(hdpiAccounts.getAccountCode()); tempHdpiAccounts.setAccountDesc(hdpiAccounts.getAccountDesc()); tempHdpiAccounts.setAccountCategory(hdpiAccounts.getAccountCategory()); tempHdpiAccounts.setAccountType(hdpiAccounts.getAccountType()); tempHdpiAccounts.setBudgetFlag(hdpiAccounts.getBudgetFlag()); tempHdpiAccounts.setComments(hdpiAccounts.getComments()); tempHdpiAccounts.setEffectiveDateFrom(hdpiAccounts.getEffectiveDateFrom()); tempHdpiAccounts.setEffectiveDateTo(hdpiAccounts.getEffectiveDateTo()); tempHdpiAccounts.setEnableFlag(hdpiAccounts.getEnableFlag()); tempHdpiAccounts.setParentFlag(hdpiAccounts.getParentFlag()); tempHdpiAccounts.setPostFlag(hdpiAccounts.getPostFlag()); tempHdpiAccounts.setLastUpdateDate(new Date()); tempHdpiAccounts.setLastUpdatedBy((SessionTool.getCurrUser().getId())); this.hdpiAccountsServi
评论
    相关推荐
    • java调用kettle的依赖包
      java调用kettle的依赖包。调试代码的过程中一个个找出来的,分享给大家 kettle java 依赖包
    • java调用kettle所需要的jar
      包含java调用kettle脚本所需要的所有的jar包 ,非常简单实用
    • java后台使用kettle的lib文件
      提供给java后台开发,kettle调用类使用,必须依赖kettle的jar文件
    • java调用kettle需要的jar包
      kettle是一个纯java编写的etl工具,同时提供了相关api供java进行调用。速度是很快的10000笔/S速度。本资料提供的是java调用kettle需要的jar包
    • java调用kettle4.2转换实例
      网上找了很多也没有找到,写了个java调用kettle4.2转换实例。望与大家分享。
    • java调用kettle
      java调用kettle
    • java kettle
      java操作kettle,其中涉及到所用的所有包都在里面。
    • kettle集成java+完整jar包
      kettle集成java做数据清洗,执行脚本,外加完整jar下载,一键启动,无需添加任何代码,可以和自己的业务代码结合,亲测可用高效
    • java调用Kettle5.3任务
      综合网上的方案 把转换和作业合成一个方法,并包含完整的测试方法 jar包
    • BBS_system_on_java.rar
      BBS论坛系统由JAVA和JSP实现,开发中涉及JavaBean,JSP和服务器Tomcat5.0.7的设置,数据库用SQL2000。有注册登陆,浏览,发帖 回帖,帖子管理,论坛设置,管理版块,用户管理等模块。