Skip to content

Commit

Permalink
Merge remote-tracking branch 'zqh/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangworld committed Aug 14, 2016
2 parents 3cb6dbd + 15d5799 commit 4a9cb51
Show file tree
Hide file tree
Showing 14 changed files with 1,025 additions and 27 deletions.
12 changes: 11 additions & 1 deletion src/main/java/com/busasst/bean/SchedualBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ public class SchedualBean {
private String driverName;
private String busNumber;
private String routeName;
private int seatNum;

public SchedualBean(String time, String date, String startStation,
String driverName, String busNumber, String routeName) {
String driverName, String busNumber, String routeName, int seatNum) {
this.time = time;
this.date = date;
this.startStation = startStation;
this.driverName = driverName;
this.busNumber = busNumber;
this.routeName = routeName;
this.seatNum = seatNum;
}

public Integer getDriverId() {
Expand Down Expand Up @@ -105,4 +107,12 @@ public String getRouteName() {
public void setRouteName(String routeName) {
this.routeName = routeName;
}

public int getSeatNum() {
return seatNum;
}

public void setSeatNum(int seatNum) {
this.seatNum = seatNum;
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/busasst/controller/WorkerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public class WorkerController {
private WorkerDao workerDao;

@RequestMapping("/list")
public String list(Model model){
public String list(Model model , Sess){
model.addAttribute("workers",workerDao.getAllWorker());

return "workers-mng";
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/busasst/dao/DriverDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.busasst.dao;

import com.busasst.entity.DriverEntity;
import org.springframework.stereotype.Repository;

/**
* Created by sl on 16-8-14.
*/
@Repository("driverDao")
public class DriverDao extends BaseDao{

public DriverEntity getById(int id){
return get(DriverEntity.class,id);
}

}
1 change: 1 addition & 0 deletions src/main/java/com/busasst/dao/RouteDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
@Repository("routeDao")
public class RouteDao extends BaseDao {

public RouteEntity getById(int id) {
return get(RouteEntity.class, id);
}
Expand Down
40 changes: 39 additions & 1 deletion src/main/java/com/busasst/dao/SchedualDao.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.busasst.dao;

import com.busasst.bean.SchedualBean;
import com.busasst.entity.BusEntity;
import com.busasst.entity.DriverEntity;
import com.busasst.entity.RouteEntity;
import com.busasst.entity.SchedualEntity;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -12,11 +18,43 @@
@Repository("schedualDao")
public class SchedualDao extends BaseDao{

@Autowired
private CarDao carDao;

@Autowired
private RouteDao routeDao;

@Autowired
private DriverDao driverDao;

public List<SchedualBean> getDetaile(String date){

List<SchedualBean> schedualBeans = new ArrayList<>();
String hql = "from SchedualEntity as schedual where schedual.date='"+date+"'";
Query query = query(hql);
return query.list();
List<SchedualEntity> schedualEntities = query.list();

for(SchedualEntity schedual : schedualEntities){
System.out.println("schedual.getRouId(): "+schedual.getRouId());
System.out.println("schedual.getDriverId(): "+schedual.getDriverId());
System.out.println("schedual.getBusId(): "+schedual.getBusId());

RouteEntity route = routeDao.getById(schedual.getRouId());
// RouteEntity route = routeDao.getById(1);

DriverEntity driver = driverDao.getById(schedual.getDriverId());
BusEntity bus = carDao.getById(schedual.getBusId());

System.out.println(bus.getNumber());
System.out.println(schedual.getTime()+" "+date+" "+route.getStartStation());

SchedualBean schedualBean = new SchedualBean(schedual.getTime(),date,route.getStartStation(),
driver.getName(),bus.getNumber(),route.getName(),bus.getSeatnum());

schedualBeans.add(schedualBean);
}

return schedualBeans;

}

Expand Down
93 changes: 93 additions & 0 deletions src/main/java/com/busasst/entity/DriverEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.busasst.entity;

import javax.persistence.*;

/**
* Created by sl on 16-8-14.
*/
@Entity
@Table(name = "driver", schema = "", catalog = "db_bus")
public class DriverEntity {
private int driverId;
private String name;
private String driverLicense;
private String sex;
private Integer age;

@Id
@Column(name = "driver_id", nullable = false, insertable = true, updatable = true)
public int getDriverId() {
return driverId;
}

public void setDriverId(int driverId) {
this.driverId = driverId;
}

@Basic
@Column(name = "name", nullable = true, insertable = true, updatable = true, length = 255)
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Basic
@Column(name = "driver_license", nullable = true, insertable = true, updatable = true, length = 255)
public String getDriverLicense() {
return driverLicense;
}

public void setDriverLicense(String driverLicense) {
this.driverLicense = driverLicense;
}

@Basic
@Column(name = "sex", nullable = true, insertable = true, updatable = true, length = 255)
public String getSex() {
return sex;
}

public void setSex(String sex) {
this.sex = sex;
}

@Basic
@Column(name = "age", nullable = true, insertable = true, updatable = true)
public Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

DriverEntity that = (DriverEntity) o;

if (driverId != that.driverId) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (driverLicense != null ? !driverLicense.equals(that.driverLicense) : that.driverLicense != null)
return false;
if (sex != null ? !sex.equals(that.sex) : that.sex != null) return false;
if (age != null ? !age.equals(that.age) : that.age != null) return false;

return true;
}

@Override
public int hashCode() {
int result = driverId;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (driverLicense != null ? driverLicense.hashCode() : 0);
result = 31 * result + (sex != null ? sex.hashCode() : 0);
result = 31 * result + (age != null ? age.hashCode() : 0);
return result;
}
}
31 changes: 23 additions & 8 deletions src/main/java/com/busasst/entity/RouteEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import javax.persistence.*;

/**
* Created by tsj on 16-7-5.
* Created by sl on 16-8-14.
*/
@Entity
@Table(name = "route", schema = "", catalog = "db_bus")
Expand All @@ -14,22 +14,25 @@ public class RouteEntity {
private Integer stationSum;
private Double riderate;
private String distance;
private String startStation;

public RouteEntity(int rouId, String name, Integer workerSum, Integer stationSum, Double riderate, String distance) {
public RouteEntity(int rouId, String name, Integer workerSum, Integer stationSum,
Double riderate, String distance, String startStation) {
this.rouId = rouId;
this.name = name;
this.workerSum = workerSum;
this.stationSum = stationSum;
this.riderate = riderate;
this.distance = distance;
this.startStation = startStation;
}

public RouteEntity(){

}

@Id
@Column(name = "rou_id")
@Column(name = "rou_id", nullable = false, insertable = true, updatable = true)
public int getRouId() {
return rouId;
}
Expand All @@ -39,7 +42,7 @@ public void setRouId(int rouId) {
}

@Basic
@Column(name = "name")
@Column(name = "name", nullable = true, insertable = true, updatable = true, length = 100)
public String getName() {
return name;
}
Expand All @@ -49,7 +52,7 @@ public void setName(String name) {
}

@Basic
@Column(name = "worker_sum")
@Column(name = "worker_sum", nullable = true, insertable = true, updatable = true)
public Integer getWorkerSum() {
return workerSum;
}
Expand All @@ -59,7 +62,7 @@ public void setWorkerSum(Integer workerSum) {
}

@Basic
@Column(name = "station_sum")
@Column(name = "station_sum", nullable = true, insertable = true, updatable = true)
public Integer getStationSum() {
return stationSum;
}
Expand All @@ -69,7 +72,7 @@ public void setStationSum(Integer stationSum) {
}

@Basic
@Column(name = "riderate")
@Column(name = "riderate", nullable = true, insertable = true, updatable = true, precision = 0)
public Double getRiderate() {
return riderate;
}
Expand All @@ -79,7 +82,7 @@ public void setRiderate(Double riderate) {
}

@Basic
@Column(name = "distance")
@Column(name = "distance", nullable = true, insertable = true, updatable = true, length = 100)
public String getDistance() {
return distance;
}
Expand All @@ -88,6 +91,16 @@ public void setDistance(String distance) {
this.distance = distance;
}

@Basic
@Column(name = "start_station", nullable = true, insertable = true, updatable = true, length = 255)
public String getStartStation() {
return startStation;
}

public void setStartStation(String startStation) {
this.startStation = startStation;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -101,6 +114,7 @@ public boolean equals(Object o) {
if (stationSum != null ? !stationSum.equals(that.stationSum) : that.stationSum != null) return false;
if (riderate != null ? !riderate.equals(that.riderate) : that.riderate != null) return false;
if (distance != null ? !distance.equals(that.distance) : that.distance != null) return false;
if (startStation != null ? !startStation.equals(that.startStation) : that.startStation != null) return false;

return true;
}
Expand All @@ -113,6 +127,7 @@ public int hashCode() {
result = 31 * result + (stationSum != null ? stationSum.hashCode() : 0);
result = 31 * result + (riderate != null ? riderate.hashCode() : 0);
result = 31 * result + (distance != null ? distance.hashCode() : 0);
result = 31 * result + (startStation != null ? startStation.hashCode() : 0);
return result;
}
}
10 changes: 5 additions & 5 deletions src/main/webapp/assets/css/app.min.css

Large diffs are not rendered by default.

Loading

0 comments on commit 4a9cb51

Please sign in to comment.