Search in sources :

Example 1 with DecAcade

use of com.bc.pmpheep.back.po.DecAcade in project pmph by BCSquad.

the class WordHelper method fillDecAcadeData.

private XWPFTable fillDecAcadeData(XWPFTable table, List<DecAcade> decAcades) {
    if (CollectionUtil.isEmpty(decAcades)) {
        return table;
    }
    if (decAcades.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decAcades.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecAcade decAcade : decAcades) {
        cells = rows.get(rowCount).getTableCells();
        String value = decAcade.getOrgName();
        if (StringUtil.notEmpty(value)) {
            cells.get(0).setText(value);
        }
        // 1=国际/2=国家/3=省部/4=其他
        Integer rank = decAcade.getRank();
        if (null != rank) {
            switch(rank) {
                case 1:
                    value = "国际";
                    break;
                case 2:
                    value = "国家";
                    break;
                case 3:
                    value = "省部";
                    break;
                case 4:
                    value = "其他";
                    break;
                default:
                    value = "无";
                    break;
            }
            cells.get(1).setText(value);
        }
        value = decAcade.getPosition();
        if (StringUtil.notEmpty(value)) {
            cells.get(2).setText(value);
        }
        value = decAcade.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(3).setText(value);
        }
        for (XWPFTableCell cell : cells) {
            cell.setVerticalAlignment(XWPFVertAlign.CENTER);
        }
        rowCount++;
    }
    return table;
}
Also used : BigInteger(java.math.BigInteger) XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) DecAcade(com.bc.pmpheep.back.po.DecAcade) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 2 with DecAcade

use of com.bc.pmpheep.back.po.DecAcade in project pmph by BCSquad.

the class DecAcadeServiceTest method testGetDecAcade.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetDecAcade() {
    long id = add().getId();
    DecAcade decAcade = decAcadeService.getDecAcadeById(id);
    Assert.assertNotNull("作家兼职学术组织信息获取失败", decAcade);
}
Also used : DecAcade(com.bc.pmpheep.back.po.DecAcade) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 3 with DecAcade

use of com.bc.pmpheep.back.po.DecAcade in project pmph by BCSquad.

the class DecAcadeServiceTest method add.

private DecAcade add() {
    DecAcade decAcade = new DecAcade();
    decAcade.setDeclarationId(3L);
    decAcade.setOrgName("脑科学研究会");
    decAcade.setPosition("副会长");
    decAcade.setRank(3);
    decAcade.setNote("主管科研方向");
    decAcade.setSort(10);
    decAcadeService.addDecAcade(decAcade);
    DecAcade decAcade2 = new DecAcade(5L, "心理学研究会", 2, "副会长", "名誉主席", 12);
    decAcadeService.addDecAcade(decAcade2);
    DecAcade decAcade3 = new DecAcade(5L, "脑科学研究会", 3, "会员", "特邀成员", 14);
    decAcadeService.addDecAcade(decAcade3);
    return decAcade3;
}
Also used : DecAcade(com.bc.pmpheep.back.po.DecAcade)

Example 4 with DecAcade

use of com.bc.pmpheep.back.po.DecAcade in project pmph by BCSquad.

the class MigrationStageSix method decAcade.

/**
 * 作家兼职学术表
 */
