KeyWorkLocalJob.java
2.05 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
package com.ruoyi.job;
import com.ruoyi.domain.scheduling.LinggangScheduling;
import com.ruoyi.service.driver.NewDriverService;
import com.ruoyi.service.key.location.LinggangKeyWorkLocationService;
import com.ruoyi.service.scheduling.LinggangSchedulingService;
import com.ruoyi.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author liujun
* @date 2024年07月30日 15:12
*/
@Component("KeyWorkLocalJob")
@Slf4j
public class KeyWorkLocalJob implements InitializingBean {
@Autowired
private NewDriverService newDriverService;
@Autowired
private LinggangSchedulingService linggangSchedulingService;
@Autowired
private LinggangKeyWorkLocationService keyWorkLocationService;
public void insertKeyWorkLocalJob(){
String dateStr = DateUtil.YYYY_MM_DD_LINK.format(new Date());
Date date = null;
try {
date = DateUtil.YYYY_MM_DD_LINK.parse(dateStr);
} catch (ParseException e) {
throw new RuntimeException(e);
}
LinggangScheduling scheduling = new LinggangScheduling();
scheduling.setStartScheduleDate(DateUtil.shortDate(date));
scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1));
scheduling.setType(100);
List<LinggangScheduling> linggangSchedulings = linggangSchedulingService.list(scheduling);
Set<Long> idSets = linggangSchedulings.stream().map(LinggangScheduling::getId).collect(Collectors.toSet());
keyWorkLocationService.insertJob(dateStr, null, idSets);
log.info("钥匙存放信息处理完毕");
}
@Override
public void afterPropertiesSet() throws Exception {
}
}