diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java index 29c88a5a..d2b000c6 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTimingOfTrafficConditionsController.java @@ -11,6 +11,8 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.io.IOException; +import java.util.Calendar; +import java.util.Date; /** *路况信息 每小时入一次库 @@ -24,13 +26,27 @@ public class DcTimingOfTrafficConditionsController { // 调用服务层方法,获取当前交通指标数据 @Scheduled(cron = "0 0 * * * *") + //@Scheduled(cron = "0 0/1 * * * ?") public void getTheCurrentCongestedSection() throws HttpException, IOException { // 调用服务层方法,获取当前交通指标数据 JSONArray jsonArray = dcTrafficStatisticsService.getTheCurrentCongestedSection(); //插入 数据库 DcRoadConditionInformation dcRoadConditionInformation =new DcRoadConditionInformation(); dcRoadConditionInformation.setOtherConfig(jsonArray.toJSONString()); - dcRoadConditionInformationService.insertDcRoadConditionInformation(dcRoadConditionInformation); + DcRoadConditionInformation dcRoadConditionInformation1 = dcRoadConditionInformationService.selectlistTime().get(0); + Date createTime = dcRoadConditionInformation1.getCreateTime(); + Calendar createTimeCalendar = Calendar.getInstance(); + createTimeCalendar.setTime(createTime); +// 获取 createTime 的小时 + int createHour = createTimeCalendar.get(Calendar.HOUR_OF_DAY); +// 获取当前时间的小时 + Calendar currentCalendar = Calendar.getInstance(); + int currentHour = currentCalendar.get(Calendar.HOUR_OF_DAY); + if (createHour != currentHour) { + dcRoadConditionInformationService.insertDcRoadConditionInformation(dcRoadConditionInformation); + } + } + // 将获取到的交通指标数据封装为成功的结果并返回 - } + } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java b/zc-business/src/main/java/com/zc/business/domain/DcEvent.java index eef30096..48ccfe1d 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEvent.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEvent.java @@ -58,7 +58,7 @@ public class DcEvent { * 2-中 * 3-下 */ - @Excel(name = "方向") + @Excel(name = "方向", readConverterExp = "1=菏泽方向,3=济南方向") //@Excel(name = "方向") @ApiModelProperty("方向") private String direction;