| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | * fixedDelay : 上一个调用结束后再次调用的延时 |
| | | */ |
| | | |
| | | @Scheduled(fixedDelay = 2000) |
| | | @Scheduled(fixedDelay = 10000) |
| | | public void screenHome() { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | Reportingdamage reportingdamage = new Reportingdamage(); |
| | | reportingdamage.setReportingWorkTime("2024-05-11"); |
| | | //reportingdamage.setReportingWorkTime("2024-05-11"); |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | // 计算最近七天的开始日期 |
| | | LocalDate startOfPeriod = today.minusDays(6); // 7天的范围包括今天,所以减去6天 |
| | | // 最近七天的结束日期就是今天 |
| | | LocalDate endOfPeriod = today; |
| | | // 格式化日期为字符串 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String startOfPeriodStr = startOfPeriod.format(formatter); |
| | | String endOfPeriodStr = endOfPeriod.format(formatter); |
| | | // 设置为最近七天的时间范围 |
| | | reportingdamage.setReportingWorkTime("2024-05-11" + " to " + endOfPeriodStr); |
| | | //reportingdamage.setReportingWorkTime(startOfPeriodStr + " to " + endOfPeriodStr); |
| | | //扇形图各设备的加工破损数量 |
| | | List<Reportingdamage> device = reportingWorkService.selectDamage(reportingdamage); |
| | | jsonObject.append("device", device); |
| | | |
| | | //获取次破未补信息 |
| | | List<AwaitingRepair> awaitingRepairs = reportingWorkService.selectAwaitingRepair(); |
| | | jsonObject.append("awaitingRepairs", awaitingRepairs); |