作者 朱兆平

init demo 0.1

@@ -9,220 +9,21 @@ import org.mybatis.spring.annotation.MapperScan; @@ -9,220 +9,21 @@ import org.mybatis.spring.annotation.MapperScan;
9 import org.springframework.boot.SpringApplication; 9 import org.springframework.boot.SpringApplication;
10 import org.springframework.boot.autoconfigure.SpringBootApplication; 10 import org.springframework.boot.autoconfigure.SpringBootApplication;
11 import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 11 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
  12 +import org.springframework.scheduling.annotation.EnableScheduling;
12 13
  14 +import java.util.Date;
13 import java.util.List; 15 import java.util.List;
14 import java.util.Map; 16 import java.util.Map;
15 17
16 @SpringBootApplication 18 @SpringBootApplication
  19 +@EnableScheduling
17 @EnableEurekaClient 20 @EnableEurekaClient
18 @MapperScan("com.example.demo.mapper")//将项目中对应的mapper类的路径加进来就可以了 21 @MapperScan("com.example.demo.mapper")//将项目中对应的mapper类的路径加进来就可以了
19 public class DemoApplication { 22 public class DemoApplication {
20 23
21 public static void main(String[] args) { 24 public static void main(String[] args) {
22 - Logger logger = LoggerFactory.getLogger(DemoApplication.class); 25 +
23 SpringApplication.run(DemoApplication.class, args); 26 SpringApplication.run(DemoApplication.class, args);
24 - String testMsg= "<MSG>\n" +  
25 - "\t<META>\n" +  
26 - "\t\t<SNDR>TXD</SNDR>\n" +  
27 - "\t\t<DDTM>20181109021010</DDTM>\n" +  
28 - "\t\t<TYPE>DFME</TYPE>\n" +  
29 - "\t\t<STYP>FWB</STYP>\n" +  
30 - "\t\t<SEQN>4638010</SEQN>\n" +  
31 - "\t</META>\n" +  
32 - "\t<MasterConsignment>\n" +  
33 - "\t\t<ID>479-77229622</ID>\n" +  
34 - "\t\t<TypeCode>741</TypeCode>\n" +  
35 - "\t\t<NilCarriageValueIndicator>false</NilCarriageValueIndicator>\n" +  
36 - "\t\t<DeclaredValueForCarriageAmount currencyID=\"CNY\">0</DeclaredValueForCarriageAmount>\n" +  
37 - "\t\t<NilCustomsValueIndicator>true</NilCustomsValueIndicator>\n" +  
38 - "\t\t<DeclaredValueForCustomsAmount currencyID=\"CNY\">NCV</DeclaredValueForCustomsAmount>\n" +  
39 - "\t\t<NilInsuranceValueIndicator>true</NilInsuranceValueIndicator>\n" +  
40 - "\t\t<InsuranceValueAmount currencyID=\"CNY\">XXX</InsuranceValueAmount>\n" +  
41 - "\t\t<TotalChargePrepaidIndicator>true</TotalChargePrepaidIndicator>\n" +  
42 - "\t\t<WeightTotalChargeAmount currencyID=\"CNY\">1153</WeightTotalChargeAmount>\n" +  
43 - "\t\t<ValuationTotalChargeAmount currencyID=\"CNY\">0.00</ValuationTotalChargeAmount>\n" +  
44 - "\t\t<TotalDisbursementPrepaidIndicator>true</TotalDisbursementPrepaidIndicator>\n" +  
45 - "\t\t<TotalPrepaidChargeAmount currencyID=\"CNY\">1384.00</TotalPrepaidChargeAmount>\n" +  
46 - "\t\t<TotalCollectChargeAmount currencyID=\"CNY\">0</TotalCollectChargeAmount>\n" +  
47 - "\t\t<DestinationCurrencyTotalCollectChargeAmount currencyID=\"CNY\">0</DestinationCurrencyTotalCollectChargeAmount>\n" +  
48 - "\t\t<IncludedTareGrossWeightMeasure unitCode=\"KGM\">1153.0</IncludedTareGrossWeightMeasure>\n" +  
49 - "\t\t<NetWeightMeasure/>\n" +  
50 - "\t\t<GrossVolumeMeasure unitCode=\"MTQ\">2.7</GrossVolumeMeasure>\n" +  
51 - "\t\t<TotalChargeableWeightMeasure unitCode=\"KGM\">1153.0</TotalChargeableWeightMeasure>\n" +  
52 - "\t\t<ConsignmentItemQuantity>1</ConsignmentItemQuantity>\n" +  
53 - "\t\t<TotalPieceQuantity>45</TotalPieceQuantity>\n" +  
54 - "\t\t<TotalLoadedPackageQuantity>45</TotalLoadedPackageQuantity>\n" +  
55 - "\t\t<PackageInfo>编织袋</PackageInfo>\n" +  
56 - "\t\t<FreightRateTypeCode>Q</FreightRateTypeCode>\n" +  
57 - "\t\t<ConsignorParty>\n" +  
58 - "\t\t\t<PrimaryID schemeAgencyID=\"1\">FY</PrimaryID>\n" +  
59 - "\t\t\t<Name>郑州飞鹰货运服务有限公司</Name>\n" +  
60 - "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +  
61 - "\t\t\t<PostalStructuredAddress>\n" +  
62 - "\t\t\t\t<StreetName>郑州</StreetName>\n" +  
63 - "\t\t\t\t<CityName>CGO</CityName>\n" +  
64 - "\t\t\t\t<CountryID>CN</CountryID>\n" +  
65 - "\t\t\t\t<SpecifiedAddressLocation/>\n" +  
66 - "\t\t\t</PostalStructuredAddress>\n" +  
67 - "\t\t\t<SpecifiedCargoAgentLocation/>\n" +  
68 - "\t\t\t<DefinedTradeContact>\n" +  
69 - "\t\t\t\t<DirectTelephoneCommunication>\n" +  
70 - "\t\t\t\t\t<CompleteNumber>13633854441</CompleteNumber>\n" +  
71 - "\t\t\t\t</DirectTelephoneCommunication>\n" +  
72 - "\t\t\t</DefinedTradeContact>\n" +  
73 - "\t\t</ConsignorParty>\n" +  
74 - "\t\t<ConsigneeParty>\n" +  
75 - "\t\t\t<PrimaryID schemeAgencyID=\"2\">SK</PrimaryID>\n" +  
76 - "\t\t\t<Name>深圳市联运通</Name>\n" +  
77 - "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +  
78 - "\t\t\t<PostalStructuredAddress>\n" +  
79 - "\t\t\t\t<StreetName>机场自提</StreetName>\n" +  
80 - "\t\t\t\t<CityName>SZX</CityName>\n" +  
81 - "\t\t\t\t<CountryID>CN</CountryID>\n" +  
82 - "\t\t\t\t<SpecifiedAddressLocation/>\n" +  
83 - "\t\t\t</PostalStructuredAddress>\n" +  
84 - "\t\t\t<SpecifiedCargoAgentLocation/>\n" +  
85 - "\t\t\t<DefinedTradeContact/>\n" +  
86 - "\t\t</ConsigneeParty>\n" +  
87 - "\t\t<FreightForwarderParty>\n" +  
88 - "\t\t\t<Name>80210200</Name>\n" +  
89 - "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +  
90 - "\t\t\t<PostalStructuredAddress>\n" +  
91 - "\t\t\t\t<CityName>CGO</CityName>\n" +  
92 - "\t\t\t\t<CountryID>CN</CountryID>\n" +  
93 - "\t\t\t\t<SpecifiedAddressLocation/>\n" +  
94 - "\t\t\t</PostalStructuredAddress>\n" +  
95 - "\t\t\t<SpecifiedCargoAgentLocation/>\n" +  
96 - "\t\t\t<DefinedTradeContact/>\n" +  
97 - "\t\t</FreightForwarderParty>\n" +  
98 - "\t\t<AssociatedParty>\n" +  
99 - "\t\t\t<PrimaryID/>\n" +  
100 - "\t\t\t<Name>CGO</Name>\n" +  
101 - "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +  
102 - "\t\t\t<RoleCode>AGT</RoleCode>\n" +  
103 - "\t\t\t<Role>Agent</Role>\n" +  
104 - "\t\t\t<PostalStructuredAddress>\n" +  
105 - "\t\t\t\t<CityName>CGO</CityName>\n" +  
106 - "\t\t\t\t<CountryID>CN</CountryID>\n" +  
107 - "\t\t\t\t<SpecifiedAddressLocation/>\n" +  
108 - "\t\t\t</PostalStructuredAddress>\n" +  
109 - "\t\t\t<SpecifiedCargoAgentLocation/>\n" +  
110 - "\t\t\t<DefinedTradeContact/>\n" +  
111 - "\t\t</AssociatedParty>\n" +  
112 - "\t\t<AssociatedParty>\n" +  
113 - "\t\t\t<PrimaryID/>\n" +  
114 - "\t\t\t<Name>CGOHA</Name>\n" +  
115 - "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +  
116 - "\t\t\t<RoleCode>GHA</RoleCode>\n" +  
117 - "\t\t\t<Role>Ground Handling Agent</Role>\n" +  
118 - "\t\t\t<PostalStructuredAddress>\n" +  
119 - "\t\t\t\t<CityName>CGO</CityName>\n" +  
120 - "\t\t\t\t<CountryID>CN</CountryID>\n" +  
121 - "\t\t\t\t<SpecifiedAddressLocation/>\n" +  
122 - "\t\t\t</PostalStructuredAddress>\n" +  
123 - "\t\t\t<SpecifiedCargoAgentLocation/>\n" +  
124 - "\t\t\t<DefinedTradeContact/>\n" +  
125 - "\t\t</AssociatedParty>\n" +  
126 - "\t\t<OriginLocation>\n" +  
127 - "\t\t\t<ID>CGO</ID>\n" +  
128 - "\t\t</OriginLocation>\n" +  
129 - "\t\t<FinalDestinationLocation>\n" +  
130 - "\t\t\t<ID>SZX</ID>\n" +  
131 - "\t\t</FinalDestinationLocation>\n" +  
132 - "\t\t<SpecifiedLogisticsTransportMovement>\n" +  
133 - "\t\t\t<StageCode>ZH9306/Nov09</StageCode>\n" +  
134 - "\t\t\t<ModeCode>4</ModeCode>\n" +  
135 - "\t\t\t<Mode>Air Transport</Mode>\n" +  
136 - "\t\t\t<ID>ZH9306</ID>\n" +  
137 - "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" +  
138 - "\t\t\t<UsedLogisticsTransportMeans/>\n" +  
139 - "\t\t\t<ArrivalEvent>\n" +  
140 - "\t\t\t\t<OccurrenceArrivalLocation>\n" +  
141 - "\t\t\t\t\t<ID>SZX</ID>\n" +  
142 - "\t\t\t\t</OccurrenceArrivalLocation>\n" +  
143 - "\t\t\t</ArrivalEvent>\n" +  
144 - "\t\t\t<DepartureEvent>\n" +  
145 - "\t\t\t\t<ScheduledOccurrenceDateTime>2018-11-09T00:00:00+08:00</ScheduledOccurrenceDateTime>\n" +  
146 - "\t\t\t\t<OccurrenceDepartureLocation>\n" +  
147 - "\t\t\t\t\t<ID>CGO</ID>\n" +  
148 - "\t\t\t\t</OccurrenceDepartureLocation>\n" +  
149 - "\t\t\t</DepartureEvent>\n" +  
150 - "\t\t</SpecifiedLogisticsTransportMovement>\n" +  
151 - "\t\t<HandlingInstructions>\n" +  
152 - "\t\t\t<Description>ELI</Description>\n" +  
153 - "\t\t\t<DescriptionCode>ELI</DescriptionCode>\n" +  
154 - "\t\t</HandlingInstructions>\n" +  
155 - "\t\t<AssociatedConsignmentCustomsProcedure/>\n" +  
156 - "\t\t<ApplicableTradeCurrencyExchange>\n" +  
157 - "\t\t\t<SourceCurrencyCode>CNY</SourceCurrencyCode>\n" +  
158 - "\t\t\t<TargetCurrencyCode>CNY</TargetCurrencyCode>\n" +  
159 - "\t\t\t<MarketID>S</MarketID>\n" +  
160 - "\t\t\t<ConversionRate>1</ConversionRate>\n" +  
161 - "\t\t</ApplicableTradeCurrencyExchange>\n" +  
162 - "\t\t<ApplicableLogisticsServiceCharge/>\n" +  
163 - "\t\t<ApplicableLogisticsAllowanceCharge>\n" +  
164 - "\t\t\t<ID>MY</ID>\n" +  
165 - "\t\t\t<Reason>燃油费</Reason>\n" +  
166 - "\t\t\t<ActualAmount currencyID=\"CNY\">231</ActualAmount>\n" +  
167 - "\t\t\t<PartyTypeCode>C</PartyTypeCode>\n" +  
168 - "\t\t</ApplicableLogisticsAllowanceCharge>\n" +  
169 - "\t\t<SignatoryCarrierAuthentication>\n" +  
170 - "\t\t\t<ActualDateTime>2018-11-09T02:07:00</ActualDateTime>\n" +  
171 - "\t\t\t<Signatory>郑天祥</Signatory>\n" +  
172 - "\t\t\t<IssueAuthenticationLocation>\n" +  
173 - "\t\t\t\t<Name>郑州</Name>\n" +  
174 - "\t\t\t</IssueAuthenticationLocation>\n" +  
175 - "\t\t</SignatoryCarrierAuthentication>\n" +  
176 - "\t\t<IncludedMasterConsignmentItem>\n" +  
177 - "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" +  
178 - "\t\t\t<TypeCode listAgencyID=\"1\">SJ</TypeCode>\n" +  
179 - "\t\t\t<GrossWeightMeasure unitCode=\"KGM\">1153.0</GrossWeightMeasure>\n" +  
180 - "\t\t\t<GrossVolumeMeasure unitCode=\"MTQ\">2.7</GrossVolumeMeasure>\n" +  
181 - "\t\t\t<PieceQuantity>45</PieceQuantity>\n" +  
182 - "\t\t\t<TareWeightMeasure unitCode=\"KGM\">1153.0</TareWeightMeasure>\n" +  
183 - "\t\t\t<NatureIdentificationTransportCargo>\n" +  
184 - "\t\t\t\t<Identification>手机(内含锂离子电池符合包装说明PI967第二部分要求)</Identification>\n" +  
185 - "\t\t\t</NatureIdentificationTransportCargo>\n" +  
186 - "\t\t\t<OriginCountry/>\n" +  
187 - "\t\t\t<AssociatedUnitLoadTransportEquipment>\n" +  
188 - "\t\t\t\t<OperatingParty/>\n" +  
189 - "\t\t\t</AssociatedUnitLoadTransportEquipment>\n" +  
190 - "\t\t\t<TransportLogisticsPackage>\n" +  
191 - "\t\t\t\t<ItemQuantity>45</ItemQuantity>\n" +  
192 - "\t\t\t\t<LinearSpatialDimension>\n" +  
193 - "\t\t\t\t\t<Description>true</Description>\n" +  
194 - "\t\t\t\t\t<WidthMeasure unitCode=\"CMT\">40</WidthMeasure>\n" +  
195 - "\t\t\t\t\t<LengthMeasure unitCode=\"CMT\">30</LengthMeasure>\n" +  
196 - "\t\t\t\t\t<HeightMeasure unitCode=\"CMT\">50</HeightMeasure>\n" +  
197 - "\t\t\t\t</LinearSpatialDimension>\n" +  
198 - "\t\t\t</TransportLogisticsPackage>\n" +  
199 - "\t\t\t<ApplicableFreightRateServiceCharge>\n" +  
200 - "\t\t\t\t<CategoryCode>Q</CategoryCode>\n" +  
201 - "\t\t\t\t<CommodityItemID>D2</CommodityItemID>\n" +  
202 - "\t\t\t\t<ChargeableWeightMeasure unitCode=\"KGM\">1153.0</ChargeableWeightMeasure>\n" +  
203 - "\t\t\t\t<AppliedRate>1</AppliedRate>\n" +  
204 - "\t\t\t\t<AppliedAmount currencyID=\"CNY\">1153</AppliedAmount>\n" +  
205 - "\t\t\t</ApplicableFreightRateServiceCharge>\n" +  
206 - "\t\t\t<SpecifiedRateCombinationPointLocation/>\n" +  
207 - "\t\t</IncludedMasterConsignmentItem>\n" +  
208 - "\t\t<ReportedStatus>\n" +  
209 - "\t\t\t<ReasonCode>FWB</ReasonCode>\n" +  
210 - "\t\t\t<EventTime>\n" +  
211 - "\t\t\t\t<OccurrenceDateTime>2018-11-09T02:07:15+08:00</OccurrenceDateTime>\n" +  
212 - "\t\t\t\t<DateTimeTypeCode>Actual</DateTimeTypeCode>\n" +  
213 - "\t\t\t</EventTime>\n" +  
214 - "\t\t\t<SpecifiedLocation>\n" +  
215 - "\t\t\t\t<ID>CGO</ID>\n" +  
216 - "\t\t\t</SpecifiedLocation>\n" +  
217 - "\t\t</ReportedStatus>\n" +  
218 - "\t</MasterConsignment>\n" +  
219 - "</MSG>";  
220 - try {  
221 - XMLParse xmlParse = new XMLParse(testMsg, "/MSG/MasterConsignment/AssociatedParty");  
222 - List<Map> stype_value =xmlParse.getNodeValuesFromXmlString();  
223 - logger.info(stype_value.toString());  
224 - }catch (Exception var7){  
225 - System.out.print("there something wrong");  
226 - } 27 +
227 } 28 }
228 } 29 }
  1 +package com.example.demo.mapper;
  2 +
  3 +import com.example.demo.model.FWBAssociatedParty;
  4 +
  5 +public interface FWBAssociatedPartyMapper {
  6 + int deleteByPrimaryKey(Integer id);
  7 +
  8 + int insert(FWBAssociatedParty record);
  9 +
  10 + int insertSelective(FWBAssociatedParty record);
  11 +
  12 + FWBAssociatedParty selectByPrimaryKey(Integer id);
  13 +
  14 + int updateByPrimaryKeySelective(FWBAssociatedParty record);
  15 +
  16 + int updateByPrimaryKey(FWBAssociatedParty record);
  17 +}
  1 +package com.example.demo.model;
  2 +
  3 +import java.time.LocalDate;
  4 +
  5 +
  6 +public class FWBAssociatedParty {
  7 + private Integer id;
  8 +
  9 + private String primaryid;
  10 +
  11 + private String name;
  12 +
  13 + private String accountid;
  14 +
  15 + private String rolecode;
  16 +
  17 + private String role;
  18 +
  19 + private String cityname;
  20 +
  21 + private String countryid;
  22 +
  23 + private String awbnumber;
  24 +
  25 + private LocalDate flightdate;
  26 +
  27 + private String flightnumber;
  28 +
  29 + public Integer getId() {
  30 + return id;
  31 + }
  32 +
  33 + public void setId(Integer id) {
  34 + this.id = id;
  35 + }
  36 +
  37 + public String getPrimaryid() {
  38 + return primaryid;
  39 + }
  40 +
  41 + public void setPrimaryid(String primaryid) {
  42 + this.primaryid = primaryid == null ? null : primaryid.trim();
  43 + }
  44 +
  45 + public String getName() {
  46 + return name;
  47 + }
  48 +
  49 + public void setName(String name) {
  50 + this.name = name == null ? null : name.trim();
  51 + }
  52 +
  53 + public String getAccountid() {
  54 + return accountid;
  55 + }
  56 +
  57 + public void setAccountid(String accountid) {
  58 + this.accountid = accountid == null ? null : accountid.trim();
  59 + }
  60 +
  61 + public String getRolecode() {
  62 + return rolecode;
  63 + }
  64 +
  65 + public void setRolecode(String rolecode) {
  66 + this.rolecode = rolecode == null ? null : rolecode.trim();
  67 + }
  68 +
  69 + public String getRole() {
  70 + return role;
  71 + }
  72 +
  73 + public void setRole(String role) {
  74 + this.role = role == null ? null : role.trim();
  75 + }
  76 +
  77 + public String getCityname() {
  78 + return cityname;
  79 + }
  80 +
  81 + public void setCityname(String cityname) {
  82 + this.cityname = cityname == null ? null : cityname.trim();
  83 + }
  84 +
  85 + public String getCountryid() {
  86 + return countryid;
  87 + }
  88 +
  89 + public void setCountryid(String countryid) {
  90 + this.countryid = countryid == null ? null : countryid.trim();
  91 + }
  92 +
  93 + public String getAwbnumber() {
  94 + return awbnumber;
  95 + }
  96 +
  97 + public void setAwbnumber(String awbnumber) {
  98 + this.awbnumber = awbnumber == null ? null : awbnumber.trim();
  99 + }
  100 +
  101 + public LocalDate getFlightdate() {
  102 + return flightdate;
  103 + }
  104 +
  105 + public void setFlightdate(LocalDate flightdate) {
  106 + this.flightdate = flightdate;
  107 + }
  108 +
  109 + public String getFlightnumber() {
  110 + return flightnumber;
  111 + }
  112 +
  113 + public void setFlightnumber(String flightnumber) {
  114 + this.flightnumber = flightnumber == null ? null : flightnumber.trim();
  115 + }
  116 +}
  1 +package com.example.demo.scheduled;
  2 +
  3 +import com.example.demo.model.FWBAssociatedParty;
  4 +import com.example.demo.util.XML.XMLParse;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.scheduling.annotation.Scheduled;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.text.SimpleDateFormat;
  11 +import java.time.LocalDate;
  12 +import java.time.LocalDateTime;
  13 +import java.time.ZonedDateTime;
  14 +import java.time.format.DateTimeFormatter;
  15 +import java.time.format.FormatStyle;
  16 +import java.util.Date;
  17 +import java.util.List;
  18 +import java.util.Locale;
  19 +import java.util.Map;
  20 +
  21 +/**
  22 + * 定时任务
  23 + */
  24 +@Component
  25 +public class FWBTask {
  26 + private static final Logger logger = LoggerFactory.getLogger(FWBTask.class);
  27 + private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  28 +
  29 + @Scheduled(fixedRate = 5000)
  30 + public void scheduledDemo(){
  31 + logger.info("scheduled - fixedRate - print time every 5 seconds:{}", format.format(new Date()) );
  32 + String testMsg= "<MSG>\n" +
  33 + "\t<META>\n" +
  34 + "\t\t<SNDR>TXD</SNDR>\n" +
  35 + "\t\t<DDTM>20181114040536</DDTM>\n" +
  36 + "\t\t<TYPE>DFME</TYPE>\n" +
  37 + "\t\t<STYP>FWB</STYP>\n" +
  38 + "\t\t<SEQN>4643187</SEQN>\n" +
  39 + "\t</META>\n" +
  40 + "\t<MasterConsignment>\n" +
  41 + "\t\t<ID>880-83213594</ID>\n" +
  42 + "\t\t<TypeCode>741</TypeCode>\n" +
  43 + "\t\t<NilCarriageValueIndicator>false</NilCarriageValueIndicator>\n" +
  44 + "\t\t<DeclaredValueForCarriageAmount currencyID=\"CNY\">0</DeclaredValueForCarriageAmount>\n" +
  45 + "\t\t<NilCustomsValueIndicator>true</NilCustomsValueIndicator>\n" +
  46 + "\t\t<DeclaredValueForCustomsAmount currencyID=\"CNY\">NCV</DeclaredValueForCustomsAmount>\n" +
  47 + "\t\t<NilInsuranceValueIndicator>true</NilInsuranceValueIndicator>\n" +
  48 + "\t\t<InsuranceValueAmount currencyID=\"CNY\">XXX</InsuranceValueAmount>\n" +
  49 + "\t\t<TotalChargePrepaidIndicator>true</TotalChargePrepaidIndicator>\n" +
  50 + "\t\t<WeightTotalChargeAmount currencyID=\"CNY\">502</WeightTotalChargeAmount>\n" +
  51 + "\t\t<ValuationTotalChargeAmount currencyID=\"CNY\">0.00</ValuationTotalChargeAmount>\n" +
  52 + "\t\t<TotalDisbursementPrepaidIndicator>true</TotalDisbursementPrepaidIndicator>\n" +
  53 + "\t\t<TotalPrepaidChargeAmount currencyID=\"CNY\">613.60</TotalPrepaidChargeAmount>\n" +
  54 + "\t\t<TotalCollectChargeAmount currencyID=\"CNY\">0</TotalCollectChargeAmount>\n" +
  55 + "\t\t<DestinationCurrencyTotalCollectChargeAmount currencyID=\"CNY\">0</DestinationCurrencyTotalCollectChargeAmount>\n" +
  56 + "\t\t<IncludedTareGrossWeightMeasure unitCode=\"KGM\">558.0</IncludedTareGrossWeightMeasure>\n" +
  57 + "\t\t<NetWeightMeasure/>\n" +
  58 + "\t\t<GrossVolumeMeasure unitCode=\"MTQ\">4.44</GrossVolumeMeasure>\n" +
  59 + "\t\t<TotalChargeableWeightMeasure unitCode=\"KGM\">558.0</TotalChargeableWeightMeasure>\n" +
  60 + "\t\t<ConsignmentItemQuantity>1</ConsignmentItemQuantity>\n" +
  61 + "\t\t<TotalPieceQuantity>74</TotalPieceQuantity>\n" +
  62 + "\t\t<TotalLoadedPackageQuantity>74</TotalLoadedPackageQuantity>\n" +
  63 + "\t\t<PackageInfo>编织袋</PackageInfo>\n" +
  64 + "\t\t<FreightRateTypeCode>Q</FreightRateTypeCode>\n" +
  65 + "\t\t<ConsignorParty>\n" +
  66 + "\t\t\t<PrimaryID schemeAgencyID=\"1\">HNHH</PrimaryID>\n" +
  67 + "\t\t\t<Name>河南汇海物流有限公司</Name>\n" +
  68 + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +
  69 + "\t\t\t<PostalStructuredAddress>\n" +
  70 + "\t\t\t\t<StreetName>郑州</StreetName>\n" +
  71 + "\t\t\t\t<CityName>CGO</CityName>\n" +
  72 + "\t\t\t\t<CountryID>CN</CountryID>\n" +
  73 + "\t\t\t\t<SpecifiedAddressLocation/>\n" +
  74 + "\t\t\t</PostalStructuredAddress>\n" +
  75 + "\t\t\t<SpecifiedCargoAgentLocation/>\n" +
  76 + "\t\t\t<DefinedTradeContact>\n" +
  77 + "\t\t\t\t<DirectTelephoneCommunication>\n" +
  78 + "\t\t\t\t\t<CompleteNumber>CGO</CompleteNumber>\n" +
  79 + "\t\t\t\t</DirectTelephoneCommunication>\n" +
  80 + "\t\t\t</DefinedTradeContact>\n" +
  81 + "\t\t</ConsignorParty>\n" +
  82 + "\t\t<ConsigneeParty>\n" +
  83 + "\t\t\t<PrimaryID schemeAgencyID=\"2\">SK</PrimaryID>\n" +
  84 + "\t\t\t<Name>海南顺丰速运有限公司</Name>\n" +
  85 + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +
  86 + "\t\t\t<PostalStructuredAddress>\n" +
  87 + "\t\t\t\t<StreetName>机场自提</StreetName>\n" +
  88 + "\t\t\t\t<CityName>HAK</CityName>\n" +
  89 + "\t\t\t\t<CountryID>CN</CountryID>\n" +
  90 + "\t\t\t\t<SpecifiedAddressLocation/>\n" +
  91 + "\t\t\t</PostalStructuredAddress>\n" +
  92 + "\t\t\t<SpecifiedCargoAgentLocation/>\n" +
  93 + "\t\t\t<DefinedTradeContact/>\n" +
  94 + "\t\t</ConsigneeParty>\n" +
  95 + "\t\t<FreightForwarderParty>\n" +
  96 + "\t\t\t<Name>CGOSA</Name>\n" +
  97 + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +
  98 + "\t\t\t<PostalStructuredAddress>\n" +
  99 + "\t\t\t\t<CityName>CGO</CityName>\n" +
  100 + "\t\t\t\t<CountryID>CN</CountryID>\n" +
  101 + "\t\t\t\t<SpecifiedAddressLocation/>\n" +
  102 + "\t\t\t</PostalStructuredAddress>\n" +
  103 + "\t\t\t<SpecifiedCargoAgentLocation/>\n" +
  104 + "\t\t\t<DefinedTradeContact/>\n" +
  105 + "\t\t</FreightForwarderParty>\n" +
  106 + "\t\t<AssociatedParty>\n" +
  107 + "\t\t\t<PrimaryID/>\n" +
  108 + "\t\t\t<Name>CGO</Name>\n" +
  109 + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +
  110 + "\t\t\t<RoleCode>AGT</RoleCode>\n" +
  111 + "\t\t\t<Role>Agent</Role>\n" +
  112 + "\t\t\t<PostalStructuredAddress>\n" +
  113 + "\t\t\t\t<CityName>CGO</CityName>\n" +
  114 + "\t\t\t\t<CountryID>CN</CountryID>\n" +
  115 + "\t\t\t\t<SpecifiedAddressLocation/>\n" +
  116 + "\t\t\t</PostalStructuredAddress>\n" +
  117 + "\t\t\t<SpecifiedCargoAgentLocation/>\n" +
  118 + "\t\t\t<DefinedTradeContact/>\n" +
  119 + "\t\t</AssociatedParty>\n" +
  120 + "\t\t<AssociatedParty>\n" +
  121 + "\t\t\t<PrimaryID/>\n" +
  122 + "\t\t\t<Name>CGOHA</Name>\n" +
  123 + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" +
  124 + "\t\t\t<RoleCode>GHA</RoleCode>\n" +
  125 + "\t\t\t<Role>Ground Handling Agent</Role>\n" +
  126 + "\t\t\t<PostalStructuredAddress>\n" +
  127 + "\t\t\t\t<CityName>CGO</CityName>\n" +
  128 + "\t\t\t\t<CountryID>CN</CountryID>\n" +
  129 + "\t\t\t\t<SpecifiedAddressLocation/>\n" +
  130 + "\t\t\t</PostalStructuredAddress>\n" +
  131 + "\t\t\t<SpecifiedCargoAgentLocation/>\n" +
  132 + "\t\t\t<DefinedTradeContact/>\n" +
  133 + "\t\t</AssociatedParty>\n" +
  134 + "\t\t<OriginLocation>\n" +
  135 + "\t\t\t<ID>CGO</ID>\n" +
  136 + "\t\t</OriginLocation>\n" +
  137 + "\t\t<FinalDestinationLocation>\n" +
  138 + "\t\t\t<ID>HAK</ID>\n" +
  139 + "\t\t</FinalDestinationLocation>\n" +
  140 + "\t\t<SpecifiedLogisticsTransportMovement>\n" +
  141 + "\t\t\t<StageCode>HU7304/Nov14</StageCode>\n" +
  142 + "\t\t\t<ModeCode>4</ModeCode>\n" +
  143 + "\t\t\t<Mode>Air Transport</Mode>\n" +
  144 + "\t\t\t<ID>HU7304</ID>\n" +
  145 + "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" +
  146 + "\t\t\t<UsedLogisticsTransportMeans/>\n" +
  147 + "\t\t\t<ArrivalEvent>\n" +
  148 + "\t\t\t\t<OccurrenceArrivalLocation>\n" +
  149 + "\t\t\t\t\t<ID>HAK</ID>\n" +
  150 + "\t\t\t\t</OccurrenceArrivalLocation>\n" +
  151 + "\t\t\t</ArrivalEvent>\n" +
  152 + "\t\t\t<DepartureEvent>\n" +
  153 + "\t\t\t\t<ScheduledOccurrenceDateTime>2018-11-14T00:00:00+08:00</ScheduledOccurrenceDateTime>\n" +
  154 + "\t\t\t\t<OccurrenceDepartureLocation>\n" +
  155 + "\t\t\t\t\t<ID>CGO</ID>\n" +
  156 + "\t\t\t\t</OccurrenceDepartureLocation>\n" +
  157 + "\t\t\t</DepartureEvent>\n" +
  158 + "\t\t</SpecifiedLogisticsTransportMovement>\n" +
  159 + "\t\t<IncludedAccountingNote>\n" +
  160 + "\t\t\t<ContentCode>20010003普通</ContentCode>\n" +
  161 + "\t\t\t<Content>20010003普通</Content>\n" +
  162 + "\t\t</IncludedAccountingNote>\n" +
  163 + "\t\t<AssociatedConsignmentCustomsProcedure/>\n" +
  164 + "\t\t<ApplicableTradeCurrencyExchange>\n" +
  165 + "\t\t\t<SourceCurrencyCode>CNY</SourceCurrencyCode>\n" +
  166 + "\t\t\t<TargetCurrencyCode>CNY</TargetCurrencyCode>\n" +
  167 + "\t\t\t<MarketID>S</MarketID>\n" +
  168 + "\t\t\t<ConversionRate>1</ConversionRate>\n" +
  169 + "\t\t</ApplicableTradeCurrencyExchange>\n" +
  170 + "\t\t<ApplicableLogisticsServiceCharge/>\n" +
  171 + "\t\t<ApplicableLogisticsAllowanceCharge>\n" +
  172 + "\t\t\t<ID>MY</ID>\n" +
  173 + "\t\t\t<Reason>燃油费</Reason>\n" +
  174 + "\t\t\t<ActualAmount currencyID=\"CNY\">111.6</ActualAmount>\n" +
  175 + "\t\t\t<PartyTypeCode>C</PartyTypeCode>\n" +
  176 + "\t\t</ApplicableLogisticsAllowanceCharge>\n" +
  177 + "\t\t<SignatoryCarrierAuthentication>\n" +
  178 + "\t\t\t<ActualDateTime>2018-11-14T04:02:00</ActualDateTime>\n" +
  179 + "\t\t\t<Signatory>牛青</Signatory>\n" +
  180 + "\t\t\t<IssueAuthenticationLocation>\n" +
  181 + "\t\t\t\t<Name>郑州</Name>\n" +
  182 + "\t\t\t</IssueAuthenticationLocation>\n" +
  183 + "\t\t</SignatoryCarrierAuthentication>\n" +
  184 + "\t\t<IncludedMasterConsignmentItem>\n" +
  185 + "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" +
  186 + "\t\t\t<TypeCode listAgencyID=\"1\">PH</TypeCode>\n" +
  187 + "\t\t\t<GrossWeightMeasure unitCode=\"KGM\">558.0</GrossWeightMeasure>\n" +
  188 + "\t\t\t<GrossVolumeMeasure unitCode=\"MTQ\">4.44</GrossVolumeMeasure>\n" +
  189 + "\t\t\t<PieceQuantity>74</PieceQuantity>\n" +
  190 + "\t\t\t<TareWeightMeasure unitCode=\"KGM\">558.0</TareWeightMeasure>\n" +
  191 + "\t\t\t<NatureIdentificationTransportCargo>\n" +
  192 + "\t\t\t\t<Identification>手机机头(无电池) 电子主板 上衣 茶叶 大枣 皮带 票证 运动鞋 背包 灯座</Identification>\n" +
  193 + "\t\t\t</NatureIdentificationTransportCargo>\n" +
  194 + "\t\t\t<OriginCountry/>\n" +
  195 + "\t\t\t<AssociatedUnitLoadTransportEquipment>\n" +
  196 + "\t\t\t\t<OperatingParty/>\n" +
  197 + "\t\t\t</AssociatedUnitLoadTransportEquipment>\n" +
  198 + "\t\t\t<TransportLogisticsPackage>\n" +
  199 + "\t\t\t\t<ItemQuantity>74</ItemQuantity>\n" +
  200 + "\t\t\t\t<LinearSpatialDimension>\n" +
  201 + "\t\t\t\t\t<Description>true</Description>\n" +
  202 + "\t\t\t\t\t<WidthMeasure unitCode=\"CMT\">40</WidthMeasure>\n" +
  203 + "\t\t\t\t\t<LengthMeasure unitCode=\"CMT\">30</LengthMeasure>\n" +
  204 + "\t\t\t\t\t<HeightMeasure unitCode=\"CMT\">50</HeightMeasure>\n" +
  205 + "\t\t\t\t</LinearSpatialDimension>\n" +
  206 + "\t\t\t</TransportLogisticsPackage>\n" +
  207 + "\t\t\t<ApplicableFreightRateServiceCharge>\n" +
  208 + "\t\t\t\t<CategoryCode>Q</CategoryCode>\n" +
  209 + "\t\t\t\t<CommodityItemID>P</CommodityItemID>\n" +
  210 + "\t\t\t\t<ChargeableWeightMeasure unitCode=\"KGM\">558.0</ChargeableWeightMeasure>\n" +
  211 + "\t\t\t\t<AppliedRate>0.9</AppliedRate>\n" +
  212 + "\t\t\t\t<AppliedAmount currencyID=\"CNY\">502</AppliedAmount>\n" +
  213 + "\t\t\t</ApplicableFreightRateServiceCharge>\n" +
  214 + "\t\t\t<SpecifiedRateCombinationPointLocation/>\n" +
  215 + "\t\t</IncludedMasterConsignmentItem>\n" +
  216 + "\t\t<ReportedStatus>\n" +
  217 + "\t\t\t<ReasonCode>FWB</ReasonCode>\n" +
  218 + "\t\t\t<EventTime>\n" +
  219 + "\t\t\t\t<OccurrenceDateTime>2018-11-14T04:03:02+08:00</OccurrenceDateTime>\n" +
  220 + "\t\t\t\t<DateTimeTypeCode>Actual</DateTimeTypeCode>\n" +
  221 + "\t\t\t</EventTime>\n" +
  222 + "\t\t\t<SpecifiedLocation>\n" +
  223 + "\t\t\t\t<ID>CGO</ID>\n" +
  224 + "\t\t\t</SpecifiedLocation>\n" +
  225 + "\t\t</ReportedStatus>\n" +
  226 + "\t</MasterConsignment>\n" +
  227 + "</MSG>";
  228 + try {
  229 + XMLParse xmlParse = new XMLParse(testMsg);
  230 + Map resoultMaps = xmlParse.getAllValuesFromXmlString();
  231 + logger.info(resoultMaps.toString());
  232 + FWBAssociatedParty fwbAssociatedParty = new FWBAssociatedParty();
  233 +
  234 + fwbAssociatedParty.setAwbnumber(xmlParse.getNodeValueFromXmlString( "/MSG/MasterConsignment/ID"));
  235 + String[] flight = xmlParse.getNodeValueFromXmlString( "/MSG/MasterConsignment/SpecifiedLogisticsTransportMovement/StageCode").split("/");
  236 + String flightDep = xmlParse.getNodeValueFromXmlString( "/MSG/MasterConsignment/SpecifiedLogisticsTransportMovement/DepartureEvent/ScheduledOccurrenceDateTime");
  237 + String flight_No = flight[0]; //航班号
  238 + String flight_date=flight[1]; //航班日期年月
  239 + fwbAssociatedParty.setFlightnumber(flight_No);
  240 +
  241 + //根据离港日期取航班日期年份
  242 + ZonedDateTime depZoneTime = ZonedDateTime.parse(flightDep);
  243 + String year = String.valueOf(depZoneTime.getYear());
  244 + //合并航班日期和离港年份,组成完整日期格式
  245 + flight_date = flight_date+year;
  246 + DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL);
  247 + formatter = DateTimeFormatter.ofPattern("MMMddyyyy",Locale.ENGLISH);
  248 + LocalDate date =LocalDate.parse(flight_date,formatter);
  249 + //写入对象
  250 + fwbAssociatedParty.setFlightdate(date);
  251 + //以上关于运单的信息与航班信息已解析完成
  252 +
  253 + //开始读取相同节点数组
  254 + List<Map> stype_value =xmlParse.getNodeValuesFromXmlString( "/MSG/MasterConsignment/AssociatedParty");
  255 + for (Map map :stype_value){
  256 + fwbAssociatedParty.setPrimaryid((String) map.get("PrimaryID"));
  257 + fwbAssociatedParty.setName(map.get("Name").toString());
  258 + fwbAssociatedParty.setAccountid(map.get("AccountID").toString());
  259 + fwbAssociatedParty.setRolecode(map.get("RoleCode").toString());
  260 + fwbAssociatedParty.setRole(map.get("Role").toString());
  261 + }
  262 +
  263 + //
  264 +
  265 + logger.info(stype_value.toString());
  266 + }catch (Exception var7){
  267 + logger.error(var7.toString());
  268 + }
  269 + }
  270 +
  271 + /**
  272 + "0/5 * * * * ?" 每5秒触发
  273 + "0 0 12 * * ?" 每天中午十二点触发
  274 + "0 15 10 ? * *" 每天早上10:15触发
  275 + "0 15 10 * * ?" 每天早上10:15触发
  276 + "0 15 10 * * ? *" 每天早上10:15触发
  277 + "0 15 10 * * ? 2005" 2005年的每天早上10:15触发
  278 + "0 * 14 * * ?" 每天从下午2点开始到2点59分每分钟一次触发
  279 + "0 0/5 14 * * ?" 每天从下午2点开始到2:55分结束每5分钟一次触发
  280 + "0 0/5 14,18 * * ?" 每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发
  281 + "0 0-5 14 * * ?" 每天14:00至14:05每分钟一次触发
  282 + "0 10,44 14 ? 3 WED" 三月的每周三的14:10和14:44触发
  283 + "0 15 10 ? * MON-FRI" 每个周一、周二、周三、周四、周五的10:15触发
  284 + */
  285 +// @Scheduled(cron="0/10 * * * * ?")
  286 +// public void scheduledCronDemo(){
  287 +// logger.info("scheduled - cron - print time every 10 seconds:{}", format.format(new Date()) );
  288 +// }
  289 +}
  1 +package com.example.demo.service;
  2 +
  3 +import com.example.demo.model.FWBAssociatedParty;
  4 +
  5 +public interface FWBAsssociatedPartyService {
  6 + int insert(FWBAssociatedParty record);
  7 +
  8 + int insertSelective(FWBAssociatedParty record);
  9 +}
  1 +package com.example.demo.service.imp;
  2 +
  3 +import com.example.demo.mapper.FWBAssociatedPartyMapper;
  4 +import com.example.demo.model.FWBAssociatedParty;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.stereotype.Service;
  7 +
  8 +@Service("fwbAssService")
  9 +public class FWBAsssociatedPartyService implements com.example.demo.service.FWBAsssociatedPartyService {
  10 +
  11 +
  12 + @Autowired
  13 + FWBAssociatedPartyMapper fwbAssociatedPartyMapper;
  14 +
  15 + public int insert(FWBAssociatedParty record){
  16 + return fwbAssociatedPartyMapper.insert(record);
  17 + }
  18 +
  19 + public int insertSelective(FWBAssociatedParty record){
  20 + return fwbAssociatedPartyMapper.insertSelective(record);
  21 + }
  22 +}
