如何从ApacheVelocityXML文件导出文本文件?

iqxoj9l9  于 2021-05-16  发布在  Spark
关注(0)|答案(0)|浏览(297)

大家好,我遇到了一个openbravo pos的问题,其中使用了ApacheVelocity,对此我不太了解。我想ApacheVelocityXML文件导出生成文本文件,然后我会附加文件和发送电子邮件工作良好发送但文本文件导出空空空请指导我怎么做,我下面是我的代码。
脚本代码

if (evalScript(0) == null) {
/* 808 */           if (!this.m_bBlindCash) {
/* 809 */             printPayments("Printer.CloseCash");
/*     */           }

/* 811 */           if (this.m_App.isSysOnline() && EmailUtils.getInstance().isConfigured()) {
/* 812 */             String sresource = this.m_dlSystem.getResourceAsXML("Printer.CloseCash.Mail");
/* 813 */             if ("".equals(sresource)) {
/* 814 */               sresource = this.m_dlSystem.getResourceAsXML("Printer.CloseCash");
/*     */             }
/* 816 */             String filename = "CLOSEDCASH_" + this.m_App.getProperties().getHost() + "_" + (new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss")).format(new Date());
/* 817 */             DeviceTicket mail_TP = new DeviceTicket(filename, false);
/* 818 */             TicketParser mail_TTP = new TicketParser(mail_TP, this.m_dlSystem);
/*     */             try {
/* 820 */               ScriptEngine script = ScriptFactory.getScriptEngines("velocity");
/* 821 */               script.put("payments", this.m_PaymentsToClose);
/* 822 */               script.put("config", AppConfig.getInstance());
/* 823 */               script.put("diff", Formats.CURRENCY.formatValue(Double.valueOf(this.m_CashDifference)));
/* 824 */               double cashremain = this.m_CashInDrawer - this.m_CashOut;
/* 825 */               script.put("cashremain", (cashremain != 0.0D) ? Formats.CURRENCY.formatValue(Double.valueOf(cashremain)) : null);
/* 826 */               script.put("daycashout", Formats.CURRENCY.formatValue(Double.valueOf(this.m_CashOut)));
/* 827 */               mail_TTP.printTicket(script.evals(sresource).toString());
/* 828 */               emailPayments(filename);
/* 829 */             } catch (ScriptException|TicketPrinterException e) {
/* 830 */               MessageInf msg = new MessageInf(-33554432, AppLocal.getIntString("message.cannotprintticket"), e);
/* 831 */               msg.show(this);
/*     */             } 
/*     */           } 
/*     */         }

评估脚本代码

private Object evalScript(int evt) {
/* 956 */     String resource = this.m_dlSystem.getResourceAsXML("Script.CloseCash");
/* 957 */     if (resource != null) {
/*     */       try {
/* 959 */         ScriptEngine script = ScriptFactory.getScriptEngine("beanshell");
/* 960 */         script.put("app", this.m_App);
/* 961 */         script.put("payments", (evt != 2) ? this.m_PaymentsToClose : this.m_PaymentsToPartialClose);
/* 962 */         script.put("event", Integer.valueOf(evt));
/* 963 */         script.put("closecash", this);
/* 964 */         return script.eval(resource);
/* 965 */       } catch (ScriptException e) {
/* 966 */         MessageInf msg = new MessageInf(-33554432, AppLocal.getIntString("message.cannotexecute"), e);
/* 967 */         msg.show(this);
/*     */       } 
/*     */     }
/* 970 */     return null;
/*     */   }

电子邮件支付方式

private void emailPayments(String filename) {
/* 317 */     File attachment = new File(System.getProperty("user.home"), filename + ".txt");
/* 318 */     String msg = EmailUtils.getInstance().sendEmail("Closed Cash report from " + this.m_App.getProperties().getHost(), attachment.getAbsolutePath());
/* 319 */     if (msg.equals("SUCCESS")) {
/* 320 */       (new MessageInf(-83886080, "Email send successfully.")).show(this);
/*     */     } else {
/* 322 */       (new MessageInf(-33554432, msg)).show(this);

/*     */     } 
/* 324 */     if (attachment.exists())
/* 325 */       attachment.delete(); 
/*     */   }

控制台消息ide

INFO: Executing static SQL: INSERT INTO draweropened ( NAME, TICKETID) VALUES ('80052e67-f429-4bc3-b49b-0ae7a42a7ba0', 'Administrator')
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
Nov 29, 2020 9:52:21 AM com.openbravo.data.loader.PreparedSentence openExec
INFO: Executing prepared SQL: SELECT CONTENT FROM resources WHERE NAME = ?

导出文本文件空

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题