示例#1
0
文件: Vender.java 项目: humin11/bnbmg
  public static void zhongbiao(Long id) {
    Toubiao toubiao = Toubiao.findById(id);
    toubiao.status = "1";
    toubiao.save();
    Request request = toubiao.request;
    request.status = 1;
    request.zb = true;
    request.save();
    List<Toubiao> toubiaos = Toubiao.find("request.id=? and id!=?", request.id, id).fetch();
    for (Toubiao tb : toubiaos) {
      tb.status = "2";
      tb.save();
    }
    Config config = Config.find("1=1").first();
    String message = "";
    SendMessage m = new SendMessage();
    message = "您已中标" + toubiao.request.name + "项目,请按时发货";
    if (config.msg_request_invite != null && !"".equals(config.msg_request_invite)) {
      message = config.msg_request_notification.replace("{request}", toubiao.request.name);
    }
    Profile p = toubiao.profile;
    if (p.contact_phone != null && !"".equals(p.contact_phone))
      m.sendSms(p.contact_phone, message, "0000003");
    if (p.contact_email != null && !"".equals(p.contact_email))
      m.sendMail(p.contact_email, "[" + Messages.get("application.name") + "]中标通知", message);

    redirect("/admin/requests");
  }
示例#2
0
文件: Vender.java 项目: humin11/bnbmg
  public static void zbAgain() {
    String id = params.get("toubiaoid");
    String againComments = params.get("againComments");
    Toubiao toubiao = Toubiao.findById(Long.valueOf(id));
    toubiao.again = true;
    toubiao.againComments = againComments;
    toubiao.save();

    Request req = toubiao.request;
    req.status = 2;
    req.save();
    redirect("/vender/tblist?id=" + id);
  }
示例#3
0
文件: Vender.java 项目: humin11/bnbmg
  public static void removeSpec() {
    String id = params.get("id");
    Specification spec = Specification.findById(Long.valueOf(id));
    List<Request> requests =
        Request.em()
            .createQuery(
                "select r from Request r join fetch r.specifications s where s.id="
                    + Long.valueOf(id),
                Request.class)
            .getResultList();

    for (Request req : requests) {
      req.specifications.remove(spec);
      req.save();
    }
    if (spec != null) spec.delete();
    renderText(id);
  }
示例#4
0
  @Test
  public void matchingBBTest() {

    /*
    ====================================================
    BLACK BOX TEST  : SEE /Z/report/report.pdf,  page 16
    ====================================================
    */

    Coordinate coorATest = new Coordinate(50.669715, 4.602624);
    Coordinate coorBTest = new Coordinate(50.667892, 4.619073);
    User userTest =
        new User(
            "loginTest",
            "Mister",
            "Nobody",
            "*****@*****.**",
            "0123-456",
            0,
            null,
            null,
            null,
            null,
            null);
    Date arrTimeTest = new Date(2013, 01, 04, 15, 00);
    Traject trajectTest =
        new Traject(
            1, // Seats
            15, // TotalCost
            null, // Request
            userTest, // User
            null, // Dep PP
            null, // Arr PP
            null); // Proposal
    Request reqTest =
        new Request(
            coorATest, // Coor departure
            coorBTest, // Coor arrival
            "Place Galilee 6 1348 Louvain-La-Neuve", // Adress departure
            "Cour des Fleurets 1348 Louvain-La-Neuve", // Adress arrival
            arrTimeTest, // Arrival time
            1, // Seats
            60, // Time tolerance
            3000, // Walk tolerance in m
            5, // Price tolerance
            userTest, // User
            trajectTest); // Traject
    trajectTest.setRequest(reqTest);

    // BB Test : msg-1
    ArrayList<Traject> response = controllers.Matching.match(reqTest);
    /*for(Traject traj : response){
        Assert.fail("Requete n est pas dans la base de donnees mais matching retourne un trajet");
    }*/
    reqTest.getUser().addRequest(reqTest);
    reqTest.save();
    reqTest.getUser().save();

    // BB Test : msg-2
    ArrayList<Traject> response2 = controllers.Matching.match(reqTest);
    for (Traject traj : response2) {
      ExpressionList<Proposal> res = Proposal.find.where().eq("id", traj.getProposal().getId());
      if (res.findRowCount() < 1) {
        Assert.fail("Proposal n est pas dans la base de donnees mais matching retourne un trajet");
      }
    }

    // BB Test : msg-3 + msg-4
    for (Traject traj : response2) {
      PickupPoint depPP = traj.getDeparturePP().getPickupPoint();
      PickupPoint arrPP = traj.getArrivalPP().getPickupPoint();
      if (PickupPoint.find.where().eq("id", depPP.getId()) != depPP) {
        Assert.fail("Departure PickUpPoint pas dans la base de donnees");
      }
      if (PickupPoint.find.where().eq("id", arrPP.getId()) != arrPP) {
        Assert.fail("Arrival PickUpPoint pas dans la base de donnees");
      }
    }

    for (Traject traj : response2) {
      // BB Test : msg-5
      double walkBegin =
          Matching.distance(
              traj.getDeparturePP().getPickupPoint().getCoordinates(),
              reqTest.getTraject().getDeparturePP().getPickupPoint().getCoordinates());
      double walkEnd =
          Matching.distance(
              reqTest.getTraject().getArrivalPP().getPickupPoint().getCoordinates(),
              traj.getArrivalPP().getPickupPoint().getCoordinates());
      if (walkBegin + walkEnd > 3000) {
        Assert.fail("La tolerance de distance de marche n est pas respectee");
      }

      // BB Test : msg-6
      Date maxiTime = new Date(2013, 01, 04, 16, 00);
      if (traj.getArrivalPP().getTime().after(maxiTime)) {
        Assert.fail("Heure d arrivee du passager depasse la tolerance d heure d arrivee");
      }

      // BB Test : msg-7
      if (traj.getReservedSeats() - 1 < 0) {
        Assert.fail("Pas assez de sieges libres dans la proposition pour satisfaire la requete");
      }

      // BB Test : msg-8
      if (traj.getTotalCost() > 5) {
        Assert.fail("Tolerance en cout non respectee.");
      }
    }
  }