Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[차트 입력 기능] OCR + S3 + presigned url로 구현하기 #86

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
48bc923
refactor : 알림 예약 수정 부분 삭제하기
pykido Nov 4, 2024
d34723b
feat : 알림 전용 테이블 만들기
pykido Nov 5, 2024
33eb197
feat : 리뷰 반영
pykido Nov 5, 2024
b09029d
feat : sqs 서비스 붙이고 테스트하기
pykido Nov 5, 2024
f25b867
feat : sqs 서비스 통일화
pykido Nov 6, 2024
2be078b
Merge branch 'refs/heads/Week10' into #48-알림-서비스-고도화
pykido Nov 6, 2024
cd7338b
feat : 관리자 페이지에서 요양보호사 추가할 때 알람 테이블도 추가하기
pykido Nov 6, 2024
b877e08
refactor : 스케쥴러 코드 수정하기
pykido Nov 6, 2024
76bb71c
feat : 요양보호사 성공!!!
pykido Nov 6, 2024
cc5d5a1
feat : 다음 근무일에 보낼 알림 메시지 작성
pykido Nov 6, 2024
a30faa6
feat : 요양보호사 로직 완성
pykido Nov 6, 2024
f04006e
refactor : 디렉토리 위치 변경
pykido Nov 6, 2024
b445829
feat : coolsms 의존성 추가
pykido Nov 7, 2024
7ad1d15
feat : sms 문자 메시지 api 연결 완료
pykido Nov 7, 2024
244fe52
feat : Presigned Url 생성 및 테스트 완료
pykido Nov 7, 2024
0f54d10
feat : 키값과 presigned url을 OcrData 테이블에 저장해주기
pykido Nov 8, 2024
c513b0d
feat : Naver Clova OCR API를 통하여 텍스트 추출 성공
pykido Nov 8, 2024
0c74f89
feat : Naver Clova OCR API를 통하여 표 추출 성공
pykido Nov 8, 2024
d80c1c7
refactor : Presigned URL 생성 및 반환 로직 수정
pykido Nov 8, 2024
69329d3
refactor : OCR 인식 과정 수정
pykido Nov 8, 2024
1458e6a
refactor : 간단한 수정
pykido Nov 9, 2024
a2a4aa6
Merge branch 'refs/heads/Week10' into #81-OCR-+-S3-+-presigned-url
pykido Nov 10, 2024
dd1bed2
refactor : excel 파일 이전
pykido Nov 10, 2024
a3ab3d2
refactor : 이름 수정
pykido Nov 10, 2024
9992a4e
refactor : 엑셀 파일 이전
pykido Nov 10, 2024
a670f84
refactor : 4. Chart API까지 확인 완료
pykido Nov 10, 2024
9537866
refactor : 숨기기
pykido Nov 10, 2024
5f3c7f3
refactor : OCR Test 완료!!!
pykido Nov 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ dependencies {

// Redis
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

// SQS
implementation platform("io.awspring.cloud:spring-cloud-aws-dependencies:3.0.1")
implementation 'io.awspring.cloud:spring-cloud-aws-starter-sqs'

// CoolSMS
implementation 'net.nurigo:sdk:4.3.0'

// AWS S3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// Naver Clova OCR API
implementation 'org.springframework.boot:spring-boot-starter-webflux' // WebClient 사용을 위한 라이브러리
}

