增加消息通知
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM openjdk:8-jre
|
FROM openjdk:8-alpine
|
||||||
LABEL name="hoperun-custom-sign"
|
LABEL name="hoperun-custom-sign"
|
||||||
MAINTAINER li@2ha.me
|
MAINTAINER li@2ha.me
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|||||||
61
pom.xml
61
pom.xml
@@ -21,7 +21,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.code.style>official</kotlin.code.style>
|
<kotlin.code.style>official</kotlin.code.style>
|
||||||
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
|
||||||
<kotlin.version>2.0.20</kotlin.version>
|
<kotlin.version>2.2.0</kotlin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -44,26 +44,6 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
@@ -89,6 +69,34 @@
|
|||||||
<jvmTarget>1.8</jvmTarget>
|
<jvmTarget>1.8</jvmTarget>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@@ -123,6 +131,17 @@
|
|||||||
<artifactId>jsoup</artifactId>
|
<artifactId>jsoup</artifactId>
|
||||||
<version>1.15.3</version>
|
<version>1.15.3</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
|||||||
13
settings.xml
13
settings.xml
@@ -131,6 +131,11 @@ under the License.
|
|||||||
<passphrase>optional; leave empty if not used.</passphrase>
|
<passphrase>optional; leave empty if not used.</passphrase>
|
||||||
</server>
|
</server>
|
||||||
-->
|
-->
|
||||||
|
<server>
|
||||||
|
<id>mirror-all</id>
|
||||||
|
<username>jimlee</username>
|
||||||
|
<password>wysnih-dybbyQ-0rigti</password>
|
||||||
|
</server>
|
||||||
<server>
|
<server>
|
||||||
<id>2ha</id>
|
<id>2ha</id>
|
||||||
<username>jimlee</username>
|
<username>jimlee</username>
|
||||||
@@ -176,7 +181,7 @@ under the License.
|
|||||||
<id>mirror-all</id>
|
<id>mirror-all</id>
|
||||||
<mirrorOf>*</mirrorOf>
|
<mirrorOf>*</mirrorOf>
|
||||||
<name>2ha mirror</name>
|
<name>2ha mirror</name>
|
||||||
<url>https://2ha.me:18082/repository/maven-public/</url>
|
<url>https://maven.2ha.me/repository/maven-public/</url>
|
||||||
</mirror>
|
</mirror>
|
||||||
</mirrors>
|
</mirrors>
|
||||||
|
|
||||||
@@ -272,7 +277,7 @@ under the License.
|
|||||||
<repository>
|
<repository>
|
||||||
<id>2ha</id>
|
<id>2ha</id>
|
||||||
<name>2ha.me nexus private</name>
|
<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>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
@@ -284,12 +289,12 @@ under the License.
|
|||||||
<repository>
|
<repository>
|
||||||
<id>maven-releases</id>
|
<id>maven-releases</id>
|
||||||
<name>Nexus Release Repository</name>
|
<name>Nexus Release Repository</name>
|
||||||
<url>https://2ha.me:18082/repository/private/</url>
|
<url>https://maven.2ha.me/repository/private/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>maven-snapshots</id>
|
<id>maven-snapshots</id>
|
||||||
<name>Nexus Snapshot Repository</name>
|
<name>Nexus Snapshot Repository</name>
|
||||||
<url>https://2ha.me:18082/repository/private/</url>
|
<url>https://maven.2ha.me/repository/private/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
</profile>
|
</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
|
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.DakaResponse
|
||||||
|
import com.pomelotea.hoperun.sign.api.model.ScNotifyResponse
|
||||||
import com.pomelotea.hoperun.sign.common.*
|
import com.pomelotea.hoperun.sign.common.*
|
||||||
import com.pomelotea.hoperun.sign.config.HoperunUserConfig
|
import com.pomelotea.hoperun.sign.config.HoperunUserConfig
|
||||||
import com.pomelotea.hoperun.sign.config.UserConfig
|
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.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@@ -45,6 +51,34 @@ class AutoDakaScheduler {
|
|||||||
if (daka == null) {
|
if (daka == null) {
|
||||||
daka = generateDakaInfo(v, dakaDate)
|
daka = generateDakaInfo(v, dakaDate)
|
||||||
dakaQueue.add(daka)
|
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")
|
logger.info("添加打卡任务: ${v.username}, $daka")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +130,33 @@ class AutoDakaScheduler {
|
|||||||
beginTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.beginTime)
|
beginTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.beginTime)
|
||||||
if (resp.result != "success") {
|
if (resp.result != "success") {
|
||||||
logger.error("打上班卡失败")
|
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 {
|
} 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("打上班卡成功")
|
logger.info("打上班卡成功")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -116,7 +176,33 @@ class AutoDakaScheduler {
|
|||||||
val resp: DakaResponse = endTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.endTime)
|
val resp: DakaResponse = endTime(employeeNo = daka.employeeNo, date = daka.dakaDate, time = daka.endTime)
|
||||||
if (resp.result != "success") {
|
if (resp.result != "success") {
|
||||||
logger.error("打下班卡失败")
|
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 {
|
} 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("打下班卡成功")
|
logger.info("打下班卡成功")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user