Commit 6ba225077374fabd33a8a8b0861b05b968faae48

Authored by liuye
1 parent 70c3e886

feat<central_clearing_system>:开发打印功能

central_clearing_system/ETradeClient.vcxproj.filters
@@ -214,7 +214,7 @@ @@ -214,7 +214,7 @@
214 <Filter>Header Files\mfc_ui</Filter> 214 <Filter>Header Files\mfc_ui</Filter>
215 </ClInclude> 215 </ClInclude>
216 <ClInclude Include="ETradeClient\mfc_ui\pay_dlg.h"> 216 <ClInclude Include="ETradeClient\mfc_ui\pay_dlg.h">
217 - <Filter>Header Files</Filter> 217 + <Filter>Header Files\mfc_ui</Filter>
218 </ClInclude> 218 </ClInclude>
219 </ItemGroup> 219 </ItemGroup>
220 <ItemGroup> 220 <ItemGroup>
@@ -345,7 +345,7 @@ @@ -345,7 +345,7 @@
345 <Filter>Source Files\mfc_ui</Filter> 345 <Filter>Source Files\mfc_ui</Filter>
346 </ClCompile> 346 </ClCompile>
347 <ClCompile Include="ETradeClient\mfc_ui\pay_dlg.cpp"> 347 <ClCompile Include="ETradeClient\mfc_ui\pay_dlg.cpp">
348 - <Filter>Source Files</Filter> 348 + <Filter>Source Files\mfc_ui</Filter>
349 </ClCompile> 349 </ClCompile>
350 </ItemGroup> 350 </ItemGroup>
351 <ItemGroup> 351 <ItemGroup>
central_clearing_system/ETradeClient/browser/async_js_callback_handler.cpp
@@ -32,6 +32,7 @@ namespace HW @@ -32,6 +32,7 @@ namespace HW
32 static const std::string JSON_VAL_CMD_RESET = "reset"; 32 static const std::string JSON_VAL_CMD_RESET = "reset";
33 static const std::string JSON_VAL_CMD_READ = "read"; 33 static const std::string JSON_VAL_CMD_READ = "read";
34 static const std::string JSON_VAL_CMD_WRITE = "write"; 34 static const std::string JSON_VAL_CMD_WRITE = "write";
  35 + static const std::string JSON_VAL_CMD_PRINT = "print";
35 36
36 static const std::string JSON_VAL_ANS_ACTIVATE_ACK = "activate_ack"; 37 static const std::string JSON_VAL_ANS_ACTIVATE_ACK = "activate_ack";
37 static const std::string JSON_VAL_ANS_ACTIVATE_FAILED = "activate_failed"; 38 static const std::string JSON_VAL_ANS_ACTIVATE_FAILED = "activate_failed";
@@ -103,6 +104,8 @@ namespace HW @@ -103,6 +104,8 @@ namespace HW
103 m_hw_cmd_map.insert(JSON_VAL_CMD_WRITE + JSON_VAL_FILEID_DILI_CARD_SERVICE_INFO, new WriteDILICardServiceInfoCmd()); 104 m_hw_cmd_map.insert(JSON_VAL_CMD_WRITE + JSON_VAL_FILEID_DILI_CARD_SERVICE_INFO, new WriteDILICardServiceInfoCmd());
104 m_hw_cmd_map.insert(JSON_VAL_CMD_READ + JSON_VAL_FILEID_BANK_CARD_NUM, new ReadBankCardNumCmd()); 105 m_hw_cmd_map.insert(JSON_VAL_CMD_READ + JSON_VAL_FILEID_BANK_CARD_NUM, new ReadBankCardNumCmd());
105 m_hw_cmd_map.insert(JSON_VAL_CMD_READ + JSON_VAL_FILEID_DILI_CARD_AND_BANK, new ReadDILIAndBankCardNumCmd()); 106 m_hw_cmd_map.insert(JSON_VAL_CMD_READ + JSON_VAL_FILEID_DILI_CARD_AND_BANK, new ReadDILIAndBankCardNumCmd());
  107 +
  108 + m_hw_cmd_map.insert(std::string(JSON_VAL_CMD_PRINT), new StylusPrinterCmd());
