#
luxiaotao1123
2024-09-23 f05b8bd0613b7a56433452a1566e6f24aeff95d8
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
package com.zy.acs.manager.manager.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.acs.framework.common.BaseRes;
import com.zy.acs.manager.common.domain.TaskDto;
import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam;
import com.zy.acs.manager.manager.entity.Bus;
import com.zy.acs.manager.manager.enums.BusStsType;
import com.zy.acs.manager.manager.mapper.BusMapper;
import com.zy.acs.manager.manager.service.BusService;
import com.zy.acs.framework.common.Cools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Slf4j
@Service("busService")
public class BusServiceImpl extends ServiceImpl<BusMapper, Bus> implements BusService {
 
    @Override
    public Bus selectByUuid(String uuid) {
        return this.getOne(new LambdaQueryWrapper<Bus>().eq(Bus::getUuid, uuid));
    }
 
    @Override
    public String checkoutValid(OpenBusSubmitParam param) {
        if (null == param) {
            return BaseRes.PARAM;
        }
        if (Cools.isEmpty(param.getBatch())) {
            return "Batch cannot be empty!";
        }
        for (TaskDto dto : param.getTaskList()) {
            if (!Cools.isEmpty(dto.getOriSta())) {
                if (!Cools.isEmpty(dto.getOriLoc())) {
                    return "OriSta and OriLoc cannot exist at the same time!";
                }
                if (Cools.isEmpty(dto.getDestSta()) && Cools.isEmpty(dto.getDestLoc())) {
                    return "Destination cannot be empty!";
                }
            }
 
            if (!Cools.isEmpty(dto.getDestSta())) {
                if (!Cools.isEmpty(dto.getDestLoc())) {
                    return "DestSta and DestLoc cannot exist at the same time!";
                }
                if (Cools.isEmpty(dto.getOriSta()) && Cools.isEmpty(dto.getOriLoc())) {
                    return "Origin cannot be empty!";
                }
            }
 
        }
        return null;
    }
 
    @Override
    public List<Bus> selectBySts(BusStsType busStsType) {
        return this.selectBySts(busStsType, null);
    }
 
    @Override
    public List<Bus> selectInSts(BusStsType... busStsTypes) {
        List<Long> params = new ArrayList<>();
        for (BusStsType busStsType : busStsTypes) {
            params.add(busStsType.val());
        }
        return this.list(new LambdaQueryWrapper<Bus>().in(Bus::getBusSts, params));
    }
 
    @Override
    public List<Bus> selectBySts(BusStsType busStsType, String memo) {
        LambdaQueryWrapper<Bus> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Bus::getBusSts, busStsType.val());
        if (!Cools.isEmpty(memo)) {
            wrapper.eq(Bus::getMemo, memo);
        }
        return this.list(wrapper);
    }
 
}