@Transactional
 public PageResult markBabysitterId(
     String babysitterId, String serviceOrderId, PageResult result) {
   long babysitterIdl = Long.valueOf(babysitterId);
   long serviceOrderIdl = Long.valueOf(serviceOrderId);
   Babysitter babysitter = dao.getResultById(Babysitter.class, babysitterIdl);
   ServiceOrder serviceOrder = dao.getResultById(ServiceOrder.class, serviceOrderIdl);
   updateBabysitterOrder(serviceOrder.getGuid(), babysitter, serviceOrder);
   result.setResult(ResultInfo.SUCCESS);
   result.put("result", babysitter.view());
   return result;
 }
  @Transactional
  public void addServiceOrderPanic(String babysitterId, String serviceOrderId) {
    long babysitterIdl = Long.valueOf(babysitterId);
    long serviceOrderIdl = Long.valueOf(serviceOrderId);

    Babysitter babysitter = dao.getResultById(Babysitter.class, babysitterIdl);
    ServiceOrder order = dao.getResultById(ServiceOrder.class, serviceOrderIdl);
    if (order != null) {

      PanicBuyingOrder buyingOrder = PanicBuyingOrder.getInstance();
      buyingOrder.setBabysitter(babysitter);
      buyingOrder.setServiceOrder(order);
      dao.add(buyingOrder);
    }
  }
 @Transactional
 public ResultInfo manageEditOrder(
     String id, String employerAddress, String price, String beginDate, String endDate) {
   try {
     long idl = Long.valueOf(id);
     ServiceOrder order = dao.getResultById(ServiceOrder.class, idl);
     if (order == null) return ResultInfo.SERVICE_ORDER_NULL;
     // String hql =
     // "from Employer e where e.ovld = true and e.mobilePhone = ?";
     // Employer employer = dao.getSingleResultByHQL(Employer.class, hql,
     // employerTelephone);
     // if (employer == null)
     // return ResultInfo.EMPLOYER_NULL;
     // if (!StringUtils.isEmpty(employerName))
     // employer.setUsername(employerName);
     // if (!StringUtils.isEmpty(employerTelephone))
     // employer.setMobilePhone(employerTelephone);
     if (!StringUtils.isEmpty(employerAddress)) order.setAddress(employerAddress);
     if (!StringUtils.isEmpty(price)) order.setOrderPrice(Long.parseLong(price));
     if (!StringUtils.isEmpty(beginDate))
       order.setServiceBeginDate(ExpectedDateCreate.parseDate(beginDate));
     if (!StringUtils.isEmpty(endDate))
       order.setServiceEndDate(ExpectedDateCreate.parseDate(endDate));
     // order.setEmployer(employer);
     order.setUpdateDate(new Date());
     dao.update(order);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return ResultInfo.SUCCESS;
 }
 @Transactional
 public void updateRole(Role role) {
   Role editRole = dao.getResultById(Role.class, role.getId());
   editRole.setName(role.getName());
   editRole.setUpdateDate(new Date());
   dao.update(editRole);
 }
 @Transactional
 public void deleteOrder(String ids) {
   String idArr[] = ids.split(",");
   for (String id : idArr) {
     long idl = Long.valueOf(id);
     ServiceOrder order = dao.getResultById(ServiceOrder.class, idl);
     order.setOvld(false);
     dao.update(order);
   }
 }
 @Transactional
 public void grant(long id, long[] resourceTreeIds) {
   Role role = dao.getResultById(Role.class, id);
   Set<Long> menuIds = new HashSet<Long>();
   for (Long menuId : resourceTreeIds) {
     menuIds.add(menuId);
   }
   // List<Menu> menus = role.getMenus();
   // for (Menu menu : menus) {
   // menuIds.add(menu.getId());
   // }
   List<Menu> roleMenus = new ArrayList<Menu>();
   for (Iterator<Long> mid = menuIds.iterator(); mid.hasNext(); ) {
     Menu m = new Menu();
     m.setId(mid.next());
     roleMenus.add(m);
   }
   role.setMenus(roleMenus);
   dao.update(role);
 }
 @Transactional
 public void addServiceOrderAdvice(String id) {
   long idl = Long.valueOf(id);
   ServiceOrder order = dao.getResultById(ServiceOrder.class, idl);
   // 更新所有通知为已通知
   String hql = "from PanicBuyingBabysitterAdvice t where t.ovld = true and t.serviceOrder.id = ?";
   List<PanicBuyingBabysitterAdvice> advices =
       dao.getListResultByHQL(PanicBuyingBabysitterAdvice.class, hql, order.getId());
   for (PanicBuyingBabysitterAdvice advice : advices) {
     advice.setIsAdvice(true);
     dao.update(advice);
   }
   Map<String, Date> dateMap = new HashMap<String, Date>();
   dateMap.put(ExpectedDateCreate.BEGIN_DATE, order.getServiceBeginDate());
   dateMap.put(ExpectedDateCreate.END_DATE, order.getServiceEndDate());
   // 重新加入月嫂通知
   addBabysitterAdvice(order.getCounty().getGuid(), order, dateMap);
   // 更新雇主订单没有完成抢单
   order.setOver(true);
   dao.update(order);
 }
 public ServiceOrder getOrder(String id) {
   return dao.getResultById(ServiceOrder.class, Long.parseLong(id));
 }
 public Role getRole(long id) {
   return dao.getResultById(Role.class, id);
 }