106 } 109 }
107 std::string HandleRequest(const std::string& request_json) 110 std::string HandleRequest(const std::string& request_json)
108 { 111 {
@@ -115,12 +118,6 @@ namespace HW @@ -115,12 +118,6 @@ namespace HW
115 LOG_TRACE(L"执行硬件调用请求:" + str_2_wstr("[" + hw_req.cmd + "," + hw_req.file_id + "," + hw_req.seq + "]")); 118 LOG_TRACE(L"执行硬件调用请求:" + str_2_wstr("[" + hw_req.cmd + "," + hw_req.file_id + "," + hw_req.seq + "]"));
116 HardwareCmd::Reply reply; 119 HardwareCmd::Reply reply;
117 std::string answer = ""; 120 std::string answer = "";
118 - //为测试定制  
119 - /*if (hw_req.cmd == JSON_VAL_CMD_READ && (hw_req.file_id == JSON_VAL_FILEID_DILI_CARD_BASIC_INFO || hw_req.file_id == JSON_VAL_FILEID_BANK_CARD_NUM))  
120 - {  
121 - hw_req.file_id = JSON_VAL_FILEID_DILI_CARD_AND_BANK;  
122 - }*/  
123 - //  
124 121
125 reply = m_hw_cmd_map.at(hw_req.cmd + hw_req.file_id).Execute(hw_req.data); 122 reply = m_hw_cmd_map.at(hw_req.cmd + hw_req.file_id).Execute(hw_req.data);
126 123
central_clearing_system/ETradeClient/hardware/hardware_cmd.cpp
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 #include "ETradeClient/utility/DLBmpManager.h" 20 #include "ETradeClient/utility/DLBmpManager.h"
21 #include "ETradeClient/utility/string_converter.h" 21 #include "ETradeClient/utility/string_converter.h"
22 #include "ETradeClient/utility/DLDes.h" 22 #include "ETradeClient/utility/DLDes.h"
  23 +#include <vector>
23 24
24 namespace StatusCode 25 namespace StatusCode
25 { 26 {
@@ -1256,4 +1257,50 @@ ReadPINPadCmd::Reply ReadDILIAndBankCardNumCmd::Execute(const std::string&amp; input @@ -1256,4 +1257,50 @@ ReadPINPadCmd::Reply ReadDILIAndBankCardNumCmd::Execute(const std::string&amp; input
1256 reply.data.put("verifyCode", card_basic_info.verify_code); 1257 reply.data.put("verifyCode", card_basic_info.verify_code);
1257 1258
1258 return reply; 1259 return reply;
  1260 +}
  1261 +
  1262 +StylusPrinterCmd::Reply StylusPrinterCmd::Execute(const std::string& input)
  1263 +{
  1264 + LOG_TRACE(L"开始打印");
  1265 + Reply reply;
  1266 + CString doc_name;
  1267 + CString statements_no;
  1268 + CString trade_time;
  1269 + CString buyer_name;
  1270 + CString saler_name;
  1271 + CString settlement_clerk;
  1272 + CString total_money;
  1273 +
  1274 + struct CommInfo
  1275 + {
  1276 + CString comm_name;
  1277 + CString price;
  1278 + CString count;
  1279 + CString total_money;
  1280 + };
  1281 + std::vector<CommInfo> comm_vector;
  1282 +
  1283 + do
  1284 + {
  1285 + LOG_TRACE(L"解析打印数据!");
  1286 +
  1287 +
  1288 + } while (0);
  1289 +
  1290 +
  1291 + CPrintDialog dlg(false); //定义打印机对话框
  1292 + dlg.GetDefaults(); //获取打印机默认值
  1293 + CDC dc;
  1294 + dc.Attach(dlg.GetPrinterDC()); //关联打印机
  1295 + dc.StartDoc(L"print"); //开始打印
  1296 +
  1297 + CFont font;
  1298 + font.CreatePointFont(500, L"宋体");
  1299 + dc.SelectObject(&font);
  1300 + dc.TextOut(350, 150, L"长春地利结算单"); //输出内容
  1301 + font.DeleteObject();
  1302 +
  1303 + dc.EndDoc();//结束打印
  1304 +
  1305 + return reply;
1259 } 1306 }
1260 \ No newline at end of file 1307 \ No newline at end of file
central_clearing_system/ETradeClient/hardware/hardware_cmd.h
@@ -95,4 +95,12 @@ public: @@ -95,4 +95,12 @@ public:
95 }; 95 };
96 // 96 //
97 97
  98 +//Õëʽ´òÓ¡»ú½Ó¿Ú
  99 +class StylusPrinterCmd : public HardwareCmd
  100 +{
  101 +public:
  102 + virtual Reply Execute(const std::string& input) override;
  103 +};
  104 +//
  105 +
98 #endif // ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED 106 #endif // ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.cpp
@@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
5 #include "ETradeClient.h" 5 #include "ETradeClient.h"
6 #include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h" 6 #include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h"
7 #include "afxdialogex.h" 7 #include "afxdialogex.h"
8 - 8 +#include "etradeclient/hardware/hardware_cmd.h"
  9 +#include "etradeclient/boost_patch/property_tree/json_parser.hpp"
9 10
10 // PayDlg ¶Ô»°¿ò 11 // PayDlg ¶Ô»°¿ò
11 12
@@ -36,6 +37,7 @@ void PayDlg::DoDataExchange(CDataExchange* pDX) @@ -36,6 +37,7 @@ void PayDlg::DoDataExchange(CDataExchange* pDX)
36 37
37 BEGIN_MESSAGE_MAP(PayDlg, CDialogEx) 38 BEGIN_MESSAGE_MAP(PayDlg, CDialogEx)
38 ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose) 39 ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose)
  40 + ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay)
