Admin
2021-04-12 65463f956e67cc0589072e501fb4a3b5e5d4c36a
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
package safeluck.drive.evaluation.util;
 
import android.content.res.Resources;
import android.graphics.PointF;
import android.os.SystemClock;
import android.util.Log;
import android.util.TypedValue;
 
import com.anyun.basecommonlib.MyLog;
import com.anyun.exam.lib.util.ByteUtil;
import com.google.gson.Gson;
import com.safeluck.aykj.utils.BytesUtils;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.security.SecureRandom;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
 
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;
 
import safeluck.drive.evaluation.app;
import safeluck.drive.evaluation.bean.CarModel;
import safeluck.drive.evaluation.bean.GisCarModel;
import safeluck.drive.evaluation.bean.Point;
import safeluck.drive.evaluation.httpmodule.GsonConverterFactory;
 
import static java.lang.Math.cos;
import static java.lang.Math.pow;
import static java.lang.Math.sin;
import static java.lang.Math.toRadians;
 
/**
 * MyApplication2
 * Created by lzw on 2019/3/18. 13:13:42
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class Utils {
    private static final String TAG = "Utils";
    public static float px2dp(float value){
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,value, Resources.getSystem().getDisplayMetrics());
    }
 
 
 
 
 
    /**
     * dp值转像素
     * @param dpValue
     * @return
     */
    public static float dp2Px(int dpValue){
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,dpValue,Resources.getSystem().getDisplayMetrics());
    }
 
    /**
     * 平台协议生成的校验码
     * @param bytes
     * @return
     */
 
    public static byte calCheckCode(byte[] bytes){
        byte checkCode =0;
        // 参与运算的两个值,如果两个相应bit位相同,则结果为0,否则为1。
        for (int i = 0; i < bytes.length; i++) {
            checkCode ^= bytes[i];
        }
 
        return checkCode;
    }
 
    /**
     * 转义
     * 采用Ox7e表示,若校验码、消息头以及消息体中出现0x7e,则要进行转义处理,转义规则定义如下:
     * 0x7e<——>0x7d后紧跟一个0x02;
     * 0x7d<——>0x7d后紧跟一个0x01。
     * @param datas
     * @return
     */
    public static byte[] transferMeaning(byte[] datas){
        byte [] temp = new byte[datas.length*2];
        int y = 0;
        temp[y++] = 0x7e;
        for (int i = 1; i < datas.length-1; i++) {
            if (datas[i] == 0x7E) {
                temp[y++] = 0x7D;
                temp[y++] = 0x02;
            } else if (datas[i] == 0x7D) {
                temp[y++] = 0x7D;
                temp[y++] = 0x01;
            } else {
                temp[y++] = datas[i];
            }
        }
        temp[y++] = 0x7e;
 
        byte[] tranferbytes = new byte[y];
        System.arraycopy(temp,0,tranferbytes,0,y);
        Log.i(TAG,"转义过后:"+ ByteUtil.byte2hex(tranferbytes));
        return tranferbytes;
    }
 
    /**
     *接收消息时:转义还原
     * @param datas
     * @return
     */
    public static byte[] parseMsg(byte[] datas){
        byte[] temp = new byte[datas.length];
        int y =0 ;
        for (int i = 0; i < datas.length; i++) {
            if (datas[i]==0x7d && datas[i+1]==0x02 ){
                temp[y++] = 0x7e;
                i++;
                continue;
            }else if (datas[i]==0x7d && datas[i+1]==0x01 ){
 
                temp[y++] = 0x7d;
                i++;
                continue;
            }else{
                temp[y++] = datas[i];
            }
        }
        return temp;
    }
 
//    public static boolean isDigital(String str) {
//        String regx= "^\\d+";
//        return str.matches(regx);
//    }
 
