|
|
@@ -9,14 +9,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
-import com.xjrsoft.common.enums.TextbookTypeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
-import com.xjrsoft.module.student.entity.BaseClassMajorSet;
|
|
|
-import com.xjrsoft.module.student.vo.BaseClassMajorSetPageVo;
|
|
|
import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import com.xjrsoft.module.textbook.dto.*;
|
|
|
import com.xjrsoft.module.textbook.entity.*;
|
|
|
@@ -37,6 +34,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -345,11 +344,13 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
|
|
|
if (dtos.isEmpty()) {
|
|
|
return false;
|
|
|
}
|
|
|
- return saveData(dtos);
|
|
|
+ Map<String, Object> result = saveData(dtos);
|
|
|
+ return result != null && (int) result.get("successNum") > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean excelImport(InputStream inputStream, Long wfTextbookSubscriptionId) {
|
|
|
+ public String excelImport(InputStream inputStream, Long wfTextbookSubscriptionId) {
|
|
|
+ AtomicReference<Map<String, Object>> atomicMap = new AtomicReference<>(new HashMap<>());
|
|
|
EasyExcel.read(inputStream, TextbookInstockroomImportDto.class, new PageReadListener<TextbookInstockroomImportDto>(dataList -> {
|
|
|
if (dataList.isEmpty()) {
|
|
|
throw new MyException("导入数据为空");
|
|
|
@@ -363,13 +364,19 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
|
|
|
setInNum(item.getInNum());
|
|
|
}});
|
|
|
}
|
|
|
- saveData(textbookInstockroomDtoList);
|
|
|
+ atomicMap.set(saveData(textbookInstockroomDtoList));
|
|
|
})).sheet().doRead();
|
|
|
|
|
|
- return true;
|
|
|
+ if(atomicMap.get() != null){
|
|
|
+ return "计划入库教材" + atomicMap.get().get("allNum") + "样,成功入库" + atomicMap.get().get("successNum") + "样,成功入库" + atomicMap.get().get("instockroomNum") + "本";
|
|
|
+ }
|
|
|
+ return "计划入库教材0样,成功入库0样,成功入库0本";
|
|
|
}
|
|
|
|
|
|
- private boolean saveData(List<TextbookInstockroomDto> dtos) {
|
|
|
+ private Map<String, Object> saveData(List<TextbookInstockroomDto> dtos) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ int successNum = 0;
|
|
|
+ int instockroomNum = 0;
|
|
|
//获取需要修改的list
|
|
|
MPJLambdaWrapper<WfTextbookSubscriptionItem> queryWrapper = new MPJLambdaWrapper<>();
|
|
|
queryWrapper
|
|
|
@@ -383,7 +390,7 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
|
|
|
List<WfTextbookSubscriptionItem> wfTextbookSubscriptionItemList = wfTextbookSubscriptionWfTextbookSubscriptionItemMapper.selectList(queryWrapper);
|
|
|
|
|
|
if (wfTextbookSubscriptionItemList.isEmpty()) {
|
|
|
- return false;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
Map<Long, WfTextbookSubscriptionItem> itemByIdMap = wfTextbookSubscriptionItemList
|
|
|
@@ -427,7 +434,13 @@ public class WfTextbookSubscriptionServiceImpl extends MPJBaseServiceImpl<WfText
|
|
|
setWarehouseNumber(dto.getInNum());
|
|
|
setSource("wm_manual");
|
|
|
}});
|
|
|
+ successNum++;
|
|
|
+ instockroomNum += dto.getInNum();
|
|
|
}
|
|
|
- return true;
|
|
|
+ result.put("allNum", dtos.size());
|
|
|
+ result.put("successNum", successNum);
|
|
|
+ result.put("instockroomNum", instockroomNum);
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|