Esempio n. 1
0
 /**
  * 列表信息页面
  *
  * @return
  */
 public String readyPage() {
   start_time = DateUtil.getPreNDay(-29);
   end_time = DateUtil.getCurrentDay();
   if (null != message) {
     addActionMessage(getText(message));
   }
   return SUCCESS;
 }
Esempio n. 2
0
  /** 从菜单进入页面 */
  public String readyPage() {
    // 设置默认查询条件
    searchVO.setBeginTime(DateUtil.getMonthFirstDay1());
    searchVO.setEndTime(DateUtil.getCurrentDay());
    searchVO.setCurr_date(DateUtil.getCurrentDay());

    return SUCCESS;
  }
Esempio n. 3
0
 /**
  * 转向记录页面
  *
  * @return
  */
 public String showRecordPage() {
   queryObj = new DriverStatInfo();
   queryObj.setBegTime(DateUtil.getPreNDay(-7));
   queryObj.setEndTime(DateUtil.getPreDay());
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
   Calendar cal = Calendar.getInstance();
   cal.add(Calendar.MONTH, -1);
   queryObj.setMonth(sdf.format(cal.getTime()));
   return SUCCESS;
 }
Esempio n. 4
0
 public static void main(String[] args) {
   // String src = "10/23/2007 15:20";
   // System.out.println(formatDateToString(parseStringToDate(src,
   // "MM/dd/yyyy HH:mm"),
   // "yyyyMMddHHmmss"));
   /*int i = getSeason();
   String test = getMonth();
   System.out.println(getCurrentMeridiem());
   String week = getPreNDay(-2);
   System.out.println(week);*/
   System.out.println(DateUtil.getCurrentDayNoSplit());
 }
Esempio n. 5
0
 /** 意见批量处理 */
 public void batchOperate() {
   // 用户信息
   UserInfo userInfo = getCurrentUser();
   HttpServletRequest request = getCurrentRequest();
   String ids = request.getParameter("ids");
   String desc = request.getParameter("desc");
   String type = request.getParameter("type");
   // 处理的告警参数
   AlarmEntity alarm = new AlarmEntity();
   alarm.setDeal_flag(Constants.ALARM_E_CODE); // 已处理
   alarm.setUser_id(userInfo.getUserID());
   alarm.setConfirm_time(DateUtil.formatDateToString(new Date(), "yyyy-MM-dd HH:mm:ss"));
   alarm.setIds(formatString(ids));
   alarm.setOpeerate_desc(desc);
   alarm.setOperate_type(type);
   try {
     this.service.update("VehicleCheckManage.updateAlarm", alarm);
   } catch (BusinessException e) {
     this.log.error("意见批量处理出错", e);
     this.printWriter("处理失败!");
   }
   this.printWriter("处理成功!");
 }
