liujie
2026-04-20 f80d57a352069f27af6ea2b442380c44208e05a3
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
package com.stylefeng.guns.modular.system.controller.specialTrain;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
 
/**
 * 跨城线路管理控制器
 *
 * @author fengshuonan
 * @Date 2020-09-15 16:17:29
 */
@Controller
@RequestMapping("/tLine")
public class TLineController extends BaseController {
 
    private String PREFIX = "/system/tLine/";
 
    @Autowired
    private ITLineService tLineService;
 
    @Autowired
    private ITSiteService itSiteService;
 
    @Autowired
    private ITServerCarmodelService itServerCarmodelService;
 
    @Autowired
    private ITLineSiteService itLineSiteService;
 
    @Autowired
    private ITLinePriceService itLinePriceService;
    
    @Autowired
    private ITLineShiftService itLineShiftService;
 
    @Autowired
    private ITLineDestinationService itLineDestinationService;
    
    @Autowired
    private ITCompanyService itCompanyService;
    
    @Autowired
    private ITLineCompanyService itLineCompanyService;
    
    /**
     * 跳转到跨城站点管理首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tLine.html";
    }
 
    /**
     * 跳转到行程列表页
     */
    @RequestMapping("/travelListPage")
    public String travelListPage() {
        return PREFIX + "travelList.html";
    }
 
    /**
     * 跳转到行程订单列表页
     */
    @RequestMapping("/travelOrdersPage")
    public String travelOrdersPage(Integer lineShiftDriverId, Integer lineId, Integer driverId, Model model) {
        model.addAttribute("lineShiftDriverId", lineShiftDriverId);
        model.addAttribute("lineId", lineId);
        model.addAttribute("driverId", driverId);
        return PREFIX + "travelOrders.html";
    }
    
