LinggangSchedulingServiceImpl.java
17.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
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
package com.ruoyi.service.impl.scheduling;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.common.utils.DateUtils;
import com.ruoyi.domain.OrderEntity;
import com.ruoyi.domain.lin.gang.LingangScheduling;
import com.ruoyi.domain.scheduling.LinggangScheduling;
import com.ruoyi.mapper.scheduling.LinggangSchedulingMapper;
import com.ruoyi.scheduling.domain.DriverSchedulingV1;
import com.ruoyi.scheduling.domain.SchedulingDateEntity;
import com.ruoyi.scheduling.service.SchedulingServiceV1;
import com.ruoyi.service.scheduling.LinggangSchedulingService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
/** Service实现类*/
public class LinggangSchedulingServiceImpl extends ServiceImpl<LinggangSchedulingMapper, LinggangScheduling> implements LinggangSchedulingService {
@Autowired
private LinggangSchedulingMapper linggangSchedulingMapper;
@Autowired
private SchedulingServiceV1 schedulingServiceV1;
/**
* 分页查询
*/
@Override
public IPage<LinggangScheduling> pageList(Page<LinggangScheduling> page, LinggangScheduling entity, OrderEntity orderEntity) {
String scheDateStr = null;
if(Objects.nonNull(entity.getScheduleDate())){
scheDateStr= DateUtils.YYYY_MM_DD.format(entity.getScheduleDate());
}
entity.setScheduleDate(null);
LambdaQueryWrapper<LinggangScheduling> countWrapper = new LambdaQueryWrapper<>(entity);
countWrapper.select(LinggangScheduling::getId);
switchScheduleDate(countWrapper, entity);
switchScheduleDateLike(countWrapper,scheDateStr);
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);
switchScheduleDateLike(selectWrapper,scheDateStr);
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) {
LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
switchScheduleDate(wrapper, entity);
return list(wrapper);
}
@Override
public List<LinggangScheduling> list(LinggangScheduling entity, OrderEntity orderEntity) {
String scheDateStr = null;
if(Objects.nonNull(entity.getScheduleDate())){
scheDateStr= DateUtils.YYYY_MM_DD.format(entity.getScheduleDate());
}
entity.setScheduleDate(null);
LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
switchScheduleDateLike(wrapper,scheDateStr);
switchScheduleDate(wrapper, entity);
if (Objects.nonNull(orderEntity)) {
orderColumn(wrapper, orderEntity);
}
return list(wrapper);
}
@Override
public List<LinggangScheduling> list(LinggangScheduling entity, Collection<Long> schedulingIds) {
LambdaQueryWrapper<LinggangScheduling> wrapper = null;
if (Objects.isNull(entity)) {
wrapper = new LambdaQueryWrapper<>();
} else {
wrapper = new LambdaQueryWrapper<>(entity);
}
if (CollectionUtils.isNotEmpty(schedulingIds)) {
wrapper.in(LinggangScheduling::getId, schedulingIds);
}
return list(wrapper);
}
@Override
public List<LinggangScheduling> listByCZ(LinggangScheduling entity) {
return linggangSchedulingMapper.listByCZ(entity);
}
@Override
public Collection<String> listNbbmByEntity(LinggangScheduling entity) {
return linggangSchedulingMapper.listNbbmByEntity(entity);
}
@Override
public List<LinggangScheduling> listNbbm(LinggangScheduling entity, Collection<String> nbbm) {
LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
switchScheduleDate(wrapper, entity);
wrapper.in(LinggangScheduling::getNbbm, nbbm);
return list(wrapper);
}
@Override
public List<LinggangScheduling> listByTime(LinggangScheduling entity) {
SchedulingDateEntity en = schedulingServiceV1.switchSchedulingDate(entity.getScheduleDate());
entity.setStartScheduleDate(en.getStartDate());
entity.setEndScheduleDate(en.getEndDate());
Date date = entity.getScheduleDate();
entity.setScheduleDate(null);
LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(entity);
wrapper.and(wr -> {
String dateStr = DateUtils.YYYY_MM_DD.format(date);
wr.likeRight(LinggangScheduling::getScheduleDate, dateStr).or().between(LinggangScheduling::getFcsjT, entity.getStartScheduleDate().getTime(), entity.getEndScheduleDate().getTime());
});
wrapper.orderByAsc(LinggangScheduling::getFcsjT);
return list(wrapper);
}
// @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 updateAlcoholCountByPrimaryKey(LinggangScheduling entity) {
LambdaUpdateWrapper<LinggangScheduling> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(LinggangScheduling::getAlcoholCount,entity.getAlcoholCount());
wrapper.eq(LinggangScheduling::getId,entity.getId());
return update(wrapper);
}
/***根据主键删除数据*/
@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(), "scheduleDateStr")) {
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(), "fcsjTStr")) {
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(), "zdsjTStr")) {
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(), "scheduleDateStr")) {
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(), "fcsjTStr")) {
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(), "zdsjTStr")) {
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());
}
}
private void switchScheduleDateLike(LambdaQueryWrapper<LinggangScheduling> wrapper, String scheduleDateStr) {
if(StringUtils.isNotBlank(scheduleDateStr)){
wrapper.likeRight(LinggangScheduling::getScheduleDate,scheduleDateStr);
}
}
}