增加消息通知
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM openjdk:8-jre
|
||||
FROM openjdk:8-alpine
|
||||
LABEL name="hoperun-custom-sign"
|
||||
MAINTAINER li@2ha.me
|
||||
WORKDIR /
|
||||
|
||||
61
pom.xml
61
pom.xml
@@ -21,7 +21,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<kotlin.code.style>official</kotlin.code.style>
|
||||
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||
<kotlin.version>2.0.20</kotlin.version>
|
||||
<kotlin.version>2.2.0</kotlin.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@@ -44,26 +44,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
@@ -89,6 +69,34 @@
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>testCompile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
@@ -123,6 +131,17 @@
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.15.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
13
settings.xml
13
settings.xml
@@ -131,6 +131,11 @@ under the License.
|
||||
<passphrase>optional; leave empty if not used.</passphrase>
|
||||
</server>
|
||||
-->
|
||||
<server>
|
||||
<id>mirror-all</id>
|
||||
<username>jimlee</username>
|
||||
<password>wysnih-dybbyQ-0rigti</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>2ha</id>
|
||||
<username>jimlee</username>
|
||||
@@ -176,7 +181,7 @@ under the License.
|
||||
<id>mirror-all</id>
|
||||
<mirrorOf>*</mirrorOf>
|
||||
<name>2ha mirror</name>
|
||||
<url>https://2ha.me:18082/repository/maven-public/</url>
|
||||
<url>https://maven.2ha.me/repository/maven-public/</url>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
|
||||
@@ -272,7 +277,7 @@ under the License.
|
||||
<repository>
|
||||
<id>2ha</id>
|
||||
<name>2ha.me nexus private</name>
|
||||
<url>https://2ha.me:18082/repository/maven-public/</url>
|
||||
<url>https://maven.2ha.me/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
@@ -284,12 +289,12 @@ under the License.
|
||||
<repository>
|
||||
<id>maven-releases</id>
|
||||
<name>Nexus Release Repository</name>
|
||||
<url>https://2ha.me:18082/repository/private/</url>
|
||||
<url>https://maven.2ha.me/repository/private/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven-snapshots</id>
|
||||
<name>Nexus Snapshot Repository</name>
|
||||
<url>https://2ha.me:18082/repository/private/</url>
|
||||
<url>https://maven.2ha.me/repository/private/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
|
||||
@@ -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