@@ -15,44 +15,87 @@ import java.io.StringReader; @@ -15,44 +15,87 @@ import java.io.StringReader;
15 import java.util.*; 15 import java.util.*;
16 16
17 public class XMLParse { 17 public class XMLParse {
  18 + private static final Logger logger = LoggerFactory.getLogger(DemoApplication.class);
18 private static String xmlString; 19 private static String xmlString;
19 - private static String[] nodes;  
20 private static Document document; 20 private static Document document;
21 private static SAXBuilder builder; 21 private static SAXBuilder builder;
22 private static Element root; 22 private static Element root;
23 private static LinkedList<SubNode> listNode; 23 private static LinkedList<SubNode> listNode;
24 private static StringReader xmlReader; 24 private static StringReader xmlReader;
25 private static InputSource xmlSource; 25 private static InputSource xmlSource;
  26 + private static List<Map> maps = new ArrayList<Map>();
  27 + private static Map<String,Map> allElementValue = new HashMap<String, Map>();
  28 + private static int domCount=0;
26 private String value; 29 private String value;
  30 +
27 public XMLParse() { 31 public XMLParse() {
28 } 32 }
29 - Logger logger = LoggerFactory.getLogger(DemoApplication.class);  
30 - /**  
31 - *  
32 - * @param xmlString xml字符窜  
33 - * @param xmlNodePath 节点参数(例如:/root/head/type)  
34 - */  
35 - public XMLParse(String xmlString, String xmlNodePath) {  
36 - this.xmlString = xmlString;  
37 - this.nodes = xmlNodePath.split("/");  
38 - this.builder = new SAXBuilder();  
39 - this.root = null;  
40 - this.listNode = new LinkedList();  
41 - this.value = "";  
42 - this.document =new Document(); 33 + public XMLParse(String XmlString) {
  34 + builder = new SAXBuilder();
  35 + root = null;
  36 + listNode = new LinkedList();
  37 + value = "";
  38 + document =new Document();
  39 + xmlString = XmlString;
  40 + }
  41 +
  42 + public Map getAllValuesFromXmlString() throws Exception{
  43 + try {
  44 + xmlReader = new StringReader(xmlString);
  45 + xmlSource = new InputSource(xmlReader);
  46 + document = builder.build(xmlSource);
  47 + root = document.getRootElement();
  48 + getElements(root);
  49 +
  50 + }catch (Exception var17) {
  51 + var17.printStackTrace();
  52 + throw var17;
  53 + } finally {
  54 + listNode.clear();
  55 + document = null;
  56 + root = null;
  57 +// builder = null;
  58 +
  59 + }
  60 + return allElementValue;
43 } 61 }
44 62
  63 + public void getElements (Element element) throws Exception{
  64 + try {
  65 + domCount++;
  66 + List<Element> Children = element.getChildren();
  67 + if (Children.size()>0){
  68 + for (Element elements : Children){
  69 + if(elements.getChildren().size()>0){
  70 + getElements(elements);
  71 + }else {//确定是最末节点了 开始取末节点的数据
  72 + String childName = elements.getName();
  73 + String childValue = elements.getText();
  74 + Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个最终节点的值
  75 + childMap.put(childName,childValue);
  76 + allElementValue.put(domCount+elements.getParentElement().getName()+"-"+childName,childMap);
  77 + }
  78 + }
  79 + }
  80 +
  81 +
  82 + }catch (Exception e){
  83 + e.printStackTrace();
  84 + throw e;
  85 + }
  86 +
  87 + }
45 /** 88 /**
46 * 取一对多关系的节点下的所有子节点的属性名 和 值 89 * 取一对多关系的节点下的所有子节点的属性名 和 值
47 * @return 90 * @return
48 * @throws Exception 91 * @throws Exception
49 */ 92 */
50 - public List<Map> getNodeValuesFromXmlString() throws Exception{  
51 - 93 + public List<Map> getNodeValuesFromXmlString(String xmlNodePath) throws Exception{
  94 + String[] nodes = xmlNodePath.split("/");
52 try { 95 try {
53 - this.xmlReader = new StringReader(this.xmlString);  
54 - this.xmlSource = new InputSource(this.xmlReader);  
55 - this.document = this.builder.build(xmlSource); 96 + xmlReader = new StringReader(xmlString);
  97 + xmlSource = new InputSource(xmlReader);
  98 + document = builder.build(xmlSource);
56 List<Map> maps = new ArrayList<Map>(); 99 List<Map> maps = new ArrayList<Map>();
57 for(int i = 1; i < nodes.length; ++i) { 100 for(int i = 1; i < nodes.length; ++i) {
58 SubNode snode; 101 SubNode snode;
@@ -71,10 +114,17 @@ public class XMLParse { @@ -71,10 +114,17 @@ public class XMLParse {
71 List<Element> elements=element.getChildren(); 114 List<Element> elements=element.getChildren();
72 Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个值 115 Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个值
73 for (Element childElements : elements){ 116 for (Element childElements : elements){
  117 + if (childElements.getChildren().size()>1){
  118 + for (Element grandChildrenEle : (List<Element>)childElements.getChildren()){
  119 + String childName = grandChildrenEle.getName();
  120 + String childValue = grandChildrenEle.getText();
  121 + childMap.put(childName,childValue);
  122 + }
  123 + }
74 String childName = childElements.getName(); 124 String childName = childElements.getName();
75 String childValue = childElements.getText(); 125 String childValue = childElements.getText();
76 childMap.put(childName,childValue); 126 childMap.put(childName,childValue);
77 - logger.debug(childValue); 127 + logger.info(childValue);
78 } 128 }
79 maps.add(childMap); 129 maps.add(childMap);
80 } 130 }
@@ -95,7 +145,7 @@ public class XMLParse { @@ -95,7 +145,7 @@ public class XMLParse {
95 listNode.clear(); 145 listNode.clear();
96 document = null; 146 document = null;
97 root = null; 147 root = null;
98 - builder = null; 148 +// builder = null;
99 nodes = null; 149 nodes = null;
100 } 150 }
101 151
@@ -106,11 +156,12 @@ public class XMLParse { @@ -106,11 +156,12 @@ public class XMLParse {
106 * @return 单一节点值 156 * @return 单一节点值
107 * @throws Exception 157 * @throws Exception
108 */ 158 */
109 - public final String getNodeValueFromXmlString() throws Exception { 159 + public final String getNodeValueFromXmlString(String xmlNodePath) throws Exception {
  160 + String[] nodes = xmlNodePath.split("/");
110 try { 161 try {
111 - this.xmlReader = new StringReader(this.xmlString);  
112 - this.xmlSource = new InputSource(this.xmlReader);  
113 - this.document = this.builder.build(xmlSource); 162 + xmlReader = new StringReader(xmlString);
  163 + xmlSource = new InputSource(xmlReader);
  164 + document = builder.build(xmlSource);
114 165
115 for(int i = 1; i < nodes.length; ++i) { 166 for(int i = 1; i < nodes.length; ++i) {
116 SubNode snode; 167 SubNode snode;
@@ -139,7 +190,7 @@ public class XMLParse { @@ -139,7 +190,7 @@ public class XMLParse {
139 listNode.clear(); 190 listNode.clear();
140 document = null; 191 document = null;
141 root = null; 192 root = null;
142 - builder = null; 193 +// builder = null;
143 nodes = null; 194 nodes = null;
144 } 195 }
145 196
@@ -31,6 +31,6 @@ @@ -31,6 +31,6 @@
31 <property name="enableSubPackages" value="true"/> 31 <property name="enableSubPackages" value="true"/>
32 </javaClientGenerator> 32 </javaClientGenerator>
33 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> 33 <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
34 - <table tableName="users" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> 34 + <table tableName="AssociatedParty" domainObjectName="FWBAssociatedParty" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
35 </context> 35 </context>
36 </generatorConfiguration> 36 </generatorConfiguration>
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3 +<mapper namespace="com.example.demo.mapper.FWBAssociatedPartyMapper" >
  4 + <resultMap id="BaseResultMap" type="com.example.demo.model.FWBAssociatedParty" >
  5 + <id column="ID" property="id" jdbcType="INTEGER" />
  6 + <result column="PrimaryID" property="primaryid" jdbcType="VARCHAR" />
  7 + <result column="Name" property="name" jdbcType="VARCHAR" />
  8 + <result column="AccountID" property="accountid" jdbcType="VARCHAR" />
  9 + <result column="RoleCode" property="rolecode" jdbcType="VARCHAR" />
  10 + <result column="Role" property="role" jdbcType="VARCHAR" />
  11 + <result column="CityName" property="cityname" jdbcType="VARCHAR" />
  12 + <result column="CountryID" property="countryid" jdbcType="VARCHAR" />
  13 + <result column="AWBNumber" property="awbnumber" jdbcType="VARCHAR" />
  14 + <result column="FlightDate" property="flightdate" jdbcType="TIMESTAMP" />
  15 + <result column="FlightNumber" property="flightnumber" jdbcType="VARCHAR" />
  16 + </resultMap>
  17 + <sql id="Base_Column_List" >
  18 + ID, PrimaryID, Name, AccountID, RoleCode, Role, CityName, CountryID, AWBNumber, FlightDate,
  19 + FlightNumber
  20 + </sql>
  21 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  22 + select
  23 + <include refid="Base_Column_List" />
  24 + from AssociatedParty
  25 + where ID = #{id,jdbcType=INTEGER}
  26 + </select>
  27 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  28 + delete from AssociatedParty
  29 + where ID = #{id,jdbcType=INTEGER}
  30 + </delete>
  31 + <insert id="insert" parameterType="com.example.demo.model.FWBAssociatedParty" >
  32 + insert into AssociatedParty (ID, PrimaryID, Name,
  33 + AccountID, RoleCode, Role,
  34 + CityName, CountryID, AWBNumber,
  35 + FlightDate, FlightNumber)
  36 + values (#{id,jdbcType=INTEGER}, #{primaryid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
  37 + #{accountid,jdbcType=VARCHAR}, #{rolecode,jdbcType=VARCHAR}, #{role,jdbcType=VARCHAR},
  38 + #{cityname,jdbcType=VARCHAR}, #{countryid,jdbcType=VARCHAR}, #{awbnumber,jdbcType=VARCHAR},
  39 + #{flightdate,jdbcType=TIMESTAMP}, #{flightnumber,jdbcType=VARCHAR})
  40 + </insert>
  41 + <insert id="insertSelective" parameterType="com.example.demo.model.FWBAssociatedParty" >
  42 + insert into AssociatedParty
  43 + <trim prefix="(" suffix=")" suffixOverrides="," >
  44 + <if test="id != null" >
  45 + ID,
  46 + </if>
  47 + <if test="primaryid != null" >
  48 + PrimaryID,
  49 + </if>
  50 + <if test="name != null" >
  51 + Name,
  52 + </if>
  53 + <if test="accountid != null" >
  54 + AccountID,
  55 + </if>
  56 + <if test="rolecode != null" >
  57 + RoleCode,
  58 + </if>
  59 + <if test="role != null" >
  60 + Role,
  61 + </if>
  62 + <if test="cityname != null" >
  63 + CityName,
  64 + </if>
  65 + <if test="countryid != null" >
  66 + CountryID,
  67 + </if>
  68 + <if test="awbnumber != null" >
  69 + AWBNumber,
  70 + </if>
  71 + <if test="flightdate != null" >
  72 + FlightDate,
  73 + </if>
  74 + <if test="flightnumber != null" >
  75 + FlightNumber,
  76 + </if>
  77 + </trim>
  78 + <trim prefix="values (" suffix=")" suffixOverrides="," >
  79 + <if test="id != null" >
  80 + #{id,jdbcType=INTEGER},
  81 + </if>
  82 + <if test="primaryid != null" >
  83 + #{primaryid,jdbcType=VARCHAR},
  84 + </if>
  85 + <if test="name != null" >
  86 + #{name,jdbcType=VARCHAR},
  87 + </if>
  88 + <if test="accountid != null" >
  89 + #{accountid,jdbcType=VARCHAR},
  90 + </if>
  91 + <if test="rolecode != null" >
  92 + #{rolecode,jdbcType=VARCHAR},
  93 + </if>
  94 + <if test="role != null" >
  95 + #{role,jdbcType=VARCHAR},
  96 + </if>
  97 + <if test="cityname != null" >
  98 + #{cityname,jdbcType=VARCHAR},
  99 + </if>
  100 + <if test="countryid != null" >
  101 + #{countryid,jdbcType=VARCHAR},
  102 + </if>
  103 + <if test="awbnumber != null" >
  104 + #{awbnumber,jdbcType=VARCHAR},
  105 + </if>
  106 + <if test="flightdate != null" >
  107 + #{flightdate,jdbcType=TIMESTAMP},
  108 + </if>
  109 + <if test="flightnumber != null" >
  110 + #{flightnumber,jdbcType=VARCHAR},
  111 + </if>
  112 + </trim>
  113 + </insert>
  114 + <update id="updateByPrimaryKeySelective" parameterType="com.example.demo.model.FWBAssociatedParty" >
  115 + update AssociatedParty
  116 + <set >
  117 + <if test="primaryid != null" >
  118 + PrimaryID = #{primaryid,jdbcType=VARCHAR},
  119 + </if>
  120 + <if test="name != null" >
  121 + Name = #{name,jdbcType=VARCHAR},
  122 + </if>
  123 + <if test="accountid != null" >
  124 + AccountID = #{accountid,jdbcType=VARCHAR},
  125 + </if>
  126 + <if test="rolecode != null" >
  127 + RoleCode = #{rolecode,jdbcType=VARCHAR},
  128 + </if>
  129 + <if test="role != null" >
  130 + Role = #{role,jdbcType=VARCHAR},
  131 + </if>
  132 + <if test="cityname != null" >
  133 + CityName = #{cityname,jdbcType=VARCHAR},
  134 + </if>
  135 + <if test="countryid != null" >
  136 + CountryID = #{countryid,jdbcType=VARCHAR},
  137 + </if>
  138 + <if test="awbnumber != null" >
  139 + AWBNumber = #{awbnumber,jdbcType=VARCHAR},
  140 + </if>
  141 + <if test="flightdate != null" >
  142 + FlightDate = #{flightdate,jdbcType=TIMESTAMP},
  143 + </if>
  144 + <if test="flightnumber != null" >
  145 + FlightNumber = #{flightnumber,jdbcType=VARCHAR},
  146 + </if>
  147 + </set>
  148 + where ID = #{id,jdbcType=INTEGER}
  149 + </update>
  150 + <update id="updateByPrimaryKey" parameterType="com.example.demo.model.FWBAssociatedParty" >
  151 + update AssociatedParty
  152 + set PrimaryID = #{primaryid,jdbcType=VARCHAR},
  153 + Name = #{name,jdbcType=VARCHAR},
  154 + AccountID = #{accountid,jdbcType=VARCHAR},
  155 + RoleCode = #{rolecode,jdbcType=VARCHAR},
  156 + Role = #{role,jdbcType=VARCHAR},
  157 + CityName = #{cityname,jdbcType=VARCHAR},
  158 + CountryID = #{countryid,jdbcType=VARCHAR},
  159 + AWBNumber = #{awbnumber,jdbcType=VARCHAR},
  160 + FlightDate = #{flightdate,jdbcType=TIMESTAMP},
  161 + FlightNumber = #{flightnumber,jdbcType=VARCHAR}
  162 + where ID = #{id,jdbcType=INTEGER}
  163 + </update>
  164 +</mapper>