39 END_MESSAGE_MAP() 41 END_MESSAGE_MAP()
40 42
41 43
@@ -108,3 +110,10 @@ void PayDlg::OnBnClickedPayButtonClose() @@ -108,3 +110,10 @@ void PayDlg::OnBnClickedPayButtonClose()
108 { 110 {
109 CDialogEx::OnCancel(); 111 CDialogEx::OnCancel();
110 } 112 }
  113 +
  114 +
  115 +void PayDlg::OnBnClickedPayButtonPay()
  116 +{
  117 + auto printer_device = StylusPrinterCmd();
  118 + HardwareCmd::Reply reply = printer_device.Execute("");
  119 +}
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.h
@@ -31,4 +31,5 @@ public: @@ -31,4 +31,5 @@ public:
31 void SetCtrlPos(); 31 void SetCtrlPos();
32 afx_msg void OnBnClickedPayButtonClose(); 32 afx_msg void OnBnClickedPayButtonClose();
33 CButton password_button_; 33 CButton password_button_;
  34 + afx_msg void OnBnClickedPayButtonPay();
34 }; 35 };
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
@@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
14 #include "ETradeClient/utility/win_msg_define.h" 14 #include "ETradeClient/utility/win_msg_define.h"
15 #include <vector> 15 #include <vector>
16 #include "pay_dlg.h" 16 #include "pay_dlg.h"
  17 +#include "etradeclient/hardware/hardware_cmd.h"
  18 +#include "etradeclient/boost_patch/property_tree/json_parser.hpp"
17 19
18 20
19 // PlaceOrderDlg ¶Ô»°¿ò 21 // PlaceOrderDlg ¶Ô»°¿ò
@@ -73,6 +75,7 @@ BEGIN_MESSAGE_MAP(PlaceOrderDlg, CDialogEx) @@ -73,6 +75,7 @@ BEGIN_MESSAGE_MAP(PlaceOrderDlg, CDialogEx)
73 ON_COMMAND(ID_ACCELERATOR_DOWN, &PlaceOrderDlg::OnAcceleratorDown) 75 ON_COMMAND(ID_ACCELERATOR_DOWN, &PlaceOrderDlg::OnAcceleratorDown)
74 ON_COMMAND(ID_ACCELERATOR_UP, &PlaceOrderDlg::OnAcceleratorUp) 76 ON_COMMAND(ID_ACCELERATOR_UP, &PlaceOrderDlg::OnAcceleratorUp)
75 ON_WM_SETFOCUS() 77 ON_WM_SETFOCUS()
  78 + ON_BN_CLICKED(IDC_BUTTON_SWIP_CARD, &PlaceOrderDlg::OnBnClickedButtonSwipCard)
