Пример #1
0
  public static void main(String[] args) {
    //		String title = createTableLine("代理人","来源","开始日期","结束日期","订单量");
    String s = MessageUtil.createTableLine("jubang", "platform", "2015-07", "2015-08", "10");
    System.out.println(s);

    InitProxy init = new InitProxy();
    init.initAll();
    PriceNumRq rq = new PriceNumRq();
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    map.put("platform", null);
    rq.setAgent_resource(map);
    rq.setEndTime("2015-09-21 23:59:59");
    rq.setTimeType(1);
    PriceFailHandler pfh = new PriceFailHandler();
    pfh.handlerRq(rq);
  }
Пример #2
0
  @Override
  public MessageRs handlerRq(PriceNumRq rq) {
    MessageRs rs = new MessageRs();
    final String type = AlarmTypeConstant.priceFail;
    try {
      if (!VerifyUtil.verifyRqParas(rq)) { // rq校验
        Loggers.ExceptionLog.error("核价失败监控RQ为空");
        rs.setCode(ResultMapper.REQ_PARAMS_ERROR);
        rs.setDescribe(ResultMapper.getMsg(ResultMapper.REQ_PARAMS_ERROR));
        return rs;
      }
      StringBuffer resultMsg = new StringBuffer();
      MsgCache msgCache = new MsgCache();
      long intervalTime = WarningService.getIntervalTimeMillis(rq.getTimeType());
      long eTime = ObjectUtil.parseTimeMillis(rq.getEndTime());
      Timestamp eTs = new Timestamp(eTime);
      Timestamp bTs = new Timestamp(eTime - intervalTime);

      List<Record> failList = PriceDao.dao.getPriceFail(rq.getAgent_resource().keySet(), bTs, eTs);
      if (ObjectUtil.isEmpty(failList)) {
        Loggers.BusinessLog.info("数据库返回为空");
      } else {
        for (Record record : failList) {
          double failRate = record.getBigDecimal("pricefail").doubleValue();
          String agentId = record.getStr("agentId");
          int value_level = WarningService.getLevel(agentId, type, rq.getTimeType(), failRate);
          ValueHandler.handleValue(
              type, failRate, "ALL", value_level, agentId, bTs, eTs, msgCache, resultMsg, rq, rs);
        }
      }
      /** 发送信息 */
      String msgHead =
          MessageUtil.createTableLine("代理人", "报警等级", "统计开始时间", "统计结束时间", "渠道", "类型", "值", "正常范围");
      msgCache.sendMsg("核价失败报警", msgHead);
      rs.setCode(ResultMapper.SUCCEED);
      if (resultMsg.length() > 0) {
        rs.setDescribe(resultMsg.toString());
      }

    } catch (Exception e) {
      rs.setCode(ResultMapper.SYSTEM_IS_BUSY);
      Loggers.ExceptionLog.error("核价失败监控服务异常", e);
      rs.setDescribe(ResultMapper.getMsg(ResultMapper.SYSTEM_IS_BUSY));
    }
    return rs;
  }