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
122e8878
Commit
122e8878
authored
Dec 22, 2020
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
变更航班动态统计逻辑
parent
799df54b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
24 deletions
+76
-24
DspReleaseInfoTask.java
src/main/java/com/foc/DspReleaseInfoTask.java
+30
-2
StatisticalDao.java
src/main/java/com/foc/dao/StatisticalDao.java
+4
-1
DspReleaseInfoService.java
src/main/java/com/foc/service/DspReleaseInfoService.java
+15
-14
DateUtils.java
src/main/java/com/foc/util/DateUtils.java
+15
-0
global.properties
src/main/resources/global.properties
+10
-5
StatisticalMapper.xml
src/main/resources/mapper/StatisticalMapper.xml
+1
-1
mybatis-config.xml
src/main/resources/mybatis-config.xml
+1
-1
No files found.
src/main/java/com/foc/DspReleaseInfoTask.java
View file @
122e8878
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
);
}
}
src/main/java/com/foc/dao/StatisticalDao.java
View file @
122e8878
...
...
@@ -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
);
/**
* 批量新增或修改
...
...
src/main/java/com/foc/service/DspReleaseInfoService.java
View file @
122e8878
...
...
@@ -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"
));
...
...
src/main/java/com/foc/util/DateUtils.java
View file @
122e8878
...
...
@@ -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
);
}
}
src/main/resources/global.properties
View file @
122e8878
...
...
@@ -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
src/main/resources/mapper/StatisticalMapper.xml
View file @
122e8878
...
...
@@ -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
...
...
src/main/resources/mybatis-config.xml
View file @
122e8878
...
...
@@ -39,7 +39,7 @@
<setting
name=
"logImpl"
value=
"STDOUT_LOGGING"
/>
</settings>
<environments
default=
"
dev
"
>
<environments
default=
"
pro
"
>
<environment
id=
"dev"
>
<transactionManager
type=
"JDBC"
/>
...
...
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