Browse Source

节假日接口KEY,收费站推送数据

develop
王兴琳 5 months ago
parent
commit
c32b627c14
  1. 6
      zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java
  2. 5
      zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java
  3. 15
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  4. 4
      zc-business/src/main/java/com/zc/business/mapper/DcTollStationStatisticsDataMapper.java
  5. 3
      zc-business/src/main/java/com/zc/business/service/IDcTollStationStatisticsDataService.java
  6. 2
      zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java
  7. 8
      zc-business/src/main/java/com/zc/business/service/impl/DcTollStationStatisticsDataImpl.java
  8. 2
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
  9. 33
      zc-business/src/main/resources/mapper/business/DcTollStationStatisticsDataMapper.xml

6
zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarning.java

@ -31,7 +31,7 @@ public class DcTrafficFlowWarning {
private IDcHolidaysService dcHolidaysService;
@Autowired
private IDcGantryStatisticsDataService dcGantryStatisticsDataService;
// @Scheduled(cron = "0/10 * * * * ?")
//@Scheduled(cron = "0/10 * * * * ?")
//@Scheduled(cron = "0 0/5 * * * ?")
public void DcTrafficFlow() {
System.out.println("每隔10秒执行一次:" + new Date());
@ -48,8 +48,8 @@ public class DcTrafficFlowWarning {
LocalDate dateAfterSevenDays = currentDate.plusDays(7);
// 格式化日期输出(可选)
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = dateAfterSevenDays.format(formatter);
// String formattedDate ="2024-05-01";
String formattedDate = dateAfterSevenDays.format(formatter);
//String formattedDate ="2024-05-01";
for (DcHolidays holidays : dcHolidaysList) {
String vacation = holidays.getVacation();

5
zc-business/src/main/java/com/zc/business/controller/DcTrafficFlowWarningDate.java

@ -2,6 +2,7 @@ package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.service.ISysConfigService;
import com.zc.business.domain.DcHolidays;
import com.zc.business.service.IDcHolidaysService;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,12 +24,14 @@ public class DcTrafficFlowWarningDate {
@Autowired
private IDcHolidaysService dcHolidaysService;
@Autowired
private ISysConfigService configService;
//@Scheduled(cron = "0/10 * * * * ?")
public void yearPriorToAcquisition() {
try {
String apiKey = "00b26cbc2cb242283452ac5c842e81d1"; // 替换为你的API密钥
String apiKey= configService.selectConfigByKey("holidayKey");//密钥
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 获取前一年 年份

15
zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

@ -131,7 +131,7 @@ public class DcTrafficStatisticsController extends BaseController {
* @param request 包含查询条件的请求对象用于筛选历史收费站统计数据
* @return 返回一个AjaxResult对象其中包含了查询到的收费站统计数据列表
*/
@ApiOperation("获取收费站统计数据")
@ApiOperation("获取收费站统计数据")
@GetMapping("/history/toll-station")
public AjaxResult historyTollStation(DcTollStationStatisticsData request){
// 调用服务层方法,根据请求条件查询历史车收费站数据
@ -400,14 +400,15 @@ public AjaxResult trafficFlowAtTollStationEntrance(String startDate, String endD
return AjaxResult.success(mapList);
}
/**
* 全路段双向实时车流量
* 获取据库中 收费站统计数据
* @param startDate 时间
* @param direction 方向
* @param accessType 出入口 1入 2出
* @param periodType 方向
*/
@ApiOperation("集团双向实时车流量")
@GetMapping("/history/realTimeTrafficFlowHour2")
public AjaxResult realTimeTrafficFlowHour2(String startDate,Long direction) throws HttpException, IOException{
JSONArray mapList = dcTrafficStatisticsService.realTimeTrafficFlowHour2(startDate,direction);
@ApiOperation("获取据库中收费站数数据")
@GetMapping("/history/TollBoothStatistics")
public AjaxResult TollBoothStatistics(String startDate,String accessType,String periodType) throws HttpException, IOException{
List<DcTollStationStatisticsData> mapList = dcTollStationStatisticsDataService.TollBoothStatistics(startDate,accessType,periodType);
// 将查询结果封装为成功响应并返回
return AjaxResult.success(mapList);
}

4
zc-business/src/main/java/com/zc/business/mapper/DcTollStationStatisticsDataMapper.java

@ -3,8 +3,10 @@ package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.DcTollStationStatisticsData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* 这是一个接口的注释用于描述收费站数据统计的Mapper
@ -29,5 +31,7 @@ public interface DcTollStationStatisticsDataMapper extends BaseMapper<DcTollStat
* @return 返回最大的统计日期
*/
Date getMaxStatisticalDate();
List<DcTollStationStatisticsData> TollBoothStatistics(@Param("startDate") String startDate, @Param("accessType") String accessType, @Param("periodType") String periodType);
}

3
zc-business/src/main/java/com/zc/business/service/IDcTollStationStatisticsDataService.java

@ -1,5 +1,6 @@
package com.zc.business.service;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zc.business.domain.DcTollStationStatisticsData;
@ -37,4 +38,6 @@ public interface IDcTollStationStatisticsDataService extends IService<DcTollStat
* 累计车流量
*/
List<DcTollStationStatisticsData> accumulatedFlow(DcTollStationStatisticsData request);
List<DcTollStationStatisticsData> TollBoothStatistics(String startDate, String accessType, String periodType);
}

2
zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java

@ -53,6 +53,6 @@ public interface IDcTrafficStatisticsService {
List<Map<String, Object>> realTimeTrafficFlowHour(String startDate,Long direction) throws HttpException, IOException;
JSONArray realTimeTrafficFlowHour2(String startDate,Long direction) throws HttpException, IOException;
// JSONArray realTimeTrafficFlowHour2(String startDate,Long direction) throws HttpException, IOException;
}

8
zc-business/src/main/java/com/zc/business/service/impl/DcTollStationStatisticsDataImpl.java

@ -53,6 +53,8 @@ public class DcTollStationStatisticsDataImpl extends ServiceImpl<DcTollStationSt
@Resource
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Resource
private DcTollStationStatisticsDataMapper dcTollStationStatisticsDataMapper;
/**
* 初始化方法用于在对象创建后恢复各种周期的交通收费站站点缓存
@ -231,6 +233,11 @@ public class DcTollStationStatisticsDataImpl extends ServiceImpl<DcTollStationSt
}
@Override
public List<DcTollStationStatisticsData> TollBoothStatistics(String startDate, String accessType, String periodType) {
return dcTollStationStatisticsDataMapper.TollBoothStatistics(startDate,accessType,periodType);
}
/**
* 恢复日缓存数据的方法获取当月收费站站点入口和出口数据
* 该方法首先会获取当前月份的收费站站点入口和出口数据
@ -294,4 +301,5 @@ public class DcTollStationStatisticsDataImpl extends ServiceImpl<DcTollStationSt
}
}

2
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -800,6 +800,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
}
return "";
}
/*
public JSONArray realTimeTrafficFlowHour2(String startDate,Long direction) throws HttpException, IOException {
OkHttp okHttp = new OkHttp();
@ -864,5 +865,6 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
return null;
}
*/
}

33
zc-business/src/main/resources/mapper/business/DcTollStationStatisticsDataMapper.xml

@ -3,7 +3,15 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcTollStationStatisticsDataMapper">
<resultMap type="map" id="countMap">
<result property="id" column="id"/>
<result property="facilityName" column="facility_name"/>
<result property="toll_station_code" column="toll_station_code"/>
<result property="traffic_volume" column="traffic_volume"/>
<result property="period_type" column="period_type"/>
<result property="access_type" column="access_type"/>
<result property="statisticalDate" column="statisticalDate"/>
</resultMap>
<!-- 插入或更新交通路段数据 -->
<insert id="insertOrUpdate" parameterType="com.zc.business.domain.DcTollStationStatisticsData">
INSERT INTO
@ -91,4 +99,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
dc_toll_station_statistics_data
</select>
<select id="TollBoothStatistics" resultMap="countMap" resultType="map" >
SELECT
fa.facility_name,
fa.stake_mark,
dt.id,
dt.access_type,
dt.period_type,
dt.traffic_volume,
dt.toll_station_code,
dt.statistical_date
FROM
dc_facility AS fa
LEFT JOIN
dc_toll_station_statistics_data AS dt
ON
fa.facility_code = dt.toll_station_code
AND DATE(dt.statistical_date) = DATE(#{startDate})
AND dt.period_type = #{periodType}
AND dt.access_type = #{accessType}
WHERE fa.facility_type = 1
</select>
</mapper>

Loading…
Cancel
Save