Esempio n. 6
0
  /** 导出 */
  public String exportList(String title, String sheetName, List<AlarmEntity> exportList) {
    String filePath = "";
    OutputStream outputStream = null;
    try {

      filePath = "/tmp/" + UUIDGenerator.getUUID() + sheetName + ".xls";

      File file = new File(filePath);
      if (!file.getParentFile().exists()) {
        file.getParentFile().mkdirs();
      }
      outputStream = new FileOutputStream(filePath);
      // 使用Excel导出器IEExcelExporter
      IEExcelExporter excelExporter = new IEExcelExporter(outputStream);
      excelExporter.setTitle(
          title + "(" + searchVO.getBeginTime() + "~" + searchVO.getEndTime() + ")");

      excelExporter.putAutoExtendSheets(sheetName, 0, exportList);
      // 将Excel写入到指定的流中
      excelExporter.write();
    } catch (FileNotFoundException e) {
      log.error("Export error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      log.error("Export error:" + e.getMessage());
      return ERROR;
    } finally {
      // 关闭流
      if (null != outputStream) {
        try {
          outputStream.close();
        } catch (IOException e) {;
        }
      }
    }
    // 设置下载文件属性
    FileInputStream fileInputStream = null;
    OutputStream out = null;
    try {
      // 设置下载文件属性
      String fileName = URLEncoder.encode(title, "UTF8");
      HttpServletResponse response = ServletActionContext.getResponse();
      response.setHeader(
          "Content-disposition",
          "attachment;filename="
              + fileName
              + "-"
              + DateUtil.formatDateToString(new Date(), "yyyyMMddHHmmss")
              + ".xls");
      response.setContentType("application/msexcel; charset=\"utf-8\"");

      // 下载刚生成的文件
      fileInputStream = new FileInputStream(filePath);
      out = response.getOutputStream();
      int i = 0;
      while ((i = fileInputStream.read()) != -1) {
        out.write(i);
      }
    } catch (FileNotFoundException e) {
      log.error("Export error:" + e.getMessage());
      return ERROR;
    } catch (Exception e) {
      log.error("Export error:" + e.getMessage());
      return ERROR;
    } finally {
      // 关闭流
      if (null != fileInputStream) {
        try {
          fileInputStream.close();
        } catch (IOException e) {;
        }
      }
      if (null != out) {
        try {
          out.close();
        } catch (IOException e) {;
        }
      }
    }
    return null;
  }
Esempio n. 7
0
 /**
  * 按记录导出
  *
  * @return
  */
 public String exportRecord() {
   String exportTitle = "驾驶员刷卡记录";
   List<DriverStatInfo> list = new ArrayList<DriverStatInfo>();
   try {
     if ("1".equals(exportObj.getSearchTimeType())) { // 按时段查询
       String start_time = exportObj.getBegTime();
       String end_time = exportObj.getEndTime();
       exportObj.setBegTime(start_time + " 00:00:00");
       exportObj.setEndTime(end_time + " 23:59:59");
     } else {
       String month = exportObj.getMonth();
       String first = month + "-01";
       Calendar cal = Calendar.getInstance();
       cal.set(Calendar.YEAR, Integer.parseInt(month.substring(0, 4)));
       cal.set(Calendar.MONTH, Integer.parseInt(month.substring(5, 7)));
       cal.set(Calendar.DAY_OF_MONTH, 1);
       cal.add(Calendar.DAY_OF_MONTH, -1);
       exportObj.setBegTime(first + " 00:00:00");
       System.out.println(cal.get(Calendar.DAY_OF_MONTH));
       exportObj.setEndTime(month + "-" + cal.get(Calendar.DAY_OF_MONTH) + " 23:59:59");
     }
     String driverIds = exportObj.getDriverId();
     String searchIds = "";
     if (driverIds.length() > 0) {
       String[] Ids = driverIds.split(","); // 字符串转字符数组
       for (String id : Ids) {
         searchIds = searchIds + "'" + id + "',";
       }
       exportObj.setDriverId(searchIds.substring(0, searchIds.length() - 1));
     }
     UserInfo user =
         (UserInfo) ActionContext.getContext().getSession().get(Constants.USER_SESSION_KEY);
     exportObj.setEnterpriseId(user.getOrganizationID());
     if ("1".equals(exportObj.getState())) exportObj.setState("UP");
     else if ("2".equals(exportObj.getState())) exportObj.setState("DOWN");
     list =
         (List<DriverStatInfo>) service.getObjects("Drivershuaka.getDriverRecordList", exportObj);
   } catch (BusinessException e) {
     setMessage("info.db.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     e.printStackTrace();
     setMessage("info.db.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   }
   String filePath = "";
   OutputStream outputStream = null;
   try {
     filePath = "/tmp/" + UUIDGenerator.getUUID() + "DriverShuaka.xls";
     File file = new File(filePath);
     if (!file.getParentFile().exists()) {
       file.getParentFile().mkdirs();
     }
     outputStream = new FileOutputStream(filePath);
     IEExcelExporter excelExporter = new IEExcelExporter(outputStream);
     if ("1".equals(exportObj.getSearchTimeType())) // 按时段查询
     excelExporter.setTitle(
           exportTitle
               + "("
               + exportObj.getBegTime().substring(0, 10)
               + "——"
               + exportObj.getEndTime().substring(0, 10)
               + ")");
     else excelExporter.setTitle(exportTitle + "(" + exportObj.getMonth() + ")");
     if (null == list || list.size() < 1) {
       list.add(new DriverStatInfo());
     }
     excelExporter.putAutoExtendSheets("exportDriverShuaka", 0, list);
     // 将Excel写入到指定的流中
     excelExporter.write();
   } catch (FileNotFoundException e) {
     setMessage("file.export.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     setMessage("file.export.error");
     log.error(exportTitle + "Export Data error:" + e.getMessage());
     return ERROR;
   } finally {
     // 关闭流
     if (null != outputStream) {
       try {
         outputStream.close();
       } catch (IOException e) {;
       }
     }
   }
   // 设置下载文件属性
   HttpServletResponse response = ServletActionContext.getResponse();
   response.setHeader(
       "Content-disposition",
       "attachment;filename=driver_shuaka_info-" + DateUtil.getCurrentDayTime() + ".xls");
   response.setContentType("application/msexcel; charset=\"utf-8\"");
   FileInputStream fileInputStream = null;
   OutputStream out = null;
   try {
     // 下载刚生成的文件
     fileInputStream = new FileInputStream(filePath);
     out = response.getOutputStream();
     int i = 0;
     while ((i = fileInputStream.read()) != -1) {
       out.write(i);
     }
   } catch (FileNotFoundException e) {
     setMessage("file.export.error");
     log.error("Export student error:" + e.getMessage());
     return ERROR;
   } catch (Exception e) {
     setMessage("file.export.error");
     log.error("Export student error:" + e.getMessage());
     return null;
   } finally {
     // 关闭流
     if (null != fileInputStream) {
       try {
         fileInputStream.close();
       } catch (IOException e) {;
       }
     }
     if (null != out) {
       try {
         out.close();
       } catch (IOException e) {;
       }
     }
   }
   // 导出文件成功
   return null;
 }