use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class MaterialServiceImpl method updateMaterial.
/**
* 通过主键id更新material 不为null 的字段
*
* @param Material
* @return 影响行数
* @throws CheckedServiceException
*/
@Override
public Integer updateMaterial(Material material, String sessionId) throws CheckedServiceException {
if (null == material.getId()) {
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 (!pmphUser.getIsAdmin()) {
// throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL,
// CheckedExceptionResult.ILLEGAL_PARAM,
// "该用户没有操作权限");
// }
// 教材权限的检查
List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
Integer power = null;
// 系统管理员权限检查
for (PmphRole pmphRole : pmphRoles) {
if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
// 我是系统管理原
power = 1;
}
}
// 教材主任检查
Material materialDirector = materialService.getMaterialById(material.getId());
if (null == power) {
if (null != materialDirector && null != materialDirector.getDirector() && pmphUser.getId().equals(materialDirector.getDirector())) {
// 我是教材的主任
power = 2;
}
}
return materialDao.updateMaterial(material);
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class MaterialServiceImpl method getMaterialMainInfoById.
@Override
public MaterialMainInfoVO getMaterialMainInfoById(Long materialId, String sessionId) throws CheckedServiceException {
// 验证用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
// 教材权限的检查
List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
// 下面进行授权
Integer projectEditorPowers = 0;
Integer role = 0;
// 系统管理员权限检查
for (PmphRole pmphRole : pmphRoles) {
if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
// 我是系统管理原
// "11111111";
projectEditorPowers = 255;
role = 1;
}
}
// 教材主任检查
Material material = this.getMaterialById(materialId);
if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
// 我是教材的主任
projectEditorPowers = 255;
role = (0 == role.intValue() ? 2 : role);
}
// 教材项目编辑检查
List<MaterialProjectEditorVO> materialProjectEditors = materialProjectEditorService.listMaterialProjectEditors(materialId);
if (null != materialProjectEditors && materialProjectEditors.size() > 0) {
for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditors) {
if (null != materialProjectEditor && null != materialProjectEditor.getEditorId() && materialProjectEditor.getEditorId().equals(pmphUser.getId())) {
// 我是教材的项目编辑
projectEditorPowers = (projectEditorPowers | material.getProjectPermission());
role = (0 == role.intValue() ? 3 : role);
}
}
}
// 教材策划编辑检查
Integer num = this.getPlanningEditorSum(materialId, pmphUser.getId());
if (null != num && num.intValue() > 0) {
// 我是教材的策划编辑编辑
projectEditorPowers = (projectEditorPowers | material.getPlanPermission());
role = (0 == role.intValue() ? 4 : role);
}
MaterialMainInfoVO materialMainInfoVO = new MaterialMainInfoVO(materialId, material.getMaterialName(), material.getIsPublished(), material.getIsAllTextbookPublished(), material.getIsForceEnd(), material.getIsDeleted(), StringUtil.tentToBinary(projectEditorPowers), role);
return materialMainInfoVO;
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class SystemMessageService method sendWhenSubmitDeclarationForm.
/**
* 作家教材申报表 给学校管理员发送或者人卫教材相关人员发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午4:31:19
* @param declarationId
* 申报id
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenSubmitDeclarationForm(Long declarationId) throws CheckedServiceException, IOException {
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(declarationId);
if (null == declaration) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "申报表不存在");
}
if (null == declaration.getOrgId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
Material material = materialService.getMaterialById(declaration.getMaterialId());
if (declaration.getOrgId() == 0) {
// 提交的人卫社
// 项目编辑 策划编辑 主任 id
String msgContent = "[<font color='red'>" + declaration.getRealname() + "</font>]提交了《<font color='red'>" + material.getMaterialName() + "</font>》申报表,请及时进行资料审核";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 主任id
Long directorId = material.getDirector();
// 项目编辑列表
List<MaterialProjectEditorVO> materialProjectEditorList = materialProjectEditorService.listMaterialProjectEditors(material.getId());
// 批量保存的消息集合
List<UserMessage> userMessageList = new ArrayList<UserMessage>(materialProjectEditorList.size() + 1);
List<String> userIds = new ArrayList<String>(materialProjectEditorList.size() + 1);
userMessageList.add(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), directorId, new Short("1"), null));
userIds.add("1_" + directorId);
for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditorList) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), materialProjectEditor.getEditorId(), new Short("1"), null);
userMessageList.add(userMessage);
userIds.add("1_" + materialProjectEditor.getEditorId());
}
// 策划编辑
// 我申报的书籍
List<DecPosition> decPositionList = decPositionService.listDecPositions(declarationId);
for (DecPosition decPosition : decPositionList) {
Textbook textbook = textbookService.getTextbookById(decPosition.getTextbookId());
if (null != textbook && null != textbook.getPlanningEditor()) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), textbook.getPlanningEditor(), new Short("1"), null);
userMessageList.add(userMessage);
userIds.add("1_" + textbook.getPlanningEditor());
}
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
} else {
// 提交的机构
String msgContent = "贵校老师[<font color='red'>" + declaration.getRealname() + "</font>]提交了《<font color='red'>" + material.getMaterialName() + "</font>》申报表,请及时进行资料审核、打印并快递申报纸质表";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 获取机构用户
List<Long> orgIds = new ArrayList<Long>(1);
orgIds.add(declaration.getOrgId());
List<OrgUser> orgUserList = orgUserService.getOrgUserListByOrgIds(orgIds);
List<UserMessage> userMessageList = new ArrayList<UserMessage>(orgUserList.size());
List<String> userIds = new ArrayList<String>(orgUserList.size());
for (OrgUser orgUser : orgUserList) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), null);
userMessageList.add(userMessage);
userIds.add("3_" + orgUser.getId());
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class SystemMessageService method sendWhenConfirmFirstEditor.
/**
* 遴选主编副主编时点击发布按钮之后向主编、副主编发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午1:57:04
* @param bookId
* 教材书籍id
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenConfirmFirstEditor(Long bookId, List<DecPositionPublished> newMessage) throws CheckedServiceException, IOException {
// 获取教材书籍
Textbook textbook = textbookService.getTextbookById(bookId);
if (textbook.getIsPublished()) {
sendWhenPubfinalResult(bookId, newMessage);
return;
}
// 获取教材
Material material = materialService.getMaterialById(textbook.getMaterialId());
if (null == material) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "该书籍没有找到对应的教材");
}
// 获取这本书的申报遴选列表
for (DecPositionPublished decPosition : newMessage) {
if (null != decPosition && null != decPosition.getChosenPosition() && null != decPosition.getRank()) {
// 筛选出主编、副主编
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
// 消息内容
String msgContent = "";
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 12) {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的第一主编和数字编委,您现在可以开始遴选编委了,最终结果以遴选结果公告为准";
} else {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的第一主编,您现在可以开始遴选编委了,最终结果以遴选结果公告为准";
}
} else {
if (decPosition.getChosenPosition() == 12) {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的主编与数字编委,最终结果以遴选结果公告为准";
} else {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的主编,最终结果以遴选结果公告为准";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 10) {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的副主编和数字编委,最终结果以遴选结果公告为准";
} else {
msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的副主编,最终结果以遴选结果公告为准";
}
}
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null);
userMessageService.addUserMessage(userMessage);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class SystemMessageService method sendWhenDeclarationFormAudit.
/**
* 教材申报表审核 向作家用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午4:42:14
* @param declarationId
* 申报id
* @param isPass
* true 通过/false 退回
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenDeclarationFormAudit(Long declarationId, boolean isPass, String returnCause) throws CheckedServiceException, IOException {
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(declarationId);
if (null == declaration) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "申报表不存在");
}
if (null == declaration.getOrgId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
// 获取教材
Material material = materialService.getMaterialById(declaration.getMaterialId());
String msgContent = "";
if (declaration.getOrgId() == 0) {
// 提交的人卫社
msgContent = "抱歉,您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>出版社</font>]退回,退回原因:" + returnCause + ",请您核对后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表已通过[<font color='red'>出版社</font>]审核";
}
} else {
// 提交的机构
msgContent = "抱歉,您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>学校管理员</font>]退回,退回原因:" + returnCause + ",请您核对后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表已通过[<font color='red'>学校管理员</font>]审核";
}
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 发送消息
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null));
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
Aggregations