예제 #1
0
  public void calculatePersonAge(Person person) {
    DateTime birthdate = person.getBirthdate();
    DateTime now = DateTime.now();

    Years years = Years.yearsBetween(birthdate, now);
    person.setAge(years.getYears());
  }
예제 #2
0
  public static int getRecurrencesBetween(
      RecurrenceInterval interval, int multiplier, Date start, Date end) {
    DateTime then = new DateTime(start);
    DateTime now = new DateTime(end);

    int count = 1;
    switch (interval) {
      case ONCE:
        break;
      case DAY:
        count += Days.daysBetween(then, now).getDays() / multiplier;
        break;
      case MONTH:
        count += Months.monthsBetween(then, now).getMonths() / multiplier;
        break;
      case QUARTER:
        int quarters = Months.monthsBetween(then, now).getMonths() / 3;
        count += quarters / multiplier;
        break;
      case YEAR:
        count += Years.yearsBetween(then, now).getYears() / multiplier;
        break;
    }

    return count;
  }
예제 #3
0
 private JSONArray constructResponse(Cursor c, String parameters) throws JSONException {
   JSONObject params = new JSONObject(parameters);
   c.moveToFirst();
   String[] columnNames = c.getColumnNames();
   JSONArray json = new JSONArray();
   String addressFieldName = null;
   if (params.has("addressFieldName") && null != params.getString("addressFieldName")) {
     addressFieldName =
         CaseFormat.LOWER_UNDERSCORE.to(
             CaseFormat.LOWER_CAMEL, params.getString("addressFieldName"));
   }
   while ((!c.isAfterLast())) {
     JSONObject obj = new JSONObject();
     for (int i = 0; i < columnNames.length; i++) {
       if (columnNames[i].equals("birthdate")) {
         obj.put(
             "age", Years.yearsBetween(DateTime.parse(c.getString(i)), new DateTime()).getYears());
       } else if (params.has("addressFieldName") && columnNames[i].equals(addressFieldName)) {
         JSONObject address = new JSONObject();
         address.put(params.getString("addressFieldName"), c.getString(i));
         obj.put("addressFieldValue", address);
       } else if (params.has("extraIdentifiers") && columnNames[i].equals("extraIdentifiers")) {
         JSONObject extraIdentifiers = new JSONObject();
         extraIdentifiers.put("extraIdentifiers", c.getString(i));
         obj.put("extraIdentifiers", extraIdentifiers);
       } else {
         obj.put(columnNames[i], c.getString(i));
       }
     }
     json.put(obj);
     c.moveToNext();
   }
   c.close();
   return json;
 }
예제 #4
0
  private void storeWeeklyMetrics(LocalDate crc) {
    // Store weekly demand metrics
    Years yr = Years.years(crc.getYear());
    Map<LocalDate, Demand> currDemandMap = demandMap.get(yr);
    if (currDemandMap == null) {
      currDemandMap = new TreeMap<LocalDate, Demand>();
    }
    Demand d = currDemandMap.get(crc);
    if (d == null) {
      d = new Demand();
    }
    d.setRcAvgDemand(rcAvgDemand);
    d.setRcAvgDemandActual(rcAvgDemandActual);
    currDemandMap.put(crc, d);
    demandMap.put(yr, currDemandMap);

    // Store weekly sales metrics
    Map<LocalDate, Sales> currSalesMap = salesMap.get(yr);
    if (currSalesMap == null) {
      currSalesMap = new TreeMap<LocalDate, Sales>();
    }
    Sales s = currSalesMap.get(crc);
    if (s == null) {
      s = new Sales();
    }
    s.setRcAvgSalesActual(rcAvgSalesActual);
    s.setRcAvgSales(rcAvgSales);
    currSalesMap.put(crc, s);
    salesMap.put(yr, currSalesMap);
  }
