🆗 兼容yxl项目
🆗 兼容多次不打卡的清空,默认取最近一次打卡的信息
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -29,3 +29,7 @@ logs
|
||||
**/target
|
||||
**/logs
|
||||
*.sh
|
||||
|
||||
.idea
|
||||
|
||||
|
||||
|
||||
@@ -37,10 +37,21 @@ class HoperunSignController {
|
||||
|
||||
init {
|
||||
AutoDakaScheduler()
|
||||
val yxl = UserConfig(
|
||||
project_id = "U2103S000112",
|
||||
projectcode = "U2103S000112",
|
||||
projectname = "JRKF-浙江网商-技术服务外包",
|
||||
device = "Android 12;Redmi;M2007J3SC;deviceId:OAIDe7fa6084205e9a22d8f6f71bc91893ff;deviceName:Android"
|
||||
)
|
||||
userConfigMap["16638"] = yxl
|
||||
}
|
||||
|
||||
@GetMapping("/username/{employeeNo}/{jsessionId}/{checked}")
|
||||
fun getUsername(@PathVariable employeeNo: String, @PathVariable jsessionId: String, @PathVariable checked: Boolean): WebResult<LoginResponse?> {
|
||||
fun getUsername(
|
||||
@PathVariable employeeNo: String,
|
||||
@PathVariable jsessionId: String,
|
||||
@PathVariable checked: Boolean
|
||||
): WebResult<LoginResponse?> {
|
||||
getJsessionIdAutoLogin(employeeNo, jsessionId)
|
||||
val userConfig = getUserConfig(employeeNo) ?: return WebResult.getFailed("登陆失败")
|
||||
userConfig.autoDaka = checked
|
||||
@@ -145,7 +156,8 @@ class HoperunSignController {
|
||||
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 }
|
||||
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
|
||||
@@ -183,7 +195,10 @@ class HoperunSignController {
|
||||
.url("http://pom.hoperun.com:8187/attm/calendar/monthAtt?staff_code=${padEmployeeNumber(employeeNo)}&yearmonth=${getNowDateyyyy_MM()}-01")
|
||||
.get()
|
||||
.addHeader("Cookie", "JSESSIONID=$jsessionId")
|
||||
.addHeader("User-Agent", "Qing/0.9.113;iOS 16.3.1;Apple;iPhone13,2;deviceId:a8baf66f-fdeb-4f4d-b1e5-9fafcd5045b6;deviceName:iOS;clientId:10200;os:iOS 16.3.1;brand:Apple;model:iPhone13,2;lang:zh-CN;fontNum:0;fontScale:1.0;ver:10.7.14;Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148")
|
||||
.addHeader(
|
||||
"User-Agent",
|
||||
"Qing/0.9.113;iOS 16.3.1;Apple;iPhone13,2;deviceId:a8baf66f-fdeb-4f4d-b1e5-9fafcd5045b6;deviceName:iOS;clientId:10200;os:iOS 16.3.1;brand:Apple;model:iPhone13,2;lang:zh-CN;fontNum:0;fontScale:1.0;ver:10.7.14;Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
||||
)
|
||||
.addHeader("accept", "*/*")
|
||||
.addHeader("Origin", "http://pom.hoperun.com:8187")
|
||||
.addHeader("Referer", "http://pom.hoperun.com:8187/attm/attence/getInfo")
|
||||
@@ -192,27 +207,34 @@ class HoperunSignController {
|
||||
val attendancesDetailResp = client.newCall(attendancesDetailRequest).execute()
|
||||
val bodyString = attendancesDetailResp.body?.string()
|
||||
val attendancesDetailResponse = JSONObject.parseObject(bodyString, AttendancesDetailResponse::class.java)
|
||||
val dataList: List<AttendancesDetail> = JSONObject.parseObject(attendancesDetailResponse.data, object : TypeReference<List<AttendancesDetail>>() {})
|
||||
val lastDakaInfo: AttendancesDetail = dataList
|
||||
.filter { it.project_id != "-1" }
|
||||
.findLast { it.yearmonth == "2023-03-21" }!!
|
||||
val dataList: List<AttendancesDetail> =
|
||||
JSONObject.parseObject(attendancesDetailResponse.data, object : TypeReference<List<AttendancesDetail>>() {})
|
||||
val userConfig: UserConfig = userConfigMap.get(employeeNo) ?: UserConfig()
|
||||
if (dataList.isNotEmpty()) {
|
||||
val lastDakaInfo: AttendancesDetail = dataList.sortedByDescending { it.yearmonth }
|
||||
.filter { it.project_id != "-1" }
|
||||
.filter { it.begin_time != null }
|
||||
.firstOrNull()!!
|
||||
if (userConfig.projectcode == null) {
|
||||
userConfig.projectcode = lastDakaInfo.projectcode
|
||||
}
|
||||
if (userConfig.projectname == null) {
|
||||
userConfig.projectname = lastDakaInfo.projectname
|
||||
}
|
||||
if (userConfig.project_id == null) {
|
||||
userConfig.project_id = lastDakaInfo.project_id
|
||||
}
|
||||
}
|
||||
|
||||
if (userConfig.projectcode == null) {
|
||||
userConfig.projectcode = lastDakaInfo.projectcode
|
||||
}
|
||||
if (userConfig.projectname == null) {
|
||||
userConfig.projectname = lastDakaInfo.projectname
|
||||
}
|
||||
if (userConfig.project_id == null) {
|
||||
userConfig.project_id = lastDakaInfo.project_id
|
||||
}
|
||||
// username 要从主页的html元素中获取
|
||||
val indexRequest = Request.Builder()
|
||||
.url("http://pom.hoperun.com:8187/attm/attence/getInfo")
|
||||
.get()
|
||||
.addHeader("Cookie", "JSESSIONID=$jsessionId")
|
||||
.addHeader("User-Agent", "Qing/0.9.113;iOS 16.3.1;Apple;iPhone13,2;deviceId:a8baf66f-fdeb-4f4d-b1e5-9fafcd5045b6;deviceName:iOS;clientId:10200;os:iOS 16.3.1;brand:Apple;model:iPhone13,2;lang:zh-CN;fontNum:0;fontScale:1.0;ver:10.7.14;Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148")
|
||||
.addHeader(
|
||||
"User-Agent",
|
||||
"Qing/0.9.113;iOS 16.3.1;Apple;iPhone13,2;deviceId:a8baf66f-fdeb-4f4d-b1e5-9fafcd5045b6;deviceName:iOS;clientId:10200;os:iOS 16.3.1;brand:Apple;model:iPhone13,2;lang:zh-CN;fontNum:0;fontScale:1.0;ver:10.7.14;Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
|
||||
)
|
||||
.addHeader("accept", "*/*")
|
||||
.addHeader("Origin", "http://pom.hoperun.com:8187")
|
||||
.addHeader("Referer", "http://pom.hoperun.com:8187/attm/attence/getInfo")
|
||||
@@ -221,7 +243,9 @@ class HoperunSignController {
|
||||
val indexResp = client.newCall(indexRequest).execute()
|
||||
val indexHtml = indexResp.body?.string()
|
||||
val doc = Jsoup.parse(indexHtml!!)
|
||||
userConfig.username = doc.select("#attendance-detail-content > div.container.none-padding > div > div:nth-child(1) > div:nth-child(4)").text()
|
||||
userConfig.username =
|
||||
doc.select("#attendance-detail-content > div.container.none-padding > div > div:nth-child(1) > div:nth-child(4)")
|
||||
.text()
|
||||
userConfig.employeeNo = employeeNo
|
||||
HoperunUserConfig.addUserConfig(
|
||||
employeeNo, userConfig
|
||||
|
||||
@@ -56,6 +56,13 @@ fun getNowDateyyyy_MM_dd(): String {
|
||||
return "${localDate.year}-${pad(localDate.monthValue)}-${pad(localDate.dayOfMonth)}"
|
||||
}
|
||||
|
||||
fun getYesterdayyyyy_MM_dd(): String {
|
||||
val localDate = LocalDate.now()
|
||||
localDate.plusDays(-1)
|
||||
return "${localDate.year}-${pad(localDate.monthValue)}-${pad(localDate.dayOfMonth)}"
|
||||
}
|
||||
|
||||
|
||||
private fun pad(num: Int): String {
|
||||
return if (num < 10) "0$num" else "$num"
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class AutoDakaScheduler {
|
||||
}
|
||||
bw.write("${v.username},${daka.toCsv()}")
|
||||
bw.newLine()
|
||||
bw.flush()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,13 +61,19 @@ class AutoDakaScheduler {
|
||||
dakaQueue.forEach {
|
||||
val beginDate = LocalDateTime.parse(it.dakaDate + "T" + it.beginTime + ":" + randowSecond(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||
val endDate = LocalDateTime.parse(it.dakaDate + "T" + it.endTime + ":" + randowSecond(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||
val beginSeconds = beginDate.toEpochSecond(DEFAULT_ZONE)
|
||||
val endSeconds = endDate.toEpochSecond(DEFAULT_ZONE)
|
||||
if (beginSeconds > System.currentTimeMillis() / 1000) {
|
||||
schedulerThreadPool.schedule({beginDaka(it)}, beginDate.toEpochSecond(DEFAULT_ZONE), TimeUnit.SECONDS)
|
||||
val beginSeconds = beginDate.toEpochSecond(DEFAULT_ZONE) - (System.currentTimeMillis() / 1000)
|
||||
val endSeconds = endDate.toEpochSecond(DEFAULT_ZONE) - (System.currentTimeMillis() / 1000)
|
||||
if (beginSeconds > 0) {
|
||||
logBw.write("[ADD-SCHEDULE]BEGIN:${it.employeeNo}:DATE:${it.dakaDate}TIME:${it.beginTime}")
|
||||
logBw.newLine()
|
||||
logBw.flush()
|
||||
schedulerThreadPool.schedule({beginDaka(it)}, beginSeconds, TimeUnit.SECONDS)
|
||||
}
|
||||
if (endSeconds > System.currentTimeMillis() / 1000) {
|
||||
schedulerThreadPool.schedule({endDaka(it)}, endDate.toEpochSecond(DEFAULT_ZONE), TimeUnit.SECONDS)
|
||||
if (endSeconds > 0) {
|
||||
logBw.write("[ADD-SCHEDULE]END:${it.employeeNo}:DATE:${it.dakaDate}TIME:${it.endTime}")
|
||||
logBw.newLine()
|
||||
logBw.flush()
|
||||
schedulerThreadPool.schedule({endDaka(it)}, endSeconds, TimeUnit.SECONDS)
|
||||
}
|
||||
// schedulerThreadPool.schedule({beginDaka(it)}, 5, TimeUnit.SECONDS)
|
||||
// schedulerThreadPool.schedule({ endDaka(it) }, 5, TimeUnit.SECONDS)
|
||||
@@ -77,14 +84,18 @@ class AutoDakaScheduler {
|
||||
|
||||
private fun beginDaka(daka: Daka) {
|
||||
// println("begin:${daka.toCsv()}")
|
||||
logBw.write("execute begin sign: ${daka.toCsv()}")
|
||||
logBw.write("[EXECUTE]BEGIN:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}")
|
||||
logBw.newLine()
|
||||
logBw.flush()
|
||||
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)
|
||||
logBw.write("[EXECUTE]END:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.endTime}")
|
||||
logBw.newLine()
|
||||
logBw.flush()
|
||||
endTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.endTime)
|
||||
}
|
||||
|
||||
private fun generateDakaInfo(userConfig: UserConfig, dakaDate: String): Daka {
|
||||
|
||||
@@ -17,6 +17,9 @@ document.querySelector('#logout').addEventListener("click", () => {
|
||||
$('#username').text("未登陆");
|
||||
$("#logout-div").hide();
|
||||
$("#login-span").show();
|
||||
$("#login").css("display", "block");
|
||||
$("#jsessionId").css("display", "block");
|
||||
$("#employee-number").css("display", "block");
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -1128,12 +1128,11 @@ body > div > div.userinfo_dialog > div > div > div input {
|
||||
font-family: 'Audiowide';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local("Audiowide"), local("Audiowide-Regular"), url(http://themes.googleusercontent.com/static/fonts/audiowide/v2/8XtYtNKEyyZh481XVWfVOj8E0i7KZn-EPnyo3HZu7kw.woff) format("woff");
|
||||
src: local("Audiowide"), local("Audiowide-Regular"), url(https://themes.googleusercontent.com/static/fonts/audiowide/v2/8XtYtNKEyyZh481XVWfVOj8E0i7KZn-EPnyo3HZu7kw.woff) format("woff");
|
||||
}
|
||||
body {
|
||||
font-size: 62.5%;
|
||||
background-color: #fff;
|
||||
margin: 10px;
|
||||
border: 1px solid #333;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user