Search in sources :

Example 1 with DecWorkExp

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

the class WordHelper method fillDecWorkExpData.

private XWPFTable fillDecWorkExpData(XWPFTable table, List<DecWorkExp> decWorkExps) {
    if (CollectionUtil.isEmpty(decWorkExps)) {
        return table;
    }
    if (decWorkExps.size() > 1) {
        int height = table.getRow(1).getHeight();
        for (int i = 1; i < decWorkExps.size(); i++) {
            table.createRow().setHeight(height);
        }
    }
    List<XWPFTableRow> rows = table.getRows();
    List<XWPFTableCell> cells;
    int rowCount = 1;
    for (DecWorkExp decWorkExp : decWorkExps) {
        cells = rows.get(rowCount).getTableCells();
        String dateBegin = decWorkExp.getDateBegin();
        if (StringUtil.isEmpty(dateBegin)) {
            dateBegin = "未知";
        }
        String dateEnd = decWorkExp.getDateEnd();
        if (StringUtil.isEmpty(dateEnd)) {
            dateEnd = "至今";
        }
        String value = dateBegin.concat("~").concat(dateEnd);
        cells.get(0).setText(value);
        value = decWorkExp.getOrgName();
        if (StringUtil.notEmpty(value)) {
            cells.get(1).setText(value);
        }
        value = decWorkExp.getPosition();
        if (StringUtil.notEmpty(value)) {
            cells.get(2).setText(value);
        }
        value = decWorkExp.getNote();
        if (StringUtil.notEmpty(value)) {
            cells.get(3).setText(value);
        }
        for (XWPFTableCell cell : cells) {
            cell.setVerticalAlignment(XWPFVertAlign.CENTER);
        }
        rowCount++;
    }
    return table;
}
Also used : XWPFTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell) DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) XWPFTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow)

Example 2 with DecWorkExp

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

the class DecWorkExpServiceTest method testGetDecWorkExp.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetDecWorkExp() {
    long id = add().getId();
    DecWorkExp decWorkExp = decWorkExpService.getDecWorkExpById(id);
    Assert.assertNotNull("作家工作经历信息获取失败", decWorkExp);
}
Also used : DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 3 with DecWorkExp

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

the class MigrationStageSix method decWorkExp.

/**
 * 作家工作经历表
 */
protected void decWorkExp() {
    // 要迁移的旧库表名
    String tableName = "writer_work";
    // 增加new_pk字段
    JdbcHelper.addColumn(tableName);
    String sql = "select w.workid,w.workunitname,w.position,w.remark,w.startstopdate,w.enddate," + "wd.new_pk id " + "from writer_work w " + "left join writer_declaration wd on wd.writerid=w.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("workid");
        // 申报表id
        Long declarationid = (Long) map.get("id");
        // 工作单位
        String orgName = (String) map.get("workunitname");
        // 职位
        String position = (String) map.get("position");
        DecWorkExp decWorkExp = new DecWorkExp();
        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;
        }
        decWorkExp.setDeclarationId(declarationid);
        decWorkExp.setOrgName(orgName);
        decWorkExp.setPosition(position);
        // 备注
        decWorkExp.setNote((String) map.get("remark"));
        // 起始时间
        Timestamp startstopDate = (Timestamp) map.get("startstopdate");
        if (null != startstopDate) {
            decWorkExp.setDateBegin(sdf.format(startstopDate));
        } else {
            decWorkExp.setDateBegin("未知");
        }
        // 终止时间
        Timestamp endDate = (Timestamp) map.get("enddate");
        if (null != endDate) {
            if (endDate.getTime() >= split.getTime() || endDate.getTime() == blank.getTime()) {
                decWorkExp.setDateEnd("至今");
            } else {
                decWorkExp.setDateEnd(sdf.format(endDate));
            }
        } else {
            decWorkExp.setDateEnd("至今");
        }
        // 显示顺序
        decWorkExp.setSort(999);
        decWorkExp = decWorkExpService.addDecWorkExp(decWorkExp);
        long pk = decWorkExp.getId();
        JdbcHelper.updateNewPrimaryKey(tableName, pk, "workid", id);
        count++;
        if (null == map.get("exception")) {
            correctCount++;
        }
    }
    if (excel.size() > 0) {
        try {
            excelHelper.exportFromMaps(excel, "作家工作经历表", "dec_work_exp");
        } catch (IOException ex) {
            logger.error("异常数据导出到Excel失败", ex);
        }
    }
    if (correctCount != maps.size()) {
        result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "dec_work_exp");
        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_work表迁移完成,异常条目数量:{}", 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) IOException(java.io.IOException) Timestamp(java.sql.Timestamp) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with DecWorkExp

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

