更新ERP资产接口表

//链接ERP库中视图所对应的dblink,数据库用户 // TODO Auto-generated method stub Date date = info.getTransactionDate(); String company = info.getCompanyName(); String deptCode = info.getDeptName(); // //注意界面用 errorLog 保存部门名称 // String deptName = info.getErroLog(); String location = info.getEnterpriseLocation(); String takerName = info.getTakerName(); String takerCode = info.getTakerCode(); String assetNo = info.getAssetNo(); Session session = super.getSession(); //根据资产编号查询 该资产的帐薄 Query queryBookType = session .createSQLQuery("select book_type_code from aol.aol_asset where asset_no=:assetNo"); queryBookType.setParameter("assetNo", assetNo); List listBookType = queryBookType.list(); String bookType = null; if (listBookType.size() > 0) { bookType = (String) listBookType.get(0); } //查询关帐日期 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); CallableStatement statement = session.connection().prepareCall("{?=call zte_gl_period_open_eam(?,?)}"); statement.registerOutParameter(1, Types.VARCHAR); statement.registerOutParameter(2, Types.VARCHAR); statement.registerOutParameter(3, Types.VARCHAR); statement.setString(2, format.format(date)); statement.setString(3, bookType); statement.execute(); String flagReturn = statement.getString(1); if("Y".equals(flagReturn)) { //此月的帐薄打开状态 } else { //此月帐薄已经关闭 throw new Exception("ERP己关账,请重新输入!"); } session.flush(); // session.clear(); //根据部门Code查询部门名称 Query query = session .createSQLQuery("select dept_name from aol_erp_dept where dept_code=:deptCode"); query.setParameter("deptCode", deptCode); List list = query.list(); String deptName = null; if (list.size() > 0) { deptName = (String) list.get(0); } // 更新ERP接口表 StringBuffer erpHql = new StringBuffer("update PersonHandoverInfo set ") // .append(" transactionDate ='"+date+"',") .append(" transactionDate =:date").append( " , companyName ='" + company + "'").append( " , deptName ='" + deptCode + "'").append( " , enterpriseLocation ='" + location + "'").append( " , takerName ='" + takerName + "' ").append( " , takerCode ='" + takerCode + "' ").append( " ,transOpeateFlag ='' ")// 写ERP接口表成功标识 E表示失败,S成功 .append(" where assetNo ='" + assetNo + "'"); // 更新资产信息表 StringBuffer modifyHql = new StringBuffer( "update AolAssetModifylog set ") // .append(" takeDate ='"+date+"',") .append(" takeDate =:date").append( " , companyNo ='" + company + "'").append( " , deptCode ='" + deptCode + "'") // .append(" , deptName ='"+deptName+"'") .append(" , enterpriseLocation ='" + location + "' ").append( " , takerName ='" + takerName + "' ").append( " , takerCode ='" + takerCode + "' ").append( " , segment15 = '2'"); if (deptName != null) { modifyHql.append(" ,deptName ='" + deptName + "' "); } StringBuffer modifyCodition = new StringBuffer("") .append(" where assetNo ='" + info.getAssetNo() + "'"); modifyHql.append(modifyCodition); // 更新资产表 StringBuffer assetHql = new StringBuffer("update AolAsset set ") .append(" deptCode ='" + deptCode + "'") // .append(", deptName ='"+deptName+"'") .append(" , enterpriseLocation ='" + location + "' ").append( " where assetNo ='" + assetNo + "'"); // 更新ERP接口表 Query Erpuery = session.createQuery(erpHql.toString()); Erpuery.setParameter("date", date); Erpuery.executeUpdate(); // 更新资产信息表 Query modifyQuery = session.createQuery(modifyHql.toString()); modifyQuery.setParameter("date", date); modifyQuery.executeUpdate(); // 更新资产表 session.createQuery(assetHql.toString()).executeUpdate(); // this.updateObject(info);

你可能感兴趣的:(更新ERP资产接口表)