use of com.bc.pmpheep.back.vo.DecExtensionVO in project pmph by BCSquad.
the class ExcelHelper method fillDecExtensionVODataPlus.
private ColumnProperties fillDecExtensionVODataPlus(List<MaterialExtension> extensions, List<DecExtensionVO> decExtensionVOs, Row row, ColumnProperties properties) {
int colCount = properties.getColCount();
int[] maxLength = properties.getMaxLength();
if (CollectionUtil.isEmpty(decExtensionVOs)) {
for (MaterialExtension extension : extensions) {
row.createCell(colCount++);
}
} else {
for (MaterialExtension extension : extensions) {
for (DecExtensionVO vo : decExtensionVOs) {
if (vo.getExtensionId().equals(extension.getId())) {
Cell cell = row.createCell(colCount++);
String content = vo.getContent();
if (StringUtil.notEmpty(content)) {
cell.setCellValue(content);
maxLength[colCount - 1] = content.length();
} else {
maxLength[colCount - 1] = 2;
}
break;
}
}
}
}
properties.setColCount(colCount);
properties.setMaxLength(maxLength);
return properties;
}
use of com.bc.pmpheep.back.vo.DecExtensionVO in project pmph by BCSquad.
the class ExcelHelper method fromDeclarationEtcBOList.
/**
* 根据业务对象(包含子集合的BO)集合创建工作簿
*
* @param material
* 申报表所属教材对象
* @param extensions
* 教材扩展项集合
* @param dataSource
* 业务对象(BO)集合
* @param sheetName
* 要生成的Excel表名(非文件名)
* @return Excel工作簿
*/
public Workbook fromDeclarationEtcBOList(Material material, List<MaterialExtension> extensions, List<DeclarationEtcBO> dataSource, String sheetName) throws CheckedServiceException, IllegalArgumentException, IllegalAccessException {
if (null == dataSource || dataSource.isEmpty()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用于导出Excel的数据源为空");
}
Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet(sheetName);
// 生成表头
sheet = generateDeclarationEtcBOHeader(extensions, sheet);
// 设置表头样式
headerStyleSetup(workbook, 2);
Field[] fields = dataSource.get(0).getClass().getDeclaredFields();
/* 设置行计数器 */
int rowCount = 2;
/* 记录列数和最大列宽 */
ColumnProperties columnProperties = new ColumnProperties(1, new int[sheet.getRow(1).getLastCellNum()]);
/* 遍历list中的对象 */
Iterator iterator = dataSource.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
Row row = sheet.createRow(rowCount);
/* 设置序号及宽度 */
row.createCell(0).setCellValue(String.valueOf(rowCount - 1));
columnProperties.setMaxElement(0, 2);
/* 设置列计数器 */
columnProperties.setColCount(1);
for (Field field : fields) {
// 可访问性设置
field.setAccessible(true);
if (field.isAnnotationPresent(ExcelHeader.class)) {
ExcelHeader excelHeader = (ExcelHeader) field.getAnnotation(ExcelHeader.class);
String headerName = excelHeader.header();
if (StringUtil.notEmpty(headerName)) {
switch(headerName) {
case "学习经历":
{
List<DecEduExp> list = (List<DecEduExp>) field.get(object);
columnProperties = fillDecEduExpData(list, row, columnProperties);
break;
}
case "工作经历":
{
List<DecWorkExp> list = (List<DecWorkExp>) field.get(object);
columnProperties = fillDecWorkExpData(list, row, columnProperties);
break;
}
case "教学经历":
{
List<DecTeachExp> list = (List<DecTeachExp>) field.get(object);
columnProperties = fillDecTeachExpData(list, row, columnProperties);
break;
}
case "个人成就":
{
DecAchievement decAchievement = (DecAchievement) field.get(object);
columnProperties = fillDecAchievementData(decAchievement, row, columnProperties);
break;
}
case "学术兼职":
{
List<DecAcade> list = (List<DecAcade>) field.get(object);
columnProperties = fillDecAcadeData(list, row, columnProperties);
break;
}
case "本套上版教材参编情况":
{
List<DecLastPosition> list = (List<DecLastPosition>) field.get(object);
columnProperties = fillDecLastPositionData(list, row, columnProperties);
break;
}
case "精品课程建设情况":
{
List<DecCourseConstruction> list = (List<DecCourseConstruction>) field.get(object);
columnProperties = fillDecCourseConstructionData(list, row, columnProperties);
break;
}
case "主编国家级规划教材情况":
{
List<DecNationalPlan> list = (List<DecNationalPlan>) field.get(object);
columnProperties = fillDecNationalPlanData(list, row, columnProperties);
break;
}
case "人卫社教材编写情况":
{
List<DecTextbookPmph> list = (List<DecTextbookPmph>) field.get(object);
columnProperties = fillDecTextbookPmphData(list, row, columnProperties);
break;
}
case "其他社教材编写情况":
{
List<DecTextbook> list = (List<DecTextbook>) field.get(object);
columnProperties = fillDecTextbookData(list, row, columnProperties);
break;
}
case "参加人卫慕课、数字教材编写情况":
{
DecMoocDigital decMoocDigital = (DecMoocDigital) field.get(object);
columnProperties = fillDecMoocDigitalData(decMoocDigital, row, columnProperties);
break;
}
case "科研情况":
{
List<DecResearch> list = (List<DecResearch>) field.get(object);
columnProperties = fillDecResearchData(list, row, columnProperties);
break;
}
case "学术专著":
{
List<DecMonograph> list = (List<DecMonograph>) field.get(object);
columnProperties = fillDecMonographData(list, row, columnProperties);
break;
}
case "出版行业获奖情况":
{
List<DecPublishReward> list = (List<DecPublishReward>) field.get(object);
columnProperties = fillDecPublishRewardData(list, row, columnProperties);
break;
}
case "SCI论文投稿及影响因子情况":
{
List<DecSci> list = (List<DecSci>) field.get(object);
columnProperties = fillDecSciData(list, row, columnProperties);
break;
}
case "临床医学获奖情况":
{
List<DecClinicalReward> list = (List<DecClinicalReward>) field.get(object);
columnProperties = fillDecClinicalRewardData(list, row, columnProperties);
break;
}
case "学术荣誉授予情况":
{
List<DecAcadeReward> list = (List<DecAcadeReward>) field.get(object);
columnProperties = fillDecAcadeRewardData(list, row, columnProperties);
break;
}
case "编写内容意向":
{
DecIntention decIntention = (DecIntention) field.get(object);
columnProperties = fillDecIntentionData(decIntention, row, columnProperties);
break;
}
case "作家扩展项":
{
if (extensions == null || extensions.isEmpty()) {
break;
}
List<DecExtensionVO> list = (List<DecExtensionVO>) field.get(object);
columnProperties = fillDecExtensionVODataPlus(extensions, list, row, columnProperties);
break;
}
default:
Object o = field.get(object);
Cell cell = row.createCell(columnProperties.getColCount());
if (null != o) {
String value = o.toString();
cell.setCellValue(value);
if (value.length() > columnProperties.getCurrentMaxElement()) {
columnProperties.setCurrentMaxElement(value.length());
}
}
columnProperties.setColCount(columnProperties.getColCount() + 1);
break;
}
}
}
}
rowCount++;
}
/* 样式调整 */
workbook = dataStyleSetup(workbook, 2, rowCount, columnProperties);
/* 以下隐藏多余的列 */
return clearColumns(workbook, material);
}
Aggregations