Commit 6ba225077374fabd33a8a8b0861b05b968faae48
1 parent
70c3e886
feat<central_clearing_system>:开发打印功能
Showing
8 changed files
with
160 additions
and
10 deletions
central_clearing_system/ETradeClient.vcxproj.filters
... | ... | @@ -214,7 +214,7 @@ |
214 | 214 | <Filter>Header Files\mfc_ui</Filter> |
215 | 215 | </ClInclude> |
216 | 216 | <ClInclude Include="ETradeClient\mfc_ui\pay_dlg.h"> |
217 | - <Filter>Header Files</Filter> | |
217 | + <Filter>Header Files\mfc_ui</Filter> | |
218 | 218 | </ClInclude> |
219 | 219 | </ItemGroup> |
220 | 220 | <ItemGroup> |
... | ... | @@ -345,7 +345,7 @@ |
345 | 345 | <Filter>Source Files\mfc_ui</Filter> |
346 | 346 | </ClCompile> |
347 | 347 | <ClCompile Include="ETradeClient\mfc_ui\pay_dlg.cpp"> |
348 | - <Filter>Source Files</Filter> | |
348 | + <Filter>Source Files\mfc_ui</Filter> | |
349 | 349 | </ClCompile> |
350 | 350 | </ItemGroup> |
351 | 351 | <ItemGroup> | ... | ... |
central_clearing_system/ETradeClient/browser/async_js_callback_handler.cpp
... | ... | @@ -32,6 +32,7 @@ namespace HW |
32 | 32 | static const std::string JSON_VAL_CMD_RESET = "reset"; |
33 | 33 | static const std::string JSON_VAL_CMD_READ = "read"; |
34 | 34 | static const std::string JSON_VAL_CMD_WRITE = "write"; |
35 | + static const std::string JSON_VAL_CMD_PRINT = "print"; | |
35 | 36 | |
36 | 37 | static const std::string JSON_VAL_ANS_ACTIVATE_ACK = "activate_ack"; |
37 | 38 | static const std::string JSON_VAL_ANS_ACTIVATE_FAILED = "activate_failed"; |
... | ... | @@ -103,6 +104,8 @@ namespace HW |
103 | 104 | m_hw_cmd_map.insert(JSON_VAL_CMD_WRITE + JSON_VAL_FILEID_DILI_CARD_SERVICE_INFO, new WriteDILICardServiceInfoCmd()); |
104 | 105 | m_hw_cmd_map.insert(JSON_VAL_CMD_READ + JSON_VAL_FILEID_BANK_CARD_NUM, new ReadBankCardNumCmd()); |
105 | 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 | 110 | std::string HandleRequest(const std::string& request_json) |
108 | 111 | { |
... | ... | @@ -115,12 +118,6 @@ namespace HW |
115 | 118 | LOG_TRACE(L"执行硬件调用请求:" + str_2_wstr("[" + hw_req.cmd + "," + hw_req.file_id + "," + hw_req.seq + "]")); |
116 | 119 | HardwareCmd::Reply reply; |
117 | 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 | 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 | 20 | #include "ETradeClient/utility/DLBmpManager.h" |
21 | 21 | #include "ETradeClient/utility/string_converter.h" |
22 | 22 | #include "ETradeClient/utility/DLDes.h" |
23 | +#include <vector> | |
23 | 24 | |
24 | 25 | namespace StatusCode |
25 | 26 | { |
... | ... | @@ -1256,4 +1257,50 @@ ReadPINPadCmd::Reply ReadDILIAndBankCardNumCmd::Execute(const std::string& input |
1256 | 1257 | reply.data.put("verifyCode", card_basic_info.verify_code); |
1257 | 1258 | |
1258 | 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 | 1307 | \ No newline at end of file | ... | ... |
central_clearing_system/ETradeClient/hardware/hardware_cmd.h
... | ... | @@ -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 | 106 | #endif // ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED | ... | ... |
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.cpp
... | ... | @@ -5,7 +5,8 @@ |
5 | 5 | #include "ETradeClient.h" |
6 | 6 | #include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h" |
7 | 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 | 11 | // PayDlg ¶Ô»°¿ò |
11 | 12 | |
... | ... | @@ -36,6 +37,7 @@ void PayDlg::DoDataExchange(CDataExchange* pDX) |
36 | 37 | |
37 | 38 | BEGIN_MESSAGE_MAP(PayDlg, CDialogEx) |
38 | 39 | ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose) |
40 | + ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay) | |
39 | 41 | END_MESSAGE_MAP() |
40 | 42 | |
41 | 43 | |
... | ... | @@ -108,3 +110,10 @@ void PayDlg::OnBnClickedPayButtonClose() |
108 | 110 | { |
109 | 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
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
... | ... | @@ -14,6 +14,8 @@ |
14 | 14 | #include "ETradeClient/utility/win_msg_define.h" |
15 | 15 | #include <vector> |
16 | 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 | 21 | // PlaceOrderDlg ¶Ô»°¿ò |
... | ... | @@ -73,6 +75,7 @@ BEGIN_MESSAGE_MAP(PlaceOrderDlg, CDialogEx) |
73 | 75 | ON_COMMAND(ID_ACCELERATOR_DOWN, &PlaceOrderDlg::OnAcceleratorDown) |
74 | 76 | ON_COMMAND(ID_ACCELERATOR_UP, &PlaceOrderDlg::OnAcceleratorUp) |
75 | 77 | ON_WM_SETFOCUS() |
78 | + ON_BN_CLICKED(IDC_BUTTON_SWIP_CARD, &PlaceOrderDlg::OnBnClickedButtonSwipCard) | |
76 | 79 | END_MESSAGE_MAP() |
77 | 80 | |
78 | 81 | |
... | ... | @@ -485,6 +488,8 @@ void PlaceOrderDlg::OnAcceleratorEnter() |
485 | 488 | |
486 | 489 | void PlaceOrderDlg::SetCtrlInitData() |
487 | 490 | { |
491 | + EnableCtrl(false); | |
492 | + | |
488 | 493 | card_edit_.SetWindowTextW(L"8888"); |
489 | 494 | |
490 | 495 | card_edit_.SetCheck(CardNumType); |
... | ... | @@ -819,4 +824,70 @@ void PlaceOrderDlg::EmptyCtrl() |
819 | 824 | |
820 | 825 | card_edit_.SetFocus(); |
821 | 826 | card_edit_.SetSel(4, 4); |
822 | -} | |
823 | 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 | #include "afxbutton.h" |
7 | 7 | #include "../utility/win_http.h" |
8 | 8 | #include "etrade_edit_control.h" |
9 | +#include <string> | |
9 | 10 | |
10 | 11 | |
11 | 12 | // PlaceOrderDlg ¶Ô»°¿ò |
... | ... | @@ -85,6 +86,16 @@ public: |
85 | 86 | bool GetCardName(CString &num, CString &name); |
86 | 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 | 99 | afx_msg void OnAcceleratorDown(); |
89 | 100 | afx_msg void OnAcceleratorUp(); |
90 | 101 | afx_msg void OnSetFocus(CWnd* pOldWnd); |
... | ... | @@ -96,4 +107,10 @@ public: |
96 | 107 | CEditBox buyer_card_edit_; |
97 | 108 | CEditBox buyer_name_edit_; |
98 | 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 | }; | ... | ... |