use of com.bc.pmpheep.service.exception.CheckedServiceException 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;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class MaterialExtraServiceImpl method updateMaterialExtraAndNoticeFile.
/**
* <pre>
* 功能描述:编辑通知详情
* 使用示范:
*
* @param materialExtraVO MaterialExtraVO
* @return Map<String, Object>集合
* @throws CheckedServiceException
* </pre>
*/
@Override
public Integer updateMaterialExtraAndNoticeFile(MaterialExtraVO materialExtraVO) throws CheckedServiceException, IOException {
// 教材ID
Long materialId = materialExtraVO.getMaterialId();
if (ObjectUtil.isNull(materialId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "教材ID为空");
}
String materialName = materialExtraVO.getMaterialName();
if (StringUtil.isEmpty(materialName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "教材名称为空");
}
String content = materialExtraVO.getContent();
if (StringUtil.isEmpty(content)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "教材通知为空");
}
// MongoDB 内容插入
Content contentObj = contentService.add(new Content(content));
if (ObjectUtil.isNull(contentObj)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.OBJECT_NOT_FOUND, "教材通知保存失败");
}
Material material = materialService.getMaterialById(materialId);
if (StringUtil.isEmpty(materialExtraVO.getContent())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "教材通知内容为空");
}
// 内容ID
Long cmsContentId = null;
CmsContent cmsContent = cmsContentService.getCmsContentByMaterialId(materialId);
if (ObjectUtil.notNull(cmsContent)) {
cmsContentId = cmsContent.getId();
String mid = null;
if (StringUtil.notEmpty(cmsContent.getMid())) {
mid = cmsContent.getMid();
}
// 存在就更新
Integer count = cmsContentService.updateCmsContent(new CmsContent(cmsContent.getId(), contentObj.getId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime())));
if (count > 0) {
// 删除之前教材通知内容
contentService.delete(mid);
}
} else {
// 保存CMSContent内容
CmsContent cmsContentObj = cmsContentService.addCmsContent(new CmsContent(0L, "0", contentObj.getId(), materialName, Const.CMS_AUTHOR_TYPE_0, false, true, material.getFounderId(), DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime()), materialId, Const.CMS_CATEGORY_ID_3, Const.TRUE, "DEFAULT"));
if (ObjectUtil.isNull(cmsContentObj.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "创建教材通知公告失败");
}
cmsContentId = cmsContentObj.getId();
}
// 先删除教材通知附件
List<CmsExtra> cmsExtras = cmsExtraService.getCmsExtraByContentId(cmsContentId);
if (CollectionUtil.isNotEmpty(cmsExtras)) {
List<Long> cmsExtraIds = new ArrayList<Long>();
for (CmsExtra cmsExtra : cmsExtras) {
cmsExtraIds.add(cmsExtra.getId());
}
cmsExtraService.deleteCmsExtraByIds(cmsExtraIds);
}
// 教材通知附件
List<MaterialNoticeAttachment> materialNoticeAttachments = null;
// 教材备注附件
List<MaterialNoteAttachment> materialNoteAttachments = null;
// 教材通知备注
MaterialExtra materialExtra = this.getMaterialExtraByMaterialId(materialId);
if (ObjectUtil.notNull(materialExtra)) {
Long materialExtraId = materialExtra.getId();
if (ObjectUtil.notNull(materialExtraId)) {
// 教材通知附件
materialNoticeAttachments = materialNoticeAttachmentService.getMaterialNoticeAttachmentsByMaterialExtraId(materialExtraId);
// 教材备注附件
materialNoteAttachments = materialNoteAttachmentService.getMaterialNoteAttachmentByMaterialExtraId(materialExtraId);
// 教材通知附件保存到CMS附件表中
for (MaterialNoticeAttachment mna : materialNoticeAttachments) {
cmsExtraService.addCmsExtra(new CmsExtra(cmsContentId, mna.getAttachment(), mna.getAttachmentName(), 0L));
}
for (MaterialNoteAttachment ma : materialNoteAttachments) {
cmsExtraService.addCmsExtra(new CmsExtra(cmsContentId, ma.getAttachment(), ma.getAttachmentName(), 0L));
}
}
}
// 教材通知附件
// String[] noticeFiles = materialExtraVO.getNoticeFiles();
// if (ArrayUtil.isNotEmpty(noticeFiles)) {
// this.saveFileToMongoDB(noticeFiles, materialExtraId, NOTICE);
// }
// 教材通知附件MongoDB对应ID
String[] noticeAttachments = materialExtraVO.getNoticeAttachments();
if (ArrayUtil.isNotEmpty(noticeAttachments)) {
// 删除MaterialNoticeAttachment 表
materialNoticeAttachmentService.deleteMaterialNoticeAttachmentByAttachments(noticeAttachments);
// 删除MongoDB对应的文件
for (int i = 0; i < noticeAttachments.length; i++) {
fileService.remove(noticeAttachments[i]);
}
}
// 教材备注附件
// String[] noteFiles = materialExtraVO.getNoteFiles();
// if (ArrayUtil.isNotEmpty(noteFiles)) {
// this.saveFileToMongoDB(noteFiles, materialExtraId, NOTE);
// }
// 教材备注附件MongoDB对应ID
String[] noteAttachments = materialExtraVO.getNoteAttachments();
if (ArrayUtil.isNotEmpty(noteAttachments)) {
// 删除MaterialNoteAttachment 表
materialNoteAttachmentService.deleteMaterialNoteAttachmentByAttachments(noteAttachments);
// 删除MongoDB对应的文件
for (int i = 0; i < noteAttachments.length; i++) {
fileService.remove(noteAttachments[i]);
}
}
return 1;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class MaterialExtraServiceImpl method noticePublished.
@Override
public Integer noticePublished(Long materialId, List<Long> orgIds, String sessionId) throws CheckedServiceException, IOException {
if (CollectionUtil.isEmpty(orgIds)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "机构为空");
}
// 防止网络延迟重复提交
Set<Long> newOrgIdSet = new HashSet<>();
newOrgIdSet.addAll(orgIds);
List<Long> listOrgIds = new ArrayList<Long>(newOrgIdSet.size());
listOrgIds.addAll(newOrgIdSet);
// 获取当前用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
Integer count = 0;
List<MaterialOrg> materialOrgList = new ArrayList<MaterialOrg>(listOrgIds.size());
// 根据教材ID查询教材-机构关联表
List<Long> OrgIds = materialOrgService.getListMaterialOrgByMaterialId(materialId);
if (CollectionUtil.isEmpty(OrgIds)) {
// 为空,初次发布
for (Long orgId : listOrgIds) {
materialOrgList.add(new MaterialOrg(materialId, orgId));
}
count = materialOrgService.addMaterialOrgs(materialOrgList);
if (count > 0) {
systemMessageService.materialSend(materialId, listOrgIds);
}
} else {
// 不为空
// 新选中的机构
List<Long> newOrgIds = new ArrayList<Long>();
for (Long orgId : listOrgIds) {
if (!OrgIds.contains(orgId)) {
newOrgIds.add(orgId);
materialOrgList.add(new MaterialOrg(materialId, orgId));
}
}
if (CollectionUtil.isEmpty(materialOrgList)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.ILLEGAL_PARAM, "当前选中的学校已收到消息,无需要再次发送");
}
count = materialOrgService.addMaterialOrgs(materialOrgList);
if (count > 0) {
systemMessageService.materialSend(materialId, newOrgIds);
}
}
CmsContent cmsContent = cmsContentService.getCmsContentByMaterialId(materialId);
if (ObjectUtil.notNull(cmsContent)) {
// throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA,
// CheckedExceptionResult.NULL_PARAM, "没有找到对应的教材通知信息");
cmsContentService.updateCmsContent(new CmsContent(cmsContent.getId(), true, false, Const.CMS_AUTHOR_STATUS_2, // authUserId
0L, // 为0代表系统审核
DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime())));
}
count = materialService.updateMaterial(new Material(materialId, true), sessionId);
return count;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class MaterialServiceImpl method updateMaterial.
@Override
public String updateMaterial(Long id, String sessionId) throws CheckedServiceException {
Material material = materialDao.getMaterialById(id);
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (pmphUser.getIsAdmin() || pmphUser.getId().equals(material.getDirector()) || pmphUser.getId().equals(material.getFounderId())) {
List<Textbook> list = textbookService.getTextbookByMaterialId(id);
for (Textbook textbook : list) {
PmphGroup group = pmphGroupService.getPmphGroupByTextbookId(textbook.getId());
if (ObjectUtil.notNull(group)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您在" + textbook.getTextbookName() + "书籍下还有未解散的小组,请先解散小组");
}
}
material = new Material();
material.setId(id);
material.setIsDeleted(true);
materialDao.updateMaterial(material);
cmsContentService.updateCmsContentByMaterialId(id);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您没有删除教材" + material.getMaterialName() + "的权限");
}
return "SUCCESS";
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class MaterialServiceImpl method upTempFile.
@Override
public List<String> upTempFile(HttpServletRequest request, MultipartFile[] files) throws CheckedServiceException, IOException {
String sessionId = CookiesUtil.getSessionId(request);
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户没有登录!");
}
if (null == files || files.length == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "没有文件");
}
for (MultipartFile file : files) {
if (file.getOriginalFilename().length() > 80) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "附件名称超出80个字符长度,请修改后上传!");
}
}
List<String> filsRelativePaths = new ArrayList<String>(files.length);
for (MultipartFile file : files) {
UUID uuid = UUID.randomUUID();
String tempFileId = uuid.toString();
request.getSession(false).setAttribute("fileName_" + tempFileId, file.getOriginalFilename());
byte[] fileByte = file.getBytes();
request.getSession(false).setAttribute(tempFileId, fileByte);
filsRelativePaths.add(tempFileId);
}
return filsRelativePaths;
}
Aggregations