fix
Helius
2021-07-15 f69fd42a3ae2d11713dcd284ae3db57e449ae6dd
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
774
775
776
777
778
779
780
781
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.xzx.gc.GcOrderApplication;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.constant.OrderEnum;
import com.xzx.gc.common.constant.UserEnum;
import com.xzx.gc.common.dto.gdmap.GdGEODto;
import com.xzx.gc.common.utils.BusinessUtil;
import com.xzx.gc.common.utils.IdUtils;
import com.xzx.gc.common.utils.RandomUtil;
import com.xzx.gc.common.utils.SpringUtil;
import com.xzx.gc.common.utils.gdmap.GdMapUtil;
import com.xzx.gc.common.utils.gdmap.GdTraceUtil;
import com.xzx.gc.entity.*;
import com.xzx.gc.model.order.FenceDto;
import com.xzx.gc.model.user.AccountVo;
import com.xzx.gc.order.dto.OrderCustomDto;
import com.xzx.gc.order.mapper.*;
import com.xzx.gc.order.service.*;
import com.xzx.order.RandomValue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
 
 
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {GcOrderApplication.class})
@ActiveProfiles("dev")
public class SpringTest {
 
    @Autowired
    private UserMapper userMapper;
 
    @Autowired
    private ConfigService configService;
 
    @Autowired
    private OrderStorageInfoMapper orderStorageInfoMapper;
 
    @Autowired
    private OrderStorageInfoInsertMapper orderStorageInfoInsertMapper;
 
    @Autowired
    private OrderStorageDetailMapper orderStorageDetailMapper;
 
    @Autowired
    private OrderDetailMapper orderDetailMapper;
 
    @Autowired
    private OrderDetailInsertMapper orderDetailInsertMapper;
 
 
    @Autowired
    private OrderItemInfoMapper orderItemInfoMapper;
 
 
    @Autowired
    private AccountMapper accountMapper;
 
    @Autowired
    private AddressMapper addressMapper;
 
    @Autowired
    private AddressLevelService addressLevelService;
 
    @Autowired
    private OrderService orderService;
 
    @Autowired
    private OrderMapper orderMapper;
 
    @Autowired
    private OrderInsertMapper orderInsertMapper;
 
    @Autowired
    private AddressInsertMapper addressInsertMapper;
 
    @Autowired
    private UserInsertMapper userInsertMapper;
 
    @Autowired
    private AccountInsertMapper accountInsertMapper;
 
    @Autowired
    private AddressService addressService;
 
    @Autowired
    private OrderItemInfoInsertMapper orderItemInfoInsertMapper;
 
    @Autowired
    private SysEnvironmentalInfoService sysEnvironmentalInfoService;
 
    @Autowired
    private FenceMapper fenceMapper;
 
    @Autowired
    private UserService userService;
 
    @Autowired
    private OtherUserService otherUserService;
 
 
    @Autowired
    private IdUtils idUtils;
 
    @Autowired
    private BusinessUtil businessUtil;
 
    @Autowired
    private PartnerGaodeService partnerGaodeService;
 
    @Autowired
    private OrderComplaintService orderComplaintService;
 
    @Autowired
    private PartnerTraceService partnerTraceService;
 
    @Autowired
    private FenceService fenceService;
 
    @Test
    public void 初始化报表(){
//        PartnerGaode byTownId = partnerGaodeService.findByTownId("1813");
//        System.out.println(byTownId.getId());
//        List<OrderComplaint> complaints = orderComplaintService.findPartner();
//        List<List<OrderComplaint>> complaintByTime = CollUtils.groupByField(complaints, "createTime");
 
    }
 