tasks.named('test') {
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/dbdr/domain/careworker/WorkDay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dbdr.domain.careworker;

public enum WorkDay {
MONDAY(1),
TUESDAY(2),
WEDNESDAY(4),
THURSDAY(8),
FRIDAY(16),
SATURDAY(32),
SUNDAY(64);

private final int value;

WorkDay(int value) {
this.value = value;
}

public int getValue() {
return value;
}
}
31 changes: 27 additions & 4 deletions src/main/java/dbdr/domain/careworker/entity/Careworker.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dbdr.domain.careworker.entity;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.DayOfWeek;
import java.time.LocalTime;

import dbdr.domain.core.base.entity.BaseEntity;
Expand Down Expand Up @@ -40,11 +39,14 @@ public class Careworker extends BaseEntity {
@JoinColumn(name = "institution_id")
private Institution institution;

@Column(nullable = false)
private int workDays; // 비트 플래그로 요일 저장

@Column(nullable = true)
private String lineUserId;

@Column(nullable = true)
private LocalTime alertTime;
private LocalTime alertTime = LocalTime.of(17, 0); // 오후 5시로 초기화

@Column(unique = true)
private String email;
Expand Down Expand Up @@ -72,4 +74,25 @@ public void updateLineUserId(String lineUserId) {
public void updateAlertTime(LocalTime alertTime) {
this.alertTime = alertTime;
}
}

// 요일 설정 및 조회 메서드
public void addWorkDay(DayOfWeek day) {
this.workDays |= day.getValue();
}

// 다음 근무일 찾기
public DayOfWeek getNextWorkingDay(DayOfWeek currentDay) {
for (int i = 1; i <= 7; i++) { // 최대 7일을 순환하여 다음 근무일 찾기
DayOfWeek nextDay = currentDay.plus(i);
if (isWorkingOn(nextDay)) {
return nextDay;
}
}
return null;
}

// 근무일인지 확인하기
public boolean isWorkingOn(DayOfWeek day) {
return (this.workDays & (1 << (day.getValue() - 1))) != 0;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dbdr.domain.careworker.dto.request.CareworkerRequestDTO;
import dbdr.domain.careworker.dto.response.CareworkerResponseDTO;
import dbdr.domain.careworker.repository.CareworkerRepository;
import dbdr.domain.core.alarm.service.AlarmService;
import dbdr.domain.institution.entity.Institution;
import dbdr.domain.institution.service.InstitutionService;
import dbdr.global.exception.ApplicationError;
Expand All @@ -12,6 +13,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalTime;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -21,6 +23,7 @@ public class CareworkerService {

private final CareworkerRepository careworkerRepository;
private final InstitutionService institutionService;
private final AlarmService alarmService;

@Transactional(readOnly = true)
public List<CareworkerResponseDTO> getCareworkersByInstitution(Long institutionId) {
Expand Down Expand Up @@ -50,8 +53,9 @@ public CareworkerResponseDTO createCareworker(CareworkerRequestDTO careworkerReq
Institution institution = institutionService.getInstitutionById(institutionId);
Careworker careworker = new Careworker(institution, careworkerRequestDTO.getName(),
careworkerRequestDTO.getEmail(), careworkerRequestDTO.getPhone());

careworkerRepository.save(careworker);
alarmService.createCareworkerAlarm(careworker);

return toResponseDTO(careworker);
}

Expand Down Expand Up @@ -102,11 +106,20 @@ private CareworkerResponseDTO toResponseDTO(Careworker careworker) {
careworker.getName(), careworker.getEmail(), careworker.getPhone());
}

public Careworker findByLineUserId(String userId) {
return careworkerRepository.findByLineUserId(userId).orElse(null);
public List<Careworker> findByAlertTime(LocalTime currentTime) {
return careworkerRepository.findByAlertTime(currentTime);
}

public Careworker findByPhone(String phoneNumber) {
return careworkerRepository.findByPhone(phoneNumber).orElse(null);
}

@Transactional
public void updateLineUserId(String userId, String phoneNumber) {
Careworker careworker = findByPhone(phoneNumber);
careworker.updateLineUserId(userId);
careworkerRepository.save(careworker);
}


}
74 changes: 74 additions & 0 deletions src/main/java/dbdr/domain/core/alarm/entity/Alarm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package dbdr.domain.core.alarm.entity;

import java.time.LocalDateTime;

import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLRestriction;

import dbdr.domain.core.base.entity.BaseEntity;
import dbdr.domain.core.messaging.MessageChannel;
import dbdr.domain.core.messaging.Role;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "alarms")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@SQLDelete(sql = "UPDATE alarms SET is_active = false WHERE id = ?")
@SQLRestriction("is_active = true")
public class Alarm extends BaseEntity {

@Column(nullable = false)
private LocalDateTime alertTime;

@Column(nullable = false)
private String message;

@Enumerated(EnumType.STRING)
@Column(nullable = true)
private MessageChannel channel;

@Column(nullable = true)
private String channelId;

@Column(nullable = false)
private String phone;

@Column(nullable = true)
private boolean isSend = false;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Role role;

@Column(nullable = false)
private Long roleId;

public Alarm(LocalDateTime alertTime, String message, String phone, Role role, Long roleId) {
this.alertTime = alertTime;
this.message = message;
this.phone = phone;
this.role = role;
this.roleId = roleId;
}

public Alarm(LocalDateTime alertTime, MessageChannel channel, String channelId, String message, String phone, Role role, Long roleId) {
this.alertTime = alertTime;
this.channel = channel;
this.channelId = channelId;
this.message = message;
this.phone = phone;
this.role = role;
this.roleId = roleId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dbdr.domain.core.alarm.repository;

import java.time.LocalDateTime;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import dbdr.domain.core.alarm.entity.Alarm;

public interface AlarmRepository extends JpaRepository<Alarm, Long> {
Optional<Alarm> findByPhone(String phone);

Optional<Alarm> findByPhoneAndAlertTime(String phone, LocalDateTime alertTime);
}
Loading