use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class CmsManualServiceImpl method addCmsManual.
@Override
public CmsManual addCmsManual(CmsManual cmsManual) throws CheckedServiceException {
if (ObjectUtil.isNull(cmsManual)) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "CmsManual对象参数为空");
}
if (ObjectUtil.isNull(cmsManual.getAttachment())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "附件id参数为空");
}
if (StringUtil.isEmpty(cmsManual.getNote())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "备注参数为空");
}
if (ObjectUtil.isNull(cmsManual.getUserId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "上传者id参数为空");
}
if (cmsManual.getManualName().length() > 50) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.ILLEGAL_PARAM, "操作手册名称不能超过50个字!");
}
String fileName = "操作手册.doc";
GridFSDBFile file = fileService.get(cmsManual.getAttachment());
if (ObjectUtil.notNull(file)) {
fileName = file.getFilename();
}
cmsManual.setManualName(fileName);
cmsManualDao.addCmsManual(cmsManual);
return cmsManual;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class CmsManualServiceImpl method listCmsManual.
@Override
public PageResult<CmsManualVO> listCmsManual(PageParameter<CmsManualVO> pageParameter, String sessionId) throws CheckedServiceException {
// 获取当前登陆用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
PageResult<CmsManualVO> pageResult = new PageResult<CmsManualVO>();
// 将页面大小和页面页码拷贝
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
// 包含数据总条数的数据集
List<CmsManualVO> cmsManualVOs = cmsManualDao.listCmsManual(pageParameter);
if (CollectionUtil.isNotEmpty(cmsManualVOs)) {
Integer count = cmsManualVOs.get(0).getCount();
pageResult.setTotal(count);
pageResult.setRows(cmsManualVOs);
}
return pageResult;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class DecPositionServiceImpl method updateDecPositionEditorSelection.
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Integer updateDecPositionEditorSelection(String jsonDecPosition, Integer selectionType, Integer editorOrSubeditorType, Integer unselectedHold, Long textbookId, String sessionId) throws CheckedServiceException, IOException {
if (StringUtil.isEmpty(jsonDecPosition)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "遴选职位不能为空");
}
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
Integer count = 0;
List<DecPosition> decPositions = // json字符串转List对象集合
new JsonUtil().getArrayListObjectFromStr(DecPosition.class, jsonDecPosition);
// 编委遴选界面 (0:未选中)
Integer unselectedHold_0 = 0;
if (CollectionUtil.isEmpty(decPositions) && unselectedHold_0 == unselectedHold && 2 == editorOrSubeditorType && 1 == selectionType) {
// 编委遴选界面,没有人员被选中也可以进行暂存
// 查询书籍下所有申报id
List<Long> ids = decPositionService.getDecPositionIdByBookId(textbookId, editorOrSubeditorType);
// 初始化作家职位申报表
if (CollectionUtil.isNotEmpty(ids)) {
decPositionService.updateDecPositionSetDefault(ids, editorOrSubeditorType);
}
} else {
if (CollectionUtil.isEmpty(decPositions)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "遴选职位为空");
}
// (1:确定,2:发布)
Integer selectionType_1 = 1;
Integer selectionType_2 = 2;
// 获取书籍id
textbookId = decPositions.get(0).getTextbookId();
// 原来的历史遴选记录
List<DecPosition> oldlist = decPositionService.listChosenDecPositionsByTextbookId(textbookId);
// 1:确定
if (selectionType_1.intValue() == selectionType.intValue()) {
// 查询书籍下所有申报id
List<Long> ids = decPositionService.getDecPositionIdByBookId(textbookId, editorOrSubeditorType);
if (2 == editorOrSubeditorType) {
// 遴选的编委ID
List<Long> newEditorialMemberIds = new ArrayList<Long>();
for (DecPosition decPosition : decPositions) {
if (1 == decPosition.getChosenPosition() || 8 == decPosition.getChosenPosition()) {
if (!ids.contains(decPosition.getId())) {
newEditorialMemberIds.add(decPosition.getId());
}
}
}
if (newEditorialMemberIds.isEmpty()) {
Textbook textbook = textbookService.getTextbookById(textbookId);
if (0 != textbook.getRevisionTimes()) {
textbookService.updatRevisionTimesByTextBookId(-1, textbookId);
}
} else {
textbookService.updatRevisionTimesByTextBookId(1, textbookId);
}
// 清楚dec_position_temp表
decPositionTempService.deleteDecPositionTempByTextbookId(textbookId);
}
// 初始化作家职位申报表
if (CollectionUtil.isNotEmpty(ids)) {
decPositionService.updateDecPositionSetDefault(ids, editorOrSubeditorType);
}
if (CollectionUtil.isNotEmpty(decPositions)) {
count = decPositionDao.updateDecPositionEditorSelection(decPositions);
}
if (ObjectUtil.isNull(textbookId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
}
// 用户类型
Integer userType = 1;
// 获取修改者id
Long updaterId = pmphUser.getId();
// 添加新的遴选记录
textbookLogService.addTextbookLog(oldlist, textbookId, updaterId, userType);
}
// 2:发布
if (selectionType_2.intValue() == selectionType.intValue()) {
// 发布的时候 先确认
this.updateDecPositionEditorSelection(jsonDecPosition, 1, editorOrSubeditorType, unselectedHold, textbookId, sessionId);
if (ObjectUtil.isNull(textbookId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
}
// 获取当前书籍书申报信息(包含没有被遴选上的)
List<DecPosition> decPositionsList = decPositionService.listDecPositionsByTextBookIds(new ArrayList<Long>(Arrays.asList(textbookId)));
if (CollectionUtil.isEmpty(decPositionsList)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "当前书籍还未遴选主编,副主编");
}
// DecPositionPublished对象集合
List<DecPositionPublished> decPositionPublisheds = new ArrayList<DecPositionPublished>(decPositionsList.size());
for (DecPosition decPosition : decPositionsList) {
// 筛选出遴选上的主编副主编人员
Integer chosenPosition = decPosition.getChosenPosition();
if (null != chosenPosition && (chosenPosition == 4 || chosenPosition == 2 || chosenPosition == 12 || chosenPosition == 10)) {
chosenPosition = chosenPosition > 8 ? chosenPosition - 8 : chosenPosition;
decPositionPublisheds.add(new DecPositionPublished(pmphUser.getId(), decPosition.getDeclarationId(), textbookId, decPosition.getPresetPosition(), chosenPosition, decPosition.getRank(), decPosition.getSyllabusId(), decPosition.getSyllabusName()));
}
}
// 已经公布的列表
List<DecPositionPublished> lst = decPositionPublishedService.getDecPositionPublishedListByBookId(textbookId);
List<DecPositionPublished> addNew = new ArrayList<DecPositionPublished>(16);
for (DecPositionPublished item : lst) {
// 编委 | 数字编委
if (item.getChosenPosition() == 1 || item.getChosenPosition() >= 8) {
// item.setChosenPosition(item.getChosenPosition() > 8
// ?(item.getChosenPosition()-8):item.getChosenPosition() );
addNew.add(item);
}
}
// 加入主编副主编
for (DecPositionPublished item : decPositionPublisheds) {
boolean no = true;
for (DecPositionPublished itemadd : addNew) {
if (itemadd.getDeclarationId().intValue() == item.getDeclarationId().intValue()) {
no = false;
itemadd.setChosenPosition(item.getChosenPosition() + 8);
break;
}
}
if (no) {
addNew.add(item);
}
}
// clear Id
for (DecPositionPublished item : addNew) {
item.setId(null);
}
// 对比重新发布之前于之后的不同
List<DecPositionPublished> newMessage = new ArrayList<>();
for (DecPositionPublished now : decPositionPublisheds) {
DecPositionPublished published = decPositionPublishedService.getDecPositionByDeclarationId(now.getDeclarationId(), now.getTextbookId());
if (ObjectUtil.isNull(published)) {
newMessage.add(now);
}
for (DecPositionPublished old : lst) {
if (now.getDeclarationId().equals(old.getDeclarationId())) {
if (!now.getChosenPosition().equals(old.getChosenPosition()) || !now.getRank().equals(old.getRank())) {
newMessage.add(now);
}
}
}
}
// 先删除当前发布人已发布的
decPositionPublishedService.deleteDecPositionPublishedByTextBookId(textbookId);
// 再添加
decPositionPublishedService.batchInsertDecPositionPublished(addNew);
// 发布时更新textbook表中is_chief_published(是否已公布主编/副主编)字段
count = textbookService.updateTextbook(new Textbook(textbookId, true));
if (count > 0) {
// 发送消息
systemMessageService.sendWhenConfirmFirstEditor(textbookId, newMessage);
}
}
}
return count;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException 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.service.exception.CheckedServiceException 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;
}
Aggregations