    @Test
    public void checkFence(){
        FenceDto fence = fenceService.getFence("1818", false, "112.939038", "28.165681", true);
    }
 
 
 
 
    public List<OtherUserInfo> findOther(List<OtherUserInfo> list,int size){
        List<OtherUserInfo> list2=new ArrayList<>();
        int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);
        for (int anInt : ints) {
            OtherUserInfo otherUserInfo = list.get(anInt);
            list2.add(otherUserInfo);
        }
        return list2;
    }
 
    public List<UserInfo> findUser(List<UserInfo> list,int size){
        List<UserInfo> list2=new ArrayList<>();
        int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);
        for (int anInt : ints) {
            UserInfo otherUserInfo = list.get(anInt);
            list2.add(otherUserInfo);
        }
        return list2;
    }
 
    public List<SysEnvironmentalInfo> findCate(List<SysEnvironmentalInfo> list,int size){
        List<SysEnvironmentalInfo> list2=new ArrayList<>();
        int[] ints = RandomUtil.randomCommon(0, list.size() - 1, size);
        for (int anInt : ints) {
            SysEnvironmentalInfo otherUserInfo = list.get(anInt);
            list2.add(otherUserInfo);
        }
        return list2;
    }
 
 
    @Test
    public void 假数据() throws InterruptedException {
        TimeInterval timer = DateUtil.timer();
        final String[] date = {null};
        final int[] len = {0};
        final int[] otherSize = {0};
        final int[] userSize = new int[1];
        final int[] weightAll = new int[1];
 
        int size=5;
 
        CountDownLatch countDownLatch = ThreadUtil.newCountDownLatch(size);
        for (int i = 0; i <size;i++) {
 
            if(i==0){
                //起始日期
                date[0] ="2019-09-23 08:30:00";
                //日期天的跨度
                len[0] =8;
                //回收员数目
                otherSize[0] =4;
                //每天50单
                userSize[0] =50;
                //公斤 总共2000公斤
                weightAll[0] =2000;
            }else if(i==1){
 
                date[0] ="2019-10-01 08:30:00";
                len[0] =31;
                otherSize[0] =10;
                userSize[0] =180;
                weightAll[0] =4500;
            }else if(i==2){
                date[0] ="2019-11-01 08:30:00";
                len[0] =30;
                otherSize[0] =20;
                userSize[0] =300;
                weightAll[0] =8000;
            }else  if(i==3){
                date[0] ="2019-12-01 08:30:00";
                len[0] =31;
                otherSize[0] =30;
                userSize[0] =500;
                weightAll[0] =12000;
 
            }else if(i==4){
                date[0] ="2020-01-01 08:30:00";
                len[0] =20;
                otherSize[0] =35;
                userSize[0] =550;
                weightAll[0] =13000;
 
            }
 
            Runnable callable=()->{
                Dict gen = gen(date[0], len[0], otherSize[0], userSize[0], weightAll[0]);
                List<OrderInfo> orders= (List<OrderInfo>) gen.get("orders");
                List<OrderItemInfo> orderItems= (List<OrderItemInfo>) gen.get("orderItems");
                List<OrderDetailInfo> orderDetails= (List<OrderDetailInfo>) gen.get("orderDetails");
                List<OrderStorageInfo> storages= (List<OrderStorageInfo>) gen.get("storages");
                List<OrderStorageDetailInfo> storageDetails= (List<OrderStorageDetailInfo>) gen.get("storageDetails");
                List<OrderStorageDetailInfo> storageDetails2= (List<OrderStorageDetailInfo>) gen.get("storageDetails2");
                orderInsertMapper.insertBatchByPrimaryKeySelective(orders);
                orderDetailInsertMapper.insertBatchByPrimaryKeySelective(orderDetails);
                orderStorageInfoInsertMapper.insertBatchByPrimaryKeySelective(storages);
 
 
 
                //切分大小  一次执行几十万将导致Gc
                int splitSize=10000;
 
                List<List<OrderItemInfo>> split = CollUtil.split(orderItems, splitSize);
                for (List<OrderItemInfo> list : split) {
                    orderItemInfoInsertMapper.insertBatchByPrimaryKeySelective(list);
                }
 
                List<List<OrderStorageDetailInfo>> split1 = CollUtil.split(storageDetails, splitSize);
                for (List<OrderStorageDetailInfo> list : split1) {
                    orderStorageDetailMapper.insertList(list);
                }
 
 
                List<List<OrderStorageDetailInfo>> split2 = CollUtil.split(storageDetails2, splitSize);
                for (List<OrderStorageDetailInfo> list : split2) {
                    orderStorageDetailMapper.insertList(list);
                }
 
                countDownLatch.countDown();
 
            };
            ThreadUtil.execAsync(callable,true);
        }
 
        countDownLatch.await();
 
        System.out.println("执行成功,耗时"+timer.intervalPretty());
 
    }
 
 
    public Dict gen(String date, int len, int otherSize, int userSize, int weightAll){
 
        Dict dict=Dict.create();
        Date dateDate=DateUtil.parseDateTime(date);
//        List<OtherUserInfo> list = otherUserService.findTest();
        List<OtherUserInfo> list = CollUtil.newArrayList();
 
        //用户数=单日订单数*2
        int generUserSize=userSize*2;
 
        List<UserInfo> userList=CollUtil.newArrayList();
        List<AccountInfo> accountList=CollUtil.newArrayList();
        List<AddressInfo> addrList=CollUtil.newArrayList();
 
        //生成用户
        for (int i = 0; i < len; i++) {
            DateTime dateTime = DateUtil.offsetDay(dateDate, i);
            for (int j = 0; j < generUserSize; j++) {
                //往后延迟1个半小时生成用户
                int minute=90*60;
                int timeIndex = (int) (Math.random() *minute);
                Date createTime=DateUtil.offsetSecond(dateTime,-timeIndex);
                String time=DateUtil.formatDateTime(createTime);
                //新建一个非注册用户
                String yh = idUtils.generate("YH", 3);
                UserInfo userInfo2=new UserInfo();
                userInfo2.setUserId(yh);
                Map address = RandomValue.getAddress();
                userInfo2.setMobilePhone(address.get("tel").toString());
                userInfo2.setNickName(Base64.encode(address.get("name").toString()));
                userInfo2.setRegistTime(time);
                userInfo2.setDelFlag(Constants.DEL_NOT_FLAG);
                userInfo2.setRegistType(Convert.toShort(CommonEnum.正常注册用户.getValue()));
                userInfo2.setUserType(CommonEnum.普通用户.getValue());
                userInfo2.setIsProhibit(false);
                userInfo2.setSex(address.get("sex").toString());
                userInfo2.setAvatar(Constants.DEFAULT_AVATAR);
                userList.add(userInfo2);
 
                //增加一个默认账户
                AccountInfo accountInfo =new AccountInfo();
                accountInfo.setAccountId(idUtils.generate("ZH",4));
                accountInfo.setAccountName(userInfo2.getMobilePhone());
                accountInfo.setUserId(yh);
                accountInfo.setFreezeMoney("0");
                accountInfo.setWithdrawMoney("0");
                accountInfo.setMoney("0");
                accountInfo.setOverdraftLimit("0");
                accountInfo.setDelFlag(0);
                accountInfo.setIsProhibit("0");
                accountInfo.setErrorTimes(0);
                accountInfo.setCreateTime(time);
                accountInfo.setUpdateTime(time);
                accountList.add(accountInfo);
 
                //偶数就新增地址 奇数不新增
                if((j+1)%2==0){
                    AddressInfo addressInfo=new AddressInfo();
                    addressInfo.setDelFlag(Convert.toStr(Constants.DEL_NOT_FLAG));
                    addressInfo.setMobilePhone(userInfo2.getMobilePhone());
                    addressInfo.setUserId(yh);
                    addressInfo.setProvinceId("1809");
                    addressInfo.setCityId("1810");
                    addressInfo.setTownshipId("1812");
                    addressInfo.setAddressArea("湖南省长沙市天心区");
                    addressInfo.setDetailAddress(address.get("road").toString());
                    addressInfo.setCreateTime(time);
                    addressInfo.setFlag(UserEnum.默认地址.getValue());
                    addressInfo.setDelFlag("0");
                    addressInfo.setRelaName(address.get("name").toString());
                    addressInfo.setRelaPhone(userInfo2.getMobilePhone());
                    addrList.add(addressInfo);
                }
            }
        }
 
        userInsertMapper.insertBatchByPrimaryKeySelective(userList);
        accountInsertMapper.insertBatchByPrimaryKeySelective(accountList);
//        addressInsertMapper.insertBatchByPrimaryKeySelective(addrList);
 
 
 
        List<UserInfo> listUser =userService.findHaveAddr();
        List<SysEnvironmentalInfo> listSys =sysEnvironmentalInfoService.find();
 
        for (Iterator<SysEnvironmentalInfo> iterator = listSys.iterator(); iterator.hasNext(); ) {
            SysEnvironmentalInfo next =  iterator.next();
            if(next.getParentId().toString().equals(Constants.HOUSE_HOLD_ITEM_TYPE)){
                iterator.remove();
            }
        }
 
        //9月23-30日数据
 
 
        int[] ints = RandomUtil.randomCommon(185, 189, 1);
 
        List<OrderInfo> orders=new ArrayList<>();
        List<OrderItemInfo> orderItems=new ArrayList<>();
        List<OrderDetailInfo> orderDetails=new ArrayList<>();
        List<OrderStorageInfo> storages=new ArrayList<>();
        List<OrderStorageDetailInfo> storageDetails=new ArrayList<>();
        List<OrderStorageDetailInfo> storageDetails2=new ArrayList<>();
 
 
        for (int i = 0; i < len; i++) {
            DateTime dateTime = DateUtil.offsetDay(dateDate, i);
            //每日 回收人数4人  每天50单 总共2000公斤
            List<OtherUserInfo> other = findOther(list,otherSize);
            List<UserInfo> user = findUser(listUser,userSize);
            //每个订单的总公斤数
            int[] weights = RandomUtil.splitInteger(userSize, weightAll, false);
            System.out.println(user.size());
            int iIndex=0;
 
 
            for (UserInfo userInfo : user) {
                String userId = userInfo.getUserId();
                String mobilePhone = userInfo.getMobilePhone();
                String address=userInfo.getDetailAddress();
                String addrArea=userInfo.getAddressArea();
 
                //插入订单表
                OrderInfo orderInfo=new OrderInfo();
                orderInfo.setAddress(address);
                orderInfo.setOrderStatus("5");
                orderInfo.setOrderType("1");
                orderInfo.setAddressArea(addrArea);
                orderInfo.setCreateUserId(userId);
                int index = (int) (Math.random() *other.size());
                OtherUserInfo otherUserInfo = other.get(index);
                orderInfo.setReceiver(otherUserInfo.getUserId());
                //五点下班
                int minute=8*60+30;
                int timeIndex = (int) (Math.random() *minute);
                Date createTime=DateUtil.offsetMinute(dateTime,timeIndex);
                orderInfo.setCreateTime(createTime.toString());
                //预约时间偏移1-2个小时
                int hour=2;
                int timeIndex2 = (int) (Math.random() *hour);
                Date reserveTime=DateUtil.offsetHour(createTime,timeIndex2+1);
                orderInfo.setReserveTime(reserveTime.toString());
                orderInfo.setRelaPhone(mobilePhone);
                String userName=userInfo.getRelaName();
                orderInfo.setRelaName(userName);
                orderInfo.setTownId(Convert.toStr(ints[0]));
                orderInfo.setCreateType(Convert.toShort(1));
                orderInfo.setDelFlag(Convert.toShort(0));
                String orderId=idUtils.generate("DD",1);
                orderInfo.setOrderId(orderId);
                orders.add(orderInfo);
//                orderMapper.insertSelective(orderInfo);
 
                //插入订单详情
                OrderDetailInfo orderDetailInfo=new OrderDetailInfo();
                orderDetailInfo.setOrderId(orderId);
                orderDetailInfo.setCreateUserName(userName);
                orderDetailInfo.setMobilePhone(mobilePhone);
                minute=31;
                timeIndex = (int) (Math.random() *minute);
                DateTime receiveTime = DateUtil.offsetMinute(createTime, timeIndex);
                orderDetailInfo.setReceiveTime(receiveTime.toString());
                orderDetailInfo.setReserveTime(reserveTime.toString());
                minute=31;
                timeIndex = (int) (Math.random() *minute);
                Date completeTime=DateUtil.offsetMinute(reserveTime,timeIndex+30);
                orderDetailInfo.setCompleteTime(completeTime.toString());
                orderDetailInfo.setAddressId(userInfo.getAddressId());
 
                int weight = weights[iIndex];
 
                int cateSize=3;
                if(weight<=5){
                    cateSize=1;
                }
                List<SysEnvironmentalInfo> cate = findCate(listSys,cateSize);
                orderDetailInfo.setWeight(weight+"");
 
                //将分类重量分下
                int[] itemWeithts = RandomUtil.splitInteger(cateSize,weight,false);
 
 
                BigDecimal money=BigDecimal.ZERO;
                int j=0;
                for (SysEnvironmentalInfo sysEnvironmentalInfo : listSys) {
                    //插入订单分类表
                    OrderItemInfo orderItemInfo=new OrderItemInfo();
                    orderItemInfo.setOrderId(orderId);
                    orderItemInfo.setItemType(sysEnvironmentalInfo.getItemType());
                    if(cate.stream().filter(x->x.getItemType().equals(sysEnvironmentalInfo.getItemType())).count()>0){
                        orderItemInfo.setWeight(Convert.toStr(itemWeithts[j]));
                        j++;
                    }else {
                        orderItemInfo.setWeight(Convert.toStr(Constants.WEIGHT_INIT));
                    }
 
                    String price = sysEnvironmentalInfo.getPrice();
                    BigDecimal mul = NumberUtil.mul(Convert.toBigDecimal(price), Convert.toBigDecimal(orderItemInfo.getWeight()));
                    orderItemInfo.setMoney(businessUtil.changeMoney(mul.toString()));
                    money=NumberUtil.add(money,mul);
                    orderItems.add(orderItemInfo);
 
                }
                String allMoney=businessUtil.changeMoney(money.toString());
                orderDetailInfo.setMoney(allMoney);
                orderDetailInfo.setStorageMoney(allMoney);
                orderDetailInfo.setReceiverName(otherUserInfo.getName());
                orderDetailInfo.setReceiverPhone(otherUserInfo.getMobilePhone());
                if(i/2==0) {
                    orderDetailInfo.setStorageUserId("USER1190571142298341376");
                    orderDetailInfo.setStorageUserName("陈松");
                    orderDetailInfo.setStorageUserPhone("17788919577");
                }else{
                    orderDetailInfo.setStorageUserId("64");
                    orderDetailInfo.setStorageUserName("匡喜寿");
                    orderDetailInfo.setStorageUserPhone("13469424076");
                }
                orderDetails.add(orderDetailInfo);
 
 
                //插入入库表
                OrderStorageInfo orderStorageInfo=new OrderStorageInfo();
                String rkId=idUtils.generate("RK",1);
                orderStorageInfo.setStorageId(rkId);
                orderStorageInfo.setOrderId(orderId);
                if(i/2==0) {
                    orderStorageInfo.setStorageUserId("USER1190571142298341376");
                    orderStorageInfo.setStorageUserName("陈松");
                    orderStorageInfo.setStorageUserPhone("17788919577");
                }else{
                    orderStorageInfo.setStorageUserId("64");
                    orderStorageInfo.setStorageUserName("匡喜寿");
                    orderStorageInfo.setStorageUserPhone("13469424076");
                }
 
                minute=31;
                timeIndex = (int) (Math.random() *minute);
                DateTime dateTime1 = DateUtil.offsetMinute(dateTime, minute);
                DateTime dateTime2 = DateUtil.offsetMinute(dateTime1, timeIndex);
                orderStorageInfo.setStorageTime(dateTime2.toString());
                orderStorageInfo.setStorageMoney(Convert.toBigDecimal(allMoney));
                orderStorageInfo.setRecycleMoney(Convert.toBigDecimal(allMoney));
                orderStorageInfo.setReceiver(orderInfo.getReceiver());
                orderStorageInfo.setReceiverName(otherUserInfo.getName());
                orderStorageInfo.setReceiverPhone(otherUserInfo.getMobilePhone());
                orderStorageInfo.setReceiverAvatar(otherUserInfo.getAvatar());
                orderStorageInfo.setSysStorageId(1L);
                orderStorageInfo.setStorageWeight(Convert.toStr(weight));
                orderStorageInfo.setRecycleWeight(Convert.toStr(weight));
                storages.add(orderStorageInfo);
 
                //插入入库详情
                int k=0;
                for (SysEnvironmentalInfo sysEnvironmentalInfo : listSys) {
                    OrderStorageDetailInfo orderStorageDetailInfo = new OrderStorageDetailInfo();
                    orderStorageDetailInfo.setStorageId(rkId);
                    orderStorageDetailInfo.setItemType(sysEnvironmentalInfo.getItemType());
                    if(cate.stream().filter(x->x.getItemType().equals(sysEnvironmentalInfo.getItemType())).count()>0) {
                        orderStorageDetailInfo.setWeight(Convert.toBigDecimal(itemWeithts[k]));
                        k++;
                    }else{
                        orderStorageDetailInfo.setWeight(Constants.WEIGHT_INIT);
                    }
                    String price = sysEnvironmentalInfo.getPrice();
                    BigDecimal mul = NumberUtil.mul(Convert.toBigDecimal(price), Convert.toBigDecimal(orderStorageDetailInfo.getWeight()));
                    orderStorageDetailInfo.setMoney(businessUtil.changeMoney(mul.toString()));
                    orderStorageDetailInfo.setFlag("1");
                    storageDetails.add(orderStorageDetailInfo);
                    OrderStorageDetailInfo orderStorageDetailInfo1=new OrderStorageDetailInfo();
                    BeanUtil.copyProperties(orderStorageDetailInfo,orderStorageDetailInfo1);
                    orderStorageDetailInfo1.setFlag("2");
                    storageDetails2.add(orderStorageDetailInfo1);
                }
                iIndex++;
          }
        }
        dict.put("orders",orders);
        dict.put("orderItems",orderItems);
        dict.put("orderDetails",orderDetails);
        dict.put("storages",storages);
        dict.put("storageDetails",storageDetails);
        dict.put("storageDetails2",storageDetails2);
 
        return dict;
    }
 
    @Test
    public void fence(){
//        List<Fence> fences = fenceMapper.selectAll();
//        System.out.println(fences.size());
        List<String> list=new ArrayList<>();
        list.add("10");
        List<UserInfo> byIds = userService.findByIds(list);
        System.out.println(byIds.size());
    }
 
 
    @Test
    public void fixtaeget(){
        //修复意向客户的地址问题
 
    }
    /**
     * 修复线上经纬度问题
     */
    @Test
    public void fixLon(){
        List<AddressInfo> addressInfos = addressService.findWithLonNull();
        System.out.println("为空的地址有"+addressInfos.size()+"条");
        int j=0;
        int i=0;
        for (AddressInfo addressInfo : addressInfos) {
            GdGEODto gdGEODto=new GdGEODto();
            AddressLevelInfo byTownIds = addressLevelService.find(addressInfo.getProvinceId(),addressInfo.getCityId(),addressInfo.getTownshipId());
            gdGEODto.setCity(byTownIds.getLevel2Name());
            gdGEODto.setAddress(addressInfo.getAddressArea()+addressInfo.getDetailAddress());
            Result locationByAddress = GdMapUtil.getLocationByAddress(gdGEODto);
            if(locationByAddress.getCode()==0&&locationByAddress.getData()!=null) {
                addressInfo.setLongitude(locationByAddress.getData().toString().split(",")[0]);
                addressInfo.setLatitude(locationByAddress.getData().toString().split(",")[1]);
                j++;
                addressMapper.updateByPrimaryKeySelective(addressInfo);
 
 
                List<OrderCustomDto> byCreateUserId = orderService.findByAddressId(addressInfo.getAddressId().toString());
 
 
                if(CollUtil.isNotEmpty(byCreateUserId)){
                    for (OrderCustomDto orderInfo : byCreateUserId) {
                        if(StrUtil.isBlank(orderInfo.getLongitude())||orderInfo.getLongitude().equals("0")){
                            OrderInfo orderInfo1=new OrderInfo();
                            orderInfo1.setOrderId(orderInfo.getOrderId());
                            orderInfo1.setLongitude(addressInfo.getLongitude());
                            orderInfo1.setLatitude(addressInfo.getLatitude());
                            orderInfo1.setTownId(addressInfo.getTownshipId());
                            orderMapper.updateByPrimaryKeySelective(orderInfo1);
                            i++;
                            System.out.println("修复订单:"+orderInfo1.getOrderId());
                        }
                    }
                }
            }
        }
 
 
        System.out.println("一共修复订单"+i+"个");
        System.out.println("一共修复地址"+j+"个");
 
    }
 
 
 
    @Test
    public void fixLon2(){
        int j=0;
        int i=0;
 
        List<OrderCustomDto> byCreateUserId = orderService.findWithLonNull();
 
 
        if(CollUtil.isNotEmpty(byCreateUserId)){
            for (OrderCustomDto orderInfo : byCreateUserId) {
                    OrderInfo orderInfo1=new OrderInfo();
 
                    orderInfo1.setOrderId(orderInfo.getOrderId());
 
                String addressId = orderInfo.getAddressId();
 
                AddressInfo addressInfo = addressService.findById(addressId);
                GdGEODto gdGEODto=new GdGEODto();
                AddressLevelInfo byTownIds = addressLevelService.find(addressInfo.getProvinceId(),addressInfo.getCityId(),addressInfo.getTownshipId());
                gdGEODto.setCity(byTownIds.getLevel2Name());
                gdGEODto.setAddress(addressInfo.getAddressArea()+addressInfo.getDetailAddress());
                Result locationByAddress = GdMapUtil.getLocationByAddress(gdGEODto);
                if(locationByAddress.getCode()==0&&locationByAddress.getData()!=null) {
                    addressInfo.setLongitude(locationByAddress.getData().toString().split(",")[0]);
                    addressInfo.setLatitude(locationByAddress.getData().toString().split(",")[1]);
                    j++;
                    addressMapper.updateByPrimaryKeySelective(addressInfo);
 
                    orderInfo1.setLongitude(addressInfo.getLongitude());
                    orderInfo1.setLatitude(addressInfo.getLatitude());
                    orderInfo1.setTownId(addressInfo.getTownshipId());
                    orderMapper.updateByPrimaryKeySelective(orderInfo1);
                    i++;
                }
 
 
            }
        }
 
        System.out.println("一共修复订单"+i+"个");
        System.out.println("一共修复地址"+j+"个");
 
    }
 
 
 
 
 
 
    @Test
    public  void test(){
        //修改目标客户的状态
//        UserInfo userInfo=new UserInfo();
//        userInfo.setUserId("1");
//        userInfo.setDelFlag(Constants.DEL_NOT_FLAG);
//        int i = userMapper.updateByPrimaryKeySelective(userInfo);
//        System.out.println(i);
//        LogUtils.writeIp("192.168.1.110","请求头部对");
//        List<UserInfo> userInfos = userMapper.selectAll();
        Map<String,Object> createUserMap=new HashMap<>();
        createUserMap.put("userId", "37");
 
        List<AccountVo> createUserAccount = accountMapper.queryMyMoney(createUserMap);
        String createUserMoney = createUserAccount.get(0).getMoney();
 
        createUserMap.put("userId", "37");
        createUserMap.put("money", Convert.toBigDecimal("10"));
 
        accountMapper.updateMyMoneyByOrder(createUserMap);
        createUserAccount = accountMapper.queryMyMoney(createUserMap);
        System.out.println(createUserMoney);
        System.out.println(createUserAccount.get(0).getMoney());
        accountMapper.updateMyMoneyByOrder(createUserMap);
    }
 
 
 
    /**
     * 修改老数据没有入库重量和回收重量的问题
     */
    @Test
    public void test3(){
 
        Example example=new Example(OrderStorageInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andIsNull("recycleWeight");
        criteria.andIsNull("storageWeight");
        List<OrderStorageInfo> orderStorageInfos = orderStorageInfoMapper.selectByExample(example);
        if(CollUtil.isNotEmpty(orderStorageInfos)){
            System.out.println("总数:"+orderStorageInfos.size());
 
            for (OrderStorageInfo orderStorageInfo : orderStorageInfos) {
                String orderId = orderStorageInfo.getOrderId();
                String storageId = orderStorageInfo.getStorageId();
 
                //修复入库重量
                double sum=0;
                OrderStorageDetailInfo orderStorageDetailInfo=new OrderStorageDetailInfo();
                orderStorageDetailInfo.setStorageId(storageId);
                orderStorageDetailInfo.setFlag("1");
                List<OrderStorageDetailInfo> select = orderStorageDetailMapper.select(orderStorageDetailInfo);
                if(CollUtil.isNotEmpty(select)){
                     sum = select.stream().mapToDouble(x -> Convert.toDouble(x.getWeight(),Convert.toDouble(Constants.WEIGHT_INIT))).sum();
                }
 
                //修复回收重量
                String[] split = orderId.split(",");
                double sumAll=0;
                for (String s : split) {
                    if(StrUtil.isNotBlank(s)){
                        OrderItemInfo orderDetailInfo=new OrderItemInfo();
                        orderDetailInfo.setOrderId(s);
                        List<OrderItemInfo> select1 = orderItemInfoMapper.select(orderDetailInfo);
                        if(CollUtil.isNotEmpty(select1)){
                            sumAll =sumAll+ select1.stream().mapToDouble(x -> Convert.toDouble(x.getWeight(),Convert.toDouble(Constants.WEIGHT_INIT))).sum();
                            System.out.println(s);
                            System.out.println(sumAll);
                        }
                    }
                }
 
                if(sum!=0&sumAll!=0) {
                    String a=NumberUtil.roundStr(sum,3,RoundingMode.DOWN);
                    String a1=NumberUtil.roundStr(sumAll,3,RoundingMode.DOWN);
                    OrderStorageInfo orderStorageInfo1 = new OrderStorageInfo();
                    orderStorageInfo1.setStorageId(orderStorageInfo.getStorageId());
                    orderStorageInfo1.setRecycleWeight(a1);
                    orderStorageInfo1.setStorageWeight(a);
                    orderStorageInfoMapper.updateByPrimaryKeySelective(orderStorageInfo1);
                }
            }
        }
 
        System.out.println("修复完成");
 
    }
 
 
}