0 / 0 / 0
Регистрация: 05.06.2022
Сообщений: 4
|
|
|
|
Как проставить дату в начале чека
01.08.2022, 12:59. Показов 362. Ответов 0
Добрый день форумчане,подскажите как в этом коде проставить код так чтобы на печать выводилось дата и время текущая по секундам. ? все перепробывал постоянная ошибка!
| Java | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
| private void printCheck() {
if (isOnline() == false) {
Toast.makeText(this, R.string.no_internet_access, Toast.LENGTH_LONG).show();
} else {
if (validate() == true) {
MaterialDialog dialog = new MaterialDialog.Builder(this)
.title(R.string.attention)
.content(R.string.print_to_check)
.positiveText(R.string.ok)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull final MaterialDialog dialog, @NonNull DialogAction which) {
progresBar();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
Methods methods = new Methods();
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
DateTime date_out = dateTimeFormatter.parseDateTime(dataForPrint.get("created_at").toString());
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
String header = "";
String body = "";
String sum = "";
String footer = "";
String recipient = "";
header = "ГРУЗОПЕРЕВОЗКИ \n" + "ЛОРА - АНДРЕЙ\n" + "г.Астана, ул.Вячеславская 13 (Казгородок) (\n" +
"вьезд с ул.Балочная (стар.Анарская) \n" + "г.Астана +7 701 588 0794 7 701 511 5377 \n" +
"г.Алматы +7 701 599 1429 +7 701 588 9666 \n\n";
printTittle("МИНИМАЛЬНАЯ СУММА ПЕРЕВОЗКИ 2000тг\n");
printTittle("ГРУЗОПЕРЕВОЗКИ \n");
printTittle("ЛОРА - АНДРЕЙ\n");
printTittle("г.Астана вячеславского 11а (2ГИС)\n");
printTittle("проспект Аль-Фараби 11 въезд со стороны \n Ул. Анарской (Яндекс навигатор)\n");
printTittle("+7 701 511 5377 +7 701 588 0794 \n");
printTittle("г.Алматы +7 701 599 1429 +7 701 588 9666 \n\n");
SendDataString("\n");
SendDataString("Код груза: " + PackageDataActivity.this.dataForPrint.get("code"));
SendDataString("\n");
SendDataString("Дата погрузки : " + dateFormat.format(date_out.toDate()));
SendDataString("\n");
if (PackageDataActivity.this.dataForPrint.get("recipient_id") != null) {
SendDataString("Получатель : " + mRecepientList.getSelectedItem());
recipient = "Получатель : " + mRecepientList.getSelectedItem();
} else {
if (PackageDataActivity.this.dataForPrint.get("recipient") != null) {
SendDataString("Получатель : " + PackageDataActivity.this.dataForPrint.get("recipient"));
recipient = "Получатель : " + PackageDataActivity.this.dataForPrint.get("recipient");
}
}
SendDataString("\n");
SendDataString("Количество : " + PackageDataActivity.this.dataForPrint.get("description"));
SendDataString("\n");
if (PackageDataActivity.this.dataForPrint.get("plate_number") != null) {
SendDataString("Номер машины : " + PackageDataActivity.this.dataForPrint.get("plate_number"));
SendDataString("\n");
}
int total = 0;
if (convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_transportation").toString())) != 0) {
total += convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_transportation").toString()));
SendDataString(getResources().getString(R.string.amount_for_transportation) + ": " +
String.valueOf(convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_transportation").toString()))) + " тг\n");
}
/*if (convertToInt(Double.parseDouble(dataForPrint.get("prepayment").toString())) != 0) {
total -= convertToInt(Double.parseDouble(dataForPrint.get("prepayment").toString()));
SendDataString(getResources().getString(R.string.amount_for_prepayment) + ": " +
String.valueOf(convertToInt(Double.parseDouble(dataForPrint.get("prepayment").toString()))) + " тг\n");
}*/
if (convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_delivery").toString())) != 0) {
total += convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_delivery").toString()));
SendDataString(getResources().getString(R.string.sum_money_of_delivery) + ": " +
String.valueOf(convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_delivery").toString()))) + " тг\n");
}
if (convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_load").toString())) != 0) {
total += convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_load").toString()));
SendDataString(getResources().getString(R.string.sum_load) + ": " +
String.valueOf(convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_load").toString()))) + " тг\n");
}
if (convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_unload").toString())) != 0) {
total += convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_unload").toString()));
SendDataString(getResources().getString(R.string.sum_unload) + ": " +
String.valueOf(convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("sum_unload").toString()))) + " тг\n");
}
if (convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("debt").toString())) != 0) {
SendDataString(getResources().getString(R.string.debt_almaty) + ": " +
String.valueOf(convertToInt(Double.parseDouble(PackageDataActivity.this.dataForPrint.get("debt").toString()))) + " тг\n");
}
footer = "\n\nИТОГО ОПЛАЧЕНО " + String.valueOf(total) + "тг\n" + "\nЗвонить через день после погрузки\n" +
"Выдача по квитанции с 08:00 до 13:00 \n" + "Хранение платное 500тг сутки за место\n" +
"Вторник - выходной\n";
printTittle("ИТОГО ОПЛАЧЕНО " + String.valueOf(total) + "тг");
SendDataString("\n");
printTittle("\nЗвонить через день после погрузки\n");
printTittle("Выдача по квитанции с 08:00 до 13:00 \n");
printTittle("Хранение платное 500тг сутки за место\n");
printTittle("Вторник - выходной\n");
SendDataString("\n");
SendDataString("\n");
SendDataString("Информация о прибытии машин в телеграм-канале “LoraAndrey”\n" +
"\n" +
"- после «звонить через день...»");
SendDataString("\n");
SendDataString("\n");
SendDataString("\n");
dismissPogressBar();
}
}, 1000);
}
})
.negativeText(R.string.cancel)
.show();
}
}
}
public void onPawerBluetooth() {
if (!this.mBtAdapter.isEnabled()) {
Intent enableIntent = new Intent(
BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
} else {
if (this.mBtAdapter.isDiscovering()) {
this.mBtAdapter.cancelDiscovery();
}
this.mBtAdapter.startDiscovery();
}
}
private boolean isPrinting = false;
@SuppressLint("HandlerLeak")
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MESSAGE_STATE_CHANGE:
switch (msg.arg1) {
case BluetoothSerialService.STATE_CONNECTED:
if (isPrinting) {
isPrinting = false;
}
break;
case BluetoothSerialService.STATE_CONNECTING:
break;
case BluetoothSerialService.STATE_LISTEN:
case BluetoothSerialService.STATE_NONE:
break;
}
break;
case MESSAGE_WRITE:
break;
case MESSAGE_READ:
break;
case MESSAGE_DEVICE_NAME:
Toast.makeText(getApplicationContext(),
"Connected to printer",
Toast.LENGTH_SHORT).show();
break;
case MESSAGE_TOAST:
Toast.makeText(getApplicationContext(),
msg.getData().getString(TOAST), Toast.LENGTH_SHORT)
.show();
break;
case MESSAGE_CONNECTION_LOST:
Toast.makeText(getApplicationContext(), "Device connection was lost",
Toast.LENGTH_SHORT).show();
break;
case MESSAGE_UNABLE_CONNECT:
Toast.makeText(getApplicationContext(), "Unable to connect device",
Toast.LENGTH_SHORT).show();
break;
}
}
}; |
|
0
|