예제 #5
0
 /**
  * 求两个直接的日期差,月份.
  *
  * <p>*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS
  *
  * @param tDate 日期格式"20150404"
  * @param txDate 日期格式"20150404"
  * @param type type 选择 DAYS||MONTHS||YEARS
  * @return
  */
 public static int diff(String tDate, String txDate, String type) {
   if (txDate != null && tDate != null) {
     DateTime txDT = DateTime.parse(txDate, ISODateTimeFormat.basicDate());
     DateTime tDT = DateTime.parse(tDate, ISODateTimeFormat.basicDate());
     if (type.toUpperCase().endsWith("DAYS")) {
       return Days.daysBetween(txDT, tDT).getDays();
     } else if (type.toUpperCase().endsWith("MONTHS")) {
       return Months.monthsBetween(txDT, tDT).getMonths();
     } else if (type.toUpperCase().endsWith("YEARS")) {
       return Years.yearsBetween(txDT, tDT).getYears();
     } else if (type.toUpperCase().endsWith("YEARS")) {
       return Years.yearsBetween(txDT, tDT).getYears();
     }
   }
   return 0;
 }
예제 #6
0
 /**
  * 计算两个日期之间的时间间隔(不计算毫秒数)
  *
  * @param date1,date2
  * @param timeType
  * @return int
  */
 public static int periodBtDate(Date date1, Date date2, TimeType timeType) {
   if (date1 == null || date2 == null) {
     throw new IllegalArgumentException("date param can not be null");
   }
   DateTime start = fromDate(date1);
   DateTime end = fromDate(date2);
   int period = 0;
   switch (timeType.getCode()) {
     case "Y":
       period = Years.yearsBetween(start, end).getYears();
       break;
     case "M":
       period = Months.monthsBetween(start, end).getMonths();
       break;
     case "W":
       period = Weeks.weeksBetween(start, end).getWeeks();
       break;
     case "D":
       period = Days.daysBetween(start, end).getDays();
       break;
     case "H":
       period = Hours.hoursBetween(start, end).getHours();
       break;
     case "MIN":
       period = Minutes.minutesBetween(start, end).getMinutes();
       break;
     case "S":
       period = Seconds.secondsBetween(start, end).getSeconds();
       break;
     default:
       break;
   }
   return Math.abs(period);
 }
  /**
   * Defines the magnitudes that can be added to the timestamp
   *
   * @param token token of form "[number][magnitude]" (ex. "1d")
   * @return integer indicating the magnitude of the date for the calendar system
   */
  public static ReadablePeriod getTimePeriod(String token) {
    String valString = token.substring(0, token.length() - 1);
    int value = Integer.parseInt(valString);
    char mag = token.charAt(token.length() - 1);

    ReadablePeriod period;

    switch (mag) {
      case 's':
        period = Seconds.seconds(value);
        break;
      case 'm':
        period = Minutes.minutes(value);
        break;
      case 'h':
        period = Hours.hours(value);
        break;
      case 'd':
        period = Days.days(value);
        break;
      case 'M':
        period = Months.months(value);
        break;
      case 'y':
        period = Years.years(value);
        break;
      default:
        logger.warn("Invalid date magnitude: {}. Defaulting to seconds.", mag);
        period = Seconds.seconds(value);
        break;
    }

    return period;
  }
예제 #8
0
 private double getDemandUplift(LocalDate dt) {
   Map<LocalDate, List<Event>> currEventMap = eventsMap.get(Years.years(dt.getYear()));
   if (currEventMap == null) {
     return 1.0;
   }
   List<Event> events = currEventMap.get(dt);
   return Event.calculateDemandUplift(events);
 }
예제 #9
0
 public void setTempOnHold(LocalDate dt, Boolean val) {
   Years yr = Years.years(dt.getYear());
   Map<LocalDate, Boolean> map = tempOnHoldMap.get(yr);
   if (map == null) {
     map = new TreeMap<LocalDate, Boolean>();
   }
   map.put(dt, val);
   tempOnHoldMap.put(yr, map);
 }
