use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class FileDownLoadController method exportEditors.
/**
* 角色遴选 批量导出主编、副主编
*
* @param textbookIds
* @param request
* @param response
* @throws IllegalAccessException
*/
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "角色遴选 批量导出主编、副主编")
@RequestMapping(value = "/position/exportEditors", method = RequestMethod.GET)
public void exportEditors(Long[] textbookIds, HttpServletRequest request, HttpServletResponse response) throws IllegalAccessException, Exception {
List<DecPositionBO> list;
Workbook workbook = null;
try {
list = textbookService.getExcelDecByMaterialId(textbookIds);
workbook = excelHelper.fromDecPositionBOList(list, "主编-副主编");
} catch (CheckedServiceException | IllegalArgumentException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_CREATION_FAILED, "数据表格化的时候失败");
}
// 通过书籍id获取教材信息
Material material = materialService.getMaterialByName(textbookIds);
String fileName = returnFileName(request, material.getMaterialName() + ".xls");
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (Exception e) {
logger.warn("文件下载时出现IO异常:{}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class FileDownLoadController method exportSituationBook.
/**
* Description:申报情况统计页面按书名统计导出统计结果
*
* @author:lyc
* @date:2018年1月9日上午11:41:10
* @param
* @return void
*/
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报情况统计页面按书名统计导出统计结果")
@RequestMapping(value = "/result/exportSituationBook", method = RequestMethod.GET)
public void exportSituationBook(Long materialId, String bookName, HttpServletRequest request, HttpServletResponse response) {
PageParameter<DeclarationSituationBookResultVO> pageParameter = new PageParameter<>(1, 50000);
DeclarationSituationBookResultVO declarationSituationBookResultVO = new DeclarationSituationBookResultVO();
declarationSituationBookResultVO.setMaterialId(materialId);
declarationSituationBookResultVO.setBookName(bookName);
pageParameter.setParameter(declarationSituationBookResultVO);
Workbook workbook = null;
List<DeclarationSituationBookResultVO> list = null;
list = decPositionService.listDeclarationSituationBookResultVOs(pageParameter).getRows();
if (list.size() == 0) {
list.add(new DeclarationSituationBookResultVO());
}
try {
workbook = excelHelper.fromBusinessObjectList(list, "申报情况按书名统计");
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException e) {
logger.warn("数据表格化的时候失败");
}
Material material = materialService.getMaterialById(materialId);
String fileName = returnFileName(request, material.getMaterialName() + ".xls");
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (Exception e) {
logger.warn("文件下载时出现IO异常: {}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.back.po.Material 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.Material 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);
}
use of com.bc.pmpheep.back.po.Material in project pmph by BCSquad.
the class TextbookServiceImpl method listBookPosition.
@Override
public PageResult<BookPositionVO> listBookPosition(Integer pageNumber, Integer pageSize, Integer state, String textBookIds, String bookName, Long materialId, String sessionId) {
// 验证用户
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 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;
}
}
// 教材项目编辑检查
if (null == power) {
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())) {
// 我是教材的项目编辑
power = 3;
}
}
}
}
// 教材策划编辑检查
if (null == power) {
Integer num = materialService.getPlanningEditorSum(materialId, pmphUser.getId());
if (null != num && num > 0) {
// 我是教材的策划编辑编辑
power = 4;
}
}
if (null == power) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "该教材您没操作权限");
}
// 拼装复合参数
Map<String, Object> map = new HashMap<String, Object>();
// 教材id
map.put("materialId", materialId);
if (StringUtil.notEmpty(textBookIds)) {
Gson gson = new Gson();
List<Long> bookIds = gson.fromJson(textBookIds, new TypeToken<ArrayList<Long>>() {
}.getType());
if (null != bookIds && bookIds.size() > 0) {
// 书籍id
map.put("list", bookIds);
}
}
if (null != state && !state.equals(0)) {
// 书籍状态
map.put("state", state);
}
String bookNameTemp = StringUtil.toAllCheck(bookName);
if (null != bookNameTemp) {
// 书籍名称
map.put("bookName", bookNameTemp);
}
// 用户id
map.put("pmphUserId", pmphUser.getId());
// 用户id
map.put("power", power);
PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
PageResult<BookPositionVO> pageResult = new PageResult<>();
// 获取总数
Integer total = textbookDao.listBookPositionTotal(pageParameter);
if (null != total && total > 0) {
List<BookPositionVO> rows = textbookDao.listBookPosition(pageParameter);
// 下面进行授权
for (BookPositionVO row : rows) {
String rowpower = "000000";
if (power == 1 || power == 2) {
// 管理员或者主任
rowpower = "11111111";
} else if (power == 3) {
// 教材项目编辑
// 因为项目编辑的权限不是全部 ,因此要检查我是不是这本书的策划编辑,如果是 ,这本书我的权利就是项目编辑+策划编辑的权利
Integer tempProjectPermission = material.getProjectPermission();
if (null != row && null != row.getPlanningEditor() && null != pmphUser.getId() && row.getPlanningEditor().intValue() == pmphUser.getId().intValue()) {
// 我又是策划编辑
tempProjectPermission = (tempProjectPermission | material.getPlanPermission());
}
rowpower = StringUtil.tentToBinary(tempProjectPermission);
} else if (power == 4) {
// 教材策划编辑
rowpower = StringUtil.tentToBinary(material.getPlanPermission());
}
// 把权限拿出来一个个判断
// 分配策划编辑的权限
String s1 = rowpower.substring(0, 1);
String s2 = rowpower.substring(1, 2);
String s3 = rowpower.substring(2, 3);
String s4 = rowpower.substring(3, 4);
String s5 = rowpower.substring(4, 5);
String s6 = rowpower.substring(5, 6);
String s7 = rowpower.substring(6, 7);
// qiangzhijiesu
String s8 = rowpower.substring(7, 8);
if (material.getIsForceEnd() || material.getIsAllTextbookPublished()) {
// 教材结束或者强制结束
s2 = "0";
s3 = "0";
s4 = "0";
s5 = "0";
s6 = "0";
} else if (row.getIsLocked() || row.getIsPublished()) {
// 书籍已经发布了或者确认了名单
s2 = (power == 1 || power == 2) ? s2 : "0";
s3 = (power == 1 || power == 2) ? s3 : "0";
s4 = (power == 1 || power == 2) ? s4 : "0";
s5 = "0";
}
rowpower = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8;
row.setMyPower(rowpower);
}
pageResult.setRows(rows);
}
pageResult.setTotal(total);
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
return pageResult;
}
Aggregations