|
|
@@ -23,9 +23,11 @@ import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
+import com.xjrsoft.module.generator.entity.ImportConfig;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
|
|
|
+import com.xjrsoft.module.student.vo.BaseClassMajorSetVo;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
|
@@ -37,19 +39,27 @@ import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
|
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
|
import com.xjrsoft.module.textbook.vo.*;
|
|
|
+import com.xjrsoft.module.veb.util.ImportExcelUtil;
|
|
|
import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
@@ -64,12 +74,8 @@ import java.util.stream.Stream;
|
|
|
@AllArgsConstructor
|
|
|
public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<TextbookStudentClaimMapper, TextbookStudentClaim> implements ITextbookStudentClaimService {
|
|
|
|
|
|
- private final XjrUserMapper xjrUserMapper;
|
|
|
-
|
|
|
private final TextbookStudentClaimMapper textbookStudentClaimMapper;
|
|
|
|
|
|
- private final IBaseSemesterService baseSemesterService;
|
|
|
-
|
|
|
private final IBaseClassService baseClassService;
|
|
|
|
|
|
private final BaseClassAdminCourseMapper baseClassAdminCourseMapper;
|
|
|
@@ -203,6 +209,12 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
return baseClassAdminCourseMapper.selectJoinPage(ConventPage.getPage(dto), HeadTeaLookClassBookSemesterVo.class, baseClassAdminCourseMPJLambdaWrapper);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IPage<AllDetailPageVo> allDetailPage(AllDetailPageDto dto) {
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public TextbookClaimStudentConfirmVo getStudentConfirmList(TextbookClaimStudentConfirmDto dto) {
|
|
|
// 获取学期
|
|
|
@@ -1276,7 +1288,7 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ByteArrayOutputStream allStuClaimExportQuery(AllStuClaimExportQueryDto dto) {
|
|
|
+ public ByteArrayOutputStream allStuClaimExportQuery(AllStuClaimExportQueryDto dto) throws IOException {
|
|
|
if(StringUtils.isEmpty(dto.getBaseSemesterId())){
|
|
|
throw new MyException("请选择学期");
|
|
|
}
|
|
|
@@ -1288,9 +1300,171 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
}
|
|
|
|
|
|
// 获取所有学生信息
|
|
|
-// AllStuClaimExportQueryVo
|
|
|
+ MPJLambdaWrapper<TextbookStudentClaim> textbookStudentClaimMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ textbookStudentClaimMPJLambdaWrapper
|
|
|
+ .select(TextbookStudentClaim.class, x -> VoToColumnUtil.fieldsToColumns(AllStuClaimExportQueryVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(BaseClass.class, BaseClass::getId, TextbookStudentClaim::getClassId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(BaseClass::getName, AllStuClaimExportQueryVo::getClassIdCn)
|
|
|
+ )
|
|
|
+ .leftJoin(XjrUser.class, XjrUser::getId, TextbookStudentClaim::getStudentUserId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(XjrUser::getName, AllStuClaimExportQueryVo::getStudentUserIdCn)
|
|
|
+ )
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, TextbookStudentClaim::getTextbookId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(Textbook::getBookName, AllStuClaimExportQueryVo::getTextbookIdCn)
|
|
|
+ )
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getClassId()), TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getClassId()), TextbookStudentClaim::getClassId, dto.getClassId())
|
|
|
+ .eq(ObjectUtils.isNotEmpty(dto.getUserId()), TextbookStudentClaim::getStudentUserId, dto.getUserId())
|
|
|
+ ;
|
|
|
|
|
|
+ List<AllStuClaimExportQueryVo> allStuClaimExportQueryVos = this.selectJoinList(AllStuClaimExportQueryVo.class, textbookStudentClaimMPJLambdaWrapper);
|
|
|
|
|
|
- return null;
|
|
|
+ if(CollectionUtils.isEmpty(allStuClaimExportQueryVos)){
|
|
|
+ throw new MyException("当前搜索条件没有领取确认数据。");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理特殊字符
|
|
|
+ for (AllStuClaimExportQueryVo vo : allStuClaimExportQueryVos) {
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(vo.getPrice())) {
|
|
|
+ vo.setPriceStr(vo.getPrice().stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(vo.getIsClaim())) {
|
|
|
+ if (vo.getIsClaim() == 0) {
|
|
|
+ vo.setIsClaimStr("未领取");
|
|
|
+ }
|
|
|
+ if (vo.getIsClaim() == 1) {
|
|
|
+ vo.setIsClaimStr("已领取");
|
|
|
+ }
|
|
|
+ if (vo.getIsClaim() == 2) {
|
|
|
+ vo.setIsClaimStr("退书");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(vo.getClaimSource())) {
|
|
|
+ if (vo.getClaimSource() == 1) {
|
|
|
+ vo.setClaimSourceStr("学生申领");
|
|
|
+ }
|
|
|
+ if (vo.getClaimSource() == 2) {
|
|
|
+ vo.setClaimSourceStr("班级申领");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始分组,现根据班级分组,再根据学生分组
|
|
|
+ Map<Long, Map<Long, List<AllStuClaimExportQueryVo>>> groupByClassIsByStuId =
|
|
|
+ Optional.of(allStuClaimExportQueryVos)
|
|
|
+ .orElse(Collections.emptyList())
|
|
|
+ .stream()
|
|
|
+ .filter(Objects::nonNull) // 过滤掉元素本身为null的情况
|
|
|
+ .filter(vo -> vo.getClassId() != null)
|
|
|
+ .filter(vo -> vo.getStudentUserId() != null)
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ AllStuClaimExportQueryVo::getClassId,
|
|
|
+ Collectors.groupingBy(AllStuClaimExportQueryVo::getStudentUserId)
|
|
|
+ ));
|
|
|
+
|
|
|
+ // 开始写入
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ // 创建一个工作表(sheet)
|
|
|
+ String sheetName = "sheet1";
|
|
|
+ Sheet sheet = workbook.createSheet(sheetName);
|
|
|
+
|
|
|
+ // 出参vo字段数量
|
|
|
+ AllStuClaimExportQueryVo obj = new AllStuClaimExportQueryVo();
|
|
|
+ List<ImportConfig> importConfigs = ImportExcelUtil.allFields(obj);
|
|
|
+
|
|
|
+ // 写大标题
|
|
|
+ int rowNumber = 0;
|
|
|
+ ImportExcelUtil.createBigHead(workbook, sheet, baseSemester.getName() + "教材领取确认情况", rowNumber++, importConfigs.size() - 1);
|
|
|
+
|
|
|
+ // 表头
|
|
|
+ ImportExcelUtil.createHead(workbook, sheet, importConfigs, IndexedColors.YELLOW.getIndex(), IndexedColors.RED.getIndex(), rowNumber++);
|
|
|
+
|
|
|
+ // 字体内容格式
|
|
|
+ Font font = workbook.createFont();
|
|
|
+ font.setBold(false);// 设置为粗体
|
|
|
+ font.setFontName("宋体");
|
|
|
+ font.setFontHeightInPoints((short) 12);
|
|
|
+
|
|
|
+ // 单元格样式
|
|
|
+ CellStyle cellStyle = workbook.createCellStyle();
|
|
|
+ cellStyle.setFont(font); // 将字体应用到样式
|
|
|
+ cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+
|
|
|
+ // 设置边框样式为细线
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex()); // 设置顶部边框颜色
|
|
|
+
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex()); // 设置底部边框颜色
|
|
|
+
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex()); // 设置左边框颜色
|
|
|
+
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+ cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex()); // 设置右边框颜色
|
|
|
+
|
|
|
+ // 记录写入
|
|
|
+ List<String> stuVo;
|
|
|
+ // 处理特殊字符
|
|
|
+ for (Map.Entry<Long, Map<Long, List<AllStuClaimExportQueryVo>>> entryByClassId : groupByClassIsByStuId.entrySet()) {
|
|
|
+ Long classId = entryByClassId.getKey();
|
|
|
+ Map<Long, List<AllStuClaimExportQueryVo>> groupByStu = entryByClassId.getValue();
|
|
|
+
|
|
|
+ int mergeClass = 0;
|
|
|
+ for (Map.Entry<Long, List<AllStuClaimExportQueryVo>> entryByStuId : groupByStu.entrySet()) {
|
|
|
+ Long sruId = entryByStuId.getKey();
|
|
|
+ List<AllStuClaimExportQueryVo> vos = entryByStuId.getValue();
|
|
|
+
|
|
|
+ int mergeStu = 0;
|
|
|
+ for (AllStuClaimExportQueryVo vo : vos) {
|
|
|
+ stuVo = new ArrayList<>();
|
|
|
+ stuVo.add(vo.getClassIdCn());
|
|
|
+ stuVo.add(vo.getStudentUserIdCn());
|
|
|
+ stuVo.add(vo.getTextbookIdCn());
|
|
|
+ stuVo.add(vo.getPriceStr());
|
|
|
+ stuVo.add(vo.getIsClaimStr());
|
|
|
+ stuVo.add(vo.getClaimSourceStr());
|
|
|
+
|
|
|
+ Row dataRow = sheet.createRow(rowNumber++);
|
|
|
+ for (int j = 0; j < stuVo.size(); j++) {
|
|
|
+ String content = stuVo.get(j);
|
|
|
+ Cell cell = dataRow.createCell(j);
|
|
|
+ cell.setCellValue(content);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ }
|
|
|
+ mergeStu++;
|
|
|
+ mergeClass++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 合并申领项
|
|
|
+ if (mergeStu > 1) {
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowNumber - mergeStu, rowNumber - 1, 1, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mergeClass > 1) {
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(rowNumber - mergeClass, rowNumber - 1, 0, 0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动列宽s
|
|
|
+ for (int i = 0; i < importConfigs.size(); i++) {
|
|
|
+ if(importConfigs.get(i).getWidth() != 0){
|
|
|
+ sheet.setColumnWidth(i, importConfigs.get(i).getWidth());
|
|
|
+ }else {
|
|
|
+ sheet.autoSizeColumn(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ workbook.write(bot);
|
|
|
+ return bot;
|
|
|
}
|
|
|
}
|