예제 #10
0
 public static int getYearsBetween(final String date1, final String date2, String format) {
   try {
     final DateTimeFormatter fmt =
         DateTimeFormat.forPattern(format)
             .withChronology(LenientChronology.getInstance(GregorianChronology.getInstance()));
     return Years.yearsBetween(fmt.parseDateTime(date1), fmt.parseDateTime(date2)).getYears();
   } catch (Exception ex) {
     ex.printStackTrace();
     return 0;
   }
 }
  @Test
  public void serializesCreditCardWithOutIdAndWithAppropriateMontshAndYears() throws Exception {

    CreditCard creditCard =
        new CreditCard(
            new CreditCardNumber("1234123412341234"),
            "Oliver Gierke",
            Months.ELEVEN,
            Years.years(2013));
    assertThat(mapper.writeValueAsString(creditCard), is(REFERENCE));
  }
예제 #12
0
  public void addEvent(LocalDate dt, Event e) {
    Years yr = Years.years(dt.getYear());
    Map<LocalDate, List<Event>> currEventMap = eventsMap.get(yr);
    if (currEventMap == null) {
      currEventMap = new TreeMap<LocalDate, List<Event>>();
    }

    List<Event> eventList = currEventMap.get(dt);
    if (eventList == null) {
      eventList = new ArrayList<Event>();
    }
    eventList.add(e);
    currEventMap.put(dt, eventList);
    eventsMap.put(yr, currEventMap);
  }
예제 #13
0
 /**
  * 求两个直接的日期差,月份.
  *
  * @param tDate
  * @param txDate
  * @param type 选择 DAYS||MONTHS||YEARS||HOURS||MSECONDS||MINUTES||SECONDS
  * @return
  */
 public static int diff(Date tDate, Date txDate, String type) {
   if (txDate != null && tDate != null) {
     DateTime txDT = new DateTime(txDate);
     DateTime tDT = new DateTime(tDate);
     if (type != null) {
       if (type.toUpperCase().endsWith("DAYS") || type.toUpperCase().endsWith("D")) {
         return Days.daysBetween(txDT, tDT).getDays();
       } else if (type.toUpperCase().endsWith("MONTHS")) {
         return Months.monthsBetween(txDT, tDT).getMonths();
       } else if (type.toUpperCase().endsWith("YEARS") || type.toUpperCase().endsWith("Y")) {
         return Years.yearsBetween(txDT, tDT).getYears();
       } else if (type.toUpperCase().endsWith("HOURS") || type.toUpperCase().endsWith("H")) {
         return Hours.hoursBetween(txDT, tDT).getHours();
       } else if (type.toUpperCase().endsWith("MSECONDS")) {
         return Seconds.secondsBetween(txDT, tDT).getSeconds();
       } else if (type.toUpperCase().endsWith("MINUTES")) {
         return Minutes.minutesBetween(txDT, tDT).getMinutes();
       } else if (type.toUpperCase().endsWith("SECONDS") || type.toUpperCase().endsWith("S")) {
         return Seconds.secondsBetween(txDT, tDT).getSeconds();
       }
     }
   }
   return 0;
 }
예제 #14
0
 public static int getAge(DateTime birthDate) {
   return Years.yearsBetween(birthDate, new DateTime()).getYears();
 }
예제 #15
0
 public int getAge() {
   DateMidnight bd = new DateMidnight(birthdate);
   DateTime now = new DateTime(gameDate);
   Years age = Years.yearsBetween(bd, now);
   return age.getYears();
 }
