예제 #1
0
  private BenefitResult getBenefitAnalysisResult() {

    Long experimentid = getLong("experiment.id");
    EntityQuery query = new EntityQuery(BenefitResult.class, "result");
    query.add(new Condition("result.experiment.id=:experimentId", experimentid));
    // query.add(new Condition("result.student.code=:stdCode", getLoginName()));
    Student std = getLoginStudent();
    addStdCondition(query, "result", std);
    List results = entityService.search(query);

    BenefitResult result = null;
    if (results.isEmpty()) {
      result = new BenefitResult();
      result.setExperiment((Experiment) entityService.load(Experiment.class, experimentid));
      //			List studentList = (List)entityService.load(Student.class,"code",getLoginName());
      //			if (null != studentList && studentList.size()!=0){
      //				result.setStudent((Student)studentList.get(0));
      //			}
      if (std == null) {
        std = (Student) entityService.load(Student.class, getLong("std.id"));
      }
      result.setStudent(std);
    } else {
      result = (BenefitResult) results.get(0);
    }
    return result;
  }
예제 #2
0
 protected String saveAndForward(Entity entity) {
   BenefitItemResult itemResult = (BenefitItemResult) entity;
   if (itemResult.isVO()) {
     Long experimentid = getLong("experiment.id");
     EntityQuery query = new EntityQuery(BenefitResult.class, "result");
     query.add(new Condition("result.experiment.id=:experimentId", experimentid));
     query.add(new Condition("result.student.code=:stdCode", getLoginName()));
     List results = entityService.search(query);
     BenefitResult result = null;
     if (results.isEmpty()) {
       result = new BenefitResult();
       result.setExperiment((Experiment) entityService.load(Experiment.class, experimentid));
       List studentList = (List) entityService.load(Student.class, "code", getLoginName());
       if (null != studentList && studentList.size() != 0) {
         result.setStudent((Student) studentList.get(0));
       }
       // result.setForm(new Aim());
     } else {
       result = (BenefitResult) results.get(0);
     }
     itemResult.setResult(result);
     // result.getForm().getItmes().add(itemResult);
     result.getItems().add(itemResult);
     entityService.saveOrUpdate(result);
   } else {
     entityService.saveOrUpdate(itemResult);
   }
   return redirect("search", "info.save.success");
 }
예제 #3
0
 public RateResult calculate(Policy policy) {
   RateResult result = new RateResult();
   EntityQuery query = new EntityQuery(PayTimeRate.class, "timerate");
   query.add(
       new Condition(
           "timerate.product=:product and timerate.paytime=:paytime",
           policy.getProduct(),
           policy.getPaytime()));
   query.add(
       new Condition(
           "timerate.time=:time and timerate.gender=:gender",
           policy.getTime(),
           policy.getGender()));
   query.add(new Condition("timerate.paytype=:paytype", policy.getPaytype()));
   List<PayTimeRate> rates = entityService.search(query);
   if (rates.isEmpty()) {
     return result;
   } else {
     PayTimeRate timeRate = rates.get(0);
     Float rate = timeRate.getAgerates().get(policy.getAge());
     result.setRate(rate);
     Number years = calcYears(policy.getAge(), policy.getPaytime().getDuration());
     int countPerYear = policy.getPaytype().getCountPerYear();
     if (years.equals(Double.NaN)) {
       result.setCount(Double.NaN);
     } else {
       result.setCount(years.intValue() * countPerYear);
     }
   }
   return result;
 }
예제 #4
0
 public String search() {
   Long experimentid = getLong("experiment.id");
   EntityQuery query = new EntityQuery(BenefitItemResult.class, "m");
   query.add(new Condition("m.result.experiment.id=:experimentId", experimentid));
   addStdCondition(query, "m.result", getLoginStudent());
   // query.add(new Condition("m.result.student.code=:stdCode", getLoginName()));
   query.setLimit(getPageLimit());
   BenefitResult benefitResult = getBenefitAnalysisResult();
   put("benefitResult", benefitResult);
   put("items", entityService.search(query));
   return forward();
 }
예제 #5
0
 private List getTopFinanceTypes() {
   EntityQuery query = new EntityQuery(FinanceType.class, "financeType");
   query.add(new Condition("financeType.parent is null"));
   List financeTypes = entityService.search(query);
   return financeTypes;
 }