직원 임시 추가 로직
This commit is contained in:
parent
bb47656bb8
commit
7caaa99ae9
@ -20,6 +20,7 @@ import java.io.Serializable;
|
||||
@Builder
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CommuteVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -16,6 +16,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ -84,6 +85,7 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
commuteList.stream().forEach(t->{
|
||||
|
||||
|
||||
|
||||
// 지각 체크
|
||||
t.setFirstActivityTimeMemo(this.getLateChk(t.getFirstActivityTime()));
|
||||
// 조기퇴근 체크
|
||||
@ -101,8 +103,10 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
commuteList.forEach(t-> {
|
||||
t.setFirstActivityTime(t.getFirstActivityTime().split(" ")[1]);
|
||||
t.setLastActivityTime(t.getLastActivityTime().split(" ")[1]);
|
||||
});
|
||||
|
||||
// 출근안한사람 체크하기
|
||||
for (UserEnum user : UserEnum.values()) {
|
||||
@ -126,11 +130,35 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
}
|
||||
}
|
||||
|
||||
commuteList.forEach(commute -> System.out.println(commute.toString()));
|
||||
|
||||
commuteList.removeIf(t -> "유인식".equals(t.getUsrid())
|
||||
|| "itn6".equals(t.getUsrid())
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
출근 09시20분~30분 출근 09시00분~15분
|
||||
퇴근 13시30분~45분 퇴근 13시30분~45분
|
||||
박승미 대리 이명환 주임
|
||||
*/
|
||||
|
||||
CommuteVO commuteVO1= new CommuteVO();
|
||||
commuteVO1.setFirstActivityTime(getRandomTime("09:20:01", "09:29:59"));
|
||||
commuteVO1.setLastActivityTime(getRandomTime("13:30:00", "13:45:00"));
|
||||
commuteVO1.setUsrid("박승미");
|
||||
commuteVO1.setPstn("대리");
|
||||
|
||||
CommuteVO commuteVO2= new CommuteVO();
|
||||
commuteVO2.setFirstActivityTime(getRandomTime("09:00:01", "09:14:59"));
|
||||
commuteVO2.setLastActivityTime(getRandomTime("13:30:00", "13:45:00"));
|
||||
commuteVO2.setUsrid("이명환");
|
||||
commuteVO2.setPstn("주임");
|
||||
|
||||
commuteList.add(commuteVO1);
|
||||
commuteList.add(commuteVO2);
|
||||
|
||||
|
||||
// controller에 return
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
|
||||
@ -139,6 +167,25 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String getRandomTime(String start, String end) {
|
||||
// 문자열을 LocalTime으로 변환
|
||||
LocalTime startTime = LocalTime.parse(start, DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
LocalTime endTime = LocalTime.parse(end, DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
|
||||
// 총 초 계산
|
||||
long startSeconds = startTime.toSecondOfDay();
|
||||
long endSeconds = endTime.toSecondOfDay();
|
||||
|
||||
// 무작위 초 생성
|
||||
long randomSeconds = ThreadLocalRandom.current().nextLong(startSeconds, endSeconds + 1);
|
||||
|
||||
// 무작위 시간 계산
|
||||
LocalTime randomTime = LocalTime.ofSecondOfDay(randomSeconds);
|
||||
|
||||
// 시간 형식을 "HH:mm:ss"로 변환
|
||||
return randomTime.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
|
||||
}
|
||||
|
||||
private String getLeaveWorkEarly(String p_lastActivityTime) {
|
||||
// DateTimeFormatter를 사용하여 String을 LocalDateTime으로 파싱
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@ -14,7 +14,7 @@ public interface CodeService {
|
||||
|
||||
RestResponse addCodeGroup(CodeVO codeGroup);
|
||||
|
||||
void updateCodeGroup(CodeVO codeGroup);
|
||||
RestResponse updateCodeGroup(CodeVO codeGroup);
|
||||
|
||||
void deleteCodeGroup(String codeGroupId);
|
||||
}
|
||||
|
||||
@ -29,8 +29,9 @@ public class CodeServiceImpl implements CodeService {
|
||||
return new RestResponse(HttpStatus.OK, "등록되었습니다.", codeVO.getCodeGroupId());
|
||||
}
|
||||
|
||||
public void updateCodeGroup(CodeVO codeVO) {
|
||||
public RestResponse updateCodeGroup(CodeVO codeVO) {
|
||||
codeMapper.update(codeVO);
|
||||
return new RestResponse(HttpStatus.OK, "수정되었습니다.", "");
|
||||
}
|
||||
|
||||
public void deleteCodeGroup(String codeGroupId) {
|
||||
|
||||
@ -37,9 +37,10 @@ public class CodeRestController {
|
||||
|
||||
// 코드 그룹 수정 메서드
|
||||
@PutMapping("/{codeGroupId}")
|
||||
public void updateCodeGroup(@PathVariable String codeGroupId, @RequestBody CodeVO codeGroup) {
|
||||
public ResponseEntity<RestResponse> updateCodeGroup(@PathVariable String codeGroupId, @RequestBody CodeVO codeGroup) {
|
||||
codeGroup.setCodeGroupId(codeGroupId);
|
||||
codeService.updateCodeGroup(codeGroup);
|
||||
return ResponseEntity.ok().body(codeService.updateCodeGroup(codeGroup));
|
||||
|
||||
}
|
||||
|
||||
// 코드 그룹 삭제 메서드
|
||||
|
||||
@ -186,8 +186,6 @@
|
||||
, "pageLength": 20
|
||||
, "buttons": ["copy", { extend: 'csv', charset: 'UTF-8', bom: true }
|
||||
, "excel", "pdf", "print", "colvis"]
|
||||
// , "buttons": ["copy", { extend: 'csv', charset: 'UTF-8', bom: true }
|
||||
// , "excel", "pdf", "print", "colvis"]
|
||||
}).buttons().container().appendTo('#commuteTb_wrapper .col-md-6:eq(0)');
|
||||
});
|
||||
|
||||
|
||||
@ -122,6 +122,40 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 공통 코드 그룹 수정 모달 -->
|
||||
<div class="modal fade" id="editCodeGroupModal" tabindex="-1" role="dialog" aria-labelledby="editCodeGroupModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="editCodeGroupModalLabel">공통 코드 수정</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editCodeGroupForm">
|
||||
<div class="form-group">
|
||||
<label for="editCodeGroupId">코드 그룹 ID</label>
|
||||
<input type="text" class="form-control" id="editCodeGroupId" name="codeGroupId" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editCodeGroupName">코드 그룹 이름</label>
|
||||
<input type="text" class="form-control" id="editCodeGroupName" name="codeGroupName" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="editDescription">설명</label>
|
||||
<textarea class="form-control" id="editDescription" name="description"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">닫기</button>
|
||||
<button type="button" class="btn btn-primary" onclick="updateCodeGroup()">저장</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 공통 코드 상세 모달 -->
|
||||
<div class="modal fade" id="commonCodeDetailModal" tabindex="-1" role="dialog" aria-labelledby="commonCodeDetailModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
@ -274,8 +308,55 @@
|
||||
});
|
||||
};
|
||||
|
||||
let currentCodeGroupId; // 전역 변수로 코드 그룹 ID를 저장
|
||||
|
||||
// 코드 그룹 수정 모달을 표시하는 함수
|
||||
window.editCodeGroup = function(codeGroupId) {
|
||||
$.ajax({
|
||||
url: '/api/codes/' + codeGroupId,
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
$('#editCodeGroupId').val(data.codeGroupId);
|
||||
$('#editCodeGroupName').val(data.codeGroupName);
|
||||
$('#editDescription').val(data.description);
|
||||
$('#editCodeGroupModal').modal('show'); // 모달 표시
|
||||
},
|
||||
error: function(xhr) {
|
||||
alert('코드 그룹 정보를 불러오는 데 실패했습니다.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 코드 그룹 수정 함수
|
||||
window.updateCodeGroup = function() {
|
||||
var formDataArray = $("#editCodeGroupForm").serializeArray();
|
||||
var formData = {};
|
||||
|
||||
// 배열 데이터를 JSON 객체로 변환
|
||||
$.each(formDataArray, function(_, field) {
|
||||
formData[field.name] = field.value;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: '/api/codes/' + formData.codeGroupId,
|
||||
type: 'PUT',
|
||||
data: JSON.stringify(formData),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
$('#editCodeGroupModal').modal('hide');
|
||||
loadCodes(); // 테이블 갱신
|
||||
fn_successAlert("성공", data.data +'(이)가 '+data.msg);
|
||||
},
|
||||
error: function(xhr) {
|
||||
alert('코드 그룹 수정 중 오류가 발생했습니다.');
|
||||
console.log('xhr : ', xhr);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
let currentCodeGroupId; // 전역 변수로 코드 그룹 ID를 저장
|
||||
// 코드 상세보기 모달을 표시하는 함수
|
||||
window.showDetails = function(codeGroupId) {
|
||||
currentCodeGroupId = codeGroupId; // 현재 코드 그룹 ID 저장
|
||||
|
||||
Loading…
Reference in New Issue
Block a user