예제 #16
0
  /** Outlier filtering has been done prior to processing daily metrics * */
  private void processDailyMetrics() {
    LocalDate crc = SystemDao.getCrc();
    double lostSales = getLostSales();

    rcSalesActual = rcSalesActual + epSalesActual;
    // rcSales is outlier filtered sales and has been calculated in outlier processing
    rcSales = rcSales + epSales;

    Years yr = Years.years(crc.getYear());
    Map<LocalDate, Sales> currSalesMap = salesMap.get(yr);
    if (currSalesMap == null) {
      currSalesMap = new TreeMap<LocalDate, Sales>();
    }
    Sales s = currSalesMap.get(crc);
    if (s == null) {
      s = new Sales();
    }
    s.setEpSalesActual(epSalesActual);
    s.setEpSales(epSales);
    s.setRcSales(rcSales);
    s.setRcSalesActual(rcSalesActual);
    s.setLostSales(lostSales);

    currSalesMap.put(crc, s);
    salesMap.put(yr, currSalesMap);

    /** * Daily Demand Calculations **** */
    // daily demand
    epDemand = getEpDemand();
    // demand = sales + lostsales
    // outlier filtered sales used for rcDemand
    rcDemand = rcSales + lostSales;
    rcDemandActual += (epSalesActual + lostSales);

    Map<LocalDate, Demand> currDemandMap = demandMap.get(yr);
    if (currDemandMap == null) {
      currDemandMap = new TreeMap<LocalDate, Demand>();
    }
    Demand d = currDemandMap.get(crc);
    if (d == null) {
      d = new Demand();
    }
    d.setEpDemand(epDemand);
    d.setRcDemand(rcDemand);
    d.setRcDemandActual(rcDemandActual);
    currDemandMap.put(crc, d);
    demandMap.put(yr, currDemandMap);

    /** **** Daily Inventory Calculations ****** */
    processInventory();

    if (epSales > rcMaxSales) {
      rcMaxSales = epSales;
      weekSinceMaxSales = 0;
    }

    if (epEopInv > demoStock) {
      daysSinceWalk = daysSinceWalk + 1;
    } else {
      daysSinceWalk = 0;
    }

    if (epSalesActual == 0) {
      daysSinceSale = daysSinceSale + 1;
    } else {
      daysSinceSale = 0;
    }

    Map<LocalDate, ProductInventory> currInventoryMap = inventoryMap.get(yr);
    if (currInventoryMap == null) {
      currInventoryMap = new TreeMap<LocalDate, ProductInventory>();
    }
    ProductInventory inv = currInventoryMap.get(crc);
    if (inv == null) {
      inv = new ProductInventory();
    }
    inv.setEpAvgInv(epAvgInv);
    inv.setEpEopInv(epEopInv);
    inv.setEpInvOut(epInvOut);
    inv.setEpInvIn(epInvIn);
    inv.setRcBopInv(rcBopInv);
    inv.setRcBopInv(rcBopInv);
    inv.setRcInvIn(rcInvIn);
    inv.setRcInvOut(rcInvOut);
    inv.setInventory(inventory);

    currInventoryMap.put(crc, inv);
    inventoryMap.put(yr, currInventoryMap);

    if (statusCd == STATUS_CD.LEARNING) {
      performDailyLearning();
    }
    resetEpAccumulators();
  }
  public void showDataEntryFragment(Event event, String programStage) {
    Bundle args = getArguments();
    DataEntryFragment fragment;
    String progId = mForm.getProgram().getId(); // new line :AgeToday
    if (event == null) {
      fragment =
          DataEntryFragment.newInstanceWithEnrollment(
              args.getString(ORG_UNIT_ID),
              args.getString(PROGRAM_ID),
              programStage,
              mForm.getEnrollment().localId);
    } else if (progId.equals("u9FZUM7kn38") && event != null) {
      /*- The If-Else block below is used to add the AgeToday Feature, a requirement for the HPV Campaign Program -*/
      fragment =
          DataEntryFragment.newInstanceWithEnrollment(
              args.getString(ORG_UNIT_ID),
              args.getString(PROGRAM_ID),
              programStage,
              event.getLocalEnrollmentId(),
              event.getLocalId());

      Enrollment enrollment = DataValueController.getEnrollment(event.getLocalEnrollmentId());
      List<TrackedEntityAttributeValue> teav = enrollment.getAttributes();
      // getActionBar().setSubtitle("Learner's AgeToday is: " + displayAge);
      // getActionBar().setDisplayShowTitleEnabled(true);

      for (TrackedEntityAttributeValue val : teav) {
        System.out.println("The learner details are: ->" + val.getValue());
      }

      // If passport number is entered then :  String learnerDob   = teav.get(4).getValue();
      // String learnerDob   = teav.get(3).getValue(); Training Instance - Position for LearnerDOB
      // when IDNumber is entered
      String learnerDob = teav.get(2).getValue(); // Staging Instance
      // String learnerDob   = teav.get(3).getValue();
      if (!isValidDate(learnerDob)) learnerDob = teav.get(3).getValue();
      System.out.println("What is in learnerstring :" + learnerDob);
      // --Use Joda Time to compute the learner's age today
      LocalDate birthdate = new LocalDate(learnerDob);
      LocalDate now = new LocalDate();
      // Compute learners age today
      Years learnersAgeToday = Years.yearsBetween(birthdate, now);

      System.out.println("The learners age today is:====>" + learnersAgeToday);
      ageToday = String.valueOf(learnersAgeToday);
      StringBuilder sbAgeToday = new StringBuilder(ageToday);
      sbAgeToday.delete(0, 1);

      sbAgeToday.append("EARS");
      System.out.println("The OLD learners age is:" + ageToday);
      //  String myDisplay = printLearnersAge();
      displayAge = sbAgeToday.toString();
      System.out.println("THE NEW LEARNERS AGE FIXED: " + displayAge);
      //   List<ProgramStageDataElement> programStageDataElements =
      // MetaDataController.getProgramStageDataElements
      // (MetaDataController.getProgramStage(event.getProgramStageId()));
      //  for(ProgramStageDataElement de: programStageDataElements) {
      //       System.out.println("The data elements in the program are:" + de.getDataElement());

      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

      builder
          .setMessage("The learner's Age Today is: " + displayAge)
          .setCancelable(false)
          .setTitle("Learner's Age Today Notification")
          .setPositiveButton(
              "OK",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  dialog.dismiss();
                }
              });

      AlertDialog dialog = builder.create();
      dialog.show();

    } else {
      fragment =
          DataEntryFragment.newInstanceWithEnrollment(
              args.getString(ORG_UNIT_ID),
              args.getString(PROGRAM_ID),
              programStage,
              event.getLocalEnrollmentId(),
              event.getLocalId());
    }

    mNavigationHandler.switchFragment(fragment, ProgramOverviewFragment.CLASS_TAG, true);
  }
