Search in sources :

Example 1 with DeclarationSituationSchoolResultVO

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

the class DecPositionServiceImpl method listPresetDeclarationSituationSchoolResultVOs.

@Override
public PageResult<DeclarationSituationSchoolResultVO> listPresetDeclarationSituationSchoolResultVOs(PageParameter<DeclarationSituationSchoolResultVO> 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<DeclarationSituationSchoolResultVO> pageResult = new PageResult<DeclarationSituationSchoolResultVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        List<DeclarationSituationSchoolResultVO> presets = decPositionDao.getSchoolResultPreset(pageParameter);
        List<DeclarationSituationSchoolResultVO> chosens = decPositionDao.getSchoolResultChosen(pageParameter);
        List<DeclarationSituationSchoolResultVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationSituationSchoolResultVO preset : presets) {
                // 计算申报人数
                Integer presetPersons = preset.getPresetPositionEditor() + preset.getPresetPositionSubeditor() + preset.getPresetPositionEditorial() + preset.getPresetDigitalEditor();
                preset.setPresetPersons(presetPersons);
                preset.setState(2);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationSituationSchoolResultVO preset : presets) {
            for (DeclarationSituationSchoolResultVO chosen : chosens) {
                if (chosen.getOrgId().equals(preset.getOrgId())) {
                    preset.setChosenPositionEditor(chosen.getChosenPositionEditor());
                    preset.setChosenPositionSubeditor(chosen.getChosenPositionSubeditor());
                    preset.setChosenPositionEditorial(chosen.getChosenPositionEditorial());
                    preset.setIsDigitalEditor(chosen.getIsDigitalEditor());
                    break;
                }
            }
            // 计算申报人数
            Integer presetPersons = preset.getPresetPositionEditor() + preset.getPresetPositionSubeditor() + preset.getPresetPositionEditorial() + preset.getPresetDigitalEditor();
            // 计算当选人数
            Integer chosenPersons = preset.getChosenPositionEditor() + preset.getChosenPositionSubeditor() + preset.getChosenPositionEditorial() + preset.getIsDigitalEditor();
            preset.setPresetPersons(presetPersons);
            preset.setChosenPersons(chosenPersons);
            preset.setState(2);
            list.add(preset);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult) DeclarationSituationSchoolResultVO(com.bc.pmpheep.back.vo.DeclarationSituationSchoolResultVO)

Example 2 with DeclarationSituationSchoolResultVO

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

the class DecPositionController method schoolResultsPreset.

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

Example 3 with DeclarationSituationSchoolResultVO

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

the class DecPositionServiceImpl method listChosenDeclarationSituationSchoolResultVOs.

