Search in sources :

Example 1 with DeclarationResultSchoolVO

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

the class FileDownLoadController method exportResultSchool.

/**
 * Description:申报结果统计页面按申报单位统计导出统计结果
 *
 * @author:lyc
 * @date:2018年1月9日上午11:16:01
 * @param
 * @return void
 */
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报结果统计页面按申报单位统计导出统计结果")
@RequestMapping(value = "/result/exportResultSchool", method = RequestMethod.GET)
public void exportResultSchool(Long materialId, String schoolName, Integer state, HttpServletRequest request, HttpServletResponse response) {
    PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(1, 50000);
    DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
    declarationResultSchoolVO.setMaterialId(materialId);
    declarationResultSchoolVO.setSchoolName(schoolName);
    pageParameter.setParameter(declarationResultSchoolVO);
    Workbook workbook = null;
    List<DeclarationResultSchoolVO> list = null;
    String sheetName = "";
    if (state.intValue() == 1) {
        list = decPositionService.listChosenDeclarationResultSchoolVOs(pageParameter).getRows();
        sheetName = "申报结果按单位统计(按当选数排序)";
    } else if (state.intValue() == 2) {
        list = decPositionService.listPresetDeclarationResultSchoolVOs(pageParameter).getRows();
        sheetName = "申报结果按单位统计(按申报数排序)";
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "未知的排序方式");
    }
    if (list.size() == 0) {
        list.add(new DeclarationResultSchoolVO());
    }
    try {
        workbook = excelHelper.fromBusinessObjectList(list, sheetName);
    } 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) DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) 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 2 with DeclarationResultSchoolVO

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

the class DecPositionController method schoolListPreset.

/**
 * Description:加载学校统计结果(按申报数排序)
 *
 * @author:lyc
 * @date:2017年12月5日下午2:57:51
 * @param
 * @return ResponseBean
 */
@ResponseBody
@RequestMapping(value = "/list/schoolListPreset", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载学校统计结果(按申报数排序)")
public ResponseBean schoolListPreset(Integer pageSize, Integer pageNumber, Long materialId, String schoolName) {
    PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
    declarationResultSchoolVO.setMaterialId(materialId);
    declarationResultSchoolVO.setSchoolName(schoolName);
    pageParameter.setParameter(declarationResultSchoolVO);
    return new ResponseBean(decPositionService.listPresetDeclarationResultSchoolVOs(pageParameter));
}
Also used : DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DeclarationResultSchoolVO

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

the class DecPositionServiceImpl method listChosenDeclarationResultSchoolVOs.

@Override
public PageResult<DeclarationResultSchoolVO> listChosenDeclarationResultSchoolVOs(PageParameter<DeclarationResultSchoolVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String schoolName = pageParameter.getParameter().getSchoolName();
    if (StringUtil.notEmpty(schoolName)) {
        pageParameter.getParameter().setSchoolName(schoolName);
    }
    PageResult<DeclarationResultSchoolVO> pageResult = new PageResult<DeclarationResultSchoolVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        boolean flag = false;
        List<DeclarationResultSchoolVO> chosens = decPositionDao.getSchoolListChosenPage(pageParameter);
        List<DeclarationResultSchoolVO> presets = decPositionDao.getSchoolListPresetChosen(pageParameter);
        List<DeclarationResultSchoolVO> delList = new ArrayList<>();
        List<DeclarationResultSchoolVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationResultSchoolVO preset : presets) {
                preset.setState(1);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        if (chosens.size() < presets.size()) {
            flag = true;
        }
        for (DeclarationResultSchoolVO chosen : chosens) {
            for (DeclarationResultSchoolVO preset : presets) {
                if (preset.getOrgId().equals(chosen.getOrgId())) {
                    delList.add(preset);
                    if (StringUtil.isEmpty(chosen.getEditorList())) {
                        chosen.setEditorList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getSubEditorList())) {
                        chosen.setSubEditorList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getEditorialList())) {
                        chosen.setEditorialList("-");
                    }
                    if (StringUtil.isEmpty(chosen.getIsDigitalEditorList())) {
                        chosen.setIsDigitalEditorList("-");
                    }
                    break;
                }
            }
            chosen.setState(1);
            list.add(chosen);
        }
        if (flag) {
            presets.removeAll(delList);
            list.addAll(presets);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 4 with DeclarationResultSchoolVO

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

the class DecPositionServiceImpl method listPresetDeclarationResultSchoolVOs.

@Override
public PageResult<DeclarationResultSchoolVO> listPresetDeclarationResultSchoolVOs(PageParameter<DeclarationResultSchoolVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String schoolName = pageParameter.getParameter().getSchoolName();
    if (StringUtil.notEmpty(schoolName)) {
        pageParameter.getParameter().setSchoolName(schoolName);
    }
    PageResult<DeclarationResultSchoolVO> pageResult = new PageResult<DeclarationResultSchoolVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        List<DeclarationResultSchoolVO> presets = decPositionDao.getSchoolListPreset(pageParameter);
        List<DeclarationResultSchoolVO> chosens = decPositionDao.getSchoolListChosen(pageParameter);
        List<DeclarationResultSchoolVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationResultSchoolVO preset : presets) {
                preset.setState(2);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationResultSchoolVO preset : presets) {
            for (DeclarationResultSchoolVO chosen : chosens) {
                if (chosen.getOrgId().equals(preset.getOrgId())) {
                    preset.setEditorList(chosen.getEditorList());
                    preset.setSubEditorList(chosen.getSubEditorList());
                    preset.setEditorialList(chosen.getEditorialList());
                    preset.setIsDigitalEditorList(chosen.getIsDigitalEditorList());
                    if (StringUtil.isEmpty(preset.getEditorList())) {
                        preset.setEditorList("-");
                    }
                    if (StringUtil.isEmpty(preset.getSubEditorList())) {
                        preset.setSubEditorList("-");
                    }
                    if (StringUtil.isEmpty(preset.getEditorialList())) {
                        preset.setEditorialList("-");
                    }
                    if (StringUtil.isEmpty(preset.getIsDigitalEditorList())) {
                        preset.setIsDigitalEditorList("-");
                    }
                    break;
                }
            }
            preset.setState(2);
            list.add(preset);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 5 with DeclarationResultSchoolVO

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

the class DecPositionController method schoolListChosen.

/**
 * Description:加载学校统计结果(按当选数排序)
 *
 * @author:lyc
 * @date:2017年12月1日下午6:50:23
 * @param
 * @return ResponseBean
 */
@ResponseBody
@RequestMapping(value = "/list/schoolListChosen", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载学校统计结果(按当选数排序)")
public ResponseBean schoolListChosen(Integer pageSize, Integer pageNumber, Long materialId, String schoolName) {
    PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
    declarationResultSchoolVO.setMaterialId(materialId);
    declarationResultSchoolVO.setSchoolName(schoolName);
    pageParameter.setParameter(declarationResultSchoolVO);
    return new ResponseBean(decPositionService.listChosenDeclarationResultSchoolVOs(pageParameter));
}
Also used : DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

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