//    public static void main(String []args){
//        String str   = "EB00020000031420010000000400A5";
////        String str   = "7EEB00020000031420010000000400A5007E";
//        String str1  = "EB000200000314200100000004030D00";
////        String str1  = "7EEB000200000314200100000004030D00D57E";
//        String str2  = "EB000200000314200100000004035000";
//        byte [] dtas=BytesUtils.hexStringToBytes(str);
//        byte checkcode = calCheckCode(dtas);
//        System.out.println(BytesUtils.toHexString(checkcode));
//    }
 
 
 
    public static int[] getRandomInts(int size,int randomMax){
        Random random = new Random();
        int[] a=new int[size];
        int index=0;
 
        while(index<size){
            System.out.println("---------------");
            int temp=random.nextInt(randomMax);
 
            if(temp!=0&&!contains(a,temp)){
                a[index++]=temp;
            }
        }
 
        for(int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
 
 
        return a;
 
    }
 
 
 
    //该方法完成判断temp在a数组中是否包含
//包含返回true
    public static boolean contains(int[] a,int temp){
 
        for(int i=0;i<a.length;i++){
            if(a[i]==temp){
                return true;
            }
        }
 
        return false;
    }
 
 
    public static String getHHmm(){
        String mMonth,mDay,mWay,mHours,mMinute;
        StringBuffer stringBuffer = new StringBuffer();
        Calendar calendar = Calendar.getInstance();
        mMonth = String.valueOf(calendar.get(Calendar.MONTH) + 1);        //获取日期的月
        mDay = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH));      //获取日期的天
        mWay = String.valueOf(calendar.get(Calendar.DAY_OF_WEEK));      //获取日期的星期
 
        /**
         * 如果小时是个位数
         *
         *则在前面价格“0”
         * */
        if (calendar.get(Calendar.HOUR) < 10) {
            mHours = "0" + calendar.get(Calendar.HOUR);
 
        } else {
            mHours = String.valueOf(calendar.get(Calendar.HOUR));
        }
        stringBuffer.append(mHours);
        stringBuffer.append(":");
        /**
         * 如果分钟是个位数
         *
         *则在前面价格“0”
         * */
        if (calendar.get(Calendar.MINUTE) < 10) {
            mMinute = "0" + calendar.get(Calendar.MINUTE);
        } else {
            mMinute = String.valueOf(calendar.get(Calendar.MINUTE));
        }
        stringBuffer.append(mMinute);
        /**
         * 获取星期
         * 并设置出来
         * */
        if ("1".equals(mWay)) {
            mWay = "天";
        } else if ("2".equals(mWay)) {
            mWay = "一";
        } else if ("3".equals(mWay)) {
            mWay = "二";
        } else if ("4".equals(mWay)) {
            mWay = "三";
        } else if ("5".equals(mWay)) {
            mWay = "四";
        } else if ("6".equals(mWay)) {
            mWay = "五";
        } else if ("7".equals(mWay)) {
            mWay = "六";
        }
        return stringBuffer.toString();
    }
 
 
    /**
     * 加密
     * @param datasource byte[]
     * @param password String
     * @return byte[]
     */
    public static  byte[] encrypt(byte[] datasource, String password) {
        try{
            SecureRandom random = new SecureRandom();
            DESKeySpec desKey = new DESKeySpec(password.getBytes());
            //创建一个密匙工厂,然后用它把DESKeySpec转换成
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            SecretKey securekey = keyFactory.generateSecret(desKey);
            //Cipher对象实际完成加密操作
            Cipher cipher = Cipher.getInstance("DES");
            //用密匙初始化Cipher对象
            cipher.init(Cipher.ENCRYPT_MODE, securekey, random);
            //现在,获取数据并加密
            //正式执行加密操作
            return cipher.doFinal(datasource);
        }catch(Throwable e){
            e.printStackTrace();
        }
        return null;
    }    /**
     * 二维码加密
     * @param datasource byte[]
     * @param password String
     * @return byte[]
     */
    public static  byte[] qrencrypt(byte[] datasource, String password) {
        try{
            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            DESKeySpec desKeySpec = new DESKeySpec(password.getBytes());
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            SecretKey securekey = keyFactory.generateSecret(desKeySpec);
            IvParameterSpec desKey = new IvParameterSpec(password.getBytes());
            //创建一个密匙工厂,然后用它把DESKeySpec转换成
            //Cipher对象实际完成加密操作
            //用密匙初始化Cipher对象
            cipher.init(Cipher.ENCRYPT_MODE, securekey, desKey);
            //现在,获取数据并加密
            //正式执行加密操作
            return cipher.doFinal(datasource);
        }catch(Throwable e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 解密
     * @param src byte[]
     * @param password String
     * @return byte[]
     * @throws Exception
     */
    public static byte[] decrypt(byte[] src, String password) throws Exception {
        // DES算法要求有一个可信任的随机数源
        SecureRandom random = new SecureRandom();
        // 创建一个DESKeySpec对象
        DESKeySpec desKey = new DESKeySpec(password.getBytes());
        // 创建一个密匙工厂
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        // 将DESKeySpec对象转换成SecretKey对象
        SecretKey securekey = keyFactory.generateSecret(desKey);
        // Cipher对象实际完成解密操作
        Cipher cipher = Cipher.getInstance("DES");
        // 用密匙初始化Cipher对象
        cipher.init(Cipher.DECRYPT_MODE, securekey, random);
        // 真正开始解密操作
        return cipher.doFinal(src);
    }
 
    public static int parseUnsignedInt(String s, int radix)
            throws NumberFormatException {
        if (s == null)  {
            throw new NumberFormatException("null");
        }
 
        int len = s.length();
        if (len > 0) {
            char firstChar = s.charAt(0);
            if (firstChar == '-') {
                throw new
                        NumberFormatException(String.format("Illegal leading minus sign " +
                        "on unsigned string %s.", s));
            } else {
                if (len <= 5 || // Integer.MAX_VALUE in Character.MAX_RADIX is 6 digits
                        (radix == 10 && len <= 9) ) { // Integer.MAX_VALUE in base 10 is 10 digits
                    return Integer.parseInt(s, radix);
                } else {
                    long ell = Long.parseLong(s, radix);
                    if ((ell & 0xffff_ffff_0000_0000L) == 0) {
                        return (int) ell;
                    } else {
                        throw new
                                NumberFormatException(String.format("String value %s exceeds " +
                                "range of unsigned int.", s));
                    }
                }
            }
        } else {
            throw new NumberFormatException("For input string: \"" + s + "\"");
        }
    }
 
    public static void main(String[] args){
        long longCurrTIme = System.currentTimeMillis()/1000;
        long CurrTIme =  System.currentTimeMillis();
        System.out.println("longCurrTIme="+longCurrTIme);
        System.out.println("intCurrTIme="+CurrTIme);
        int unsignedTime=  parseUnsignedInt(String.valueOf(longCurrTIme),10);
        System.out.println("unsigned int time = "+unsignedTime);
 
 
 
Point p1 = new Point(2.55,1.0);
Point p2 = new Point(1.55,1.0);
        System.out.println(Calc3Point(p1,p2,1.0).toString());
        System.out.println( isDigital("2003233d"));
        System.out.println( isDigital("d2003233"));
        System.out.println( dateToLongSec("20200330101455"));
        Date date = new Date(utc2NetWorkTime("20200330142612"));
 
        System.out.println(date.getTime() );
        System.out.println("date="+formatTimeYYMMDDHHmmSS(date.getTime()) );
 
        System.out.println(        formatTimeYYMMDDHHmmSS(1585578372000L));
        System.out.println(        "============================");
        String utc =utc2NetWorkTimeMillSeconds("20200401014101.400");
        System.out.println(utc );
        String sss ="{\"utc\":\"20200401014101.40\",\"qf\":3,\"coord_x\":-7630.0,\"coord_x_dir\":\"N\",\"coord_y\":16570.0,\"coord_y_dir\":\"E\",\"heading\":90.0,\"pitch\":0.0,\"roll\":0.0,\"sat_num\":14,\"latitude\":33.26948983333333,\"longitude\":120.78270283333333,\"altitude\":58.9666,\"speed\":1.72591488,\"track_ture\":90.0}";
               sss= sss.replaceFirst("[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*",utc);
        System.out.println(String.format("ssss=%s",sss));
 
 
 
        String str = "{\"result\":true,\"data\":{\"server\":\"gps.safeluck.com\",\"port\":\"3301\",\"map_json\":{\"axial\":[0.0,12.0],\"left_front_tire\":[8.0,9.0],\"main_ant\":[-9151.5063,13030.5118],\"right_front_tire\":[20.0,21.0],\"right_rear_tire\":[22.0,23.0],\"name\":\"科二场考车模型\",\"left_rear_tire\":[10.0,11.0],\"type\":\"car\",\"body\":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0],\"point\":[-9149.6063,13033.0768,-9149.9978,13033.3124,-9150.3258,13033.3485,-9150.8341,13032.8985,-9151.7318,13031.6639,-9152.3573,13030.83,-9152.5214,13030.5639,-9152.602,13030.3105,-9150.8053,13032.8843,-9150.6537,13032.7602,-9152.3352,13030.8124,-9152.221,13030.7008,-9152.092,13029.7892,-9151.4638,13029.4333,-9151.2111,13029.568,-9150.9808,13029.8341,-9150.3546,13030.6796,-9149.458,13031.8642,-9149.1611,13032.4276,-9149.2827,13032.7653,-9149.4842,13031.8708,-9149.6176,13031.9937,-9151.0011,13029.8717,-9151.1367,13029.9878]},\"pzh\":\"豫E8000测\"}}";
       System.out.println("http="+parseHttpRsp(str));
 
 
    }
 
 
    public static String parseHttpRsp(String str){
        StringBuilder stringBuilder = new StringBuilder();
 
 
        int begin =0;
        String patternAll = "\\d+\\.[0-9]{1,4}";
        Pattern all = Pattern.compile(patternAll);
        Matcher mall = all.matcher(str);
        int k = 0;
        String pattern111 = "^\\d{1,2}\\.[0]{1}$";
        Pattern pattern1111= Pattern.compile(pattern111);
 
        while (mall.find()){
            String temp=mall.group();
            Matcher mmm = pattern1111.matcher(temp);
            int start =mall.start();
            int end= mall.end();
            if (mmm.matches()){
                String mmmStr = mmm.group();
                String intNumber = mmmStr.substring(0,mmmStr.indexOf("."));
                System.out.println("mmmStr="+mmmStr+" intNumber="+intNumber+" start="+start+"end="+end);
                String bbbb = str.substring(begin,start);
 
 
                stringBuilder.append(bbbb+intNumber);
 
                begin = 0;
                begin+=end;
 
                k++;
 
            }
 
 
        }
        stringBuilder.append(str.substring(begin));
        return stringBuilder.toString();
    }
 
    public static Point Calc3Point(Point p1,Point p2,double L ){
        Point p3 = new Point(0.0,0.0);
        System.out.println(p1.toString()+" "+p2.toString());
        if (isEqual(p1.getX(), p2.getX())) {
            p3.setY( p2.getY());
            if (p2.getY() > p1.getY()) {
                p3.setX(p2.getX() - L);
            } else {
                p3.setX(p2.getX() + L)  ;
            }
            return p3;
        }
        if (isEqual(p1.getY(), p2.getY())) {
            p3.setX(p2.getX());
            if (p2.getX() > p1.getX()) {
                p3.setY(p2.getY()+L);
            } else {
                p3.setY(p2.getY() - L);
            }
            return p3;
        }
 
        double k = (p2.getY() - p1.getY()) / (p2.getX() - p1.getX());
        double b = p1.getY() - k*p1.getX();
 
        double A = 1 + pow(k, 2);
        double B = 2*k*(b - p2.getY()) - 2*p2.getX();
        double C = pow(b - p2.getY(), 2) + pow(p2.getX(), 2) - pow(L,2);
 
        double x3, y3;
 
 
        if (p1.getX() < p2.getX()) {
            x3 = (- B - Math.sqrt(pow(B, 2) - 4*A*C))/(2*A);
        } else {
            x3 = (- B + Math.sqrt(pow(B, 2) - 4*A*C))/(2*A);
        }
        y3 = k * x3 + b;
 
 
        p3.setX(x3);
        p3.setY(y3);
 
        p3 = rotatePoint(p3, p2, 270);
 
 
        return p3;
 
    }
 
    private static boolean isEqual(double a,double b){
        return (Math.abs(a-b)<1e-3);
    }
    public static Point rotatePoint(Point oldPoint,Point centre,double degree){
 
        Point newPoint = new Point(0.0,0.0);
        newPoint.setX(getdouble((oldPoint.getX()-centre.getX())*cos(toRadians(degree)) -
                (oldPoint.getY()-centre.getY())*sin(toRadians(degree)) + centre.getX(),4)) ;
        newPoint.setY(getdouble( (oldPoint.getX()-centre.getX())*sin(toRadians(degree))
                + (oldPoint.getY()-centre.getY())*cos(toRadians(degree)) + centre.getY(),4));
        return newPoint;
    }
 
 
    /**
     * 对double保留几位小数
     */
    public static Double  getdouble(Double d,int reserve) {
 
        BigDecimal b= new BigDecimal(d);
        return b.setScale(reserve, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
 
 
   public static double YawOf(Point p1, Point p2)
    {
        double deg = 0.0;
 
        if (Math.abs(p1.getY() - p2.getY()) <= 1e-3) {
            if (p1.getX() > p2.getX()) {
                deg = 90;
            } else {
                deg = 270;
            }
        } else if (Math.abs(p1.getX() - p2.getX()) <= 1e-3) {
            if (p1.getY() > p2.getY()) {
                deg = 0;
            } else {
                deg = 180;
            }
        } else {
            deg = Math.atan(Math.abs(p1.getX() - p2.getX()) /
                    Math.abs(p1.getY() - p2.getY()));
 
            deg = Math.toDegrees(deg);
 
            if (p1.getX() > p2.getX() &&
                    p1.getY() > p2.getY()) {
 
            } else if (p1.getX() < p2.getX() &&
                    p1.getY() > p2.getY()) {
                deg = 360 - deg;
            } else if (p1.getX() < p2.getX() &&
                    p1.getY() < p2.getY()) {
                deg = 180 + deg;
            } else if (p1.getX() > p2.getX() &&
                    p1.getY() < p2.getY()) {
                deg = 180 - deg;
            }
        }
 
        return deg;
    }
 
    public static String formatTimeYYMMDDHHmmSS(long begin_time) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
        return  simpleDateFormat.format(begin_time);
    }
    public static String formatTimeYYMMDDHHmmSSSSS(long begin_time) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
 
        return  simpleDateFormat.format(begin_time);
    }
 
    public static boolean isDigital(String str){
        String regx = "^[0-9]*$";
        Pattern pattern = Pattern.compile(regx);
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }
    public static boolean isNumber(String str) {
        //采用正则表达式的方式来判断一个字符串是否为数字,这种方式判断面比较全
        //可以判断正负、整数小数
 
        boolean isInt = Pattern.compile("^-?[1-9]\\d*$").matcher(str).find();
        boolean isDouble = Pattern.compile("^-?([1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|0?\\.0+|0)$").matcher(str).find();
 
        return isInt || isDouble;
 
    }
    public static long dateToLongSec(String utc) {
//        MyLog.i("dateToLongSec:"+utc);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = null;
        try {
            date = simpleDateFormat.parse(utc);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (date==null){
//            MyLog.i("dateToLongSec date==null");
            return new Date().getTime();
        }
        return date.getTime()/1000;
    }
 
    public static long  utc2NetWorkTime(String utc){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = null;
        try {
            date = simpleDateFormat.parse(utc);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long utcTime = date.getTime()+8*60*60*1000;
        return utcTime;
    }
    public static String  utc2NetWorkTimeStr(String utc){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        Date date = null;
        try {
            date = simpleDateFormat.parse(utc);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long utcTime = date.getTime()+8*60*60*1000;
        date.setTime(utcTime);
        return simpleDateFormat.format(date);
    }
    public static String  utc2NetWorkTimeMillSeconds(String utcMillSeconds){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss.SSS");
        Date date = null;
        try {
            date = simpleDateFormat.parse(utcMillSeconds);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long utcTime = date.getTime()+8*60*60*1000;
        date.setTime(utcTime);
        return simpleDateFormat.format(date);
    }
 
    public static void zipFolder(String srcFileString,String zipFileString) throws Exception{
        //创建zip
        ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString));
 
        //创建文件
        File file = new File(srcFileString);
        //压缩
        System.out.println("----->"+file.getParent()+"==="+file.getAbsolutePath());
        zipFiles(file.getParent()+File.separator,file.getName(),outZip);
        outZip.finish();
        outZip.close();
    }
 
    /**
     * 压缩文件
     * @param folderString
     * @param fileString
     * @param outZip
     */
    private static void zipFiles(String folderString, String fileString, ZipOutputStream outZip)
    throws Exception{
        System.out.println("folderString="+folderString+ "\n" +
                "fileString:" + fileString + "\n==========================");
        if (outZip == null){
            return;
        }
        File file = new File(folderString + fileString);
        if (file.isFile()){
            ZipEntry zipEntry = new ZipEntry(fileString);
            FileInputStream fileInputStream = new FileInputStream(file);
            outZip.putNextEntry(zipEntry);
            int len = 0;
            byte[] buffer = new byte[1024];
            while ((len=fileInputStream.read(buffer))!=-1){
                outZip.write(buffer,0,len);
            }
            outZip.closeEntry();
        }else{
            //文件夹
            String []fileList = file.list();
            //没有子文件的压缩
            if (fileList.length<=0){
                ZipEntry zipEntry = new ZipEntry(fileString+File.separator);
                outZip.putNextEntry(zipEntry);
                outZip.closeEntry();
            }else{
                for (int i = 0; i < fileList.length; i++) {
                    zipFiles(folderString+fileString+"/",fileList[i],outZip);
                }
            }
        }
 
    }
 
 
    public static List<CarModel> getCarModelData(Point basePoint, List<Integer> axial, List<Point> car){
        List<CarModel> carModelList = new ArrayList<>();
        double C02= (car.get(0).getX()-basePoint.getX())*(car.get(0).getX()-basePoint.getX()) + (car.get(0).getY()-basePoint.getY())*(car.get(0).getY()-basePoint.getY());
        double c0 = Math.sqrt(C02);
        CarModel carModel = new CarModel();
        carModel.setDistance(c0);
        carModel.setAngle(0.0);
        carModelList.add(carModel);
 
        for (int i = 1; i < car.size(); ++i) {
            double dis2 = (car.get(i).getX()-basePoint.getX())*(car.get(i).getX()-basePoint.getX()) + (car.get(i).getY()-basePoint.getY())*(car.get(i).getY()-basePoint.getY());
            double dis = Math.sqrt(dis2);
 
            CarModel c =new CarModel();
            c.setDistance(dis);
 
            c.setAngle(180 * Math.acos((dis2 + C02 - ((car.get(i).getX()-car.get(0).getX())*(car.get(i).getX()-car.get(0).getX()) +
                    (car.get(i).getY()-car.get(0).getY())*(car.get(i).getY()-car.get(0).getY())))/(2*c0*dis)) / Math.PI);
 
            if (i > axial.get(1)){
                c.setAngle( 360.0 - c.getAngle());
            }
            carModelList.add(c);
        }
        return carModelList;
    }
 
    public static List<Point> getCarPoint(double pitch,double yaw,Point point,GisCarModel gisCarModel){
        pitch = 0;
//        yaw = 45;
        Point main_ant = point;
        List<Point> carNew = new ArrayList<>();
//        StringBuffer buffer=FileUtil.readAssetTxtFile(app.getAppContext(),"giscar.json");
//        Log.i(TAG,"giscar="+buffer.toString());
//        GisCarModel gisCarModel= new Gson().fromJson(buffer.toString(),GisCarModel.class);
        List<Point> pointList = new ArrayList<Point>() ;
        for (int i = 0; i < gisCarModel.getPoint().size(); i++) {
                double x= gisCarModel.getPoint().get(i);
                i++;
                double y= gisCarModel.getPoint().get(i);
                pointList.add(new Point(x,y));
 
 
 
        }
        double mainAnt_x = gisCarModel.getMain_ant().get(0);
        double mainAnt_y = gisCarModel.getMain_ant().get(1);
        long pretime = System.currentTimeMillis();
        List<CarModel> carModels = getCarModelData(new Point(mainAnt_x, mainAnt_y),gisCarModel.getAxial(),pointList);
 
        if (carModels != null && carModels.size()>0){
 
            for (int i = 0; i < carModels.size(); ++i) {
//                Log.i(TAG,String.format("位置[%d],distance=%f,angle=%f",i,carModels.get(i).getDistance(),carModels.get(i).getAngle()));
                double qrx = carModels.get(i).getDistance() * Math.sin(carModels.get(i).getAngle() * Math.PI / 180);
                double qry = carModels.get(i).getDistance() * Math.cos(carModels.get(i).getAngle() * Math.PI / 180) * Math.cos(pitch * Math.PI / 180);
 
                double projectDistance = Math.sqrt(Math.pow(qrx, 2) + Math.pow(qry, 2));
                double projectAngle = Math.acos(qry / projectDistance) * 180 / Math.PI;
 
                if (carModels.get(i).getAngle() > 180) {
                    projectAngle = 360 - projectAngle;
                }
 
                double X =
                        projectDistance * Math.sin(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) -
                                projectDistance * Math.cos(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
                                main_ant.getX();
                double Y =
                        projectDistance * Math.sin(yaw * Math.PI / 180) * Math.sin(projectAngle * Math.PI / 180) +
                                projectDistance * Math.cos(yaw * Math.PI / 180) * Math.cos(projectAngle * Math.PI / 180) +
                                main_ant.getY();
                carNew.add(new Point(X,Y));
 
            }
        }
        Log.i(TAG,String.format("getCarModelData 耗时=%d毫秒",System.currentTimeMillis()-pretime));
        return carNew;
 
 
    }
}