use of com.bc.pmpheep.back.po.DecPosition in project pmph by BCSquad.
the class DecPositionServiceImpl method saveBooks.
@Override
public long saveBooks(DecPositionVO decPositionVO, HttpServletRequest request) throws IOException {
List<NewDecPosition> list = decPositionVO.getList();
if (CollectionUtil.isEmpty(list)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "添加内容不能为空");
}
List<DecPosition> istDecPositions = decPositionDao.listDecPositions(list.get(0).getDeclarationId());
if (CollectionUtil.isEmpty(istDecPositions)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "内容不能为空");
}
String newId = ",";
for (NewDecPosition newDecPosition : list) {
// 遍历所有的id
newId += newDecPosition.getId() + ",";
}
for (DecPosition DecPosition : istDecPositions) {
// 遍历原数据
if (!newId.contains("," + DecPosition.getId() + ",")) {
if (ObjectUtil.notNull(DecPosition.getId())) {
decPositionDao.deleteDecPosition(DecPosition.getId());
}
}
}
for (NewDecPosition newDecPosition : list) {
Long id = newDecPosition.getId();
Long declarationId = newDecPosition.getDeclarationId();
Long textbookId = newDecPosition.getTextbookId();
String file = newDecPosition.getFile();
String showPosition = newDecPosition.getShowPosition();
DecPosition decPosition = new DecPosition();
if ("编委".equals(showPosition)) {
decPosition.setPresetPosition(1);
} else if ("副主编".equals(showPosition)) {
decPosition.setPresetPosition(2);
} else if ("副主编,编委".equals(showPosition)) {
decPosition.setPresetPosition(3);
} else if ("主编".equals(showPosition)) {
decPosition.setPresetPosition(4);
} else if ("主编,编委".equals(showPosition)) {
decPosition.setPresetPosition(5);
} else if ("主编,副主编".equals(showPosition)) {
decPosition.setPresetPosition(6);
} else if ("主编,副主编,编委".equals(showPosition)) {
decPosition.setPresetPosition(7);
} else if ("数字编委".equals(showPosition)) {
decPosition.setPresetPosition(8);
} else if ("编委,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(9);
} else if ("副主编,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(10);
} else if ("副主编,编委,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(11);
} else if ("主编,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(12);
} else if ("主编,编委,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(13);
} else if ("主编,副主编,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(14);
} else if ("主编,副主编,编委,数字编委".equals(showPosition)) {
decPosition.setPresetPosition(15);
}
File files = null;
String fileName = null;
if (StringUtil.isEmpty(file)) {
decPosition.setSyllabusId(null);
decPosition.setSyllabusName(null);
} else {
files = new File(file);
if (files.exists()) {
// 获取原文件名字
fileName = files.getName();
decPosition.setSyllabusName(fileName);
} else {
decPosition.setSyllabusId(null);
decPosition.setSyllabusName(null);
}
}
decPosition.setDeclarationId(declarationId);
decPosition.setTextbookId(textbookId);
decPosition.setId(id);
if (ObjectUtil.isNull(id)) {
// 保存或者修改
decPositionDao.addDecPosition(decPosition);
String fileNames = null;
String mongoId = null;
if (ObjectUtil.notNull(decPosition.getId()) && StringUtil.notEmpty(file)) {
// mongoId = fileService.saveLocalFile(files, FileType.SYLLABUS,
// decPosition.getId());
byte[] fileByte = (byte[]) request.getSession(false).getAttribute(file);
fileNames = (String) request.getSession(false).getAttribute("fileName_" + file);
InputStream input = new ByteArrayInputStream(fileByte);
mongoId = fileService.save(input, fileNames, FileType.SYLLABUS, decPosition.getId());
if (StringUtil.isEmpty(mongoId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.FILE_UPLOAD_FAILED, "文件上传失败!");
}
}
if (StringUtil.notEmpty(mongoId)) {
decPosition.setSyllabusId(mongoId);
decPosition.setSyllabusName(fileNames);
decPositionDao.updateDecPosition(decPosition);
}
} else {
decPositionDao.updateDecPosition(decPosition);
}
}
return list.size();
}
use of com.bc.pmpheep.back.po.DecPosition 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.back.po.DecPosition 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.DecPosition in project pmph by BCSquad.
the class TextbookLogServiceImpl method addTextbookLog.
@Override
public void addTextbookLog(List<DecPosition> oldlist, Long textbookId, Long updaterId, int userType) throws CheckedServiceException {
if (null == textbookId) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "书籍为空!");
}
if (null == updaterId) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "修改者为空!");
}
List<DecPosition> newlist = decPositionService.listChosenDecPositionsByTextbookId(textbookId);
int addSumZhuBian = 0;
StringBuilder addZhuBian = new StringBuilder("");
int redSumZhuBian = 0;
StringBuilder redZhuBian = new StringBuilder("");
int addSumFuZhuBian = 0;
StringBuilder addFuZhuBian = new StringBuilder("");
int redSumFuZhuBian = 0;
StringBuilder redFuZhuBian = new StringBuilder("");
int addSumBianWei = 0;
StringBuilder addBianWei = new StringBuilder("");
int redSumBianWei = 0;
StringBuilder redBianWei = new StringBuilder("");
int addSumShuZiBianWei = 0;
StringBuilder addShuZiBianWei = new StringBuilder("");
int redSumShuZiBianWei = 0;
StringBuilder redShuZiBianWei = new StringBuilder("");
// 新旧申报的id
List<Long> ids = new ArrayList<>(oldlist.size() + newlist.size());
for (DecPosition oldDecPosition : oldlist) {
ids.add(oldDecPosition.getDeclarationId());
}
for (DecPosition newDecPosition : newlist) {
ids.add(newDecPosition.getDeclarationId());
}
List<Declaration> declarations = declarationService.getDeclarationByIds(ids);
// 增加的
for (DecPosition newDecPosition : newlist) {
// 申报者
Long declarationId = newDecPosition.getDeclarationId();
// 新的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 新选的职位
Integer newChosenPosition = newDecPosition.getChosenPosition();
// 是否是新增
boolean isAdd = true;
// 遍历出所有的旧的信息
for (DecPosition oldDecPosition : oldlist) {
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
isAdd = false;
break;
}
}
if (isAdd) {
// 新增的主编
if (null != newChosenPosition && (newChosenPosition == 4 || newChosenPosition == 12)) {
addSumZhuBian++;
addZhuBian.append("," + declaration.getRealname());
}
// 新增的副主编
if (null != newChosenPosition && (newChosenPosition == 2 || newChosenPosition == 10)) {
addSumFuZhuBian++;
addFuZhuBian.append("," + declaration.getRealname());
}
// 新增的编委
if (null != newChosenPosition && (newChosenPosition == 1 || newChosenPosition == 9)) {
addSumBianWei++;
addBianWei.append("," + declaration.getRealname());
}
// 新增的数字编委
if (null != newChosenPosition && (newChosenPosition == 8 || newChosenPosition == 12 || newChosenPosition == 10 || newChosenPosition == 9)) {
addSumShuZiBianWei++;
addShuZiBianWei.append("," + declaration.getRealname());
}
}
}
// 减少的
for (DecPosition oldDecPosition : oldlist) {
// 申报者
Long declarationId = oldDecPosition.getDeclarationId();
// 老的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 老的的职位
Integer oldChosenPosition = oldDecPosition.getChosenPosition();
// 是否删除
boolean isDel = true;
// 遍历出所有新的信息
for (DecPosition newDecPosition : newlist) {
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
isDel = false;
break;
}
}
if (isDel) {
// 移除了主编
if (null != oldChosenPosition && (oldChosenPosition == 4 || oldChosenPosition == 12)) {
redSumZhuBian++;
redZhuBian.append("," + declaration.getRealname());
}
// 移除了副主编
if (null != oldChosenPosition && (oldChosenPosition == 2 || oldChosenPosition == 10)) {
redSumFuZhuBian++;
redFuZhuBian.append("," + declaration.getRealname());
}
// 移除了编委
if (null != oldChosenPosition && (oldChosenPosition == 1 || oldChosenPosition == 9)) {
redSumBianWei++;
redBianWei.append("," + declaration.getRealname());
}
// 移除了编委
if (null != oldChosenPosition && (oldChosenPosition == 8 || oldChosenPosition == 12 || oldChosenPosition == 10 || oldChosenPosition == 9)) {
redSumShuZiBianWei++;
redShuZiBianWei.append("," + declaration.getRealname());
}
}
}
// 职位被修改的
StringBuilder updateString = new StringBuilder("");
boolean allUpdate = false;
for (DecPosition newDecPosition : newlist) {
// 申报者
Long declarationId = newDecPosition.getDeclarationId();
// 新的申报表
Declaration declaration = new Declaration();
for (Declaration tempDeclaration : declarations) {
if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
declaration = tempDeclaration;
break;
}
}
// 新选的职位
Integer newChosenPosition = newDecPosition.getChosenPosition();
Integer newRank = newDecPosition.getRank();
newRank = newRank == null ? 0 : newRank;
// 是否是新增
boolean isUpdate = false;
// 遍历出所有的旧的信息
for (DecPosition oldDecPosition : oldlist) {
Integer oldChosenPosition = oldDecPosition.getChosenPosition();
Integer oldRank = oldDecPosition.getRank();
oldRank = oldRank == null ? 0 : oldRank;
// 修改的是职位或者排序 都算
if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue() && !(newChosenPosition.intValue() == oldChosenPosition.intValue() && newRank.intValue() == oldRank.intValue())) {
isUpdate = true;
break;
}
}
if (isUpdate) {
allUpdate = true;
updateString.append("," + declaration.getRealname());
}
}
// 遍历错误信息
if (addSumZhuBian > 0 || redSumZhuBian > 0 || addSumFuZhuBian > 0 || redSumFuZhuBian > 0 || addSumBianWei > 0 || redSumBianWei > 0 || addSumShuZiBianWei > 0 || redSumShuZiBianWei > 0 || allUpdate) {
StringBuilder detail = new StringBuilder("");
if (redSumZhuBian > 0) {
detail.append("移除了" + redSumZhuBian + "位主编:[" + redZhuBian.toString().substring(1) + "];");
}
if (redSumFuZhuBian > 0) {
detail.append("移除了" + redSumFuZhuBian + "位副主编:[" + redFuZhuBian.toString().substring(1) + "];");
}
if (redSumBianWei > 0) {
detail.append("移除了" + redSumBianWei + "位编委:[" + redBianWei.toString().substring(1) + "];");
}
if (redSumShuZiBianWei > 0) {
detail.append("移除了" + redSumShuZiBianWei + "位数字编辑:[" + redShuZiBianWei.toString().substring(1) + "];");
}
if (addSumZhuBian > 0) {
detail.append("增加了" + addSumZhuBian + "位主编:[" + addZhuBian.toString().substring(1) + "];");
}
if (addSumFuZhuBian > 0) {
detail.append("增加了" + addSumFuZhuBian + "位副主编:[" + addFuZhuBian.toString().substring(1) + "];");
}
if (addSumBianWei > 0) {
detail.append("增加了" + addSumBianWei + "位编委:[" + addBianWei.toString().substring(1) + "];");
}
if (addSumShuZiBianWei > 0) {
detail.append("增加了" + addSumShuZiBianWei + "位数字编辑:[" + addShuZiBianWei.toString().substring(1) + "];");
}
if (allUpdate) {
detail.append("修改了:[" + updateString.toString().substring(1) + "]的职位信息;");
}
String detail2 = detail.toString();
// 去掉最后一个;
detail2 = detail2.substring(0, detail2.length() - 1);
TextbookLog textbookLog = new TextbookLog();
textbookLog.setDetail(detail2.length() >= 100 ? detail2.substring(0, 95) + "..." : detail2);
textbookLog.setIsPmphUpdater(userType == 1);
textbookLog.setTextbookId(textbookId);
textbookLog.setUpdaterId(updaterId);
textbookLogDao.addTextbookLog(textbookLog);
}
}
use of com.bc.pmpheep.back.po.DecPosition 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> 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);
/**
* 下面是发布更新最终结果表的数据
*/
// 获取这些书的申报者
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);
}
}
}
}
}
}
// 先删除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);
}
// 当教材遴选结束时给为遴选上的用户推送消息
Material material2 = materialService.getMaterialById(materialId);
if (ObjectUtil.notNull(material2)) {
if (material2.getIsAllTextbookPublished()) {
List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
systemMessageService.sendWhenPositionChooserLoss(materialId, declaration);
}
}
// 遍历被遴选人发送动态 和被修改成专家
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;
}
Aggregations