Skip to content

Commit

Permalink
Added DepartureDate on Ticket class
Browse files Browse the repository at this point in the history
  • Loading branch information
woshizhangbin committed Dec 14, 2012
1 parent bbacff9 commit 407e526
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 18 deletions.
Binary file modified docs/uml/org.ng12306.tpms.prototype.vpp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private TrainNumber CreateK600K597() {
TrainNumber rs = new TrainNumber();

rs.setId(UUID.randomUUID());
rs.setTrainNumber("K600/K597");
rs.setName("K600/K597");
Route route = new Route();
route.setId(UUID.randomUUID());
route.setStartDate(new LocalDate(0L));
Expand All @@ -87,11 +87,11 @@ private TrainNumber CreateG101() {
TrainNumber rs = new TrainNumber();

rs.setId(UUID.randomUUID());
rs.setTrainNumber("G101");
rs.setName("G101");
Route route = new Route();
route.setId(UUID.randomUUID());
route.setStartDate(new LocalDate(0L));
route.setEndDate(new LocalDate(Long.MAX_VALUE));
route.setEndDate(LocalDate.now().plusYears(10));
rs.getRoutes().add(route);

for(int i = 0; i <=7; i ++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,18 @@ public boolean hasTickets(TicketQueryArgs args) throws Exception {
public Ticket[] book(TicketQueryArgs args) throws Exception {

final TicketPoolQueryArgs args2 = this.toPoolQueryArgs(args);
PlanTicket[] planTickets = Queries.query(this.query(args2)).toArray(new PlanTicket[0]);;
PlanTicket[] planTickets = Queries.query(this.query(args2)).toArray(new PlanTicket[0]);



for(PlanTicket pt : planTickets)
{
pt.getGroup().getTickets().remove(pt);
if(pt.getGroup().getTickets().size() == 0)
{
this._stopRangeGroups.remove(pt.getGroup());
}

if(args2.getDepartureStop() > pt.getStartStop())
{
PlanTicket pre = new PlanTicket();
Expand All @@ -183,10 +190,28 @@ public Ticket[] book(TicketQueryArgs args) throws Exception {
after.getSalableRange().copyFrom(pt.getSalableRange());
this.addPlanTicketToGroup(after);
}


}

Ticket[] rs = new Ticket[planTickets.length];

return null;
for(int i = 0; i < planTickets.length; i++)
{
PlanTicket pt = planTickets[i];
rs[i] = new Ticket();
rs[i].setId(UUID.randomUUID());
rs[i].setTrainNumber(this._train.getTrainNumber().getName());
rs[i].setCar(Integer.toString(pt.getSeat().getCar().getCarNumber()));
rs[i].setSeatNumber(pt.getSeat().getSeatNumber());
rs[i].setDepartureStation(args.getDepartureStation());
rs[i].setDestinationStation(args.getDestinationStation());
rs[i].setDepartureDate(args.getDate());

}


return rs;
}

private void addPlanTicketToGroup(PlanTicket pt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void initializeService() throws Exception
pool.setSite(this.getSite());
pool.initialize();

String key = tn.getTrainNumber() + "|" + date.toString();
String key = tn.getName() + "|" + date.toString();

this._pools.put(key, pool);

Expand Down
46 changes: 40 additions & 6 deletions trunk/tpms/src/main/java/org/ng12306/tpms/runtime/Ticket.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.ng12306.tpms.runtime;

import org.joda.time.LocalDate;

public class Ticket extends Entity {

private String _trainNumber;
Expand All @@ -14,25 +16,57 @@ public void setTrainNumber(String value) {

private String _departureStation;

public String getname() {
public String getDepartureStation() {
return this._departureStation;
}

public void setname(String value) {
public void setDepartureStation(String value) {
this._departureStation = value;
}



private String _destinationStation;

public String getDestination() {
public String getDestinationStation() {
return this._destinationStation;
}

public void setDestination(String value) {
public void setDestinationStation(String value) {
this._destinationStation = value;
}

private String _car;

public String getCar() {
return this._car;
}

public void setCar(String value) {
this._car = value;
}

private String _seatNumber;

public String getSeatNumber() {
return this._seatNumber;
}

public void setSeatNumber(String value) {
this._seatNumber = value;
}

private LocalDate _departureDate;

public LocalDate getDepartureDate() {
return this._departureDate;
}

public void setDepartureDate(LocalDate value) {
this._departureDate = value;
}







Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import java.util.Collection;

public class TrainNumber extends Entity {
private String _trainNumber;
private String _name;

public String getTrainNumber() {
return this._trainNumber;
public String getName() {
return this._name;
}

public void setTrainNumber(String value) {
this._trainNumber = value;
public void setName(String value) {
this._name = value;
}

private Collection<Route> _routes = new ArrayList<Route>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse
#Fri Dec 14 17:54:01 EST 2012
#Fri Dec 14 19:32:52 EST 2012
version=0.1
groupId=org.ng12306.tpms
m2e.projectName=org.ng12306.tpms
Expand Down

0 comments on commit 407e526

Please sign in to comment.