76 END_MESSAGE_MAP() 79 END_MESSAGE_MAP()
77 80
78 81
@@ -485,6 +488,8 @@ void PlaceOrderDlg::OnAcceleratorEnter() @@ -485,6 +488,8 @@ void PlaceOrderDlg::OnAcceleratorEnter()
485 488
486 void PlaceOrderDlg::SetCtrlInitData() 489 void PlaceOrderDlg::SetCtrlInitData()
487 { 490 {
  491 + EnableCtrl(false);
  492 +
488 card_edit_.SetWindowTextW(L"8888"); 493 card_edit_.SetWindowTextW(L"8888");
489 494
490 card_edit_.SetCheck(CardNumType); 495 card_edit_.SetCheck(CardNumType);
@@ -819,4 +824,70 @@ void PlaceOrderDlg::EmptyCtrl() @@ -819,4 +824,70 @@ void PlaceOrderDlg::EmptyCtrl()
819 824
820 card_edit_.SetFocus(); 825 card_edit_.SetFocus();
821 card_edit_.SetSel(4, 4); 826 card_edit_.SetSel(4, 4);
822 -}  
823 \ No newline at end of file 827 \ No newline at end of file
  828 +}
  829 +
  830 +void PlaceOrderDlg::OnBnClickedButtonSwipCard()
  831 +{
  832 + auto dili_card_device = ReadDILIAndBankCardNumCmd();
  833 + HardwareCmd::Reply reply = dili_card_device.Execute("");
  834 +
  835 + CString err_msg;
  836 + do
  837 + {
  838 + if (reply.error_code.compare("") != 0)
  839 + {
  840 + err_msg = "¿¨Æ¬Òì³££¡";
  841 + break;
  842 + }
  843 +
  844 + boost::property_tree::ptree card_num_node = reply.data.get_child("chipNo");
  845 + std::string card_num = card_num_node.data();
  846 +
  847 + boost::property_tree::ptree card_type_node = reply.data.get_child("type");
  848 + std::string card_type = card_type_node.data();
  849 +
  850 + if (!GetCardInfo(str_2_wstr(card_num).c_str(), err_msg))
  851 + {
  852 + break;
  853 + }
  854 +
  855 + buyer_card_edit_.SetWindowText(card_info_.card_num);
  856 + buyer_name_edit_.SetWindowText(card_info_.card_name);
  857 +
  858 + EnableCtrl(true);
  859 +
  860 + } while (0);
  861 +
  862 + if (!err_msg.IsEmpty())
  863 + {
  864 + SetErrorMsg(err_msg);
  865 + }
  866 +
  867 +}
  868 +
  869 +
  870 +void PlaceOrderDlg::EnableCtrl(bool is_enable)
  871 +{
  872 + card_edit_.EnableWindow(is_enable);
  873 + comm_num_edit_.EnableWindow(is_enable);
  874 + unit_edit_.EnableWindow(is_enable);
  875 + price_edit_.EnableWindow(is_enable);
  876 + count_edit_.EnableWindow(is_enable);
  877 +
  878 + if (is_enable == false)
  879 + {
  880 + card_edit_.SetWindowTextW(L"8888");
  881 + name_edit_.SetWindowTextW(L"");
  882 + comm_num_edit_.SetWindowTextW(L"");
  883 + comm_name_edit_.SetWindowTextW(L"");
  884 + unit_edit_.SetWindowTextW(L"");
  885 + price_edit_.SetWindowTextW(L"");
  886 + count_edit_.SetWindowTextW(L"");
  887 + }
  888 +}
  889 +
  890 +bool PlaceOrderDlg::GetCardInfo(CString num, CString &err_msg)
  891 +{
  892 + return true;
  893 +}
  894 +
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.h
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 #include "afxbutton.h" 6 #include "afxbutton.h"
7 #include "../utility/win_http.h" 7 #include "../utility/win_http.h"
8 #include "etrade_edit_control.h" 8 #include "etrade_edit_control.h"
  9 +#include <string>
9 10
10 11
11 // PlaceOrderDlg ¶Ô»°¿ò 12 // PlaceOrderDlg ¶Ô»°¿ò
@@ -85,6 +86,16 @@ public: @@ -85,6 +86,16 @@ public:
85 bool GetCardName(CString &num, CString &name); 86 bool GetCardName(CString &num, CString &name);
86 bool GetCommName(CString &num, CString &name); 87 bool GetCommName(CString &num, CString &name);
87 88
  89 + struct CardInfo
  90 + {
  91 + CString card_num;
  92 + CString card_name;
  93 + CString card_type;
  94 + };
  95 +
  96 + CardInfo card_info_;
  97 + bool GetCardInfo(CString num, CString &err_msg);
  98 +
88 afx_msg void OnAcceleratorDown(); 99 afx_msg void OnAcceleratorDown();
89 afx_msg void OnAcceleratorUp(); 100 afx_msg void OnAcceleratorUp();
90 afx_msg void OnSetFocus(CWnd* pOldWnd); 101 afx_msg void OnSetFocus(CWnd* pOldWnd);
@@ -96,4 +107,10 @@ public: @@ -96,4 +107,10 @@ public:
96 CEditBox buyer_card_edit_; 107 CEditBox buyer_card_edit_;
97 CEditBox buyer_name_edit_; 108 CEditBox buyer_name_edit_;
98 CButton swip_card_button_; 109 CButton swip_card_button_;
  110 + afx_msg void OnBnClickedButtonSwipCard();
  111 +
  112 + //std::string card_num_;
  113 + //std::string card_type_;
  114 +
  115 + void EnableCtrl(bool is_enable);
99 }; 116 };