use of com.bc.pmpheep.back.po.DecCourseConstruction in project pmph by BCSquad.
the class WordHelper method fillDecCourseConstructionData.
private XWPFTable fillDecCourseConstructionData(XWPFTable table, List<DecCourseConstruction> decCourseConstructions) {
if (CollectionUtil.isEmpty(decCourseConstructions)) {
return table;
}
if (decCourseConstructions.size() > 1) {
int height = table.getRow(1).getHeight();
for (int i = 1; i < decCourseConstructions.size(); i++) {
table.createRow().setHeight(height);
}
}
List<XWPFTableRow> rows = table.getRows();
List<XWPFTableCell> cells;
int rowCount = 1;
for (DecCourseConstruction decCourseConstruction : decCourseConstructions) {
cells = rows.get(rowCount).getTableCells();
String value = decCourseConstruction.getCourseName();
if (StringUtil.notEmpty(value)) {
cells.get(0).setText(value);
}
// 1=国家/2=省部/3=学校
Integer type = decCourseConstruction.getType();
if (null != type) {
switch(type) {
case 1:
value = "国际";
break;
case 2:
value = "国家";
break;
case 3:
value = "省部";
break;
default:
value = "其他";
break;
}
cells.get(1).setText(value);
}
value = decCourseConstruction.getClassHour();
if (StringUtil.notEmpty(value)) {
cells.get(2).setText(value);
}
value = decCourseConstruction.getNote();
if (StringUtil.notEmpty(value)) {
cells.get(3).setText(value);
}
for (XWPFTableCell cell : cells) {
cell.setVerticalAlignment(XWPFVertAlign.CENTER);
}
rowCount++;
}
return table;
}
use of com.bc.pmpheep.back.po.DecCourseConstruction in project pmph by BCSquad.
the class DecCourseConstructionServiceTest method add.
private DecCourseConstruction add() {
DecCourseConstruction decCourseConstruction = new DecCourseConstruction();
decCourseConstruction.setDeclarationId(2L);
decCourseConstruction.setCourseName("神经内科学");
decCourseConstruction.setClassHour("72");
decCourseConstruction.setType(2);
decCourseConstruction.setNote("通识课");
decCourseConstruction.setSort(19);
decCourseConstructionService.addDecCourseConstruction(decCourseConstruction);
DecCourseConstruction decCourseConstruction2 = new DecCourseConstruction(3L, "咨询心理学", "36", 3, null, null);
decCourseConstructionService.addDecCourseConstruction(decCourseConstruction2);
DecCourseConstruction decCourseConstruction3 = new DecCourseConstruction(2L, "脑科学", "72", 1, null, 20);
decCourseConstructionService.addDecCourseConstruction(decCourseConstruction3);
return decCourseConstruction3;
}
use of com.bc.pmpheep.back.po.DecCourseConstruction in project pmph by BCSquad.
the class DecCourseConstructionServiceTest method testAddDecCourseConstruction.
@Test
@Rollback(Const.ISROLLBACK)
public void testAddDecCourseConstruction() {
DecCourseConstruction decCourseConstruction = new DecCourseConstruction(4L, "心理学史", "36", 2, "专业选修", null);
decCourseConstruction = decCourseConstructionService.addDecCourseConstruction(decCourseConstruction);
Assert.assertTrue("数据添加失败", decCourseConstruction.getId() > 0);
}
use of com.bc.pmpheep.back.po.DecCourseConstruction in project pmph by BCSquad.
the class DecCourseConstructionServiceTest method testGetDecCourseConstruction.
@Test
@Rollback(Const.ISROLLBACK)
public void testGetDecCourseConstruction() {
long id = add().getId();
DecCourseConstruction decCourseConstruction = decCourseConstructionService.getDecCourseConstructionById(id);
Assert.assertNotNull("获取作家精品课程建设情况信息失败", decCourseConstruction);
}
use of com.bc.pmpheep.back.po.DecCourseConstruction in project pmph by BCSquad.
the class MigrationStageSix method decCourseConstruction.
/**
* 作家精品课程建设情况表
*/
protected void decCourseConstruction() {
// 要迁移的旧库表名
String tableName = "writer_construction ";
// 增加new_pk字段
JdbcHelper.addColumn(tableName);
String sql = "select wc.constructionid,wc.curriculumname,wc.classhour,wc.type,wc.remark," + "wd.new_pk id " + "from writer_construction wc " + "left join writer_declaration wd on wd.writerid=wc.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("constructionid");
// 申报表id
Long declarationid = (Long) map.get("id");
// 课程名称
String courseName = (String) map.get("curriculumname");
// 课程全年课时数
String classHour = (String) map.get("classhour");
// 课程级别
String typeJudge = (String) map.get("type");
DecCourseConstruction decCourseConstruction = new DecCourseConstruction();
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;
}
decCourseConstruction.setDeclarationId(declarationid);
decCourseConstruction.setCourseName(courseName);
decCourseConstruction.setClassHour(classHour);
Integer type = Integer.parseInt(typeJudge);
if (type.intValue() == 1) {
decCourseConstruction.setType(2);
} else if (type.intValue() == 2) {
decCourseConstruction.setType(3);
} else if (type.intValue() == 3) {
decCourseConstruction.setType(0);
} else {
decCourseConstruction.setType(0);
}
// 备注
decCourseConstruction.setNote((String) map.get("remark"));
// 显示顺序
decCourseConstruction.setSort(999);
decCourseConstruction = decCourseConstructionService.addDecCourseConstruction(decCourseConstruction);
long pk = decCourseConstruction.getId();
JdbcHelper.updateNewPrimaryKey(tableName, pk, "constructionid", id);
count++;
if (null == map.get("exception")) {
correctCount++;
}
}
if (excel.size() > 0) {
try {
excelHelper.exportFromMaps(excel, "作家精品课程建设情况表", "dec_course_construction");
} catch (IOException ex) {
logger.error("异常数据导出到Excel失败", ex);
}
}
if (correctCount != maps.size()) {
result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "dec_course_construction");
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_construction表迁移完成,异常条目数量:{}", 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);
}
Aggregations