/webccr/src/com/emis/caesarui/webccr/webccr.java

https://bitbucket.org/sanliou/synccr · Java · 800 lines · 559 code · 125 blank · 116 comment · 19 complexity · 0fdeb69bd10710737787f2207a87e982 MD5 · raw file

  1. package com.emis.caesarui.webccr;
  2. import com.emis.caesar.emisComponents;
  3. import com.emis.caesar.emisUI;
  4. import com.emis.caesar.emisUILoader;
  5. import com.emis.caesar.senao.unit.TCcr;
  6. import com.emis.caesar.senao.util.CcrUtil;
  7. import com.emis.caesar.senao.util.UU2Util;
  8. import com.emis.caesarui.webccr.button.TDynBtnFactory;
  9. import com.emis.caesarui.webccr.core.PromotionInfoList;
  10. import com.emis.caesarui.webccr.core.PromotionMgr;
  11. import com.emis.caesarui.webccr.listener.TCcrKeyPressHandler;
  12. import com.emis.caesarui.webccr.printer.emisPrinter;
  13. import com.emis.caesarui.webccr.printer.emisPrinterFactory;
  14. import com.emis.caesarui.webccr.ui.table.TSalePayTable;
  15. import com.emis.caesarui.webccr.ui.table.TSalesTable;
  16. import com.emis.db.emisProp;
  17. import com.emis.servlet.jQueryServlet;
  18. import com.emis.user.emisAuthFactory;
  19. import com.emis.util.emisUtil;
  20. import com.vaadin.annotations.Theme;
  21. import com.vaadin.annotations.VaadinServletConfiguration;
  22. import com.vaadin.event.FieldEvents;
  23. import com.vaadin.event.LayoutEvents;
  24. import com.vaadin.server.VaadinRequest;
  25. import com.vaadin.server.VaadinService;
  26. import com.vaadin.server.WrappedSession;
  27. import com.vaadin.shared.communication.PushMode;
  28. import com.vaadin.ui.*;
  29. import com.vaadin.ui.Window.CloseEvent;
  30. import com.vaadin.ui.Window.CloseListener;
  31. import de.steinwedel.messagebox.ButtonOption;
  32. import de.steinwedel.messagebox.MessageBox;
  33. import elemental.json.JsonArray;
  34. import javax.servlet.annotation.WebServlet;
  35. import java.util.HashMap;
  36. @SuppressWarnings("serial")
  37. @Theme("caesar")
  38. public class webccr extends emisUI {
  39. @WebServlet(value = {"/webccr/*"}, asyncSupported = true)
  40. @VaadinServletConfiguration(productionMode = true, ui = webccr.class)
  41. //public static class Servlet extends VaadinServlet {
  42. public static class Servlet extends jQueryServlet {
  43. }
  44. // here we define some architecture flag
  45. public static final boolean bDevelopMode = true;
  46. public static final boolean bUseJavaScriptButton = true;
  47. // if it is cloud db mode , you have to use localThreadFilter
  48. public static final boolean bCouldDBMode = true;
  49. /*
  50. * 交易結束後,因為要多按一個 key, 或 5 秒後自動 reset 的機制,這邊需要一個 control flag
  51. */
  52. boolean m_bNewTransactionState = false;
  53. private Label FlSysDate_;//交易日期
  54. private Label FlSysTime_;//時間
  55. private Label FlStoreNo_;//門市
  56. private Label FlIdNo_;//機號
  57. private Label FlInvNo_;//發票號碼
  58. private Label FlSlNo_;//交易序號
  59. private Label FlSaler;//售貨員
  60. private Label FlUID;// 統一編號
  61. private Label FlOwner;// 買受人
  62. private Label FlCsNo;// 經銷商
  63. private Label FlCarryDonate;// 電子發票歸戶
  64. private Label FlInvCount;//發票剩餘張數
  65. private Label FlCcrState;//CCR交易狀態
  66. private Label FlLMSState;//LMS連線狀態
  67. private Label FlTotalAmt;//銷售金額
  68. private Label FlTotalOrderAmt;//客訂金額
  69. private Label FlTotalPayAmt;//應付金額
  70. private Label FlChangeAmt;//未付款(+)/找零(-)
  71. private TextField textField; //畫面輸入框
  72. private Label showMsg; //訊息框
  73. private GridLayout gridBtnTop_;
  74. private GridLayout gridBtnButton_;
  75. private HashMap<Integer, GridLayout> hashMapTop_;
  76. private HashMap<Integer, GridLayout> hashMapButton_;
  77. private HashMap<String, HashMap<String, String>> hashMapAllButtonInfo_ = null;
  78. private Table FTSaleTable;
  79. private Table FTSalePayTable;
  80. VerticalLayout SLDateLayout;
  81. Label SLDateTitleLabel;
  82. boolean m_keyClearState = false;
  83. confirmDlg m_delAllDlg = null;
  84. confirmDlg m_MessageDlg = null;
  85. confirmDlg m_ExitDlg = null;
  86. timeInfoThread bthread;
  87. // backgroundTask bTask;
  88. // some properties
  89. String m_InvKey;
  90. String m_3EINV_AP;
  91. String m_3EINV_ACCOUNT;
  92. String m_3EINV_PASSWD;
  93. String m_PRINTER;
  94. String m_PRINTTYPE;
  95. String m_PRINTPORT;
  96. String m_PRINTPORTCFG;
  97. emisPrinter m_Printer;
  98. private TCcr FoCCR_;
  99. public emisComponents componentWebCcr_ = null;
  100. //會員
  101. Label FlMEM_NAME = null;//會員姓名
  102. Label FlMEM_POINT = null; //會員點數
  103. Label FlMEM_S_CARE = null; //S-Care
  104. Label FlMEM_DOUBLE_AUTH = null; //神腦會員
  105. Label FlMEM_JOINSTORE = null; //綁定門市
  106. Label FlMEM_EMAIL = null; //email
  107. Label FlMEM_ADDRESS = null; //居住區域
  108. Label FlMEM_SEX = null; //性別
  109. Label FlMEM_BIRTHDAY = null; //生日
  110. Label FlMEN_NUMBER = null; //會員手機號碼
  111. private TextArea ANNOUNCEMENT; // 公告訊息
  112. @Override
  113. protected void init(VaadinRequest request) {
  114. if (!super.init(request, true)) {
  115. return;
  116. }
  117. try {
  118. FoCCR_ = (TCcr) emisAuthFactory.getCcr(emisUtil.getServletContext(), VaadinService.getCurrentRequest().getWrappedSession());
  119. } catch (Exception e) {
  120. }
  121. this.getPushConfiguration().setPushMode(PushMode.DISABLED);
  122. // System.out.println("TEST="+this.getPushConfiguration().getPushMode().isEnabled());
  123. getPage().setTitle(FoCCR_.getWEB_TITLE() + FoCCR_.getPage());
  124. FoCCR_.setPage(FoCCR_.getPage() + 1);
  125. emisComponents pointDisc = null;
  126. emisComponents buidCust = null;
  127. emisComponents birthDiscDlg = null;
  128. emisComponents clearCustDlg = null;
  129. emisComponents delAllDlg = null;
  130. emisComponents messageDlg = null;
  131. emisComponents exitDlg = null;
  132. try {
  133. componentWebCcr_ = emisUILoader.load(this, m_config, "webccr");
  134. // pointDisc= emisUILoader.load( this , m_config , "point_discount");
  135. // buidCust = emisUILoader.load( this , m_config , "build_cust");
  136. // birthDiscDlg = emisUILoader.load( this , m_config , "confirmdlg");
  137. // clearCustDlg = emisUILoader.load( this , m_config , "confirmdlg");
  138. delAllDlg = emisUILoader.load(this, m_config, "confirmdlg");
  139. messageDlg = emisUILoader.load(this, m_config, "confirmdlg");
  140. exitDlg = emisUILoader.load(this, m_config, "confirmdlg");
  141. m_delAllDlg = new confirmDlg("", "是否取消交易Y/N ?", delAllDlg, "600px", "420px");
  142. m_MessageDlg = new confirmDlg("", "", messageDlg, "600px", "420px");
  143. m_ExitDlg = new confirmDlg("", "确定离开WebCCR系统?", exitDlg, "600px", "420px");
  144. } catch (Exception e) {
  145. senaolog.error(webccr.class, e);
  146. e.getStackTrace();
  147. return;
  148. }
  149. textField = (TextField) componentWebCcr_.getComponent("inputText");
  150. showMsg = (Label) componentWebCcr_.getComponent("showMsg");
  151. textField.addFocusListener(new FieldEvents.FocusListener() {
  152. @Override
  153. public void focus(FieldEvents.FocusEvent event) {
  154. CcrUtil.setMessage("textField on focus");
  155. }
  156. });
  157. textField.addBlurListener(new FieldEvents.BlurListener() {
  158. @Override
  159. public void blur(FieldEvents.BlurEvent event) {
  160. //只有MESSAGE BOX設定FOCUS時才會設定為唯獨,因為有BUG會莫名其妙的FOCUS
  161. //被拖走,初步懷疑是MESSGEBOX關窗的時候又把FOCUS拉走了,因此在此特別
  162. //判斷若是唯獨狀態,則將FOCUS再拉回來一次
  163. CcrUtil.setMessage(" textField blur event, isReadOnly:"+textField.isReadOnly());
  164. if (textField.isReadOnly()) {
  165. textField.setReadOnly(false);
  166. textField.focus();
  167. }
  168. }
  169. });
  170. //設定按下鍵馬上觸發TEXTCHANGE 按鍵前的值可透過textField.getValue()取得,
  171. //按鍵後的值可透過event.getText()取得
  172. textField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER);
  173. textField.addTextChangeListener(new FieldEvents.TextChangeListener() {
  174. @Override
  175. public void textChange(FieldEvents.TextChangeEvent event) {
  176. String _sLastWord = "";
  177. int _iPos = textField.getCursorPosition();
  178. // System.out.println("current DisplayReset="+FoCCR_.isMainDisplayReset()); //滑鼠游標從0開始算起,當打了一個字就變成1
  179. //判斷主畫面輸入框是否需要清除
  180. // System.out.println("current position=" + _iPos); //滑鼠游標從0開始算起,當打了一個字就變成1
  181. if (_iPos > 0 && FoCCR_.isMainDisplayReset()) {
  182. //檢查目前游標位置要小於等於目前長度
  183. // System.out.println("current value=" +textField.getValue());
  184. // System.out.println("event text=" +event.getText());
  185. // System.out.println("current value length =" + textField.getValue().length());
  186. // System.out.println("event value length =" + event.getText().length());
  187. // System.out.println("lastword=" + _sLastWord);
  188. FoCCR_.setMainDisplayReset(false);//此行不可以放於textField.setValue之後,否則又會觸發一次validator
  189. //計算大小
  190. // int _iCnt = event.getText().length() - textField.getValue().length();
  191. // //如果只差一個字,代表從鍵盤輸入的(目前只能這樣判斷因為不能擷取所有的鍵盤輸入)
  192. // //若剪貼簿跟原字串正好相差一個字,就會有BUG會被清掉...
  193. // if ( _iCnt == 1) {
  194. // if (_iPos <= event.getText().length())
  195. // _sLastWord = event.getText().substring(_iPos - 1, _iPos); // 依據目前游標位置取得輸入的值
  196. // } else if (_iCnt >1 ){ //如果相差字數大於1代表剪貼簿來的
  197. // //取得相差的字數代表剪貼簿貼上的字數,再從游標位置減掉該自數到目前的游標位置
  198. // if (_iPos <= event.getText().length())
  199. // _sLastWord = event.getText().substring(_iPos - _iCnt, _iPos);
  200. // } //如果相差字數=0或小於0代表剪貼簿的字數完全貼上則不做任何處理
  201. // textField.setValue(_sLastWord );
  202. }
  203. }
  204. });
  205. TCcrKeyPressHandler _keyPressHandler = new TCcrKeyPressHandler();
  206. _keyPressHandler.bindComponent(textField, "TextField");
  207. this.addActionHandler(_keyPressHandler);
  208. try {
  209. TDynBtnFactory _oBtnFactory = new TDynBtnFactory(FoCCR_.getStore().getFLDxS_NO(), _keyPressHandler);
  210. this.hashMapTop_ = _oBtnFactory.getHashMapTop_();
  211. this.hashMapButton_ = _oBtnFactory.getHashMapButton_();
  212. this.hashMapAllButtonInfo_ = _oBtnFactory.getHashMapAllButton_();
  213. gridBtnTop_ = (GridLayout) componentWebCcr_.getComponent("gridBtnTop");
  214. gridBtnButton_ = (GridLayout) componentWebCcr_.getComponent("gridBtnButton");
  215. changeButton(0);
  216. changeTopButton(0);
  217. } catch (Exception e) {
  218. MessageBox.createError()
  219. .withCaption("錯誤")
  220. .withMessage("設定有誤,請聯繫資訊人員")
  221. .withWidth("400px")
  222. .withCloseButton(() -> {
  223. // 繼續往下執行
  224. FoCCR_.UInotify.closeWebCcr();
  225. }, ButtonOption.focus())
  226. .open();
  227. return;
  228. }
  229. // table
  230. FTSaleTable = (TSalesTable) componentWebCcr_.getComponent("saleTable");
  231. FTSalePayTable = (TSalePayTable) componentWebCcr_.getComponent("salePayTable");
  232. VerticalLayout _oInfoGrid = (VerticalLayout) componentWebCcr_.getComponent("WEBCCR_LAYOUT");
  233. _oInfoGrid.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
  234. @Override
  235. public void layoutClick(LayoutEvents.LayoutClickEvent event) {
  236. CcrUtil.setMessage("LayoutEvents click");
  237. textField.focus();
  238. }
  239. });
  240. /**上方畫面資料顯示區**/
  241. //交易日期
  242. FlSysDate_ = (Label) componentWebCcr_.getComponent("SYSDATE");
  243. FlSysDate_.setValue(FoCCR_.getSaleDate() + "/" + emisUtil.todayTime(":"));
  244. //系統時間
  245. // FlSysTime_ = (Label) componentWebCcr_.getComponent("SYSTIME");
  246. // FlSysTime_.setValue(emisUtil.todayTime(":"));
  247. //門市
  248. FlStoreNo_ = (Label) componentWebCcr_.getComponent("STORENAME");
  249. // FlStoreNo_.setValue(FoCCR_.getFoStore().getStoreNo()+" "+FoCCR_.getFoStore().getStoreName());
  250. FlStoreNo_.setValue(FoCCR_.getStore().getFLDxS_NO());
  251. //機號
  252. FlIdNo_ = (Label) componentWebCcr_.getComponent("ID_NO");
  253. FlIdNo_.setValue(FoCCR_.getCcrID());
  254. //發票號碼
  255. FlInvNo_ = (Label) componentWebCcr_.getComponent("INVNO");
  256. FlInvNo_.setValue(FoCCR_.getCurrentInvoiceNo());
  257. //交易序號
  258. FlSlNo_ = (Label) componentWebCcr_.getComponent("SL_NO");
  259. FlSlNo_.setValue("");
  260. //售貨員
  261. FlSaler = (Label) componentWebCcr_.getComponent("USER");
  262. FlSaler.setValue("");
  263. //統一編號
  264. FlUID = (Label) componentWebCcr_.getComponent("UID");
  265. FlUID.setValue("");
  266. //買受人
  267. // FlOwner = (Label) componentWebCcr_.getComponent("OWNER");
  268. // FlOwner.setValue("");
  269. //經銷商
  270. FlCsNo = (Label) componentWebCcr_.getComponent("CS_NO");
  271. FlCsNo.setValue("");
  272. // 電子發票歸戶
  273. FlCarryDonate = (Label) componentWebCcr_.getComponent("CARRY_DONATE");
  274. FlCarryDonate.setValue("");
  275. //發票剩餘張數
  276. FlInvCount = (Label) componentWebCcr_.getComponent("INVCOUNT");
  277. FlInvCount.setValue("");
  278. //交易狀態
  279. FlCcrState = (Label) componentWebCcr_.getComponent("CCRSTATE");
  280. FlCcrState.setValue("");
  281. //銷售金額
  282. FlTotalAmt = (Label) componentWebCcr_.getComponent("TOTALAMT");
  283. FlTotalAmt.setValue("");
  284. //客訂金額
  285. FlTotalOrderAmt = (Label) componentWebCcr_.getComponent("TOTALORDERAMT");
  286. FlTotalOrderAmt.setValue("");
  287. //應付金額
  288. FlTotalPayAmt = (Label) componentWebCcr_.getComponent("TOTALPAYAMT");
  289. FlTotalPayAmt.setValue("");
  290. //未付款(+)/找零(-)
  291. FlChangeAmt = (Label) componentWebCcr_.getComponent("CHANGEAMT");
  292. FlChangeAmt.setValue("");
  293. //LMS連線狀態
  294. FlLMSState = (Label) componentWebCcr_.getComponent("LMSSTATE");
  295. //會員
  296. FlMEM_NAME= (Label) componentWebCcr_.getComponent("MEM_NAME");//會員姓名
  297. FlMEM_POINT= (Label) componentWebCcr_.getComponent("MEM_POINT"); //會員點數
  298. // FlMEM_S_CARE= (Label) componentWebCcr_.getComponent("MEM_S_CARE"); //S-Care
  299. FlMEM_DOUBLE_AUTH= (Label) componentWebCcr_.getComponent("MEM_DOUBLE_AUTH"); //神腦會員
  300. FlMEM_JOINSTORE= (Label) componentWebCcr_.getComponent("MEM_JOINSTORE"); //綁定門市
  301. FlMEM_EMAIL= (Label) componentWebCcr_.getComponent("MEM_EMAIL"); //email
  302. FlMEM_ADDRESS= (Label) componentWebCcr_.getComponent("MEM_ADDRESS"); //居住區域
  303. FlMEM_SEX= (Label) componentWebCcr_.getComponent("MEM_SEX"); //性別
  304. FlMEM_BIRTHDAY= (Label) componentWebCcr_.getComponent("MEM_BIRTHDAY"); //生日
  305. FlMEN_NUMBER= (Label) componentWebCcr_.getComponent("MEN_NUMBER"); //會員手機號碼
  306. //公告訊息
  307. ANNOUNCEMENT = (TextArea) componentWebCcr_.getComponent("ANNOUNCEMENT");
  308. ANNOUNCEMENT.setEnabled(false);
  309. m_delAllDlg.addOnConfirmListener(new CCREventListener() {
  310. public void onEvent(Object src) {
  311. reset();
  312. }
  313. });
  314. m_delAllDlg.addCloseListener(new CloseListener() {
  315. public void windowClose(CloseEvent e) {
  316. onSubWindowClose();
  317. }
  318. });
  319. m_MessageDlg.addCloseListener(new CloseListener() {
  320. public void windowClose(CloseEvent e) {
  321. onSubWindowClose();
  322. }
  323. });
  324. m_ExitDlg.addOnConfirmListener(new CCREventListener() {
  325. public void onEvent(Object src) {
  326. try {
  327. emisAuthFactory.logout(m_application, m_session);
  328. close();
  329. emisUtil.setLocation("/esn/login");
  330. } catch (Exception e) {
  331. senaolog.error(webccr.class, e);
  332. }
  333. }
  334. });
  335. m_ExitDlg.addCloseListener(new CloseListener() {
  336. public void windowClose(CloseEvent e) {
  337. onSubWindowClose();
  338. }
  339. });
  340. //JavaScript.getCurrent().execute("window.onbeforeunload = function (e) { var e = e || window.event; aboutToClose(); return '确定离开WebCCR系统?'; };");
  341. // JavaScript.getCurrent().execute(
  342. // "window.onbeforeunload = " +
  343. // "function (e) { return '確定離開WebCCR系统?'; };"
  344. // );
  345. bthread = new timeInfoThread(this);
  346. bthread.start();
  347. // bTask = new backgroundTask(this);
  348. // bTask.start();
  349. this.addDetachListener(new DetachListener() {
  350. // clean the thread ?
  351. public void detach(DetachEvent event) {
  352. CcrUtil.setMessage("Detach called");
  353. if (bthread != null) {
  354. bthread.stopIt();
  355. }
  356. // if (bTask != null) {
  357. // bTask.stopIt();
  358. // }
  359. }
  360. });
  361. //頁面關閉,關閉時間的Thread
  362. JavaScript.getCurrent().addFunction("onClose", new JavaScriptFunction() {
  363. public void call(JsonArray arguments) {
  364. //System.out.println("Detach called");
  365. // senaolog.info(webccr.class, "window onClose called");
  366. CcrUtil.setMessage("window onClose called");
  367. // if( bTask != null ) { bTask.stopIt(); }
  368. if( bthread != null) { bthread.stopIt(); }
  369. }
  370. });
  371. //
  372. JavaScript.getCurrent().addFunction("CloseSession", new JavaScriptFunction() {
  373. public void call(JsonArray arguments) {
  374. try {
  375. WrappedSession session = VaadinService.getCurrentRequest().getWrappedSession();
  376. emisAuthFactory.logout(emisUtil.getServletContext(), session);
  377. } catch (Exception e) {
  378. e.printStackTrace();
  379. }
  380. }
  381. });
  382. JavaScript.getCurrent().execute("window.onbeforeunload = function (e) { e.returnValue = '確定離開WebCCR系统?'; return '確定離開WebCCR系统?'; };");
  383. // JavaScript.getCurrent().execute("window.onunload = function (e) { onClose(); };");
  384. //載入CCR周邊資訊
  385. // emisUtil.getCcrDevice();
  386. //
  387. // 寫入ini
  388. String path = "C:/emis/bin/";
  389. JavaScript.getCurrent().execute(
  390. " var util = new emisUtility(); " +
  391. " var a = '" + FoCCR_.getCcrID() + "'; " +
  392. " var d = '" + path +"CCR.ini';" +
  393. " util.writeStringToUTF8File(d, a);");
  394. //登錄下傳POSAP download/機台 至Local端 20190305 ADD BY DAFF-DWN
  395. CcrUtil.Login_Download(FoCCR_.getCcrID());
  396. senaolog.init(FoCCR_.getStore().getFLDxS_NO(), FoCCR_.getCcrID());
  397. // ANNOUNCEMENT.addStyleName("SenaoMarquee");
  398. // CcrUtil.realMsgRun("ANNOUNCEMENT");
  399. //找出門市可用促銷單
  400. FoCCR_.getPromoHashMap().clear();
  401. FoCCR_.getDbData.getPromoMMStore();
  402. FoCCR_.getDbData.getPromoFIStore();
  403. FoCCR_.getDbData.getPromoSMStore();
  404. textField.focus();
  405. setContent(componentWebCcr_.getRootComponent());
  406. // senaolog.info(login.class, "登入機號="+ FoCCR_.getCcrID());
  407. CcrUtil.setMessage("登入機號="+ FoCCR_.getCcrID());
  408. // 分頁付置問題
  409. if (FoCCR_.getPage() > 1) {
  410. MessageBox.createError()
  411. .withCaption("錯誤")
  412. .withMessage("Webccr頁面超過1頁或重新載入,請確認分頁數。")
  413. .withWidth("400px")
  414. .withCloseButton(() -> {
  415. // 繼續往下執行
  416. FoCCR_.UInotify.closeWebCcr();
  417. }, ButtonOption.focus())
  418. .open();
  419. }
  420. // 登入悠遊卡 連接熱感機才能登入
  421. if (FoCCR_.isEINV()) {
  422. UU2Util uu2 = new UU2Util();
  423. uu2.signOnUUcard();
  424. // 悠遊卡儲值料號取得語法(每個門市有機會不同)
  425. String P_NO = FoCCR_.getDbData.getUU_PNO(FoCCR_.getStore().getFLDxS_NO());
  426. if (!emisUtil.isEmpty(P_NO)) {
  427. FoCCR_.setUU_PNO(P_NO);
  428. }
  429. }
  430. // 福利金料號取得語法
  431. String BENEFIT_PNO = FoCCR_.getDbData.getBENEFIT_PNO(FoCCR_.getStore().getFLDxS_NO());
  432. if (!emisUtil.isEmpty(BENEFIT_PNO)) {
  433. FoCCR_.setBENEFIT_PNO(BENEFIT_PNO);
  434. }
  435. //add by Ares 20181009 HAMIPOINT
  436. // HAMIPOINT折抵料號取得語法
  437. String HAMIPOINT_PNO = FoCCR_.getDbData.getHAMIPOINT_PNO(FoCCR_.getStore().getFLDxS_NO());
  438. if (!emisUtil.isEmpty(HAMIPOINT_PNO)) {
  439. FoCCR_.setHAMIPOINT_PNO(HAMIPOINT_PNO);
  440. }
  441. }
  442. public void changeButton(int page) {
  443. gridBtnButton_.removeComponent(0, 0);
  444. gridBtnButton_.addComponent((GridLayout) hashMapButton_.get(page), 0, 0);
  445. }
  446. public void changeTopButton(int page) {
  447. gridBtnTop_.removeComponent(0, 0);
  448. gridBtnTop_.addComponent((GridLayout) hashMapTop_.get(page), 0, 0);
  449. }
  450. protected void getCCRParameters() {
  451. try {
  452. HashMap m = emisProp.getProps(m_User, "INVKEY,3EINV_AP,3EINV_ACCOUNT,3EINV_PASSWD");
  453. m_InvKey = (String) m.get("INVKEY");
  454. m_3EINV_AP = (String) m.get("3EINV_AP");
  455. m_3EINV_ACCOUNT = (String) m.get("3EINV_ACCOUNT");
  456. m_3EINV_PASSWD = (String) m.get("3EINV_PASSWD");
  457. } catch (Exception e) {
  458. senaolog.error(webccr.class, e);
  459. }
  460. try {
  461. HashMap m = emisProp.getCCRProps(m_User, "PRINTER,PRINTTYPE,PRINTPORT,PRINTPORTCFG");
  462. m_PRINTER = (String) m.get(m_User.getID_NO() + ".PRINTER");
  463. m_PRINTTYPE = (String) m.get(m_User.getID_NO() + ".PRINTTYPE");
  464. m_PRINTPORT = (String) m.get(m_User.getID_NO() + ".PRINTPORT");
  465. m_PRINTPORTCFG = (String) m.get(m_User.getID_NO() + ".PRINTPORTCFG");
  466. } catch (Exception e) {
  467. senaolog.error(webccr.class, e);
  468. }
  469. System.out.println("Printer:" + m_PRINTER + "," + m_PRINTTYPE + "," + m_PRINTPORT + "," + m_PRINTPORTCFG);
  470. m_Printer = emisPrinterFactory.getPrinter(m_PRINTER);
  471. m_Printer.setConfig(m_PRINTTYPE, m_PRINTPORT, m_PRINTPORTCFG);
  472. }
  473. public void reset() {
  474. //SaleTransaction ccr = (SaleTransaction) src;
  475. System.out.println("webccr.reset");
  476. m_keyClearState = false;
  477. SLDateLayout.removeStyleName("alert_labelLayoutStyle");
  478. SLDateTitleLabel.removeStyleName("alert_labelstyle");
  479. SLDateLayout.addStyleName("labelLayoutStyle");
  480. SLDateTitleLabel.addStyleName("labelstyle");
  481. SLDateTitleLabel.setValue("交易日期");
  482. }
  483. private void onSubWindowClose() {
  484. // textField.focus();
  485. }
  486. // CLS , 清除
  487. public void clear() {
  488. setInput("");
  489. // messageLabel.setValue("");
  490. FlTotalAmt.setValue("");
  491. FlTotalOrderAmt.setValue("");
  492. FlTotalPayAmt.setValue("");
  493. FlChangeAmt.setValue("");
  494. m_keyClearState = false;
  495. }
  496. private void printhashMapAllButtonInfo() {
  497. HashMap<String, String> mapBtn = null;
  498. for (Object key1 : hashMapAllButtonInfo_.keySet()) {
  499. mapBtn = hashMapAllButtonInfo_.get(key1);
  500. System.out.println("--- " + key1 + " ---");
  501. for (Object key2 : mapBtn.keySet()) {
  502. System.out.println(key2 + " : " + mapBtn.get(key2));
  503. }
  504. }
  505. }
  506. CCREventListener m_OnTransactionEnd = null;
  507. public void addTransactionEndListener(CCREventListener listener) {
  508. m_OnTransactionEnd = listener;
  509. }
  510. // This is called by background thread
  511. public void updateTimeInfo() {
  512. if (FlSysDate_ != null) {
  513. FlSysDate_.setValue(FoCCR_.getSaleDate() + "/" + emisUtil.todayTime(":"));
  514. // this.push();
  515. }
  516. }
  517. public synchronized boolean IsNewTransactionState() {
  518. if (m_bNewTransactionState) {
  519. m_bNewTransactionState = false;
  520. return true;
  521. }
  522. return false;
  523. }
  524. /*
  525. * 需求, 交易結束後 , 5 秒自動清除
  526. */
  527. public synchronized void clearbyBackground() {
  528. if (IsNewTransactionState()) {
  529. //System.out.println("clearbyBackground");
  530. //m_CurrentSt.reset();
  531. reset();
  532. this.push();
  533. }
  534. }
  535. public emisComponents getComponentWebCcr() {
  536. return componentWebCcr_;
  537. }
  538. public String getInput() {
  539. return this.textField.getValue();
  540. }
  541. public void setInput(String input) {
  542. this.textField.setValue(input);
  543. }
  544. public TCcr getFoCCR() {
  545. return FoCCR_;
  546. }
  547. public Table getFTSaleTable() {
  548. return FTSaleTable;
  549. }
  550. public TextField getInputLabel() {
  551. return textField;
  552. }
  553. public Label getFlSaler() {
  554. return FlSaler;
  555. }
  556. public Label getFlUID() {
  557. return FlUID;
  558. }
  559. public Label getFlOwner() {
  560. return FlOwner;
  561. }
  562. public Label getFlCcrState() {
  563. return FlCcrState;
  564. }
  565. public Label getFlLMSState() {
  566. return FlLMSState;
  567. }
  568. public Table getFTSalePayTable() {
  569. return FTSalePayTable;
  570. }
  571. public Label getFlSysDate() {
  572. return FlSysDate_;
  573. }
  574. public Label getFlStoreNo() {
  575. return FlStoreNo_;
  576. }
  577. public Label getFlIdNo() {
  578. return FlIdNo_;
  579. }
  580. public Label getFlSlNo() {
  581. return FlSlNo_;
  582. }
  583. public Label getFlInvNo() {
  584. return FlInvNo_;
  585. }
  586. public Label getFlInvCount() {
  587. return FlInvCount;
  588. }
  589. public Label getFlTotalAmt() {
  590. return FlTotalAmt;
  591. }
  592. public Label getFlTotalOrderAmt() {
  593. return FlTotalOrderAmt;
  594. }
  595. public Label getFlTotalPayAmt() {
  596. return FlTotalPayAmt;
  597. }
  598. public Label getFlChangeAmt() {
  599. return FlChangeAmt;
  600. }
  601. public GridLayout getGridBtnTop() {
  602. return gridBtnTop_;
  603. }
  604. public GridLayout getGridBtnButton() {
  605. return gridBtnButton_;
  606. }
  607. public HashMap getHashMapTop() {
  608. return hashMapTop_;
  609. }
  610. public HashMap getHashMapButton() {
  611. return hashMapButton_;
  612. }
  613. public HashMap<String, HashMap<String, String>> getHashMapAllButtonInfo_() {
  614. return hashMapAllButtonInfo_;
  615. }
  616. // 取得某一個按鈕的資訊
  617. public HashMap<String, String> getHashMapButtonInfo(String sFP_FUNC_CODE) {
  618. return hashMapAllButtonInfo_.get(sFP_FUNC_CODE);
  619. }
  620. // 公司別先給空白
  621. public PromotionInfoList getPmList() {
  622. try {
  623. return PromotionMgr.getInstance(emisUtil.getServletContext()).
  624. getPromoteList(FoCCR_);
  625. } catch (Exception e) {
  626. senaolog.error(this.getClass(), e);
  627. return null;
  628. }
  629. }
  630. public webccrlog getlog() {
  631. return senaolog;
  632. }
  633. public Label getFlMEM_NAME() {
  634. return FlMEM_NAME;
  635. }
  636. public Label getFlMEM_POINT() {
  637. return FlMEM_POINT;
  638. }
  639. public Label getFlMEM_S_CARE() {
  640. return FlMEM_S_CARE;
  641. }
  642. public Label getFlMEM_DOUBLE_AUTH() {
  643. return FlMEM_DOUBLE_AUTH;
  644. }
  645. public Label getFlMEM_JOINSTORE() {
  646. return FlMEM_JOINSTORE;
  647. }
  648. public Label getFlMEM_EMAIL() {
  649. return FlMEM_EMAIL;
  650. }
  651. public Label getFlMEM_ADDRESS() {
  652. return FlMEM_ADDRESS;
  653. }
  654. public Label getFlMEM_SEX() {
  655. return FlMEM_SEX;
  656. }
  657. public Label getFlMEM_BIRTHDAY() {
  658. return FlMEM_BIRTHDAY;
  659. }
  660. public Label getShowMsg() {
  661. return showMsg;
  662. }
  663. public void setShowMsg(String showMsg) {
  664. this.showMsg.setValue(showMsg);
  665. }
  666. public Label getFlCsNo() {
  667. return FlCsNo;
  668. }
  669. public Label getFlCarryDonate() {
  670. return FlCarryDonate;
  671. }
  672. public Label getFlMEN_NUMBER() {
  673. return FlMEN_NUMBER;
  674. }
  675. }