use of com.bc.pmpheep.back.vo.DecPositionEditorSelectionVO 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;
}
Aggregations