@Override
public PageResult<DeclarationSituationSchoolResultVO> listChosenDeclarationSituationSchoolResultVOs(PageParameter<DeclarationSituationSchoolResultVO> 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<DeclarationSituationSchoolResultVO> pageResult = new PageResult<DeclarationSituationSchoolResultVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 得到申报单位的总数
    int total = decPositionDao.getSchoolCount(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        boolean flag = false;
        List<DeclarationSituationSchoolResultVO> chosens = decPositionDao.getSchoolResultChosenPage(pageParameter);
        List<DeclarationSituationSchoolResultVO> presets = decPositionDao.getSchoolResultPresetChosen(pageParameter);
        List<DeclarationSituationSchoolResultVO> delList = new ArrayList<>();
        List<DeclarationSituationSchoolResultVO> list = new ArrayList<>();
        if (null == chosens || chosens.isEmpty()) {
            for (DeclarationSituationSchoolResultVO preset : presets) {
                // 计算申报人数
                Integer presetPersons = preset.getPresetPositionEditor() + preset.getPresetPositionSubeditor() + preset.getPresetPositionEditorial() + preset.getPresetDigitalEditor();
                preset.setPresetPersons(presetPersons);
                preset.setState(1);
                list.add(preset);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        if (chosens.size() < presets.size()) {
            flag = true;
        }
        for (DeclarationSituationSchoolResultVO chosen : chosens) {
            for (DeclarationSituationSchoolResultVO preset : presets) {
                if (preset.getOrgId().equals(chosen.getOrgId())) {
                    delList.add(preset);
                    chosen.setPresetPositionEditor(preset.getPresetPositionEditor());
                    chosen.setPresetPositionSubeditor(preset.getPresetPositionSubeditor());
                    chosen.setPresetPositionEditorial(preset.getPresetPositionEditorial());
                    chosen.setPresetDigitalEditor(preset.getPresetDigitalEditor());
                    break;
                }
            }
            // 计算申报人数
            Integer presetPersons = chosen.getPresetPositionEditor() + chosen.getPresetPositionSubeditor() + chosen.getPresetPositionEditorial() + chosen.getPresetDigitalEditor();
            // 计算当选人数
            Integer chosenPersons = chosen.getChosenPositionEditor() + chosen.getChosenPositionSubeditor() + chosen.getChosenPositionEditorial() + chosen.getIsDigitalEditor();
            chosen.setPresetPersons(presetPersons);
            chosen.setChosenPersons(chosenPersons);
            chosen.setState(1);
            list.add(chosen);
        }
        if (flag) {
            presets.removeAll(delList);
            for (DeclarationSituationSchoolResultVO preset : presets) {
                // 计算申报人数
                Integer presetPersons = preset.getPresetPositionEditor() + preset.getPresetPositionSubeditor() + preset.getPresetPositionEditorial() + preset.getPresetDigitalEditor();
                preset.setPresetPersons(presetPersons);
                preset.setState(1);
                list.add(preset);
            }
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult) DeclarationSituationSchoolResultVO(com.bc.pmpheep.back.vo.DeclarationSituationSchoolResultVO)

Example 4 with DeclarationSituationSchoolResultVO

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

the class FileDownLoadController method exportSituationSchool.

/**
 * Description:申报情况统计页面按申报单位统计导出统计结果
 *
 * @author:lyc
 * @date:2018年1月9日上午10:29:21
 * @param
 * @return void
 */
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报情况统计页面按申报单位统计导出统计结果")
@RequestMapping(value = "/result/exportSituationSchool", method = RequestMethod.GET)
public void exportSituationSchool(Long materialId, String schoolName, Integer state, HttpServletRequest request, HttpServletResponse response) {
    PageParameter<DeclarationSituationSchoolResultVO> pageParameter = new PageParameter<>(1, 50000);
    DeclarationSituationSchoolResultVO declarationSituationSchoolResultVO = new DeclarationSituationSchoolResultVO();
    declarationSituationSchoolResultVO.setMaterialId(materialId);
    declarationSituationSchoolResultVO.setSchoolName(schoolName);
    pageParameter.setParameter(declarationSituationSchoolResultVO);
    Workbook workbook = null;
    List<DeclarationSituationSchoolResultVO> list = null;
    String sheetName = "";
    if (state.intValue() == 1) {
        list = decPositionService.listChosenDeclarationSituationSchoolResultVOs(pageParameter).getRows();
        sheetName = "申报情况按单位统计(按当选数排序)";
    } else if (state.intValue() == 2) {
        list = decPositionService.listPresetDeclarationSituationSchoolResultVOs(pageParameter).getRows();
        sheetName = "申报情况按单位统计(按申报数排序)";
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "未知的排序方式");
    }
    if (list.size() == 0) {
        list.add(new DeclarationSituationSchoolResultVO());
    }
    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) 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) DeclarationSituationSchoolResultVO(com.bc.pmpheep.back.vo.DeclarationSituationSchoolResultVO) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DeclarationSituationSchoolResultVO

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

the class DecPositionController method schoolResultsChosen.

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

Aggregations

DeclarationSituationSchoolResultVO (com.bc.pmpheep.back.vo.DeclarationSituationSchoolResultVO)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