Commit 122e8878 by java-李谡

变更航班动态统计逻辑

parent 799df54b
package com.foc;
import com.foc.service.DspReleaseInfoService;
import com.foc.service.DynamicFlightService;
import com.foc.util.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* @author LEGION
......@@ -13,6 +19,28 @@ public class DspReleaseInfoTask {
public static void main(String[] args) throws Exception {
DspReleaseInfoService.init();
DspReleaseInfoService.addInfo();
List<LocalDate> dates = new ArrayList<>();
//如果参数不为空,开始按照输入时间进行统计
if (args.length != 0) {
log.info("input beginTime:" + args[0] + ",input endTime:" + args[1]);
//获取开始时间到结束时间所有日期
LocalDate startDate = LocalDate.parse(args[0], DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate endDate = LocalDate.parse(args[1], DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//如果开始时间晚于结束时间,退出
if (startDate.isAfter(endDate)) {
log.info("error:input wrongTime");
return;
}
//如果两个时间相同,退出
dates = DateUtils.getDatesBetween(startDate, endDate);
if (CollectionUtils.isEmpty(dates)) {
log.info("error:no static time");
return;
}
} else {
//按照当天数据开始统计
dates.add(LocalDate.now());
}
DspReleaseInfoService.addInfo(dates);
}
}
......@@ -4,6 +4,7 @@ import com.foc.entity.DspReleaseInfo;
import com.foc.entity.StatisticalEntity;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDate;
import java.util.List;
/**
......@@ -72,9 +73,11 @@ public interface StatisticalDao {
/**
* 获取航班号列表
*
* @param date
* @return
*/
List<String> getFlightNoList();
List<String> getFlightNoList(LocalDate date);
/**
* 批量新增或修改
......
......@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.time.LocalDate;
import java.util.*;
/**
......@@ -52,7 +53,7 @@ public class DspReleaseInfoService {
}
public static void addInfo() throws Exception {
public static void addInfo(List<LocalDate> dates) throws Exception {
Properties properties = PropertiesUtils.getProperties();
String gatewayUatUrl = properties.getProperty("esb.security.gateway.uat.url");
String key = properties.getProperty("esb.security.key");
......@@ -61,19 +62,20 @@ public class DspReleaseInfoService {
if (StringUtils.isEmpty(gatewayUatUrl) || StringUtils.isEmpty(key)) {
log.error("获取配置文件中机型的文件");
}
StatisticalDao dao = session.getMapper(StatisticalDao.class);
List<String> flightNoList = dao.getFlightNoList();
for (String s : flightNoList
) {
//生成requestCode
Map<String, String> map = buildGatewayRequestString(s, key, userAccount, password);
//掉接口
String resultString = nativeHttpCall(map, gatewayUatUrl, key);
//解密
decrypt(resultString, key, dao);
for (LocalDate date : dates) {
List<String> flightNoList = dao.getFlightNoList(date);
log.info("开始" + date + "时间统计");
for (String s : flightNoList) {
//生成requestCode
Map<String, String> map = buildGatewayRequestString(s, key, userAccount, password);
//掉接口
String resultString = nativeHttpCall(map, gatewayUatUrl, key);
//解密
decrypt(resultString, key, dao);
}
session.commit();
}
session.commit();
}
......@@ -162,8 +164,7 @@ public class DspReleaseInfoService {
String data = jsonObject.getString("data");
List<DspReleaseInfo> dspReleaseInfoList = JSON.parseArray(data, DspReleaseInfo.class);
if (Empty4JUtil.listIsNotEmpty(dspReleaseInfoList)) {
for (DspReleaseInfo ss : dspReleaseInfoList
) {
for (DspReleaseInfo ss : dspReleaseInfoList) {
ss.setDelFlag("0");
ss.setCreateDate(DateUtils.getTime("yyyy-MM-dd hh:mm:ss"));
ss.setUpdateDate(DateUtils.getTime("yyyy-MM-dd hh:mm:ss"));
......
......@@ -2,10 +2,14 @@ package com.foc.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @author lisu
......@@ -75,4 +79,15 @@ public class DateUtils {
return date;
}
public static List<LocalDate> getDatesBetween(LocalDate startDate, LocalDate endDate) {
long numOfDaysBetween = ChronoUnit.DAYS.between(startDate, endDate);
return IntStream.iterate(0, i -> i + 1).limit(numOfDaysBetween).mapToObj(i -> startDate.plusDays(i)).collect(Collectors.toList());
}
public static void main(String[] args) {
LocalDate startDate = LocalDate.now();
LocalDate endDate = LocalDate.now().plusDays(2);
List<LocalDate> list = getDatesBetween(startDate, endDate);
System.out.println(list);
}
}
......@@ -27,7 +27,12 @@ toEmail=zangtao@bbdtek.com
#lisu@bbdtek.com
fromName=sdhkxxaq
verifyAcType=A319/A320,A321,A320neo,A330
esb.security.account=JD_FOCIMC_UAT
esb.security.key=SkRfRk9DSU1DX1VBVA0ODw==
esb.security.password=+ZwiuDzP8swD5XmjLn/Ln/80DBPZ4YvD/e830qPMDbk=
esb.security.gateway.uat.url=https://esbgatewaytest.hnair.com/esbforward/getRestInfo
\ No newline at end of file
#uat
#esb.security.account=JD_FOCIMC_UAT
#esb.security.key=SkRfRk9DSU1DX1VBVA0ODw==
#esb.security.password=+ZwiuDzP8swD5XmjLn/Ln/80DBPZ4YvD/e830qPMDbk=
#esb.security.gateway.uat.url=https://esbgatewaytest.hnair.com/esbforward/getRestInfo
esb.security.account=JD_FOCIMC_PROD
esb.security.key=SkRfRk9DSU1DX1BST0QODw==
esb.security.password=yR0Uk0z85XYWqZtEnw0eHNGrK48BPpDN8hrgDzZv16s=
esb.security.gateway.uat.url=https://esbgateway.hnair.com/esbgateway/getRestInfo
\ No newline at end of file
......@@ -113,7 +113,7 @@
FROM
foc_flight_dynamics ffd
WHERE
ffd.datop_chn = date_sub( curdate(), INTERVAL 1 DAY )
ffd.datop_chn = date_sub( #{date}, INTERVAL 1 DAY )
AND ffd.`status` != 'CNL'
AND ffd.ata_chn IS NOT NULL
GROUP BY
......
......@@ -39,7 +39,7 @@
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
<environments default="dev">
<environments default="pro">
<environment id="dev">
<transactionManager type="JDBC"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment