@ -342,10 +358,6 @@ public class CarOwnerCertificateActivity extends AppCompatActivity implements Vi
|
|
342
|
358
|
bitmap = FileUtils.rotateIfRequired(file, bitmap);
|
|
343
|
359
|
bitmap = imageZoom(bitmap);
|
|
344
|
360
|
insertBitmap = bitmap;
|
|
345
|
|
|
|
346
|
|
u_path = SDCardUtil.saveToSdCard(bitmap);
|
|
347
|
|
|
|
348
|
|
subscriber.onNext(u_path);
|
|
349
|
361
|
subscriber.onComplete();
|
|
350
|
362
|
} catch (Exception e) {
|
|
351
|
363
|
e.printStackTrace();
|
|
|
@ -362,7 +374,8 @@ public class CarOwnerCertificateActivity extends AppCompatActivity implements Vi
|
|
362
|
374
|
driving_license_icon.setImageBitmap(insertBitmap);
|
|
363
|
375
|
driving_license_upload_icon.setVisibility(View.GONE);
|
|
364
|
376
|
driving_license_text_view.setVisibility(View.GONE);
|
|
365
|
|
// uploadPic(insertBitmap, u_path); // TODO EditAnswerActivity
|
|
|
377
|
String base64 = bitmapToBase64(insertBitmap);
|
|
|
378
|
uploadPic(base64);
|
|
366
|
379
|
}
|
|
367
|
380
|
|
|
368
|
381
|
@Override
|
|
|
@ -382,4 +395,180 @@ public class CarOwnerCertificateActivity extends AppCompatActivity implements Vi
|
|
382
|
395
|
}
|
|
383
|
396
|
});
|
|
384
|
397
|
}
|
|
|
398
|
|
|
|
399
|
private String bitmapToBase64(Bitmap bitmap) {
|
|
|
400
|
String result = null;
|
|
|
401
|
ByteArrayOutputStream baos = null;
|
|
|
402
|
try {
|
|
|
403
|
if (bitmap != null) {
|
|
|
404
|
baos = new ByteArrayOutputStream();
|
|
|
405
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
|
|
406
|
baos.flush();
|
|
|
407
|
baos.close();
|
|
|
408
|
byte[] bitmapBytes = baos.toByteArray();
|
|
|
409
|
result = Base64.encodeToString(bitmapBytes, Base64.NO_WRAP);
|
|
|
410
|
}
|
|
|
411
|
} catch (IOException e) {
|
|
|
412
|
e.printStackTrace();
|
|
|
413
|
} finally {
|
|
|
414
|
try {
|
|
|
415
|
if (baos != null) {
|
|
|
416
|
baos.flush();
|
|
|
417
|
baos.close();
|
|
|
418
|
}
|
|
|
419
|
} catch (IOException e) {
|
|
|
420
|
e.printStackTrace();
|
|
|
421
|
}
|
|
|
422
|
}
|
|
|
423
|
return result;
|
|
|
424
|
}
|
|
|
425
|
|
|
|
426
|
private void uploadPic(final String base64) {
|
|
|
427
|
driving_license_info.setVisibility(View.VISIBLE);
|
|
|
428
|
if (base64 == null) {
|
|
|
429
|
return;
|
|
|
430
|
}
|
|
|
431
|
drivingLicenseBase64Data = "data:image/png;base64," + base64;
|
|
|
432
|
insertDialog.setMessage("正在识别行驶证");
|
|
|
433
|
insertDialog.show();
|
|
|
434
|
long appTime = System.currentTimeMillis() / 1000;
|
|
|
435
|
long updateTime = appTime - MainMapActivity.cha - 1;
|
|
|
436
|
String token = null;
|
|
|
437
|
try {
|
|
|
438
|
token = URLEncoder.encode(DES3.encode(String.valueOf(updateTime)));
|
|
|
439
|
} catch (Exception e) {
|
|
|
440
|
e.printStackTrace();
|
|
|
441
|
}
|
|
|
442
|
|
|
|
443
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/car/ocr";
|
|
|
444
|
OkHttpUtils.post().url(url).addParams("Base64Data", drivingLicenseBase64Data).addParams("Category", "driving").addParams("token", token)
|
|
|
445
|
.build().execute(new StringCallback() {
|
|
|
446
|
@Override
|
|
|
447
|
public void onError(Call call, Exception e) {
|
|
|
448
|
insertDialog.dismiss();
|
|
|
449
|
e.printStackTrace();
|
|
|
450
|
ToastUtil.showToast(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT);
|
|
|
451
|
}
|
|
|
452
|
|
|
|
453
|
@Override
|
|
|
454
|
public void onResponse(String response) {
|
|
|
455
|
insertDialog.dismiss();
|
|
|
456
|
// {"Code":0,"Message":"成功","RequestId":"F84FF659-1D65-48E1-8C12-B253CEFCC4F8","Data":{"plate_num":"京Q52DR5","vehicle_type":"小型轿车","owner":"北京一度用车信息科技有限公司","address":"北京市海淀区中关村东路18号1号楼C日609-1","useCharacter":"葙赁","model":"北京牌BJ7000B3D5-BEV","vin":"LNBSCB3F4HD101254","engine_num":"AD33DH03040031","register_date":"20170525","issueDate":"00170525"}}
|
|
|
457
|
String code = JsonUtils.getKeyResult(response, "Code");
|
|
|
458
|
if ("0".equals(code)) {
|
|
|
459
|
String data = JsonUtils.getKeyResult(response, "Data");
|
|
|
460
|
String platNum = JsonUtils.getKeyResult(data, "plate_num");
|
|
|
461
|
String engineNum = JsonUtils.getKeyResult(data, "engine_num");
|
|
|
462
|
String registerDate = JsonUtils.getKeyResult(data, "register_date");
|
|
|
463
|
plate_num.setText(platNum);
|
|
|
464
|
engine_num.setText(engineNum);
|
|
|
465
|
register_date.setText(registerDate);
|
|
|
466
|
} else {
|
|
|
467
|
String message = JsonUtils.getKeyResult(response, "Message");
|
|
|
468
|
ToastUtil.showToast(getApplicationContext(), message, Toast.LENGTH_SHORT);
|
|
|
469
|
}
|
|
|
470
|
}
|
|
|
471
|
});
|
|
|
472
|
}
|
|
|
473
|
|
|
|
474
|
private void addCarOwnerCertification() {
|
|
|
475
|
if (carSeriesEntity == null) {
|
|
|
476
|
ToastUtil.showToast(this, "请添加车型", Toast.LENGTH_SHORT);
|
|
|
477
|
return;
|
|
|
478
|
}
|
|
|
479
|
|
|
|
480
|
// if (drivingLicenseBase64Data == null) {
|
|
|
481
|
// ToastUtil.showToast(this, "请上传行驶证首页" + drivingLicenseType, Toast.LENGTH_SHORT);
|
|
|
482
|
// return;
|
|
|
483
|
// }
|
|
|
484
|
|
|
|
485
|
insertDialog.setMessage("数据提交中");
|
|
|
486
|
insertDialog.show();
|
|
|
487
|
|
|
|
488
|
String url = MainApplication.url + "/zhannew/basic/web/index.php/car/add";
|
|
|
489
|
Map<String, String> map = new HashMap<>();
|
|
|
490
|
map.put("brand_id", carSeriesEntity.getBrandId());
|
|
|
491
|
map.put("brand_name", carSeriesEntity.getBrandName());
|
|
|
492
|
map.put("company_id", carSeriesEntity.getCompanyId());
|
|
|
493
|
map.put("icon", carSeriesEntity.getIcon());
|
|
|
494
|
map.put("series_id", carSeriesEntity.getSeriesId());
|
|
|
495
|
map.put("chexing", carSeriesEntity.getSeriesName());
|
|
|
496
|
if (drivingLicenseBase64Data != null) {
|
|
|
497
|
map.put("license_img1", drivingLicenseBase64Data);
|
|
|
498
|
map.put("plate_number", plate_num.getText().toString().trim());
|
|
|
499
|
map.put("engine_number", engine_num.getText().toString().trim());
|
|
|
500
|
map.put("regdate", register_date.getText().toString().trim());
|
|
|
501
|
}
|
|
|
502
|
map.put("cartype",drivingLicenseType);
|
|
|
503
|
map.put("userid", MainApplication.userId);
|
|
|
504
|
OkHttpUtils.postString().url(url).content(new Gson().toJson(map)).mediaType(MediaType.parse("application/json; charset=utf-8")).build().execute(new StringCallback() {
|
|
|
505
|
@Override
|
|
|
506
|
public void onError(Call call, Exception e) {
|
|
|
507
|
insertDialog.dismiss();
|
|
|
508
|
e.printStackTrace();
|
|
|
509
|
ToastUtil.showToast(getApplicationContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT);
|
|
|
510
|
}
|
|
|
511
|
|
|
|
512
|
@Override
|
|
|
513
|
public void onResponse(String response) {
|
|
|
514
|
insertDialog.dismiss();
|
|
|
515
|
// {"Code":0,"Message":"成功","RequestId":"F84FF659-1D65-48E1-8C12-B253CEFCC4F8","Data":{"plate_num":"京Q52DR5","vehicle_type":"小型轿车","owner":"北京一度用车信息科技有限公司","address":"北京市海淀区中关村东路18号1号楼C日609-1","useCharacter":"葙赁","model":"北京牌BJ7000B3D5-BEV","vin":"LNBSCB3F4HD101254","engine_num":"AD33DH03040031","register_date":"20170525","issueDate":"00170525"}}
|
|
|
516
|
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
|
|
|
517
|
if ("01".equals(rtnCode)) {
|
|
|
518
|
ToastUtil.showToast(getApplicationContext(), "数据提交成功", Toast.LENGTH_SHORT);
|
|
|
519
|
finish();
|
|
|
520
|
} else {
|
|
|
521
|
String message = JsonUtils.getKeyResult(response, "Message");
|
|
|
522
|
ToastUtil.showToast(getApplicationContext(), message, Toast.LENGTH_SHORT);
|
|
|
523
|
}
|
|
|
524
|
}
|
|
|
525
|
});
|
|
|
526
|
}
|
|
|
527
|
|
|
|
528
|
@Override
|
|
|
529
|
public void onPermissionsGranted(int requestCode, List<String> perms) {
|
|
|
530
|
|
|
|
531
|
}
|
|
|
532
|
|
|
|
533
|
@Override
|
|
|
534
|
public void onPermissionsDenied(int requestCode, List<String> perms) {
|
|
|
535
|
|
|
|
536
|
}
|
|
|
537
|
|
|
|
538
|
@Override
|
|
|
539
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
|
540
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
541
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
|
|
542
|
}
|
|
|
543
|
|
|
|
544
|
@AfterPermissionGranted(RC_ALBUM_PERM)
|
|
|
545
|
public void permissionTask() {
|
|
|
546
|
if (isPermissionOK()) {
|
|
|
547
|
Matisse.from(CarOwnerCertificateActivity.this)
|
|
|
548
|
.choose(MimeType.of(MimeType.JPEG, MimeType.PNG))
|
|
|
549
|
.showSingleMediaType(true)
|
|
|
550
|
.countable(true)
|
|
|
551
|
.maxSelectable(1)
|
|
|
552
|
.capture(true)
|
|
|
553
|
.captureStrategy(new CaptureStrategy(true, "com.electric.chargingpile.provider"))
|
|
|
554
|
.imageEngine(new GlideEngine())
|
|
|
555
|
.forResult(REQUEST_CODE_CHOOSE);
|
|
|
556
|
} else {
|
|
|
557
|
EasyPermissions.requestPermissions(
|
|
|
558
|
this, "充电桩想要获取您的图片读取权限,是否允许?",
|
|
|
559
|
RC_ALBUM_PERM,
|
|
|
560
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
|
561
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
562
|
Manifest.permission.CAMERA
|
|
|
563
|
);
|
|
|
564
|
}
|
|
|
565
|
}
|
|
|
566
|
|
|
|
567
|
private boolean isPermissionOK() {
|
|
|
568
|
return EasyPermissions.hasPermissions(this,
|
|
|
569
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
|
|
570
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
571
|
Manifest.permission.CAMERA
|
|
|
572
|
);
|
|
|
573
|
}
|
|
385
|
574
|
}
|
|
|
@ -74,8 +74,8 @@ public class MainApplication extends MultiDexApplication {
|
|
74
|
74
|
public static String firstPoint = "";
|
|
75
|
75
|
public static Boolean firstSsyd;
|
|
76
|
76
|
public static String password = "";
|
|
77
|
|
// public static String url = "http://59.110.68.162";// 充电桩测试环境
|
|
78
|
|
public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
|
|
|
77
|
public static String url = "http://59.110.68.162";// 充电桩测试环境
|
|
|
78
|
// public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
|
|
79
|
79
|
// public static String urlNew = "http://123.56.67.7:83/api/0300";// 一电测试环境
|
|
80
|
80
|
public static String urlNew = "https://api.touchev.com:83/api/0300";// 一电正式环境
|
|
81
|
81
|
public static String pic_url = "http://cdz.evcharge.cc/zhannew/uploadfile/";
|
|
|
@ -1,14 +1,14 @@
|
|
1
|
1
|
package com.electric.chargingpile.entity;
|
|
2
|
2
|
|
|
3
|
3
|
public class CarSeriesEntity {
|
|
4
|
|
private int brandId;
|
|
|
4
|
private String brandId;
|
|
5
|
5
|
private String brandName;
|
|
6
|
|
private int companyId;
|
|
7
|
|
private int seriesId;
|
|
|
6
|
private String companyId;
|
|
|
7
|
private String seriesId;
|
|
8
|
8
|
private String seriesName;
|
|
9
|
9
|
private String icon;
|
|
10
|
10
|
|
|
11
|
|
public CarSeriesEntity(int brandId, String brandName, int companyId, int seriesId, String seriesName, String icon) {
|
|
|
11
|
public CarSeriesEntity(String brandId, String brandName, String companyId, String seriesId, String seriesName, String icon) {
|
|
12
|
12
|
this.brandId = brandId;
|
|
13
|
13
|
this.brandName = brandName;
|
|
14
|
14
|
this.companyId = companyId;
|
|
|
@ -17,11 +17,11 @@ public class CarSeriesEntity {
|
|
17
|
17
|
this.icon = icon;
|
|
18
|
18
|
}
|
|
19
|
19
|
|
|
20
|
|
public int getBrandId() {
|
|
|
20
|
public String getBrandId() {
|
|
21
|
21
|
return brandId;
|
|
22
|
22
|
}
|
|
23
|
23
|
|
|
24
|
|
public void setBrandId(int brandId) {
|
|
|
24
|
public void setBrandId(String brandId) {
|
|
25
|
25
|
this.brandId = brandId;
|
|
26
|
26
|
}
|
|
27
|
27
|
|
|
|
@ -33,19 +33,19 @@ public class CarSeriesEntity {
|
|
33
|
33
|
this.brandName = brandName;
|
|
34
|
34
|
}
|
|
35
|
35
|
|
|
36
|
|
public int getCompanyId() {
|
|
|
36
|
public String getCompanyId() {
|
|
37
|
37
|
return companyId;
|
|
38
|
38
|
}
|
|
39
|
39
|
|
|
40
|
|
public void setCompanyId(int companyId) {
|
|
|
40
|
public void setCompanyId(String companyId) {
|
|
41
|
41
|
this.companyId = companyId;
|
|
42
|
42
|
}
|
|
43
|
43
|
|
|
44
|
|
public int getSeriesId() {
|
|
|
44
|
public String getSeriesId() {
|
|
45
|
45
|
return seriesId;
|
|
46
|
46
|
}
|
|
47
|
47
|
|
|
48
|
|
public void setSeriesId(int seriesId) {
|
|
|
48
|
public void setSeriesId(String seriesId) {
|
|
49
|
49
|
this.seriesId = seriesId;
|
|
50
|
50
|
}
|
|
51
|
51
|
|
|
|
@ -0,0 +1,65 @@
|
|
|
1
|
package com.electric.chargingpile.util;
|
|
|
2
|
|
|
|
3
|
/**
|
|
|
4
|
* Base64 工具类
|
|
|
5
|
*/
|
|
|
6
|
public class Base64Util {
|
|
|
7
|
private static final char last2byte = (char) Integer.parseInt("00000011", 2);
|
|
|
8
|
private static final char last4byte = (char) Integer.parseInt("00001111", 2);
|
|
|
9
|
private static final char last6byte = (char) Integer.parseInt("00111111", 2);
|
|
|
10
|
private static final char lead6byte = (char) Integer.parseInt("11111100", 2);
|
|
|
11
|
private static final char lead4byte = (char) Integer.parseInt("11110000", 2);
|
|
|
12
|
private static final char lead2byte = (char) Integer.parseInt("11000000", 2);
|
|
|
13
|
private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
|
|
|
14
|
|
|
|
15
|
public Base64Util() {
|
|
|
16
|
}
|
|
|
17
|
|
|
|
18
|
public static String encode(byte[] from) {
|
|
|
19
|
StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3);
|
|
|
20
|
int num = 0;
|
|
|
21
|
char currentByte = 0;
|
|
|
22
|
|
|
|
23
|
int i;
|
|
|
24
|
for (i = 0; i < from.length; ++i) {
|
|
|
25
|
for (num %= 8; num < 8; num += 6) {
|
|
|
26
|
switch (num) {
|
|
|
27
|
case 0:
|
|
|
28
|
currentByte = (char) (from[i] & lead6byte);
|
|
|
29
|
currentByte = (char) (currentByte >>> 2);
|
|
|
30
|
case 1:
|
|
|
31
|
case 3:
|
|
|
32
|
case 5:
|
|
|
33
|
default:
|
|
|
34
|
break;
|
|
|
35
|
case 2:
|
|
|
36
|
currentByte = (char) (from[i] & last6byte);
|
|
|
37
|
break;
|
|
|
38
|
case 4:
|
|
|
39
|
currentByte = (char) (from[i] & last4byte);
|
|
|
40
|
currentByte = (char) (currentByte << 2);
|
|
|
41
|
if (i + 1 < from.length) {
|
|
|
42
|
currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6);
|
|
|
43
|
}
|
|
|
44
|
break;
|
|
|
45
|
case 6:
|
|
|
46
|
currentByte = (char) (from[i] & last2byte);
|
|
|
47
|
currentByte = (char) (currentByte << 4);
|
|
|
48
|
if (i + 1 < from.length) {
|
|
|
49
|
currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4);
|
|
|
50
|
}
|
|
|
51
|
}
|
|
|
52
|
|
|
|
53
|
to.append(encodeTable[currentByte]);
|
|
|
54
|
}
|
|
|
55
|
}
|
|
|
56
|
|
|
|
57
|
if (to.length() % 4 != 0) {
|
|
|
58
|
for (i = 4 - to.length() % 4; i > 0; --i) {
|
|
|
59
|
to.append("=");
|
|
|
60
|
}
|
|
|
61
|
}
|
|
|
62
|
|
|
|
63
|
return to.toString();
|
|
|
64
|
}
|
|
|
65
|
}
|
|
|
@ -191,6 +191,8 @@
|
|
191
|
191
|
android:layout_width="match_parent"
|
|
192
|
192
|
android:layout_height="wrap_content"
|
|
193
|
193
|
android:layout_marginTop="5dp"
|
|
|
194
|
android:visibility="gone"
|
|
|
195
|
tools:visibility="visible"
|
|
194
|
196
|
android:layout_marginBottom="50dp"
|
|
195
|
197
|
android:orientation="vertical"
|
|
196
|
198
|
app:layout_constraintTop_toBottomOf="@+id/driving_license">
|
|
|
@ -204,12 +206,13 @@
|
|
204
|
206
|
<TextView
|
|
205
|
207
|
android:layout_width="90dp"
|
|
206
|
208
|
android:layout_height="wrap_content"
|
|
207
|
|
android:text="* 车牌号"
|
|
|
209
|
android:text="车牌号"
|
|
208
|
210
|
android:textColor="#0D1120"
|
|
209
|
211
|
android:textSize="14sp"
|
|
210
|
212
|
android:textStyle="bold" />
|
|
211
|
213
|
|
|
212
|
214
|
<EditText
|
|
|
215
|
android:id="@+id/plate_num"
|
|
213
|
216
|
android:layout_width="0dp"
|
|
214
|
217
|
android:layout_height="match_parent"
|
|
215
|
218
|
android:layout_weight="1"
|
|
|
@ -235,12 +238,13 @@
|
|
235
|
238
|
<TextView
|
|
236
|
239
|
android:layout_width="90dp"
|
|
237
|
240
|
android:layout_height="wrap_content"
|
|
238
|
|
android:text="* 发动机号"
|
|
|
241
|
android:text="发动机号"
|
|
239
|
242
|
android:textColor="#0D1120"
|
|
240
|
243
|
android:textSize="14sp"
|
|
241
|
244
|
android:textStyle="bold" />
|
|
242
|
245
|
|
|
243
|
246
|
<EditText
|
|
|
247
|
android:id="@+id/engine_num"
|
|
244
|
248
|
android:layout_width="0dp"
|
|
245
|
249
|
android:layout_height="match_parent"
|
|
246
|
250
|
android:layout_weight="1"
|
|
|
@ -266,17 +270,18 @@
|
|
266
|
270
|
<TextView
|
|
267
|
271
|
android:layout_width="90dp"
|
|
268
|
272
|
android:layout_height="wrap_content"
|
|
269
|
|
android:text="注册时间"
|
|
|
273
|
android:text="注册日期"
|
|
270
|
274
|
android:textColor="#0D1120"
|
|
271
|
275
|
android:textSize="14sp"
|
|
272
|
276
|
android:textStyle="bold" />
|
|
273
|
277
|
|
|
274
|
278
|
<EditText
|
|
|
279
|
android:id="@+id/register_date"
|
|
275
|
280
|
android:layout_width="0dp"
|
|
276
|
281
|
android:layout_height="match_parent"
|
|
277
|
282
|
android:layout_weight="1"
|
|
278
|
283
|
android:background="@null"
|
|
279
|
|
android:hint="请输入有效日期"
|
|
|
284
|
android:hint="请输入注册日期"
|
|
280
|
285
|
android:inputType="text"
|
|
281
|
286
|
android:textColor="#0D1120"
|
|
282
|
287
|
android:textColorHint="#CBCBCB"
|