|
|
@@ -12,6 +12,7 @@ import com.izouma.wenlvju.domain.performance.Participant;
|
|
|
import com.izouma.wenlvju.domain.performance.Programme;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.dto.ProgrammeDTO;
|
|
|
+import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.ArtTypeRepo;
|
|
|
import com.izouma.wenlvju.repo.GradingOrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
@@ -20,11 +21,17 @@ import com.izouma.wenlvju.repo.performance.ParticipantRepo;
|
|
|
import com.izouma.wenlvju.repo.performance.ProgrammeRepo;
|
|
|
import com.izouma.wenlvju.service.ArtTypeService;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
+import com.izouma.wenlvju.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
+import javax.transaction.Transactional;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -122,11 +129,9 @@ public class ProgrammeService {
|
|
|
|
|
|
public List<ProgrammeDTO> toDTOList(List<Programme> programmes) {
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
- List<Long> settingIds = new ArrayList<>();
|
|
|
|
|
|
programmes.forEach(programme -> {
|
|
|
ids.add(programme.getId());
|
|
|
- settingIds.add(programme.getLevelSettingId());
|
|
|
});
|
|
|
|
|
|
Map<Long, String> organizationMap = organizationRepo.findAll()
|
|
|
@@ -138,7 +143,7 @@ public class ProgrammeService {
|
|
|
Map<Long, String> artTypeMap = artTypeRepo.findAll()
|
|
|
.stream()
|
|
|
.collect(Collectors.toMap(ArtType::getId, ArtType::getName));
|
|
|
- Map<Long, String> settingMap = settingRepo.findAllById(settingIds)
|
|
|
+ Map<Long, String> settingMap = settingRepo.findAllByFlagIn(CollUtil.newArrayList(3, 4))
|
|
|
.stream()
|
|
|
.collect(Collectors.toMap(Setting::getId, Setting::getName));
|
|
|
|
|
|
@@ -160,4 +165,23 @@ public class ProgrammeService {
|
|
|
settingMap.get(programme.getLevelSettingId()), 0);
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackOn = Exception.class)
|
|
|
+ public void upload(InputStream is, Long userId) throws IOException {
|
|
|
+ organizationRepo.findByUserId(userId).orElseThrow(new BusinessException("无记录"));
|
|
|
+
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int len;
|
|
|
+ while ((len = is.read(buffer)) > -1) {
|
|
|
+ baos.write(buffer, 0, len);
|
|
|
+ }
|
|
|
+ baos.flush();
|
|
|
+
|
|
|
+ InputStream indicatorStream = new ByteArrayInputStream(baos.toByteArray());
|
|
|
+ List<ProgrammeDTO> dtos = ExcelUtils.readExcel(indicatorStream, ProgrammeDTO.class, 1, 1);
|
|
|
+
|
|
|
+ settingRepo.findAllByFlagIn(CollUtil.newArrayList(3, 4));
|
|
|
+ }
|
|
|
}
|