StatisticsDriveService.java
1.77 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
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import cn.com.glsx.stdinterface.modules.mapper.StatisticsDriveMapper;
import cn.com.glsx.stdinterface.modules.model.StatisticsDrive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 项目名:ne-shield-standard-interfaces
* 包名: cn.com.glsx.stdinterface.modules.service
* 作者: Yanglinlong
* 日期: 2021/8/25 14:27
*/
@Slf4j
@Service
public class StatisticsDriveService {
@Autowired
private StatisticsDriveMapper statisticsDriveMapper;
public List<StatisticsDriveDto> statisticsDriveDataEveryDay() {
// 获取昨天的日期
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
String yesterDayFormat = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
return statisticsDriveMapper.statisticsDriveDataEveryDay(yesterDayFormat);
}
public void insertStatisticsDriveList(List<StatisticsDriveDto> statisticsDriveDtoList) {
for (StatisticsDriveDto statisticsDriveDto : statisticsDriveDtoList) {
StatisticsDrive statisticsDrive = new StatisticsDrive();
statisticsDrive.setSn(statisticsDriveDto.getSn());
statisticsDrive.setDriveNum(statisticsDriveDto.getDriveNum());
statisticsDrive.setDriveTotal(statisticsDriveDto.getDriveTotal());
statisticsDrive.setDriveTime(statisticsDriveDto.getDriveTime());
statisticsDrive.setCreatedTime(new Date());
statisticsDriveMapper.insertSelective(statisticsDrive);
}
}
}