Compare commits
5 Commits
27dfb4d26f
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| ad6a302867 | |||
| 548dca52c3 | |||
| 86e4a02759 | |||
| 5f11e3184e | |||
| 3197c4e16f |
@@ -23,10 +23,11 @@ public final class ContactConstant {
|
|||||||
public static final int OUTSOURCE_USER_ROLE = 4000;
|
public static final int OUTSOURCE_USER_ROLE = 4000;
|
||||||
public static final int FIELDWORK_USER_ROLE = 9000;
|
public static final int FIELDWORK_USER_ROLE = 9000;
|
||||||
public static final StreamingReadOptions UPPER_CASE_HEADER_OPTIONS =
|
public static final StreamingReadOptions UPPER_CASE_HEADER_OPTIONS =
|
||||||
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.toUpperCase(
|
new StreamingReadOptions(null, 0, 1, header -> header == null ? null : header.trim().toUpperCase(
|
||||||
Locale.ROOT));
|
Locale.ROOT));
|
||||||
|
|
||||||
public static final String LIST_HEADER_ACCEPT_REGEX = "^[가-힣a-zA-Z0-9()_\\-\\[\\] ]+$";
|
public static final String LIST_HEADER_ACCEPT_REGEX = "^[가-힣a-zA-Z0-9()_\\-\\[\\] ]+$";
|
||||||
|
public static final String LIST_HEADER_COLOR_REGEX = "^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$";
|
||||||
|
|
||||||
public static final List<ListHeaderType> DEFAULT_AND_FILE_TYPE = Stream.concat(
|
public static final List<ListHeaderType> DEFAULT_AND_FILE_TYPE = Stream.concat(
|
||||||
Arrays.stream(ListHeaderTypeDefault.values())
|
Arrays.stream(ListHeaderTypeDefault.values())
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ public enum ListHeaderType implements CodeEnum<Short> {
|
|||||||
EMAIL(ListHeaderTypeSpecific.EMAIL), //31 : 이메일
|
EMAIL(ListHeaderTypeSpecific.EMAIL), //31 : 이메일
|
||||||
FILE(ListHeaderTypeSpecific.FILE), //81 : 파일업로드
|
FILE(ListHeaderTypeSpecific.FILE), //81 : 파일업로드
|
||||||
CONTENT_ITEM(ListHeaderTypeSpecific.CONTENT_ITEM), //91 : 목록형
|
CONTENT_ITEM(ListHeaderTypeSpecific.CONTENT_ITEM), //91 : 목록형
|
||||||
|
MULTILINE_TEXT(ListHeaderTypeSpecific.MULTILINE_TEXT), //98 : 여러 줄 텍스트
|
||||||
TEXT((short) 99); //99 : 텍스트
|
TEXT((short) 99); //99 : 텍스트
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
ListHeaderType(CodeEnum<Short> source) { this.code = source.getCode();}
|
ListHeaderType(CodeEnum<Short> source) { this.code = source.getCode();}
|
||||||
|
|
||||||
|
/** 저장·처리 방식이 일반 텍스트와 동일한 타입 여부 */
|
||||||
|
public boolean isText() {
|
||||||
|
return this == TEXT || this == MULTILINE_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
public static ListHeaderType fromCode(Short code) {
|
public static ListHeaderType fromCode(Short code) {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public enum ListHeaderTypeSpecific implements CodeEnum<Short> {
|
|||||||
TEL_NUM((short) 21), //21 : 전화번호
|
TEL_NUM((short) 21), //21 : 전화번호
|
||||||
EMAIL((short) 31), //31 : 이메일
|
EMAIL((short) 31), //31 : 이메일
|
||||||
FILE((short) 81), //81 : 파일업로드
|
FILE((short) 81), //81 : 파일업로드
|
||||||
CONTENT_ITEM((short) 91); //목록형
|
CONTENT_ITEM((short) 91), //목록형
|
||||||
|
MULTILINE_TEXT((short) 98); //98 : 여러 줄 텍스트 (텍스트 계열)
|
||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ public enum ChannelType implements CodeEnum<Short> {
|
|||||||
|
|
||||||
private final Short code;
|
private final Short code;
|
||||||
|
|
||||||
ChannelType(CodeEnum<Short> source) {
|
|
||||||
this.code = source.getCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
|
||||||
public static ChannelType fromCode(Short code) {
|
public static ChannelType fromCode(Short code) {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class NotiHubTemplateBasicDto extends NotiHubExtensibleDto {
|
|||||||
private Short tmplatPurpose;
|
private Short tmplatPurpose;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Size(max = 32)
|
@Size(max = 128)
|
||||||
private String tmplatNm;
|
private String tmplatNm;
|
||||||
|
|
||||||
@Size(max = 128)
|
@Size(max = 128)
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
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.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -66,27 +64,4 @@ public class ListCallHistController {
|
|||||||
now
|
now
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "Find list call history by agent session")
|
|
||||||
@GetMapping("/session/{agentSessionId}")
|
|
||||||
public ListCallHistDto findByAgentSessionId(
|
|
||||||
@PathVariable String agentSessionId,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return listCallHistService.findByAgentSessionId(
|
|
||||||
agentSessionId,
|
|
||||||
ctx.getUserId(),
|
|
||||||
ctx.getUserCmpn(),
|
|
||||||
ctx.getUserRole()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "Update Call History at Client Hangup")
|
|
||||||
@PatchMapping("hangup/{agentSessionId}")
|
|
||||||
public boolean hangupClient(
|
|
||||||
@PathVariable String agentSessionId,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return listCallHistService.hangupClient(agentSessionId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.kri.contact.server.common.enums.ListHeaderType;
|
|||||||
import com.kri.contact.server.persistence.entity.TListHeaderEntity;
|
import com.kri.contact.server.persistence.entity.TListHeaderEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -44,6 +45,9 @@ public class ListHeaderDto {
|
|||||||
@Schema(description = "헤더 타입")
|
@Schema(description = "헤더 타입")
|
||||||
private ListHeaderType listHderTy;
|
private ListHeaderType listHderTy;
|
||||||
|
|
||||||
|
@Schema(description = "헤더 색상 hex (#RRGGBB 또는 #RRGGBBAA, null: 기본색)")
|
||||||
|
private String listHderColor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Schema(description = "필터 사용 여부")
|
@Schema(description = "필터 사용 여부")
|
||||||
private Boolean useFilter = false;
|
private Boolean useFilter = false;
|
||||||
@@ -60,6 +64,29 @@ public class ListHeaderDto {
|
|||||||
@Schema(description = "면접원 수정가능 여부")
|
@Schema(description = "면접원 수정가능 여부")
|
||||||
private Boolean useIntrvwerEdit = false;
|
private Boolean useIntrvwerEdit = false;
|
||||||
|
|
||||||
|
public String getListHderNm() {
|
||||||
|
return listHderNm == null ? null : listHderNm.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListHderNm(String listHderNm) {
|
||||||
|
this.listHderNm = listHderNm == null ? null : listHderNm.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getListHderColor() {
|
||||||
|
return normalizeColor(listHderColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListHderColor(String listHderColor) {
|
||||||
|
this.listHderColor = normalizeColor(listHderColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String normalizeColor(String color) {
|
||||||
|
if (color == null || color.isBlank()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return color.trim().toUpperCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
public static ListHeaderDto fromEntity(TListHeaderEntity entity) {
|
public static ListHeaderDto fromEntity(TListHeaderEntity entity) {
|
||||||
return ListHeaderDto.builder()
|
return ListHeaderDto.builder()
|
||||||
.prjctIdx(entity.getPrjctIdx())
|
.prjctIdx(entity.getPrjctIdx())
|
||||||
@@ -68,6 +95,7 @@ public class ListHeaderDto {
|
|||||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||||
.listHderNm(entity.getListHderNm())
|
.listHderNm(entity.getListHderNm())
|
||||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||||
|
.listHderColor(entity.getListHderColor())
|
||||||
.useFilter(entity.getUseFilter())
|
.useFilter(entity.getUseFilter())
|
||||||
.useColView(entity.getUseColView())
|
.useColView(entity.getUseColView())
|
||||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||||
@@ -83,6 +111,7 @@ public class ListHeaderDto {
|
|||||||
.listHderGrad(src.getListHderGrad())
|
.listHderGrad(src.getListHderGrad())
|
||||||
.listHderNm(src.getListHderNm())
|
.listHderNm(src.getListHderNm())
|
||||||
.listHderTy(src.getListHderTy())
|
.listHderTy(src.getListHderTy())
|
||||||
|
.listHderColor(src.getListHderColor())
|
||||||
.useFilter(src.getUseFilter())
|
.useFilter(src.getUseFilter())
|
||||||
.useColView(src.getUseColView())
|
.useColView(src.getUseColView())
|
||||||
.useIntrvwerView(src.getUseIntrvwerView())
|
.useIntrvwerView(src.getUseIntrvwerView())
|
||||||
@@ -96,7 +125,7 @@ public class ListHeaderDto {
|
|||||||
.listHderId(headerId)
|
.listHderId(headerId)
|
||||||
.listHderOrder((short) headerId)
|
.listHderOrder((short) headerId)
|
||||||
.listHderGrad(ListHeaderGrade.COMMON)
|
.listHderGrad(ListHeaderGrade.COMMON)
|
||||||
.listHderNm(headerName)
|
.listHderNm(headerName == null ? null : headerName.trim())
|
||||||
.listHderTy(type)
|
.listHderTy(type)
|
||||||
.useFilter(true)
|
.useFilter(true)
|
||||||
.useColView(true)
|
.useColView(true)
|
||||||
@@ -109,13 +138,13 @@ public class ListHeaderDto {
|
|||||||
return Objects.equals(listHderId, dto.listHderId) &&
|
return Objects.equals(listHderId, dto.listHderId) &&
|
||||||
Objects.equals(listHderOrder, dto.listHderOrder) &&
|
Objects.equals(listHderOrder, dto.listHderOrder) &&
|
||||||
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
||||||
Objects.equals(listHderNm, dto.listHderNm) &&
|
Objects.equals(getListHderNm(), dto.getListHderNm()) &&
|
||||||
Objects.equals(listHderTy, dto.listHderTy);
|
Objects.equals(listHderTy, dto.listHderTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEqualSimple(ListHeaderDto dto) {
|
public boolean isEqualSimple(ListHeaderDto dto) {
|
||||||
return Objects.equals(listHderId, dto.listHderId) &&
|
return Objects.equals(listHderId, dto.listHderId) &&
|
||||||
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
Objects.equals(listHderGrad, dto.listHderGrad) &&
|
||||||
Objects.equals(listHderNm, dto.listHderNm);
|
Objects.equals(getListHderNm(), dto.getListHderNm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class ListHeaderWithFilterContentDto extends ListHeaderDto {
|
|||||||
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
.listHderGrad(ListHeaderGrade.fromCode(entity.getListHderGrad()))
|
||||||
.listHderNm(entity.getListHderNm())
|
.listHderNm(entity.getListHderNm())
|
||||||
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
.listHderTy(ListHeaderType.fromCode(entity.getListHderTy()))
|
||||||
|
.listHderColor(entity.getListHderColor())
|
||||||
.useFilter(entity.getUseFilter())
|
.useFilter(entity.getUseFilter())
|
||||||
.useColView(entity.getUseColView())
|
.useColView(entity.getUseColView())
|
||||||
.useIntrvwerView(entity.getUseIntrvwerView())
|
.useIntrvwerView(entity.getUseIntrvwerView())
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.kri.contact.server.dto.message;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Schema(description = "MessageFailedChunkDto")
|
|
||||||
public record MessageFailedChunkDto(
|
|
||||||
|
|
||||||
@Schema(description = "chunkIndex")
|
|
||||||
int chunkIndex,
|
|
||||||
|
|
||||||
@Schema(description = "from")
|
|
||||||
int from,
|
|
||||||
|
|
||||||
@Schema(description = "to")
|
|
||||||
int to,
|
|
||||||
|
|
||||||
@Schema(description = "targetCount")
|
|
||||||
int targetCount,
|
|
||||||
|
|
||||||
@Schema(description = "errorMessage")
|
|
||||||
String errorMessage
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.kri.contact.server.dto.message;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.Builder;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
@Schema(description = "MessageBulkSendResponseDto")
|
|
||||||
public record MessageSendBulkResponseDto(
|
|
||||||
|
|
||||||
@Schema(description = "bulkSendKey")
|
|
||||||
String bulkSendKey,
|
|
||||||
|
|
||||||
@Schema(description = "targetCount")
|
|
||||||
int targetCount,
|
|
||||||
|
|
||||||
@Schema(description = "requestCount")
|
|
||||||
int requestCount,
|
|
||||||
|
|
||||||
@Schema(description = "acceptCount")
|
|
||||||
int acceptCount,
|
|
||||||
|
|
||||||
@Schema(description = "failCount")
|
|
||||||
int failCount,
|
|
||||||
|
|
||||||
@Schema(description = "failedChunks")
|
|
||||||
List<MessageFailedChunkDto> failedChunks
|
|
||||||
) {
|
|
||||||
|
|
||||||
public static class MessageSendBulkResponseDtoBuilder {
|
|
||||||
private boolean failedChunksSet;
|
|
||||||
private List<MessageFailedChunkDto> failedChunks;
|
|
||||||
|
|
||||||
public MessageSendBulkResponseDtoBuilder failedChunks(List<MessageFailedChunkDto> failedChunks) {
|
|
||||||
this.failedChunks = failedChunks;
|
|
||||||
this.failedChunksSet = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageSendBulkResponseDto build() {
|
|
||||||
return new MessageSendBulkResponseDto(
|
|
||||||
bulkSendKey, targetCount, requestCount, acceptCount, failCount,
|
|
||||||
failedChunksSet ? failedChunks : new ArrayList<>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,6 @@ import jakarta.persistence.Table;
|
|||||||
import jakarta.persistence.UniqueConstraint;
|
import jakarta.persistence.UniqueConstraint;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Size;
|
import jakarta.validation.constraints.Size;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@@ -155,19 +154,6 @@ public class TListCallHistEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean markUserHangup(LocalDateTime endDt) {
|
|
||||||
if (this.callStatus == CallStatus.CALL_CLOSE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LocalDateTime resolvedEndDt = this.endDt == null ? endDt : this.endDt;
|
|
||||||
int durationSeconds = durationSeconds(this.startDt, resolvedEndDt);
|
|
||||||
this.endDt = resolvedEndDt;
|
|
||||||
this.totalTime = durationSeconds;
|
|
||||||
this.talkTime = durationSeconds;
|
|
||||||
this.callStatus = CallStatus.USER_HANGUP;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalDateTime resolveEndDt(ListCallCloseRequestDto request, LocalDateTime now) {
|
private static LocalDateTime resolveEndDt(ListCallCloseRequestDto request, LocalDateTime now) {
|
||||||
return isCompletedRequest(request) ? now : null;
|
return isCompletedRequest(request) ? now : null;
|
||||||
}
|
}
|
||||||
@@ -181,14 +167,6 @@ public class TListCallHistEntity {
|
|||||||
|| isPositive(request.getTalkTime());
|
|| isPositive(request.getTalkTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int durationSeconds(LocalDateTime startDt, LocalDateTime endDt) {
|
|
||||||
if (startDt == null || endDt == null || endDt.isBefore(startDt)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
long seconds = Duration.between(startDt, endDt).getSeconds();
|
|
||||||
return seconds > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isPositive(Integer value) {
|
private static boolean isPositive(Integer value) {
|
||||||
return value != null && value > 0;
|
return value != null && value > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ public class TListHeaderEntity {
|
|||||||
@Column(name = "list_hder_ty", nullable = false)
|
@Column(name = "list_hder_ty", nullable = false)
|
||||||
private Short listHderTy;
|
private Short listHderTy;
|
||||||
|
|
||||||
|
@Size(max = 16)
|
||||||
|
@Column(name = "list_hder_color", length = 16)
|
||||||
|
private String listHderColor;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@ColumnDefault("0")
|
@ColumnDefault("0")
|
||||||
@Column(name = "use_filter", nullable = false)
|
@Column(name = "use_filter", nullable = false)
|
||||||
@@ -101,8 +105,9 @@ public class TListHeaderEntity {
|
|||||||
.id(TListHeaderEntityId.create(prjctIdx, src.getListHderId()))
|
.id(TListHeaderEntityId.create(prjctIdx, src.getListHderId()))
|
||||||
.listHderOrder(src.getListHderOrder())
|
.listHderOrder(src.getListHderOrder())
|
||||||
.listHderGrad(src.getListHderGrad())
|
.listHderGrad(src.getListHderGrad())
|
||||||
.listHderNm(src.getListHderNm())
|
.listHderNm(src.getListHderNm() == null ? null : src.getListHderNm().trim())
|
||||||
.listHderTy(src.getListHderTy())
|
.listHderTy(src.getListHderTy())
|
||||||
|
.listHderColor(src.getListHderColor())
|
||||||
.useFilter(src.getUseFilter())
|
.useFilter(src.getUseFilter())
|
||||||
.useColView(src.getUseColView())
|
.useColView(src.getUseColView())
|
||||||
.useIntrvwerView(src.getUseIntrvwerView())
|
.useIntrvwerView(src.getUseIntrvwerView())
|
||||||
@@ -119,6 +124,7 @@ public class TListHeaderEntity {
|
|||||||
.listHderGrad(dto.getListHderGrad().getCode())
|
.listHderGrad(dto.getListHderGrad().getCode())
|
||||||
.listHderNm(dto.getListHderNm())
|
.listHderNm(dto.getListHderNm())
|
||||||
.listHderTy(dto.getListHderTy().getCode())
|
.listHderTy(dto.getListHderTy().getCode())
|
||||||
|
.listHderColor(dto.getListHderColor())
|
||||||
.useFilter(dto.getUseFilter())
|
.useFilter(dto.getUseFilter())
|
||||||
.useColView(dto.getUseColView())
|
.useColView(dto.getUseColView())
|
||||||
.useIntrvwerView(dto.getUseIntrvwerView())
|
.useIntrvwerView(dto.getUseIntrvwerView())
|
||||||
|
|||||||
@@ -220,20 +220,5 @@ public class ListResetJdbcSupport {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteCounts plus(DeleteCounts other) {
|
|
||||||
return new DeleteCounts(
|
|
||||||
fileCount + other.fileCount,
|
|
||||||
callHistCount + other.callHistCount,
|
|
||||||
eventHistCount + other.eventHistCount,
|
|
||||||
eventLatestCount + other.eventLatestCount,
|
|
||||||
updateHistCount + other.updateHistCount,
|
|
||||||
itemCount + other.itemCount,
|
|
||||||
listCount + other.listCount,
|
|
||||||
assignUserCount + other.assignUserCount,
|
|
||||||
assignCmpnCount + other.assignCmpnCount,
|
|
||||||
resveCount + other.resveCount
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,17 +21,6 @@ public class ListResetPersistenceSupport {
|
|||||||
private final ListDeleteSessionContext deleteSessionContext;
|
private final ListDeleteSessionContext deleteSessionContext;
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
public int resetWithAuditContext(
|
|
||||||
Long prjctIdx,
|
|
||||||
Collection<String> sids,
|
|
||||||
ListResetMode mode,
|
|
||||||
String listResetLogId,
|
|
||||||
String delUser,
|
|
||||||
int chunkSize
|
|
||||||
) {
|
|
||||||
return resetWithAuditContext(prjctIdx, sids, mode, listResetLogId, delUser, chunkSize, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int resetChunkWithAuditContext(Long projectId, Collection<String> sids, ListResetMode mode,
|
public int resetChunkWithAuditContext(Long projectId, Collection<String> sids, ListResetMode mode,
|
||||||
String logId, String user, int chunkSize) {
|
String logId, String user, int chunkSize) {
|
||||||
return resetWithAuditContext(projectId, sids, mode, logId, user, chunkSize, true);
|
return resetWithAuditContext(projectId, sids, mode, logId, user, chunkSize, true);
|
||||||
|
|||||||
@@ -102,24 +102,6 @@ public class ListCallHistService {
|
|||||||
return ListCallHistDto.from(entity);
|
return ListCallHistDto.from(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public ListCallHistDto findByAgentSessionId(
|
|
||||||
String agentSessionId,
|
|
||||||
String userId,
|
|
||||||
String userCmpn,
|
|
||||||
Integer userRole
|
|
||||||
) {
|
|
||||||
validateAgentSessionId(agentSessionId);
|
|
||||||
TListCallHistEntity entity = listCallHistRepository.findByAgentSessionId(agentSessionId)
|
|
||||||
.orElseThrow(() -> BusinessException.notFound(
|
|
||||||
"CALL_HISTORY_NOT_FOUND",
|
|
||||||
"통화 이력을 찾을 수 없습니다."
|
|
||||||
).with("agentSessionId", agentSessionId));
|
|
||||||
|
|
||||||
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_NOT_FOUND");
|
|
||||||
return ListCallHistDto.from(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public void validateListCallHistoryForEvent(
|
public void validateListCallHistoryForEvent(
|
||||||
Long listCallHistIdx,
|
Long listCallHistIdx,
|
||||||
@@ -153,16 +135,6 @@ public class ListCallHistService {
|
|||||||
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_FORBIDDEN");
|
validateUsableCallHistory(entity, userId, userCmpn, userRole, "CALL_HISTORY_FORBIDDEN");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public boolean hangupClient(
|
|
||||||
String agentSessionId
|
|
||||||
) {
|
|
||||||
validateAgentSessionId(agentSessionId);
|
|
||||||
return listCallHistRepository.findByAgentSessionId(agentSessionId)
|
|
||||||
.map(entity -> entity.markUserHangup(LocalDateTime.now()))
|
|
||||||
.orElse(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateAgentSessionId(String agentSessionId) {
|
private void validateAgentSessionId(String agentSessionId) {
|
||||||
if (!hasText(agentSessionId) || agentSessionId.length() > 64) {
|
if (!hasText(agentSessionId) || agentSessionId.length() > 64) {
|
||||||
throw BusinessException.badRequest(
|
throw BusinessException.badRequest(
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.kri.contact.server.persistence.repository.ProjectRepository;
|
|||||||
import com.kri.contact.server.persistence.repository.ProjectSurveyRepository;
|
import com.kri.contact.server.persistence.repository.ProjectSurveyRepository;
|
||||||
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
|
import com.kri.contact.server.persistence.repository.ResultCodeRepository;
|
||||||
import com.kri.contact.server.service.file.ListItemFileService;
|
import com.kri.contact.server.service.file.ListItemFileService;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -112,18 +111,6 @@ public class ListDownloadService {
|
|||||||
default void beforeWrite() { checkCancelled(); }
|
default void beforeWrite() { checkCancelled(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final DownloadObserver NO_OBSERVER = new DownloadObserver() {};
|
|
||||||
|
|
||||||
public byte[] downloadList(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto listFilter,
|
|
||||||
boolean includeResult
|
|
||||||
) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeList(prjctIdx, listFilter, includeResult, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeList(
|
public void writeList(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
ListFilterDto listFilter,
|
ListFilterDto listFilter,
|
||||||
@@ -189,20 +176,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadListWithEventHist(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto listFilter,
|
|
||||||
Collection<ResultCodeType> resultCodeTypes,
|
|
||||||
ListEventHistoryBase searchBase,
|
|
||||||
DateRangeDto dateRange,
|
|
||||||
ListEventHistoryOrder historyOrder,
|
|
||||||
boolean includeResult
|
|
||||||
) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeListWithEventHist(prjctIdx, listFilter, resultCodeTypes, searchBase, dateRange, historyOrder, includeResult, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeListWithEventHist(
|
public void writeListWithEventHist(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
ListFilterDto listFilter,
|
ListFilterDto listFilter,
|
||||||
@@ -309,12 +282,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeSidWithUpdateHist(prjctIdx, listFilter, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
public void writeSidWithUpdateHist(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||||
observer.checkCancelled();
|
observer.checkCancelled();
|
||||||
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter, observer);
|
int maxHistoryGroupCount = findMaxUpdateHistoryGroupCount(prjctIdx, listFilter, observer);
|
||||||
@@ -367,12 +334,6 @@ public class ListDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] downloadItemFile(Long prjctIdx, ListFilterDto listFilter) {
|
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
||||||
writeItemFile(prjctIdx, listFilter, out, NO_OBSERVER);
|
|
||||||
return out.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeItemFile(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
public void writeItemFile(Long prjctIdx, ListFilterDto listFilter, OutputStream out, DownloadObserver observer) {
|
||||||
observer.checkCancelled();
|
observer.checkCancelled();
|
||||||
List<ListHeaderDto> fileHeaders = getSortedHeaders(prjctIdx).stream()
|
List<ListHeaderDto> fileHeaders = getSortedHeaders(prjctIdx).stream()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.kri.contact.server.service;
|
|||||||
|
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.EXACT_MATCH_HEADER_TYPE;
|
import static com.kri.contact.server.common.consts.ContactConstant.EXACT_MATCH_HEADER_TYPE;
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.LIST_HEADER_ACCEPT_REGEX;
|
import static com.kri.contact.server.common.consts.ContactConstant.LIST_HEADER_ACCEPT_REGEX;
|
||||||
|
import static com.kri.contact.server.common.consts.ContactConstant.LIST_HEADER_COLOR_REGEX;
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.SYSTEM_USER_NAME;
|
import static com.kri.contact.server.common.consts.ContactConstant.SYSTEM_USER_NAME;
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.UPPER_CASE_HEADER_OPTIONS;
|
import static com.kri.contact.server.common.consts.ContactConstant.UPPER_CASE_HEADER_OPTIONS;
|
||||||
|
|
||||||
@@ -116,6 +117,10 @@ public class ListHeaderService {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
excelHeaders = excelHeaders.stream()
|
||||||
|
.map(name -> name == null ? null : name.trim())
|
||||||
|
.toList();
|
||||||
|
|
||||||
List<ListHeaderDto> defaultHeaders = listHeaderRepository.findDefaultHeader().stream()
|
List<ListHeaderDto> defaultHeaders = listHeaderRepository.findDefaultHeader().stream()
|
||||||
.map(ListHeaderDto::fromEntity)
|
.map(ListHeaderDto::fromEntity)
|
||||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderId))
|
.sorted(Comparator.comparing(ListHeaderDto::getListHderId))
|
||||||
@@ -241,6 +246,16 @@ public class ListHeaderService {
|
|||||||
.with("invalidHeaderList", invalidHeaderList);
|
.with("invalidHeaderList", invalidHeaderList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> invalidColorHeaderList = headerList.stream()
|
||||||
|
.filter(h -> h.getListHderColor() != null && !h.getListHderColor().matches(LIST_HEADER_COLOR_REGEX))
|
||||||
|
.map(ListHeaderDto::getListHderNm)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (!invalidColorHeaderList.isEmpty()) {
|
||||||
|
throw BusinessException.badRequest("WRONG_HEADER_COLOR", "헤더 색상은 #RRGGBB 또는 #RRGGBBAA 형식이어야 합니다.")
|
||||||
|
.with("invalidHeaderList", invalidColorHeaderList);
|
||||||
|
}
|
||||||
|
|
||||||
validateUniqueHeaderNames(headerList);
|
validateUniqueHeaderNames(headerList);
|
||||||
|
|
||||||
// headerList에 없는 헤더는 삭제
|
// headerList에 없는 헤더는 삭제
|
||||||
@@ -340,7 +355,7 @@ public class ListHeaderService {
|
|||||||
Map<String, Integer> headerIdByName = createHeaderIdByNameMap(getHeader(prjctIdx));
|
Map<String, Integer> headerIdByName = createHeaderIdByNameMap(getHeader(prjctIdx));
|
||||||
if (!ignoreUnknownHeaders) {
|
if (!ignoreUnknownHeaders) {
|
||||||
Set<String> missingHeaderNames = contentsByHeaderName.keySet().stream()
|
Set<String> missingHeaderNames = contentsByHeaderName.keySet().stream()
|
||||||
.filter(name -> !headerIdByName.containsKey(name))
|
.filter(name -> !headerIdByName.containsKey(name == null ? null : name.trim()))
|
||||||
.collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
|
.collect(LinkedHashSet::new, LinkedHashSet::add, LinkedHashSet::addAll);
|
||||||
|
|
||||||
if (!missingHeaderNames.isEmpty()) {
|
if (!missingHeaderNames.isEmpty()) {
|
||||||
@@ -351,7 +366,7 @@ public class ListHeaderService {
|
|||||||
|
|
||||||
Map<Integer, String> contentsByHeaderId = new LinkedHashMap<>();
|
Map<Integer, String> contentsByHeaderId = new LinkedHashMap<>();
|
||||||
contentsByHeaderName.forEach((name, value) -> {
|
contentsByHeaderName.forEach((name, value) -> {
|
||||||
Integer headerId = headerIdByName.get(name);
|
Integer headerId = headerIdByName.get(name == null ? null : name.trim());
|
||||||
if (headerId != null) {
|
if (headerId != null) {
|
||||||
contentsByHeaderId.put(headerId, value);
|
contentsByHeaderId.put(headerId, value);
|
||||||
}
|
}
|
||||||
@@ -399,6 +414,7 @@ public class ListHeaderService {
|
|||||||
case TEL_NUM -> ListHeaderType.TEL_NUM;
|
case TEL_NUM -> ListHeaderType.TEL_NUM;
|
||||||
case FILE -> ListHeaderType.FILE;
|
case FILE -> ListHeaderType.FILE;
|
||||||
case CONTENT_ITEM -> ListHeaderType.CONTENT_ITEM;
|
case CONTENT_ITEM -> ListHeaderType.CONTENT_ITEM;
|
||||||
|
case MULTILINE_TEXT -> ListHeaderType.MULTILINE_TEXT;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.kri.contact.server.service;
|
package com.kri.contact.server.service;
|
||||||
|
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
|
||||||
|
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import com.kri.contact.server.common.consts.ContactConstant;
|
import com.kri.contact.server.common.consts.ContactConstant;
|
||||||
import com.kri.contact.server.common.enums.ListResetMode;
|
import com.kri.contact.server.common.enums.ListResetMode;
|
||||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
|
||||||
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
import com.kri.contact.server.dto.list.ListResetRequestDto;
|
||||||
import com.kri.contact.server.dto.list.ListResetScopeDto;
|
import com.kri.contact.server.dto.list.ListResetScopeDto;
|
||||||
import com.kri.contact.server.persistence.entity.TListResetLogEntity;
|
import com.kri.contact.server.persistence.entity.TListResetLogEntity;
|
||||||
@@ -26,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
public class ListResetService {
|
public class ListResetService {
|
||||||
|
|
||||||
private final ListResetLogRepository listResetLogRepository;
|
private final ListResetLogRepository listResetLogRepository;
|
||||||
private final ListSearchService listSearchService;
|
|
||||||
private final ListResetPersistenceSupport listResetPersistenceSupport;
|
private final ListResetPersistenceSupport listResetPersistenceSupport;
|
||||||
private final ProjectSurveyRepository projectSurveyRepository;
|
private final ProjectSurveyRepository projectSurveyRepository;
|
||||||
|
|
||||||
@@ -75,39 +72,6 @@ public class ListResetService {
|
|||||||
return BusinessException.badRequest("INVALID_LIST_RESET", message);
|
return BusinessException.badRequest("INVALID_LIST_RESET", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int resetByFilter(
|
|
||||||
Long prjctIdx,
|
|
||||||
ListFilterDto filter,
|
|
||||||
ListResetMode mode,
|
|
||||||
String regUser,
|
|
||||||
LocalDateTime regDt
|
|
||||||
) {
|
|
||||||
requireValidFilterConditions(filter == null ? null : filter.getSidSet());
|
|
||||||
Set<String> sids = listSearchService.findTargetSids(prjctIdx, filter);
|
|
||||||
return resetBySids(prjctIdx, sids, mode, regUser, regDt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public int resetBySids(
|
|
||||||
Long prjctIdx,
|
|
||||||
Set<String> sids,
|
|
||||||
ListResetMode mode,
|
|
||||||
String regUser,
|
|
||||||
LocalDateTime regDt
|
|
||||||
) {
|
|
||||||
if (sids == null || sids.isEmpty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (mode == null) {
|
|
||||||
throw BusinessException.badRequest("EMPTY_MODE", "mode는 필수 입니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String listResetLogId = createResetLog(prjctIdx, mode, 0, regUser, regDt);
|
|
||||||
return listResetPersistenceSupport.resetWithAuditContext(
|
|
||||||
prjctIdx, sids, mode, listResetLogId, regUser, ContactConstant.INSERT_CHUNK_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public String createResetLog(
|
public String createResetLog(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ import com.kri.contact.server.common.enums.ListHeaderTypeSpecific;
|
|||||||
import com.kri.contact.server.common.enums.ListIsUse;
|
import com.kri.contact.server.common.enums.ListIsUse;
|
||||||
import com.kri.contact.server.common.enums.ListResetMode;
|
import com.kri.contact.server.common.enums.ListResetMode;
|
||||||
import com.kri.contact.server.common.enums.ListUploadMode;
|
import com.kri.contact.server.common.enums.ListUploadMode;
|
||||||
import com.kri.contact.server.common.util.ExcelUploadResultUtil;
|
|
||||||
import com.kri.contact.server.dto.excel.ExcelUploadResultDto;
|
|
||||||
import com.kri.contact.server.dto.excel.ListUploadErrorDto;
|
import com.kri.contact.server.dto.excel.ListUploadErrorDto;
|
||||||
import com.kri.contact.server.dto.list.ListFilterDto;
|
import com.kri.contact.server.dto.list.ListFilterDto;
|
||||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||||
@@ -196,124 +194,6 @@ public class ListUploadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public ExcelUploadResultDto uploadExcel(
|
|
||||||
Long prjctIdx,
|
|
||||||
MultipartFile file,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
String uploadUser,
|
|
||||||
LocalDateTime uploadDt
|
|
||||||
) {
|
|
||||||
Path listFilePath = listFileService.saveListFile(file, prjctIdx);
|
|
||||||
|
|
||||||
List<String> excelHeaders = ExcelMapper.readHeaderStreaming(listFilePath,
|
|
||||||
UPPER_CASE_HEADER_OPTIONS);
|
|
||||||
List<ListUploadErrorDto> headerErrorList = new ArrayList<>();
|
|
||||||
|
|
||||||
List<ListHeaderDto> resolvedHeaders = listHeaderService.resolveUploadHeaders(
|
|
||||||
prjctIdx,
|
|
||||||
excelHeaders,
|
|
||||||
request,
|
|
||||||
headerErrorList
|
|
||||||
);
|
|
||||||
if (!headerErrorList.isEmpty()) {
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
|
||||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ListHeaderDto> existingHeaders = listHeaderService.getHeader(prjctIdx).stream()
|
|
||||||
.map(ListHeaderDto.class::cast)
|
|
||||||
.toList();
|
|
||||||
List<ListHeaderDto> existingCommon = existingHeaders.stream()
|
|
||||||
.filter(h -> Objects.equals(h.getListHderGrad(), ListHeaderGrade.COMMON))
|
|
||||||
.sorted(Comparator.comparing(ListHeaderDto::getListHderOrder))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (!existingCommon.isEmpty() && !listHeaderService.isEqualHeader(existingHeaders, resolvedHeaders, true)) {
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, null);
|
|
||||||
headerErrorList.add(ListUploadErrorDto.of(1, "헤더", "기존 헤더와 업로드 헤더가 일치하지 않습니다."));
|
|
||||||
return buildErrorResponse(0, headerErrorList, listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> prjctAssignList = assignService.getPrjctFieldworkAssign(prjctIdx);
|
|
||||||
List<String> prjctAssignCmpnList = assignService.getPrjctCmpnAssign(prjctIdx);
|
|
||||||
Map<String, Integer> userRoleByUserId = assignService.findActiveUserRoleMap(prjctAssignList);
|
|
||||||
Map<String, Short> assignRoleByHeaderName = createAssignRoleByHeaderName(resolvedHeaders);
|
|
||||||
Map<Short, Set<String>> allowedUserRolesByAssignRole =
|
|
||||||
assignService.findAllowedUserRolesByAssignRole(new LinkedHashSet<>(assignRoleByHeaderName.values()));
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText = createCmpnByUploadText(resolvedHeaders, listFilePath);
|
|
||||||
|
|
||||||
TListUploadLogEntity uploadLog = createPendingLog(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
|
|
||||||
ValidationSummary validation = validateFile(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
resolvedHeaders,
|
|
||||||
prjctAssignList,
|
|
||||||
prjctAssignCmpnList,
|
|
||||||
userRoleByUserId,
|
|
||||||
assignRoleByHeaderName,
|
|
||||||
allowedUserRolesByAssignRole,
|
|
||||||
cmpnByUploadText,
|
|
||||||
uploadLog.getListUploadLogId()
|
|
||||||
);
|
|
||||||
|
|
||||||
markValidated(uploadLog, validation.totalCount());
|
|
||||||
|
|
||||||
if (!validation.errors().isEmpty()) {
|
|
||||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
|
||||||
listFilePath = markUploadFailed(prjctIdx, listFilePath, uploadLog);
|
|
||||||
return buildErrorResponse(validation.totalCount(), validation.errors(), listFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (existingCommon.isEmpty()) {
|
|
||||||
listHeaderService.upsertHeader(prjctIdx, resolvedHeaders, uploadUser, uploadDt);
|
|
||||||
}
|
|
||||||
|
|
||||||
persistUpload(
|
|
||||||
prjctIdx,
|
|
||||||
listFilePath,
|
|
||||||
request,
|
|
||||||
resolvedHeaders,
|
|
||||||
cmpnByUploadText,
|
|
||||||
uploadLog.getListUploadLogId(),
|
|
||||||
validation.uploadedSids(),
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
|
|
||||||
markSuccess(uploadLog, validation.totalCount());
|
|
||||||
listUploadJdbcSupport.deleteTemp(uploadLog.getListUploadLogId());
|
|
||||||
|
|
||||||
//목록형 헤더의 값들 최신화
|
|
||||||
listContentItemService.refreshListContentItem(prjctIdx, resolvedHeaders);
|
|
||||||
|
|
||||||
return ExcelUploadResultDto.success(validation.totalCount(), validation.totalCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private Path markUploadFailed(Long prjctIdx, Path listFilePath, TListUploadLogEntity uploadLog) {
|
|
||||||
Path failedFilePath = listFileService.renameFailedListFile(prjctIdx, listFilePath);
|
|
||||||
if (uploadLog != null) {
|
|
||||||
uploadLog.setFileNm(failedFilePath.getFileName().toString());
|
|
||||||
listUploadLogRepository.save(uploadLog);
|
|
||||||
}
|
|
||||||
return failedFilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, TCmpnEntity> createCmpnByUploadText(
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
Path listFilePath
|
|
||||||
) {
|
|
||||||
return createCmpnByUploadText(resolvedHeaders, listFilePath, () -> {});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, TCmpnEntity> createCmpnByUploadText(List<ListHeaderDto> resolvedHeaders,
|
private Map<String, TCmpnEntity> createCmpnByUploadText(List<ListHeaderDto> resolvedHeaders,
|
||||||
Path listFilePath, Runnable checkCancelled) {
|
Path listFilePath, Runnable checkCancelled) {
|
||||||
String outsourceHeaderName = findOptionalHeaderNameByType(resolvedHeaders, ListHeaderType.OUTSOURCE);
|
String outsourceHeaderName = findOptionalHeaderNameByType(resolvedHeaders, ListHeaderType.OUTSOURCE);
|
||||||
@@ -422,40 +302,6 @@ public class ListUploadService {
|
|||||||
listUploadLogRepository.save(uploadLog);
|
listUploadLogRepository.save(uploadLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void persistUpload(
|
|
||||||
Long prjctIdx,
|
|
||||||
Path listFilePath,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
|
||||||
String listUploadLogId,
|
|
||||||
Set<String> uploadedSids,
|
|
||||||
String uploadUser,
|
|
||||||
LocalDateTime uploadDt
|
|
||||||
) {
|
|
||||||
if (request.uploadMode() == ListUploadMode.RESET_AND_INSERT) {
|
|
||||||
listResetService.resetByFilter(
|
|
||||||
prjctIdx,
|
|
||||||
null,
|
|
||||||
ListResetMode.ALL,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (request.uploadMode() == ListUploadMode.ADD_AND_CHANGE && !uploadedSids.isEmpty()) {
|
|
||||||
listResetService.resetBySids(
|
|
||||||
prjctIdx,
|
|
||||||
uploadedSids,
|
|
||||||
ListResetMode.LIST_UPLOAD,
|
|
||||||
uploadUser,
|
|
||||||
uploadDt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
readUploadChunks(prjctIdx, listFilePath, resolvedHeaders, cmpnByUploadText,
|
|
||||||
listUploadLogId, uploadUser, uploadDt, () -> {}, this::insertUploadChunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
public record UploadChunk(List<ListRowInsert> lists, List<ListItemRowInsert> items,
|
public record UploadChunk(List<ListRowInsert> lists, List<ListItemRowInsert> items,
|
||||||
List<ListAssignRowInsert> users, List<ListAssignCmpnRowInsert> companies) {
|
List<ListAssignRowInsert> users, List<ListAssignCmpnRowInsert> companies) {
|
||||||
public List<String> sids() { return lists.stream().map(ListRowInsert::sid).toList(); }
|
public List<String> sids() { return lists.stream().map(ListRowInsert::sid).toList(); }
|
||||||
@@ -534,7 +380,7 @@ public class ListUploadService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||||
raw = escapeUnsafeText(raw);
|
raw = escapeUnsafeText(raw);
|
||||||
}
|
}
|
||||||
if (header.getListHderTy() == ListHeaderType.EMAIL) {
|
if (header.getListHderTy() == ListHeaderType.EMAIL) {
|
||||||
@@ -677,24 +523,6 @@ public class ListUploadService {
|
|||||||
listUploadJdbcSupport.batchInsertListAssignCmpn(chunk.companies(), ContactConstant.INSERT_CHUNK_SIZE);
|
listUploadJdbcSupport.batchInsertListAssignCmpn(chunk.companies(), ContactConstant.INSERT_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValidationSummary validateFile(
|
|
||||||
Long prjctIdx,
|
|
||||||
Path listFilePath,
|
|
||||||
ListUploadRequestDto request,
|
|
||||||
List<ListHeaderDto> resolvedHeaders,
|
|
||||||
List<String> prjctAssignList,
|
|
||||||
List<String> prjctAssignCmpnList,
|
|
||||||
Map<String, Integer> userRoleByUserId,
|
|
||||||
Map<String, Short> assignRoleByHeaderName,
|
|
||||||
Map<Short, Set<String>> allowedUserRolesByAssignRole,
|
|
||||||
Map<String, TCmpnEntity> cmpnByUploadText,
|
|
||||||
String listUploadLogId
|
|
||||||
) {
|
|
||||||
return validateFile(prjctIdx, listFilePath, request, resolvedHeaders, prjctAssignList,
|
|
||||||
prjctAssignCmpnList, userRoleByUserId, assignRoleByHeaderName, allowedUserRolesByAssignRole,
|
|
||||||
cmpnByUploadText, listUploadLogId, () -> {}, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ValidationSummary validateFile(Long prjctIdx, Path listFilePath, ListUploadRequestDto request,
|
private ValidationSummary validateFile(Long prjctIdx, Path listFilePath, ListUploadRequestDto request,
|
||||||
List<ListHeaderDto> resolvedHeaders, List<String> prjctAssignList, List<String> prjctAssignCmpnList,
|
List<ListHeaderDto> resolvedHeaders, List<String> prjctAssignList, List<String> prjctAssignCmpnList,
|
||||||
Map<String, Integer> userRoleByUserId, Map<String, Short> assignRoleByHeaderName,
|
Map<String, Integer> userRoleByUserId, Map<String, Short> assignRoleByHeaderName,
|
||||||
@@ -803,7 +631,7 @@ public class ListUploadService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.getListHderTy() == ListHeaderType.TEXT) {
|
if (header.getListHderTy() != null && header.getListHderTy().isText()) {
|
||||||
raw = escapeUnsafeText(raw);
|
raw = escapeUnsafeText(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -900,31 +728,6 @@ public class ListUploadService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExcelUploadResultDto buildErrorResponse(
|
|
||||||
int totalCount,
|
|
||||||
List<ListUploadErrorDto> errorList,
|
|
||||||
Path sourceFile
|
|
||||||
) {
|
|
||||||
String origin = sourceFile.getFileName().toString();
|
|
||||||
String errorFileName = origin.endsWith(".xlsx")
|
|
||||||
? origin.substring(0, origin.length() - 5) + "_error.xlsx"
|
|
||||||
: origin + "_error.xlsx";
|
|
||||||
int failCount = errorList.stream()
|
|
||||||
.map(ListUploadErrorDto::getRowNumber)
|
|
||||||
.distinct()
|
|
||||||
.toList()
|
|
||||||
.size();
|
|
||||||
|
|
||||||
return ExcelUploadResultUtil.buildUploadResult(
|
|
||||||
totalCount,
|
|
||||||
0,
|
|
||||||
failCount,
|
|
||||||
errorList,
|
|
||||||
ListUploadErrorDto.class,
|
|
||||||
errorFileName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<Integer, ListHeaderDto> toHeaderById(List<ListHeaderDto> headers) {
|
private Map<Integer, ListHeaderDto> toHeaderById(List<ListHeaderDto> headers) {
|
||||||
Map<Integer, ListHeaderDto> map = new LinkedHashMap<>();
|
Map<Integer, ListHeaderDto> map = new LinkedHashMap<>();
|
||||||
for (ListHeaderDto h : headers) {
|
for (ListHeaderDto h : headers) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.kri.contact.server.service;
|
|||||||
|
|
||||||
import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE;
|
import static com.kri.contact.server.common.consts.ContactConstant.REQUEST_SERVICE;
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireSid;
|
import static com.kri.contact.server.common.util.SidUtil.requireSid;
|
||||||
import static com.kri.contact.server.common.util.SidUtil.requireValidFilterConditions;
|
|
||||||
|
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import com.kri.common.feature.web.RequestUserContext;
|
import com.kri.common.feature.web.RequestUserContext;
|
||||||
@@ -18,8 +17,6 @@ import com.kri.contact.server.common.external.notihub.dto.NotiHubSendRequestSing
|
|||||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubSendSingleResponseDto;
|
import com.kri.contact.server.common.external.notihub.dto.NotiHubSendSingleResponseDto;
|
||||||
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
import com.kri.contact.server.common.external.notihub.dto.NotiHubTemplateDto;
|
||||||
import com.kri.contact.server.dto.list.ListHeaderDto;
|
import com.kri.contact.server.dto.list.ListHeaderDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendBulkResponseDto;
|
|
||||||
import com.kri.contact.server.dto.message.MessageFailedChunkDto;
|
|
||||||
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
import com.kri.contact.server.dto.message.MessageSendBulkRequestDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
import com.kri.contact.server.dto.message.MessageSendSingleRequestDto;
|
||||||
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
import com.kri.contact.server.dto.message.MessageSendSingleResponseDto;
|
||||||
@@ -50,7 +47,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MessageSendService {
|
public class MessageSendService {
|
||||||
private static final int BULK_SEND_CHUNK_SIZE = 1_000;
|
|
||||||
private static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("(?:\\[\\$|#\\{)([^\\]}]+)(?:]|})");
|
private static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("(?:\\[\\$|#\\{)([^\\]}]+)(?:]|})");
|
||||||
|
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
@@ -92,16 +88,6 @@ public class MessageSendService {
|
|||||||
return sendSingle(prjctIdx, request, ctx, ChannelType.SMS);
|
return sendSingle(prjctIdx, request, ctx, ChannelType.SMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendEmailBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.EMAIL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendSmsBulk(Long prjctIdx, MessageSendBulkRequestDto request, RequestUserContext ctx) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.SMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public MessageSendSingleResponseDto sendKkoSingle(
|
public MessageSendSingleResponseDto sendKkoSingle(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
@@ -111,15 +97,6 @@ public class MessageSendService {
|
|||||||
return sendSingle(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
return sendSingle(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
public MessageSendBulkResponseDto sendKkoBulk(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
RequestUserContext ctx
|
|
||||||
) {
|
|
||||||
return sendBulk(prjctIdx, request, ctx, ChannelType.KKO_AT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MessageSendSingleResponseDto sendSingle(
|
private MessageSendSingleResponseDto sendSingle(
|
||||||
Long prjctIdx,
|
Long prjctIdx,
|
||||||
MessageSendSingleRequestDto request,
|
MessageSendSingleRequestDto request,
|
||||||
@@ -172,101 +149,6 @@ public class MessageSendService {
|
|||||||
return MessageSendSingleResponseDto.from(response);
|
return MessageSendSingleResponseDto.from(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MessageSendBulkResponseDto sendBulk(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
RequestUserContext ctx,
|
|
||||||
ChannelType channelType
|
|
||||||
) {
|
|
||||||
validateDestinationHeaders(request.destHeaderIds());
|
|
||||||
requireValidFilterConditions(
|
|
||||||
request.listFilter() == null ? null : request.listFilter().getSidSet()
|
|
||||||
);
|
|
||||||
|
|
||||||
MessageContext messageContext = createMessageContext(prjctIdx, request.tmplatIdx(), request.destHeaderIds());
|
|
||||||
List<NotiHubDestInfoDto> destInfos = createAllDestInfos(
|
|
||||||
prjctIdx,
|
|
||||||
request,
|
|
||||||
messageContext,
|
|
||||||
channelType,
|
|
||||||
request.dedupe()
|
|
||||||
);
|
|
||||||
if (destInfos.isEmpty()) {
|
|
||||||
throw BusinessException.badRequest("NO_DESTINATION", "발송 대상 이메일 또는 전화번호가 없습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String bulkSendKey = createBulkSendKey(request, ctx, messageContext, destInfos.size(), channelType);
|
|
||||||
int requestCount = 0;
|
|
||||||
int acceptCount = 0;
|
|
||||||
int failCount = 0;
|
|
||||||
List<MessageFailedChunkDto> failedChunks = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int start = 0, chunkIndex = 1; start < destInfos.size(); start += BULK_SEND_CHUNK_SIZE, chunkIndex++) {
|
|
||||||
int end = Math.min(start + BULK_SEND_CHUNK_SIZE, destInfos.size());
|
|
||||||
List<NotiHubDestInfoDto> chunk = destInfos.subList(start, end);
|
|
||||||
try {
|
|
||||||
NotiHubBulkSendResponseDto response = sendBulkChunk(bulkSendKey, chunk, channelType);
|
|
||||||
requestCount += defaultInt(response.requestCount());
|
|
||||||
acceptCount += defaultInt(response.acceptCount());
|
|
||||||
failCount += defaultInt(response.failCount());
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
requestCount += chunk.size();
|
|
||||||
failCount += chunk.size();
|
|
||||||
failedChunks.add(MessageFailedChunkDto.builder()
|
|
||||||
.chunkIndex(chunkIndex)
|
|
||||||
.from(start + 1)
|
|
||||||
.to(end)
|
|
||||||
.targetCount(chunk.size())
|
|
||||||
.errorMessage(e.getMessage())
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MessageSendBulkResponseDto.builder()
|
|
||||||
.bulkSendKey(bulkSendKey)
|
|
||||||
.targetCount(destInfos.size())
|
|
||||||
.requestCount(requestCount)
|
|
||||||
.acceptCount(acceptCount)
|
|
||||||
.failCount(failCount)
|
|
||||||
.failedChunks(failedChunks)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<NotiHubDestInfoDto> createAllDestInfos(
|
|
||||||
Long prjctIdx,
|
|
||||||
MessageSendBulkRequestDto request,
|
|
||||||
MessageContext messageContext,
|
|
||||||
ChannelType channelType,
|
|
||||||
boolean dedupe
|
|
||||||
) {
|
|
||||||
List<NotiHubDestInfoDto> destInfos = new ArrayList<>();
|
|
||||||
Set<String> dedupeKeys = new LinkedHashSet<>();
|
|
||||||
String lastSid = null;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
List<ListSearchService.DownloadListRow> rows = listSearchService.findDownloadListRows(
|
|
||||||
prjctIdx,
|
|
||||||
request.listFilter(),
|
|
||||||
lastSid
|
|
||||||
);
|
|
||||||
if (rows.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
destInfos.addAll(createDestInfos(
|
|
||||||
rows,
|
|
||||||
request.destHeaderIds(),
|
|
||||||
request.destNameHeaderId(),
|
|
||||||
messageContext,
|
|
||||||
channelType,
|
|
||||||
dedupeKeys,
|
|
||||||
dedupe
|
|
||||||
));
|
|
||||||
lastSid = rows.get(rows.size() - 1).sid();
|
|
||||||
}
|
|
||||||
return destInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<NotiHubDestInfoDto> createDestInfos(
|
private List<NotiHubDestInfoDto> createDestInfos(
|
||||||
Collection<ListSearchService.DownloadListRow> rows,
|
Collection<ListSearchService.DownloadListRow> rows,
|
||||||
List<Integer> destHeaderIds,
|
List<Integer> destHeaderIds,
|
||||||
@@ -537,10 +419,6 @@ public class MessageSendService {
|
|||||||
return trimmed.isEmpty() ? null : trimmed;
|
return trimmed.isEmpty() ? null : trimmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int defaultInt(Integer value) {
|
|
||||||
return value == null ? 0 : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public record MessageContext(
|
public record MessageContext(
|
||||||
ProjectInfoDto project,
|
ProjectInfoDto project,
|
||||||
NotiHubTemplateDto template,
|
NotiHubTemplateDto template,
|
||||||
|
|||||||
@@ -191,11 +191,6 @@ public class ListAsyncJobStore {
|
|||||||
finishLocked(lock(key), errorCode, null);
|
finishLocked(lock(key), errorCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
||||||
public void finish(String key, String errorCode, Integer failedChunkNo) {
|
|
||||||
finishLocked(lock(key), errorCode, failedChunkNo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
public void finish(String key, String errorCode, Integer failedChunkNo,
|
public void finish(String key, String errorCode, Integer failedChunkNo,
|
||||||
Map<String, Object> failureDetail) {
|
Map<String, Object> failureDetail) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.kri.contact.server.service.file;
|
package com.kri.contact.server.service.file;
|
||||||
|
|
||||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
|
||||||
import com.kri.common.feature.util.CommonUtil;
|
import com.kri.common.feature.util.CommonUtil;
|
||||||
import com.kri.common.feature.web.BusinessException;
|
import com.kri.common.feature.web.BusinessException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -27,37 +26,11 @@ public abstract class AbstractFileService {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String extractBaseName(String originalFileName) {
|
|
||||||
if (originalFileName == null || originalFileName.isBlank()) {
|
|
||||||
return "file";
|
|
||||||
}
|
|
||||||
|
|
||||||
String fileName = java.nio.file.Paths.get(originalFileName).getFileName().toString();
|
|
||||||
int dot = fileName.lastIndexOf('.');
|
|
||||||
|
|
||||||
if (dot > 0) {
|
|
||||||
return fileName.substring(0, dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String buildFileName(MultipartFile file) {
|
protected String buildFileName(MultipartFile file) {
|
||||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
||||||
return CommonUtil.uuid32() + extractExtension(original);
|
return CommonUtil.uuid32() + extractExtension(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String buildFileNameWithTime(MultipartFile file, String prefix) {
|
|
||||||
String original = Optional.ofNullable(file.getOriginalFilename()).orElse("file");
|
|
||||||
String baseName = extractBaseName(original);
|
|
||||||
String ext = extractExtension(original);
|
|
||||||
|
|
||||||
String timestamp = DateTimeUtil.nowKstLocalDateTime()
|
|
||||||
.format(java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
|
|
||||||
|
|
||||||
return prefix + "_" + timestamp + "_" + baseName + ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Path createDirectories(Path dir) throws IOException {
|
protected Path createDirectories(Path dir) throws IOException {
|
||||||
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
return Files.createDirectories(dir.toAbsolutePath().normalize());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -26,19 +25,6 @@ public class ListFileService extends AbstractFileService {
|
|||||||
return Paths.get(properties.getListBaseDir()).toAbsolutePath().normalize();
|
return Paths.get(properties.getListBaseDir()).toAbsolutePath().normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path saveListFile(MultipartFile file, Long prjctIdx) {
|
|
||||||
String newFileName = buildFileNameWithTime(file, prjctIdx.toString());
|
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
|
||||||
Path savedPath = dir.resolve(newFileName).toAbsolutePath().normalize();
|
|
||||||
|
|
||||||
try {
|
|
||||||
saveFile(dir, file, newFileName);
|
|
||||||
return savedPath;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw BusinessException.internalError("FAIL_LIST_UPLOAD", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Path saveAsyncListFile(MultipartFile file, Long projectId) {
|
public Path saveAsyncListFile(MultipartFile file, Long projectId) {
|
||||||
if (file == null || file.isEmpty()) {
|
if (file == null || file.isEmpty()) {
|
||||||
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
throw BusinessException.badRequest("EMPTY_FILE", "업로드할 파일이 없습니다.");
|
||||||
@@ -95,33 +81,6 @@ public class ListFileService extends AbstractFileService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path renameFailedListFile(Long prjctIdx, Path sourceFilePath) {
|
|
||||||
String failPrefix = "uploadfail_";
|
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
|
||||||
Path source = sourceFilePath.toAbsolutePath().normalize();
|
|
||||||
|
|
||||||
if (!source.startsWith(dir)) {
|
|
||||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
|
||||||
}
|
|
||||||
|
|
||||||
String sourceFileName = source.getFileName().toString();
|
|
||||||
if (sourceFileName.startsWith(failPrefix)) {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
Path target = dir.resolve(failPrefix + sourceFileName).toAbsolutePath().normalize();
|
|
||||||
if (!target.startsWith(dir)) {
|
|
||||||
throw BusinessException.badRequest("WRONG_FILE_PATH", "Wrong file path.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
return target;
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw BusinessException.internalError("FAIL_RENAME_LIST_UPLOAD_FILE", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] readListFile(Long prjctIdx, String fileName) {
|
public byte[] readListFile(Long prjctIdx, String fileName) {
|
||||||
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
Path dir = getBaseDir().resolve(prjctIdx.toString()).toAbsolutePath().normalize();
|
||||||
Path filePath = dir.resolve(fileName).toAbsolutePath().normalize();
|
Path filePath = dir.resolve(fileName).toAbsolutePath().normalize();
|
||||||
|
|||||||
Reference in New Issue
Block a user