@Override
 public long getCountFunctionBilled(Long spId, String start, String end) {
   StringBuilder sql = new StringBuilder();
   sql.append("select count(distinct fs.card_no) from fee_stat fs")
       .append(" where fs.sp_id=")
       .append(spId)
       .append(" and fs.fee_type=")
       .append(FeeStat.TYPE_FUNCTION)
       .append(" and fs.operate_time>=TO_DATE('")
       .append(start)
       .append("','yyyymmdd')")
       .append(" and fs.operate_time<=TO_DATE('")
       .append(end)
       .append("','yyyymmdd')");
   Session s = null;
   BigDecimal result = null;
   try {
     s = super.sessionFactory.openSession();
     result = (BigDecimal) s.createSQLQuery(sql.toString()).uniqueResult();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       s.close();
     } catch (PlatformException he) {
       he.printStackTrace();
     }
   }
   return result.longValue();
 }
 @RequestMapping
 public @ResponseBody JsonResult findDesiredOperationByCustomer(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     Page<DesiredOperation> page = SpringMVCUtils.getPage(request);
     String executionStatus = ServletRequestUtils.getStringParameter(request, "executionStatus");
     String cardNo = request.getParameter("cardNo");
     String userName = SpringSecurityUtils.getCurrentUserName();
     if (StringUtils.isBlank(userName)) {
       CustomerCardInfo customerCardInfo = customerCardInfoManager.getByCardNo(cardNo);
       SysUser user = customerCardInfo.getCustomer().getSysUser();
       userName = user.getUserName();
     }
     page = desiredOperationManager.findPageByCustomerParam(page, userName, executionStatus);
     List<DesiredOperation> requistionList = page.getResult();
     List<Map<String, Object>> mappedDesiredOperation =
         desiredOperationResult(requistionList, executionStatus);
     Page<Map<String, Object>> pageMap = page.getMappedPage();
     pageMap.setResult(mappedDesiredOperation);
     result.setTotalPage(page.getTotalPages());
     result.setTotalCount(page.getTotalCount());
     result.setPage(pageMap);
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
 /**
  * @param request
  * @return
  */
 @RequestMapping
 public @ResponseBody JsonResult index(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     Page<LocalTransaction> page = SpringMVCUtils.getPage(request);
     page.addOrder("beginTime", "desc");
     List<PropertyFilter> filters = SpringMVCUtils.getParameters(request);
     filters.add(new PropertyFilter("ALIAS_superTransactionL_NULLI_id", "0"));
     filters.add(new PropertyFilter("ALIAS_taskI_NOTNULLL_id", "0"));
     page = localTransactionManager.findPage(page, filters);
     // page =
     // localTransactionManager.findPage(page,ServletRequestUtils.getStringParameter(request,
     // "search_LIKES_mobileNo"),
     // ServletRequestUtils.getLongParameter(request,
     // "search_EQL_id",-1));
     List<LocalTransaction> requistionList = page.getResult();
     List<Map<String, Object>> mappedLocalTransactions = localTransactionResult(requistionList);
     Page<Map<String, Object>> pageMap = page.getMappedPage();
     pageMap.setResult(mappedLocalTransactions);
     result.setPage(pageMap);
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
 @RequestMapping
 public @ResponseBody JsonResult findDesiredOperationByUser(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     Page<DesiredOperation> page = SpringMVCUtils.getPage(request);
     Map<String, String> paramMap = new HashMap<String, String>();
     String executionStatus = ServletRequestUtils.getStringParameter(request, "executionStatus");
     String resultStr = ServletRequestUtils.getStringParameter(request, "result");
     paramMap.put("result", resultStr);
     paramMap.put("executionStatus", executionStatus);
     String currentUserName = SpringSecurityUtils.getCurrentUserName();
     paramMap.put("currentUserName", currentUserName);
     page = desiredOperationManager.findPageByParam(page, paramMap);
     List<DesiredOperation> requistionList = page.getResult();
     List<Map<String, Object>> mappedDesiredOperation =
         desiredOperationResult(requistionList, executionStatus);
     Page<Map<String, Object>> pageMap = page.getMappedPage();
     pageMap.setResult(mappedDesiredOperation);
     result.setPage(pageMap);
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
  @SuppressWarnings("unchecked")
  @Override
  public List<FeeStat> getFunctionBilled(Long spId, String start, String end) {
    StringBuilder sql = new StringBuilder();
    sql.append("select distinct fs.card_no as cardNo,fs.mobile_no as mobileNo,");
    sql.append("fs.sp_id as spId,fs.sp_name as spName");
    sql.append(" from fee_stat fs");
    sql.append(" where fs.sp_id=")
        .append(spId)
        .append(" and fs.fee_type=")
        .append(FeeStat.TYPE_FUNCTION)
        .append(" and fs.operate_time>=TO_DATE('")
        .append(start)
        .append("','yyyymmdd')")
        .append(" and fs.operate_time<=TO_DATE('")
        .append(end)
        .append("','yyyymmdd')");
    System.out.println("sql==" + sql.toString());
    Session s = null;
    List<Object[]> result = null;
    List<FeeStat> fsList = new ArrayList<FeeStat>();
    FeeStat fs = null;
    try {
      s = super.sessionFactory.openSession();
      result = s.createSQLQuery(sql.toString()).list();
      System.out.println("result.size()==" + result.size());
      for (Object[] o : result) {
        fs = new FeeStat();
        fs.setCardNo((String) o[0]);
        fs.setMobileNo((String) o[1]);
        fs.setSpId(((BigDecimal) o[2]).longValue());
        fs.setSpName((String) o[3]);
        fsList.add(fs);
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        s.close();
      } catch (PlatformException he) {
        he.printStackTrace();
      }
    }
    return fsList;
  }
 @RequestMapping
 public @ResponseBody JsonResult execute(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     String ids = ServletRequestUtils.getStringParameter(request, "ids");
     localTransactionManager.changeStatus(ids, "1");
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
 @RequestMapping
 public @ResponseBody JsonResult cancel(HttpServletRequest request) {
   JsonResult result = new JsonResult();
   try {
     String id = ServletRequestUtils.getStringParameter(request, "id");
     desiredOperationManager.remove(Long.parseLong(id));
   } catch (PlatformException e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     result.setSuccess(Boolean.FALSE);
     result.setMessage(e.getMessage());
   }
   return result;
 }
 @RequestMapping
 public @ResponseBody JsonMessage get(@RequestParam("id") Long id) {
   JsonMessage message = new JsonMessage();
   try {
     LocalTransaction lt = localTransactionManager.load(id);
     Map<String, Object> map = lt.toMap(null, null);
     message.setMessage(map);
   } catch (PlatformException e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   }
   return message;
 }
 @RequestMapping
 public @ResponseBody JsonMessage checkCardOptFinish(HttpServletRequest request) {
   JsonMessage message = new JsonMessage();
   try {
     String sessionId = ServletRequestUtils.getStringParameter(request, "sessionId");
     boolean flag = localTransactionManager.checkCardOptFinish(sessionId);
     if (!flag) {
       message.setSuccess(flag);
     }
   } catch (PlatformException e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   }
   return message;
 }