xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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 com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.*;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ExcelExportUtil;
 
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
* 车辆出租
* @author pzb
* @Date 2022/5/28 14:52
*/
@Controller
@RequestMapping("/carRental")
public class CarRentalController {
 
    private String PREFIX = "/system/carRental/";
 
    @Autowired
    private ITCarBrandService carBrandService;
 
    @Autowired
    private ICarRentalService carRentalService;
 
    @Autowired
    private ITRegionService regionService;
 
    @Autowired
    private ITUserService userService;
 
    @Autowired
    private ITDriverService driverService;
 
    @Autowired
    private ITCompanyService companyService;
 
 
 
    /**
     * 跳转到列表页
     * @return
     */
    @GetMapping("/showCarRental")
    public String showCarRental(Model model){
        List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
        model.addAttribute("carBrand", state);
        model.addAttribute("userType", ShiroKit.getUser().getRoleType());
        return PREFIX + "carRental.html";
    }
 
    /**
     * 跳转到添加页
     * @param model
     * @return
     */
    @GetMapping("/carRental_add")
    public String carRental_add(Model model){
        model.addAttribute("push", ShiroKit.getUser().getRoleType() == 1 ? true : false);
        List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
        model.addAttribute("carBrand", state);
        List<TRegion> regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
        model.addAttribute("regions", regions);
        regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", regions.get(0).getId()));
        model.addAttribute("city", regions);
        return PREFIX + "carRental_add.html";
    }
 
 
    /**
     * 跳转到详情页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/showCarRentalInfo")
    public String showCarRentalInfo(Model model, Integer id){
        CarRental carRental = carRentalService.selectById(id);
        model.addAttribute("item", carRental);
        TCarBrand tCarBrand = carBrandService.selectById(carRental.getBrandId());
        model.addAttribute("brand", tCarBrand.getName());
        model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
        model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
        model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
        if(carRental.getUserType() == 1){
            TUser tUser = userService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tUser.getName());
            model.addAttribute("pushUserPhone", tUser.getPhone());
        }
        if(carRental.getUserType() == 2){
            TDriver tDriver = driverService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tDriver.getName());
            model.addAttribute("pushUserPhone", tDriver.getPhone());
        }
        if(carRental.getUserType() == 3){
            TCompany tCompany = companyService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tCompany.getName());
            model.addAttribute("pushUserPhone", tCompany.getPrincipalPhone());
        }
        model.addAttribute("status", (carRental.getStatus() == 1 || carRental.getStatus() == 4) ? "待发布" : (carRental.getStatus() == 2 ? "上架中" : carRental.getStatus() == 3 ? "下架中" : "已删除"));
        return PREFIX + "carRental_info.html";
    }
 
 
    /**
     * 跳转到编辑页
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/carRental_update")
    public String carRental_update(Model model, Integer id){
        CarRental carRental = carRentalService.selectById(id);
        model.addAttribute("item", carRental);
        List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
        model.addAttribute("carBrand", state);
        model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
        model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
        model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
        List<TRegion> regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
        model.addAttribute("province", regions);
        regions = regionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", regionService.selectOne(new EntityWrapper<TRegion>().eq("code", carRental.getProvinceCode())).getId()));
        model.addAttribute("city", regions);
        model.addAttribute("push", ShiroKit.getUser().getRoleType() == 1 ? true : false);
        return PREFIX + "carRental_edit.html";
    }
 
 
    /**
     * 跳转到车辆出租审核页
     * @return
     */
    @GetMapping("/showAuditCarRentalList")
    public String showAuditCarRentalList(Model model){
        List<TCarBrand> state = carBrandService.selectList(new EntityWrapper<TCarBrand>().eq("state", 1));
        model.addAttribute("carBrand", state);
        return PREFIX + "auditCarRental.html";
    }
 
