🆗 兼容yxl项目

🆗 兼容多次不打卡的清空,默认取最近一次打卡的信息
This commit is contained in:
jimlee
2023-03-22 23:46:42 +08:00
parent 8e9842b4f9
commit dae6cb5522
6 changed files with 77 additions and 29 deletions

View File

@@ -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