Commit cfd1da4d by 罗胜

2023-02-08 罗胜

1.航班执行期监控更新
2.油量分析获取签派放行数据缺少xml文件,解析失败
parent 56067a6c
......@@ -106,7 +106,7 @@
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.foc.StatisticalTask</mainClass>
<mainClass>com.foc.DspReleaseInfoTask</mainClass>
</transformer>
</transformers>
</configuration>
......
......@@ -42,7 +42,7 @@ public class DspReleaseInfoTask {
dates.add(LocalDate.now());
}
DspReleaseInfoService.addInfo(dates);
DspReleaseInfoService.addPltPlan(dates.get(0).plusDays(-1));
// DspReleaseInfoService.addHistoryPltPlan();
DspReleaseInfoService.addPltPlan(LocalDate.now().plusDays(-1));
// DspReleaseInfoService.addPltPlan(LocalDate.parse("2023-02-05", DateTimeFormatter.ofPattern("yyyy-MM-dd")));
}
}
......@@ -65,6 +65,14 @@ public interface StatisticalDao {
*/
String getSailingCommand(@Param(value = "entity") StatisticalEntity entity, @Param(value = "verifyAcType") String verifyAcType);
/***
*
* @param entity
* @param verifyAcType
* @return
*/
String getUnMainSailingCommand(@Param(value = "entity") StatisticalEntity entity, @Param(value = "verifyAcType") String verifyAcType);
/**
* 批量新增或修改
*
......@@ -165,4 +173,7 @@ public interface StatisticalDao {
List<DspReleaseInfo> selectReleaseInfoByDate(@Param("startTime") String startTime,@Param("endTime") String endTime);
int findFltPlanCountByDynamicsId(@Param("dynamicsId") Integer dynamicsId);
}
......@@ -220,7 +220,7 @@ public class DspReleaseInfoService {
public static void decrypt(String resultString, String key, String password, String account, String gatewayUatUrl, StatisticalDao dao) throws GeneralSecurityException, UnsupportedEncodingException {
String response = EncodeUtil.decrypt(resultString, key);
System.out.println(response);
String nowDate=LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String nowDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//转成jsonObject
JSONObject jsonObject = JSON.parseObject(response);
//取出jsonObject中的data
......@@ -235,14 +235,14 @@ public class DspReleaseInfoService {
List<DspReleaseInfo> list = new ArrayList<>();
if (Empty4JUtil.listIsNotEmpty(dspReleaseInfoList)) {
for (DspReleaseInfo ss : dspReleaseInfoList) {
if(ss.getStd().contains(nowDate)){
continue;
}
// if(ss.getStd().contains(nowDate)){
// continue;
// }
int year = DateTime.of(ss.getStd(), "yyyy-MM-dd HH:mm:ss").year();
ss.setDepAirPortName(dao.selectAirPortNameByIataId(ss.getDepIataId()));
ss.setArrAirPortName(dao.selectAirPortNameByIataId(ss.getArrIataId()));
ss.setDispatcherAccount(dao.selectUserNameByLoginName(ss.getDispatcherName()));
ss.setAcTypeName((dao.selectAcTypeNameByAcNo(ss.getAcNo(),year) == null) ? "" : dao.selectAcTypeNameByAcNo(ss.getAcNo(),year));
ss.setAcTypeName((dao.selectAcTypeNameByAcNo(ss.getAcNo(), year) == null) ? "" : dao.selectAcTypeNameByAcNo(ss.getAcNo(), year));
ss.setArrIcaoId(dao.selectIcaoIdByTataId(ss.getArrIataId()));
ss.setDepIcaoId(dao.selectIcaoIdByTataId(ss.getDepIataId()));
ss.setDelFlag("0");
......@@ -284,10 +284,12 @@ public class DspReleaseInfoService {
flightPlan = new FlightPlan();
BeanUtil.copyProperties(fltPLan, flightPlan);
flightPlan.setDynamicsStaId(staId);
cn.hutool.json.JSONObject block = null;
cn.hutool.json.JSONObject aircraft = null;
if (ObjectUtil.equal("0", fltPLan.getCfpFlag()) || ObjectUtil.equal("1", fltPLan.getCfpFlag())) {
if(ObjectUtil.isNull(fltPLan.getPlanContentsXml())||StringUtils.isEmpty(fltPLan.getPlanContentsXml())){
return ;
}
block = XML.toJSONObject(fltPLan.getPlanContentsXml()).getJSONObject("FlightPlan").getJSONObject("Block");
aircraft = XML.toJSONObject(fltPLan.getPlanContentsXml()).getJSONObject("FlightPlan").getJSONObject("Aircraft");
flightPlan.setTakeoffWeight(aircraft.getJSONObject("Weights").getInt("takeoff", 0));
......@@ -321,6 +323,9 @@ public class DspReleaseInfoService {
flightPlan.setEtopTime(block.getJSONObject("Etop").getStr("time"));
}
} else if (ObjectUtil.equal("2", fltPLan.getCfpFlag()) || ObjectUtil.equal("3", fltPLan.getCfpFlag())) {
if(ObjectUtil.isNull(fltPLan.getRecPlanContentsXml())||StringUtils.isEmpty(fltPLan.getRecPlanContentsXml())){
return ;
}
block = XML.toJSONObject(fltPLan.getRecPlanContentsXml()).getJSONObject("FlightPlan").getJSONObject("Block");
aircraft = XML.toJSONObject(fltPLan.getRecPlanContentsXml()).getJSONObject("FlightPlan").getJSONObject("Aircraft");
flightPlan.setTakeoffWeight(aircraft.getJSONObject("Weights").getInt("takeoff", 0));
......@@ -356,6 +361,9 @@ public class DspReleaseInfoService {
flightPlan.setPlanLeftOver(flightPlan.getTotal() - flightPlan.getTrip() - flightPlan.getTaxiOut());
flightPlan.setCreateDate(DateTime.now());
flightPlan.setUpdateDate(DateTime.now());
flightPlan.setLimitingLandingWeight((int) Math.floor(flightPlan.getLimitingLandingWeight() / 2.204617647D));
;
flightPlan.setLimitingTakeoffWeight((int) Math.floor(flightPlan.getLimitingTakeoffWeight() / 2.204617647D));
list.add(flightPlan);
fltPLan = null;
}
......@@ -381,62 +389,84 @@ public class DspReleaseInfoService {
log.error("获取配置文件中机型的文件");
}
StatisticalDao dao = session.getMapper(StatisticalDao.class);
List<Integer> ids = new ArrayList<>();
List<DspReleaseInfo> dspReleaseInfoList = dao.selectReleaseInfoByDate(dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE) + " 00:00:00", dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE)+" 23:59:59");
List<DspReleaseInfo> dspReleaseInfoList = dao.selectReleaseInfoByDate(dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE) + " 00:00:00", dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE) + " 23:59:59");
for (DspReleaseInfo ss : dspReleaseInfoList) {
//生成requestCode
Map<String, String> fltMap = buildFltPlanGatewayRequestString(ss.getFlightNo(), key, userAccount, password, ss.getStd(), ss.getDepIataId(), ss.getArrIataId());
//掉接口
String fltResultString = nativeHttpCall(fltMap, gatewayUatUrl, key);
decryptFlt(ss.getId(), fltResultString, key, dao);
ids.add(ss.getId());
int count = dao.findFltPlanCountByDynamicsId(ss.getId());
if (count < 1) {
Map<String, String> fltMap = buildFltPlanGatewayRequestString(ss.getFlightNo(), key, userAccount, password, ss.getStd(), ss.getDepIataId(), ss.getArrIataId());
//掉接口
String fltResultString = nativeHttpCall(fltMap, gatewayUatUrl, key);
decryptFlt(ss.getId(), fltResultString, key, dao);
}
}
session.commit();
}
public static void addHistoryPltPlan() {
public static void addHistoryPltPlan() {
LocalDateTime endTime = LocalDateTimeUtil.parse("2022-03-14", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
System.out.println(endTime);
LocalDateTime startTime = LocalDateTimeUtil.parse("2022-01-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
System.out.println(startTime);
long days = LocalDateTimeUtil.between(startTime,endTime, ChronoUnit.DAYS);
long days = LocalDateTimeUtil.between(startTime, endTime, ChronoUnit.DAYS);
System.out.println(days);
for (int i = 0; i <=days; i++) {
for (int i = 0; i <= days; i++) {
String plus = startTime.plusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate parse = LocalDate.parse(plus);
System.out.println(parse);
try {
addPltPlan(parse);
}catch (Exception e){
log.error("std:"+parse+e.getMessage());
} catch (Exception e) {
log.error("std:" + parse + e.getMessage());
}
}
}
public static void main(String[] args) {
LocalDateTime endTime = LocalDateTimeUtil.parse("2022-03-14", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
System.out.println(endTime);
LocalDateTime startTime = LocalDateTimeUtil.parse("2022-01-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
System.out.println(startTime);
long days = LocalDateTimeUtil.between(startTime,endTime, ChronoUnit.DAYS);
System.out.println(days);
String format1 = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
for (int i = 0; i <=days; i++) {
LocalDateTime plus = startTime.plusDays(i);
String format = plus.format(DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00"));
if(format.contains(format1)){
continue;
}
String plusStr = startTime.plusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDate parse = LocalDate.parse(plusStr);
System.out.println(parse);
}
public static void main(String[] args) throws GeneralSecurityException, UnsupportedEncodingException {
LocalDate date = LocalDate.parse("2022-08-28", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String gatewayUatUrl = "https://esbgatewaytest.hnair.com/esbforward/getRestInfo";
String key = "SkRfRk9DSU1DX1VBVA0ODw==";
String userAccount = "JD_FOCIMC_UAT";
String password = "+ZwiuDzP8swD5XmjLn/Ln/80DBPZ4YvD/e830qPMDbk=";
//生成requestCode
Map<String, String> map = buildGatewayRequestString("JD5653", key, userAccount, password, date);
//掉接口
// String resultString = nativeHttpCall(map, gatewayUatUrl, key);
String s = "364b8e0e68fbfef895d8314c9e8b88884abfcaa30180624986b0bf4fa6192d34deae04b55bd37198b871f6bf85f49df221cd0be5099b3731ebf5e1de28966f8f9a9467e88e8ce542406a02645ed6838efe14335092fca65bdb2b06a61d0157b7f622dd6098630f0b796f7f74f3ba2ed6193b787d8ee9d5fe6731cca502e88268998df1d3e6e3cdedfae3f1fe16aab82d61b4df6def7bd1deb342b373eeea3d8362b5365ab2a54f14ad3c1825865ee9b73ac697948d9d0cf58ca44ca763b949b59430588d2898594348ed561d60076df11eff60dc2996201fbc93b0766227311cce588f1e28afd4007b2365319f36b34d249ed56e28f62237a0726b16e3ea4ceee74477fd436497e3e9e340886b9836b5762c64ad72c47d78b811d8c0adeecdbd7da6925e7a2623a3b98e8a68906368e7da61d32027d2f6837ba05f911116ff3fc1df9f3a0917ae68bfad9779b8451624e502fa7b70e5c138b7abb3fc7ac1327538c7154a06509db5be425b32903ab77280c69a40bad7741deebe05cf64dfe060e84e4dbf62433f354a09097b4651b6a0555c1f90e058ddbcd36a61f1ef152bc887b7d95bacde45a5";
init();
StatisticalDao dao = session.getMapper(StatisticalDao.class);
decryptFlt(11, s, key, dao);
}
// public static void main(String[] args) {
// LocalDateTime endTime = LocalDateTimeUtil.parse("2022-03-14", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// System.out.println(endTime);
// LocalDateTime startTime = LocalDateTimeUtil.parse("2022-01-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// System.out.println(startTime);
// long days = LocalDateTimeUtil.between(startTime,endTime, ChronoUnit.DAYS);
// System.out.println(days);
// String format1 = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// for (int i = 0; i <=days; i++) {
// LocalDateTime plus = startTime.plusDays(i);
// String format = plus.format(DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00"));
// if(format.contains(format1)){
// continue;
// }
// String plusStr = startTime.plusDays(i).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// LocalDate parse = LocalDate.parse(plusStr);
// System.out.println(parse);
// }
//
// }
}
......@@ -140,7 +140,13 @@ public class DynamicFlightService {
//判断是否有论证,判断范围在verify_type为(01,02,03,04),flight_type为(01正班,02加班,03包机,对应前边航班动态中航班类型为J,G,A)
String verifyDate = dao.getSailingCommand(e, str);
if (StringUtils.isEmpty(verifyDate)) {
acType.setStatus("3");
//判断非主航线的论证
String unMainVerifyDate=dao.getUnMainSailingCommand(e, str);
if(StringUtils.isEmpty(unMainVerifyDate)){
acType.setStatus("3");
}else{
acType.setStatus("2");
}
} else {
acType.setStatus("2");
}
......
......@@ -26,7 +26,7 @@ toEmail=zangtao@bbdtek.com
#,lisu@bbdtek.com
#lisu@bbdtek.com
fromName=sdhkxxaq
verifyAcType=A319/A320,A320neo,A321,321neo,A330
verifyAcType=A319/A320,A320neo,A321,A321neo,A330
#uat
#esb.security.account=JD_FOCIMC_UAT
#esb.security.key=SkRfRk9DSU1DX1VBVA0ODw==
......
......@@ -30,7 +30,7 @@
DATE_FORMAT(std_chn,'%Y/%m/%d') as lastAirlineTime
from foc_flight_dynamics
where dep_stn=#{entity.depIata} and arr_stn=#{entity.arrIata}
AND stc IN ('J', 'A', 'G', 'H')
AND stc IN ('J', 'A', 'G', 'H') AND est_status is not null and est_status !=''
AND `status`!='CNL'
AND `atd_chn` &lt;= #{date}
and ac_type in
......@@ -81,6 +81,9 @@
<when test="verifyAcType=='A319/A320'">
and upper(b.type_name) like concat(upper(#{verifyAcType}),'%')
</when>
<when test="verifyAcType=='321neo'">
and upper(b.type_name) like concat('A',upper(#{verifyAcType}))
</when>
<otherwise>
and upper(b.type_name) = upper(#{verifyAcType})
</otherwise>
......@@ -89,6 +92,39 @@
order by sc.create_date desc limit 1
</select>
<select id="getUnMainSailingCommand" resultType="java.lang.String">
SELECT
sc.create_date
FROM
foc_sailing_command sc
LEFT JOIN foc_airline_verify a ON a.id = sc.verif_id
LEFT JOIN foc_aircraft_type b ON a.aircraft_type = b.id
LEFT JOIN foc_airline_connect fac ON fac.verif_id = sc.verif_id
WHERE
a.verif_type IN ( '01', '02', '03', '04' )
AND a.del_flag = 0
AND ( a.flight_type = '01' OR a.flight_type = '02' OR a.flight_type = '03' )
AND b.del_flag = 0
AND 180-TIMESTAMPDIFF ( DAY, a.start_time, CURRENT_TIMESTAMP )> 0
AND fac.del_flag = '0'
AND fac.Is_main != '0'
AND (( fac.depIata = #{entity.depIata} AND fac.arrIata = #{entity.arrIata} )
OR ( fac.depIata = #{entity.arrIata} AND fac.arrIata = #{entity.depIata} ))
<choose>
<when test="verifyAcType=='A319/A320'">
and upper(b.type_name) like concat(upper(#{verifyAcType}),'%')
</when>
<when test="verifyAcType=='321neo'">
and upper(b.type_name) like concat('A',upper(#{verifyAcType}))
</when>
<otherwise>
and upper(b.type_name) = upper(#{verifyAcType})
</otherwise>
</choose>
ORDER BY
sc.create_date DESC
LIMIT 1
</select>
<insert id="insertOrUpdateBatch" parameterType="java.util.List">
INSERT INTO foc_airline_sta
......@@ -119,7 +155,7 @@
FROM
foc_flight_dynamics ffd
WHERE
ffd.datop_chn = date_sub( #{date}, INTERVAL 1 DAY )
(ffd.datop_chn = date_sub( #{date}, INTERVAL 1 DAY ) or ffd.datop_chn=#{date})
AND ffd.`status` != 'CNL'
AND ffd.ata_chn IS NOT NULL
GROUP BY
......@@ -326,6 +362,12 @@
select airport_icao from foc_airports where airport_iata=#{iataId}
</select>
<select id="selectReleaseInfoByDate" resultType="com.foc.entity.DspReleaseInfo">
select * from foc_flight_dynamics_sta where std BETWEEN #{startTime} and #{endTime}
select * from foc_flight_dynamics_sta where update_time BETWEEN #{startTime} and #{endTime}
</select>
<select id="findFltPlanCountByDynamicsId" resultType="java.lang.Integer">
select count(1) from foc_flight_plan where dynamics_sta_id=#{dynamicsId}
</select>
</mapper>
\ No newline at end of file
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