use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class FileDownLoadController method exportTopic.
/**
* Description:设置选题号页面导出选题号
*
* @author:lyc
* @date:2018年1月23日下午6:18:41
* @param
* @return void
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "设置选题号页面导出选题号信息")
@RequestMapping(value = "/textbook/exportTopic", method = RequestMethod.GET)
public void exportTopic(Long materialId, HttpServletRequest request, HttpServletResponse response) {
List<Textbook> list = textbookService.listTopicNumber(materialId);
Workbook workbook = null;
if (list.size() == 0) {
list.add(new Textbook());
}
try {
workbook = excelHelper.fromTextbookTopic(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.po.Material 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, "文件在传输时中断");
}
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class DecPositionServiceImpl method listEditorSelection.
@Override
public Map<String, Object> listEditorSelection(Long textbookId, Long materialId, String realName, String orgName) throws CheckedServiceException {
if (ObjectUtil.isNull(textbookId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "书籍id不能为空");
}
if (ObjectUtil.isNull(materialId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
}
Map<String, Object> resultMap = new HashMap<String, Object>();
List<DecPositionEditorSelectionVO> listEditorSelectionVOs = decPositionDao.listEditorSelection(textbookId, StringUtil.toAllCheck(realName), StringUtil.toAllCheck(orgName));
// 因为作家申报机构为0时 为人卫社 但机构中又不存在0机构 在此遍历作家申报的机构,如果为null这里设置为人卫社
for (DecPositionEditorSelectionVO decPositionEditorSelectionVO : listEditorSelectionVOs) {
if (null == decPositionEditorSelectionVO.getReportName()) {
decPositionEditorSelectionVO.setReportName("人民卫生出版社");
}
}
// 排序
List<DecPositionEditorSelectionVO> selectedDecPositionEditorSelectionVOs = // 已遴选集合
new ArrayList<DecPositionEditorSelectionVO>();
List<DecPositionEditorSelectionVO> unselectedDecPositionEditorSelectionVOs = // 未遴选集合
new ArrayList<DecPositionEditorSelectionVO>();
for (DecPositionEditorSelectionVO de : listEditorSelectionVOs) {
if (ObjectUtil.notNull(de.getRank())) {
selectedDecPositionEditorSelectionVOs.add(de);
} else if (de.getChosenPosition() > 0) {
selectedDecPositionEditorSelectionVOs.add(de);
} else {
unselectedDecPositionEditorSelectionVOs.add(de);
}
}
List<DecPositionEditorSelectionVO> editorList = // 已遴选主编集合
new ArrayList<DecPositionEditorSelectionVO>(selectedDecPositionEditorSelectionVOs.size());
List<DecPositionEditorSelectionVO> subeditorList = // 已遴选副主编集合
new ArrayList<DecPositionEditorSelectionVO>(selectedDecPositionEditorSelectionVOs.size());
List<DecPositionEditorSelectionVO> editorialMemberList = // 已遴选编委集合
new ArrayList<DecPositionEditorSelectionVO>(selectedDecPositionEditorSelectionVOs.size());
List<DecPositionEditorSelectionVO> digitalrList = // 已遴选数字编委集合
new ArrayList<DecPositionEditorSelectionVO>(selectedDecPositionEditorSelectionVOs.size());
for (DecPositionEditorSelectionVO decVo : selectedDecPositionEditorSelectionVOs) {
if (4 == decVo.getChosenPosition() || 12 == decVo.getChosenPosition()) {
// 主编 1100 0100
editorList.add(decVo);
} else if (2 == decVo.getChosenPosition() || 10 == decVo.getChosenPosition()) {
// 副主编
// 1010
// 0010
subeditorList.add(decVo);
} else if (1 == decVo.getChosenPosition() || 9 == decVo.getChosenPosition()) {
// 编委 1001
// 0001
editorialMemberList.add(decVo);
} else if (8 == decVo.getChosenPosition()) {
// 数字编委 1000
digitalrList.add(decVo);
}
}
Collections.sort(editorList, new Comparator<DecPositionEditorSelectionVO>() {
public int compare(DecPositionEditorSelectionVO arg0, DecPositionEditorSelectionVO arg1) {
return arg0.getRank().compareTo(arg1.getRank());
}
});
Collections.sort(subeditorList, new Comparator<DecPositionEditorSelectionVO>() {
public int compare(DecPositionEditorSelectionVO arg0, DecPositionEditorSelectionVO arg1) {
return arg0.getRank().compareTo(arg1.getRank());
}
});
Collections.sort(unselectedDecPositionEditorSelectionVOs, new Comparator<DecPositionEditorSelectionVO>() {
public int compare(DecPositionEditorSelectionVO arg0, DecPositionEditorSelectionVO arg1) {
return arg1.getPresetPosition().compareTo(arg0.getPresetPosition());
}
});
List<DecPositionEditorSelectionVO> newDecPositionEditorSelectionVOs = // 重新排序后的集合
new ArrayList<DecPositionEditorSelectionVO>(listEditorSelectionVOs.size());
newDecPositionEditorSelectionVOs.addAll(editorList);
newDecPositionEditorSelectionVOs.addAll(subeditorList);
newDecPositionEditorSelectionVOs.addAll(editorialMemberList);
newDecPositionEditorSelectionVOs.addAll(digitalrList);
newDecPositionEditorSelectionVOs.addAll(unselectedDecPositionEditorSelectionVOs);
resultMap.put("DecPositionEditorSelectionVO", newDecPositionEditorSelectionVOs);
Material material = materialService.getMaterialById(materialId);
resultMap.put("IsDigitalEditorOptional", material.getIsDigitalEditorOptional());
return resultMap;
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class DeclarationServiceImpl method confirmPaperList.
@Override
public Declaration confirmPaperList(Long id, Integer offlineProgress, String sessionId) throws CheckedServiceException, IOException {
if (ObjectUtil.isNull(id)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "主键不能为空!");
}
if (ObjectUtil.isNull(offlineProgress)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "确认收到纸质表不能为空!");
}
// 纸质表审核人id
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.OBJECT_NOT_FOUND, "审核人为空!");
}
// 纸质表审核人Id为登陆用户ID
Long authUserId = pmphUser.getId();
// 获取当前作家用户申报信息
Declaration declarationCon = declarationDao.getDeclarationById(id);
// 获取教材
Material material = materialService.getMaterialById(declarationCon.getMaterialId());
if (ObjectUtil.isNull(declarationCon)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.OBJECT_NOT_FOUND, "查询结果为空!");
}
// 纸质表审核人id
declarationCon.setAuthUserId(authUserId);
Date date = new Date();
// 纸质表收到时间
declarationCon.setPaperDate(new Timestamp(date.getTime()));
declarationCon.setOfflineProgress(offlineProgress);
declarationDao.updateDeclaration(declarationCon);
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationCon.getUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
if (0 == offlineProgress) {
map.put("content", "抱歉,您在《" + material.getMaterialName() + "》提交的申报纸质表被退回,请您核对后重试。");
} else {
map.put("content", "您好,人民卫生出版社已收到您在《" + material.getMaterialName() + "》提交的申报纸质表,感谢您的参与,请耐心等待遴选结果。");
}
map.put("img", 1);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationCon.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
Boolean isPass = true;
if (0 == offlineProgress) {
isPass = false;
}
// 发送系统消息
systemMessageService.sendWhenReceiptAudit(declarationCon.getId(), isPass);
return declarationCon;
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class DeclarationServiceImpl method onlineProgress.
@Override
public Declaration onlineProgress(Long id, Integer onlineProgress, String returnCause) throws CheckedServiceException, IOException {
if (ObjectUtil.isNull(id)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "主键不能为空!");
}
if (ObjectUtil.isNull(onlineProgress)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "审核进度不能为空!");
}
// 获取当前作家用户申报信息
Declaration declarationCon = declarationDao.getDeclarationById(id);
// 获取教材
Material material = materialService.getMaterialById(declarationCon.getMaterialId());
// 提交出版社,出版社点击通过
if (3 == onlineProgress.intValue() && 1 == declarationCon.getOnlineProgress() && 0 == declarationCon.getOrgId()) {
declarationCon.setOnlineProgress(onlineProgress);
declarationDao.updateDeclaration(declarationCon);
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationCon.getUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
map.put("content", "恭喜!您提交的《" + material.getMaterialName() + "》申报表已通过出版社审核。");
map.put("img", 1);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationCon.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
// 发送系统消息
systemMessageService.sendWhenDeclarationFormAudit(declarationCon.getId(), true, returnCause);
// 获取审核进度是4并且已经通过审核单位并且不是提交到出版社0则被退回给申报单位
// 提交审核单位,审核单位已经通过,出版社退回给申报单位操作
} else if (4 == onlineProgress.intValue() && 3 == declarationCon.getOnlineProgress() && 0 != declarationCon.getOrgId()) {
List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
for (DecPosition decPositions : decPosition) {
Integer chosenPosition = decPositions.getChosenPosition();
if (null != chosenPosition && chosenPosition.intValue() > 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给申报单位!");
}
}
declarationCon.setOnlineProgress(onlineProgress);
if (StringUtil.strLength(returnCause) > 100) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
}
declarationCon.setReturnCause(returnCause);
declarationDao.updateDeclaration(declarationCon);
// 添加动态信息
/*WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationCon.getUserId());
writerUserTrendst.setIsPublic(false);// 自己可见
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
map.put("content", "抱歉,贵校老师" + declarationCon.getRealname() + "提交的《" + material.getMaterialName()
+ "》申报表被出版社退回,退回原因:" + returnCause + ",请贵校核对后重试。");
map.put("img", 2);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationCon.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);*/
// 发送系统消息
systemMessageService.sendWhenDeclarationFormAuditToOrgUser(declarationCon.getId(), false, returnCause, onlineProgress);
// 获取审核进度是5并且已经通过审核单位并且不是提交到出版社0则被退回给个人
// 提交审核单位,审核单位已经通过,出版社退回给个人操作
} else if (5 == onlineProgress.intValue() && 3 == declarationCon.getOnlineProgress() && 0 != declarationCon.getOrgId()) {
List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
for (DecPosition decPositions : decPosition) {
Integer chosenPosition = decPositions.getChosenPosition();
if (null != chosenPosition && chosenPosition.intValue() > 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给个人!");
}
}
declarationCon.setOnlineProgress(onlineProgress);
if (StringUtil.strLength(returnCause) > 100) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
}
declarationCon.setReturnCause(returnCause);
declarationDao.updateDeclaration(declarationCon);
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationCon.getUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
map.put("content", "抱歉,您提交的《" + material.getMaterialName() + "》申报表被出版社退回," + "退回原因:" + returnCause + ",请您核对后重试。");
map.put("img", 2);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationCon.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
// 发送系统消息
systemMessageService.sendWhenDeclarationFormAuditToOrgUser(declarationCon.getId(), false, returnCause, onlineProgress);
// 获取审核进度是5并且机构id为出版社0则被退回给个人
// 提交到出版社,出版社退回给个人操作
} else if (5 == onlineProgress.intValue() && 0 == declarationCon.getOrgId()) {
List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
for (DecPosition decPositions : decPosition) {
Integer chosenPosition = decPositions.getChosenPosition();
if (null != chosenPosition && chosenPosition.intValue() > 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给个人!");
}
}
declarationCon.setOnlineProgress(onlineProgress);
if (StringUtil.strLength(returnCause) > 100) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
}
declarationCon.setReturnCause(returnCause);
declarationDao.updateDeclaration(declarationCon);
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationCon.getUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
map.put("content", "抱歉,您提交的《" + material.getMaterialName() + "》申报表被出版社退回," + "退回原因:" + returnCause + ",请您核对后重试。");
map.put("img", 2);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationCon.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
// 发送系统消息
systemMessageService.sendWhenDeclarationFormAudit(declarationCon.getId(), false, returnCause);
}
return declarationCon;
}
Aggregations