增加消息通知
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.pomelotea.hoperun.sign.api.model
|
||||
|
||||
data class ScNotifyRequest(
|
||||
val title: String,
|
||||
val desp: String?,
|
||||
val tags: String?,
|
||||
val short: String?
|
||||
)
|
||||
|
||||
data class ScNotifyResponse(
|
||||
val code: Int,
|
||||
val message: String,
|
||||
val data: String?
|
||||
)
|
||||
@@ -1,9 +1,15 @@
|
||||
package com.pomelotea.hoperun.sign.scheduler
|
||||
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.pomelotea.hoperun.sign.api.DakaResponse
|
||||
import com.pomelotea.hoperun.sign.api.model.ScNotifyResponse
|
||||
import com.pomelotea.hoperun.sign.common.*
|
||||
import com.pomelotea.hoperun.sign.config.HoperunUserConfig
|
||||
import com.pomelotea.hoperun.sign.config.UserConfig
|
||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.time.LocalDateTime
|
||||
@@ -45,6 +51,34 @@ class AutoDakaScheduler {
|
||||
if (daka == null) {
|
||||
daka = generateDakaInfo(v, dakaDate)
|
||||
dakaQueue.add(daka)
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "添加打卡任务:${v.username}, $daka",
|
||||
"desp" to "添加打卡任务:${v.username}, $daka"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
val resp = JSONObject.parseObject(result, ScNotifyResponse::class.java)
|
||||
if (resp.code != 0) {
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "添加打卡任务失败:${v.username}, $daka",
|
||||
"desp" to "添加打卡任务失败:${v.username}, $daka"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
logger.info(result)
|
||||
}
|
||||
logger.info("添加打卡任务: ${v.username}, $daka")
|
||||
}
|
||||
}
|
||||
@@ -96,7 +130,33 @@ class AutoDakaScheduler {
|
||||
beginTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.beginTime)
|
||||
if (resp.result != "success") {
|
||||
logger.error("打上班卡失败")
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "打上班卡失败:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}",
|
||||
"desp" to "打上班卡失败:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
logger.info(result)
|
||||
} else {
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "打上班卡成功:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}",
|
||||
"desp" to "打上班卡成功:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
logger.info(result)
|
||||
logger.info("打上班卡成功")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -116,7 +176,33 @@ class AutoDakaScheduler {
|
||||
val resp: DakaResponse = endTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.endTime)
|
||||
if (resp.result != "success") {
|
||||
logger.error("打下班卡失败")
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "打下班卡失败:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}",
|
||||
"desp" to "打下班卡失败:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
logger.info(result)
|
||||
} else {
|
||||
val notifyRequest = Request.Builder()
|
||||
.url("https://7248.push.ft07.com/send/sctp7248ta-yehg0lpo6cr9xl6ikqwbpn4l.send")
|
||||
.post(
|
||||
JSON.toJSONString(
|
||||
mapOf<String, String>(
|
||||
"title" to "打下班卡成功:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}",
|
||||
"desp" to "打下班卡成功:${daka.employeeNo}:DATE:${daka.dakaDate}:TIME:${daka.beginTime}"
|
||||
)
|
||||
).toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
|
||||
)
|
||||
.build()
|
||||
val result: String? = client.newCall(notifyRequest).execute().body?.string()
|
||||
logger.info(result)
|
||||
logger.info("打下班卡成功")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
Reference in New Issue
Block a user