use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class FileDownLoadController method downloadZip.
/**
* word打包文件
*
* @param id
* 生成的唯一标识符
* @param response
* 服务响应
* @throws UnsupportedEncodingException
*/
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "word打包文件")
@RequestMapping(value = "/zip/download", method = RequestMethod.GET)
public void downloadZip(@RequestParam("id") String id, HttpServletRequest request, HttpServletResponse response) {
String src = this.getClass().getResource("/").getPath();
src = src.substring(1);
if (!src.endsWith(File.separator)) {
src += File.separator;
}
String materialName = Const.WORD_EXPORT_MAP.get(id).getMaterialName();
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
String filePath = src + id + File.separator + materialName + ".zip";
String fileName = returnFileName(request, materialName + ".zip");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
OutputStream fos = null;
InputStream fis = null;
try {
fis = new FileInputStream(filePath);
bis = new BufferedInputStream(fis);
fos = response.getOutputStream();
bos = new BufferedOutputStream(fos);
int byteRead = 0;
byte[] buffer = new byte[1024];
while ((byteRead = bis.read(buffer, 0, 1024)) != -1) {
bos.write(buffer, 0, byteRead);
}
bos.flush();
fis.close();
bis.close();
fos.close();
bos.close();
} catch (Exception e) {
e.printStackTrace();
logger.warn("文件下载时出现IO异常:{}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
} finally {
Const.WORD_EXPORT_MAP.remove(id);
ZipDownload.DeleteFolder(src + id);
}
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class FileDownLoadController method exportOrgInfo.
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "导出机构用户对比后的信息")
@RequestMapping(value = "/org/exportOrgInfo", method = RequestMethod.GET)
public void exportOrgInfo(HttpServletRequest request, HttpServletResponse response, String uuid) {
if (StringUtil.isEmpty(uuid)) {
throw new CheckedServiceException(CheckedExceptionBusiness.EXCEL, CheckedExceptionResult.NULL_PARAM, "参数不能为空");
}
String sessionId = CookiesUtil.getSessionId(request);
HttpSession session = SessionContext.getSession(sessionId);
List<OrgVO> list = (List<OrgVO>) session.getAttribute(uuid);
if (null == list || list.isEmpty()) {
throw new CheckedServiceException(CheckedExceptionBusiness.ORG, CheckedExceptionResult.NULL_PARAM, "导出的机构信息不能为空");
}
Workbook workbook = null;
try {
workbook = excelHelper.fromOrgVO(list, "机构用户信息");
} catch (CheckedServiceException | IllegalAccessException | IllegalArgumentException e) {
logger.warn("数据表格化的时候失败");
}
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
String fileName = returnFileName(request, "机构用户信息" + ".xls");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (IOException e) {
logger.warn("文件下载时出现IO异常: {}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class FileDownLoadController method declarationWord.
/**
* 功能描述:申报表批量导出word
*
* @param ids
* 申报表ids
* @param response
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报表批量导出word")
@RequestMapping(value = "/front/word/declaration", method = RequestMethod.GET)
public String declarationWord(String selectedIds) {
List<Long> decIds = new ArrayList<>();
String[] decId = selectedIds.split(",");
for (int i = 0; i < decId.length; i++) {
decIds.add(Long.valueOf(decId[i]));
}
String id = String.valueOf(System.currentTimeMillis()).concat(String.valueOf(RandomUtil.getRandomNum()));
taskExecutor.execute(new Front(logger, zipHelper, wordHelper, materialService, textbookService, declarationService, materialExtensionService, decIds, id));
return '"' + id + '"';
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class FileDownLoadController method exportSituationBook.
/**
* Description:申报情况统计页面按书名统计导出统计结果
*
* @author:lyc
* @date:2018年1月9日上午11:41:10
* @param
* @return void
*/
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报情况统计页面按书名统计导出统计结果")
@RequestMapping(value = "/result/exportSituationBook", method = RequestMethod.GET)
public void exportSituationBook(Long materialId, String bookName, HttpServletRequest request, HttpServletResponse response) {
PageParameter<DeclarationSituationBookResultVO> pageParameter = new PageParameter<>(1, 50000);
DeclarationSituationBookResultVO declarationSituationBookResultVO = new DeclarationSituationBookResultVO();
declarationSituationBookResultVO.setMaterialId(materialId);
declarationSituationBookResultVO.setBookName(bookName);
pageParameter.setParameter(declarationSituationBookResultVO);
Workbook workbook = null;
List<DeclarationSituationBookResultVO> list = null;
list = decPositionService.listDeclarationSituationBookResultVOs(pageParameter).getRows();
if (list.size() == 0) {
list.add(new DeclarationSituationBookResultVO());
}
try {
workbook = excelHelper.fromBusinessObjectList(list, "申报情况按书名统计");
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException e) {
logger.warn("数据表格化的时候失败");
}
Material material = materialService.getMaterialById(materialId);
String fileName = returnFileName(request, material.getMaterialName() + ".xls");
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (Exception e) {
logger.warn("文件下载时出现IO异常: {}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.annotation.LogDetail in project pmph by BCSquad.
the class BookController method list.
/**
* 功能描述:初始化/条件查询书籍信息
*
* @param pageSize
* 当页条数
* @param pageNumber
* 当前页数
* @param type
* 书籍类别
* @param name
* 书籍名称/ISBN
* @param isOnSale
* 是否上架
* @param isNew
* 是否新书
* @param isPromote
* 是否推荐
* @param path
* 书籍类别根路径
* @return
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "初始化/条件查询书籍信息")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseBean list(Integer pageSize, Integer pageNumber, Long type, String name, Boolean isOnSale, Boolean isNew, Boolean isPromote, String path) {
PageParameter<BookVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
BookVO bookVO = new BookVO();
bookVO.setName(name);
bookVO.setIsNew(isNew);
bookVO.setPath(path);
bookVO.setType(type);
bookVO.setIsOnSale(isOnSale);
bookVO.setIsPromote(isPromote);
pageParameter.setParameter(bookVO);
return new ResponseBean(bookService.listBookVO(pageParameter));
}
Aggregations