use of com.bc.pmpheep.back.po.DecPositionPublished in project pmph by BCSquad.
the class SystemMessageService method sendWhenPubfinalResult.
/**
* 某一本书的最终结果公布 或者 整套教材全部公布时 向当选者和学校管理员发送消息
*
* @author Mryang
* @createDate 2017年11月19日 上午11:24:31
* @param textBookId
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenPubfinalResult(Long textBookId, List<DecPositionPublished> decPositionPublishedLst) throws CheckedServiceException, IOException {
Textbook textbook = textbookService.getTextbookById(textBookId);
Material material = materialService.getMaterialById(textbook.getMaterialId());
// 给主编、副主编、编委、数字编委发送
String msg = "";
for (DecPositionPublished decPosition : decPositionPublishedLst) {
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (null != decPosition.getRank() && decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的第一主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的副主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || 9 == decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 1) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的编委";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的编委、数字编委";
}
}
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
// 存入消息主体
Message message = new Message(msg);
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, msg, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
// 给学校管理员发送消息
if (material.getIsAllTextbookPublished()) {
// 所有都发布了
String orgMsg = "《<font color='red'>" + material.getMaterialName() + "</font>》的编写团队遴选已结束,贵校共[{sum}]位老师当选,名单如下:";
// 根据教材Id查询对应的书籍集合
List<Textbook> textbooks = textbookService.getTextbookByMaterialId(material.getId());
List<Long> bookIds = new ArrayList<Long>();
for (Textbook book : textbooks) {
bookIds.add(book.getId());
}
// 根据书籍获取当选了该书籍的人员所属机构
List<Org> orgs = orgService.listBeElectedOrgByBookIds(bookIds);
for (Org org : orgs) {
// 根据orgid和bookid获取该机构某些已公布的书的申报职位
List<DecPosition> decPositions = decPositionService.listDecPositionsByTextbookIdAndOrgid(bookIds, org.getId());
if (null != decPositions && decPositions.size() > 0) {
String msgContent = orgMsg;
int sum = 0;
for (int i = 0; i < decPositions.size(); i++) {
DecPosition decPosition = decPositions.get(i);
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
msgContent += "</br>" + "[<font color='red'>" + declaration.getRealname() + "</font>]";
msgContent += " - " + textbookService.getTextbookById(decPosition.getTextbookId()).getTextbookName() + " - ";
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msgContent += "数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msgContent += "第一主编";
} else {
msgContent += "第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msgContent += "主编";
} else {
msgContent += "主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msgContent += "副主编";
} else {
msgContent += "副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || decPosition.getChosenPosition() == 9) {
if (decPosition.getChosenPosition() == 1) {
msgContent += "编委";
} else {
msgContent += "编委、数字编委";
}
}
}
sum++;
}
msgContent.replace("{sum}", String.valueOf(sum));
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 获取机构管理员
OrgUser orgUser = orgUserService.getOrgUserByOrgId(org.getId());
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), 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("3_" + orgUser.getId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
// 《全国高等学校五年制临床医学专业第九轮规划教材》的编写团队遴选已结束,贵校共[5]位老师当选,名单如下:
// [丁志国] - 局部解剖学 - 第一主编
// [王海滨] - 医学影像学 - 第二主编
// [雷国华] - 医学计算机应用 - 副主编
// [孙风梅] - 医学文献检索与论文写作 - 编委
// [宋守君] - 医患沟通 - 编委
} else {
String orgMsg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,贵校老师";
// 《全国高等学校五年制临床医学专业第九轮规划教材》[传染病学]的最终结果已公布,贵校老师[丁志国]当选第一主编,[丁志国]当选第一主编,[丁志国]当选第一主编
// 先要将学校分队
List<Long> bookIds = new ArrayList<Long>();
bookIds.add(textBookId);
// 根据教材Id查询对应的书籍集合
List<Org> orgs = orgService.listBeElectedOrgByBookIds(bookIds);
for (Org org : orgs) {
// 根据orgid和bookid获取该机构某些已公布的书的申报职位
List<DecPosition> decPositions = decPositionService.listDecPositionsByTextbookIdAndOrgid(bookIds, org.getId());
if (null != decPositions && decPositions.size() > 0) {
// 拼装消息
String msgContent = orgMsg;
for (int i = 0; i < decPositions.size(); i++) {
DecPosition decPosition = decPositions.get(i);
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
if (i > 0) {
msgContent += ",";
}
msgContent += "[<font color='red'>" + declaration.getRealname() + "</font>]当选";
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msgContent += "数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msgContent += "第一主编";
} else {
msgContent += "第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msgContent += "主编";
} else {
msgContent += "主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msgContent += "副主编";
} else {
msgContent += "副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || decPosition.getChosenPosition() == 9) {
if (decPosition.getChosenPosition() == 1) {
msgContent += "编委";
} else {
msgContent += "编委、数字编委";
}
}
}
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 获取机构管理员
OrgUser orgUser = orgUserService.getOrgUserByOrgId(org.getId());
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), 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("3_" + orgUser.getId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
}
}
use of com.bc.pmpheep.back.po.DecPositionPublished in project pmph by BCSquad.
the class TextbookServiceImpl method updateTextbookAndMaterial.
@Override
public Integer updateTextbookAndMaterial(Long[] ids, String sessionId, Long materialId) throws CheckedServiceException, Exception {
// 获取当前用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
// if (!pmphUser.getIsAdmin()) {
// throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
// 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 material = materialService.getMaterialById(materialId);
if (null == power) {
if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
// 我是教材的主任
power = 2;
}
}
List<Textbook> textbooks = textbookDao.getTextbooks(ids);
if (textbooks.size() > 0) {
for (Textbook textbook : textbooks) {
// 是否存在策划编辑
if (ObjectUtil.isNull(textbook.getPlanningEditor())) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未选择策划编辑,不能进行公布");
}
// 是否发布主编
if (!textbook.getIsChiefPublished()) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未发布主编/副主编,不能进行公布");
}
List<DecPosition> decMainPosition = decPositionService.getMainDecPositionByTextbookId(textbook.getId());
// 确认是否有主编副主编
if (decMainPosition.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未遴选主编/副主编,不能进行公布");
}
// textbookDao.
List<DecPosition> decPosition = decPositionService.getDecPositionByTextbookId(textbook.getId());
// 是否确认编委
if (decPosition.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未确认编委,不能进行公布");
}
}
}
Material materials = new Material();
List<Long> textBookIds = new ArrayList<>(textbooks.size());
for (Textbook textbook : textbooks) {
// if(Const.TRUE==textbook.getIsPublished()){
// throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK,
// CheckedExceptionResult.ILLEGAL_PARAM,"名单已确认");
// }
// if(textbook.getIsPublished()) {
Textbook textbook2 = new Textbook(textbook.getId(), textbook.getRevisionTimes().intValue() + 1).setIsPublished(true);
textbook2.setRevisionTimes(textbook.getRevisionTimes().intValue() + 1);
textbookDao.updateTextbook(textbook2);
// }else {
// Textbook textbook2 = new Textbook(textbook.getId(), 0).setIsPublished(true);
// textbook2.setRevisionTimes(0) ;
// textbookDao.updateTextbook(textbook2);
// }
materials.setId(textbook.getMaterialId());
textBookIds.add(textbook.getId());
}
// textbookDao.updateBookPublished(textBooks);
// textbookDao.updateTextbook(textbook);
/*下面是向主任、项目编辑、策划编辑 发送企业微信推送*/
// 向列表中书籍的主任、项目编辑、策划编辑,发送微信推送,内容拼接如下
localMethodToLeaderWXMsg(pmphUser, textbooks, "结果公布");
/**
* 下面是发布更新最终结果表的数据
*/
// 获取这些书的申报者
List<DecPosition> lst = decPositionService.listDecPositionsByTextBookIds(textBookIds);
// 这些书的被遴选者
List<DecPositionPublished> decPositionPublishedLst = new ArrayList<DecPositionPublished>(lst.size());
for (DecPosition decPosition : lst) {
if (null == decPosition || null == decPosition.getChosenPosition() || decPosition.getChosenPosition() <= 0) {
continue;
}
DecPositionPublished decPositionPublished = new DecPositionPublished();
decPositionPublished.setPublisherId(pmphUser.getId());
decPositionPublished.setDeclarationId(decPosition.getDeclarationId());
decPositionPublished.setTextbookId(decPosition.getTextbookId());
decPositionPublished.setPresetPosition(decPosition.getPresetPosition());
decPositionPublished.setIsOnList(true);
decPositionPublished.setChosenPosition(decPosition.getChosenPosition());
decPositionPublished.setRank(decPosition.getRank());
decPositionPublished.setSyllabusId(decPosition.getSyllabusId());
decPositionPublished.setSyllabusName(decPosition.getSyllabusName());
decPositionPublishedLst.add(decPositionPublished);
}
List<DecPositionPublished> olds = decPositionPublishedService.getDecPositionPublishedListByBookIds(textBookIds);
List<DecPositionPublished> sends = new ArrayList<>();
for (DecPositionPublished now : decPositionPublishedLst) {
if (ObjectUtil.notNull(now.getRank())) {
sends.add(now);
} else {
DecPositionPublished published = decPositionPublishedService.getDecPositionByDeclarationId(now.getDeclarationId(), now.getTextbookId());
if (ObjectUtil.isNull(published)) {
sends.add(now);
}
for (DecPositionPublished old : olds) {
if (old.getDeclarationId().equals(now.getDeclarationId()) && old.getTextbookId().equals(now.getTextbookId())) {
if (!old.getChosenPosition().equals(now.getChosenPosition())) {
sends.add(now);
} else {
if (null == now.getRank() && null == now.getRank()) {
} else if (null != now.getRank() && null != now.getRank()) {
if (!now.getRank().equals(now.getRank())) {
sends.add(now);
}
} else {
sends.add(now);
}
}
}
}
}
}
// 被撤销的职位的人发动态
for (DecPositionPublished old : olds) {
// 初始化 是否被撤销
boolean isDismissed = true;
// 初始化 被撤销的职位
int dismissPosition = old.getChosenPosition();
for (DecPositionPublished now : decPositionPublishedLst) {
if (old.getDeclarationId().equals(now.getDeclarationId()) && old.getTextbookId().equals(now.getTextbookId())) {
isDismissed = false;
// 被撤销的职务数字 = 原职务数字 按位与 (新职务数字 按位取反) [即原本有现在没有的]
dismissPosition = old.getChosenPosition() & (~now.getChosenPosition());
}
}
if (isDismissed) {
// 撤销需要发动态的,从此处打开
// 转换为文字
String dismissPositionStr = "";
if ((dismissPosition & 4) > 0) {
dismissPositionStr += "主编";
}
if ((dismissPosition & 2) > 0) {
dismissPositionStr += "副主编";
}
if ((dismissPosition & 1) > 0) {
dismissPositionStr += "编委";
}
if ((dismissPosition & 8) > 0) {
if (dismissPositionStr.length() > 0) {
dismissPositionStr += ",";
}
dismissPositionStr += "数字编委";
}
if (dismissPositionStr.length() > 0) {
// 若存在被撤销的职务 发动态给相应作者
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(old.getWriterUserId());
// 自己可见
writerUserTrendst.setIsPublic(false);
writerUserTrendst.setType(8);
String detail = "";
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", CheckedExceptionBusiness.MATERIAL);
// map.put("content", "抱歉,您《" + old.getTextbookName() + "》的"+dismissPositionStr+"职务已被取消。");
map.put("content", "您参加的教材“" + material.getMaterialName() + "”的《" + old.getTextbookName() + "》遴选已结束。");
map.put("img", 2);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(materialId);
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
}
}
// 先删除dec_position_published表中的所有数据
decPositionPublishedService.deleteDecPositionPublishedByBookIds(textBookIds);
// 向dec_position_published插入新数据
decPositionPublishedService.batchInsertDecPositionPublished(decPositionPublishedLst);
/**
* 发布更新最终结果表的数据 ---end ---
*/
// List<Textbook> books = materialDao.getMaterialAndTextbook(materials);
List<Textbook> books = textbookService.getTextbookByMaterialId(materials.getId());
Integer count = 0;
/* 通过遍历查看教材下面所有书籍是否公布,当数据全部公布则该教材改为最终公布 */
for (Textbook book : books) {
if (book.getIsPublished()) {
count++;
}
}
if (count == books.size()) {
// 检查有没有再次公布
PageResult<BookPositionVO> listBookPosition = this.listBookPosition(1, 9999999, null, null, null, materials.getId(), sessionId);
boolean haveNo = true;
for (BookPositionVO bookPositionVO : listBookPosition.getRows()) {
if (bookPositionVO.getIsPublished() && bookPositionVO.getRepub()) {
haveNo = false;
break;
}
}
if (haveNo) {
count = materialDao.updateMaterialPublished(materials);
}
}
// 发送消息
for (Textbook textbook : textbooks) {
systemMessageService.sendWhenPubfinalResult(textbook.getId(), sends, pmphUser);
}
// 当教材遴选结束时给为遴选上的用户推送消息
Material material2 = materialService.getMaterialById(materialId);
if (ObjectUtil.notNull(material2)) {
if (material2.getIsAllTextbookPublished()) {
List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
systemMessageService.sendWhenPositionChooserLoss(materialId, declaration, pmphUser);
if (null != declaration && declaration.size() > 0) {
for (Declaration d : declaration) {
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(d.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", "教材已遴选结束,很遗憾,您未入选");
map.put("img", 2);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(materialId);
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
}
}
}
// 遍历被遴选人发送动态 和被修改成专家
for (DecPositionPublished decPositionPublished : decPositionPublishedLst) {
if (null == decPositionPublished || null == decPositionPublished.getChosenPosition() || decPositionPublished.getChosenPosition() <= 0) {
continue;
}
// 获取申报表
Declaration declarationById = declarationService.getDeclarationById(decPositionPublished.getDeclarationId());
// 修改成专家
WriterUser writerUser = new WriterUser();
writerUser.setId(declarationById.getUserId());
writerUser.setIsExpert(true);
writerUser.setRank(3);
writerUserService.update(writerUser);
// 获取书籍
Textbook textbook = textbookService.getTextbookById(decPositionPublished.getTextbookId());
// 作家遴选
String showChosenPosition = "";
if (decPositionPublished.getChosenPosition() != 0) {
switch(decPositionPublished.getChosenPosition()) {
case 1:
showChosenPosition = "编委";
break;
case 2:
showChosenPosition = "副主编";
break;
case 3:
showChosenPosition = "副主编,编委";
break;
case 4:
showChosenPosition = "主编";
break;
case 5:
showChosenPosition = "主编,编委";
break;
case 6:
showChosenPosition = "主编,副主编";
break;
case 7:
showChosenPosition = "主编,副主编,编委";
break;
case 8:
showChosenPosition = "数字编委";
break;
case 9:
showChosenPosition = "编委,数字编委";
break;
case 10:
showChosenPosition = "副主编,数字编委";
break;
case 11:
showChosenPosition = "副主编,编委,数字编委";
break;
case 12:
showChosenPosition = "主编,数字编委";
break;
case 13:
showChosenPosition = "主编,编委,数字编委";
break;
case 14:
showChosenPosition = "主编,副主编,数字编委";
break;
case 15:
showChosenPosition = "主编,副主编,编委,数字编委";
break;
default:
break;
}
}
// 添加动态信息
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(declarationById.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", "您已被遴选为《" + textbook.getTextbookName() + "》的" + showChosenPosition + "。");
map.put("img", 1);
detail = new Gson().toJson(map);
writerUserTrendst.setDetail(detail);
writerUserTrendst.setCmsContentId(null);
writerUserTrendst.setBookId(declarationById.getMaterialId());
writerUserTrendst.setBookCommentId(null);
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
return count;
}
use of com.bc.pmpheep.back.po.DecPositionPublished in project pmph by BCSquad.
the class WriterUserServiceImpl method getListexpertUser.
@Override
public PageResult<WriterUserManagerVO> getListexpertUser(PageParameter<WriterUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
String name = pageParameter.getParameter().getName();
if (StringUtil.notEmpty(name)) {
pageParameter.getParameter().setName(name);
}
String orgName = pageParameter.getParameter().getOrgName();
if (StringUtil.notEmpty(orgName)) {
pageParameter.getParameter().setOrgName(orgName);
}
if (!ObjectUtil.isNull(groupId)) {
pageParameter.getParameter().setGroupId(groupId);
}
PageResult<WriterUserManagerVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
// 当rank为1的时候 查询教师用户
int total = 0;
if (pageParameter.getParameter().getRank() == null || pageParameter.getParameter().getRank() != 1) {
// 当rank不为1的时候
total = writerUserDao.getListexpertUserTotal(pageParameter);
if (total > 0) {
List<WriterUserManagerVO> list = writerUserDao.getListexpertUser(pageParameter);
for (int i = 0; i < list.size(); i++) {
WriterUserManagerVO vo = list.get(i);
String title = vo.getTitle();
if (title != null) {
if (ObjectUtil.isNumber(title)) {
vo.setTitle(dataDictionaryDao.getDataDictionaryItemNameByCode(Const.WRITER_USER_TITLE, title));
}
}
switch(vo.getRank()) {
case 0:
vo.setRankName("普通用户");
break;
case 1:
vo.setRankName("教师用户");
break;
case 2:
vo.setRankName("作家用户");
break;
case 3:
vo.setRankName("专家用户");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
}
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
} else {
total = writerUserDao.getLsitisTeacherTotal(pageParameter);
if (total > 0) {
List<WriterUserManagerVO> list = writerUserDao.getLsitisTeacher(pageParameter);
for (int i = 0; i < list.size(); i++) {
WriterUserManagerVO vo = list.get(i);
String voS = com.alibaba.fastjson.JSON.toJSONString(vo).replaceAll("-", "");
vo = com.alibaba.fastjson.JSON.parseObject(voS, WriterUserManagerVO.class);
list.remove(i);
list.add(i, vo);
switch(vo.getRank()) {
case 0:
vo.setRankName("普通用户");
break;
case 1:
vo.setRankName("教师用户");
break;
case 2:
vo.setRankName("作家用户");
break;
case 3:
vo.setRankName("专家用户");
break;
default:
throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
}
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
}
// 设置职位
if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
// 清空职位
for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
writerUserManagerVO.setPosition("无");
}
// 设置职位
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
Long bookId = pmphGroup.getBookId();
if (null != bookId && bookId.intValue() > 0) {
// 查询这本书的发布职位
List<DecPositionPublished> publisheds = decPositionPublishedService.getDecPositionPublishedListByBookId(bookId);
if (null != publisheds && publisheds.size() > 0) {
Map<Long, String> userIdsAndPostions = new HashMap<Long, String>();
for (DecPositionPublished published : publisheds) {
Declaration declaration = declarationService.getDeclarationById(published.getDeclarationId());
String postiton = "无";
if (published.getChosenPosition().intValue() == 4 && null != published.getRank() && published.getRank() == 1) {
postiton = "主编(第一主编)";
} else if (published.getChosenPosition().intValue() == 4) {
postiton = "主编";
} else if (published.getChosenPosition().intValue() == 12 && null != published.getRank() && published.getRank() == 1) {
postiton = "主编(第一主编),数字编委";
} else if (published.getChosenPosition().intValue() == 12) {
postiton = "主编,数字编委";
} else if (published.getChosenPosition().intValue() == 2) {
postiton = "副主编";
} else if (published.getChosenPosition().intValue() == 10) {
postiton = "副主编,数字编委";
} else if (published.getChosenPosition().intValue() == 1) {
postiton = "编委";
} else if (published.getChosenPosition().intValue() == 9) {
postiton = "编委,数字编委";
}
userIdsAndPostions.put(declaration.getUserId(), postiton);
}
for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
String postion = userIdsAndPostions.get(writerUserManagerVO.getId());
if (null != postion) {
writerUserManagerVO.setPosition(postion);
}
}
}
}
}
// 设置职位 end
return pageResult;
}
use of com.bc.pmpheep.back.po.DecPositionPublished 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);
/* if (org.springframework.util.StringUtils.isEmpty(decPositions.get(0).getRank())) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL,
CheckedExceptionResult.NULL_PARAM, "排序不能为空");
}*/
// 编委遴选界面 (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) {
HashMap<String, Object> paraMap = new HashMap<>();
paraMap.put("declarationId", decPosition.getDeclarationId());
String declarationlCreateDate = declarationDao.findDeclarationCreateDate(paraMap);
Date date1 = DateUtil.fomatDate(declarationlCreateDate == null ? "2019-04-13 12:00" : declarationlCreateDate);
Date date = DateUtil.fomatDate("2019-04-12 12:00");
// 筛选出遴选上的主编副主编人员
Integer chosenPosition = decPosition.getChosenPosition();
if (date1.getTime() > date.getTime()) {
if (null != chosenPosition && (chosenPosition == 1 || chosenPosition == 2)) {
decPositionPublisheds.add(new DecPositionPublished(pmphUser.getId(), decPosition.getDeclarationId(), textbookId, decPosition.getPresetPosition(), chosenPosition, decPosition.getRank(), decPosition.getSyllabusId(), decPosition.getSyllabusName()));
}
} else {
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) {
HashMap<String, Object> paraMap = new HashMap<>();
paraMap.put("declarationId", item.getDeclarationId());
String declarationlCreateDate = declarationDao.findDeclarationCreateDate(paraMap);
Date date1 = DateUtil.fomatDate(declarationlCreateDate);
Date date = DateUtil.fomatDate("2019-04-12 12:00");
// 编委 | 数字编委
if (date1.getTime() > date.getTime()) {
if (item.getChosenPosition() == 3) {
// item.setChosenPosition(item.getChosenPosition() > 8
// ?(item.getChosenPosition()-8):item.getChosenPosition() );
addNew.add(item);
}
} else {
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) {
HashMap<String, Object> paraMap = new HashMap<>();
paraMap.put("declarationId", itemadd.getDeclarationId());
String declarationlCreateDate = declarationDao.findDeclarationCreateDate(paraMap);
Date date1 = DateUtil.fomatDate(declarationlCreateDate);
Date date = DateUtil.fomatDate("2019-04-12 12:00");
if (itemadd.getDeclarationId().intValue() == item.getDeclarationId().intValue()) {
no = false;
if (date1.getTime() > date.getTime()) {
itemadd.setChosenPosition(item.getChosenPosition());
} else {
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, pmphUser);
}
}
}
return count;
}
use of com.bc.pmpheep.back.po.DecPositionPublished in project pmph by BCSquad.
the class DecPositionServiceImpl method batchPublishEditor.
@Override
public Integer batchPublishEditor(List<Long> textbookIds, String sessionId) throws CheckedServiceException, IOException {
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, "用户为空");
}
if (ObjectUtil.isNull(textbookIds)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "未选中书籍");
}
Integer count = 0;
for (Long textbookId : textbookIds) {
// 查询当前书籍已遴选的主编,副主编
List<DecPosition> listDecPositions = this.getEditorByTextbookId(textbookId);
if (CollectionUtil.isEmpty(listDecPositions)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "当前选中书籍还未遴选主编,副主编");
}
// DecPositionPublished对象集合
List<DecPositionPublished> decPositionPublisheds = new ArrayList<DecPositionPublished>(listDecPositions.size());
for (DecPosition decPosition : listDecPositions) {
decPositionPublisheds.add(new DecPositionPublished(pmphUser.getId(), decPosition.getDeclarationId(), textbookId, decPosition.getPresetPosition(), decPosition.getChosenPosition(), decPosition.getRank(), decPosition.getSyllabusId(), decPosition.getSyllabusName()));
}
// 删除已发布的主编,副主编
decPositionPublishedService.deletePublishedEditorByTextbookId(textbookId);
// 重新发布
// 再添加
decPositionPublishedService.batchInsertDecPositionPublished(decPositionPublisheds);
// 发布时更新textbook表中is_chief_published(是否已公布主编/副主编)字段
count = textbookService.updateTextbook(new Textbook(textbookId, true));
if (count > 0) {
// 发送消息
systemMessageService.sendWhenConfirmFirstEditor(textbookId, decPositionPublisheds, pmphUser);
}
}
return count;
}
Aggregations