DriverSchedulingExpandServiceImpl.java
4.56 KB
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
package com.ruoyi.expand.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.driver.domain.Driver;
import com.ruoyi.driver.mapper.DriverMapper;
import com.ruoyi.pojo.vo.ExpandResponseViewVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.expand.mapper.DriverSchedulingExpandMapper;
import com.ruoyi.expand.domain.DriverSchedulingExpand;
import com.ruoyi.expand.service.IDriverSchedulingExpandService;
/**
* 跟班设置Service业务层处理
*
* @author guzijian
* @date 2023-09-12
*/
@Service
public class DriverSchedulingExpandServiceImpl implements IDriverSchedulingExpandService {
@Autowired
private DriverSchedulingExpandMapper driverSchedulingExpandMapper;
@Autowired
private DriverMapper driverMapper;
/**
* 查询跟班设置
*
* @param id 跟班设置主键
* @return 跟班设置
*/
@Override
public DriverSchedulingExpand selectDriverSchedulingExpandById(Long id) {
return driverSchedulingExpandMapper.selectDriverSchedulingExpandById(id);
}
/**
* 查询跟班设置列表
*
* @param driverSchedulingExpand 跟班设置
* @return 跟班设置
*/
@Override
public TableDataInfo selectDriverSchedulingExpandList(DriverSchedulingExpand driverSchedulingExpand) {
List<DriverSchedulingExpand> expandList = driverSchedulingExpandMapper.selectDriverSchedulingExpandList(driverSchedulingExpand);
List<ExpandResponseViewVo> vos = new ArrayList<>(expandList.size());
List<String> jobCodes = new ArrayList<>();
for (DriverSchedulingExpand expand : expandList) {
jobCodes.add(expand.getMasterJobCode());
jobCodes.add(expand.getSlaveJobCode());
ExpandResponseViewVo vo = new ExpandResponseViewVo();
BeanUtils.copyProperties(expand, vo);
vos.add(vo);
}
jobCodes = jobCodes.stream().distinct().collect(Collectors.toList());
Map<String, Driver> driverMap = driverMapper.getNameByJobCode(jobCodes).stream().collect(Collectors.toMap(Driver::getJobCode, driver -> driver));
vos = vos.stream().peek(vo -> {
Driver master = driverMap.get(vo.getMasterJobCode());
Driver slave = driverMap.get(vo.getSlaveJobCode());
vo.setMaster(vo.getMasterJobCode() + "/" + (Objects.isNull(master) ? null : master.getPersonnelName()));
vo.setSlave(vo.getSlaveJobCode() + "/" + (Objects.isNull(slave) ? null : slave.getPersonnelName()));
}).collect(Collectors.toList());
return BaseController.getDataTable(vos, new PageInfo(expandList).getTotal());
}
/**
* 新增跟班设置
*
* @param driverSchedulingExpand 跟班设置
* @return 结果
*/
@Override
public int insertDriverSchedulingExpand(DriverSchedulingExpand driverSchedulingExpand) {
driverSchedulingExpand.setCreateTime(DateUtils.getNowDate());
driverSchedulingExpand.setCreateBy(SecurityUtils.getUsername());
return driverSchedulingExpandMapper.insertDriverSchedulingExpand(driverSchedulingExpand);
}
/**
* 修改跟班设置
*
* @param driverSchedulingExpand 跟班设置
* @return 结果
*/
@Override
public int updateDriverSchedulingExpand(DriverSchedulingExpand driverSchedulingExpand) {
driverSchedulingExpand.setUpdateTime(DateUtils.getNowDate());
driverSchedulingExpand.setUpdateBy(SecurityUtils.getUsername());
return driverSchedulingExpandMapper.updateDriverSchedulingExpand(driverSchedulingExpand);
}
/**
* 批量删除跟班设置
*
* @param ids 需要删除的跟班设置主键
* @return 结果
*/
@Override
public int deleteDriverSchedulingExpandByIds(Long[] ids) {
return driverSchedulingExpandMapper.deleteDriverSchedulingExpandByIds(ids);
}
/**
* 删除跟班设置信息
*
* @param id 跟班设置主键
* @return 结果
*/
@Override
public int deleteDriverSchedulingExpandById(Long id) {
return driverSchedulingExpandMapper.deleteDriverSchedulingExpandById(id);
}
}