Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
package com.gk.firework.Service.ServiceImpl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.firework.Domain.Exception.BusinessException;
import com.gk.firework.Domain.TransportCarrier;
import com.gk.firework.Domain.UserInfo;
import com.gk.firework.Domain.Utils.FilterObject;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Mapper.TransportCarrierMapper;
import com.gk.firework.Service.TransportCarrierService;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.Map;
 
@Service("transportCarrierService")
public class TransportCarrierServiceImpl extends ServiceImpl<TransportCarrierMapper, TransportCarrier> implements TransportCarrierService {
 
    /**
    * @Description: 分页查询承运人
    * @date 2021/3/30 10:05
    */
    @Override
    public IPage selectPage(Page<TransportCarrier> page, Map filter) {
        //负责人
        String name = (String) filter.get("name");
        //单位名称
        String companyName = (String) filter.get("companyname");
        LambdaQueryWrapper<TransportCarrier> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(TransportCarrier::getName, name)
                .like(TransportCarrier::getCompanyname, companyName)
                .eq(TransportCarrier::getValidflag,true)
                .orderByDesc(TransportCarrier::getCreatetime);
        return this.page(page, queryWrapper);
    }
 
    /**
    * @Description: 新增承运人
    * @date 2021/3/30 10:05
    */
    @Override
    public void addCarrier(TransportCarrier transportCarrier, UserInfo user) {
        transportCarrier.setCreateby(user.getId());
        transportCarrier.setCreatetime(new Date());
        transportCarrier.setCreatebyname(user.getUsername());
        transportCarrier.setValidflag(true);
        this.save(transportCarrier);
    }
 
 
    /**
    * @Description: 修改承运人
    * @date 2021/3/30 10:08
    */
    @Override
    public void modCarrier(TransportCarrier transportCarrier, UserInfo user) {
        transportCarrier.setUpdateby(user.getId());
        transportCarrier.setUpdatebyname(user.getUsername());
        transportCarrier.setUpdatetime(new Date());
        this.updateById(transportCarrier);
    }
 
    @Override
    public void delCarrier(Long id, UserInfo user) {
        TransportCarrier transportCarrier = new TransportCarrier();
        transportCarrier.setId(id);
        transportCarrier.setUpdateby(user.getId());
        transportCarrier.setUpdatebyname(user.getUsername());
        transportCarrier.setUpdatetime(new Date());
        transportCarrier.setValidflag(false);
        this.updateById(transportCarrier);
    }
 
    /**
    * @Description: 承运人 校验
    * @date 2021/4/6 16:10
    */
 
    @Override
    public void checkCarrier(TransportCarrier transportCarrier) {
 
        if (StringUtils.isBlank(transportCarrier.getCompanyname())) {
            throw new BusinessException("单位名称不能为空");
        }
 
        if (StringUtils.isBlank(transportCarrier.getNumber())) {
            throw new BusinessException("危险货物道路运输资质证号不能为空");
        }
 
        if (StringUtils.isBlank(transportCarrier.getAddress())) {
            throw new BusinessException("地址不能为空");
        }
 
        if (StringUtils.isBlank(transportCarrier.getName())) {
            throw new BusinessException("负责人姓名不能为空");
        }
 
        if (StringUtils.isBlank(transportCarrier.getPhone())) {
            throw new BusinessException("负责人联系电话不能为空");
        }
 
        if (transportCarrier.getValidtime() == null) {
            throw new BusinessException("证件有效期不能为空");
        }
 
    }
 
 
}