|
|
@@ -137,28 +137,41 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
MPJLambdaWrapper<TextbookSubscriptionItem> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
queryWrapper
|
|
|
.disableSubLogicDel()
|
|
|
- .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookInstockroomListVo.class).contains(x.getProperty()))
|
|
|
- .select(TextbookSubscriptionItem.class, x -> VoToColumnUtil.fieldsToColumns(TextbookInstockroomListVo.class).contains(x.getProperty()))
|
|
|
- .selectAs(TextbookSubscriptionItem::getPrice, TextbookInstockroomListVo::getActualPrice)
|
|
|
+// .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookInstockroomListVo.class).contains(x.getProperty()))
|
|
|
+// .select(TextbookSubscriptionItem.class, x -> VoToColumnUtil.fieldsToColumns(TextbookInstockroomListVo.class).contains(x.getProperty()))
|
|
|
+ .selectAs(TextbookSubscriptionItem::getTextbookSubscriptionId, TextbookInstockroomListVo::getTextbookSubscriptionId)
|
|
|
+ .selectAs(TextbookSubscriptionItem::getId, TextbookInstockroomListVo::getTextbookSubscriptionItemId)
|
|
|
+ .selectAs(TextbookSubscriptionItem::getTextbookId, TextbookInstockroomListVo::getTextbookId)
|
|
|
.selectAs(TextbookSubscriptionItem::getSourcePrice, TextbookInstockroomListVo::getPrice)
|
|
|
+ .selectAs(TextbookSubscriptionItem::getDiscount, TextbookInstockroomListVo::getDiscount)
|
|
|
+ .selectAs(TextbookSubscriptionItem::getPrice, TextbookInstockroomListVo::getActualPrice)
|
|
|
.selectAs(TextbookSubscriptionItem::getStudentNum, TextbookInstockroomListVo::getStudentSubscriptionNumber)
|
|
|
.selectAs(TextbookSubscriptionItem::getTeacherNum, TextbookInstockroomListVo::getTeacherSubscriptionNumber)
|
|
|
- .selectAs(TextbookSubscriptionItem::getId, TextbookInstockroomListVo::getTextbookSubscriptionItemId)
|
|
|
- .leftJoin(Textbook.class, Textbook::getId, TextbookSubscriptionItem::getTextbookId)
|
|
|
- .leftJoin(TextbookWarehouseRecord.class, TextbookWarehouseRecord::getDataItemId, TextbookSubscriptionItem::getId)
|
|
|
- .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId,
|
|
|
- wrapper -> wrapper
|
|
|
- .selectAs(BaseCourseSubject::getName, TextbookInstockroomListVo::getCourseName)
|
|
|
- .like(StringUtils.isNotEmpty(dto.getCourseName()), BaseCourseSubject::getName, dto.getCourseName())
|
|
|
- )
|
|
|
- .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ .selectAs(TextbookSubscriptionItem::getInStockNum, TextbookInstockroomListVo::getInStockNum)
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, TextbookSubscriptionItem::getTextbookId,
|
|
|
wrapper -> wrapper
|
|
|
- .selectAs(DictionaryDetail::getName, TextbookInstockroomListVo::getTextbookTypeCn)
|
|
|
+ .selectAs(Textbook::getCourseSubjectId, TextbookInstockroomListVo::getCourseSubjectId)
|
|
|
+ .selectAs(Textbook::getBookName, TextbookInstockroomListVo::getBookName)
|
|
|
+ .selectAs(Textbook::getIssn, TextbookInstockroomListVo::getIssn)
|
|
|
+ .selectAs(Textbook::getPublishingHouse, TextbookInstockroomListVo::getPublishingHouse)
|
|
|
+ .selectAs(Textbook::getEditorInChief, TextbookInstockroomListVo::getEditorInChief)
|
|
|
+ .selectAs(Textbook::getTextbookType, TextbookInstockroomListVo::getTextbookType)
|
|
|
+ .selectAs(Textbook::getUseType, TextbookInstockroomListVo::getUseType)
|
|
|
+ .selectAs(Textbook::getVersion, TextbookInstockroomListVo::getVersion)
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, Textbook::getCourseSubjectId,
|
|
|
+ wra -> wra
|
|
|
+ .selectAs(BaseCourseSubject::getName, TextbookInstockroomListVo::getCourseName)
|
|
|
+ .like(StringUtils.isNotEmpty(dto.getCourseName()), BaseCourseSubject::getName, dto.getCourseName())
|
|
|
+ )
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wra -> wra
|
|
|
+ .selectAs(DictionaryDetail::getName, TextbookInstockroomListVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .like(StringUtils.isNotEmpty(dto.getBookName()), Textbook::getBookName, dto.getBookName())
|
|
|
+ .like(StringUtils.isNotEmpty(dto.getIssn()), Textbook::getIssn, dto.getIssn())
|
|
|
)
|
|
|
-
|
|
|
+// .leftJoin(TextbookWarehouseRecord.class, TextbookWarehouseRecord::getDataItemId, TextbookSubscriptionItem::getId)
|
|
|
.eq(TextbookSubscriptionItem::getTextbookSubscriptionId, dto.getTextbookSubscriptionId())
|
|
|
- .like(StringUtils.isNotEmpty(dto.getBookName()), Textbook::getBookName, dto.getBookName())
|
|
|
- .like(StringUtils.isNotEmpty(dto.getIssn()), Textbook::getIssn, dto.getIssn())
|
|
|
.orderByAsc(TextbookSubscriptionItem::getInStockNum)
|
|
|
;
|
|
|
|
|
|
@@ -519,12 +532,12 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
;
|
|
|
List<TextbookWarehouseRecord> textbookWarehouseRecords = textbookWarehouseRecordMapper.selectList(textbookWarehouseRecordLambdaQueryWrapper);
|
|
|
|
|
|
- // 因为入库的时候可以修改定价,不同定价应该对应不同的入库记录
|
|
|
- Map<Long, Map<BigDecimal, TextbookWarehouseRecord>> textbookWarehouseRecordByItemIdByPriceMap = textbookWarehouseRecords.stream()
|
|
|
+ // 因为入库的时候可以修改定价和折扣,不同定价和折扣应该对应不同的入库记录
|
|
|
+ Map<Long, Map<String, TextbookWarehouseRecord>> textbookWarehouseRecordByItemIdByPriceMap = textbookWarehouseRecords.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
|
TextbookWarehouseRecord::getDataItemId, // 第一层分组:按征订项 ID 分组
|
|
|
Collectors.toMap(
|
|
|
- TextbookWarehouseRecord::getPrice, // 第二层映射:按入库定价作为键
|
|
|
+ p -> p.getPrice().stripTrailingZeros().toPlainString() + "-" + String.format("%.2f", p.getDiscount()), // 第二层映射:按入库定价作为键
|
|
|
wr -> wr, // 值为 TextbookStudentClaim 对象本身
|
|
|
(existing, replacement) -> existing // 如果有重复键,保留现有的值
|
|
|
)
|
|
|
@@ -563,20 +576,30 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
TextbookSubscriptionItem old = null;
|
|
|
TextbookSubscriptionItem updateItem;
|
|
|
TextbookWarehouseRecord textbookWarehouseRecord;
|
|
|
- Map<BigDecimal, TextbookWarehouseRecord> oldTextbookWarehouseRecordByPrice = null;
|
|
|
+ Map<String, TextbookWarehouseRecord> oldTextbookWarehouseRecordByPrice = null;
|
|
|
TextbookWarehouseRecord oldTextbookWarehouseRecord = null;
|
|
|
TextbookWarehouseRecordDetail textbookWarehouseRecordDetail;
|
|
|
- for (TextbookInstockroomDto dto : dtos) {
|
|
|
+ for (int i = 0; i < dtos.size(); i++) {
|
|
|
+ TextbookInstockroomDto dto = dtos.get(i);
|
|
|
if (ObjectUtils.isNotEmpty(dto.getTextbookSubscriptionItemId())) {
|
|
|
old = itemByIdMap.get(dto.getTextbookSubscriptionItemId());
|
|
|
oldTextbookWarehouseRecordByPrice = textbookWarehouseRecordByItemIdByPriceMap.get(dto.getTextbookSubscriptionItemId());
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(dto.getPrice())){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材价格为空,请填写。");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(dto.getDiscount())){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材折扣为空,请填写。");
|
|
|
+ }
|
|
|
+
|
|
|
if(MapUtils.isNotEmpty(oldTextbookWarehouseRecordByPrice)){
|
|
|
- oldTextbookWarehouseRecord = oldTextbookWarehouseRecordByPrice.get(dto.getPrice());
|
|
|
+ oldTextbookWarehouseRecord = oldTextbookWarehouseRecordByPrice.get(dto.getPrice().stripTrailingZeros().toPlainString() + "-" + String.format("%.2f", dto.getDiscount()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (ObjectUtils.isEmpty(old)) {
|
|
|
- continue;
|
|
|
+ if(ObjectUtils.isEmpty(old)){
|
|
|
+ throw new MyException("第" + (i+1) + "本教材征订信息被修改,请刷新重试");
|
|
|
}
|
|
|
|
|
|
// 现在入库价格改动不影响征订项的价格相关属性
|
|
|
@@ -681,11 +704,11 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
// Map<Long, TextbookWarehouseRecord> textbookWarehouseRecordByItemIdMap = textbookWarehouseRecords.stream()
|
|
|
// .collect(Collectors.toMap(TextbookWarehouseRecord::getDataItemId, t -> t, (t1, t2) -> t2));
|
|
|
// 因为入库的时候可以修改定价,不同定价应该对应不同的入库记录
|
|
|
- Map<Long, Map<BigDecimal, TextbookWarehouseRecord>> textbookWarehouseRecordByItemIdByPriceMap = textbookWarehouseRecords.stream()
|
|
|
+ Map<Long, Map<String, TextbookWarehouseRecord>> textbookWarehouseRecordByItemIdByPriceMap = textbookWarehouseRecords.stream()
|
|
|
.collect(Collectors.groupingBy(
|
|
|
TextbookWarehouseRecord::getDataItemId, // 第一层分组:按征订项 ID 分组
|
|
|
Collectors.toMap(
|
|
|
- TextbookWarehouseRecord::getPrice, // 第二层映射:按入库定价作为键
|
|
|
+ p -> p.getPrice().stripTrailingZeros().toPlainString() + "-" + String.format("%.2f", p.getDiscount()), // 第二层映射:按入库定价作为键
|
|
|
wr -> wr, // 值为 TextbookStudentClaim 对象本身
|
|
|
(existing, replacement) -> existing // 如果有重复键,保留现有的值
|
|
|
)
|
|
|
@@ -720,7 +743,7 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
// 处理入库细节
|
|
|
TextbookSubscriptionItem oldItem;
|
|
|
TextbookSubscriptionItem updateItem;
|
|
|
- Map<BigDecimal, TextbookWarehouseRecord> oldTextbookWarehouseRecordByPrice;
|
|
|
+ Map<String, TextbookWarehouseRecord> oldTextbookWarehouseRecordByPrice;
|
|
|
TextbookWarehouseRecord oldTextbookWarehouseRecord = null;
|
|
|
TextbookWarehouseRecord textbookWarehouseRecord;
|
|
|
TextbookWarehouseRecordDetail textbookWarehouseRecordDetail;
|
|
|
@@ -746,9 +769,17 @@ public class TextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
throw new MyException("第" + (i + 4) + "行数据主键被修改,请重新下载模板");
|
|
|
}
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(vo.getPrice())) {
|
|
|
+ throw new MyException("第" + (i + 4) + "行数据定价为空,请填写");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(vo.getDiscount())) {
|
|
|
+ throw new MyException("第" + (i + 4) + "行数据折扣为空,请填写");
|
|
|
+ }
|
|
|
+
|
|
|
oldTextbookWarehouseRecordByPrice = textbookWarehouseRecordByItemIdByPriceMap.get(Long.parseLong(vo.getTextbookSubscriptionItemId()));
|
|
|
if(MapUtils.isNotEmpty(oldTextbookWarehouseRecordByPrice)){
|
|
|
- oldTextbookWarehouseRecord = oldTextbookWarehouseRecordByPrice.get(vo.getPrice());
|
|
|
+ oldTextbookWarehouseRecord = oldTextbookWarehouseRecordByPrice.get(vo.getPrice().stripTrailingZeros().toPlainString() + "-" + String.format("%.2f", vo.getDiscount()));
|
|
|
}
|
|
|
|
|
|
updateItem = new TextbookSubscriptionItem();
|