    /**
     * 跳转到添加跨城站点管理
     */
    @RequestMapping("/tLine_add")
    public String tLineAdd(Model model) {
        //站点
        Integer companyId = null;
        if(ShiroKit.getUser().getRoleType() != 1){
            companyId = ShiroKit.getUser().getObjectId();
        }
        List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1)
                .eq(null != companyId, "companyId", companyId));
        model.addAttribute("siteList",siteList);
        //跨城车型
        List<TServerCarmodel> carmodelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
        model.addAttribute("carmodelList",carmodelList);
        return PREFIX + "tLine_add.html";
    }
 
    /**
     * 分配企业页面
     */
    @RequestMapping("/tLine_addCompany/{tLineId}")
    public String tLine_addCompany(@PathVariable Integer tLineId,Model model) {
        TLine tLine = tLineService.selectById(tLineId);
        model.addAttribute("tLine",tLine);
        //查询所有企业
        List<TCompany> companyList = itCompanyService.selectList(new EntityWrapper<TCompany>().last(" where not FIND_IN_SET(state,'1') and not FIND_IN_SET(flag,'3')"));
        model.addAttribute("companyList",companyList);
        //查询已分配企业
        List<Map<String, Object>> lineCompanyList = tLineService.getLineCompanyList(tLineId);
        model.addAttribute("lineCompanyList",lineCompanyList);
        return PREFIX + "tLine_addCompany.html";
    }
 
 
    @RequestMapping("/set/{redict}")
    public String set(Model model,@PathVariable String redict) {
            model.addAttribute("redict",redict);
        return PREFIX + "set.html";
    }
 
    @RequestMapping("/set1/{redict}")
    public String set1(Model model,@PathVariable String redict) {
        model.addAttribute("redict",redict);
        return PREFIX + "set1.html";
    }
    /**
     * 跳转到修改跨城站点管理
     */
    @RequestMapping("/tLine_update/{tLineId}")
    public String tLineUpdate(@PathVariable Integer tLineId, Model model) {
        TLine tLine = tLineService.selectById(tLineId);
        model.addAttribute("item",tLine);
        LogObjectHolder.me().set(tLine);
 
        //查找站点起点+终点
        TLineSite start = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 1));
        model.addAttribute("start",start);
        TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLineId).eq("type", 2));
        model.addAttribute("end",end);
        //站点
        Integer companyId = null;
        if(ShiroKit.getUser().getRoleType() != 1){
            companyId = ShiroKit.getUser().getObjectId();
        }
        List<TSite> siteList = itSiteService.selectList(new EntityWrapper<TSite>().eq("state", 1)
                .eq(null != companyId, "companyId", companyId));
        model.addAttribute("siteList",siteList);
        //跨城车型
        List<TServerCarmodel> carmodelList = itServerCarmodelService.selectList(new EntityWrapper<TServerCarmodel>().eq("type", 2).eq("state", 1));
        model.addAttribute("carmodelList",carmodelList);
        //查询所有站点
        List<Map<String, Object>> linePriceList = tLineService.getLinePriceList(tLineId);
        model.addAttribute("linePriceList",linePriceList);
        //查询所有班次
        List<TLineShift> lineShiftList = itLineShiftService.selectList(new EntityWrapper<TLineShift>().eq("lineId", tLineId).last(" and not FIND_IN_SET(state,'3')"));
        model.addAttribute("lineShiftList",lineShiftList);
        //查询线路目的地
        List<TLineDestination> lineDestinationList = itLineDestinationService.selectList(
                new EntityWrapper<TLineDestination>().eq("lineId", tLineId).ne("state", 3).orderBy("isMain", false).orderBy("id", true));
        model.addAttribute("lineDestinationList", lineDestinationList);
        return PREFIX + "tLine_edit.html";
    }
 
    /**
     * 获取跨城站点管理列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String insertTime,String name,String insertUser,String modelStr,Integer state) {
        String beginTime = null;
        String endTime = null;
        if (SinataUtil.isNotEmpty(insertTime)) {
            String[] timeArray = insertTime.split(" - ");
            beginTime = timeArray[0];
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        Integer companyId = null;
        if(ShiroKit.getUser().getRoleType() != 1){
            companyId = ShiroKit.getUser().getObjectId();
        }
        page.setRecords(tLineService.getLineList(page, beginTime, endTime, name, insertUser, modelStr, state, companyId));
        return super.packForBT(page);
    }
 
    /**
     * 获取行程列表
     */
    @RequestMapping(value = "/travelList")
    @ResponseBody
    public Object travelList(String city, String lineName, String driverKeyword, Integer status) {
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer companyId = ShiroKit.getUser().getObjectId();
        page.setRecords(tLineService.getTravelList(page, city, lineName, driverKeyword, status, roleType, companyId));
        return super.packForBT(page);
    }
 
    /**
     * 获取行程对应订单列表
     */
    @RequestMapping(value = "/travelOrders")
    @ResponseBody
    public Object travelOrders(Integer lineShiftDriverId, Integer lineId, Integer driverId) {
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer companyId = ShiroKit.getUser().getObjectId();
        page.setRecords(tLineService.getTravelOrders(page, lineShiftDriverId, lineId, driverId, roleType, companyId));
        return super.packForBT(page);
    }
 
    /**
     * 新增跨城站点管理
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public ResultUtil add(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,
                          @RequestParam String shuArr, @RequestParam(required = false) String destArr) {
        JSONArray jsonArray1 = JSON.parseArray(shuArr);
        int size1 = jsonArray1.size();
        for (int i = 0; i < size1; i++) {
            JSONObject jsonObject = jsonArray1.getJSONObject(i);
            String shiftTime = jsonObject.getString("shiftTime");
            if (SinataUtil.isNotEmpty(shiftTime)){
                String[] timeArray = shiftTime.split(" - ");
                String startTime = timeArray[0].split(":")[0];
                String endTime = timeArray[1].split(":")[0];
                if(Integer.valueOf(startTime) >= Integer.valueOf(endTime)){
                    return ResultUtil.error("班次结束时间不能小于开始时间");
                }
            }
        }
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
        name = name.replaceAll("& #40;", "(");
        name = name.replaceAll("& #41;", ")");
        tLine.setName(name);
        tLine.setState(1);
        tLine.setInsertTime(new Date());
        tLine.setInsertUserId(ShiroKit.getUser().getId());
        tLine.setCompanyId(ShiroKit.getUser().getObjectId());
        tLineService.insert(tLine);
    
        //添加线路站点起点+终点
        TLineSite start = new TLineSite();
        start.setLineId(tLine.getId());
        start.setSiteId(startSiteId);
        start.setType(1);
        itLineSiteService.insert(start);
        TLineSite end = new TLineSite();
        end.setLineId(tLine.getId());
        end.setSiteId(endSiteId);
        end.setType(2);
        itLineSiteService.insert(end);
 
        //添加价格设置
        addPrice(tLine.getId(), subArr);
 
        //添加班次设置
        ResultUtil shiftResult = addShift(tLine.getId(), shuArr);
        if(200 != shiftResult.getStatus()){
            return shiftResult;
        }
        //添加目的地设置
        ResultUtil destinationResult = addDestination(tLine.getId(), destArr);
        if(200 != destinationResult.getStatus()){
            return destinationResult;
        }
        return ResultUtil.success();
    }
 
    /**
     * 添加线路班次
     * @param lineId
     * @param shuArr
     */
    private ResultUtil addShift(Integer lineId, @RequestParam String shuArr) {
        try {
            JSONArray jsonArray1 = JSON.parseArray(shuArr);
            int size1 = jsonArray1.size();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            List<String> list = new ArrayList<>();
            for (int i = 0; i < size1; i++) {
                List<TLineShift> tLineShifts = itLineShiftService.selectList(new EntityWrapper<TLineShift>().eq("lineId", lineId).ne("state", 3).orderBy("startTime"));
                JSONObject jsonObject = jsonArray1.getJSONObject(i);
                TLineShift shift = new TLineShift();
                shift.setLineId(lineId);
                String shiftTime = jsonObject.getString("shiftTime");
                String startTime = null;
                String endTime = null;
                if (SinataUtil.isNotEmpty(shiftTime)){
                    String[] timeArray = shiftTime.split(" - ");
                    startTime = timeArray[0];
                    endTime = timeArray[1];
                }
                Date s1 = sdf.parse("2020-11-11 " + startTime + ":00");
                Date e1 = sdf.parse("2020-11-11 " + endTime + ":00");
                if(s1.getTime() >= e1.getTime()){
                    return ResultUtil.error("【" + startTime + " - " + endTime + "】时间段无效,添加失败!");
                }
                boolean b = false;
                for(TLineShift lineShift : tLineShifts){
                    Date s2 = sdf.parse("2020-11-11 " + lineShift.getStartTime() + ":00");
                    Date e2 = sdf.parse("2020-11-11 " + lineShift.getEndTime() + ":00");
                    if(s2.getTime() < s1.getTime() && e1.getTime() < e2.getTime()){
                        list.add(startTime + " - " + endTime);
                        b = true;
                        break;
                    }
                    if(s1.getTime() < s2.getTime() && s1.getTime() < e2.getTime() && e1.getTime() > s2.getTime()){
                        list.add(startTime + " - " + endTime);
                        b = true;
                        break;
                    }
                    if(s1.getTime() > s2.getTime() && s1.getTime() < e2.getTime() && e1.getTime() > e2.getTime()){
                        list.add(startTime + " - " + endTime);
                        b = true;
                        break;
                    }
                }
                if(b){
                    continue;
                }
                shift.setStartTime(startTime);
                shift.setEndTime(endTime);
                shift.setCarNum(jsonObject.getInteger("carNum"));
                shift.setInsertTime(new Date());
                shift.setAddTime(jsonObject.getString("time2"));
                shift.setState(1);
                itLineShiftService.insert(shift);
            }
            if(list.size() > 0){
                return ResultUtil.error("【" + JSON.toJSONString(list) + "】时间段与现存时间段重合,添加失败!");
            }
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    /**
     * 添加线路价格
     * @param lineId
     * @param subArr
     */
    private void addPrice(Integer lineId, @RequestParam String subArr) {
        JSONArray jsonArray = JSON.parseArray(subArr);
        int size = jsonArray.size();
        for (int i = 0; i < size; i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            TLinePrice price = new TLinePrice();
            price.setLineId(lineId);
            price.setServerCarModelId(jsonObject.getInteger("serverModelId"));
            price.setType(jsonObject.getInteger("type"));
            price.setContent(jsonObject.getString("content"));
            price.setContentStr(jsonObject.getString("contentStr"));
            price.setState(1);
            price.setInsertTime(new Date());
            price.setAddTime(jsonObject.getString("time"));
            itLinePriceService.insert(price);
        }
    }
 
    /**
     * 操作跨城站点管理
     * optType 1=删除 2=冻结 3=解冻
     */
    @RequestMapping(value = "/opt")
    @ResponseBody
    public Object opt(@RequestParam Integer tLineId,@RequestParam Integer optType) {
        TLine tLine = tLineService.selectById(tLineId);
        if (1 == optType){
            tLine.setState(3);
        }else if (2 == optType){
            tLine.setState(2);
        }else if (3 == optType){
            tLine.setState(1);
        }
        tLineService.updateById(tLine);
        return SUCCESS_TIP;
    }
 
    /**
     * 分配企业操作
     */
    @RequestMapping(value = "/addCompany")
    @ResponseBody
    public Object addCompany(Integer lineId,@RequestParam String comArr) {
        //删除分配企业
        itLineCompanyService.delete(new EntityWrapper<TLineCompany>().eq("lineId",lineId));
        //添加企业
        if (SinataUtil.isNotEmpty(comArr)){
            JSONArray jsonArray = JSON.parseArray(comArr);
            int size = jsonArray.size();
            for (int i = 0; i < size; i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                TLineCompany lineCompany = new TLineCompany();
                lineCompany.setLineId(lineId);
                lineCompany.setCompanyId(jsonObject.getInteger("companyId"));
                lineCompany.setInsertTime(new Date());
                lineCompany.setInsertUserId(ShiroKit.getUser().getId());
                itLineCompanyService.insert(lineCompany);
            }
        }
        return SUCCESS_TIP;
    }
    /**
     * 修改跨城站点管理
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public ResultUtil update(TLine tLine,Integer startSiteId,Integer endSiteId,@RequestParam String subArr,
                             @RequestParam String shuArr, @RequestParam(required = false) String destArr) {
        JSONArray jsonArray1 = JSON.parseArray(shuArr);
        int size1 = jsonArray1.size();
        for (int i = 0; i < size1; i++) {
            JSONObject jsonObject = jsonArray1.getJSONObject(i);
            String shiftTime = jsonObject.getString("shiftTime");
            if (SinataUtil.isNotEmpty(shiftTime)){
                String[] timeArray = shiftTime.split(" - ");
                String startTime = timeArray[0].split(":")[0];
                String endTime = timeArray[1].split(":")[0];
                if(Integer.valueOf(startTime) >= Integer.valueOf(endTime)){
                    return ResultUtil.error("班次结束时间不能小于开始时间");
                }
            }
        }
        String name = tLine.getName();
        name = name.replaceAll("& lt;", "<");
        name = name.replaceAll("& gt;", ">");
        name = name.replaceAll("& #40;", "(");
        name = name.replaceAll("& #41;", ")");
        tLine.setName(name);
        tLineService.updateById(tLine);
 
        //修改站点起点
        TLineSite start = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLine.getId()).eq("type", 1));
        if (SinataUtil.isNotEmpty(start)){
            if (start.getSiteId().intValue() != startSiteId.intValue()){
                start.setSiteId(startSiteId);
                itLineSiteService.updateById(start);
            }
        }else{
            start = new TLineSite();
            start.setLineId(tLine.getId());
            start.setSiteId(startSiteId);
            start.setType(1);
            itLineSiteService.insert(start);
        }
        //修改站点终点
        TLineSite end = itLineSiteService.selectOne(new EntityWrapper<TLineSite>().eq("lineId", tLine.getId()).eq("type", 2));
        if (SinataUtil.isNotEmpty(end)){
            if (end.getSiteId().intValue() != endSiteId.intValue()){
                end.setSiteId(endSiteId);
                itLineSiteService.updateById(end);
            }
        }else{
            end = new TLineSite();
            end.setLineId(tLine.getId());
            end.setSiteId(endSiteId);
            end.setType(2);
            itLineSiteService.insert(end);
        }
 
        //删除线路价格
        itLinePriceService.delete(new EntityWrapper<TLinePrice>().eq("lineId",tLine.getId()));
        //添加价格设置
        addPrice(tLine.getId(), subArr);
        //删除线路班次
        itLineShiftService.delete(new EntityWrapper<TLineShift>().eq("lineId",tLine.getId()));
        //添加班次设置
        ResultUtil shiftResult = addShift(tLine.getId(), shuArr);
        if(200 != shiftResult.getStatus()){
            return shiftResult;
        }
        //删除线路目的地并重建
        itLineDestinationService.delete(new EntityWrapper<TLineDestination>().eq("lineId", tLine.getId()));
        ResultUtil destinationResult = addDestination(tLine.getId(), destArr);
        if(200 != destinationResult.getStatus()){
            return destinationResult;
        }
        return ResultUtil.success();
 
    }
 
    /**
     * 添加线路目的地配置
     */
    private ResultUtil addDestination(Integer lineId, String destArr) {
        if (SinataUtil.isEmpty(destArr)) {
            return ResultUtil.success();
        }
        JSONArray jsonArray = JSON.parseArray(destArr);
        int size = jsonArray.size();
        if(size <= 0){
            return ResultUtil.success();
        }
        if(size > 3){
            return ResultUtil.error("最多只能添加3个目的地");
        }
        int mainCount = 0;
        for (int i = 0; i < size; i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            String name = ToolUtil.formatting(jsonObject.getString("name"));
            if (SinataUtil.isEmpty(name)) {
                return ResultUtil.error("目的地名称不能为空");
            }
            Integer fenceType = jsonObject.getInteger("fenceType");
            if (fenceType == null || (fenceType != 1 && fenceType != 2)) {
                return ResultUtil.error("围栏类型错误");
            }
            String coordinate = jsonObject.getString("coordinate");
            if (SinataUtil.isEmpty(coordinate)) {
                return ResultUtil.error("目的地围栏不能为空");
            }
 
            BigDecimal price5;
            BigDecimal price7;
            try {
                price5 = new BigDecimal(jsonObject.getString("price5"));
                price7 = new BigDecimal(jsonObject.getString("price7"));
            } catch (Exception ex) {
                return ResultUtil.error("目的地价格格式不正确");
            }
            if (price5.compareTo(BigDecimal.ZERO) < 0 || price7.compareTo(BigDecimal.ZERO) < 0) {
                return ResultUtil.error("目的地价格不能小于0");
            }
 
            Integer isMain = jsonObject.getInteger("isMain");
            if (isMain != null && isMain == 1) {
                mainCount++;
            }
            if(mainCount > 1){
                return ResultUtil.error("最多只能设置一个主要目的地");
            }
 
            Double defaultPointLon = jsonObject.getDouble("defaultPointLon");
            Double defaultPointLat = jsonObject.getDouble("defaultPointLat");
            if (fenceType == 1) {
                String[] arr = coordinate.split(";");
                if (arr.length != 2) {
                    return ResultUtil.error("圆形围栏坐标格式错误");
                }
                String[] center = arr[0].split(",");
                if (center.length != 2) {
                    return ResultUtil.error("圆形围栏中心点格式错误");
                }
                try {
                    defaultPointLon = Double.valueOf(center[0]);
                    defaultPointLat = Double.valueOf(center[1]);
                    double radius = Double.valueOf(arr[1]);
                    if(radius <= 0 || radius > 5000){
                        return ResultUtil.error("圆形围栏半径必须在(0,5000]米");
                    }
                } catch (Exception ex) {
                    return ResultUtil.error("圆形围栏坐标格式错误");
                }
            } else {
                if(defaultPointLon == null || defaultPointLat == null){
                    return ResultUtil.error("多边形围栏需要设置默认点");
                }
            }
 
            TLineDestination destination = new TLineDestination();
            destination.setLineId(lineId);
            destination.setName(name);
            destination.setFenceType(fenceType);
            destination.setCoordinate(coordinate);
            destination.setDefaultPointLon(defaultPointLon);
            destination.setDefaultPointLat(defaultPointLat);
            destination.setPrice5(price5);
            destination.setPrice7(price7);
            Integer state = jsonObject.getInteger("state");
            destination.setState(state == null ? 1 : state);
            destination.setIsMain(isMain == null ? 0 : isMain);
            destination.setAddTime(jsonObject.getString("time"));
            destination.setInsertTime(new Date());
            itLineDestinationService.insert(destination);
        }
        return ResultUtil.success();
    }
 
}