正在显示
76 个修改的文件
包含
1359 行增加
和
0 行删除
WebRoot/META-INF/MANIFEST.MF
0 → 100644
WebRoot/WEB-INF/lib/aopalliance-1.0.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/asm-3.3.1.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/aspectjweaver.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/c3p0-0.9.1.2.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/cfgatewayadapter.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/commons-logging.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/cxf-2.7.3.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/dom4j-1.6.1.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/ezmorph-1.0.6.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/freemarker-2.3.16.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/gson-1.6.jar
0 → 100644
不能预览此文件类型
不能预览此文件类型
WebRoot/WEB-INF/lib/httpclient-4.2.1.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/httpcore-4.2.2.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/httpcore-nio-4.2.2.jar
0 → 100644
不能预览此文件类型
不能预览此文件类型
WebRoot/WEB-INF/lib/jackson-core-2.2.3.jar
0 → 100644
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
WebRoot/WEB-INF/lib/javassist-3.12.0.GA.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/jmxtools-1.2.1.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/jotm.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/json-lib-2.4-jdk15.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/json.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/jtds-1.2.4.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/log4j-1.2.13.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/mybatis-3.2.8.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/mybatis-spring-1.2.2.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/neethi-3.0.2.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/ojdbc14.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/servlet-api.jar
0 → 100644
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
不能预览此文件类型
WebRoot/WEB-INF/lib/sql2008.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/wsdl4j-1.6.2.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/lib/xmlschema-core-2.0.3.jar
0 → 100644
不能预览此文件类型
WebRoot/WEB-INF/web.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> | ||
3 | + <display-name>flight</display-name> | ||
4 | + <context-param> | ||
5 | + <param-name>contextConfigLocation</param-name> | ||
6 | + <param-value> | ||
7 | + classpath:config/applicationContext.xml, | ||
8 | + classpath:config/applicationContext-webservice.xml | ||
9 | + </param-value> | ||
10 | + </context-param> | ||
11 | + <listener> | ||
12 | + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> | ||
13 | + </listener> | ||
14 | + <servlet> | ||
15 | + <servlet-name>CXFService</servlet-name> | ||
16 | + <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> | ||
17 | + </servlet> | ||
18 | + <servlet-mapping> | ||
19 | + <servlet-name>CXFService</servlet-name> | ||
20 | + <url-pattern>/*</url-pattern> | ||
21 | + </servlet-mapping> | ||
22 | + <welcome-file-list> | ||
23 | + <welcome-file>index.html</welcome-file> | ||
24 | + <welcome-file>index.htm</welcome-file> | ||
25 | + <welcome-file>index.jsp</welcome-file> | ||
26 | + <welcome-file>default.html</welcome-file> | ||
27 | + <welcome-file>default.htm</welcome-file> | ||
28 | + <welcome-file>default.jsp</welcome-file> | ||
29 | + </welcome-file-list> | ||
30 | +</web-app> |
WebRoot/index.jsp
0 → 100644
1 | +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
2 | + pageEncoding="ISO-8859-1"%> | ||
3 | +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
4 | +<html> | ||
5 | +<head> | ||
6 | +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | ||
7 | +<title>Insert title here</title> | ||
8 | +</head> | ||
9 | +<body> | ||
10 | + this is a page | ||
11 | +</body> | ||
12 | +</html> |
build/classes/.gitignore
0 → 100644
src/com/tianbo/flight/dao/FlightDao.java
0 → 100644
src/com/tianbo/flight/entity/Flight.java
0 → 100644
1 | +package com.tianbo.flight.entity; | ||
2 | + | ||
3 | +import java.math.BigDecimal; | ||
4 | +import java.util.Date; | ||
5 | + | ||
6 | +public class Flight { | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + private BigDecimal fid; | ||
11 | + | ||
12 | + private BigDecimal flid; | ||
13 | + | ||
14 | + private String fatt; | ||
15 | + | ||
16 | + private String ffid; | ||
17 | + | ||
18 | + private String stat; | ||
19 | + | ||
20 | + private String ista; | ||
21 | + | ||
22 | + private Date past; | ||
23 | + | ||
24 | + private Date eldt; | ||
25 | + | ||
26 | + private String msta; | ||
27 | + | ||
28 | + private String mist; | ||
29 | + | ||
30 | + private BigDecimal messageBakId; | ||
31 | + | ||
32 | + private String flightnum; | ||
33 | + | ||
34 | + private String impexp; | ||
35 | + | ||
36 | + private BigDecimal state; | ||
37 | + | ||
38 | + private String sendtime; | ||
39 | + | ||
40 | + public BigDecimal getFid() { | ||
41 | + return fid; | ||
42 | + } | ||
43 | + | ||
44 | + public void setFid(BigDecimal fid) { | ||
45 | + this.fid = fid; | ||
46 | + } | ||
47 | + | ||
48 | + public BigDecimal getFlid() { | ||
49 | + return flid; | ||
50 | + } | ||
51 | + | ||
52 | + public void setFlid(BigDecimal flid) { | ||
53 | + this.flid = flid; | ||
54 | + } | ||
55 | + | ||
56 | + public String getFatt() { | ||
57 | + return fatt; | ||
58 | + } | ||
59 | + | ||
60 | + public void setFatt(String fatt) { | ||
61 | + this.fatt = fatt == null ? null : fatt.trim(); | ||
62 | + } | ||
63 | + | ||
64 | + public String getFfid() { | ||
65 | + return ffid; | ||
66 | + } | ||
67 | + | ||
68 | + public void setFfid(String ffid) { | ||
69 | + this.ffid = ffid == null ? null : ffid.trim(); | ||
70 | + } | ||
71 | + | ||
72 | + public String getStat() { | ||
73 | + return stat; | ||
74 | + } | ||
75 | + | ||
76 | + public void setStat(String stat) { | ||
77 | + this.stat = stat == null ? null : stat.trim(); | ||
78 | + } | ||
79 | + | ||
80 | + public String getIsta() { | ||
81 | + return ista; | ||
82 | + } | ||
83 | + | ||
84 | + public void setIsta(String ista) { | ||
85 | + this.ista = ista == null ? null : ista.trim(); | ||
86 | + } | ||
87 | + | ||
88 | + public Date getPast() { | ||
89 | + return past; | ||
90 | + } | ||
91 | + | ||
92 | + public void setPast(Date past) { | ||
93 | + this.past = past; | ||
94 | + } | ||
95 | + | ||
96 | + public Date getEldt() { | ||
97 | + return eldt; | ||
98 | + } | ||
99 | + | ||
100 | + public void setEldt(Date eldt) { | ||
101 | + this.eldt = eldt; | ||
102 | + } | ||
103 | + | ||
104 | + public String getMsta() { | ||
105 | + return msta; | ||
106 | + } | ||
107 | + | ||
108 | + public void setMsta(String msta) { | ||
109 | + this.msta = msta == null ? null : msta.trim(); | ||
110 | + } | ||
111 | + | ||
112 | + public String getMist() { | ||
113 | + return mist; | ||
114 | + } | ||
115 | + | ||
116 | + public void setMist(String mist) { | ||
117 | + this.mist = mist == null ? null : mist.trim(); | ||
118 | + } | ||
119 | + | ||
120 | + public BigDecimal getMessageBakId() { | ||
121 | + return messageBakId; | ||
122 | + } | ||
123 | + | ||
124 | + public void setMessageBakId(BigDecimal messageBakId) { | ||
125 | + this.messageBakId = messageBakId; | ||
126 | + } | ||
127 | + | ||
128 | + public String getFlightnum() { | ||
129 | + return flightnum; | ||
130 | + } | ||
131 | + | ||
132 | + public void setFlightnum(String flightnum) { | ||
133 | + this.flightnum = flightnum == null ? null : flightnum.trim(); | ||
134 | + } | ||
135 | + | ||
136 | + public String getImpexp() { | ||
137 | + return impexp; | ||
138 | + } | ||
139 | + | ||
140 | + public void setImpexp(String impexp) { | ||
141 | + this.impexp = impexp == null ? null : impexp.trim(); | ||
142 | + } | ||
143 | + | ||
144 | + public BigDecimal getState() { | ||
145 | + return state; | ||
146 | + } | ||
147 | + | ||
148 | + public void setState(BigDecimal state) { | ||
149 | + this.state = state; | ||
150 | + } | ||
151 | + | ||
152 | + public String getSendtime() { | ||
153 | + return sendtime; | ||
154 | + } | ||
155 | + | ||
156 | + public void setSendtime(String sendtime) { | ||
157 | + this.sendtime = sendtime == null ? null : sendtime.trim(); | ||
158 | + } | ||
159 | + | ||
160 | + @Override | ||
161 | + public String toString() { | ||
162 | + return "Flight [past=" + past + ", eldt=" + eldt + ",flightnum=" + flightnum + ", impexp=" + impexp + ", sendtime=" + sendtime + "]"; | ||
163 | + } | ||
164 | + | ||
165 | + | ||
166 | +} |
src/com/tianbo/flight/entity/FlightJson.java
0 → 100644
1 | +package com.tianbo.flight.entity; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | + | ||
5 | +public class FlightJson { | ||
6 | + | ||
7 | + private Date ArrivalDate; | ||
8 | + | ||
9 | + private Date DepartureDate; | ||
10 | + | ||
11 | + private String ArrivalDateTime; | ||
12 | + | ||
13 | + private String DepartureDateTime; | ||
14 | + | ||
15 | + private String SendTime; | ||
16 | + | ||
17 | + private String flag; | ||
18 | + | ||
19 | + public String getArrivalDateTime() { | ||
20 | + return ArrivalDateTime; | ||
21 | + } | ||
22 | + | ||
23 | + public void setArrivalDateTime(String arrivalDateTime) { | ||
24 | + ArrivalDateTime = arrivalDateTime; | ||
25 | + } | ||
26 | + | ||
27 | + public String getDepartureDateTime() { | ||
28 | + return DepartureDateTime; | ||
29 | + } | ||
30 | + | ||
31 | + public void setDepartureDateTime(String departureDateTime) { | ||
32 | + DepartureDateTime = departureDateTime; | ||
33 | + } | ||
34 | + | ||
35 | + public String getSendTime() { | ||
36 | + return SendTime; | ||
37 | + } | ||
38 | + | ||
39 | + public void setSendTime(String sendTime) { | ||
40 | + SendTime = sendTime; | ||
41 | + } | ||
42 | + | ||
43 | + public String getFlag() { | ||
44 | + return flag; | ||
45 | + } | ||
46 | + | ||
47 | + public void setFlag(String flag) { | ||
48 | + this.flag = flag; | ||
49 | + } | ||
50 | + | ||
51 | + public Date getArrivalDate() { | ||
52 | + return ArrivalDate; | ||
53 | + } | ||
54 | + | ||
55 | + public void setArrivalDate(Date arrivalDate) { | ||
56 | + ArrivalDate = arrivalDate; | ||
57 | + } | ||
58 | + | ||
59 | + public Date getDepartureDate() { | ||
60 | + return DepartureDate; | ||
61 | + } | ||
62 | + | ||
63 | + public void setDepartureDate(Date departureDate) { | ||
64 | + DepartureDate = departureDate; | ||
65 | + } | ||
66 | + | ||
67 | +} |
1 | +package com.tianbo.flight.service.impl; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | +import java.util.HashMap; | ||
5 | +import java.util.Map; | ||
6 | +import java.util.UUID; | ||
7 | + | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | + | ||
11 | +import com.tianbo.flight.dao.FlightDao; | ||
12 | +import com.tianbo.flight.entity.Flight; | ||
13 | +import com.tianbo.flight.service.FlightService; | ||
14 | +import com.tianbo.flight.util.DateUtils; | ||
15 | +@Service | ||
16 | +public class FlightServiceImpl implements FlightService { | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private FlightDao flightDao; | ||
20 | + | ||
21 | + @Override | ||
22 | + public Flight getTime(String flightnum ,String impexp, String sendtime) { | ||
23 | + Map<String, String> map = new HashMap<String, String>(); | ||
24 | + map.put("flightnum", flightnum); | ||
25 | + map.put("impexp", impexp); | ||
26 | + map.put("sendtime", sendtime); | ||
27 | + return flightDao.getTime(map); | ||
28 | + } | ||
29 | + public static void main(String[] args) | ||
30 | + { | ||
31 | + System.out.println(UUID.randomUUID().toString()); | ||
32 | + Date currtDate = DateUtils.stringToDate((DateUtils.DateToString(new Date(), "yyyy-MM-dd")),"yyyy-MM-dd"); | ||
33 | + System.out.println(currtDate); | ||
34 | + } | ||
35 | + @Override | ||
36 | + public Flight getLastTime(String flightnum, String impexp) { | ||
37 | + Map<String, String> map = new HashMap<String, String>(); | ||
38 | + map.put("flightnum", flightnum); | ||
39 | + map.put("impexp", impexp); | ||
40 | + return flightDao.getLastTime(map); | ||
41 | + } | ||
42 | + | ||
43 | +} |
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.io.IOException; | ||
4 | +import java.text.SimpleDateFormat; | ||
5 | +import java.util.Date; | ||
6 | + | ||
7 | +import com.fasterxml.jackson.core.JsonGenerator; | ||
8 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
9 | +import com.fasterxml.jackson.databind.JsonSerializer; | ||
10 | +import com.fasterxml.jackson.databind.SerializerProvider; | ||
11 | + | ||
12 | +/** | ||
13 | + * 然后在你的POJO上找到日期的get方法 | ||
14 | + * | ||
15 | + * @JsonSerialize(using = CustomDateSerializer.class) | ||
16 | + * public Date getCreateAt() { return createAt; }} | ||
17 | + * @author zhangy | ||
18 | + * | ||
19 | + */ | ||
20 | +public class CustomDateSerializer extends JsonSerializer<Date> { | ||
21 | + | ||
22 | + @Override | ||
23 | + public void serialize(Date value, JsonGenerator jgen, | ||
24 | + SerializerProvider provider) throws IOException, | ||
25 | + JsonProcessingException { | ||
26 | + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); | ||
27 | + String formattedDate = formatter.format(value); | ||
28 | + jgen.writeString(formattedDate); | ||
29 | + } | ||
30 | +} |
src/com/tianbo/flight/util/DateUtils.java
0 → 100644
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.text.ParseException; | ||
4 | +import java.text.SimpleDateFormat; | ||
5 | +import java.util.Date; | ||
6 | + | ||
7 | +import com.sun.jmx.snmp.Timestamp; | ||
8 | + | ||
9 | +public class DateUtils { | ||
10 | + | ||
11 | + /** 日志对象 */ | ||
12 | + | ||
13 | + /** 年-月-日 时:分:秒 显示格式 */ | ||
14 | + // 备注:如果使用大写HH标识使用24小时显示格式,如果使用小写hh就表示使用12小时制格式。 | ||
15 | + public static String DATE_TO_STRING_DETAIAL_PATTERN = "yyyy-MM-dd HH:mm:ss"; | ||
16 | + | ||
17 | + /** 年-月-日 显示格式 */ | ||
18 | + public static String DATE_TO_STRING_SHORT_PATTERN = "yyyy-MM-dd"; | ||
19 | + | ||
20 | + private static SimpleDateFormat simpleDateFormat; | ||
21 | + | ||
22 | + /** | ||
23 | + * Date类型转为指定格式的String类型 | ||
24 | + * | ||
25 | + * @param source | ||
26 | + * @param pattern | ||
27 | + * @return | ||
28 | + */ | ||
29 | + public static String DateToString(Date source, String pattern) { | ||
30 | + simpleDateFormat = new SimpleDateFormat(pattern); | ||
31 | + return simpleDateFormat.format(source); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * | ||
36 | + * unix时间戳转为指定格式的String类型 | ||
37 | + * | ||
38 | + * | ||
39 | + * System.currentTimeMillis()获得的是是从1970年1月1日开始所经过的毫秒数 | ||
40 | + * unix时间戳:是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒 | ||
41 | + * | ||
42 | + * @param source | ||
43 | + * @param pattern | ||
44 | + * @return | ||
45 | + */ | ||
46 | + public static String timeStampToString(long source, String pattern) { | ||
47 | + simpleDateFormat = new SimpleDateFormat(pattern); | ||
48 | + Date date = new Date(source * 1000); | ||
49 | + return simpleDateFormat.format(date); | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * 将日期转换为时间戳(unix时间戳,单位秒) | ||
54 | + * | ||
55 | + * @param date | ||
56 | + * @return | ||
57 | + */ | ||
58 | + public static long dateToTimeStamp(Date date) { | ||
59 | + Timestamp timestamp = new Timestamp(date.getTime()); | ||
60 | + return timestamp.getDateTime() / 1000; | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * | ||
66 | + * 字符串转换为对应日期(可能会报错异常) | ||
67 | + * | ||
68 | + * @param source | ||
69 | + * @param pattern | ||
70 | + * @return | ||
71 | + */ | ||
72 | + public static Date stringToDate(String source, String pattern) { | ||
73 | + simpleDateFormat = new SimpleDateFormat(pattern); | ||
74 | + Date date = null; | ||
75 | + try { | ||
76 | + date = simpleDateFormat.parse(source); | ||
77 | + } catch (ParseException e) { | ||
78 | + } | ||
79 | + return date; | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * 获得当前时间对应的指定格式 | ||
84 | + * | ||
85 | + * @param pattern | ||
86 | + * @return | ||
87 | + */ | ||
88 | + public static String currentFormatDate(String pattern) { | ||
89 | + simpleDateFormat = new SimpleDateFormat(pattern); | ||
90 | + return simpleDateFormat.format(new Date()); | ||
91 | + | ||
92 | + } | ||
93 | + | ||
94 | + public static String timeFormatDate(String pattern,long dateTime) { | ||
95 | + simpleDateFormat = new SimpleDateFormat(pattern); | ||
96 | + return simpleDateFormat.format(new Date(dateTime)); | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * 获得当前unix时间戳(单位秒) | ||
101 | + * | ||
102 | + * @return 当前unix时间戳 | ||
103 | + */ | ||
104 | + public static long currentTimeStamp() { | ||
105 | + return System.currentTimeMillis() / 1000; | ||
106 | + } | ||
107 | + | ||
108 | + //待补充 | ||
109 | + public static void main(String args[]){ | ||
110 | + Date stringToDate = stringToDate("20180615", "yyyymmdd"); | ||
111 | + System.out.println(stringToDate); | ||
112 | + long longTime = new Date().getTime(); | ||
113 | + | ||
114 | + System.out.println("字符串类型的Long日期转换成日期:"); | ||
115 | + String str = "1498457677473"; | ||
116 | + Long dateLong = Long.valueOf(str); | ||
117 | + System.out.println(timeFormatDate("yyyy-MM-dd HH:mm:ss", dateLong)); | ||
118 | + | ||
119 | + } | ||
120 | +} |
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.io.IOException; | ||
4 | +import java.io.StringWriter; | ||
5 | +import java.text.SimpleDateFormat; | ||
6 | +import java.util.List; | ||
7 | +import java.util.Map; | ||
8 | + | ||
9 | +import org.apache.log4j.Logger; | ||
10 | + | ||
11 | +import com.fasterxml.jackson.core.JsonGenerationException; | ||
12 | +import com.fasterxml.jackson.databind.JsonMappingException; | ||
13 | + | ||
14 | +public class JsonConversion { | ||
15 | + /** | ||
16 | + * 日志. | ||
17 | + */ | ||
18 | + private static Logger logger = Logger.getLogger(JsonConversion.class); | ||
19 | + private static final String SIMPLE_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; | ||
20 | + | ||
21 | + /** | ||
22 | + * java对象转换成json字符串 | ||
23 | + * @param obj | ||
24 | + */ | ||
25 | + public static final String writeEntityJSON(Object obj) { | ||
26 | + | ||
27 | + if (null == obj) { | ||
28 | + return "{}"; | ||
29 | + } | ||
30 | + | ||
31 | + StringWriter stringWriter = new StringWriter(); | ||
32 | + | ||
33 | + ObjectMappingCustomer mapper = new ObjectMappingCustomer(); | ||
34 | + mapper.setDateFormat(new SimpleDateFormat(SIMPLE_DATE_FORMAT)); | ||
35 | + try { | ||
36 | + | ||
37 | + mapper.writeValue(stringWriter, obj); | ||
38 | + } catch (JsonGenerationException e) { | ||
39 | + logger.debug(e.getMessage(), e); | ||
40 | + } catch (JsonMappingException e) { | ||
41 | + logger.debug(e.getMessage(), e); | ||
42 | + } catch (IOException e) { | ||
43 | + logger.debug(e.getMessage(), e); | ||
44 | + } | ||
45 | + | ||
46 | + return stringWriter.toString(); | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * List集合转JSON字符串. | ||
51 | + * @param list | ||
52 | + * @return | ||
53 | + */ | ||
54 | + public static final String writeListJSON(List<?> list) { | ||
55 | + | ||
56 | + StringWriter stringWriter = new StringWriter(); | ||
57 | + try { | ||
58 | + ObjectMappingCustomer mapper = new ObjectMappingCustomer(); | ||
59 | + mapper.setDateFormat(new SimpleDateFormat(SIMPLE_DATE_FORMAT)); | ||
60 | + mapper.writeValue(stringWriter,list); | ||
61 | + } catch (JsonGenerationException e) { | ||
62 | + logger.debug(e.getMessage(), e); | ||
63 | + } catch (JsonMappingException e) { | ||
64 | + logger.debug(e.getMessage(), e); | ||
65 | + } catch (IOException e) { | ||
66 | + logger.debug(e.getMessage(), e); | ||
67 | + } | ||
68 | + return stringWriter.toString(); | ||
69 | + | ||
70 | + } | ||
71 | + /** | ||
72 | + * Map集合转换成Json字符串. | ||
73 | + * @param map | ||
74 | + * @return | ||
75 | + */ | ||
76 | + public static final String writeMapJSON(Map<?, ?> map) { | ||
77 | + StringWriter stringWriter = new StringWriter(); | ||
78 | + try { | ||
79 | + ObjectMappingCustomer mapper = new ObjectMappingCustomer(); | ||
80 | + mapper.setDateFormat(new SimpleDateFormat(SIMPLE_DATE_FORMAT)); | ||
81 | + mapper.writeValue(stringWriter,map); | ||
82 | + } catch (JsonGenerationException e) { | ||
83 | + logger.debug(e.getMessage(), e); | ||
84 | + } catch (JsonMappingException e) { | ||
85 | + logger.debug(e.getMessage(), e); | ||
86 | + } catch (IOException e) { | ||
87 | + logger.debug(e.getMessage(), e); | ||
88 | + } | ||
89 | + return stringWriter.toString(); | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * 使用Servlet的输出java对象转换成的json字符串. | ||
94 | + * @param json | ||
95 | + * @throws IOException | ||
96 | + */ | ||
97 | + /*public static final void writeEntityJSONToHttpServletResponse(Object obj) throws IOException{ | ||
98 | + HttpServletResponse response=ServletActionContext.getResponse(); | ||
99 | + | ||
100 | + * 在调用getWriter之前未设置编码(既调用setContentType或者setCharacterEncoding方法设置编码), | ||
101 | + * HttpServletResponse则会返回一个用默认的编码(既ISO-8859-1)编码的PrintWriter实例。这样就会 | ||
102 | + * 造成中文乱码。而且设置编码时必须在调用getWriter之前设置,不然是无效的。 | ||
103 | + * | ||
104 | + response.setContentType("text/html;charset=utf-8"); | ||
105 | + //response.setCharacterEncoding("UTF-8"); | ||
106 | + PrintWriter out = response.getWriter(); | ||
107 | + //JSON在传递过程中是普通字符串形式传递 | ||
108 | + out.println(writeEntityJSON(obj)); | ||
109 | + out.flush(); | ||
110 | + out.close(); | ||
111 | + }*/ | ||
112 | +} |
src/com/tianbo/flight/util/JsonMap.java
0 → 100644
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.lang.reflect.Type; | ||
4 | +import java.util.ArrayList; | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.Iterator; | ||
7 | +import java.util.List; | ||
8 | +import java.util.Map; | ||
9 | + | ||
10 | +import com.google.gson.Gson; | ||
11 | +import com.google.gson.reflect.TypeToken; | ||
12 | + | ||
13 | + | ||
14 | +/** | ||
15 | + * Depiction:模仿NSdictionary实现json解析,使用方法类似HashMap | ||
16 | + * <p/> | ||
17 | + * Modify: | ||
18 | + * <p/> | ||
19 | + * Author: Kevin Lynn | ||
20 | + * <p/> | ||
21 | + * Create Date:2014-4-8 下午5:28:12 | ||
22 | + * <p/> | ||
23 | + * | ||
24 | + * @version 1.0 | ||
25 | + * @since 1.0 | ||
26 | + */ | ||
27 | +public class JsonMap extends HashMap<String, Object> { | ||
28 | + private static final long serialVersionUID = 4567321902312180302L; | ||
29 | + | ||
30 | + public boolean getBoolean(String key) { | ||
31 | + try { | ||
32 | + return getString(key).equals("true"); | ||
33 | + } catch (Exception e) { | ||
34 | + } | ||
35 | + return false; | ||
36 | + } | ||
37 | + | ||
38 | + public int getInt(String key) { | ||
39 | + try { | ||
40 | + return (int) getFloat(key); | ||
41 | + } catch (Exception e) { | ||
42 | + } | ||
43 | + return 0; | ||
44 | + } | ||
45 | + | ||
46 | + public float getFloat(String key) { | ||
47 | + try { | ||
48 | + return Float.parseFloat(get(key).toString()); | ||
49 | + } catch (Exception e) { | ||
50 | + } | ||
51 | + return 0.0f; | ||
52 | + } | ||
53 | + | ||
54 | + public double getDouble(String key) { | ||
55 | + try { | ||
56 | + return Double.parseDouble(get(key).toString()); | ||
57 | + } catch (Exception e) { | ||
58 | + } | ||
59 | + return 0.0f; | ||
60 | + } | ||
61 | + | ||
62 | + public long getLong(String key) { | ||
63 | + try { | ||
64 | + return (long) getDouble(key); | ||
65 | + } catch (Exception e) { | ||
66 | + } | ||
67 | + return 0l; | ||
68 | + } | ||
69 | + | ||
70 | + public String getString(String key) { | ||
71 | + return get(key) != null ? get(key).toString() : null; | ||
72 | + } | ||
73 | + | ||
74 | + @SuppressWarnings ("unchecked") | ||
75 | + public JsonMap getMap(String key) { | ||
76 | + try { | ||
77 | + Map<String, Object> map = (Map<String, Object>) get(key); | ||
78 | + JsonMap data = new JsonMap(); | ||
79 | + for (Iterator<String> keys = map.keySet().iterator(); keys.hasNext();) { | ||
80 | + String k = (String) keys.next(); | ||
81 | + Object v = map.get(k); | ||
82 | + data.put(k, v); | ||
83 | + } | ||
84 | + return data; | ||
85 | + } catch (Exception e) { | ||
86 | + } | ||
87 | + return null; | ||
88 | + } | ||
89 | + | ||
90 | + @SuppressWarnings ("unchecked") | ||
91 | + public List<JsonMap> getListMap(String key) { | ||
92 | + try { | ||
93 | + List<Map<String, Object>> maps = (List<Map<String, Object>>) get(key); | ||
94 | + List<JsonMap> listMap = new ArrayList<JsonMap>(); | ||
95 | + for (Map<String, Object> map : maps) { | ||
96 | + JsonMap data = new JsonMap(); | ||
97 | + for (Iterator<String> keys = map.keySet().iterator(); keys.hasNext();) { | ||
98 | + String k = (String) keys.next(); | ||
99 | + Object v = map.get(k); | ||
100 | + data.put(k, v); | ||
101 | + } | ||
102 | + listMap.add(data); | ||
103 | + } | ||
104 | + return listMap; | ||
105 | + } catch (Exception e) { | ||
106 | + } | ||
107 | + return null; | ||
108 | + } | ||
109 | + | ||
110 | + public static JsonMap toJsonMap(Map<String, Object> map) { | ||
111 | + JsonMap data = new JsonMap(); | ||
112 | + for (Iterator<String> keys = map.keySet().iterator(); keys.hasNext();) { | ||
113 | + String k = (String) keys.next(); | ||
114 | + Object v = map.get(k); | ||
115 | + data.put(k, v); | ||
116 | + } | ||
117 | + return data; | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * Json数据解析 | ||
122 | + * | ||
123 | + * @param json | ||
124 | + * json源串 | ||
125 | + * @return JsonMap | ||
126 | + */ | ||
127 | + public static JsonMap parseJson(String json) { | ||
128 | + return parseJson(json, JsonMap.class); | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Json数据解析 | ||
133 | + * | ||
134 | + * @param json | ||
135 | + * json源串 | ||
136 | + * @return List<JsonMap> | ||
137 | + */ | ||
138 | + public static List<JsonMap> parseJsonArray(String json) { | ||
139 | + List<JsonMap> listMap = new ArrayList<JsonMap>(); | ||
140 | + try { | ||
141 | + Type listType = new TypeToken<List<Map<String, Object>>>() {}.getType(); | ||
142 | + List<Map<String, Object>> list = parseJson(json, listType); | ||
143 | + for (Map<String, Object> map : list) { | ||
144 | + listMap.add(toJsonMap(map)); | ||
145 | + } | ||
146 | + } catch (Exception e) { | ||
147 | + } | ||
148 | + return listMap; | ||
149 | + } | ||
150 | + | ||
151 | + /** | ||
152 | + * Json数据解析 | ||
153 | + * | ||
154 | + * @param json | ||
155 | + * json源串 | ||
156 | + * @param cls | ||
157 | + * 存储json的实体类 | ||
158 | + * @return 相应的实体类对象 | ||
159 | + */ | ||
160 | + public static <T> T parseJson(String json, Type cls) { | ||
161 | + try { | ||
162 | + Gson gson = new Gson(); | ||
163 | + return gson.fromJson(json, cls); | ||
164 | + } catch (Exception e) { | ||
165 | + } | ||
166 | + return null; | ||
167 | + } | ||
168 | + | ||
169 | + @Override | ||
170 | + public Object get(Object key) { | ||
171 | + return super.get(key); | ||
172 | + } | ||
173 | + | ||
174 | + @Override | ||
175 | + public String toString() { | ||
176 | + try { | ||
177 | + Gson gson = new Gson(); | ||
178 | + return gson.toJson(this); | ||
179 | + } catch (Exception e) { | ||
180 | + } | ||
181 | + return super.toString(); | ||
182 | + } | ||
183 | +} |
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.util.ArrayList; | ||
4 | +import java.util.List; | ||
5 | + | ||
6 | + | ||
7 | +/** | ||
8 | + * Depiction: 多图json数据重组实现,依赖gson库 | ||
9 | + * <p> | ||
10 | + * Modify: | ||
11 | + * <p> | ||
12 | + * Author: Kevin Lynn | ||
13 | + * <p> | ||
14 | + * Create Date:2015年11月26日 下午5:45:16 | ||
15 | + * <p> | ||
16 | + * | ||
17 | + * @version 1.0 | ||
18 | + * @since 1.0 | ||
19 | + */ | ||
20 | +public class MultipleImgsJson { | ||
21 | + | ||
22 | + private MultipleImgsJson() { | ||
23 | + | ||
24 | + } | ||
25 | + | ||
26 | + /** | ||
27 | + * 重组多图的json数据,为每个图片对象添加duration字段,单位分钟。 | ||
28 | + * | ||
29 | + * @param oldJson 原有json数据 | ||
30 | + * @return 重组后的json数据 | ||
31 | + */ | ||
32 | + public static String rebuildJson(String oldJson) { | ||
33 | + JsonMap data = JsonMap.parseJson(oldJson); | ||
34 | + if (data != null) { | ||
35 | + List<JsonMap> imgs = data.getListMap("imgs"); | ||
36 | + if (imgs != null) { | ||
37 | + List<JsonMap> newImgs = new ArrayList<JsonMap>(); | ||
38 | + for (JsonMap img : imgs) { | ||
39 | + String n = img.getString("n"); | ||
40 | + //11月26日16时55分 | ||
41 | + if (n != null && n.trim().length() > 0 && n.contains("日")) { | ||
42 | + String[] array = n.split("日"); | ||
43 | + if (array != null && array.length > 1) { | ||
44 | + String time = array[1].replace("时", "").replace("分", ""); | ||
45 | + int hour = Integer.parseInt(time.substring(0, 2)); | ||
46 | + int min = Integer.parseInt(time.substring(2, 4)); | ||
47 | + int total = hour * 60 + min; | ||
48 | + img.put("duration", total); | ||
49 | + newImgs.add(img); | ||
50 | + } | ||
51 | + } | ||
52 | + } | ||
53 | + data.put("imgs", newImgs); | ||
54 | + return data.toString(); | ||
55 | + } | ||
56 | + } | ||
57 | + | ||
58 | + return null; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * 重组多图的json数据,为每个图片对象添加duration字段,单位分钟。 | ||
63 | + * | ||
64 | + * @param oldJson 原有json数据 | ||
65 | + * @return 重组后的json数据 | ||
66 | + */ | ||
67 | + public static JsonMap rebuildJson2JsonMap(String oldJson) { | ||
68 | + JsonMap data = JsonMap.parseJson(oldJson); | ||
69 | + if (data != null) { | ||
70 | + List<JsonMap> imgs = data.getListMap("imgs"); | ||
71 | + if (imgs != null) { | ||
72 | + List<JsonMap> newImgs = new ArrayList<JsonMap>(); | ||
73 | + for (JsonMap img : imgs) { | ||
74 | + String n = img.getString("n"); | ||
75 | + //11月26日16时55分 | ||
76 | + if (n != null && n.trim().length() > 0 && n.contains("日")) { | ||
77 | + String[] array = n.split("日"); | ||
78 | + if (array != null && array.length > 1) { | ||
79 | + String time = array[1].replace("时", "").replace("分", ""); | ||
80 | + int hour = Integer.parseInt(time.substring(0, 2)); | ||
81 | + int min = Integer.parseInt(time.substring(2, 4)); | ||
82 | + int total = hour * 60 + min; | ||
83 | + img.put("duration", total); | ||
84 | + newImgs.add(img); | ||
85 | + } | ||
86 | + } | ||
87 | + } | ||
88 | + data.put("imgs", newImgs); | ||
89 | + return data; | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + return null; | ||
94 | + } | ||
95 | +} |
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.io.IOException; | ||
4 | + | ||
5 | +import com.fasterxml.jackson.core.JsonGenerator; | ||
6 | +import com.fasterxml.jackson.core.JsonParser; | ||
7 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
8 | +import com.fasterxml.jackson.databind.JsonSerializer; | ||
9 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
10 | +import com.fasterxml.jackson.databind.SerializerProvider; | ||
11 | +/** | ||
12 | + * 解决jackson输出null为空字符串、单引号、字段和数字加引号问题. | ||
13 | + * @author wangchenbo | ||
14 | + * | ||
15 | + */ | ||
16 | +public class ObjectMappingCustomer extends ObjectMapper { | ||
17 | + | ||
18 | + public ObjectMappingCustomer() { | ||
19 | + super(); | ||
20 | + // 允许单引号 | ||
21 | + this.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); | ||
22 | + // 字段和值都加引号 | ||
23 | + this.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); | ||
24 | + // 转义字符-异常情况 | ||
25 | + this.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true); | ||
26 | + // 数字也加引号 | ||
27 | + this.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, true); | ||
28 | + this.configure(JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS, true); | ||
29 | + | ||
30 | + // 空值处理为空串 | ||
31 | + this.getSerializerProvider().setNullValueSerializer( | ||
32 | + new JsonSerializer<Object>() { | ||
33 | + | ||
34 | + @Override | ||
35 | + public void serialize(Object value, JsonGenerator jg, | ||
36 | + SerializerProvider sp) throws IOException, | ||
37 | + JsonProcessingException { | ||
38 | + jg.writeString(""); | ||
39 | + } | ||
40 | + }); | ||
41 | + | ||
42 | + } | ||
43 | +} |
1 | +package com.tianbo.flight.util; | ||
2 | + | ||
3 | +import java.util.Properties; | ||
4 | + | ||
5 | +public class PropertiesUtils { | ||
6 | + | ||
7 | + private static Properties properties=new Properties(); | ||
8 | + | ||
9 | + static{ | ||
10 | + try { | ||
11 | + //注意属性配置文件所在的路径 | ||
12 | + properties.load(PropertiesUtils.class.getClassLoader().getResourceAsStream("/config/time.properties")); | ||
13 | + } catch (Exception e) { | ||
14 | + System.out.println(e.getMessage()); | ||
15 | + } | ||
16 | + } | ||
17 | + | ||
18 | + //读取属性配置文件中的某个属性对应的值 | ||
19 | + public static String readProperty(String property){ | ||
20 | + return (String) properties.get(property); | ||
21 | + } | ||
22 | + | ||
23 | +} |
1 | +package com.tianbo.flight.webservice; | ||
2 | + | ||
3 | +import javax.jws.WebParam; | ||
4 | +import javax.jws.WebService; | ||
5 | + | ||
6 | +@WebService | ||
7 | +public interface FlightWebService { | ||
8 | + | ||
9 | + public String getTime(@WebParam(name="flightnum") String flightnum,@WebParam(name="impexp") String impexp,@WebParam(name="sendtime") String sendtime); | ||
10 | + | ||
11 | +} |
1 | +package com.tianbo.flight.webservice.impl; | ||
2 | + | ||
3 | +import java.text.SimpleDateFormat; | ||
4 | +import java.util.Date; | ||
5 | + | ||
6 | +import javax.jws.WebService; | ||
7 | + | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | +import org.springframework.transaction.annotation.Transactional; | ||
11 | + | ||
12 | +import com.tianbo.flight.entity.Flight; | ||
13 | +import com.tianbo.flight.entity.FlightJson; | ||
14 | +import com.tianbo.flight.service.FlightService; | ||
15 | +import com.tianbo.flight.util.DateUtils; | ||
16 | +import com.tianbo.flight.util.JsonConversion; | ||
17 | +import com.tianbo.flight.util.PropertiesUtils; | ||
18 | +import com.tianbo.flight.webservice.FlightWebService; | ||
19 | + | ||
20 | +@Transactional | ||
21 | +@Service | ||
22 | +@WebService(endpointInterface = "com.tianbo.flight.webservice.FlightWebService", serviceName = "flightWebService") | ||
23 | +public class FlightWebServiceImpl implements FlightWebService { | ||
24 | + | ||
25 | + @Autowired | ||
26 | + private FlightService flightService; | ||
27 | + | ||
28 | + @Override | ||
29 | + public String getTime(String flightnum, String impexp, String sendtime) { | ||
30 | + String flag_twenty_value = PropertiesUtils.readProperty("flag_twenty"); | ||
31 | + long flag_twenty = Long.valueOf(flag_twenty_value); | ||
32 | + SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmm"); | ||
33 | + Date currentTime = new Date(); | ||
34 | + long flag = 14400000; // 4小时 | ||
35 | + // long flag_twenty = 1200000; //20分钟 | ||
36 | + long flag_half = 1800000; // 30分钟 | ||
37 | + long flag_two=7200000;//2小时 | ||
38 | + Flight flight = flightService.getTime(flightnum, impexp, sendtime); | ||
39 | + if (flight != null) { | ||
40 | + Date DepartureDate = flight.getPast(); // 离岗时间 | ||
41 | + Date ArrivalDate = flight.getEldt(); // 到达时间 | ||
42 | + long day = (ArrivalDate.getTime() - DepartureDate.getTime()); // 航程 | ||
43 | + FlightJson flightJson = new FlightJson(); | ||
44 | + | ||
45 | + if (day > flag) { // 航程超过4小时 | ||
46 | + flightJson.setFlag("1"); | ||
47 | + if (currentTime.getTime() - DepartureDate.getTime() > 0) { // 当前时间大于起飞时间 不符合时效 | ||
48 | + if (ArrivalDate.getTime() - currentTime.getTime() > 0) { // 当前时间早于降落时间 | ||
49 | + long sendTime = currentTime.getTime(); | ||
50 | + long departureDateTime = sendTime + flag_twenty; | ||
51 | + long arrivalDateTime = departureDateTime + flag_twenty; | ||
52 | + flightJson.setSendTime(df.format(sendTime) + "38038"); | ||
53 | + flightJson.setArrivalDateTime(df.format(arrivalDateTime) + "38086"); | ||
54 | + flightJson.setDepartureDateTime(df.format(departureDateTime) + "38086"); | ||
55 | + Date departureDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", departureDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
56 | + Date arrivalDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", arrivalDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
57 | + flightJson.setDepartureDate(departureDate); | ||
58 | + flightJson.setArrivalDate(arrivalDate); | ||
59 | + } else { // 晚于 | ||
60 | + flightJson.setSendTime(df.format(new Date()) + "38038"); | ||
61 | + flightJson.setArrivalDateTime(df.format(ArrivalDate) + "38086"); | ||
62 | + flightJson.setDepartureDateTime(df.format(DepartureDate) + "38086"); | ||
63 | + flightJson.setDepartureDate(DepartureDate); | ||
64 | + flightJson.setArrivalDate(ArrivalDate); | ||
65 | + } | ||
66 | + } else { // 符合时效 | ||
67 | + flightJson.setSendTime(df.format(new Date()) + "38038"); | ||
68 | + flightJson.setArrivalDateTime(df.format(ArrivalDate) + "38086"); | ||
69 | + flightJson.setDepartureDateTime(df.format(DepartureDate) + "38086"); | ||
70 | + flightJson.setDepartureDate(DepartureDate); | ||
71 | + flightJson.setArrivalDate(ArrivalDate); | ||
72 | + } | ||
73 | + | ||
74 | + } else {// 4小时内 | ||
75 | + flightJson.setFlag("0"); | ||
76 | + if (currentTime.getTime() - DepartureDate.getTime() > 0) {// 当前时间>起飞时间 | ||
77 | + if (ArrivalDate.getTime() - currentTime.getTime() > 0) { // 当前时间是否早于降落时间 | ||
78 | + long sendTime = currentTime.getTime(); | ||
79 | + long departureDateTime = sendTime + flag_twenty; | ||
80 | + long arrivalDateTime = departureDateTime + flag_twenty; | ||
81 | + flightJson.setSendTime(df.format(sendTime) + "38038"); | ||
82 | + flightJson.setArrivalDateTime(df.format(arrivalDateTime) + "38086"); | ||
83 | + flightJson.setDepartureDateTime(df.format(departureDateTime) + "38086"); | ||
84 | + Date departureDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", departureDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
85 | + Date arrivalDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", arrivalDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
86 | + flightJson.setDepartureDate(departureDate); | ||
87 | + flightJson.setArrivalDate(arrivalDate); | ||
88 | + } else { // 晚于 | ||
89 | + flightJson.setSendTime(df.format(new Date()) + "38038"); | ||
90 | + flightJson.setArrivalDateTime(df.format(ArrivalDate) + "38086"); | ||
91 | + flightJson.setDepartureDateTime(df.format(DepartureDate) + "38086"); | ||
92 | + | ||
93 | + flightJson.setDepartureDate(DepartureDate); | ||
94 | + flightJson.setArrivalDate(ArrivalDate); | ||
95 | + } | ||
96 | + }else{ | ||
97 | + flightJson.setSendTime(df.format(new Date()) + "38038"); | ||
98 | + flightJson.setArrivalDateTime(df.format(ArrivalDate) + "38086"); | ||
99 | + flightJson.setDepartureDateTime(df.format(DepartureDate) + "38086"); | ||
100 | + flightJson.setDepartureDate(DepartureDate); | ||
101 | + flightJson.setArrivalDate(ArrivalDate); | ||
102 | + } | ||
103 | + } | ||
104 | + String json = JsonConversion.writeEntityJSON(flightJson); | ||
105 | + // return flightService.getTime(flightnum, | ||
106 | + // impexp,sendtime).toString(); | ||
107 | + return json; | ||
108 | + } else { | ||
109 | + FlightJson flightJson = new FlightJson(); | ||
110 | + Date date = DateUtils.stringToDate((DateUtils.DateToString(new Date(), "yyyy-MM-dd HH:mm:ss")),"yyyy-MM-dd HH:mm:ss"); | ||
111 | + Date currtDate = DateUtils.stringToDate((DateUtils.DateToString(new Date(), "yyyy-MM-dd")),"yyyy-MM-dd"); | ||
112 | + Date DepartureDate = DateUtils.stringToDate(sendtime, "yyyyMMdd"); //最后一班到达时间 | ||
113 | + long arrivalDateTime = DepartureDate.getTime() + flag_two; | ||
114 | + if(currtDate.getTime()-DepartureDate.getTime()!=0){ //查询航班日期与当前日期是否相差。只取年月日 | ||
115 | + flightJson.setSendTime(df.format(date) + "38038");//当前时间 | ||
116 | + flightJson.setDepartureDateTime(df.format(DepartureDate) + "38086");//查询时间 | ||
117 | + Date arrivalDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", arrivalDateTime), "yyyy-MM-dd HH:mm:ss");; | ||
118 | + flightJson.setArrivalDate(arrivalDate); | ||
119 | + flightJson.setDepartureDate(DepartureDate); | ||
120 | + flightJson.setArrivalDateTime(df.format(arrivalDateTime) + "38086"); | ||
121 | + }else{ | ||
122 | + flightJson = new FlightJson(); | ||
123 | + long departureDateTime = date.getTime() + flag_half; | ||
124 | + arrivalDateTime = departureDateTime + flag_half; | ||
125 | + Date departureDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", departureDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
126 | + Date arrivalDate = DateUtils.stringToDate(DateUtils.timeFormatDate("yyyy-MM-dd HH:mm:ss", arrivalDateTime), "yyyy-MM-dd HH:mm:ss"); | ||
127 | + flightJson.setSendTime(df.format(date) + "38038"); | ||
128 | + flightJson.setDepartureDateTime(df.format(departureDateTime) + "38086"); | ||
129 | + flightJson.setArrivalDateTime(df.format(arrivalDateTime) + "38086"); | ||
130 | + flightJson.setDepartureDate(departureDate); | ||
131 | + flightJson.setArrivalDate(arrivalDate); | ||
132 | + } | ||
133 | + String json = JsonConversion.writeEntityJSON(flightJson); | ||
134 | + return json; | ||
135 | + } | ||
136 | + } | ||
137 | + | ||
138 | +} |
src/config/applicationContext-webservice.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<beans xmlns="http://www.springframework.org/schema/beans" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xmlns:aop="http://www.springframework.org/schema/aop" | ||
5 | + xmlns:jaxws="http://cxf.apache.org/jaxws" | ||
6 | + xsi:schemaLocation="http://www.springframework.org/schema/aop | ||
7 | + http://www.springframework.org/schema/aop/spring-aop-4.1.xsd | ||
8 | + http://www.springframework.org/schema/beans | ||
9 | + http://www.springframework.org/schema/beans/spring-beans.xsd | ||
10 | + http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> | ||
11 | + | ||
12 | + <import resource="classpath:META-INF/cxf/cxf.xml" /> | ||
13 | + <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> | ||
14 | + | ||
15 | + | ||
16 | + <jaxws:endpoint id="flightWebService" address="/flightWebService" | ||
17 | + implementor="com.tianbo.flight.webservice.impl.FlightWebServiceImpl" /> | ||
18 | + | ||
19 | +</beans> |
src/config/applicationContext.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<beans xmlns="http://www.springframework.org/schema/beans" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xmlns:context="http://www.springframework.org/schema/context" | ||
5 | + xmlns:p="http://www.springframework.org/schema/p" | ||
6 | + xmlns:aop="http://www.springframework.org/schema/aop" | ||
7 | + xmlns:tx="http://www.springframework.org/schema/tx" | ||
8 | + xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd | ||
9 | + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
10 | + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd | ||
11 | + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> | ||
12 | + | ||
13 | + <!-- 采用注释的方式配置bean --> | ||
14 | + <context:annotation-config/> | ||
15 | + <!-- 配置要扫描的包 --> | ||
16 | + <context:component-scan base-package="com.tianbo.flight"/> | ||
17 | + <!-- 数据库配置文件位置 --> | ||
18 | + <context:property-placeholder location="classpath:config/init.properties"/> | ||
19 | + <!-- 配置数据源 oracle c3p0--> | ||
20 | + <bean id="dataSourceTarget" class="com.mchange.v2.c3p0.ComboPooledDataSource" | ||
21 | + p:driverClass="${jdbc.driverClassName}" | ||
22 | + p:jdbcUrl="${jdbc.url}" | ||
23 | + p:user="${jdbc.username}" | ||
24 | + p:password="${jdbc.password}" | ||
25 | + p:checkoutTimeout="${cpool.checkoutTimeout}" | ||
26 | + p:minPoolSize="${cpool.minPoolSize}" | ||
27 | + p:maxPoolSize="${cpool.maxPoolSize}" | ||
28 | + p:maxIdleTime="${cpool.maxIdleTime}" | ||
29 | + destroy-method="close" | ||
30 | + ></bean> | ||
31 | + | ||
32 | + <bean id="dataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy"> | ||
33 | + <property name="targetDataSource" ref="dataSourceTarget"></property> | ||
34 | + </bean> | ||
35 | + | ||
36 | + <!-- 声明式事务管理begin --> | ||
37 | + <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> | ||
38 | + <property name="dataSource" ref="dataSource" /> | ||
39 | + </bean> | ||
40 | + | ||
41 | + <aop:config> | ||
42 | + <aop:advisor pointcut="execution(* com.tianbo.flight..*Impl.*(..))" advice-ref="txAdvice"/> | ||
43 | + </aop:config> | ||
44 | + | ||
45 | + <tx:advice id="txAdvice" transaction-manager="transactionManager"> | ||
46 | + <tx:attributes> | ||
47 | + <tx:method name="find*" read-only="true"/> | ||
48 | + <tx:method name="get*" read-only="true"/> | ||
49 | + <tx:method name="load*" read-only="true"/> | ||
50 | + <tx:method name="query*" read-only="true"/> | ||
51 | + <tx:method name="search*" read-only="true"/> | ||
52 | + <tx:method name="*" rollback-for="Exception"/> | ||
53 | + </tx:attributes> | ||
54 | + </tx:advice> | ||
55 | + <!-- 声明式事务管理end --> | ||
56 | + | ||
57 | + <!-- 配置mybitasSqlSessionFactoryBean --> | ||
58 | + <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" > | ||
59 | + <property name="dataSource" ref="dataSource" /> | ||
60 | + <property name="configLocation" value="classpath:config/sqlmap-config.xml" /> | ||
61 | + <property name="mapperLocations" value="classpath:sqlMapper/**/*.xml" /> | ||
62 | + </bean> | ||
63 | + <!-- 配置dao层与mapper.xml关联 --> | ||
64 | + <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" > | ||
65 | + <property name="basePackage" value="com.tianbo.flight.dao" /> | ||
66 | + <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /> | ||
67 | + </bean> | ||
68 | +</beans> |
src/config/generatorConfig - 副本.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" > | ||
3 | +<generatorConfiguration > | ||
4 | + | ||
5 | + <!-- 这个文件可以不用管 可以删掉 --> | ||
6 | + | ||
7 | + <classPathEntry location="D:\\\generator\\ojdbc14.jar"/> | ||
8 | + <context id="context1" > | ||
9 | + <commentGenerator> | ||
10 | + <property name="suppressAllcomments" value="true"/> | ||
11 | + <property name="suppressDate" value="true"/> | ||
12 | + </commentGenerator> | ||
13 | + <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@10.50.3.69:1521:CGODB" userId="cgonms" password="1q2w3e4r" /> | ||
14 | + <javaModelGenerator targetPackage="com.test.mybatis.model" targetProject="D:\generator\src" /> | ||
15 | + <sqlMapGenerator targetPackage="com.test.mybatis.mapper" targetProject="D:\generator\src" /> | ||
16 | + <javaClientGenerator targetPackage="com.topsci.atfm.persistence.mybatis.client" targetProject="D:\generator\src" type="XMLMAPPER" /> | ||
17 | + <table schema="" tableName="ORIGINMANIFESTSECONDARY" ></table> | ||
18 | + <!-- <table tableName="SYN_TRACK_EST" domainObjectName="AtfmTrack"></table> --> | ||
19 | + </context> | ||
20 | +</generatorConfiguration> |
src/config/generatorConfig.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE generatorConfiguration | ||
3 | + PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> | ||
4 | + | ||
5 | +<generatorConfiguration> | ||
6 | + <!--<properties resource="jdbc.properties" /> --> | ||
7 | + <!--MYSQL连接器JAR包位置 --> | ||
8 | + <!--<classPathEntry location="/Users/mrz/Documents/maven/mysql-connector-java-5.1.7-bin.jar"/>--> | ||
9 | + <!--oracle连接器JAR包位置 --> | ||
10 | + <classPathEntry location="D:\\\generator\\ojdbc14.jar"/> | ||
11 | + <context id="testTables" targetRuntime="MyBatis3" > | ||
12 | + <!--mySql分页插件 --> | ||
13 | + <!--<plugin type="com.tianbo.mybatis.plugin.PaginationPlugin" />--> | ||
14 | + <!-- oracle 分页插件--> | ||
15 | + <!-- <plugin type="com.tianbo.mybatis.plugin.OraclePaginationPlugin" /> --> | ||
16 | + <commentGenerator> | ||
17 | + <!-- 是否去除自动生成的注释 true:是 : false:否 --> | ||
18 | + <property name="suppressAllComments" value="true" /> | ||
19 | + </commentGenerator> | ||
20 | + <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> | ||
21 | + <!--<jdbcConnection driverClass="${jdbc.driver}"--> | ||
22 | + <!--connectionURL="${jdbc.url}"--> | ||
23 | + <!--userId="${jdbc.username}"--> | ||
24 | + <!--password="${jdbc.password}">--> | ||
25 | + <!--</jdbcConnection>--> | ||
26 | + <!--<jdbcConnection driverClass="com.mysql.jdbc.Driver"--> | ||
27 | + <!--connectionURL="jdbc:mysql://127.0.0.1:3307/statistics?characterEncoding=UTF-8"--> | ||
28 | + <!--userId="root"--> | ||
29 | + <!--password="">--> | ||
30 | + <!--</jdbcConnection>--> | ||
31 | + | ||
32 | + <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@10.50.3.69:1521:CGODB" userId="cgonms" password="1q2w3e4r" /> | ||
33 | + | ||
34 | + <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 | ||
35 | + NUMERIC 类型解析为java.math.BigDecimal --> | ||
36 | + <!--<javaTypeResolver>--> | ||
37 | + <!--<property name="forceBigDecimals" value="true" />--> | ||
38 | + <!--</javaTypeResolver>--> | ||
39 | + | ||
40 | + <!-- targetProject:生成PO类的位置 --> | ||
41 | + <javaModelGenerator targetPackage="com.tianbo.model" | ||
42 | + targetProject="D:\generator\src"> | ||
43 | + <!-- enableSubPackages:是否让schema作为包的后缀 --> | ||
44 | + <property name="enableSubPackages" value="false" /> | ||
45 | + <!-- 从数据库返回的值被清理前后的空格 --> | ||
46 | + <property name="trimStrings" value="true" /> | ||
47 | + </javaModelGenerator> | ||
48 | + <!-- targetProject:mapper映射文件生成的位置 --> | ||
49 | + <sqlMapGenerator targetPackage="com.tianbo.mapper" | ||
50 | + targetProject="D:\generator\src"> | ||
51 | + <!-- enableSubPackages:是否让schema作为包的后缀 --> | ||
52 | + <property name="enableSubPackages" value="false" /> | ||
53 | + </sqlMapGenerator> | ||
54 | + <!-- targetPackage:mapper接口生成的位置 --> | ||
55 | + <javaClientGenerator type="XMLMAPPER" | ||
56 | + targetPackage="com.tianbo.mapper" | ||
57 | + targetProject="D:\generator\src"> | ||
58 | + <!-- enableSubPackages:是否让schema作为包的后缀 --> | ||
59 | + <property name="enableSubPackages" value="false" /> | ||
60 | + </javaClientGenerator> | ||
61 | + <!-- 指定数据库表 --> | ||
62 | + <!--<table tableName="USERS"></table>--> | ||
63 | + <!--<table tableName="ROLE_PERMISSION"></table>--> | ||
64 | + <!--<table tableName="USER_ROLE"></table>--> | ||
65 | + <!--<table tableName="ROLE"></table>--> | ||
66 | + <!--<table tableName="PERMISSION"></table>--> | ||
67 | + <table tableName="ARRIVEDMASTER"></table> | ||
68 | + <!-- 有些表的字段需要指定java类型 | ||
69 | + <table schema="" tableName=""> | ||
70 | + <columnOverride column="" javaType="" /> | ||
71 | + </table> --> | ||
72 | + </context> | ||
73 | +</generatorConfiguration> |
src/config/init.properties
0 → 100644
src/config/mybatis-generator-core-1.3.2.jar
0 → 100644
不能预览此文件类型
src/config/sqlmap-config.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE configuration | ||
3 | + PUBLIC "-//mybatis.org//DTD Config 3.0//EN" | ||
4 | + "http://mybatis.org/dtd/mybatis-3-config.dtd"> | ||
5 | + | ||
6 | +<configuration> | ||
7 | + | ||
8 | + <settings> | ||
9 | + <!-- changes from the defaults --> | ||
10 | + <setting name="cacheEnabled" value="false" /> | ||
11 | + <setting name="lazyLoadingEnabled" value="false" /> | ||
12 | + <setting name="mapUnderscoreToCamelCase" value="true" /> | ||
13 | + <setting name="useColumnLabel" value="true" /> | ||
14 | + <setting name="defaultExecutorType" value="REUSE" /> | ||
15 | + <setting name="defaultStatementTimeout" value="25000" /> | ||
16 | + <setting name="jdbcTypeForNull" value="NULL" /> | ||
17 | + </settings> | ||
18 | +</configuration> |
src/config/time.properties
0 → 100644
src/sqlMapper/flight.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE mapper | ||
3 | + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
4 | + "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
5 | + | ||
6 | +<mapper namespace="com.tianbo.flight.dao.FlightDao"> | ||
7 | + | ||
8 | + <!-- 号源 --> | ||
9 | + <select id="getTime" parameterType="Map" | ||
10 | + resultType="com.tianbo.flight.entity.Flight"> | ||
11 | + SELECT | ||
12 | + T.SEQN, | ||
13 | + o.* | ||
14 | + FROM | ||
15 | + T_ETL_MESSAGE T, | ||
16 | + T_FACT_HB_ONRE o | ||
17 | + WHERE | ||
18 | + T.FID=o.MESSAGE_BAK_ID | ||
19 | + AND T.SNDR='FIMS' | ||
20 | + AND T.STYP = 'ONRE' | ||
21 | + AND o.FLIGHTNUM =#{flightnum} | ||
22 | + AND o.IMPEXP=#{impexp} | ||
23 | + AND o.SENDTIME=#{sendtime} | ||
24 | + AND ROWNUM=1 | ||
25 | + ORDER BY | ||
26 | + T.SEQN | ||
27 | + </select> | ||
28 | + | ||
29 | + <select id="getLastTime" parameterType="Map" | ||
30 | + resultType="com.tianbo.flight.entity.Flight"> | ||
31 | + SELECT | ||
32 | + T.SEQN, | ||
33 | + o.* | ||
34 | + FROM | ||
35 | + T_ETL_MESSAGE T, | ||
36 | + T_FACT_HB_ONRE o | ||
37 | + WHERE | ||
38 | + T.FID=o.MESSAGE_BAK_ID | ||
39 | + AND T.SNDR='FIMS' | ||
40 | + AND T.STYP = 'ONRE' | ||
41 | + AND o.FLIGHTNUM =#{flightnum} | ||
42 | + AND o.IMPEXP=#{impexp} | ||
43 | + AND ROWNUM=1 | ||
44 | + ORDER BY | ||
45 | + T.SEQN | ||
46 | + </select> | ||
47 | + | ||
48 | +</mapper> |
-
请 注册 或 登录 后发表评论