protected void decAcade() {
    // 要迁移的旧库表名
    String tableName = "writer_acade";
    // 增加new_pk字段
    JdbcHelper.addColumn(tableName);
    String sql = "select wa.acadeid,wa.level,wa.duties,wa.organization,wa.remark," + "wd.new_pk id " + "from writer_acade wa " + "left join writer_declaration wd on wd.writerid=wa.writerid";
    // 取得该表中所有数据
    List<Map<String, Object>> maps = JdbcHelper.getJdbcTemplate().queryForList(sql);
    // 迁移成功的条目数
    int count = 0;
    int declarationidCount = 0;
    List<Map<String, Object>> excel = new LinkedList<>();
    Map<String, Object> result = new LinkedHashMap<>();
    int correctCount = 0;
    int[] state = { 0 };
    StringBuilder reason = new StringBuilder();
    StringBuilder dealWith = new StringBuilder();
    /* 开始遍历查询结果 */
    for (Map<String, Object> map : maps) {
        StringBuilder sb = new StringBuilder();
        // 旧表主键值
        String id = (String) map.get("acadeid");
        // 申报表id
        Long declarationid = (Long) map.get("id");
        // 级别
        String rankJudge = (String) map.get("level");
        // 职务
        String position = (String) map.get("duties");
        // 兼职学术组织
        String orgName = (String) map.get("organization");
        DecAcade decAcade = new DecAcade();
        if (ObjectUtil.isNull(declarationid) || declarationid.intValue() == 0) {
            map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("未找到申报表对应的关联结果。"));
            excel.add(map);
            logger.debug("未找到申报表对应的关联结果,此结果将被记录在Excel中");
            declarationidCount++;
            if (state[0] == 0) {
                reason.append("找不到对应的申报作家。");
                dealWith.append("放弃迁移。");
                state[0] = 1;
            }
            continue;
        }
        decAcade.setDeclarationId(declarationid);
        if ("nu".equals(rankJudge)) {
            decAcade.setRank(null);
        } else {
            if (StringUtil.isEmpty(rankJudge)) {
                decAcade.setRank(null);
            } else {
                Integer rank = Integer.parseInt(rankJudge);
                decAcade.setRank(rank);
            }
        }
        decAcade.setOrgName(orgName);
        decAcade.setPosition(position);
        // 备注
        decAcade.setNote((String) map.get("remark"));
        decAcade.setSort(999);
        decAcade = decAcadeService.addDecAcade(decAcade);
        long pk = decAcade.getId();
        JdbcHelper.updateNewPrimaryKey(tableName, pk, "acadeid", id);
        count++;
        if (null == map.get("exception")) {
            correctCount++;
        }
    }
    if (excel.size() > 0) {
        try {
            excelHelper.exportFromMaps(excel, "作家兼职学术表", "dec_acade");
        } catch (IOException ex) {
            logger.error("异常数据导出到Excel失败", ex);
        }
    }
    if (correctCount != maps.size()) {
        result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "dec_acade");
        result.put(SQLParameters.EXCEL_HEADER_DESCRIPTION, "作家兼职学术表");
        result.put(SQLParameters.EXCEL_HEADER_SUM_DATA, maps.size());
        result.put(SQLParameters.EXCEL_HEADER_MIGRATED_DATA, count);
        result.put(SQLParameters.EXCEL_HEADER_CORECT_DATA, correctCount);
        result.put(SQLParameters.EXCEL_HEADER_TRANSFERED_DATA, count - correctCount);
        result.put(SQLParameters.EXCEL_HEADER_NO_MIGRATED_DATA, maps.size() - count);
        result.put(SQLParameters.EXCEL_HEADER_EXCEPTION_REASON, reason.toString());
        result.put(SQLParameters.EXCEL_HEADER_DEAL_WITH, dealWith.toString());
        SQLParameters.STATISTICS_RESULT.add(result);
    }
    logger.info("未找到申报表对应的关联结果数量:{}", declarationidCount);
    logger.info("writer_acade表迁移完成,异常条目数量:{}", excel.size());
    logger.info("原数据库中共有{}条数据,迁移了{}条数据", maps.size(), count);
    // 记录信息
    Map<String, Object> msg = new HashMap<String, Object>();
    msg.put("result", "" + tableName + "  表迁移完成" + count + "/" + maps.size());
    SQLParameters.STATISTICS.add(msg);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DecAcade(com.bc.pmpheep.back.po.DecAcade) IOException(java.io.IOException) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with DecAcade

use of com.bc.pmpheep.back.po.DecAcade in project pmph by BCSquad.

the class ExcelHelper method fillDecAcadeData.