예제 #18
0
 private ProductInventory getInventory(LocalDate dt) {
   return inventoryMap.get(Years.years(dt.getYear())) == null
       ? null
       : inventoryMap.get(Years.years(dt.getYear())).get(dt);
 }
예제 #19
0
  public void fillIrcReservePerInfo(IrcReserve ircReserve) {
    if (ircReserve != null && StringUtils.isBlank(ircReserve.getUserName())) {
      Integer perId = ircReserve.getUserId();
      Integer resId = ircReserve.getResId();

      try {
        Map<String, Object> perMap =
            getJdbcTemplate().queryForMap("SELECT * FROM per_user WHERE id=?", perId);

        String birthday = ObjectUtils.toString(perMap.get("birthday"));
        Integer age = 16;
        if (StringUtils.isNotBlank(birthday)) {
          age = Years.yearsBetween(new DateTime(birthday), DateTime.now()).getYears();
          age = (age < 16 || age > 65) ? 16 : age;
        }
        String userName = ObjectUtils.toString(perMap.get("userName"));
        Integer gender = NumberUtils.toInt(ObjectUtils.toString(perMap.get("gender")), 0);
        Integer jobyearType = NumberUtils.toInt(ObjectUtils.toString(perMap.get("jobyearType")), 0);
        String schoolName = "";
        int degree = 0;
        PerUser perUser = perUserEao.get(perId);
        if (perUser != null) {
          PerResumeBo vo;
          try {
            vo = perResumeEao.getResumeVo(perUser.getResId());
          } catch (Exception ex) {
            vo = null;
          }
          if (vo != null) {
            if (vo.getEducationInfoVoList() != null) {
              for (PerResumeBo.EducationInfoVo eduVo : vo.getEducationInfoVoList()) {
                if (eduVo != null && eduVo.getDegree() != null && eduVo.getDegree() > degree) {
                  degree = eduVo.getDegree();
                  schoolName = eduVo.getSchoolName();
                }
              }
            }
          }
        }

        ircReserve.setUserName(userName);
        ircReserve.setGender(gender);
        ircReserve.setAge(age);
        ircReserve.setDegree(degree);
        ircReserve.setSchoolName(schoolName);
        ircReserve.setJobyearType(jobyearType);

        getJdbcTemplateIrc()
            .update(
                "UPDATE irc_reserve SET "
                    + " user_name = ?,"
                    + " age = ?,"
                    + " gender=?,"
                    + " jobyear_type = ? "
                    + " WHERE "
                    + " res_id=? ",
                userName,
                age,
                gender,
                jobyearType,
                resId);

      } catch (Exception e) {
        // 不处理
      }
    }
  }
