use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class TextbookServiceImpl method updateTextbooks.
@Override
public Integer updateTextbooks(Long[] ids, String sessionId) {
// 获取当前用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
// }
if (null == ids) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
}
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, "还未确认编委,不能名单确认");
}
}
}
Integer count = 0;
if (CollectionUtil.isNotEmpty(textbooks)) {
count = textbookDao.updateTextbooks(textbooks);
}
return count;
}
use of com.bc.pmpheep.back.po.Textbook 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.Textbook 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.Textbook in project pmph by BCSquad.
the class Front method run.
@Override
public synchronized void run() {
System.out.println("线程开始");
String src = this.getClass().getResource("/").getPath();
src = src.substring(1);
if (!src.endsWith(File.separator)) {
src += File.separator;
}
ZipDownload zipDownload = new ZipDownload();
List<DeclarationEtcBO> declarationEtcBOs = new ArrayList<>();
List<DeclarationOrDisplayVO> declarationOrDisplayVOs = this.declarationService.getDeclarationOrDisplayVOByRealname(this.decIds);
String dest = src + this.id;
zipDownload.setId(this.id);
zipDownload.setState(0);
zipDownload.setMaterialName(declarationOrDisplayVOs.get(0).getOrgNameOne());
zipDownload.setDetail("loading...");
zipDownload.setCreateTime(DateUtil.getCurrentTime());
Const.WORD_EXPORT_MAP.put(this.id, zipDownload);
try {
declarationEtcBOs = this.declarationService.getDeclarationOrDisplayVOByIdOrRealname(this.decIds);
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException e) {
logger.warn("数据表格化的时候失败");
}
try {
List<DeclarationEtcBO> list = new ArrayList<>();
for (int i = 0; i < declarationOrDisplayVOs.size(); i++) {
Material material = this.materialService.getMaterialById(declarationOrDisplayVOs.get(i).getMaterialId());
StringBuilder str = new StringBuilder();
str.append(material.getIsEduExpUsed() ? "1" : "0");
str.append(material.getIsWorkExpUsed() ? "1" : "0");
str.append(material.getIsTeachExpUsed() ? "1" : "0");
str.append(material.getIsAchievementUsed() ? "1" : "0");
str.append(material.getIsAcadeUsed() ? "1" : "0");
str.append(material.getIsLastPositionUsed() ? "1" : "0");
str.append(material.getIsNationalPlanUsed() ? "1" : "0");
str.append(material.getIsPmphTextbookUsed() ? "1" : "0");
str.append(material.getIsTextbookUsed() ? "1" : "0");
str.append(material.getIsMoocDigitalUsed() ? "1" : "0");
str.append(material.getIsCourseUsed() ? "1" : "0");
str.append(material.getIsResearchUsed() ? "1" : "0");
str.append(material.getIsMonographUsed() ? "1" : "0");
str.append(material.getIsPublishRewardUsed() ? "1" : "0");
str.append(material.getIsSciUsed() ? "1" : "0");
str.append(material.getIsClinicalRewardUsed() ? "1" : "0");
str.append(material.getIsAcadeRewardUsed() ? "1" : "0");
str.append(material.getIsIntentionUsed() ? "1" : "0");
Integer filter = Integer.parseInt(str.toString(), 2);
List<Textbook> textbooks = this.textbookService.getTextbookByMaterialId(material.getId());
String name = declarationOrDisplayVOs.get(i).getRealname() + "-" + material.getMaterialName();
for (DeclarationEtcBO declarationEtcBO : declarationEtcBOs) {
for (DeclarationEtcBO etcBO : declarationEtcBOs) {
if (declarationEtcBO.getRealname().equals(etcBO.getRealname()) && !declarationEtcBO.getTextbookName().contains(etcBO.getTextbookName().get(0))) {
declarationEtcBO.getTextbookName().add(etcBO.getTextbookName().get(0));
declarationEtcBO.getPresetPosition().add(etcBO.getPresetPosition().get(0));
}
}
if (declarationOrDisplayVOs.get(i).getRealname().equals(declarationEtcBO.getRealname())) {
list.add(declarationEtcBO);
}
}
if (!CollectionUtil.isEmpty(list)) {
StringBuilder sb = new StringBuilder();
sb.append(src);
sb.append(this.id);
sb.append(File.separator);
sb.append(declarationOrDisplayVOs.get(i).getOrgNameOne());
sb.append(File.separator);
sb.append(name);
sb.append(File.separator);
this.wordHelper.export(material.getMaterialName(), sb.toString(), list, str.toString(), this.materialExtensionService.getMaterialExtensionByMaterialId(material.getId()));
list.removeAll(list);
}
}
} catch (Exception e) {
e.printStackTrace();
}
new Thread(zipDownload).start();
try {
this.zipHelper.zip(dest + File.separator + declarationOrDisplayVOs.get(0).getOrgNameOne(), dest + File.separator, true, null);
} catch (Exception e) {
e.getMessage();
}
zipDownload.setState(1);
zipDownload.setDetail("/zip/download?id=" + this.id);
Const.WORD_EXPORT_MAP.put(this.id, zipDownload);
}
use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class SpringThread method run.
@Override
public synchronized void run() {
// System.out.println("线程开始");
String src = this.getClass().getResource("/").getPath();
src = src.substring(1);
if (!src.endsWith(File.separator)) {
src += File.separator;
}
ZipDownload zipDownload = new ZipDownload();
Material material = this.materialService.getMaterialById(this.materialId);
StringBuilder str = new StringBuilder();
str.append(material.getIsEduExpUsed() ? "1" : "0");
str.append(material.getIsWorkExpUsed() ? "1" : "0");
str.append(material.getIsTeachExpUsed() ? "1" : "0");
str.append(material.getIsAchievementUsed() ? "1" : "0");
str.append(material.getIsAcadeUsed() ? "1" : "0");
str.append(material.getIsLastPositionUsed() ? "1" : "0");
str.append(material.getIsNationalPlanUsed() ? "1" : "0");
str.append(material.getIsPmphTextbookUsed() ? "1" : "0");
str.append(material.getIsTextbookUsed() ? "1" : "0");
str.append(material.getIsMoocDigitalUsed() ? "1" : "0");
str.append(material.getIsCourseUsed() ? "1" : "0");
str.append(material.getIsResearchUsed() ? "1" : "0");
str.append(material.getIsMonographUsed() ? "1" : "0");
str.append(material.getIsPublishRewardUsed() ? "1" : "0");
str.append(material.getIsSciUsed() ? "1" : "0");
str.append(material.getIsClinicalRewardUsed() ? "1" : "0");
str.append(material.getIsAcadeRewardUsed() ? "1" : "0");
str.append(material.getIsIntentionUsed() ? "1" : "0");
Integer filter = Integer.parseInt(str.toString(), 2);
List<Textbook> textbooks = this.textbookService.getTextbookByMaterialId(this.materialId);
List<DeclarationEtcBO> declarationEtcBOs = new ArrayList<>();
String dest = src + this.id;
zipDownload.setId(this.id);
zipDownload.setMaterialName(material.getMaterialName());
zipDownload.setState(0);
zipDownload.setDetail("loading...");
zipDownload.setCreateTime(DateUtil.getCurrentTime());
Const.WORD_EXPORT_MAP.put(this.id, zipDownload);
try {
declarationEtcBOs = this.declarationService.declarationEtcBO(this.materialId, this.textBookids, this.realname, this.position, this.title, this.orgName, this.unitName, this.positionType, this.onlineProgress, this.offlineProgress);
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException e) {
logger.warn("数据表格化的时候失败");
}
try {
List<DeclarationEtcBO> list = new ArrayList<>();
for (int i = 0; i < textbooks.size(); i++) {
String textbookName = textbooks.get(i).getTextbookName() + "第" + textbooks.get(i).getTextbookRound() + "版";
for (DeclarationEtcBO declarationEtcBO : declarationEtcBOs) {
for (DeclarationEtcBO etcBO : declarationEtcBOs) {
if (declarationEtcBO.getRealname().equals(etcBO.getRealname()) && !declarationEtcBO.getTextbookName().contains(etcBO.getTextbookName().get(0))) {
declarationEtcBO.getTextbookName().add(etcBO.getTextbookName().get(0));
declarationEtcBO.getPresetPosition().add(etcBO.getPresetPosition().get(0));
}
}
if (textbookName.equals(declarationEtcBO.getTextbookName().get(0))) {
list.add(declarationEtcBO);
}
}
if (!CollectionUtil.isEmpty(list)) {
StringBuilder sb = new StringBuilder();
sb.append(src);
sb.append(this.id);
sb.append(File.separator);
sb.append(material.getMaterialName());
sb.append(File.separator);
sb.append((i + 1) + "." + textbookName);
sb.append(File.separator);
this.wordHelper.export(material.getMaterialName(), sb.toString(), list, str.toString(), this.materialExtensionService.getMaterialExtensionByMaterialId(this.materialId));
list.removeAll(list);
}
}
} catch (Exception e) {
e.printStackTrace();
}
new Thread(zipDownload).start();
try {
this.zipHelper.zip(dest + File.separator + material.getMaterialName(), dest + File.separator, true, null);
} catch (Exception e) {
e.getMessage();
}
zipDownload.setState(1);
zipDownload.setDetail("/zip/download?id=" + this.id);
Const.WORD_EXPORT_MAP.put(this.id, zipDownload);
}
Aggregations