dashboard
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using FCOMMON;
|
using FCOMMON;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
@@ -38,6 +39,77 @@ namespace Project.Web.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public HttpResponseMessage GetHolydayRequestCount()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cn = DBM.getCn();
|
||||||
|
|
||||||
|
var sql = "select count(*) from EETGW_HolydayRequest" +
|
||||||
|
" where gcode = @gcode" +
|
||||||
|
" and conf = 0";
|
||||||
|
|
||||||
|
cn.Open();
|
||||||
|
|
||||||
|
var cmd = new System.Data.SqlClient.SqlCommand(sql, cn);
|
||||||
|
cmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = FCOMMON.info.Login.gcode;
|
||||||
|
var cnt1 = (int)cmd.ExecuteScalar();
|
||||||
|
cn.Dispose();
|
||||||
|
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
HOLY = cnt1,
|
||||||
|
Message = string.Empty,
|
||||||
|
};
|
||||||
|
return CreateJsonResponse(response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
HOLY = 0,
|
||||||
|
Message = ex.Message,
|
||||||
|
};
|
||||||
|
return CreateJsonResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public HttpResponseMessage GetPurchaseWaitCount()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FCOMMON.DBM.GetPurchaseWaitCount(FCOMMON.info.Login.gcode, out int cnt1, out int cnt2);
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
NR = cnt1,
|
||||||
|
CR = cnt2,
|
||||||
|
Message = string.Empty,
|
||||||
|
};
|
||||||
|
return CreateJsonResponse(response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
NR = 0,
|
||||||
|
CR = 0,
|
||||||
|
Message = ex.Message,
|
||||||
|
};
|
||||||
|
return CreateJsonResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public HttpResponseMessage GetUserGroups()
|
public HttpResponseMessage GetUserGroups()
|
||||||
@@ -131,5 +203,21 @@ namespace Project.Web.Controllers
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HttpResponseMessage CreateJsonResponse(object data)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(data, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HttpResponseMessage()
|
||||||
|
{
|
||||||
|
Content = new StringContent(
|
||||||
|
json,
|
||||||
|
System.Text.Encoding.UTF8,
|
||||||
|
"application/json")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ namespace Project.Web.Controllers
|
|||||||
return CreateJsonResponse(response);
|
return CreateJsonResponse(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public HttpResponseMessage CheckLoginStatus()
|
public HttpResponseMessage CheckLoginStatus()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -105,7 +105,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 통계 카드 -->
|
<!-- 통계 카드 -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8">
|
||||||
|
|
||||||
<!-- 출근 카드 -->
|
<!-- 출근 카드 -->
|
||||||
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up">
|
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
@@ -151,12 +152,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 구매요청 카드 -->
|
<!-- 구매요청 카드(NR) -->
|
||||||
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up">
|
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<p class="text-white/70 text-sm font-medium">구매요청</p>
|
<p class="text-white/70 text-sm font-medium">구매요청(NR)</p>
|
||||||
<p class="text-3xl font-bold text-white" id="purchaseCount">0</p>
|
<p class="text-3xl font-bold text-white" id="purchaseCountNR">0</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-12 h-12 bg-danger-500/20 rounded-full flex items-center justify-center">
|
<div class="w-12 h-12 bg-danger-500/20 rounded-full flex items-center justify-center">
|
||||||
<svg class="w-6 h-6 text-danger-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-6 h-6 text-danger-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
@@ -165,6 +166,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 구매요청 카드(CR) -->
|
||||||
|
<div class="glass-effect rounded-2xl p-6 card-hover animate-slide-up">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<p class="text-white/70 text-sm font-medium">구매요청(CR)</p>
|
||||||
|
<p class="text-3xl font-bold text-white" id="purchaseCountCR">0</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-12 h-12 bg-danger-500/20 rounded-full flex items-center justify-center">
|
||||||
|
<svg class="w-6 h-6 text-danger-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"></path>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 휴가자 현황 테이블 -->
|
<!-- 휴가자 현황 테이블 -->
|
||||||
@@ -270,6 +288,52 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 구매요청 데이터 Ajax 업데이트
|
||||||
|
function updatePurchaseCount() {
|
||||||
|
showLoading();
|
||||||
|
fetch('http://127.0.0.1:9000/DashBoard/GetPurchaseWaitCount')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data) {
|
||||||
|
// NR 구매요청 카운트 업데이트
|
||||||
|
if (data.NR !== undefined) {
|
||||||
|
animateNumberChange('purchaseCountNR', data.NR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CR 구매요청 카운트 업데이트
|
||||||
|
if (data.CR !== undefined) {
|
||||||
|
animateNumberChange('purchaseCountCR', data.CR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('구매요청 데이터 업데이트 중 오류 발생:', error);
|
||||||
|
hideLoading();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 휴가요청 데이터 Ajax 업데이트
|
||||||
|
function updateHolydayRequestCount() {
|
||||||
|
showLoading();
|
||||||
|
fetch('http://127.0.0.1:9000/DashBoard/GetHolydayRequestCount')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data) {
|
||||||
|
// NR 구매요청 카운트 업데이트
|
||||||
|
if (data.HOLY !== undefined) {
|
||||||
|
animateNumberChange('leaveRequestCount', data.HOLY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hideLoading();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('휴가요청 데이터 업데이트 중 오류 발생:', error);
|
||||||
|
hideLoading();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 숫자 애니메이션
|
// 숫자 애니메이션
|
||||||
function animateNumberChange(elementId, newValue) {
|
function animateNumberChange(elementId, newValue) {
|
||||||
const element = document.getElementById(elementId);
|
const element = document.getElementById(elementId);
|
||||||
@@ -300,11 +364,14 @@
|
|||||||
// 페이지 로드 시 데이터 업데이트
|
// 페이지 로드 시 데이터 업데이트
|
||||||
updateLeaveCount();
|
updateLeaveCount();
|
||||||
updateHolidayList();
|
updateHolidayList();
|
||||||
|
updatePurchaseCount();
|
||||||
|
updateHolydayRequestCount();
|
||||||
// 30초마다 데이터 새로고침
|
// 30초마다 데이터 새로고침
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
updateLeaveCount();
|
updateLeaveCount();
|
||||||
updateHolidayList();
|
updateHolidayList();
|
||||||
|
updatePurchaseCount();
|
||||||
|
updateHolydayRequestCount();
|
||||||
}, 30000);
|
}, 30000);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -19,6 +19,31 @@ namespace FCOMMON
|
|||||||
return cn;
|
return cn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void GetPurchaseWaitCount(string gcode,out int cnt1,out int cnt2)
|
||||||
|
{
|
||||||
|
cnt1 = 0;
|
||||||
|
cnt2 = 0;
|
||||||
|
var cn = getCn();
|
||||||
|
var sql1 = "select count(*) from Purchase where gcode = @gcode" +
|
||||||
|
" and state like '--%'" +
|
||||||
|
" and pdate >= @date";
|
||||||
|
|
||||||
|
var sql2 = "select count(*) from EETGW_PurchaseCR where gcode = @gcode" +
|
||||||
|
" and state like '--%'" +
|
||||||
|
" and pdate >= @date";
|
||||||
|
|
||||||
|
cn.Open();
|
||||||
|
|
||||||
|
var cmd = new System.Data.SqlClient.SqlCommand(sql1, cn);
|
||||||
|
cmd.Parameters.Add("gcode", SqlDbType.VarChar).Value = gcode;
|
||||||
|
cmd.Parameters.Add("date", SqlDbType.VarChar).Value = DateTime.Now.AddYears(-1).ToShortDateString();
|
||||||
|
cnt1 = (int)cmd.ExecuteScalar();
|
||||||
|
cmd.CommandText = sql2;
|
||||||
|
cnt2 = (int)cmd.ExecuteScalar();
|
||||||
|
cn.Dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static UserModel GetUserInfo(string uid)
|
public static UserModel GetUserInfo(string uid)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user