示例#1
0
 /**
  * 统计 by 客户 2013-05-27 修改为不分页形式
  *
  * @return
  */
 @Action("statQdtgRecordByCvs")
 public String statQdtgRecordByCvs() {
   try {
     Long userId = LoginUserUtils.getLoginUserInfo().getId();
     if (userId != null) {
       if (statCondition.getStatType() == SysConfig.QDTG_STAT_DAY) {
         statRecords =
             qdtgRecordModel.statQdtgRecordByCvsByDay(userId, statCondition, start, limit);
         //					if(total==null){
         //						total=qdtgRecordModel.statQdtgRecordByCvsByDayCount(userId,statCondition);
         //					}
       } else {
         statRecords = qdtgRecordModel.statQdtgRecordByCvsByMonth(userId, statCondition);
         //					if(total==null){
         //						total=(long)statRecords.size();
         //					}
       }
       statCondition = null;
     }
   } catch (Exception e) {
     setErrorMessage(e);
     log.error(e.getMessage(), e);
   }
   return JSON;
 }
示例#2
0
 /**
  * 统计 2013-05-27 修改为不分页形式
  *
  * @return
  */
 @Action("statQdtgRecord")
 public String statQdtgRecord() {
   try {
     if (statCondition.getStatType() == SysConfig.QDTG_STAT_DAY) {
       statRecords = qdtgRecordModel.statQdtgRecordByDay(statCondition, start, limit);
       //				if(total==null){
       //					total=qdtgRecordModel.statQdtgRecordByDayCount(statCondition);
       //				}
     } else {
       statRecords = qdtgRecordModel.statQdtgRecordByMonth(statCondition);
       //				if(total==null){
       //					total=(long)statRecords.size();
       //				}
     }
     statCondition = null;
   } catch (Exception e) {
     setErrorMessage(e);
     log.error(e.getMessage(), e);
   }
   return JSON;
 }
示例#3
0
 @Action(
     value = "exportQdtgXLS",
     results = {
       @Result(
           name = "xls",
           type = "stream",
           params = {
             "contentType",
             "application/octet-stream;charset=ISO8859-1",
             "inputName",
             "inputStream",
             "contentDisposition",
             "attachment;filename=\"${downloadFileName}\"",
             "bufferSize",
             "4096"
           })
     })
 public String exportQdtgXLS() {
   String title = "";
   HttpServletResponse response = ServletActionContext.getResponse();
   ByteArrayOutputStream buffer = new ByteArrayOutputStream();
   try {
     if (statCondition.getStatType() == SysConfig.QDTG_STAT_DAY) {
       title = "对帐单-按日";
       statRecords = qdtgRecordModel.statQdtgRecordByDay(statCondition, start, limit);
     } else {
       title = "对帐单-按月";
       statRecords = qdtgRecordModel.statQdtgRecordByMonth(statCondition);
     }
     setDownloadFileName(title);
     JasperReportBuilder report = DynamicReports.report(); // 创建空报表
     JasperXlsExporterBuilder xlsExporter =
         DynamicReports.export
             .xlsExporter(buffer)
             .setDetectCellType(true)
             .setIgnorePageMargins(true)
             .setWhitePageBackground(false)
             .setRemoveEmptySpaceBetweenColumns(true);
     report
         .setColumnTitleStyle(ReportConfig.getColumnTitleStl())
         .addProperty(JasperProperty.EXPORT_XLS_FREEZE_ROW, "2")
         .ignorePageWidth()
         .ignorePagination()
         .columns(
             Columns.column("日期", "recordTime", DataTypes.stringType()),
             Columns.column("产品", "productName", DataTypes.stringType()),
             Columns.column("渠道号", "channelNo", DataTypes.stringType()),
             Columns.column("文件名", "fileName", DataTypes.stringType()),
             Columns.column("单价", "unitPrice", DataTypes.floatType()),
             Columns.column(
                 "激活",
                 "activateQt_Net",
                 statCondition.getStatType() == SysConfig.QDTG_STAT_DAY
                     ? DataTypes.integerType()
                     : DataTypes.longType()),
             Columns.column(
                 "小计",
                 "totalPrice_Net",
                 statCondition.getStatType() == SysConfig.QDTG_STAT_DAY
                     ? DataTypes.floatType()
                     : DataTypes.doubleType()))
         .title(Components.text(title).setStyle(ReportConfig.getTitleStl())); // 标题
     if (statRecords == null || statRecords.size() <= 0) {
       report.setDataSource(new JREmptyDataSource());
     } else {
       report.setDataSource(statRecords); // 数据源
     }
     report.toXls(xlsExporter);
     byte[] bytes = buffer.toByteArray();
     response.setContentLength(bytes.length);
     if (bytes != null) {
       inputStream = new ByteArrayInputStream(bytes);
     }
     return "xls";
   } catch (Exception e) {
     setErrorMessage(e);
     log.error(e.getMessage(), e);
     statRecords = null;
     return JSON;
   } finally {
     try {
       buffer.close();
       if (inputStream != null) inputStream.close();
     } catch (Exception e) {
       log.error(e.getMessage(), e);
     }
   }
 }