DB 수정

This commit is contained in:
hehihoho3@gmail.com 2024-10-29 15:48:55 +09:00
parent 09e9d2421d
commit db220dd7b0
14 changed files with 431 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package com.itn.admin;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
@ -10,6 +11,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication
@MapperScan("com.itn.admin.itn.commute.mapper") // 패키지 경로를 정확히 지정
//@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
public class ItnAdminApplication {

View File

@ -31,7 +31,7 @@ public interface AgentCFourMapper {
String findByRequestDateWhereMessageFromLog(AgentCFourVO agentCFourVO);
@Select("""
SELECT
COUNT(*) AS reportCnt, -- ' 카운트',
MIN(REPORT_DATE) AS minReportDate, -- '가장 빠른 REPORT_DATE',

View File

@ -31,7 +31,7 @@ public interface AgentCThreeMapper {
String findByRequestDateWhereMessageFromLog(AgentCThreeVO agentCFourVO);
@Select("""
SELECT
COUNT(*) AS reportCnt, -- ' 카운트',
MIN(REPORT_DATE) AS minReportDate, -- '가장 빠른 REPORT_DATE',

View File

@ -0,0 +1,23 @@
package com.itn.admin.itn.commute.mapper;
import com.itn.admin.itn.commute.mapper.domain.ItnCommuteVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* packageName : com.itn.mjonApi.mjon.api.send.mapper.domain
* fileName : SendMapper
* author : hylee
* date : 2023-05-19
* description :
* ===========================================================
* DATE AUTHOR NOTE
* -----------------------------------------------------------
* 2023-05-19 hylee 최초 생성
*/
@Mapper
public interface ItnCommuteMapper {
List<ItnCommuteVO> findAll(ItnCommuteVO itnCommuteVO);
}

View File

@ -0,0 +1,26 @@
package com.itn.admin.itn.commute.mapper.domain;
import lombok.*;
import java.io.Serializable;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Getter
@Setter
@ToString
public class ItnCommuteVO implements Serializable {
private static final long serialVersionUID = 1L;
private String commuteId; // 아이디
private String commuteName; // 이름
private String commuteCategory; // 구분
private String commuteWorkDate; // 근무일자
private String commuteStartTime; // 출근시간
private String commuteEndTime; // 퇴근시간
private String startDate;
private String endDate;
}

View File

@ -0,0 +1,12 @@
package com.itn.admin.itn.commute.service;
import com.itn.admin.itn.commute.mapper.domain.ItnCommuteVO;
import java.util.Map;
public interface ItnCommuteService {
Map<String, Object> getList(ItnCommuteVO itnCommuteVO);
}

View File

@ -0,0 +1,65 @@
package com.itn.admin.itn.commute.service.impl;
import com.itn.admin.itn.commute.mapper.ItnCommuteMapper;
import com.itn.admin.itn.commute.mapper.domain.ItnCommuteVO;
import com.itn.admin.itn.commute.service.ItnCommuteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Slf4j
@Service
public class ItnCommuteServiceImpl implements ItnCommuteService {
@Autowired
ItnCommuteMapper itnCommuteMapper;
private static final int PAGE_SIZE = 5;
public Map<String, Object> getList(ItnCommuteVO itnCommuteVO) {
Random random = new Random(); // Random 객체 생성
// controller에 return
Map<String, Object> map = new HashMap<String, Object>();
List<ItnCommuteVO> resultList = itnCommuteMapper.findAll(itnCommuteVO);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss"); // 시간 형식 패턴
for (ItnCommuteVO result : resultList) {
// 출근 시간에 랜덤 추가
if(StringUtils.isEmpty(result.getCommuteStartTime()))
continue;
String startTimeStr = result.getCommuteStartTime();
LocalTime startTime = LocalTime.parse(startTimeStr, formatter); // String을 LocalTime으로 변환
LocalTime randomStartTime = startTime.withSecond(random.nextInt(59) + 1); // 01 ~ 59 사이의 랜덤
result.setCommuteStartTime(randomStartTime.format(formatter)); // 다시 String으로 변환하여 설정
System.out.println("Random Start Time: " + randomStartTime.format(formatter));
// 퇴근 시간에 랜덤 추가
String endTimeStr = result.getCommuteEndTime();
LocalTime endTime = LocalTime.parse(endTimeStr, formatter); // String을 LocalTime으로 변환
LocalTime randomEndTime = endTime.withSecond(random.nextInt(59) + 1); // 01 ~ 59 사이의 랜덤
result.setCommuteEndTime(randomEndTime.format(formatter)); // 다시 String으로 변환하여 설정
System.out.println("Random End Time: " + randomEndTime.format(formatter));
System.out.println("==");
}
map.put("resultList", resultList);
return map;
}
}

View File

@ -0,0 +1,64 @@
package com.itn.admin.itn.commute.web;
import com.itn.admin.itn.commute.mapper.domain.ItnCommuteVO;
import com.itn.admin.itn.commute.service.ItnCommuteService;
import org.springframework.beans.factory.annotation.Autowired;
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;
@Controller
public class ItnCommuteController {
private ItnCommuteService commuteService;
@Autowired
public void setCommuteService(ItnCommuteService commuteService) {
this.commuteService = commuteService;
}
@GetMapping(value = "/itn/commute/list")
public String list(
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
Model model) {
// 기본 설정 (만약 값이 없으면 현재 날짜를 기준으로 설정)
if (startDate == null || endDate == null) {
startDate = "2023-01-01"; // 예시 기본값
endDate = "2024-12-31"; // 예시 기본값
}
// CommuteVO 생성
ItnCommuteVO itnCommuteVO = ItnCommuteVO.builder()
.startDate(startDate)
.endDate(endDate)
.build();
Map<String, Object> resultMap = commuteService.getList(itnCommuteVO);
model.addAttribute("list", resultMap.get("resultList"));
model.addAttribute("commuteVO", itnCommuteVO);
model.addAttribute("startDate", startDate);
model.addAttribute("endDate", endDate);
return "itn/commute/list";
}
// @GetMapping(value = "/itn/commute/list")
// public String list(@ModelAttribute("commuteVO") ItnCommuteVO itnCommuteVO, Model model) {
//
//
// Map<String, Object> resultMap = commuteService.getList(itnCommuteVO);
//
// model.addAttribute("list", resultMap.get("resultList"));
// model.addAttribute("commuteVO", itnCommuteVO);
//
// return "itn/commute/list";
// }
}

View File

@ -1,3 +1,4 @@
server.port=8077
# mybatis setting
@ -46,9 +47,9 @@ spring.mjagent.client.one.datasource.password=mjagent123$
# agent client 2
spring.mjagent.client.two.userid=006star
spring.mjagent.client.two.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.mjagent.client.two.datasource.jdbc-url=jdbc:log4jdbc:mysql://192.168.0.30:3306/mjonUr_agent?serverTimezone=Asia/Seoul
spring.mjagent.client.two.datasource.username=mjonAgentUr
spring.mjagent.client.two.datasource.password=mjonAgentUr!@#$
spring.mjagent.client.two.datasource.jdbc-url=jdbc:log4jdbc:mysql://192.168.0.60:3303/mjon_agent?serverTimezone=Asia/Seoul
spring.mjagent.client.two.datasource.username=mjonUr_agent
spring.mjagent.client.two.datasource.password=mjagent123$
# agent client 3
@ -74,7 +75,7 @@ spring.mjagent.client.five.datasource.password=mjonAgentUr!@#$
# agent server
spring.mjagent.server.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.mjagent.server.datasource.jdbc-url=jdbc:log4jdbc:mysql://119.193.215.98:3306/mjon_agent_back?serverTimezone=Asia/Seoul
spring.mjagent.server.datasource.jdbc-url=jdbc:log4jdbc:mysql://192.168.0.60:3303/mjon_agent_server?serverTimezone=Asia/Seoul
spring.mjagent.server.datasource.username=mjonUr_agent
spring.mjagent.server.datasource.password=mjagent123$
spring.mjagent.server.datasource.hikari.minimum-idle=2

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itn.admin.itn.commute.mapper.ItnCommuteMapper">
<select id="findAll" parameterType="itnCommuteVO" resultType="itnCommuteVO">
SELECT
commute_id AS commuteId,
commute_name AS commuteName,
commute_category AS commuteCategory,
commute_work_date AS commuteWorkDate,
commute_start_time AS commuteStartTime,
commute_end_time AS commuteEndTime
FROM
itn_commute
WHERE
1=1
<if test="startDate != null and startDate != ''">
AND commute_work_date BETWEEN #{startDate} AND #{endDate}
</if>
</select>
</mapper>

View File

@ -25,6 +25,7 @@
<typeAlias type="com.itn.admin.itn.code.mapper.domain.CodeVO" alias="codeVO"/>
<typeAlias type="com.itn.admin.itn.code.mapper.domain.CodeDetailVO" alias="codeDetailVO"/>
<typeAlias type="com.itn.admin.itn.commute.mapper.domain.ItnCommuteVO" alias="itnCommuteVO"/>
</typeAliases>
<!-- <environments default="development">-->

View File

@ -70,7 +70,7 @@
<option th:each="year : ${#numbers.sequence(2023, 2022 + 40)}"
th:value="${year}"
th:text="${year}"
th:selected="${year.toString() == commuteVO.searchYear}"></option>
th:selected="${year.toString() == itnCommuteVO.searchYear}"></option>
</select>
</div>
</div>
@ -81,7 +81,7 @@
<option th:each="month : ${#numbers.sequence(1, 12)}"
th:value="${month}"
th:text="${month}"
th:selected="${month.toString() == commuteVO.searchMonth}"></option>
th:selected="${month.toString() == itnCommuteVO.searchMonth}"></option>
</select>
</div>
</div>
@ -92,7 +92,7 @@
<option th:each="day : ${#numbers.sequence(1, 31)}"
th:value="${day}"
th:text="${day}"
th:selected="${day.toString() == commuteVO.searchDay}"></option>
th:selected="${day.toString() == itnCommuteVO.searchDay}"></option>
</select>
</div>
</div>
@ -112,7 +112,7 @@
</thead>
<tbody>
<tr th:each="row, stat : ${list}">
<td th:text="${commuteVO.searchYear + '-' + commuteVO.searchMonth + '-' + commuteVO.searchDay}"></td>
<td th:text="${itnCommuteVO.searchYear + '-' + itnCommuteVO.searchMonth + '-' + itnCommuteVO.searchDay}"></td>
<td th:text="${row.usrid}"></td>
<td th:text="${row.pstn}"></td>
<td th:text="${row.firstActivityTime}"></td>

View File

@ -57,6 +57,15 @@
</a>
</li>
</ul>
<ul class="nav nav-treeview">
<li class="nav-item">
<a th:href="@{/itn/commute/list}" class="nav-link">
<!-- <i class="far fa-circle nav-icon"></i>-->
<i class="far fa-clock nav-icon"></i>
<p>itn 출퇴근 관리</p>
</a>
</li>
</ul>
<ul class="nav nav-treeview">
<li class="nav-item">
<a th:href="@{/admin/user/list}" class="nav-link">

View File

@ -0,0 +1,190 @@
<!DOCTYPE html>
<!-- 관련 Namespace 선언 및 layout:decorate 추가 -->
<html lang="en"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="layout">
<head>
<!-- layout.html 에 들어간 head 부분을 제외하고 개별 파일에만 적용되는 head 부분 추가 -->
<title>직원 출퇴근 관리</title>
<!-- 필요하다면 개별 파일에 사용될 css/js 선언 -->
<link rel="stylesheet" th:href="@{/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css}">
<link rel="stylesheet" th:href="@{/plugins/datatables-responsive/css/responsive.bootstrap4.min.css}">
<link rel="stylesheet" th:href="@{/plugins/datatables-buttons/css/buttons.bootstrap4.min.css}">
<style>
</style>
<script>
</script>
</head>
<body layout:fragment="body">
<div class="wrapper">
<div th:replace="~{fragments/top_nav :: topFragment}"/>
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4"
th:insert="~{fragments/mainsidebar :: sidebarFragment}">
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">출퇴근 관리</h1>
</div><!-- /.col -->
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">출퇴근 관리</li>
</ol>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<!-- /.card -->
<div class="card">
<div class="card-header">
<h3 class="card-title">목록</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<form id="searchForm" method="GET" th:action="@{/itn/commute/list}">
<div class="row">
<div class="col-sm-2">
<div class="form-group">
<label>시작 날짜</label>
<input type="date" name="startDate" class="form-control" th:value="${startDate}" required>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<label>종료 날짜</label>
<input type="date" name="endDate" class="form-control" th:value="${endDate}" required>
</div>
</div>
<!-- 검색 버튼 -->
<div class="col-sm-2 d-flex align-items-end">
<button type="submit" class="btn btn-primary btn-search btn-block" style="height: 70px;">검색</button>
</div>
</div>
</form>
<table id="commuteTb" class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>출근</th>
<!-- <th>직위</th>-->
<th>비고</th>
<th>퇴근</th>
</tr>
</thead>
<tbody>
<tr th:each="row, stat : ${list}">
<td th:text="${row.commuteWorkDate}"></td>
<td th:text="${row.commuteName}"></td>
<td th:text="${row.commuteStartTime}"></td>
<td th:text="${row.commuteCategory}"></td>
<td th:text="${row.commuteEndTime}"></td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<th>Name</th>
<th>출근</th>
<!-- <th>직위</th>-->
<th>비고</th>
<th>퇴근</th>
</tr>
</tfoot>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>
<!-- /Main content -->
</div>
<!-- /.content-wrapper -->
<footer class="main-footer"
th:insert="~{fragments/footer :: footerFragment}">
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<!-- DataTables & Plugins -->
<script th:src="@{/plugins/datatables/jquery.dataTables.min.js}"></script>
<script th:src="@{/plugins/datatables-bs4/js/dataTables.bootstrap4.min.js}"></script>
<script th:src="@{/plugins/datatables-responsive/js/dataTables.responsive.min.js}"></script>
<script th:src="@{/plugins/datatables-responsive/js/responsive.bootstrap4.min.js}"></script>
<script th:src="@{/plugins/datatables-buttons/js/dataTables.buttons.min.js}"></script>
<script th:src="@{/plugins/datatables-buttons/js/buttons.bootstrap4.min.js}"></script>
<script th:src="@{/plugins/jszip/jszip.min.js}"></script>
<script th:src="@{/plugins/pdfmake/pdfmake.min.js}"></script>
<script th:src="@{/plugins/pdfmake/vfs_fonts.js}"></script>
<script th:src="@{/plugins/datatables-buttons/js/buttons.html5.min.js}"></script>
<script th:src="@{/plugins/datatables-buttons/js/buttons.print.min.js}"></script>
<script th:src="@{/plugins/datatables-buttons/js/buttons.colVis.min.js}"></script>
<script>
$(function () {
$("#commuteTb").DataTable({
"responsive": true
, "lengthChange": false
, "autoWidth": false
, "pageLength": 20000,
"scrollY": "1600px", // 원하는 높이를 설정합니다.
"scrollCollapse": true, // 내용이 적을 경우 테이블 높이를 축소합니다.
"paging": false // 페이지네이션을 없애고 스크롤로 대체합니다.
, "buttons": ["copy", { extend: 'csv', charset: 'UTF-8', bom: true }
, "excel", "pdf", "print", "colvis"]
}).buttons().container().appendTo('#commuteTb_wrapper .col-md-6:eq(0)');
});
$( document ).ready( function() {
$('#searchDay, #searchMonth, #searchYear').on('change', function (){
$('#searchForm').submit();
});
} );
</script>
</body>
</html>