private ColumnProperties fillDecAcadeData(List<DecAcade> decAcades, Row row, ColumnProperties properties) {
    int colCount = properties.getColCount();
    int[] maxLength = properties.getMaxLength();
    if (CollectionUtil.isEmpty(decAcades)) {
        for (int i = 0; i < 3; i++) {
            row.createCell(colCount++);
        }
    } else {
        String value;
        List<StringBuilder> builders = new ArrayList<>(3);
        for (int i = 0; i < 3; i++) {
            builders.add(new StringBuilder());
        }
        boolean isFirst = true;
        for (DecAcade decAcade : decAcades) {
            if (isFirst == false) {
                for (StringBuilder builder : builders) {
                    builder.append("\r\n");
                }
            } else {
                isFirst = false;
            }
            int index = 0;
            value = decAcade.getOrgName();
            if (StringUtil.isEmpty(value)) {
                value = "";
            }
            builders.get(index++).append(value);
            if (value.length() > maxLength[colCount]) {
                maxLength[colCount] = value.length();
            }
            colCount++;
            value = "无";
            Integer rank = decAcade.getRank();
            if (ObjectUtil.isNull(rank)) {
                rank = 0;
            }
            switch(rank) {
                case 1:
                    value = "国际";
                    break;
                case 2:
                    value = "国家";
                    break;
                case 3:
                    value = "省部";
                    break;
                case 4:
                    value = "市级";
                    break;
                default:
                    break;
            }
            builders.get(index++).append(value);
            if (value.length() > maxLength[colCount]) {
                maxLength[colCount] = value.length();
            }
            colCount++;
            value = decAcade.getPosition();
            if (StringUtil.isEmpty(value)) {
                value = "";
            }
            builders.get(index++).append(value);
            if (value.length() > maxLength[colCount]) {
                maxLength[colCount] = value.length();
            }
            // 列数复位
            colCount = properties.getColCount();
        }
        for (int i = 0; i < 3; i++) {
            Cell cell = row.createCell(colCount++);
            value = builders.get(i).toString();
            cell.setCellValue(value);
        }
    }
    properties.setColCount(colCount);
    properties.setMaxLength(maxLength);
    return properties;
}
Also used : ArrayList(java.util.ArrayList) DecAcade(com.bc.pmpheep.back.po.DecAcade) Cell(org.apache.poi.ss.usermodel.Cell)

Aggregations

DecAcade (com.bc.pmpheep.back.po.DecAcade)12 DecCourseConstruction (com.bc.pmpheep.back.po.DecCourseConstruction)5 DecEduExp (com.bc.pmpheep.back.po.DecEduExp)5 DecLastPosition (com.bc.pmpheep.back.po.DecLastPosition)5 DecNationalPlan (com.bc.pmpheep.back.po.DecNationalPlan)5 DecResearch (com.bc.pmpheep.back.po.DecResearch)5 DecTeachExp (com.bc.pmpheep.back.po.DecTeachExp)5 DecTextbook (com.bc.pmpheep.back.po.DecTextbook)5 DecWorkExp (com.bc.pmpheep.back.po.DecWorkExp)5 ArrayList (java.util.ArrayList)5 DecAcadeReward (com.bc.pmpheep.back.po.DecAcadeReward)4 DecAchievement (com.bc.pmpheep.back.po.DecAchievement)4 DecClinicalReward (com.bc.pmpheep.back.po.DecClinicalReward)4 DecIntention (com.bc.pmpheep.back.po.DecIntention)4 DecMonograph (com.bc.pmpheep.back.po.DecMonograph)4 DecMoocDigital (com.bc.pmpheep.back.po.DecMoocDigital)4 DecPublishReward (com.bc.pmpheep.back.po.DecPublishReward)4 DecSci (com.bc.pmpheep.back.po.DecSci)4 DecTextbookPmph (com.bc.pmpheep.back.po.DecTextbookPmph)4 DecExtensionVO (com.bc.pmpheep.back.vo.DecExtensionVO)4