Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
task3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
首航-临时账号
task3.0
Commits
4d064360
Commit
4d064360
authored
Nov 19, 2020
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开发航线监控定时
parent
95690c91
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
320 additions
and
6 deletions
+320
-6
StatisticalTask.java
src/main/java/com/foc/StatisticalTask.java
+18
-0
StatisticalDao.java
src/main/java/com/foc/dao/StatisticalDao.java
+58
-0
AcType.java
src/main/java/com/foc/entity/AcType.java
+13
-0
StatisticalEntity.java
src/main/java/com/foc/entity/StatisticalEntity.java
+21
-0
DynamicFlightService.java
src/main/java/com/foc/service/DynamicFlightService.java
+106
-0
DateUtils.java
src/main/java/com/foc/util/DateUtils.java
+6
-0
global.properties
src/main/resources/global.properties
+3
-2
StatisticalMapper.xml
src/main/resources/mapper/StatisticalMapper.xml
+89
-0
mybatis-config.xml
src/main/resources/mybatis-config.xml
+6
-4
No files found.
src/main/java/com/foc/StatisticalTask.java
0 → 100644
View file @
4d064360
package
com
.
foc
;
import
com.foc.service.DynamicFlightService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @author LEGION
*/
public
class
StatisticalTask
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
StatisticalTask
.
class
);
public
static
void
main
(
String
[]
args
)
{
DynamicFlightService
.
init
();
DynamicFlightService
.
sta
();
}
}
src/main/java/com/foc/dao/StatisticalDao.java
0 → 100644
View file @
4d064360
package
com
.
foc
.
dao
;
import
com.foc.entity.StatisticalEntity
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @author LEGION
*/
public
interface
StatisticalDao
{
/**
* 获取所有类型为J,状态为ATA的航线
*
* @return
*/
List
<
StatisticalEntity
>
getFlightList
();
/**
* 根据起飞地和到达地获取航线最近时间
*
* @param entity
* @param acTypes
* @return
*/
String
getFlightByDepAndArr
(
@Param
(
value
=
"entity"
)
StatisticalEntity
entity
,
@Param
(
value
=
"acTypes"
)
List
acTypes
);
/**
* 根据论证机型获取小机型
*
* @param verifyAcType
* @return
*/
List
<
String
>
getLacTypesByVerifyAcType
(
String
verifyAcType
);
/**
* 根据论证机型获取小机型
* @param verifyAcTypes
* @return
*/
List
<
String
>
getLacTypesByVerifyAcTypes
(
List
<
String
>
verifyAcTypes
);
/**
* 查询开航指令
*
* @param entity
* @param verifyAcType
* @return
*/
int
getSailingCommand
(
@Param
(
value
=
"entity"
)
StatisticalEntity
entity
,
@Param
(
value
=
"verifyAcType"
)
String
verifyAcType
);
/**
* 批量新增或修改
*
* @param list
*/
void
insertOrUpdateBatch
(
List
<
StatisticalEntity
>
list
);
}
src/main/java/com/foc/entity/AcType.java
0 → 100644
View file @
4d064360
package
com
.
foc
.
entity
;
import
lombok.Data
;
/**
* @author LEGION
*/
@Data
public
class
AcType
{
String
type
;
String
lastTime
;
String
status
;
}
src/main/java/com/foc/entity/StatisticalEntity.java
0 → 100644
View file @
4d064360
package
com
.
foc
.
entity
;
import
lombok.Data
;
/**
* @author LEGION
*/
@Data
public
class
StatisticalEntity
{
private
String
id
;
private
String
arrIata
;
private
String
arrIataName
;
private
String
depIata
;
private
String
depIataName
;
private
String
lastAirlineTime
;
private
String
updateTime
;
private
String
airlineJson
;
private
Integer
delFlag
;
}
src/main/java/com/foc/service/DynamicFlightService.java
0 → 100644
View file @
4d064360
package
com
.
foc
.
service
;
import
com.alibaba.fastjson.JSON
;
import
com.foc.dao.StatisticalDao
;
import
com.foc.entity.AcType
;
import
com.foc.entity.StatisticalEntity
;
import
com.foc.util.DateUtils
;
import
com.foc.util.PropertiesUtils
;
import
com.foc.util.StringUtils
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.CollectionUtils
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Properties
;
/**
* @author LEGION
*/
public
class
DynamicFlightService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
DynamicFlightService
.
class
);
private
static
Reader
reader
;
private
static
SqlSessionFactory
sqlSessionFactory
;
private
static
SqlSession
session
;
public
static
void
init
()
{
try
{
reader
=
Resources
.
getResourceAsReader
(
"mybatis-config.xml"
);
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
reader
);
session
=
sqlSessionFactory
.
openSession
();
}
catch
(
IOException
e
)
{
log
.
error
(
"连接数据库异常"
);
e
.
printStackTrace
();
}
}
public
static
void
sta
()
{
//从配置文件中获取需要统计的大机型
Properties
properties
=
PropertiesUtils
.
getProperties
();
String
verifyAcType
=
properties
.
getProperty
(
"verifyAcType"
);
if
(
StringUtils
.
isEmpty
(
verifyAcType
))
{
log
.
error
(
"获取配置文件中机型的文件"
);
return
;
}
List
<
String
>
verifyAcTypes
=
Arrays
.
asList
(
verifyAcType
.
split
(
","
));
StatisticalDao
dao
=
session
.
getMapper
(
StatisticalDao
.
class
);
//获取航班动态表中所有航班性质为J,状态为ATA,机型为319/A320,321,320neo,330的航线的最后一班时间
List
<
StatisticalEntity
>
list
=
dao
.
getFlightList
();
List
<
StatisticalEntity
>
slist
=
new
ArrayList
<>();
List
<
String
>
acTypes
=
dao
.
getLacTypesByVerifyAcTypes
(
verifyAcTypes
);
list
.
forEach
(
e
->
{
//获取该航线所有论证机型(319/A320,321,320neo,330)的最后执行时间(实际起飞时间)
String
lastDate
=
dao
.
getFlightByDepAndArr
(
e
,
acTypes
);
StatisticalEntity
entity
=
new
StatisticalEntity
();
entity
.
setArrIata
(
e
.
getArrIata
());
entity
.
setArrIataName
(
e
.
getArrIataName
());
entity
.
setDepIata
(
e
.
getDepIata
());
entity
.
setDepIataName
(
e
.
getDepIataName
());
entity
.
setLastAirlineTime
(
lastDate
);
List
<
AcType
>
acTypeList
=
new
ArrayList
<>();
//遍历论证机型查询对应小机型
for
(
String
str
:
verifyAcTypes
)
{
AcType
acType
=
new
AcType
();
acType
.
setType
(
str
);
List
<
String
>
lacTypes
=
dao
.
getLacTypesByVerifyAcType
(
str
);
if
(
CollectionUtils
.
isEmpty
(
lacTypes
))
{
continue
;
}
//获取该航线特定机型下的最后执行时间
String
acTypeLastTime
=
dao
.
getFlightByDepAndArr
(
e
,
lacTypes
);
if
(
StringUtils
.
isEmpty
(
acTypeLastTime
))
{
int
count
=
dao
.
getSailingCommand
(
e
,
str
);
//查询开航指令,有的话为可用
if
(
count
!=
0
)
{
acType
.
setStatus
(
"2"
);
//没有开航指令为不可用
}
else
{
acType
.
setStatus
(
"3"
);
}
acType
.
setLastTime
(
""
);
}
else
{
acType
.
setStatus
(
"1"
);
acType
.
setLastTime
(
acTypeLastTime
);
}
acTypeList
.
add
(
acType
);
}
entity
.
setAirlineJson
(
JSON
.
toJSONString
(
acTypeList
));
entity
.
setUpdateTime
(
DateUtils
.
getTime
(
"yyyy-MM-dd hh:mm:ss"
));
entity
.
setDelFlag
(
0
);
slist
.
add
(
entity
);
});
dao
.
insertOrUpdateBatch
(
slist
);
session
.
commit
();
}
}
src/main/java/com/foc/util/DateUtils.java
View file @
4d064360
package
com
.
foc
.
util
;
package
com
.
foc
.
util
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.ChronoUnit
;
...
@@ -16,4 +17,9 @@ public class DateUtils {
...
@@ -16,4 +17,9 @@ public class DateUtils {
public
static
long
until
(
LocalDateTime
time
)
{
public
static
long
until
(
LocalDateTime
time
)
{
return
Math
.
abs
(
LocalDateTime
.
now
().
until
(
time
,
ChronoUnit
.
MINUTES
));
return
Math
.
abs
(
LocalDateTime
.
now
().
until
(
time
,
ChronoUnit
.
MINUTES
));
}
}
public
static
String
getTime
(
String
formatType
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
formatType
);
return
format
.
format
(
System
.
currentTimeMillis
());
}
}
}
src/main/resources/global.properties
View file @
4d064360
...
@@ -25,4 +25,5 @@ aict=1
...
@@ -25,4 +25,5 @@ aict=1
toEmail
=
zangtao@bbdtek.com
toEmail
=
zangtao@bbdtek.com
#,lisu@bbdtek.com
#,lisu@bbdtek.com
#lisu@bbdtek.com
#lisu@bbdtek.com
fromName
=
sdhkxxaq
fromName
=
sdhkxxaq
\ No newline at end of file
verifyAcType
=
A319/A320,A321,A320neo,A330
\ No newline at end of file
src/main/resources/mapper/StatisticalMapper.xml
0 → 100644
View file @
4d064360
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.foc.dao.StatisticalDao"
>
<select
id=
"getFlightList"
resultType=
"com.foc.entity.StatisticalEntity"
>
SELECT
d.dep_stn AS depIata,
a.city_name AS depIataName,
d.arr_stn AS arrIata,
fa.city_name AS arrIataName
FROM
foc_flight_dynamics d
LEFT JOIN foc_airports a ON d.dep_stn = a.airport_iata
LEFT JOIN foc_airports fa ON d.arr_stn = fa.airport_iata
WHERE
d.`status` = 'ATA'
AND d.`stc` = 'J'
GROUP BY
d.dep_stn,
d.arr_stn
</select>
<select
id=
"getFlightByDepAndArr"
resultType=
"string"
>
SELECT
DATE_FORMAT(atd,'%Y/%m/%d') as lastAirlineTime
from foc_flight_dynamics
where dep_stn=#{entity.depIata} and arr_stn=#{entity.arrIata}
and ac_type in
<foreach
item=
"acType"
collection=
"acTypes"
separator=
","
open=
"("
close=
")"
index=
""
>
#{acType}
</foreach>
order by atd desc limit 1;
</select>
<select
id=
"getLacTypesByVerifyAcType"
resultType=
"string"
>
SELECT
ac_type
from foc_ac_type_compare
where
verify_ac_type=#{verifyAcType}
</select>
<select
id=
"getLacTypesByVerifyAcTypes"
resultType=
"string"
>
SELECT
ac_type
from foc_ac_type_compare
where
verify_ac_type in
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</select>
<select
id=
"getSailingCommand"
resultType=
"int"
>
SELECT
count(*)
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
where a.verif_status='02' AND a.del_flag = 0
and a.depIata=#{entity.depIata} and a.arrIata=#{entity.arrIata}
and b.id=#{verifyAcType}
</select>
<insert
id=
"insertOrUpdateBatch"
parameterType=
"java.util.List"
>
INSERT INTO foc_airline_sta
(arr_iata, arr_iata_name, dep_iata, dep_iata_name, last_airline_time, airline_json, update_date, del_flag)
VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
#{item.arrIata}
, #{item.arrIataName}
, #{item.depIata}
, #{item.depIataName}
, #{item.lastAirlineTime}
, #{item.airlineJson}
, #{item.updateTime}
, #{item.delFlag}
)
</foreach>
ON DUPLICATE KEY UPDATE
last_airline_time = values(last_airline_time)
, airline_json = values(airline_json)
, update_date = values(update_date)
</insert>
</mapper>
\ No newline at end of file
src/main/resources/mybatis-config.xml
View file @
4d064360
...
@@ -45,11 +45,11 @@
...
@@ -45,11 +45,11 @@
<transactionManager
type=
"JDBC"
/>
<transactionManager
type=
"JDBC"
/>
<!-- 配置数据库连接信息 -->
<!-- 配置数据库连接信息 -->
<dataSource
type=
"POOLED"
>
<dataSource
type=
"POOLED"
>
<property
name=
"driver"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"driver"
value=
"com.mysql.
cj.
jdbc.Driver"
/>
<property
name=
"url"
value=
"jdbc:mysql://106.75.
97.50:3306
/jd_foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"
/>
<property
name=
"url"
value=
"jdbc:mysql://106.75.
105.96:5508
/jd_foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"
/>
<!-- <property name="url" value="jdbc:mysql://mysql_server:3306/foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"/>-->
<!-- <property name="url" value="jdbc:mysql://mysql_server:3306/foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"/>-->
<property
name=
"username"
value=
"
focuser
"
/>
<property
name=
"username"
value=
"
sms_develop
"
/>
<property
name=
"password"
value=
"
FOC@2016
"
/>
<property
name=
"password"
value=
"
Develop2018!@#
"
/>
</dataSource>
</dataSource>
</environment>
</environment>
...
@@ -59,6 +59,7 @@
...
@@ -59,6 +59,7 @@
<mappers>
<mappers>
<mapper
resource=
"mapper/SoundsMaxIdMapper.xml"
/>
<mapper
resource=
"mapper/SoundsMaxIdMapper.xml"
/>
<mapper
resource=
"mapper/BlackIpMapper.xml"
/>
<mapper
resource=
"mapper/BlackIpMapper.xml"
/>
<mapper
resource=
"mapper/StatisticalMapper.xml"
/>
</mappers>
</mappers>
</configuration>
</configuration>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment