use of com.bc.pmpheep.back.vo.DeclarationSituationBookResultVO in project pmph by BCSquad.
the class DecPositionServiceImpl method listDeclarationSituationBookResultVOs.
@Override
public PageResult<DeclarationSituationBookResultVO> listDeclarationSituationBookResultVOs(PageParameter<DeclarationSituationBookResultVO> 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<DeclarationSituationBookResultVO> pageResult = new PageResult<DeclarationSituationBookResultVO>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
int total = decPositionDao.getBooks(pageParameter.getParameter().getMaterialId());
if (total > 0) {
List<DeclarationSituationBookResultVO> books = decPositionDao.getBookListOne(pageParameter);
List<DeclarationSituationBookResultVO> presets = decPositionDao.getBookResultPreset(pageParameter);
List<DeclarationSituationBookResultVO> chosens = decPositionDao.getBookResultChosen(pageParameter);
List<DeclarationSituationBookResultVO> middle = new ArrayList<>();
List<DeclarationSituationBookResultVO> list = new ArrayList<>();
if (null == presets || presets.isEmpty()) {
for (DeclarationSituationBookResultVO book : books) {
// 计算申报人数
Integer presetPersons = book.getPresetPositionEditor() + book.getPresetPositionSubeditor() + book.getPresetPositionEditorial() + book.getPresetDigitalEditor();
book.setPresetPersons(presetPersons);
list.add(book);
}
pageResult.setRows(list);
pageResult.setTotal(total);
return pageResult;
}
for (DeclarationSituationBookResultVO book : books) {
for (DeclarationSituationBookResultVO preset : presets) {
if (preset.getId().equals(book.getId())) {
book.setPresetPositionEditor(preset.getPresetPositionEditor());
book.setPresetPositionSubeditor(preset.getPresetPositionSubeditor());
book.setPresetPositionEditorial(preset.getPresetPositionEditorial());
book.setPresetDigitalEditor(preset.getPresetDigitalEditor());
break;
}
}
// 计算申报人数
Integer presetPersons = book.getPresetPositionEditor() + book.getPresetPositionSubeditor() + book.getPresetPositionEditorial() + book.getPresetDigitalEditor();
book.setPresetPersons(presetPersons);
middle.add(book);
}
if (null == chosens || chosens.isEmpty()) {
pageResult.setRows(middle);
pageResult.setTotal(total);
return pageResult;
}
for (DeclarationSituationBookResultVO book : middle) {
for (DeclarationSituationBookResultVO chosen : chosens) {
if (chosen.getId().equals(book.getId())) {
book.setChosenPositionEditor(chosen.getChosenPositionEditor());
book.setChosenPositionSubeditor(chosen.getChosenPositionSubeditor());
book.setChosenPositionEditorial(chosen.getChosenPositionEditorial());
book.setIsDigitalEditor(chosen.getIsDigitalEditor());
break;
}
}
// 计算当选人数
Integer chosenPersons = book.getChosenPositionEditor() + book.getChosenPositionSubeditor() + book.getChosenPositionEditorial() + book.getIsDigitalEditor();
book.setChosenPersons(chosenPersons);
list.add(book);
}
pageResult.setRows(list);
pageResult.setTotal(total);
}
return pageResult;
}
use of com.bc.pmpheep.back.vo.DeclarationSituationBookResultVO 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.back.vo.DeclarationSituationBookResultVO in project pmph by BCSquad.
the class DecPositionController method bookResults.
/**
* Description:加载书本申报情况统计结果
*
* @author:lyc
* @date:2017年12月1日下午5:44:16
* @param
* @return ResponseBean
*/
@ResponseBody
@RequestMapping(value = "/list/bookResults", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载书本申报情况统计结果")
public ResponseBean bookResults(Integer pageSize, Integer pageNumber, Long materialId, String bookName) {
PageParameter<DeclarationSituationBookResultVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
DeclarationSituationBookResultVO declarationSituationBookResultVO = new DeclarationSituationBookResultVO();
declarationSituationBookResultVO.setMaterialId(materialId);
declarationSituationBookResultVO.setBookName(bookName);
pageParameter.setParameter(declarationSituationBookResultVO);
return new ResponseBean(decPositionService.listDeclarationSituationBookResultVOs(pageParameter));
}
Aggregations