예제 #20
0
 private Demand getDemand(LocalDate dt) {
   return demandMap.get(Years.years(dt.getYear())) == null
       ? null
       : demandMap.get(Years.years(dt.getYear())).get(dt);
 }
예제 #21
0
 private Sales getSales(LocalDate dt) {
   return salesMap.get(Years.years(dt.getYear())) == null
       ? null
       : salesMap.get(Years.years(dt.getYear())).get(dt);
 }
예제 #22
0
  public void fillBuyHistoryPerInfo(ComResumeBuyHistory comResumeBuyHistory) {
    if (comResumeBuyHistory != null && StringUtils.isBlank(comResumeBuyHistory.getSchoolName())) {
      Integer perId = comResumeBuyHistory.getPerUserId();
      Integer id = comResumeBuyHistory.getId();

      try {
        Map<String, Object> perMap =
            getJdbcTemplate().queryForMap("SELECT * FROM per_user WHERE id=?", perId);

        String birthday = ObjectUtils.toString(perMap.get("birthday"));
        Integer age = 16;
        if (StringUtils.isNotBlank(birthday)) {
          // 计算年龄的公司修改为精确到年与搜索引擎匹配
          DateTime bDate = new DateTime(birthday);
          bDate = bDate.monthOfYear().setCopy(1).dayOfMonth().setCopy(1);
          DateTime nDate = DateTime.now();
          nDate = nDate.monthOfYear().setCopy(1).dayOfMonth().setCopy(1);
          age = Years.yearsBetween(bDate, nDate).getYears();
          age = (age < 16 || age > 65) ? 16 : age;
        }
        Integer gender = NumberUtils.toInt(ObjectUtils.toString(perMap.get("gender")), 0);
        Integer jobyearType = NumberUtils.toInt(ObjectUtils.toString(perMap.get("jobyearType")), 0);
        String schoolName = "";
        String speciality = "";
        String genderStr = OptionMap.getValueByType(OptionMap.OptionType.OPT_GENDER, gender, null);

        PerUser perUser = perUserEao.get(perId);
        if (perUser != null) {
          PerResumeBo vo;
          try {
            vo = perResumeEao.getResumeVo(perUser.getResId());
          } catch (Exception ex) {
            vo = null;
          }
          if (vo != null) {
            int degree = 0;
            if (vo.getEducationInfoVoList() != null) {
              for (PerResumeBo.EducationInfoVo eduVo : vo.getEducationInfoVoList()) {
                if (eduVo != null && eduVo.getDegree() != null && eduVo.getDegree() > degree) {
                  degree = eduVo.getDegree();
                  schoolName = eduVo.getSchoolName();
                  speciality = eduVo.getSpeciality();
                }
              }
            }
          }
        }
        String degreeStr =
            OptionMap.getValueByType(OptionMap.OptionType.OPT_PER_DEGREE, gender, null);
        ;

        comResumeBuyHistory.setAge(age);
        comResumeBuyHistory.setGender(genderStr);
        comResumeBuyHistory.setDegree(degreeStr);
        comResumeBuyHistory.setSchoolName(schoolName);
        comResumeBuyHistory.setSpeciality(speciality);
        comResumeBuyHistory.setJobyear(jobyearType);

        getJdbcTemplate()
            .update(
                "UPDATE com_resume_buy_history SET "
                    + " age = ?,"
                    + " gender = ?,"
                    + " degree = ?,"
                    + " school_name = ? "
                    + " speciality = ? "
                    + " jobyear = ? "
                    + " WHERE "
                    + " id=? ",
                age,
                genderStr,
                degreeStr,
                schoolName,
                speciality,
                jobyearType,
                id);

      } catch (Exception e) {
        // 不处理
      }
    }
  }
    public Arrest(DateTime baseDate, PersonElementWrapper person) {

      date = person.birthdate;

      while (Years.yearsBetween(person.birthdate, date).getYears() < 14) {
        // make sure we don't arrest anyone younger than 14
        date = generateUniformRandomDateBetween(baseDate.minusYears(8), baseDate);
      }

      id =
          generateRandomID(
              "A",
              10); // could be a problem in the unlikely event you generate two arrests with the
                   // same id (this is used as an xml id)
      recordId = generateRandomID("", 3) + generateRandomID("-", 7);
      int chargeCount = generatePoissonInt(1, true);
      int courtCaseLength = (int) randomGenerator.nextGaussian(180, 60);
      int daysSinceArrest = Days.daysBetween(date, baseDate).getDays();
      arrestingAgency = new Agency();
      arrestingAgency.name = getRandomCity(person.state).toUpperCase() + " PD";

      if (courtCaseLength < daysSinceArrest) {
        dispoDate = date.plusDays(courtCaseLength);
      }

      int maxDaysInJail = 0;
      int maxDaysOfProbation = 0;
      felonyConviction = false;

      for (int i = 0; i < chargeCount; i++) {
        ArrestCharge arrestCharge = new ArrestCharge(person);
        charges.add(arrestCharge);
        if (arrestCharge.offense != null) {
          maxDaysInJail = Math.max(maxDaysInJail, arrestCharge.offense.daysInJail);
          maxDaysOfProbation = Math.max(maxDaysOfProbation, arrestCharge.offense.daysOfProbation);
          if ("F".equals(arrestCharge.severity.substring(0, 1))) {
            felonyConviction = true;
          }
          if (arrestCharge.offense.daysOfProbation > 0) {
            probationSupervisionAgency = arrestCharge.offense.supervisionAgency;
          }
          if (arrestCharge.offense.daysInJail > 0) {
            custodySupervisionAgency = arrestCharge.offense.supervisionAgency;
          }
        }
      }

      if (maxDaysInJail > 0 && dispoDate != null) {
        custodyEndDate = dispoDate.plusDays(maxDaysInJail);
        custodySupervisionId = id + "SC";
      }

      if (maxDaysOfProbation > 0 && dispoDate != null) {
        probationEndDate = dispoDate.plusDays(maxDaysOfProbation);
        probationSupervisionId = id + "SP";
      }

      if (coinFlip(.15)) {
        arrestingAgency.name = "State Police";
      }
    }
