Search in sources :

Example 6 with DeclarationEtcBO

use of com.bc.pmpheep.back.bo.DeclarationEtcBO 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)

Example 7 with DeclarationEtcBO

use of com.bc.pmpheep.back.bo.DeclarationEtcBO in project pmph by BCSquad.

the class WordHelperTest method test.

@Test
@Ignore
public void test() throws CheckedServiceException, IllegalArgumentException, IllegalAccessException {
    List<DeclarationEtcBO> list = declarationService.declarationEtcBO(2L, null, null, null, null, null, null, null, null, null);
    Material material = materialService.getMaterialById(2L);
    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");
    String src = this.getClass().getResource("/").getPath();
    src = src.substring(1);
    if (!src.endsWith(File.separator)) {
        src += File.separator;
    }
    wordHelper.export("测试", src, list, str.toString(), materialExtensionService.getMaterialExtensionByMaterialId(2L));
}
Also used : DeclarationEtcBO(com.bc.pmpheep.back.bo.DeclarationEtcBO) Material(com.bc.pmpheep.back.po.Material) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Aggregations

DeclarationEtcBO (com.bc.pmpheep.back.bo.DeclarationEtcBO)7 ArrayList (java.util.ArrayList)5 DecAcade (com.bc.pmpheep.back.po.DecAcade)3 DecCourseConstruction (com.bc.pmpheep.back.po.DecCourseConstruction)3 DecEduExp (com.bc.pmpheep.back.po.DecEduExp)3 DecLastPosition (com.bc.pmpheep.back.po.DecLastPosition)3 DecNationalPlan (com.bc.pmpheep.back.po.DecNationalPlan)3 DecResearch (com.bc.pmpheep.back.po.DecResearch)3 DecTeachExp (com.bc.pmpheep.back.po.DecTeachExp)3 DecTextbook (com.bc.pmpheep.back.po.DecTextbook)3 DecWorkExp (com.bc.pmpheep.back.po.DecWorkExp)3 Material (com.bc.pmpheep.back.po.Material)3 DecExtensionVO (com.bc.pmpheep.back.vo.DecExtensionVO)3 DeclarationOrDisplayVO (com.bc.pmpheep.back.vo.DeclarationOrDisplayVO)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)3 DecAcadeReward (com.bc.pmpheep.back.po.DecAcadeReward)2 DecAchievement (com.bc.pmpheep.back.po.DecAchievement)2 DecClinicalReward (com.bc.pmpheep.back.po.DecClinicalReward)2 DecIntention (com.bc.pmpheep.back.po.DecIntention)2 DecMonograph (com.bc.pmpheep.back.po.DecMonograph)2