    /**
     * 跳转到审核页
     * @return
     */
    @GetMapping("/openAuditCarRental")
    public String openAuditCarRental(Model model, Integer id){
        CarRental carRental = carRentalService.selectById(id);
        model.addAttribute("item", carRental);
        TCarBrand tCarBrand = carBrandService.selectById(carRental.getBrandId());
        model.addAttribute("brand", tCarBrand.getName());
        model.addAttribute("imgs", ToolUtil.isNotEmpty(carRental.getImgUrl()) ? carRental.getImgUrl().split(",") : "");
        model.addAttribute("videos", ToolUtil.isNotEmpty(carRental.getVideoUrl()) ? carRental.getVideoUrl().split(",") : "");
        model.addAttribute("describeImgs", ToolUtil.isNotEmpty(carRental.getDescribeImgUrl()) ? carRental.getDescribeImgUrl().split(",") : "");
        if(carRental.getUserType() == 1){
            TUser tUser = userService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tUser.getName());
            model.addAttribute("pushUserPhone", tUser.getPhone());
        }
        if(carRental.getUserType() == 2){
            TDriver tDriver = driverService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tDriver.getName());
            model.addAttribute("pushUserPhone", tDriver.getPhone());
        }
        if(carRental.getUserType() == 3){
            TCompany tCompany = companyService.selectById(carRental.getUserId());
            model.addAttribute("pushUser", tCompany.getName());
            model.addAttribute("pushUserPhone", tCompany.getPrincipalPhone());
        }
        model.addAttribute("status", (carRental.getStatus() == 1 || carRental.getStatus() == 4) ? "待发布" : (carRental.getStatus() == 2 ? "上架中" : carRental.getStatus() == 3 ? "下架中" : "已删除"));
        return PREFIX + "auditCarRental_info.html";
    }
 
 
    /**
     * 获取列表数据
     * @param createTime
     * @param title
     * @param brandId
     * @param insertUser
     * @param status
     * @param userType
     * @param offset
     * @param limit
     * @return
     */
    @ResponseBody
    @PostMapping("/list")
    public Object list(String createTime, String title, Integer brandId, String insertUser, Integer status, Integer userType, Integer offset, Integer limit){
        try {
            List<Integer> state = Arrays.asList(2, 3, 4);
            if(null != status){
                state = Arrays.asList(status);
            }
            return carRentalService.list(createTime, title, brandId, insertUser, state, userType, offset, limit);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 添加数据
     * @param carRental
     * @return
     */
    @ResponseBody
    @PostMapping("/addCarRental")
    public ResultUtil addCarRental(CarRental carRental){
        try {
            return carRentalService.addCarRental(carRental);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 编辑数据
     * @param carRental
     * @return
     */
    @ResponseBody
    @PostMapping("/updateCarRental")
    public ResultUtil updateCarRental(CarRental carRental){
        try {
            return carRentalService.updateCarRental(carRental);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 删除数据
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/deleteCarRental")
    public ResultUtil deleteCarRental(Integer id){
        try {
            CarRental carRental = carRentalService.selectById(id);
            carRental.setStatus(6);
            carRentalService.updateById(carRental);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 上架操作
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/onlineCarRental")
    public ResultUtil onlineCarRental(Integer id){
        try {
            CarRental carRental = carRentalService.selectById(id);
            if(carRental.getStatus() == 1){
                return ResultUtil.error("该数据还未审核");
            }
            if(carRental.getStatus() == 2){
                return ResultUtil.error("不允许重复操作");
            }
            carRental.setStatus(2);
            carRentalService.updateById(carRental);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 下架操作
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/offlineCarRental")
    public ResultUtil offlineCarRental(Integer id){
        try {
            CarRental carRental = carRentalService.selectById(id);
            if(carRental.getStatus() == 1){
                return ResultUtil.error("该数据还未审核");
            }
            if(carRental.getStatus() == 3){
                return ResultUtil.error("不允许重复操作");
            }
            carRental.setStatus(3);
            carRentalService.updateById(carRental);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 设置首页推荐
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/homeCarRental")
    public ResultUtil homeCarRental(Integer id){
        try {
            CarRental carRental = carRentalService.selectById(id);
            if(carRental.getStatus() == 1){
                return ResultUtil.error("该数据还未审核");
            }
            if(carRental.getStatus() == 3){
                return ResultUtil.error("该数据已下架");
            }
            if(carRental.getStatus() == 4){
                return ResultUtil.error("该数据还未上架");
            }
            if(carRental.getFirstPageShow() == 1){
                return ResultUtil.error("不允许重复操作");
            }
            int i = carRentalService.selectCount(new EntityWrapper<CarRental>().in("status", Arrays.asList(2, 3)).eq("firstPageShow", 1));
            if(i >= 6){
                return ResultUtil.error("首页推荐最多设置6个");
            }
            carRental.setFirstPageShow(1);
            carRentalService.updateById(carRental);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 取消首页推荐
     * @param id
     * @return
     */
    @ResponseBody
    @PostMapping("/cancelHomeCarRental")
    public ResultUtil cancelHomeCarRental(Integer id){
        try {
            CarRental carRental = carRentalService.selectById(id);
            if(carRental.getStatus() == 1){
                return ResultUtil.error("该数据还未审核");
            }
            if(carRental.getStatus() == 3){
                return ResultUtil.error("该数据已下架");
            }
            if(carRental.getStatus() == 4){
                return ResultUtil.error("该数据还未上架");
            }
            if(carRental.getFirstPageShow() == 2){
                return ResultUtil.error("不允许重复操作");
            }
            carRental.setFirstPageShow(2);
            carRentalService.updateById(carRental);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 下载导入模板
     * @param request
     * @param response
     */
    @RequestMapping(value = "/uploadCarRentalModel")
    public void uploadCarRentalModel(HttpServletRequest request, HttpServletResponse response) {
        // 表格数据【封装】
        List<List<String>> dataList = new ArrayList<List<String>>();
 
        // 首行【封装】
        List<String> shellList = new ArrayList<String>();
        shellList.add("用户类型[用户/司机/企业]");
        shellList.add("用户手机号/企业名称");
        shellList.add("标题");
        shellList.add("品牌名称");
        shellList.add("类别");
        shellList.add("座位");
        shellList.add("排量");
        shellList.add("档位");
        shellList.add("取车证件");
        shellList.add("租金");
        shellList.add("押金");
        shellList.add("描述");
        shellList.add("描述图片地址[多个英文逗号分隔]");
        shellList.add("联系人");
        shellList.add("联系人电话");
        shellList.add("省");
        shellList.add("市");
        shellList.add("详细地址");
        shellList.add("车辆图片地址[多个英文逗号分隔]");
        shellList.add("车辆视频地址");
        dataList.add(shellList);
 
        try {
            // 调用工具类进行导出
            ExcelExportUtil.easySheet("车辆出租导入模板"+ DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "车辆出租导入模板", dataList, request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 导入数据
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/importCarRental")
    public ResultUtil importCarRental(HttpServletRequest request){
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        MultipartFile file = (MultipartFile) multipartRequest.getFile("file");
        try {
            Workbook book = WoUtil.ImportFile(file);
            Sheet sh = book.getSheetAt(0);   //获取到第一个表
            for (int i = 1; i <= sh.getLastRowNum(); i++) {
                Row row = sh.getRow(i);
 
                Cell cell0 = row.getCell(0);  //用户类型[用户/司机/企业]
                String zero = null;
                if (SinataUtil.isNotEmpty(cell0)){
                    if(row.getCell(0)!=null){
                        row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    zero = String.valueOf(cell0.getStringCellValue()).trim();
                }
 
                Cell cell1 = row.getCell(1);  //用户名称
                String one = null;
                if (SinataUtil.isNotEmpty(cell1)){
                    if(row.getCell(1)!=null){
                        row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    one = String.valueOf(cell1.getStringCellValue()).trim();
                }
 
                Cell cell2 = row.getCell(2);  //标题
                String two = null;
                if (SinataUtil.isNotEmpty(cell2)){
                    if(row.getCell(2)!=null){
                        row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    two = String.valueOf(cell2.getStringCellValue()).trim();
                }
 
                Cell cell3 = row.getCell(3);  //品牌名称
                String three = null;
                if (SinataUtil.isNotEmpty(cell3)){
                    if(row.getCell(3)!=null){
                        row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    three = String.valueOf(cell3.getStringCellValue()).trim();
                }
 
                Cell cell4 = row.getCell(4);  //类别
                String four = null;
                if (SinataUtil.isNotEmpty(cell4)){
                    if(row.getCell(4)!=null){
                        row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    four = String.valueOf(cell4.getStringCellValue()).trim();
                }
 
                Cell cell5 = row.getCell(5);  //座位
                String five = null;
                if (SinataUtil.isNotEmpty(cell5)){
                    if(row.getCell(5)!=null){
                        row.getCell(5).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    five = String.valueOf(cell5.getStringCellValue()).trim();
                }
 
                Cell cell6 = row.getCell(6);  //排量
                String six = null;
                if (SinataUtil.isNotEmpty(cell6)){
                    if(row.getCell(6)!=null){
                        row.getCell(6).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    six = String.valueOf(cell6.getStringCellValue()).trim();
                }
 
                Cell cell7 = row.getCell(7);  //档位
                String seven = null;
                if (SinataUtil.isNotEmpty(cell7)){
                    if(row.getCell(7)!=null){
                        row.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    seven = String.valueOf(cell7.getStringCellValue()).trim();
                }
 
                Cell cell8 = row.getCell(8);  //取车证件
                String eight = null;
                if (SinataUtil.isNotEmpty(cell8)){
                    if(row.getCell(8)!=null){
                        row.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    eight = String.valueOf(cell8.getStringCellValue()).trim();
                }
 
                Cell cell9 = row.getCell(9);  //租金
                String nine = null;
                if (SinataUtil.isNotEmpty(cell9)){
                    if(row.getCell(9)!=null){
                        row.getCell(9).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    nine = String.valueOf(cell9.getStringCellValue()).trim();
                }
 
                Cell cell10 = row.getCell(10);  //押金
                String ten = null;
                if (SinataUtil.isNotEmpty(cell10)){
                    if(row.getCell(10)!=null){
                        row.getCell(10).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    ten = String.valueOf(cell10.getStringCellValue()).trim();
                }
 
                Cell cell11 = row.getCell(11);  //描述
                String eleven = null;
                if (SinataUtil.isNotEmpty(cell11)){
                    if(row.getCell(11)!=null){
                        row.getCell(11).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    eleven = String.valueOf(cell11.getStringCellValue()).trim();
                }
 
                Cell cell12 = row.getCell(12);  //描述图片地址[多个英文逗号分隔]
                String twelve = null;
                if (SinataUtil.isNotEmpty(cell12)){
                    if(row.getCell(12)!=null){
                        row.getCell(12).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    twelve = String.valueOf(cell12.getStringCellValue()).trim();
                }
 
                Cell cell13 = row.getCell(13);  //联系人
                String thirteen = null;
                if (SinataUtil.isNotEmpty(cell13)){
                    if(row.getCell(13)!=null){
                        row.getCell(13).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    thirteen = String.valueOf(cell13.getStringCellValue()).trim();
                }
 
                Cell cell14 = row.getCell(14);  //联系人电话
                String fourteen = null;
                if (SinataUtil.isNotEmpty(cell14)){
                    if(row.getCell(14)!=null){
                        row.getCell(14).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    fourteen = String.valueOf(cell14.getStringCellValue()).trim();
                }
 
                Cell cell15 = row.getCell(15);  //省
                String fifteen = null;
                if (SinataUtil.isNotEmpty(cell15)){
                    if(row.getCell(15)!=null){
                        row.getCell(15).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    fifteen = String.valueOf(cell15.getStringCellValue()).trim();
                }
 
                Cell cell16 = row.getCell(16);  //市
                String sixteen = null;
                if (SinataUtil.isNotEmpty(cell16)){
                    if(row.getCell(16)!=null){
                        row.getCell(16).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    sixteen = String.valueOf(cell16.getStringCellValue()).trim();
                }
 
                Cell cell17 = row.getCell(17);  //详细地址
                String seventeen = null;
                if (SinataUtil.isNotEmpty(cell17)){
                    if(row.getCell(17)!=null){
                        row.getCell(17).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    seventeen = String.valueOf(cell17.getStringCellValue()).trim();
                }
 
                Cell cell18 = row.getCell(18);  //车辆图片地址[多个英文逗号分隔]
                String eighteen = null;
                if (SinataUtil.isNotEmpty(cell18)){
                    if(row.getCell(18)!=null){
                        row.getCell(18).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    eighteen = String.valueOf(cell18.getStringCellValue()).trim();
                }
 
                Cell cell19 = row.getCell(19);  //车辆视频地址
                String nineteen = null;
                if (SinataUtil.isNotEmpty(cell19)){
                    if(row.getCell(19)!=null){
                        row.getCell(19).setCellType(Cell.CELL_TYPE_STRING);
                    }
                    nineteen = String.valueOf(cell19.getStringCellValue()).trim();
                }
 
 
                if (SinataUtil.isEmpty(zero) || SinataUtil.isEmpty(three) || SinataUtil.isEmpty(four)
                        || SinataUtil.isEmpty(five) || SinataUtil.isEmpty(six) || SinataUtil.isEmpty(seven)
                        || SinataUtil.isEmpty(eight) || SinataUtil.isEmpty(nine) || SinataUtil.isEmpty(ten)
                        || SinataUtil.isEmpty(eleven) || SinataUtil.isEmpty(twelve) || SinataUtil.isEmpty(thirteen)
                        || SinataUtil.isEmpty(fourteen) || SinataUtil.isEmpty(fifteen) || SinataUtil.isEmpty(sixteen)
                        || SinataUtil.isEmpty(seventeen) || SinataUtil.isEmpty(eighteen) || SinataUtil.isEmpty(nineteen)){
                    return ResultUtil.error("单元格不能为空");
                }else{
                    //判断所属机构
                    if (!zero.equals("用户") && !zero.equals("司机") && !zero.equals("企业")){
                        return ResultUtil.error("用户类型不正确");
                    }
 
                    Integer userType = 0;
                    Integer userId = null;
                    if("用户".equals(zero)){
                        TUser tUser = userService.selectOne(new EntityWrapper<TUser>().eq("phone", one).eq("flag", 1));
                        if(null == tUser){
                            return ResultUtil.error("用户手机号不正确");
                        }
                        userType = 1;
                        userId = tUser.getId();
                    }
                    if("司机".equals(zero)){
                        TDriver tDriver = driverService.selectOne(new EntityWrapper<TDriver>().eq("phone", one).eq("flag", 1));
                        if(null == tDriver){
                            return ResultUtil.error("司机手机号不正确");
                        }
                        userType = 2;
                        userId = tDriver.getId();
                    }
                    if("企业".equals(zero)){
                        TCompany tCompany = companyService.selectOne(new EntityWrapper<TCompany>().eq("name", one).eq("flag", 1));
                        if(null == tCompany){
                            return ResultUtil.error("企业名称不正确");
                        }
                        userType = 3;
                        userId = tCompany.getId();
                    }
 
                    TCarBrand tCarBrand = carBrandService.selectOne(new EntityWrapper<TCarBrand>().eq("name", three).eq("state", 1));
                    if(null == tCarBrand){
                        return ResultUtil.error("品牌名称不正确");
                    }
                    TRegion province = regionService.selectOne(new EntityWrapper<TRegion>().eq("name", fifteen));
                    if(null == province){
                        return ResultUtil.error("省名称不正确");
                    }
                    TRegion city = regionService.selectOne(new EntityWrapper<TRegion>().eq("name", sixteen));
                    if(null == city){
                        return ResultUtil.error("市名称不正确");
                    }
 
 
                    CarRental carRental = new CarRental();
                    carRental.setUserType(userType);
                    carRental.setUserId(userId);
                    carRental.setTitle(two);
                    carRental.setBrandId(tCarBrand.getId());
                    carRental.setBrandName(three);
                    carRental.setCategory(four);
                    carRental.setSeat(five);
                    carRental.setDisplacement(six);
                    carRental.setGear(seven);
                    carRental.setPickUpCarCarCertificates(eight);
                    carRental.setRentMoney(nine);
                    carRental.setDeposit(Double.valueOf(ten));
                    carRental.setDescribe(eleven);
                    carRental.setDescribeImgUrl(twelve);
                    carRental.setContactsName(thirteen);
                    carRental.setContactsPhone(fourteen);
                    carRental.setProvinceCode(province.getCode());
                    carRental.setCityCode(city.getCode());
                    carRental.setProvinceName(province.getName());
                    carRental.setCityName(city.getName());
                    carRental.setCreateTime(new Date());
                    carRental.setStatus(1);
                    carRental.setAddres(seventeen);
                    carRental.setImgUrl(eighteen);
                    carRental.setVideoUrl(nineteen);
                    carRental.setFirstPageShow(2);
                    carRental.setInsertUser(ShiroKit.getUser().getId());
                    carRentalService.insert(carRental);
                }
            }
            return ResultUtil.success();
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 获取车辆出租审核列表
     * @param createTime
     * @param title
     * @param brandId
     * @param insertUser
     * @param status
     * @param userType
     * @param offset
     * @param limit
     * @return
     */
    @ResponseBody
    @PostMapping("/listAuditCarRental")
    public Object listAuditCarRental(String createTime, String title, Integer brandId, String insertUser, Integer status, Integer userType, Integer offset, Integer limit){
        try {
            List<Integer> state = Arrays.asList(1, 5);
            if(null != status){
                state = Arrays.asList(status);
            }
            return carRentalService.list(createTime, title, brandId, insertUser, state, userType, offset, limit);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 审核操作
     * @param id
     * @param status
     * @param authRemark
     * @return
     */
    @ResponseBody
    @PostMapping("/auditCarRental")
    public ResultUtil auditCarRental(Integer id, Integer status, String authRemark){
        try {
            return carRentalService.auditCarRental(id, status, authRemark);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
}