예제 #24
0
  private Map<String, String> updateResumeMixInfo(Integer perId, String updateTable) {
    PerUser perUser = perUserEao.get(perId);
    if (perUser != null) {
      PerResumeBo vo;
      try {
        vo = perResumeEao.getResumeVo(perUser.getResId());
      } catch (Exception ex) {
        vo = null;
      }

      if (vo != null) {

        int degree = 0;
        String schoolName = "";
        String speciality = "";
        if (vo.getEducationInfoVoList() != null) {
          for (PerResumeBo.EducationInfoVo eduVo : vo.getEducationInfoVoList()) {
            if (eduVo != null && eduVo.getDegree() != null && eduVo.getDegree() > degree) {
              degree = eduVo.getDegree();
              schoolName = eduVo.getSchoolName();
              speciality = eduVo.getSpeciality();
            }
          }
        }

        ComReceiveAssistBo craVo = new ComReceiveAssistBo();
        if (vo.getWorkInfoVoList() != null && CollectionUtils.size(vo.getWorkInfoVoList()) > 0) {
          PerResumeBo.WorkInfoVo workVo = vo.getWorkInfoVoList().get(0);
          craVo.setLastPosName(workVo.getJobName());
          //                        craVo.setLastJobLocation(workVo.get); //个人简历无此数据
          craVo.setComName(workVo.getComName());
          craVo.setStart(workVo.getBegin());
          craVo.setEnd(workVo.getEnd());
        }

        craVo.setJobyearType(perUser.getJobyearType());
        craVo.setMobile(perUser.getMobile());
        if (vo.getIntentInfoVo() != null) {
          craVo.setSkill(vo.getIntentInfoVo().getProfessionSkill());
        }
        //                    craVo.setFileName();
        //                    craVo.setFilePath();

        // 计算年龄的公式修改为精确到年与搜索引擎匹配
        DateTime bDate = new DateTime(perUser.getBirthday());
        bDate = bDate.monthOfYear().setCopy(1).dayOfMonth().setCopy(1);
        DateTime nDate = DateTime.now();
        nDate = nDate.monthOfYear().setCopy(1).dayOfMonth().setCopy(2);
        Integer age = Years.yearsBetween(bDate, nDate).getYears();

        if (perUser.getResId() != null
            && perUser.getResId() > 0
            && StringUtils.isNotBlank(perUser.getUserName())) {
          getJdbcTemplateAction()
              .update(
                  "update "
                      + updateTable
                      + " set "
                      + "resume_id = ? , "
                      + "user_name=? , "
                      + "gender = ? , "
                      +
                      //                        "job_location = ? , " +
                      //                        "location = ? , " +
                      "age = ? , "
                      + "degree = ? , "
                      + "mix_info = ? , "
                      + "school_name = ? , "
                      + "speciality = ?, "
                      + "jobyear_type = ? "
                      + "where per_user_id = ?",
                  perUser.getResId(),
                  perUser.getUserName(),
                  perUser.getGender(),
                  //                            vo.getIntentInfoVo().getJobLocation(),
                  //                            "",
                  (age < 16 || age > 65) ? 16 : age,
                  degree,
                  (new Gson()).toJson(craVo),
                  schoolName,
                  speciality,
                  perUser.getJobyearType(),
                  perUser.getId());
        }

        Map<String, String> map = Maps.newHashMap();
        map.put("resumeId", String.valueOf(perUser.getResId()));
        map.put("userName", perUser.getUserName());
        map.put("gender", String.valueOf(perUser.getGender()));
        map.put("age", String.valueOf((age < 16 || age > 65) ? 16 : age));
        map.put("degree", String.valueOf(degree));
        map.put("mixInfo", (new Gson()).toJson(craVo));
        map.put("schoolName", schoolName);
        map.put("speciality", speciality);
        map.put("schoolName", schoolName);
        map.put("jobyearType", String.valueOf(perUser.getJobyearType()));

        return map;
      }
    }
    return null;
  }