260410_02_ENH: 리스트, 컨택이력, 수정이력 다운로드 1차 구현
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
package com.kri.contact.server.common.consts;
|
||||
|
||||
import com.kri.common.feature.excel.StreamingReadOptions;
|
||||
import com.kri.contact.server.common.enums.ListHeaderType;
|
||||
import com.kri.contact.server.common.enums.ListHeaderTypeDefault;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class ContactConstant {
|
||||
public static final int INSERT_CHUNK_SIZE = 1_000;
|
||||
public static final int LIST_SELECT_CHUNK_SIZE = 1_000;
|
||||
public static final String DEFAULT_COMPANY_NAME = "KRI";
|
||||
public static final String DEFAULT_USER_TEAM = "S101";
|
||||
|
||||
public static final int OUTSOURCE_USER_ROLE = 4000;
|
||||
public static final int FIELDWORK_USER_ROLE = 9000;
|
||||
|
||||
public static final StreamingReadOptions LOWER_CASE_HEADER_OPTIONS =
|
||||
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.toLowerCase(
|
||||
Locale.ROOT));
|
||||
|
||||
public static final String LIST_TEXT_REGEX = "^[가-힣a-zA-Z0-9()_\\-\\[\\] ]+$";
|
||||
|
||||
public static final List<ListHeaderType> DEFAULT_AND_FILE_TYPE = Stream.concat(
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.kri.contact.server.common.enums;
|
||||
|
||||
public enum ListSearchResponseType {
|
||||
BASE,
|
||||
WITH_RESULT,
|
||||
WITH_FULL_RESULT
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.kri.contact.server.common.util;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
@NoArgsConstructor
|
||||
public final class ExcelResponseBuilder {
|
||||
public static ResponseEntity<byte[]> buildExcelResponse(String fileName, byte[] bytes) {
|
||||
String contentDisposition = "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
|
||||
.contentType(MediaType.parseMediaType(
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
|
||||
.body(bytes);
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,12 @@ import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
@NoArgsConstructor
|
||||
public final class ExcelUploadResultUtil {
|
||||
|
||||
private ExcelUploadResultUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 엑셀 업로드 결과 + 에러 엑셀 생성까지 공통 처리.
|
||||
*
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import static com.kri.contact.server.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.common.feature.web.page.PageResponseDto;
|
||||
import com.kri.contact.server.common.enums.ListSearchResponseType;
|
||||
import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchResponseDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchWithResultDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchWithFullResultDto;
|
||||
import com.kri.contact.server.dto.list.ListUpdateRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListUploadRequestDto;
|
||||
import com.kri.contact.server.dto.project.ProjectInfoDto;
|
||||
import com.kri.contact.server.service.ListDownloadService;
|
||||
import com.kri.contact.server.service.ListResetService;
|
||||
import com.kri.contact.server.service.ListSearchService;
|
||||
import com.kri.contact.server.service.ListUpdateService;
|
||||
@@ -21,15 +25,13 @@ import com.kri.contact.server.service.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -46,6 +48,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
public class ListController {
|
||||
|
||||
private final ProjectService projectService;
|
||||
private final ListDownloadService listDownloadService;
|
||||
private final ListSearchService listSearchService;
|
||||
private final ListUploadService listUploadService;
|
||||
private final ListUpdateService listUpdateService;
|
||||
@@ -54,41 +57,54 @@ public class ListController {
|
||||
|
||||
@Operation(summary = "리스트 정보 조회 With Sid")
|
||||
@GetMapping("/search/{prjctIdx}/{sid}")
|
||||
public ListSearchWithResultDto getListSearchWithResult(
|
||||
public ListSearchWithFullResultDto searchListWithSid(
|
||||
@PathVariable Long prjctIdx,
|
||||
@PathVariable Integer sid
|
||||
){
|
||||
return listSearchService.getListSearchOne(prjctIdx, sid);
|
||||
) {
|
||||
return listSearchService.searchListWithSid(prjctIdx, sid);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 정보 조회 With Filter")
|
||||
@PostMapping("/search/{prjctIdx}")
|
||||
public PageResponseDto<ListSearchWithResultDto> searchListWithFilter(
|
||||
public PageResponseDto<ListSearchWithFullResultDto> searchListWithFilter(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListSearchRequestDto request
|
||||
){
|
||||
return listSearchService.getListSearchWithResultList(prjctIdx, request);
|
||||
) {
|
||||
return listSearchService.searchListWithPaging(
|
||||
prjctIdx,
|
||||
request,
|
||||
ListSearchResponseType.WITH_FULL_RESULT
|
||||
);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 파일 업로드 양식 다운로드")
|
||||
@PostMapping("/excel/template/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadExcelTemplate(
|
||||
@PathVariable Long prjctIdx,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) throw BusinessException.internalError("프로젝트가 없습니다.");
|
||||
|
||||
public ResponseEntity<byte[]> downloadExcelTemplate(@PathVariable Long prjctIdx) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listUploadService.downloadExcelTemplate(prjctIdx);
|
||||
String fileName = projectInfoDto.getPrjctName() + " upload_template.xlsx";
|
||||
String contentDisposition = "attachment; filename*=UTF-8''" +
|
||||
URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " upload_template.xlsx", bytes);
|
||||
}
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition)
|
||||
.contentType(MediaType.parseMediaType(
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
|
||||
.body(bytes);
|
||||
@Operation(summary = "리스트 다운로드")
|
||||
@PostMapping("/excel/download/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadList(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestBody(required = false) ListFilterDto listFilter
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadList(prjctIdx, listFilter);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " list.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 수정 이력 다운로드")
|
||||
@PostMapping("/excel/download/update/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadListUpdateHistory(
|
||||
@PathVariable Long prjctIdx,
|
||||
@RequestBody(required = false) ListFilterDto listFilter
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadSidWithUpdateHist(prjctIdx, listFilter);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " 수정 이력.xlsx", bytes);
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 파일 업로드")
|
||||
@@ -99,43 +115,51 @@ public class ListController {
|
||||
@Valid @RequestPart("request") ListUploadRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) throw BusinessException.internalError("프로젝트가 없습니다.");
|
||||
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
getProjectOrThrow(prjctIdx);
|
||||
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
ExcelUploadResultDto result = listUploadService.uploadExcel(prjctIdx, file, request, ctx.getUserId(), now);
|
||||
systemEventLogService.writeUploadList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, file.getOriginalFilename());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 수정")
|
||||
@PostMapping("/update/{prjctIdx}")
|
||||
@PatchMapping("/update/{prjctIdx}")
|
||||
public int updateList(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListUpdateRequestDto request,
|
||||
RequestUserContext ctx) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
int updateCount = listUpdateService.updateList(prjctIdx, request, ctx.getUserRole(), ctx.getUserId(), now);
|
||||
systemEventLogService.writeUpdateList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, request);
|
||||
|
||||
return updateCount;
|
||||
}
|
||||
|
||||
@Operation(summary = "리스트 삭제")
|
||||
@Operation(summary = "리스트 초기화")
|
||||
@DeleteMapping("/{prjctIdx}")
|
||||
public int resetList(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListResetRequestDto request,
|
||||
RequestUserContext ctx
|
||||
){
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
int resetCount = listResetService.resetByFilter(prjctIdx, request.getListFilter(), request.getResetMode(), ctx.getUserId(), now);
|
||||
) {
|
||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
int resetCount = listResetService.resetByFilter(
|
||||
prjctIdx,
|
||||
request.getListFilter(),
|
||||
request.getResetMode(),
|
||||
ctx.getUserId(),
|
||||
now
|
||||
);
|
||||
systemEventLogService.writeResetList(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, request);
|
||||
|
||||
return resetCount;
|
||||
}
|
||||
|
||||
private ProjectInfoDto getProjectOrThrow(Long prjctIdx) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) {
|
||||
throw BusinessException.internalError("프로젝트가 없습니다.");
|
||||
}
|
||||
return projectInfoDto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.kri.contact.server.controller;
|
||||
|
||||
import static com.kri.contact.server.common.util.ExcelResponseBuilder.buildExcelResponse;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.contact.server.dto.list.ListEventHistDownloadRequestDto;
|
||||
import com.kri.contact.server.dto.project.ProjectInfoDto;
|
||||
import com.kri.contact.server.service.ListDownloadService;
|
||||
import com.kri.contact.server.service.ProjectService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/list")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "ListHistory", description = "리스트 이력 API")
|
||||
public class ListHistoryController {
|
||||
|
||||
private final ProjectService projectService;
|
||||
private final ListDownloadService listDownloadService;
|
||||
|
||||
@Operation(summary = "리스트 이벤트 이력 다운로드")
|
||||
@PostMapping("/excel/download/event/{prjctIdx}")
|
||||
public ResponseEntity<byte[]> downloadListWithEventHistory(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody ListEventHistDownloadRequestDto request
|
||||
) {
|
||||
ProjectInfoDto projectInfoDto = getProjectOrThrow(prjctIdx);
|
||||
byte[] bytes = listDownloadService.downloadListWithEventHist(
|
||||
prjctIdx,
|
||||
request.getListFilter(),
|
||||
request.getResultCodeTypes(),
|
||||
request.getDateRange()
|
||||
);
|
||||
return buildExcelResponse(projectInfoDto.getPrjctName() + " 컨택 이력.xlsx", bytes);
|
||||
}
|
||||
|
||||
private ProjectInfoDto getProjectOrThrow(Long prjctIdx) {
|
||||
ProjectInfoDto projectInfoDto = projectService.getProject(prjctIdx);
|
||||
if (projectInfoDto == null) {
|
||||
throw BusinessException.internalError("프로젝트가 없습니다.");
|
||||
}
|
||||
return projectInfoDto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kri.contact.server.dto.common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "날짜 범위 Dto")
|
||||
public class DateRangeDto {
|
||||
|
||||
@Schema(description = "시작 날짜")
|
||||
private LocalDateTime startDate;
|
||||
@Schema(description = "종료 날짜")
|
||||
private LocalDateTime endDate;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.kri.contact.server.dto.list;
|
||||
|
||||
import com.kri.contact.server.common.enums.ResultCodeType;
|
||||
import com.kri.contact.server.dto.common.DateRangeDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "리스트 + 컨택이력 다운로드 요청 DTO")
|
||||
public class ListEventHistDownloadRequestDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "리스트 필터")
|
||||
private ListFilterDto listFilter;
|
||||
|
||||
@NotEmpty
|
||||
@Schema(description = "조회할 ResultCodeType 목록")
|
||||
private List<ResultCodeType> resultCodeTypes;
|
||||
|
||||
@Valid
|
||||
@Schema(description = "조회 기간")
|
||||
private DateRangeDto dateRange;
|
||||
}
|
||||
@@ -5,11 +5,17 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "리스트 검색 조건")
|
||||
public class ListSearchRequestDto {
|
||||
|
||||
@@ -20,4 +26,11 @@ public class ListSearchRequestDto {
|
||||
@NotNull
|
||||
@Schema(description = "페이지네이션 정보")
|
||||
private PageRequestDto pageRequest;
|
||||
|
||||
public static ListSearchRequestDto of(ListFilterDto listFilter, PageRequestDto pageRequest){
|
||||
return ListSearchRequestDto.builder()
|
||||
.listFilter(listFilter)
|
||||
.pageRequest(pageRequest)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.kri.contact.server.dto.list;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "리스트 조회 응답(기본 + 결과 + 발송 결과)")
|
||||
public class ListSearchResponseDto extends ListSearchWithResultDto {
|
||||
|
||||
@Schema(description = "메일 발송 결과")
|
||||
private ListResultBaseDto mailSendResult;
|
||||
|
||||
@Schema(description = "문자 발송 결과")
|
||||
private ListResultBaseDto smsSendResult;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.kri.contact.server.dto.list;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TListEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "리스트 조회 응답(기본 + 결과 + 발송 결과)")
|
||||
public class ListSearchWithFullResultDto extends ListSearchWithResultDto {
|
||||
|
||||
@Schema(description = "메일 발송 결과")
|
||||
private ListResultBaseDto mailSendResult;
|
||||
|
||||
@Schema(description = "문자 발송 결과")
|
||||
private ListResultBaseDto smsSendResult;
|
||||
|
||||
public static ListSearchWithFullResultDto from(
|
||||
TListEntity entity,
|
||||
Map<Integer, String> itemList,
|
||||
ListContactResultDto contactResult,
|
||||
ListContactResultDto interviewResult,
|
||||
ListResultBaseDto surveyResult,
|
||||
ListResultBaseDto mailSendResult,
|
||||
ListResultBaseDto smsSendResult
|
||||
) {
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ListSearchWithFullResultDto.builder()
|
||||
.prjctIdx(entity.getPrjctIdx())
|
||||
.sid(entity.getSid())
|
||||
.use(entity.getUse())
|
||||
.memo(entity.getMemo())
|
||||
.itemList(itemList)
|
||||
.contactResult(contactResult)
|
||||
.interviewResult(interviewResult)
|
||||
.surveyResult(surveyResult)
|
||||
.mailSendResult(mailSendResult)
|
||||
.smsSendResult(smsSendResult)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.kri.contact.server.persistence.repository;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TListAssignEntity;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -27,4 +28,16 @@ public interface ListAssignRepository extends JpaRepository<TListAssignEntity, L
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select a
|
||||
from TListAssignEntity a
|
||||
where a.prjctIdx = :prjctIdx
|
||||
and a.sid in :sids
|
||||
order by a.sid asc, a.listAssignIdx asc
|
||||
""")
|
||||
List<TListAssignEntity> findByPrjctIdxAndSidIn(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.kri.contact.server.persistence.repository;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TListEventHistEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -65,4 +67,45 @@ public interface ListEventHistRepository extends JpaRepository<TListEventHistEnt
|
||||
Long prjctIdx,
|
||||
List<Integer> sids
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select h
|
||||
from TListEventHistEntity h
|
||||
where h.prjctIdx = :prjctIdx
|
||||
and h.sid in :sids
|
||||
and h.eventTy in :eventTypes
|
||||
and (:startDate is null or h.regDt >= :startDate)
|
||||
and (:endDate is null or h.regDt <= :endDate)
|
||||
order by h.sid asc, h.regDt asc, h.listEventHistIdx asc
|
||||
""")
|
||||
List<TListEventHistEntity> findDownloadHistories(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids,
|
||||
Collection<Short> eventTypes,
|
||||
LocalDateTime startDate,
|
||||
LocalDateTime endDate
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select h.sid as sid, count(h) as historyCount
|
||||
from TListEventHistEntity h
|
||||
where h.prjctIdx = :prjctIdx
|
||||
and h.sid in :sids
|
||||
and h.eventTy in :eventTypes
|
||||
and (:startDate is null or h.regDt >= :startDate)
|
||||
and (:endDate is null or h.regDt <= :endDate)
|
||||
group by h.sid
|
||||
""")
|
||||
List<EventHistoryCountProjection> findDownloadHistoryCounts(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids,
|
||||
Collection<Short> eventTypes,
|
||||
LocalDateTime startDate,
|
||||
LocalDateTime endDate
|
||||
);
|
||||
|
||||
interface EventHistoryCountProjection {
|
||||
Integer getSid();
|
||||
Long getHistoryCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,20 @@ public interface ListQueryRepository {
|
||||
List<TListEntity> findAllListEntities(Long prjctIdx, List<Integer> emailTelnumHeaderIds, ListFilterDto listFilter);
|
||||
|
||||
List<Integer> findAllSids(Long prjctIdx, List<Integer> emailTelnumHeaderIds, ListFilterDto listFilter);
|
||||
|
||||
List<TListEntity> findChunkedListEntities(
|
||||
Long prjctIdx,
|
||||
List<Integer> emailTelnumHeaderIds,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid,
|
||||
int limit
|
||||
);
|
||||
|
||||
List<Integer> findChunkedSids(
|
||||
Long prjctIdx,
|
||||
List<Integer> emailTelnumHeaderIds,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid,
|
||||
int limit
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,49 @@ public class ListQueryRepositoryImpl implements ListQueryRepository {
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TListEntity> findChunkedListEntities(
|
||||
Long prjctIdx,
|
||||
List<Integer> emailTelnumHeaderIds,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid,
|
||||
int limit
|
||||
) {
|
||||
QTListEntity list = QTListEntity.tListEntity;
|
||||
BooleanBuilder predicate = buildListFilterPredicate(prjctIdx, emailTelnumHeaderIds, listFilter, list);
|
||||
if (lastSid != null) {
|
||||
predicate.and(list.id.sid.gt(lastSid));
|
||||
}
|
||||
|
||||
return jpaQueryFactory.selectFrom(list)
|
||||
.where(predicate)
|
||||
.orderBy(list.id.sid.asc())
|
||||
.limit(limit)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> findChunkedSids(
|
||||
Long prjctIdx,
|
||||
List<Integer> emailTelnumHeaderIds,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid,
|
||||
int limit
|
||||
) {
|
||||
QTListEntity list = QTListEntity.tListEntity;
|
||||
BooleanBuilder predicate = buildListFilterPredicate(prjctIdx, emailTelnumHeaderIds, listFilter, list);
|
||||
if (lastSid != null) {
|
||||
predicate.and(list.id.sid.gt(lastSid));
|
||||
}
|
||||
|
||||
return jpaQueryFactory.select(list.id.sid)
|
||||
.from(list)
|
||||
.where(predicate)
|
||||
.orderBy(list.id.sid.asc())
|
||||
.limit(limit)
|
||||
.fetch();
|
||||
}
|
||||
|
||||
private BooleanBuilder buildListFilterPredicate(
|
||||
Long prjctIdx,
|
||||
List<Integer> emailTelnumHeaderIds,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.kri.contact.server.persistence.repository;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TListUpdateHistEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface ListUpdateHistRepository extends JpaRepository<TListUpdateHistEntity, Long> {
|
||||
|
||||
@Query("""
|
||||
select h
|
||||
from TListUpdateHistEntity h
|
||||
where h.prjctIdx = :prjctIdx
|
||||
and h.sid in :sids
|
||||
order by h.sid asc, h.regDt asc, h.regUser asc, h.listUpdateHistIdx asc
|
||||
""")
|
||||
List<TListUpdateHistEntity> findDownloadHistories(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
);
|
||||
|
||||
@Query("""
|
||||
select h.sid as sid, h.regDt as regDt, h.regUser as regUser
|
||||
from TListUpdateHistEntity h
|
||||
where h.prjctIdx = :prjctIdx
|
||||
and h.sid in :sids
|
||||
group by h.sid, h.regDt, h.regUser
|
||||
order by h.sid asc, h.regDt asc, h.regUser asc
|
||||
""")
|
||||
List<UpdateHistoryGroupProjection> findDownloadHistoryGroups(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
);
|
||||
|
||||
interface UpdateHistoryGroupProjection {
|
||||
Integer getSid();
|
||||
LocalDateTime getRegDt();
|
||||
String getRegUser();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.kri.contact.server.persistence.repository;
|
||||
|
||||
import com.kri.contact.server.persistence.entity.TUserEntity;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@@ -20,6 +21,8 @@ public interface UserRepository extends JpaRepository<TUserEntity, Long> {
|
||||
|
||||
List<TUserEntity> findByUserCmpnAndUserRoleGreaterThanEqualAndDelFalse(String userCmpn, Integer userRoleCd);
|
||||
|
||||
List<TUserEntity> findByUserIdInAndDelFalse(Collection<String> userIds);
|
||||
|
||||
@Query("""
|
||||
select u
|
||||
from TUserEntity u
|
||||
@@ -59,4 +62,4 @@ public interface UserRepository extends JpaRepository<TUserEntity, Long> {
|
||||
and u.del = false
|
||||
""")
|
||||
int softDeleteByUserId(String userId, String delUser, LocalDateTime delDt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.contact.server.common.enums.ListHeaderType;
|
||||
import com.kri.contact.server.common.enums.ListIsUse;
|
||||
import com.kri.contact.server.common.enums.ResultCodeType;
|
||||
import com.kri.contact.server.dto.common.DateRangeDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ListDownloadService {
|
||||
|
||||
private static final String HEADER_TYPE = "구분";
|
||||
private static final String HEADER_DATE = "일시";
|
||||
private static final String HEADER_USER = "사용자";
|
||||
private static final String HEADER_RESULT = "결과";
|
||||
private static final String HEADER_MEMO = "메모";
|
||||
private static final String HEADER_BEFORE = "변경전";
|
||||
private static final String HEADER_AFTER = "변경후";
|
||||
|
||||
private static final List<String> EVENT_HISTORY_HEADERS = List.of(
|
||||
HEADER_TYPE,
|
||||
HEADER_DATE,
|
||||
HEADER_USER,
|
||||
HEADER_RESULT,
|
||||
HEADER_MEMO
|
||||
);
|
||||
private static final List<String> UPDATE_HISTORY_HEADERS = List.of(
|
||||
HEADER_DATE,
|
||||
HEADER_USER,
|
||||
HEADER_BEFORE,
|
||||
HEADER_AFTER
|
||||
);
|
||||
|
||||
private final ListHeaderService listHeaderService;
|
||||
private final ListSearchService listSearchService;
|
||||
|
||||
public byte[] downloadList(Long prjctIdx, ListFilterDto listFilter) {
|
||||
List<ListHeaderDto> headers = getSortedHeaders(prjctIdx);
|
||||
|
||||
try (
|
||||
ExcelMapper.StreamingMapWriter writer = ExcelMapper.openStreamingMapWriter(toBaseHeaderNames(headers), 100);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()
|
||||
) {
|
||||
Integer lastSid = null;
|
||||
while (true) {
|
||||
List<ListSearchService.DownloadListRow> rows = listSearchService.findDownloadListRows(prjctIdx, listFilter, lastSid);
|
||||
if (rows.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (ListSearchService.DownloadListRow row : rows) {
|
||||
writer.append(createBaseRow(headers, row));
|
||||
lastSid = row.sid();
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeTo(out);
|
||||
return out.toByteArray();
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("리스트 다운로드 파일 생성 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] downloadListWithEventHist(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
Collection<ResultCodeType> resultCodeTypes,
|
||||
DateRangeDto dateRange
|
||||
) {
|
||||
validateDateRange(dateRange);
|
||||
List<ListHeaderDto> headers = getSortedHeaders(prjctIdx);
|
||||
int maxHistoryCount = findMaxEventHistoryCount(prjctIdx, listFilter, resultCodeTypes, dateRange);
|
||||
List<String> excelHeaders = new ArrayList<>(toBaseHeaderNames(headers));
|
||||
appendRepeatedHeaders(excelHeaders, EVENT_HISTORY_HEADERS, maxHistoryCount);
|
||||
|
||||
try (
|
||||
ExcelMapper.StreamingMapWriter writer = ExcelMapper.openStreamingMapWriter(excelHeaders, 100);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()
|
||||
) {
|
||||
Integer lastSid = null;
|
||||
while (true) {
|
||||
List<ListSearchService.DownloadListRow> rows = listSearchService.findDownloadListRows(prjctIdx, listFilter, lastSid);
|
||||
if (rows.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
List<Integer> sids = rows.stream().map(ListSearchService.DownloadListRow::sid).toList();
|
||||
Map<Integer, List<ListSearchService.EventHistoryRow>> historyMap = listSearchService.findEventHistoriesForDownload(
|
||||
prjctIdx,
|
||||
sids,
|
||||
resultCodeTypes,
|
||||
dateRange
|
||||
);
|
||||
|
||||
for (ListSearchService.DownloadListRow row : rows) {
|
||||
writer.append(createEventHistoryRow(
|
||||
headers,
|
||||
row,
|
||||
historyMap.getOrDefault(row.sid(), List.of()),
|
||||
maxHistoryCount
|
||||
));
|
||||
lastSid = row.sid();
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeTo(out);
|
||||
return out.toByteArray();
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("리스트 + 컨택이력 다운로드 파일 생성 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] downloadSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter) {
|
||||
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter);
|
||||
List<String> excelHeaders = new ArrayList<>();
|
||||
excelHeaders.add("sid");
|
||||
appendRepeatedHeaders(excelHeaders, UPDATE_HISTORY_HEADERS, maxHistoryGroupCount);
|
||||
|
||||
try (
|
||||
ExcelMapper.StreamingMapWriter writer = ExcelMapper.openStreamingMapWriter(excelHeaders, 100);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream()
|
||||
) {
|
||||
Integer lastSid = null;
|
||||
while (true) {
|
||||
List<Integer> sids = listSearchService.findDownloadSids(prjctIdx, listFilter, lastSid);
|
||||
if (sids.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
Map<Integer, List<ListSearchService.UpdateHistoryGroupRow>> historyMap =
|
||||
listSearchService.findUpdateHistoryGroupsForDownload(prjctIdx, sids);
|
||||
|
||||
for (Integer sid : sids) {
|
||||
writer.append(createUpdateHistoryRow(
|
||||
sid,
|
||||
historyMap.getOrDefault(sid, List.of()),
|
||||
maxHistoryGroupCount
|
||||
));
|
||||
lastSid = sid;
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeTo(out);
|
||||
return out.toByteArray();
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw BusinessException.internalError("SID + 수정이력 다운로드 파일 생성 중 오류가 발생했습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private int findMaxEventHistoryCount(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
Collection<ResultCodeType> resultCodeTypes,
|
||||
DateRangeDto dateRange
|
||||
) {
|
||||
int maxCount = 0;
|
||||
Integer lastSid = null;
|
||||
while (true) {
|
||||
List<Integer> sids = listSearchService.findDownloadSids(prjctIdx, listFilter, lastSid);
|
||||
if (sids.isEmpty()) {
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
Map<Integer, Integer> countMap = listSearchService.findEventHistoryCountsForDownload(
|
||||
prjctIdx,
|
||||
sids,
|
||||
resultCodeTypes,
|
||||
dateRange
|
||||
);
|
||||
for (Integer count : countMap.values()) {
|
||||
maxCount = Math.max(maxCount, count);
|
||||
}
|
||||
lastSid = sids.get(sids.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private int findMaxUpdateHistoryGroupCount(Long prjctIdx, ListFilterDto listFilter) {
|
||||
int maxCount = 0;
|
||||
Integer lastSid = null;
|
||||
while (true) {
|
||||
List<Integer> sids = listSearchService.findDownloadSids(prjctIdx, listFilter, lastSid);
|
||||
if (sids.isEmpty()) {
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
Map<Integer, Integer> countMap = listSearchService.findUpdateHistoryGroupCountsForDownload(prjctIdx, sids);
|
||||
for (Integer count : countMap.values()) {
|
||||
maxCount = Math.max(maxCount, count);
|
||||
}
|
||||
lastSid = sids.get(sids.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ListHeaderDto> getSortedHeaders(Long prjctIdx) {
|
||||
List<ListHeaderDto> headers = listHeaderService.getHeader(prjctIdx).stream()
|
||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderOrder))
|
||||
.toList();
|
||||
if (headers.isEmpty()) {
|
||||
throw BusinessException.badRequest("LIST_HEADER_NOT_FOUND", "리스트 헤더가 없습니다.");
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
private List<String> toBaseHeaderNames(List<ListHeaderDto> headers) {
|
||||
return headers.stream()
|
||||
.map(ListHeaderDto::getListHderNm)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private Map<String, Object> createBaseRow(List<ListHeaderDto> headers, ListSearchService.DownloadListRow row) {
|
||||
Map<String, Object> excelRow = new LinkedHashMap<>();
|
||||
for (ListHeaderDto header : headers) {
|
||||
excelRow.put(header.getListHderNm(), resolveBaseCellValue(header, row));
|
||||
}
|
||||
return excelRow;
|
||||
}
|
||||
|
||||
private Map<String, Object> createEventHistoryRow(
|
||||
List<ListHeaderDto> headers,
|
||||
ListSearchService.DownloadListRow row,
|
||||
List<ListSearchService.EventHistoryRow> histories,
|
||||
int maxHistoryCount
|
||||
) {
|
||||
Map<String, Object> excelRow = createBaseRow(headers, row);
|
||||
for (int index = 0; index < maxHistoryCount; index++) {
|
||||
ListSearchService.EventHistoryRow history = index < histories.size() ? histories.get(index) : null;
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_TYPE, index), history == null ? "" : defaultString(history.eventTy()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_DATE, index), history == null ? "" : formatDateTime(history.regDt()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_USER, index), history == null ? "" : defaultString(history.regUser()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_RESULT, index), history == null ? "" : defaultString(history.resultCd()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_MEMO, index), history == null ? "" : defaultString(history.memo()));
|
||||
}
|
||||
return excelRow;
|
||||
}
|
||||
|
||||
private Map<String, Object> createUpdateHistoryRow(
|
||||
Integer sid,
|
||||
List<ListSearchService.UpdateHistoryGroupRow> histories,
|
||||
int maxHistoryCount
|
||||
) {
|
||||
Map<String, Object> excelRow = new LinkedHashMap<>();
|
||||
excelRow.put("sid", sid);
|
||||
for (int index = 0; index < maxHistoryCount; index++) {
|
||||
ListSearchService.UpdateHistoryGroupRow history = index < histories.size() ? histories.get(index) : null;
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_DATE, index), history == null ? "" : formatDateTime(history.regDt()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_USER, index), history == null ? "" : defaultString(history.regUser()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_BEFORE, index), history == null ? "" : defaultString(history.beforeSummary()));
|
||||
excelRow.put(createRepeatedHeaderName(HEADER_AFTER, index), history == null ? "" : defaultString(history.afterSummary()));
|
||||
}
|
||||
return excelRow;
|
||||
}
|
||||
|
||||
private Object resolveBaseCellValue(ListHeaderDto header, ListSearchService.DownloadListRow row) {
|
||||
if (Objects.equals(header.getListHderTy(), ListHeaderType.SID)) {
|
||||
return row.sid();
|
||||
}
|
||||
if (Objects.equals(header.getListHderTy(), ListHeaderType.IS_USE)) {
|
||||
return toUseValue(row.isUse());
|
||||
}
|
||||
if (Objects.equals(header.getListHderTy(), ListHeaderType.MEMO)) {
|
||||
return defaultString(row.memo());
|
||||
}
|
||||
if (Objects.equals(header.getListHderTy(), ListHeaderType.OUTSOURCE)) {
|
||||
return String.join(", ", row.assignValues().outsourceUserIds());
|
||||
}
|
||||
if (Objects.equals(header.getListHderTy(), ListHeaderType.FIELDWORK)) {
|
||||
return String.join(", ", row.assignValues().fieldworkUserIds());
|
||||
}
|
||||
return defaultString(row.itemMap().get(header.getListHderId()));
|
||||
}
|
||||
|
||||
private void appendRepeatedHeaders(List<String> headers, List<String> repeatedHeaders, int repeatCount) {
|
||||
for (int index = 0; index < repeatCount; index++) {
|
||||
for (String repeatedHeader : repeatedHeaders) {
|
||||
headers.add(createRepeatedHeaderName(repeatedHeader, index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String createRepeatedHeaderName(String headerName, int index) {
|
||||
return index == 0 ? headerName : headerName + "\u200B".repeat(index);
|
||||
}
|
||||
|
||||
private void validateDateRange(DateRangeDto dateRange) {
|
||||
if (dateRange == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dateRange.getStartDate() != null
|
||||
&& dateRange.getEndDate() != null
|
||||
&& dateRange.getStartDate().isAfter(dateRange.getEndDate())) {
|
||||
throw BusinessException.badRequest("INVALID_DATE_RANGE", "시작일은 종료일보다 늦을 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDateTime(LocalDateTime dateTime) {
|
||||
return dateTime == null ? "" : DateTimeUtil.DATETIME_FMT.format(dateTime);
|
||||
}
|
||||
|
||||
private String toUseValue(Short isUse) {
|
||||
if (Objects.equals(isUse, ListIsUse.USABLE.getCode())) {
|
||||
return "O";
|
||||
}
|
||||
if (Objects.equals(isUse, ListIsUse.UNUSABLE.getCode())) {
|
||||
return "X";
|
||||
}
|
||||
if (Objects.equals(isUse, ListIsUse.TEST.getCode())) {
|
||||
return "TEST";
|
||||
}
|
||||
return defaultString(isUse);
|
||||
}
|
||||
|
||||
private String defaultString(Object value) {
|
||||
return value == null ? "" : String.valueOf(value);
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,40 @@ package com.kri.contact.server.service;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.common.feature.web.page.PageRequestDto;
|
||||
import com.kri.common.feature.web.page.PageResponseDto;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.common.enums.ListSearchResponseType;
|
||||
import com.kri.contact.server.common.enums.ResultCodeType;
|
||||
import com.kri.contact.server.dto.common.DateRangeDto;
|
||||
import com.kri.contact.server.dto.list.ListContactResultDto;
|
||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||
import com.kri.contact.server.dto.list.ListResultBaseDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchBaseDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchRequestDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchWithFullResultDto;
|
||||
import com.kri.contact.server.dto.list.ListSearchWithResultDto;
|
||||
import com.kri.contact.server.persistence.entity.TListAssignEntity;
|
||||
import com.kri.contact.server.persistence.entity.TListEntity;
|
||||
import com.kri.contact.server.persistence.entity.TListEventHistEntity;
|
||||
import com.kri.contact.server.persistence.entity.TListItemEntity;
|
||||
import com.kri.contact.server.persistence.entity.TListUpdateHistEntity;
|
||||
import com.kri.contact.server.persistence.entity.TUserEntity;
|
||||
import com.kri.contact.server.persistence.repository.ListAssignRepository;
|
||||
import com.kri.contact.server.persistence.repository.ListEventHistRepository;
|
||||
import com.kri.contact.server.persistence.repository.ListItemRepository;
|
||||
import com.kri.contact.server.persistence.repository.ListRepository;
|
||||
import com.kri.contact.server.persistence.repository.ListUpdateHistRepository;
|
||||
import com.kri.contact.server.persistence.repository.UserRepository;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -36,18 +49,24 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@RequiredArgsConstructor
|
||||
public class ListSearchService {
|
||||
|
||||
private final ListAssignRepository listAssignRepository;
|
||||
private final ListEventHistRepository listEventHistRepository;
|
||||
private final ListItemRepository listItemRepository;
|
||||
private final ListRepository listRepository;
|
||||
private final ListUpdateHistRepository listUpdateHistRepository;
|
||||
private final ListHeaderService listHeaderService;
|
||||
private final UserRepository userRepository;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public ListSearchWithResultDto getListSearchOne(Long prjctIdx, Integer sid) {
|
||||
public ListSearchWithFullResultDto searchListWithSid(Long prjctIdx, Integer sid) {
|
||||
ListFilterDto filterDto = ListFilterDto.onlyOneSid(sid);
|
||||
List<ListSearchWithResultDto> result = createListSearchWithResult(prjctIdx, findAllListEntities(prjctIdx, filterDto));
|
||||
List<ListSearchWithFullResultDto> result = createListSearchWithFullResult(
|
||||
prjctIdx,
|
||||
findAllListEntities(prjctIdx, filterDto)
|
||||
);
|
||||
|
||||
if (result.isEmpty()) {
|
||||
throw BusinessException.notFound("Not found list", "해당하는 List가 없습니다.")
|
||||
throw BusinessException.notFound("LIST_NOT_FOUND", "해당하는 리스트가 없습니다.")
|
||||
.with("sid", sid);
|
||||
}
|
||||
|
||||
@@ -55,17 +74,18 @@ public class ListSearchService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public PageResponseDto<ListSearchWithResultDto> getListSearchWithResultList(
|
||||
public <T extends ListSearchBaseDto> PageResponseDto<T> searchListWithPaging(
|
||||
Long prjctIdx,
|
||||
ListSearchRequestDto request
|
||||
ListSearchRequestDto request,
|
||||
ListSearchResponseType responseType
|
||||
) {
|
||||
List<TListEntity> listEntities = findPagedListEntities(prjctIdx, request);
|
||||
List<ListSearchWithResultDto> content = createListSearchWithResult(prjctIdx, listEntities);
|
||||
long totalCount = findAllSids(prjctIdx, request == null ? null : request.getListFilter()).size();
|
||||
List<T> content = createListSearch(prjctIdx, listEntities, responseType);
|
||||
int totalCount = findAllSids(prjctIdx, request == null ? null : request.getListFilter()).size();
|
||||
|
||||
PageRequestDto pageRequest = request == null ? null : request.getPageRequest();
|
||||
int pageIndex = pageRequest == null ? 0 : Math.max(pageRequest.getPageIndex(), 0);
|
||||
int pageSize = pageRequest == null ? Math.max(content.size(), 1) : Math.max(pageRequest.getPageSize(), 1);
|
||||
int pageSize = pageRequest == null ? Math.max(totalCount, 1) : Math.max(pageRequest.getPageSize(), 1);
|
||||
|
||||
return PageResponseDto.from(new PageImpl<>(
|
||||
content,
|
||||
@@ -73,11 +93,207 @@ public class ListSearchService {
|
||||
totalCount
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public <T extends ListSearchBaseDto> List<T> searchListWithPagingOnlyContents(
|
||||
Long prjctIdx,
|
||||
ListSearchRequestDto request,
|
||||
ListSearchResponseType responseType
|
||||
) {
|
||||
List<TListEntity> listEntities = findPagedListEntities(prjctIdx, request);
|
||||
return createListSearch(prjctIdx, listEntities, responseType);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Set<Integer> findTargetSids(Long prjctIdx, ListFilterDto listFilter) {
|
||||
return new LinkedHashSet<>(findAllSids(prjctIdx, listFilter));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<DownloadListRow> findDownloadListRows(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid
|
||||
) {
|
||||
List<Integer> emailTelnumHeaderIds = listHeaderService.getEmailTelnumHeaderId(prjctIdx);
|
||||
List<TListEntity> listEntities = listRepository.findChunkedListEntities(
|
||||
prjctIdx,
|
||||
emailTelnumHeaderIds,
|
||||
listFilter,
|
||||
lastSid,
|
||||
ContactConstant.LIST_SELECT_CHUNK_SIZE
|
||||
);
|
||||
if (listEntities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<Integer> sidSet = listEntities.stream()
|
||||
.map(TListEntity::getSid)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
Map<Integer, Map<Integer, String>> itemMapBySid = createItemMapBySid(prjctIdx, sidSet, null);
|
||||
Map<Integer, AssignValues> assignMapBySid = createAssignMapBySid(prjctIdx, sidSet);
|
||||
|
||||
return listEntities.stream()
|
||||
.map(entity -> new DownloadListRow(
|
||||
entity.getSid(),
|
||||
entity.getUse(),
|
||||
entity.getMemo(),
|
||||
itemMapBySid.getOrDefault(entity.getSid(), Collections.emptyMap()),
|
||||
assignMapBySid.getOrDefault(entity.getSid(), AssignValues.empty())
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<Integer> findDownloadSids(
|
||||
Long prjctIdx,
|
||||
ListFilterDto listFilter,
|
||||
Integer lastSid
|
||||
) {
|
||||
List<Integer> emailTelnumHeaderIds = listHeaderService.getEmailTelnumHeaderId(prjctIdx);
|
||||
return listRepository.findChunkedSids(
|
||||
prjctIdx,
|
||||
emailTelnumHeaderIds,
|
||||
listFilter,
|
||||
lastSid,
|
||||
ContactConstant.LIST_SELECT_CHUNK_SIZE
|
||||
);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Map<Integer, Integer> findEventHistoryCountsForDownload(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids,
|
||||
Collection<ResultCodeType> resultCodeTypes,
|
||||
DateRangeDto dateRange
|
||||
) {
|
||||
if (sids == null || sids.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return listEventHistRepository.findDownloadHistoryCounts(
|
||||
prjctIdx,
|
||||
sids,
|
||||
toEventTypeCodes(resultCodeTypes),
|
||||
getStartDate(dateRange),
|
||||
getEndDate(dateRange)
|
||||
)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
ListEventHistRepository.EventHistoryCountProjection::getSid,
|
||||
projection -> projection.getHistoryCount().intValue(),
|
||||
(left, right) -> right,
|
||||
LinkedHashMap::new
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Map<Integer, List<EventHistoryRow>> findEventHistoriesForDownload(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids,
|
||||
Collection<ResultCodeType> resultCodeTypes,
|
||||
DateRangeDto dateRange
|
||||
) {
|
||||
if (sids == null || sids.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return listEventHistRepository.findDownloadHistories(
|
||||
prjctIdx,
|
||||
sids,
|
||||
toEventTypeCodes(resultCodeTypes),
|
||||
getStartDate(dateRange),
|
||||
getEndDate(dateRange)
|
||||
)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TListEventHistEntity::getSid,
|
||||
LinkedHashMap::new,
|
||||
Collectors.mapping(
|
||||
entity -> new EventHistoryRow(
|
||||
entity.getEventTy(),
|
||||
entity.getRegDt(),
|
||||
entity.getRegUser(),
|
||||
entity.getResultCd(),
|
||||
entity.getMemo()
|
||||
),
|
||||
Collectors.toList()
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Map<Integer, Integer> findUpdateHistoryGroupCountsForDownload(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
) {
|
||||
if (sids == null || sids.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<Integer, Integer> counts = new LinkedHashMap<>();
|
||||
for (ListUpdateHistRepository.UpdateHistoryGroupProjection projection
|
||||
: listUpdateHistRepository.findDownloadHistoryGroups(prjctIdx, sids)) {
|
||||
counts.merge(projection.getSid(), 1, Integer::sum);
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Map<Integer, List<UpdateHistoryGroupRow>> findUpdateHistoryGroupsForDownload(
|
||||
Long prjctIdx,
|
||||
Collection<Integer> sids
|
||||
) {
|
||||
if (sids == null || sids.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<Integer, ListHeaderDto> headerMap = listHeaderService.getHeader(prjctIdx).stream()
|
||||
.collect(Collectors.toMap(
|
||||
ListHeaderDto::getListHderId,
|
||||
header -> header,
|
||||
(left, right) -> left,
|
||||
LinkedHashMap::new
|
||||
));
|
||||
|
||||
List<TListUpdateHistEntity> histories = listUpdateHistRepository.findDownloadHistories(prjctIdx, sids);
|
||||
Map<UpdateHistoryGroupKey, List<TListUpdateHistEntity>> grouped = histories.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
history -> new UpdateHistoryGroupKey(history.getSid(), history.getRegDt(), history.getRegUser()),
|
||||
LinkedHashMap::new,
|
||||
Collectors.toList()
|
||||
));
|
||||
|
||||
Map<Integer, List<UpdateHistoryGroupRow>> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<UpdateHistoryGroupKey, List<TListUpdateHistEntity>> entry : grouped.entrySet()) {
|
||||
List<TListUpdateHistEntity> groupHistories = entry.getValue().stream()
|
||||
.sorted(Comparator.comparing(
|
||||
(TListUpdateHistEntity history) -> headerMap.containsKey(history.getListHderId())
|
||||
? headerMap.get(history.getListHderId()).getListHderOrder()
|
||||
: Short.MAX_VALUE
|
||||
).thenComparing(TListUpdateHistEntity::getListUpdateHistIdx))
|
||||
.toList();
|
||||
|
||||
List<String> beforeValues = new ArrayList<>(groupHistories.size());
|
||||
List<String> afterValues = new ArrayList<>(groupHistories.size());
|
||||
for (TListUpdateHistEntity history : groupHistories) {
|
||||
String headerName = resolveHeaderName(headerMap, history.getListHderId());
|
||||
beforeValues.add(headerName + ": " + defaultString(history.getBeforeVal()));
|
||||
afterValues.add(headerName + ": " + defaultString(history.getAfterVal()));
|
||||
}
|
||||
|
||||
UpdateHistoryGroupKey key = entry.getKey();
|
||||
result.computeIfAbsent(key.sid(), ignored -> new ArrayList<>())
|
||||
.add(new UpdateHistoryGroupRow(
|
||||
key.regDt(),
|
||||
key.regUser(),
|
||||
"[" + String.join(", ", beforeValues) + "]",
|
||||
"[" + String.join(", ", afterValues) + "]"
|
||||
));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<ListUpdateTargetRow> findUpdateTargetRows(
|
||||
Long prjctIdx,
|
||||
@@ -109,8 +325,8 @@ public class ListSearchService {
|
||||
|
||||
private List<TListEntity> findPagedListEntities(Long prjctIdx, ListSearchRequestDto request) {
|
||||
List<Integer> emailTelnumHeaderIds = listHeaderService.getEmailTelnumHeaderId(prjctIdx);
|
||||
|
||||
ListFilterDto listFilter = request == null ? null : request.getListFilter();
|
||||
|
||||
return listRepository.findPagedListEntities(
|
||||
prjctIdx,
|
||||
emailTelnumHeaderIds,
|
||||
@@ -168,6 +384,61 @@ public class ListSearchService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
private List<ListSearchWithFullResultDto> createListSearchWithFullResult(Long prjctIdx, List<TListEntity> listEntities) {
|
||||
List<ListSearchRow> rows = createListSearchRows(prjctIdx, listEntities);
|
||||
if (rows.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Integer> sids = rows.stream()
|
||||
.map(row -> row.listEntity().getSid())
|
||||
.toList();
|
||||
|
||||
Map<ListResultKey, TListEventHistEntity> resultMap = listEventHistRepository
|
||||
.findLatestListByEventTy(prjctIdx, sids)
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
entity -> new ListResultKey(entity.getSid(), entity.getEventTy()),
|
||||
entity -> entity,
|
||||
(left, right) -> left
|
||||
));
|
||||
|
||||
ListResultBaseDto mailSendResult = null;
|
||||
ListResultBaseDto smsSendResult = null;
|
||||
|
||||
return rows.stream()
|
||||
.map(row -> {
|
||||
Integer sid = row.listEntity().getSid();
|
||||
return ListSearchWithFullResultDto.from(
|
||||
row.listEntity(),
|
||||
row.itemList(),
|
||||
ListContactResultDto.from(resultMap.get(new ListResultKey(sid, ResultCodeType.CONTACT.getCode()))),
|
||||
ListContactResultDto.from(resultMap.get(new ListResultKey(sid, ResultCodeType.INTERVIEW.getCode()))),
|
||||
ListResultBaseDto.from(resultMap.get(new ListResultKey(sid, ResultCodeType.SURVEY.getCode()))),
|
||||
mailSendResult,
|
||||
smsSendResult
|
||||
);
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends ListSearchBaseDto> List<T> createListSearch(
|
||||
Long prjctIdx,
|
||||
List<TListEntity> listEntities,
|
||||
ListSearchResponseType responseType
|
||||
) {
|
||||
if (responseType == null) {
|
||||
throw BusinessException.badRequest("INVALID_RESPONSE_TYPE", "리스트 반환 타입은 필수입니다.");
|
||||
}
|
||||
|
||||
return switch (responseType) {
|
||||
case BASE -> (List<T>) createListSearchBase(prjctIdx, listEntities);
|
||||
case WITH_RESULT -> (List<T>) createListSearchWithResult(prjctIdx, listEntities);
|
||||
case WITH_FULL_RESULT -> (List<T>) createListSearchWithFullResult(prjctIdx, listEntities);
|
||||
};
|
||||
}
|
||||
|
||||
private List<ListSearchRow> createListSearchRows(Long prjctIdx, List<TListEntity> listEntities) {
|
||||
if (listEntities.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
@@ -208,6 +479,71 @@ public class ListSearchService {
|
||||
));
|
||||
}
|
||||
|
||||
private Map<Integer, AssignValues> createAssignMapBySid(Long prjctIdx, Set<Integer> sidSet) {
|
||||
List<TListAssignEntity> assignEntities = listAssignRepository.findByPrjctIdxAndSidIn(prjctIdx, sidSet);
|
||||
if (assignEntities.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Set<String> assignedUserIds = assignEntities.stream()
|
||||
.map(TListAssignEntity::getUserId)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(userId -> !userId.isBlank())
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
Map<String, Integer> roleByUserId = userRepository.findByUserIdInAndDelFalse(assignedUserIds).stream()
|
||||
.collect(Collectors.toMap(
|
||||
TUserEntity::getUserId,
|
||||
TUserEntity::getUserRole,
|
||||
(left, right) -> right,
|
||||
LinkedHashMap::new
|
||||
));
|
||||
|
||||
Map<Integer, AssignValues> result = new LinkedHashMap<>();
|
||||
for (TListAssignEntity assignEntity : assignEntities) {
|
||||
Integer role = roleByUserId.get(assignEntity.getUserId());
|
||||
if (role == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AssignValues assignValues = result.computeIfAbsent(assignEntity.getSid(), ignored -> AssignValues.empty());
|
||||
if (role >= ContactConstant.FIELDWORK_USER_ROLE) {
|
||||
assignValues.fieldworkUserIds().add(assignEntity.getUserId());
|
||||
} else if (role >= ContactConstant.OUTSOURCE_USER_ROLE) {
|
||||
assignValues.outsourceUserIds().add(assignEntity.getUserId());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Short> toEventTypeCodes(Collection<ResultCodeType> resultCodeTypes) {
|
||||
if (resultCodeTypes == null || resultCodeTypes.isEmpty()) {
|
||||
throw BusinessException.badRequest("INVALID_RESULT_CODE_TYPE", "조회할 결과 구분은 1개 이상이어야 합니다.");
|
||||
}
|
||||
|
||||
return resultCodeTypes.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(ResultCodeType::getCode)
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
private LocalDateTime getStartDate(DateRangeDto dateRange) {
|
||||
return dateRange == null ? null : dateRange.getStartDate();
|
||||
}
|
||||
|
||||
private LocalDateTime getEndDate(DateRangeDto dateRange) {
|
||||
return dateRange == null ? null : dateRange.getEndDate();
|
||||
}
|
||||
|
||||
private String resolveHeaderName(Map<Integer, ListHeaderDto> headerMap, Integer headerId) {
|
||||
ListHeaderDto header = headerMap.get(headerId);
|
||||
return header == null ? String.valueOf(headerId) : header.getListHderNm();
|
||||
}
|
||||
|
||||
private String defaultString(String value) {
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
private record ListSearchRow(
|
||||
TListEntity listEntity,
|
||||
Map<Integer, String> itemList
|
||||
@@ -218,6 +554,44 @@ public class ListSearchService {
|
||||
Short eventTy
|
||||
) {}
|
||||
|
||||
private record UpdateHistoryGroupKey(
|
||||
Integer sid,
|
||||
LocalDateTime regDt,
|
||||
String regUser
|
||||
) {}
|
||||
|
||||
public record AssignValues(
|
||||
List<String> outsourceUserIds,
|
||||
List<String> fieldworkUserIds
|
||||
) {
|
||||
public static AssignValues empty() {
|
||||
return new AssignValues(new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
public record DownloadListRow(
|
||||
Integer sid,
|
||||
Short isUse,
|
||||
String memo,
|
||||
Map<Integer, String> itemMap,
|
||||
AssignValues assignValues
|
||||
) {}
|
||||
|
||||
public record EventHistoryRow(
|
||||
Short eventTy,
|
||||
LocalDateTime regDt,
|
||||
String regUser,
|
||||
Integer resultCd,
|
||||
String memo
|
||||
) {}
|
||||
|
||||
public record UpdateHistoryGroupRow(
|
||||
LocalDateTime regDt,
|
||||
String regUser,
|
||||
String beforeSummary,
|
||||
String afterSummary
|
||||
) {}
|
||||
|
||||
public record ListUpdateTargetRow(
|
||||
Integer sid,
|
||||
Short isUse,
|
||||
|
||||
@@ -9,11 +9,11 @@ import static com.kri.common.feature.util.StringUtil.normalizeOnlyNumber;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.ASSIGN_TYPE;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.DEFAULT_AND_FILE_TYPE;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.LIST_TEXT_REGEX;
|
||||
import static com.kri.contact.server.common.consts.ContactConstant.LOWER_CASE_HEADER_OPTIONS;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kri.common.feature.excel.ExcelMapper;
|
||||
import com.kri.common.feature.excel.StreamingReadOptions;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.common.enums.ListHeaderGrade;
|
||||
@@ -44,7 +44,6 @@ import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -60,9 +59,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
@RequiredArgsConstructor
|
||||
public class ListUploadService {
|
||||
|
||||
private static final StreamingReadOptions LOWER_CASE_HEADER_OPTIONS =
|
||||
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.toLowerCase(Locale.ROOT));
|
||||
|
||||
private final ListRepository listRepository;
|
||||
private final ListUploadJdbcSupport listUploadJdbcSupport;
|
||||
private final ListUploadLogRepository listUploadLogRepository;
|
||||
|
||||
Reference in New Issue
Block a user