dev-2025 #1
@@ -12,6 +12,7 @@ import com.pomelotea.hoperun.sign.config.HoperunUserConfig.getUserConfig
|
||||
import com.pomelotea.hoperun.sign.config.HoperunUserConfig.userConfigMap
|
||||
import com.pomelotea.hoperun.sign.config.UserConfig
|
||||
import com.pomelotea.hoperun.sign.scheduler.AutoDakaScheduler
|
||||
import com.pomelotea.hoperun.sign.scheduler.AutoDakaScheduler.Companion.dakaQueue
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.Request
|
||||
@@ -143,6 +144,12 @@ class HoperunSignController {
|
||||
queryMonthAttData(employeeNo, jsessionId, getLastDateyyyy_MM() + "-01")
|
||||
val lastMonthAttLogs = lastMonthAttList.sortedByDescending { it.yearmonth }.filter { it.dateType == "1" }
|
||||
monthAttResult.addAll(lastMonthAttLogs)
|
||||
val monthAttLog = monthAttResult.find { it.yearmonth == getNowDateyyyy_MM_dd() }
|
||||
val autoDaka = dakaQueue.filter { it.dakaDate == getNowDateyyyy_MM_dd() }.findLast { it.employeeNo == employeeNo }
|
||||
if (autoDaka != null && monthAttLog != null) {
|
||||
monthAttLog.autoDakaBeginTime = autoDaka.beginTime
|
||||
monthAttLog.autoDakaEndTime = autoDaka.endTime
|
||||
}
|
||||
return monthAttResult
|
||||
}
|
||||
|
||||
@@ -278,7 +285,9 @@ data class MonthAttLog(
|
||||
var project_id: String? = null,
|
||||
var projectcode: String? = null,
|
||||
var staff_code: String? = null,
|
||||
var yearmonth: String? = null
|
||||
var yearmonth: String? = null,
|
||||
var autoDakaBeginTime: String? = null,
|
||||
var autoDakaEndTime: String? = null,
|
||||
)
|
||||
|
||||
data class HoperunDakaRequest(
|
||||
|
||||
@@ -25,6 +25,10 @@ class AutoDakaScheduler {
|
||||
val outFile = File("./daka.log")
|
||||
val bw: BufferedWriter = BufferedWriter(OutputStreamWriter(outFile.outputStream()))
|
||||
|
||||
val logFile = File("./scheduler.log")
|
||||
val logBw: BufferedWriter = BufferedWriter(OutputStreamWriter(logFile.outputStream()))
|
||||
|
||||
|
||||
val timeThreadPool: ScheduledExecutorService = Executors.newScheduledThreadPool(1)
|
||||
val schedulerThreadPool: ScheduledExecutorService = Executors.newScheduledThreadPool(10)
|
||||
|
||||
@@ -39,18 +43,16 @@ class AutoDakaScheduler {
|
||||
fun addAutoDakaScheduled(dakaDate: String = getNowDateyyyy_MM_dd()) {
|
||||
// 调休的工作日
|
||||
if (isNeedDaka(dakaDate)) {
|
||||
bw.use {
|
||||
HoperunUserConfig.userConfigMap.forEach { (k, v) ->
|
||||
if (v.autoDaka) {
|
||||
// 没有当日的打卡信息才插入
|
||||
var daka = dakaQueue.find { it.dakaDate == dakaDate && it.employeeNo == v.employeeNo }
|
||||
if (daka == null) {
|
||||
daka = generateDakaInfo(v, dakaDate)
|
||||
dakaQueue.add(daka)
|
||||
}
|
||||
bw.write("${v.username},${daka.toCsv()}")
|
||||
bw.newLine()
|
||||
HoperunUserConfig.userConfigMap.forEach { (_, v) ->
|
||||
if (v.autoDaka) {
|
||||
// 没有当日的打卡信息才插入
|
||||
var daka = dakaQueue.find { it.dakaDate == dakaDate && it.employeeNo == v.employeeNo }
|
||||
if (daka == null) {
|
||||
daka = generateDakaInfo(v, dakaDate)
|
||||
dakaQueue.add(daka)
|
||||
}
|
||||
bw.write("${v.username},${daka.toCsv()}")
|
||||
bw.newLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,11 +77,13 @@ class AutoDakaScheduler {
|
||||
|
||||
private fun beginDaka(daka: Daka) {
|
||||
// println("begin:${daka.toCsv()}")
|
||||
logBw.write("execute begin sign: ${daka.toCsv()}")
|
||||
beginTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.beginTime)
|
||||
}
|
||||
|
||||
private fun endDaka(daka: Daka) {
|
||||
// println("end:${daka.toCsv()}")
|
||||
logBw.write("execute end sign: ${daka.toCsv()}")
|
||||
endTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.beginTime)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ if ($('#login-span').css('display') !== 'none') {
|
||||
|
||||
let jsessonIdInput = document.querySelector('#jsessionId');
|
||||
let autoDaka = document.querySelector("#toggle--switch")
|
||||
autoDaka.checked = window.localStorage.getItem("autodaka")
|
||||
|
||||
document.querySelector('#login').addEventListener("click", () => {
|
||||
window.localStorage.setItem("employeeNo", employeeNumberInput.value);
|
||||
@@ -77,7 +78,7 @@ function loginAndLoadRecord() {
|
||||
cocoMessage.error("登陆失败!" + result.message, 3000);
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
error: function () {
|
||||
cocoMessage.error("请求失败!", 3000);
|
||||
}
|
||||
})
|
||||
@@ -109,6 +110,8 @@ function loadDakaList() {
|
||||
'<div class="job-detail-buttons">' +
|
||||
'<button class="search-buttons detail-button">' + (signlog.begin_time == null ? "未打卡" : signlog.begin_time.substr(11, 5)) + '</button>' +
|
||||
'<button class="search-buttons detail-button">' + (signlog.end_time == null ? "未打卡" : signlog.end_time.substr(11, 5)) + '</button>' +
|
||||
(signlog.autoDakaBeginTime == null ? "" : '<br><button class="search-buttons detail-button">定时上班卡时间: ' + signlog.autoDakaBeginTime + '</button>') +
|
||||
(signlog.autoDakaEndTime == null ? "" : '<button class="search-buttons detail-button">定时下班卡时间: ' + signlog.autoDakaEndTime + '</button>') +
|
||||
(signlog.end_time != null && signlog.end_time.substr(11, 5) > "20:30" ? '<button class="search-buttons detail-button">餐补</button>' : '') +
|
||||
'</div>' +
|
||||
(index <= 3 ? '<div class="job-card-buttons">' +
|
||||
@@ -130,7 +133,7 @@ function loadDakaList() {
|
||||
}
|
||||
closeLoading()
|
||||
},
|
||||
error: function (e) {
|
||||
error: function () {
|
||||
cocoMessage.error("请求失败!", 3000);
|
||||
closeLoading()
|
||||
}
|
||||
@@ -205,7 +208,8 @@ function bindSaveDakaTime() {
|
||||
|
||||
function bindAutoDakaToggle() {
|
||||
document.querySelectorAll("#toggle--switch").forEach((dakaButton) => {
|
||||
$(dakaButton).off('change').on('change', function (e) {
|
||||
$(dakaButton).off('change').on('change', function () {
|
||||
window.localStorage.setItem("autodaka", this.checked);
|
||||
$.ajax({
|
||||
method: "get",
|
||||
url: "/api/daka/auto/" + window.localStorage.getItem("employeeNo") + "/" + autoDaka.checked,
|
||||
@@ -214,7 +218,7 @@ function bindAutoDakaToggle() {
|
||||
cocoMessage.error("登陆失败!" + result.message, 3000);
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
error: function () {
|
||||
cocoMessage.error("请求失败!", 3000);
|
||||
}
|
||||
})
|
||||
@@ -260,7 +264,7 @@ function saveDakaTime(signDate, beginTime, endTime) {
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
error: function () {
|
||||
cocoMessage.error("请求失败!", 3000);
|
||||
}
|
||||
});
|
||||
@@ -290,7 +294,7 @@ function saveDakaTime(signDate, beginTime, endTime) {
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
error: function () {
|
||||
cocoMessage.error("请求失败!", 3000);
|
||||
}
|
||||
});
|
||||
@@ -308,7 +312,7 @@ function randomBeginTime() {
|
||||
function randomEndTime() {
|
||||
let hourArray = [18, 19, 20, 21, 22, 23, 20, 21, 22, 20, 20, 21];
|
||||
let randomHour = hourArray[Math.round(Math.random() * 9)];
|
||||
let randomMinute = 0;
|
||||
let randomMinute;
|
||||
if (randomHour === 18) {
|
||||
randomMinute = Math.round(Math.random() * 30) + 29;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user