|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.Entity;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -17,6 +18,7 @@ import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.enums.UseSemesterTypeEnum;
|
|
|
import com.xjrsoft.common.enums.WarehouseModeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
@@ -27,6 +29,7 @@ import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.courseTable.entity.CourseTable;
|
|
|
import com.xjrsoft.module.generator.constant.ComponentTypeConstant;
|
|
|
import com.xjrsoft.module.generator.entity.ColumnConfig;
|
|
|
import com.xjrsoft.module.generator.entity.ImportConfig;
|
|
|
@@ -1142,4 +1145,75 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
workbook.write(bot);
|
|
|
return bot;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ByteArrayOutputStream subscriptionExportQuery(SubscriptionExportQueryDto dto) throws IOException {
|
|
|
+ MPJLambdaWrapper<TextbookSubscriptionItem> textbookSubscriptionItemMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ textbookSubscriptionItemMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .selectAs(TextbookSubscriptionItem::getId, SubscriptionExportQueryListVo::getTextbookSubscriptionItemId)
|
|
|
+ .selectAs(Textbook::getPrice, SubscriptionExportQueryListVo::getPrice)
|
|
|
+ .selectAs(TextbookSubscriptionItem::getPrice, SubscriptionExportQueryListVo::getSubtotal)
|
|
|
+ .select("(SELECT GROUP_CONCAT(DISTINCT b.name)\n" +
|
|
|
+ " FROM textbook_subscription_item_class a\n" +
|
|
|
+ " LEFT JOIN base_class b ON (b.id = a.base_class_id)\n" +
|
|
|
+ " WHERE a.delete_mark = 0\n" +
|
|
|
+ " and a.textbook_subscription_item_id = t.id) AS useClass"
|
|
|
+ )
|
|
|
+ .select("(SELECT GROUP_CONCAT(DISTINCT c.name)\n" +
|
|
|
+ " FROM textbook_subscription_item_class a\n" +
|
|
|
+ " LEFT JOIN base_class b ON (b.id = a.base_class_id)\n" +
|
|
|
+ " LEFT JOIN base_grade c ON (c.id = b.grade_id)\n" +
|
|
|
+ " WHERE a.delete_mark = 0\n" +
|
|
|
+ " and a.textbook_subscription_item_id = t.id) AS useGrade"
|
|
|
+ )
|
|
|
+ .select("(SELECT count(a.id)\n" +
|
|
|
+ " FROM textbook_subscription_item_class a\n" +
|
|
|
+ " WHERE a.delete_mark = 0\n" +
|
|
|
+ " and a.textbook_subscription_item_id = t.id) AS useClassNum"
|
|
|
+ )
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(SubscriptionExportQueryListVo.class).contains(x.getProperty()))
|
|
|
+ .select(TextbookSubscriptionItem.class, x -> VoToColumnUtil.fieldsToColumns(SubscriptionExportQueryListVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, TextbookSubscriptionItem::getTextbookId,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .leftJoin(SubjectGroup.class, SubjectGroup::getId, Textbook::getSubjectGroupId,
|
|
|
+ wrap -> wrap
|
|
|
+ .selectAs(SubjectGroup::getGroupName, SubscriptionExportQueryListVo::getSubjectName)
|
|
|
+ )
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId,
|
|
|
+ wrap -> wrap
|
|
|
+ .selectAs(BaseCourseSubject::getName, SubscriptionExportQueryListVo::getCourseName)
|
|
|
+ )
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrap -> wrap
|
|
|
+ .selectAs(DictionaryDetail::getName, SubscriptionExportQueryListVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .eq(TextbookSubscriptionItem::getTextbookSubscriptionId, dto.getTextbookSubscriptionId())
|
|
|
+ ;
|
|
|
+ List<SubscriptionExportQueryListVo> dataList = textbookSubscriptionTextbookSubscriptionItemMapper.selectJoinList(SubscriptionExportQueryListVo.class, textbookSubscriptionItemMPJLambdaWrapper);
|
|
|
+
|
|
|
+ for (SubscriptionExportQueryListVo vo : dataList){
|
|
|
+ if(ObjectUtils.isNotEmpty(vo.getIsTextbookPlan()) && vo.getIsTextbookPlan() == 0){
|
|
|
+ vo.setIsTextbookPlanCn("否");
|
|
|
+ }
|
|
|
+ if(ObjectUtils.isNotEmpty(vo.getIsTextbookPlan()) && vo.getIsTextbookPlan() == 1){
|
|
|
+ vo.setIsTextbookPlanCn("是");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtils.isNotEmpty(vo.getUseType())){
|
|
|
+ vo.setUseTypeCn(UseSemesterTypeEnum.getValue(vo.getUseType()));
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setTotalNumber(vo.getStudentNum() + vo.getTeacherNum());
|
|
|
+ vo.setStudentPrice(vo.getSubtotal().multiply(BigDecimal.valueOf(vo.getStudentNum())));
|
|
|
+ vo.setTeacherPrice(vo.getSubtotal().multiply(BigDecimal.valueOf(vo.getTeacherNum())));
|
|
|
+ vo.setTotalPrice(vo.getStudentPrice().add(vo.getTeacherPrice()));
|
|
|
+ }
|
|
|
+
|
|
|
+ ByteArrayOutputStream bot = new ByteArrayOutputStream();
|
|
|
+ EasyExcel.write(bot, SubscriptionExportQueryListVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
|
|
|
+
|
|
|
+ return bot;
|
|
|
+ }
|
|
|
}
|