Esempio n. 1
0
 private String changeskins() {
   String skin = getParaValue("skin");
   CommonAppUtil.setSkin(skin);
   UserDao dao = new UserDao();
   User user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
   user.setSkins(skin);
   dao.update(user);
   return "/user.do?action=home";
 }
  /**
   * 设备事件统计:01 主机设备告警统计明细:02 网络设备告警统计明细:03 事件告警趋势分析(每小时):04 主机设备TOP趋势分析:05 网络设备TOP趋势分析:06 星期日:0
   * 星期一:1 星期二:2 星期三:3 星期四:4 星期五:5 星期六:6 时间:03 模板保存
   */
  public void savePerforIndexWeek() {
    String dataStr = "保存成功!";

    String startTime = request.getParameter("startdate"); // 开始时间
    SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    if (startTime == null) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      startTime = sdf.format(new Date()) + " 00:00:00";
    } else {
      startTime = startTime + " 00:00:00";
    }
    String toTime = request.getParameter("todate"); // 截至时间
    if (toTime == null) {
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      toTime = sdf.format(new Date()) + " 23:59:59";
    } else {
      toTime = toTime + " 23:59:59";
    }
    DBManager dbManager = new DBManager();

    // 报表中内容
    String reportname = this.getParaValue("report_name"); // 报表名称 reportName,
    String username = this.getParaValue("recievers_name"); // 邮件接收人 reportUserName,
    String tile = this.getParaValue("tile"); // 邮件标题  emailTitle,
    String desc = this.getParaValue("desc"); // 邮件描述  emailContent,
    String bidtext = this.getParaValue("bidtext"); // 所属业务  attachmentBusiness,
    String reporttype = this.getParaValue("reporttype"); // 周报表   reportType,
    String exporttype = request.getParameter("exporttype"); // 报表类型  ExpReportType,
    String ids = request.getParameter("ids"); // 选择的设备  ids,
    String eventCount = this.getParaValue("eventCount"); // 设备事件统计
    //			String hostAlarmCount = this.getParaValue("hostAlarmCount");//hostAlarmCount 主机设备告警统计明细
    //			String netAlarmCount = this.getParaValue("netAlarmCount");//netAlarmCount  网络设备告警统计明细
    String eventAnalyze = this.getParaValue("eventAnalyze"); // eventAnalyze  事件告警趋势分析
    String hostTopAnalyze = this.getParaValue("hostTopAnalyze"); // hostTopAnalyze  主机设备TOP趋势分析
    String netTopAnalyze = this.getParaValue("netTopAnalyze"); // netTopAnalyze  网络设备TOP趋势分析
    String transmitfrequency = this.getParaValue("transmitfrequency"); // 周 reportContentOption,
    String sendtimeweek = this.getParaValue("sendtimeweek"); // 星期几  sendWeek,
    String sendtimehou = request.getParameter("sendtimehou"); // 发生时间  sendTime,
    String startdate = this.getParaValue("mystartdate");
    String mytodate = this.getParaValue("mytodate");

    // 报表内容
    try {
      reportname = new String(reportname.getBytes("iso8859-1"), "UTF-8");
      username = new String(username.getBytes("iso8859-1"), "UTF-8");
      tile = new String(tile.getBytes("iso8859-1"), "UTF-8");
      desc = new String(desc.getBytes("iso8859-1"), "UTF-8");
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }

    String recieversId = this.getParaValue("recievers_id");
    UserDao userDao = new UserDao();
    List userList = new ArrayList();
    try {
      userList = userDao.findbyIDs(recieversId.substring(1));
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      userDao.close();
    }
    StringBuffer buf = new StringBuffer(); // 接收者邮件地址
    for (int i = 0; i < userList.size(); i++) {
      User vo = (User) userList.get(i);
      buf.append(vo.getEmail());
      buf.append(",");
    }
    Calendar tempCal = Calendar.getInstance();
    Date cc = tempCal.getTime();
    String time = sdFormat.format(cc);
    StringBuffer sql = new StringBuffer();
    // sql  attachmentBusiness
    sql.append(
        "insert into nms_compreReportWeek_resources"
            + "(reportName,reportUserName,emailTitle,emailContent,attachmentBusiness,"
            + "reportType,ExpReportType,ids,eventCount,"
            +
            //					"hostAlarmCount,netAlarmCount," +
            "eventAnalyze,hostTopAnalyze,netTopAnalyze,sendWeek,"
            + "sendOtherDay,sendTime,reportUserEmail) values('");
    sql.append(reportname + "','");
    sql.append(username + "','");
    sql.append(tile + "','");
    sql.append(desc + "','");
    sql.append(bidtext + "','");
    sql.append(reporttype + "','");
    sql.append(exporttype + "','");
    sql.append(ids + "','");
    sql.append(eventCount + "','");
    //			sql.append(hostAlarmCount+"','");
    //			sql.append(netAlarmCount+"','");
    sql.append(eventAnalyze + "','");
    sql.append(hostTopAnalyze + "','");
    sql.append(netTopAnalyze + "','");
    sql.append(transmitfrequency + "','");
    sql.append(sendtimeweek + "','");
    sql.append(sendtimehou + "','");
    //			sql.append(startdate+"','");
    //			sql.append(mytodate+"','");
    sql.append(buf.toString() + "')");
    try {
      dbManager.executeUpdate(sql.toString());
    } catch (Exception e) {
      e.printStackTrace();
      dataStr = "保存失败!!!";
    } finally {
      dbManager.close();
    }
    Map<String, String> map = new HashMap<String, String>();
    map.put("dataStr", dataStr);
    JSONObject json = JSONObject.fromObject(map);
    out.print(json);
    out.flush();
  }