Search in sources :

Example 1 with DeclarationResultBookVO

use of com.bc.pmpheep.back.vo.DeclarationResultBookVO in project pmph by BCSquad.

the class DecPositionServiceImpl method listDeclarationResultBookVOs.

@Override
public PageResult<DeclarationResultBookVO> listDeclarationResultBookVOs(PageParameter<DeclarationResultBookVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String bookName = pageParameter.getParameter().getBookName();
    if (StringUtil.notEmpty(bookName)) {
        pageParameter.getParameter().setBookName(bookName);
    }
    PageResult<DeclarationResultBookVO> pageResult = new PageResult<DeclarationResultBookVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getBooks(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        List<DeclarationResultBookVO> books = decPositionDao.getBookListTwo(pageParameter);
        List<DeclarationResultBookVO> VOs = decPositionDao.getBookChosenList(pageParameter);
        List<DeclarationResultBookVO> list = new ArrayList<>();
        if (null == VOs || VOs.isEmpty()) {
            pageResult.setRows(books);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationResultBookVO book : books) {
            for (DeclarationResultBookVO vo : VOs) {
                if (vo.getId().equals(book.getId())) {
                    book.setEditorList(vo.getEditorList());
                    book.setSubEditorList(vo.getSubEditorList());
                    book.setEditorialList(vo.getEditorialList());
                    book.setIsDigitalEditorList(vo.getIsDigitalEditorList());
                    if (StringUtil.isEmpty(book.getEditorList())) {
                        book.setEditorList("-");
                    }
                    if (StringUtil.isEmpty(book.getSubEditorList())) {
                        book.setSubEditorList("-");
                    }
                    if (StringUtil.isEmpty(book.getEditorialList())) {
                        book.setEditorialList("-");
                    }
                    if (StringUtil.isEmpty(book.getIsDigitalEditorList())) {
                        book.setIsDigitalEditorList("-");
                    }
                    break;
                }
            }
            list.add(book);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DeclarationResultBookVO(com.bc.pmpheep.back.vo.DeclarationResultBookVO) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 2 with DeclarationResultBookVO

use of com.bc.pmpheep.back.vo.DeclarationResultBookVO in project pmph by BCSquad.

the class FileDownLoadController method exportResultBook.

/**
 * Description:申报结果统计页面按书名统计导出统计结果
 *
 * @author:lyc
 * @date:2018年1月9日下午2:42:26
 * @param
 * @return void
 */
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报结果统计页面按书名统计导出统计结果")
@RequestMapping(value = "/result/exportResultBook", method = RequestMethod.GET)
public void exportResultBook(Long materialId, String bookName, HttpServletRequest request, HttpServletResponse response) {
    PageParameter<DeclarationResultBookVO> pageParameter = new PageParameter<>(1, 50000);
    DeclarationResultBookVO declarationResultBookVO = new DeclarationResultBookVO();
    declarationResultBookVO.setMaterialId(materialId);
    declarationResultBookVO.setBookName(bookName);
    pageParameter.setParameter(declarationResultBookVO);
    Workbook workbook = null;
    List<DeclarationResultBookVO> list = null;
    list = decPositionService.listDeclarationResultBookVOs(pageParameter).getRows();
    if (list.size() == 0) {
        list.add(new DeclarationResultBookVO());
    }
    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, "文件在传输时中断");
    }
}
Also used : BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) DeclarationResultBookVO(com.bc.pmpheep.back.vo.DeclarationResultBookVO) Workbook(org.apache.poi.ss.usermodel.Workbook) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DeclarationResultBookVO

use of com.bc.pmpheep.back.vo.DeclarationResultBookVO in project pmph by BCSquad.

the class DecPositionController method bookList.

/**
 * Description:加载书本统计结果
 *
 * @author:lyc
 * @date:2017年12月1日下午6:50:46
 * @param
 * @return ResponseBean
 */
@ResponseBody
@RequestMapping(value = "/list/bookList", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载书本统计结果")
public ResponseBean bookList(Integer pageSize, Integer pageNumber, Long materialId, String bookName) {
    PageParameter<DeclarationResultBookVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    DeclarationResultBookVO declarationResultBookVO = new DeclarationResultBookVO();
    declarationResultBookVO.setMaterialId(materialId);
    declarationResultBookVO.setBookName(bookName);
    pageParameter.setParameter(declarationResultBookVO);
    return new ResponseBean(decPositionService.listDeclarationResultBookVOs(pageParameter));
}
Also used : PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) DeclarationResultBookVO(com.bc.pmpheep.back.vo.DeclarationResultBookVO) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DeclarationResultBookVO (com.bc.pmpheep.back.vo.DeclarationResultBookVO)3 LogDetail (com.bc.pmpheep.annotation.LogDetail)2 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 Material (com.bc.pmpheep.back.po.Material)1 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)1 BufferedOutputStream (java.io.BufferedOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1