Search in sources :

Example 1 with ZipDownload

use of com.bc.pmpheep.general.bean.ZipDownload in project pmph by BCSquad.

the class FileDownLoadController method progress.

/**
 * 功能描述:查询进度
 *
 * @param id
 * @return
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "查询word打包进度")
@RequestMapping(value = "/word/progress", method = RequestMethod.GET)
public ZipDownload progress(String id) {
    ZipDownload zipDownload = new ZipDownload();
    if (Const.WORD_EXPORT_MAP.containsKey(id)) {
        zipDownload.setId(Const.WORD_EXPORT_MAP.get(id).getId());
        zipDownload.setState(Const.WORD_EXPORT_MAP.get(id).getState());
        zipDownload.setDetail(Const.WORD_EXPORT_MAP.get(id).getDetail());
        zipDownload.setCreateTime(Const.WORD_EXPORT_MAP.get(id).getCreateTime());
    }
    return zipDownload;
}
Also used : ZipDownload(com.bc.pmpheep.general.bean.ZipDownload) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ZipDownload

use of com.bc.pmpheep.general.bean.ZipDownload 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);
}
Also used : ZipDownload(com.bc.pmpheep.general.bean.ZipDownload) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DeclarationOrDisplayVO(com.bc.pmpheep.back.vo.DeclarationOrDisplayVO) DeclarationEtcBO(com.bc.pmpheep.back.bo.DeclarationEtcBO) Textbook(com.bc.pmpheep.back.po.Textbook)

Example 3 with ZipDownload

use of com.bc.pmpheep.general.bean.ZipDownload 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);
}
Also used : ZipDownload(com.bc.pmpheep.general.bean.ZipDownload) ArrayList(java.util.ArrayList) Material(com.bc.pmpheep.back.po.Material) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Textbook(com.bc.pmpheep.back.po.Textbook) DeclarationEtcBO(com.bc.pmpheep.back.bo.DeclarationEtcBO)

Aggregations

ZipDownload (com.bc.pmpheep.general.bean.ZipDownload)3 DeclarationEtcBO (com.bc.pmpheep.back.bo.DeclarationEtcBO)2 Material (com.bc.pmpheep.back.po.Material)2 Textbook (com.bc.pmpheep.back.po.Textbook)2 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 ArrayList (java.util.ArrayList)2 LogDetail (com.bc.pmpheep.annotation.LogDetail)1 DeclarationOrDisplayVO (com.bc.pmpheep.back.vo.DeclarationOrDisplayVO)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1