the class ExcelHelper method fillDecWorkExpData.

private ColumnProperties fillDecWorkExpData(List<DecWorkExp> decWorkExps, Row row, ColumnProperties properties) {
    int colCount = properties.getColCount();
    int[] maxLength = properties.getMaxLength();
    if (CollectionUtil.isEmpty(decWorkExps)) {
        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 (DecWorkExp decWorkExp : decWorkExps) {
            if (isFirst == false) {
                for (StringBuilder builder : builders) {
                    builder.append("\r\n");
                }
            } else {
                isFirst = false;
            }
            int index = 0;
            String dateBegin = decWorkExp.getDateBegin();
            String dateEnd = decWorkExp.getDateEnd();
            if (StringUtil.isEmpty(dateBegin)) {
                dateBegin = " ";
            }
            if (StringUtil.isEmpty(dateEnd)) {
                dateEnd = "至今";
            }
            value = dateBegin.concat(" ~ ").concat(dateEnd);
            builders.get(index++).append(value);
            if (value.length() / 2 + 1 > maxLength[colCount]) {
                maxLength[colCount] = value.length() / 2 + 1;
            }
            colCount++;
            value = decWorkExp.getOrgName();
            if (StringUtil.isEmpty(value)) {
                value = "";
            }
            builders.get(index++).append(value);
            if (value.length() > maxLength[colCount]) {
                maxLength[colCount] = value.length();
            }
            colCount++;
            value = decWorkExp.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) DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) Cell(org.apache.poi.ss.usermodel.Cell)

Example 5 with DecWorkExp

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

the class DeclarationServiceImpl method getDeclarationEtcBOs.

@Override
public List<DeclarationEtcBO> getDeclarationEtcBOs(Long materialId) {
    List<DeclarationEtcBO> declarationEtcBOs = new ArrayList<>(20);
    List<Declaration> declarations = declarationDao.getDeclarationByMaterialId(materialId);
    if (CollectionUtil.isEmpty(declarations)) {
        return null;
    }
    int count = 1;
    for (Declaration declaration : declarations) {
        // 学习经历
        ArrayList<DecEduExp> decEduExps = (ArrayList<DecEduExp>) decEduExpDao.getListDecEduExpByDeclarationId(declaration.getId());
        // 工作经历
        ArrayList<DecWorkExp> decWorkExps = (ArrayList<DecWorkExp>) decWorkExpDao.getListDecWorkExpByDeclarationId(declaration.getId());
        // 教学经历
        ArrayList<DecTeachExp> decTeachExps = (ArrayList<DecTeachExp>) decTeachExpDao.getListDecTeachExpByDeclarationId(declaration.getId());
        // 兼职学术
        ArrayList<DecAcade> decAcades = (ArrayList<DecAcade>) decAcadeDao.getListDecAcadeByDeclarationId(declaration.getId());
        // 上套教材
        ArrayList<DecLastPosition> decLastPositions = (ArrayList<DecLastPosition>) decLastPositionDao.getListDecLastPositionByDeclarationId(declaration.getId());
        // 精品课程建设情况
        ArrayList<DecCourseConstruction> decCourseConstructions = (ArrayList<DecCourseConstruction>) decCourseConstructionDao.getDecCourseConstructionByDeclarationId(declaration.getId());
        // 主编国家级规划
        ArrayList<DecNationalPlan> decNationalPlans = (ArrayList<DecNationalPlan>) decNationalPlanDao.getListDecNationalPlanByDeclarationId(declaration.getId());
        // 教材编写
        ArrayList<DecTextbook> decTextbooks = (ArrayList<DecTextbook>) decTextbookDao.getListDecTextbookByDeclarationId(declaration.getId());
        // 作家科研
        ArrayList<DecResearch> decResearchs = (ArrayList<DecResearch>) decResearchDao.getListDecResearchByDeclarationId(declaration.getId());
        /*
			 * ArrayList<DecAchievement> decAchievements = (ArrayList<DecAchievement>)
			 * decAchievementDao .getDecAchievementByDeclarationId(declaration.getId());
			 */
        DeclarationEtcBO declarationEtcBO = new DeclarationEtcBO();
        declarationEtcBO.setRealname("欧阳望月".concat(String.valueOf(count)));
        declarationEtcBO.setUsername("Smith");
        // declarationEtcBO.setTextbookName("人体解剖学与组织胚胎学");
        // declarationEtcBO.setPresetPosition("副主编");
        declarationEtcBO.setChosenOrgName("人民卫生出版社");
        declarationEtcBO.setSex("女");
        declarationEtcBO.setBirthday("1975年11月22日");
        declarationEtcBO.setAddress("浙江省金华市婺城区婺州街1188号");
        declarationEtcBO.setExperience(23);
        declarationEtcBO.setOrgName("金华职业技术学院医学院");
        declarationEtcBO.setPosition("教师");
        declarationEtcBO.setTitle("教授");
        declarationEtcBO.setPostcode("321017");
        declarationEtcBO.setHandphone("13857989881");
        declarationEtcBO.setEmail("test10001test@163.com");
        declarationEtcBO.setFax("01065930013");
        declarationEtcBO.setTelephone("010-65930013");
        declarationEtcBO.setDecEduExps(decEduExps);
        declarationEtcBO.setDecWorkExps(decWorkExps);
        declarationEtcBO.setDecTeachExps(decTeachExps);
        declarationEtcBO.setDecAcades(decAcades);
        declarationEtcBO.setDecLastPositions(decLastPositions);
        declarationEtcBO.setDecCourseConstructions(decCourseConstructions);
        declarationEtcBO.setDecNationalPlans(decNationalPlans);
        declarationEtcBO.setDecTextbooks(decTextbooks);
        declarationEtcBO.setDecResearchs(decResearchs);
        // declarationEtcBO.setDecAchievement(decAchievements.get(0));
        declarationEtcBOs.add(declarationEtcBO);
        count++;
        if (count > 21) {
            break;
        }
    }
    return declarationEtcBOs;
}
Also used : DecTextbook(com.bc.pmpheep.back.po.DecTextbook) DecLastPosition(com.bc.pmpheep.back.po.DecLastPosition) ArrayList(java.util.ArrayList) DecAcade(com.bc.pmpheep.back.po.DecAcade) DecEduExp(com.bc.pmpheep.back.po.DecEduExp) DecCourseConstruction(com.bc.pmpheep.back.po.DecCourseConstruction) DeclarationEtcBO(com.bc.pmpheep.back.bo.DeclarationEtcBO) Declaration(com.bc.pmpheep.back.po.Declaration) DecTeachExp(com.bc.pmpheep.back.po.DecTeachExp) DecWorkExp(com.bc.pmpheep.back.po.DecWorkExp) DecResearch(com.bc.pmpheep.back.po.DecResearch) DecNationalPlan(com.bc.pmpheep.back.po.DecNationalPlan)

Aggregations

DecWorkExp (com.bc.pmpheep.back.po.DecWorkExp)12 DecAcade (com.bc.pmpheep.back.po.DecAcade)5 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 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