LinggangSchedulingServiceImpl.java
12.1 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
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
package com.ruoyi.service.impl.scheduling;
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.github.pagehelper.PageHelper;
import com.ruoyi.domain.OrderEntity;
import com.ruoyi.domain.scheduling.LinggangScheduling;
import com.ruoyi.mapper.scheduling.LinggangSchedulingMapper;
import com.ruoyi.service.scheduling.LinggangSchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@Service
/** Service实现类*/
public class LinggangSchedulingServiceImpl extends ServiceImpl<LinggangSchedulingMapper, LinggangScheduling> implements LinggangSchedulingService {
@Autowired
private LinggangSchedulingMapper linggangSchedulingMapper;
/**
* 分页查询
*/
@Override
public IPage<LinggangScheduling> pageList(Page<LinggangScheduling> page, LinggangScheduling entity, OrderEntity orderEntity) {
LambdaQueryWrapper<LinggangScheduling> countWrapper = new LambdaQueryWrapper<>(entity);
countWrapper.select(LinggangScheduling::getId);
switchScheduleDate(countWrapper,entity);
int count = count(countWrapper);
List<LinggangScheduling> lists = Collections.emptyList();
if (count > 0) {
PageHelper.startPage((int) page.getCurrent(), (int) page.getSize(), false);
LambdaQueryWrapper<LinggangScheduling> selectWrapper = new LambdaQueryWrapper<>(entity);
switchScheduleDate(selectWrapper,entity);
orderColumn(selectWrapper, orderEntity);
lists = list(selectWrapper);
}
IPage<LinggangScheduling> returnPage = new Page<LinggangScheduling>();
returnPage.setRecords(lists);
returnPage.setPages(count % page.getSize() == 0 ? count / page.getSize() : count / page.getSize() + 1);
returnPage.setCurrent(page.getCurrent());
returnPage.setSize(page.getSize());
returnPage.setTotal(count);
return returnPage;
}
@Override
public List<LinggangScheduling> list(LinggangScheduling entity) {
return list(new LambdaQueryWrapper<>(entity));
}
@Override
public List<LinggangScheduling> listByCZ(LinggangScheduling entity) {
return linggangSchedulingMapper.listByCZ(entity);
}
// @Override
// public List<LinggangScheduling> listOfSelect(LinggangScheduling entity) {
// LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
// wrapper.select(LinggangScheduling::, LinggangScheduling::);
// return list(wrapper);
// }
// @Override
// public List<LinggangScheduling> listOfIds(java.util.Collection<java.lang.Integer> ids) {
// if (org.springframework.util.CollectionUtils.isEmpty(ids)) {
// return java.util.Collections.emptyList();
// }
// LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>();
// wrapper.select(LinggangScheduling::getId,LinggangScheduling::);
// wrapper.in(LinggangScheduling::getId, ids);
// return list(wrapper);
// }
@Override
public LinggangScheduling getOne(LinggangScheduling entity) {
return getOne(new LambdaQueryWrapper<>(entity));
}
@Override
public Integer countId(LinggangScheduling entity) {
LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
switchScheduleDate(wrapper,entity);
wrapper.select(LinggangScheduling::getId);
return count(wrapper);
}
/**
* 插入有值的列
*/
@Override
public int insertSelective(LinggangScheduling entity) {
return linggangSchedulingMapper.insertSelective(entity);
}
/**
* 插入数据
*/
@Override
public boolean insert(LinggangScheduling entity) {
return save(entity);
}
/**
* 根据主键修改数据
*/
@Override
public boolean updateByPrimaryKey(LinggangScheduling entity) {
return updateById(entity);
}
/***根据主键删除数据*/
@Override
public boolean deleteById(Integer id) {
return removeById(id);
}
public static void orderColumn(LambdaQueryWrapper<LinggangScheduling> wrapper, OrderEntity orderEntity) {
if (org.apache.commons.lang3.StringUtils.equals("ascending", orderEntity.getOrder())) {
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "id")) {
wrapper.orderByAsc(LinggangScheduling::getId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "scheduleDate")) {
wrapper.orderByAsc(LinggangScheduling::getScheduleDate);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "lineName")) {
wrapper.orderByAsc(LinggangScheduling::getLineName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "jobCode")) {
wrapper.orderByAsc(LinggangScheduling::getJobCode);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "name")) {
wrapper.orderByAsc(LinggangScheduling::getName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "posts")) {
wrapper.orderByAsc(LinggangScheduling::getPosts);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "lpName")) {
wrapper.orderByAsc(LinggangScheduling::getLpName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "nbbm")) {
wrapper.orderByAsc(LinggangScheduling::getNbbm);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "bcType")) {
wrapper.orderByAsc(LinggangScheduling::getBcType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "fcsjT")) {
wrapper.orderByAsc(LinggangScheduling::getFcsjT);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "zdsjT")) {
wrapper.orderByAsc(LinggangScheduling::getZdsjT);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signInId")) {
wrapper.orderByAsc(LinggangScheduling::getSignInId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "exType")) {
wrapper.orderByAsc(LinggangScheduling::getExType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signTime")) {
wrapper.orderByAsc(LinggangScheduling::getSignTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signType")) {
wrapper.orderByAsc(LinggangScheduling::getSignType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "alcoholFlag")) {
wrapper.orderByAsc(LinggangScheduling::getAlcoholFlag);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "alcoholIntake")) {
wrapper.orderByAsc(LinggangScheduling::getAlcoholIntake);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "remark")) {
wrapper.orderByAsc(LinggangScheduling::getRemark);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "keyInfoId")) {
wrapper.orderByAsc(LinggangScheduling::getKeyInfoId);
}
} else if (org.apache.commons.lang3.StringUtils.equals("descending", orderEntity.getOrder())) {
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "id")) {
wrapper.orderByDesc(LinggangScheduling::getId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "scheduleDate")) {
wrapper.orderByDesc(LinggangScheduling::getScheduleDate);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "lineName")) {
wrapper.orderByDesc(LinggangScheduling::getLineName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "jobCode")) {
wrapper.orderByDesc(LinggangScheduling::getJobCode);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "name")) {
wrapper.orderByDesc(LinggangScheduling::getName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "posts")) {
wrapper.orderByDesc(LinggangScheduling::getPosts);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "lpName")) {
wrapper.orderByDesc(LinggangScheduling::getLpName);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "nbbm")) {
wrapper.orderByDesc(LinggangScheduling::getNbbm);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "bcType")) {
wrapper.orderByDesc(LinggangScheduling::getBcType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "fcsjT")) {
wrapper.orderByDesc(LinggangScheduling::getFcsjT);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "zdsjT")) {
wrapper.orderByDesc(LinggangScheduling::getZdsjT);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signInId")) {
wrapper.orderByDesc(LinggangScheduling::getSignInId);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "exType")) {
wrapper.orderByDesc(LinggangScheduling::getExType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signTime")) {
wrapper.orderByDesc(LinggangScheduling::getSignTime);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "signType")) {
wrapper.orderByDesc(LinggangScheduling::getSignType);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "alcoholFlag")) {
wrapper.orderByDesc(LinggangScheduling::getAlcoholFlag);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "alcoholIntake")) {
wrapper.orderByDesc(LinggangScheduling::getAlcoholIntake);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "remark")) {
wrapper.orderByDesc(LinggangScheduling::getRemark);
}
if (org.apache.commons.lang3.StringUtils.equals(orderEntity.getProp(), "keyInfoId")) {
wrapper.orderByDesc(LinggangScheduling::getKeyInfoId);
}
} else {
wrapper.orderByDesc(LinggangScheduling::getId);
}
}
private void switchScheduleDate(LambdaQueryWrapper<LinggangScheduling> wrapper,LinggangScheduling entity){
if(Objects.nonNull(entity.getStartScheduleDate()) && Objects.nonNull(entity.getEndScheduleDate())){
wrapper.between(LinggangScheduling::getScheduleDate,entity.getStartScheduleDate(),entity.getEndScheduleDate());
}else if(Objects.nonNull(entity.getStartScheduleDate())){
wrapper.ge(LinggangScheduling::getScheduleDate,entity.getStartScheduleDate());
}else if(Objects.nonNull(entity.getEndScheduleDate())){
wrapper.le(LinggangScheduling::getScheduleDate,entity.getEndScheduleDate());
}
}
}