commute 진행중
This commit is contained in:
parent
3c94a2ff8c
commit
e5f73bd852
@ -25,9 +25,10 @@ public class UserInterceptor implements HandlerInterceptor {
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
log.info(" :: postHandle :: ");
|
||||
log.info("Request URL: " + request.getRequestURL());
|
||||
log.info("Request Method: " + request.getMethod());
|
||||
log.info("Remote Address: " + request.getRemoteAddr());
|
||||
log.info(" :: Request URL: " + request.getRequestURL());
|
||||
log.info(" :: Request Method: " + request.getMethod());
|
||||
log.info(" :: Remote Address: " + request.getRemoteAddr());
|
||||
log.info(" :: modelAndView: " + modelAndView);
|
||||
|
||||
if (modelAndView != null) {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
47
src/main/java/com/itn/admin/cmn/util/DateUtils.java
Normal file
47
src/main/java/com/itn/admin/cmn/util/DateUtils.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.itn.admin.cmn.util;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DateUtils {
|
||||
|
||||
|
||||
|
||||
public static Map<String,String> getPreviousBusinessDay(){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
|
||||
|
||||
// 현재 날짜 구하기
|
||||
LocalDate now = LocalDate.now().minusDays(1);
|
||||
|
||||
// 만약 전날이 토요일(7) 또는 일요일(1)이면 금요일로 설정
|
||||
if (now.getDayOfWeek() == DayOfWeek.SATURDAY) {
|
||||
now = now.minusDays(1); // 토요일이면 금요일로
|
||||
} else if (now.getDayOfWeek() == DayOfWeek.SUNDAY) {
|
||||
now = now.minusDays(2); // 일요일이면 금요일로
|
||||
}
|
||||
// 년도 구하기
|
||||
String year = String.valueOf(now.getYear());
|
||||
|
||||
String month = now.format(DateTimeFormatter.ofPattern("M"));
|
||||
|
||||
String day = now.format(DateTimeFormatter.ofPattern("d"));
|
||||
|
||||
|
||||
// 결과 출력
|
||||
System.out.println("Year: " + year);
|
||||
System.out.println("Month: " + month);
|
||||
System.out.println("Day: " + day);
|
||||
|
||||
map.put("year",year);
|
||||
map.put("month",month);
|
||||
map.put("day",day);
|
||||
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
package com.itn.admin.cmn.util.scheduled;
|
||||
|
||||
import com.itn.admin.commute.mapper.domain.CommuteVO;
|
||||
import com.itn.admin.commute.service.CommuteService;
|
||||
import com.itn.admin.etc.crawling.morak.service.MorakService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -19,15 +22,25 @@ import java.io.IOException;
|
||||
* 2023-08-28 hylee 최초 생성
|
||||
*/
|
||||
@Service
|
||||
@ConditionalOnProperty(name = "spring.profiles.active", havingValue = "prod")
|
||||
public class ScheduledTasks {
|
||||
|
||||
@Autowired
|
||||
private MorakService morakService;
|
||||
|
||||
@Autowired
|
||||
private CommuteService commuteService;
|
||||
|
||||
// @Scheduled(cron = "*/50 * * * * MON-FRI")
|
||||
@Scheduled(cron = "0 40 10 * * MON-FRI")
|
||||
public void noonJob() throws IOException {
|
||||
System.out.println("It's noon!");
|
||||
morakService.morakMenu();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 10 * * MON-FRI")
|
||||
public void commuteJob() throws IOException {
|
||||
CommuteVO commuteVO = new CommuteVO();
|
||||
commuteService.transfer(commuteVO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,8 +14,10 @@ public class ItnCommuteVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String commuteId; // 아이디
|
||||
private Integer commuteId; // 아이디
|
||||
private Integer commuteGroupId; // 그룹 아이디
|
||||
private String name; // 이름
|
||||
private String pstn; // 직위
|
||||
private String category; // 구분
|
||||
private String workDt; // 근무일자
|
||||
private String startTime; // 출근시간
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.itn.admin.commute.service.impl;
|
||||
|
||||
import com.itn.admin.cmn.util.DateUtils;
|
||||
import com.itn.admin.commute.mapper.CommuteMapper;
|
||||
import com.itn.admin.commute.mapper.domain.CommuteVO;
|
||||
import com.itn.admin.commute.mapper.domain.ItnCommuteGroupVO;
|
||||
import com.itn.admin.commute.mapper.domain.ItnCommuteVO;
|
||||
import com.itn.admin.commute.mapper.domain.UserEnum;
|
||||
import com.itn.admin.commute.service.CommuteService;
|
||||
import com.itn.admin.itn.commute.mapper.ItnCommuteMapper;
|
||||
@ -52,29 +54,44 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
public Map<String, Object> transfer(CommuteVO commuteVO) {
|
||||
List<CommuteVO> commuteList = makeList(commuteVO);
|
||||
|
||||
String startDate = commuteList.get(0).getStartDate();
|
||||
String startDate = commuteVO.getStartDate();
|
||||
|
||||
Boolean startDateYN = false;
|
||||
for (CommuteVO tt : commuteList){
|
||||
if(StringUtils.isNotEmpty(tt.getStartDate())){
|
||||
startDateYN = true;
|
||||
}
|
||||
}
|
||||
if(!startDateYN){
|
||||
|
||||
}
|
||||
|
||||
String wordDt = startDate.split(" ")[0];
|
||||
Integer groupId = itnCommuteMapper.findByCommuteGroupIdFromItnCommuteWhereWordDt(wordDt);
|
||||
System.out.println("startDate :: "+startDate);
|
||||
String workDt = startDate.split(" ")[0];
|
||||
Integer groupId = itnCommuteMapper.findByCommuteGroupIdFromItnCommuteWhereWordDt(workDt);
|
||||
|
||||
// groupId가 없으면 groupId insert
|
||||
if(groupId == null) {
|
||||
ItnCommuteGroupVO itnGroupVO = new ItnCommuteGroupVO();
|
||||
itnGroupVO.setWorkDt(workDt);
|
||||
itnCommuteMapper.insertCommuteGroup(itnGroupVO);
|
||||
groupId = itnGroupVO.getCommuteGroupId();
|
||||
}
|
||||
System.out.println("groupId : "+groupId);
|
||||
|
||||
|
||||
List<ItnCommuteVO> itnCommuteList = new ArrayList<>();
|
||||
|
||||
for(CommuteVO vo : commuteList) {
|
||||
ItnCommuteVO itnCommuteVO = new ItnCommuteVO();
|
||||
itnCommuteVO.setCommuteGroupId(groupId);
|
||||
itnCommuteVO.setWorkDt(workDt);
|
||||
|
||||
itnCommuteVO.setName(vo.getUsrid());
|
||||
itnCommuteVO.setPstn(vo.getPstn());
|
||||
|
||||
itnCommuteVO.setStartTime(vo.getFirstActivityTime());
|
||||
itnCommuteVO.setStartRslt(vo.getFirstActivityTimeMemo());
|
||||
|
||||
itnCommuteVO.setEndTime(vo.getLastActivityTime());
|
||||
itnCommuteVO.setEndRslt(vo.getLastActivityTimeMemo());
|
||||
|
||||
itnCommuteList.add(itnCommuteVO);
|
||||
}
|
||||
|
||||
itnCommuteMapper.upsertCommuteList(itnCommuteList);
|
||||
|
||||
|
||||
// controller에 return
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
@ -91,31 +108,12 @@ public class CommuteServiceImpl implements CommuteService {
|
||||
if(StringUtils.isNotEmpty(commuteVO.getSearchYear())){
|
||||
|
||||
}else{
|
||||
// 현재 날짜 구하기
|
||||
LocalDate now = LocalDate.now().minusDays(1);
|
||||
|
||||
// 만약 전날이 토요일(7) 또는 일요일(1)이면 금요일로 설정
|
||||
if (now.getDayOfWeek() == DayOfWeek.SATURDAY) {
|
||||
now = now.minusDays(1); // 토요일이면 금요일로
|
||||
} else if (now.getDayOfWeek() == DayOfWeek.SUNDAY) {
|
||||
now = now.minusDays(2); // 일요일이면 금요일로
|
||||
}
|
||||
// 년도 구하기
|
||||
String year = String.valueOf(now.getYear());
|
||||
|
||||
String month = now.format(DateTimeFormatter.ofPattern("M"));
|
||||
|
||||
String day = now.format(DateTimeFormatter.ofPattern("d"));
|
||||
Map<String,String> map = DateUtils.getPreviousBusinessDay();
|
||||
|
||||
|
||||
// 결과 출력
|
||||
System.out.println("Year: " + year);
|
||||
System.out.println("Month: " + month);
|
||||
System.out.println("Day: " + day);
|
||||
|
||||
commuteVO.setSearchYear(year);
|
||||
commuteVO.setSearchMonth(month);
|
||||
commuteVO.setSearchDay(day);
|
||||
commuteVO.setSearchYear(map.get("year"));
|
||||
commuteVO.setSearchMonth(map.get("month"));
|
||||
commuteVO.setSearchDay(map.get("day"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.itn.admin.commute.web;
|
||||
|
||||
import com.itn.admin.cmn.util.DateUtils;
|
||||
import com.itn.admin.commute.mapper.domain.CommuteVO;
|
||||
import com.itn.admin.commute.mapper.domain.ItnCommuteVO;
|
||||
import com.itn.admin.commute.service.CommuteService;
|
||||
@ -8,6 +9,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -33,8 +35,17 @@ public class CommuteController {
|
||||
return "commute/list_backup";
|
||||
}
|
||||
|
||||
@GetMapping(value = "1")
|
||||
public String list_test(@ModelAttribute("commuteVO") ItnCommuteVO itnCommuteVO, Model model) {
|
||||
@GetMapping(value = "/commute/list_test")
|
||||
public String list_test(@ModelAttribute ItnCommuteVO itnCommuteVO, Model model) {
|
||||
// commuteVO.getWorkDt()를 사용하여 workDt 값에 접근할 수 있습니다.
|
||||
System.out.println("itnCommuteVO.getWorkDt(); : "+ itnCommuteVO.getWorkDt());
|
||||
|
||||
|
||||
// Map<String,String> map = DateUtils.getPreviousBusinessDay();
|
||||
// commuteVO.setSearchYear(map.get("year"));
|
||||
// commuteVO.setSearchMonth(map.get("month"));
|
||||
// commuteVO.setSearchDay(map.get("day"));
|
||||
|
||||
|
||||
|
||||
// Map<String, Object> resultMap = commuteService.getList(itnCommuteVO);
|
||||
|
||||
@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@ -26,7 +28,35 @@ public class CommuteRestController {
|
||||
|
||||
@GetMapping(value = "/api/commute/transfer")
|
||||
public ResponseEntity<RestResponse> list(@ModelAttribute("commuteVO") CommuteVO commuteVO, Model model) {
|
||||
Map<String, Object> resultMap = commuteService.transfer(commuteVO);
|
||||
// 시작 날짜 (2024년 8월 1일)
|
||||
// LocalDate startDate = LocalDate.of(2024, 8, 1);
|
||||
// 오늘 날짜
|
||||
// LocalDate endDate = LocalDate.now();
|
||||
|
||||
// 날짜 형식
|
||||
// DateTimeFormatter yearFormatter = DateTimeFormatter.ofPattern("yyyy");
|
||||
// DateTimeFormatter monthFormatter = DateTimeFormatter.ofPattern("MM");
|
||||
// DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern("dd");
|
||||
|
||||
// 날짜 반복 (하루씩 증가)
|
||||
// for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
// // 현재 날짜를 파라미터 형식에 맞게 변환
|
||||
// String year = date.format(yearFormatter);
|
||||
// String month = date.format(monthFormatter);
|
||||
// String day = date.format(dayFormatter);
|
||||
|
||||
// commuteVO.setSearchYear(year);
|
||||
// commuteVO.setSearchMonth(month);
|
||||
// commuteVO.setSearchDay(day);
|
||||
|
||||
// 서비스 메서드 호출
|
||||
Map<String, Object> resultMap = commuteService.transfer(commuteVO);
|
||||
|
||||
// 결과 출력 (디버깅용)
|
||||
// System.out.println("Date: " + date + ", Result: " + resultMap);
|
||||
// }
|
||||
|
||||
// return ResponseEntity.ok().body(new RestResponse(HttpStatus.OK,"성공적으로 조회했습니다.",""));
|
||||
return ResponseEntity.ok().body(new RestResponse(HttpStatus.OK,"성공적으로 조회했습니다.",resultMap));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.itn.admin.itn.commute.mapper;
|
||||
|
||||
import com.itn.admin.commute.mapper.domain.ItnCommuteGroupVO;
|
||||
import com.itn.admin.commute.mapper.domain.ItnCommuteVO;
|
||||
import com.itn.admin.itn.commute.mapper.domain.ItnCommuteBackVO;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -26,7 +27,9 @@ public interface ItnCommuteMapper {
|
||||
|
||||
Integer findByCommuteGroupIdFromItnCommuteWhereWordDt(String wordDt);
|
||||
|
||||
@Insert("INSERT INTO itn_commute_group (work_dt) VALUES (NOW())")
|
||||
@Insert("INSERT INTO itn_commute_group (work_dt) VALUES (#{workDt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "commuteGroupId")
|
||||
void insertCommuteGroup(ItnCommuteGroupVO itnGroupVO);
|
||||
|
||||
void upsertCommuteList(List<ItnCommuteVO> itnCommuteList);
|
||||
}
|
||||
|
||||
@ -31,10 +31,23 @@
|
||||
FROM
|
||||
itn_commute
|
||||
WHERE
|
||||
word_dt = #{wordDt}
|
||||
work_dt = #{workDt}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="upsertCommuteList" parameterType="java.util.List">
|
||||
INSERT INTO itn_commute
|
||||
(commute_group_id, name, pstn, work_dt, start_time, start_rslt, end_time, end_rslt)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.commuteGroupId}, #{item.name}, #{item.pstn}, #{item.workDt},
|
||||
#{item.startTime}, #{item.startRslt}, #{item.endTime}, #{item.endRslt})
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
start_time = VALUES(start_time),
|
||||
start_rslt = VALUES(start_rslt),
|
||||
end_time = VALUES(end_time),
|
||||
end_rslt = VALUES(end_rslt)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@ -74,6 +74,66 @@
|
||||
.attendance-table td:nth-child(2) {
|
||||
border-right: 2px solid #dee2e6; /* 이름 열의 오른쪽 테두리 굵게 */
|
||||
}
|
||||
/* 검색 버튼 스타일 */
|
||||
.search-btn {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 12px 20px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
border-radius: 5px;
|
||||
width: 50%;
|
||||
transition: all 0.3s ease;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.top_row {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.search-btn:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
/* 버튼 및 날짜 필드 정렬 */
|
||||
.card-body .form-group {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.card-body .input-group, .card-body .search-btn {
|
||||
height: 55%;
|
||||
width: 222px;
|
||||
}
|
||||
|
||||
/* 테이블 및 컨테이너 스타일 */
|
||||
.attendance-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.attendance-table th, .attendance-table td {
|
||||
border: 1px solid #dee2e6;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.attendance-table thead th {
|
||||
background-color: #f4f6f9;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.attendance-table tbody tr:nth-child(even) {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.attendance-table tbody tr:hover {
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
@ -81,7 +141,7 @@
|
||||
<body layout:fragment="body">
|
||||
|
||||
<div class="wrapper">
|
||||
<div th:replace="~{fragments/top_nav :: topFragment}"/>
|
||||
<div th:replace="~{fragments/top_nav :: topFragment}"></div>
|
||||
|
||||
<!-- Main Sidebar Container -->
|
||||
<aside class="main-sidebar sidebar-dark-primary elevation-4"
|
||||
@ -120,53 +180,69 @@
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
<table class="attendance-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>순번</th>
|
||||
<th>이름</th>
|
||||
<th>퇴근시간(전일)</th>
|
||||
<th>결과</th>
|
||||
<th>출근(당일)</th>
|
||||
<th>결과</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 04:38:30</td>
|
||||
<td>미인식</td>
|
||||
<td>2012.11.02 04:38:30</td>
|
||||
<td>미인식</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 06:47:02</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td>연차(오전)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 07:03:21</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:05:39</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!-- 나머지 행들도 동일한 형식으로 추가 -->
|
||||
</tbody>
|
||||
</table>
|
||||
<form id="searchForm" method="GET" th:action="@{/commute/list_test}">
|
||||
<div class="row top_row">
|
||||
<div class="col-sm-2">
|
||||
<div class="form-group">
|
||||
<label>검색 날짜</label>
|
||||
<div class="input-group">
|
||||
<input type="date" name="workDt" class="form-control" th:value="${itnCommuteVO.workDt}" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 검색 버튼 -->
|
||||
<div class="col-sm-2 d-flex align-items-end">
|
||||
<button type="submit" class="btn btn-primary search-btn">검색</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<table class="attendance-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>순번</th>
|
||||
<th>이름</th>
|
||||
<th>퇴근시간(전일)</th>
|
||||
<th>결과</th>
|
||||
<th>출근(당일)</th>
|
||||
<th>결과</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 04:38:30</td>
|
||||
<td>미인식</td>
|
||||
<td>2012.11.02 04:38:30</td>
|
||||
<td>미인식</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 06:47:02</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:01:10</td>
|
||||
<td>연차(오전)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>박성경</td>
|
||||
<td>2012.11.02 07:03:21</td>
|
||||
<td></td>
|
||||
<td>2012.11.02 07:05:39</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!-- 나머지 행들도 동일한 형식으로 추가 -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user