mirror of
https://github.com/abcv7/sfbx-cloud.git
synced 2026-08-16 11:47:00 +00:00
功能:在保险、规则、交易、积分和短信模块中实现初始功能和基础组件。
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>sfbx-cloud</artifactId>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<!--任务监听处理模块-->
|
||||
<artifactId>sfbx-task</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>sfbx-task</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
<modules>
|
||||
<module>task-job</module>
|
||||
<module>task-listener</module>
|
||||
</modules>
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
FROM openjdk:11-jdk
|
||||
LABEL maintainer="研究院研发组 <research@itcast.cn>"
|
||||
|
||||
# 时区修改为东八区
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR /task-job
|
||||
ARG PACKAGE_PATH=./target/task-job.jar
|
||||
ADD ${PACKAGE_PATH:-./} task-job.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENV JAVA_OPTS="\
|
||||
-server \
|
||||
-Xms256m \
|
||||
-Xmx512m \
|
||||
-XX:MetaspaceSize=256m \
|
||||
-XX:MaxMetaspaceSize=512m\
|
||||
-Dspring.profiles.active=test"
|
||||
ENTRYPOINT ["sh","-c","java -Djava.security.egd=file:/dev/./urandom -jar $JAVA_OPTS task-job.jar"]
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>sfbx-task</artifactId>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<!--计划任务处理-->
|
||||
<artifactId>task-job</artifactId>
|
||||
<name>task-job</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>file-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>sms-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>trade-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>framework-xxl-job</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>points-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>insurance-interface</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.yaml</include>
|
||||
<include>**/*.txt</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>task-job</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.itheima.sfbx.task;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 定时任务启动类
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.itheima.sfbx")
|
||||
public class TaskJobStart {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TaskJobStart.class, args);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.itheima.sfbx.task.job;
|
||||
|
||||
import com.itheima.sfbx.file.feign.FileBusinessFeign;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @ClassName ClearFileHandlerJob.java
|
||||
* @Description 清理垃圾文件
|
||||
*/
|
||||
@Component
|
||||
public class ClearFileHandlerJob {
|
||||
|
||||
@Autowired
|
||||
FileBusinessFeign fileBusinessFeign;
|
||||
|
||||
@XxlJob(value = "clear-file")
|
||||
public ReturnT<String> execute(String param) {
|
||||
Boolean responseWrap = fileBusinessFeign.clearFile();
|
||||
if (responseWrap){
|
||||
ReturnT.SUCCESS.setMsg("计划任务:清理垃圾文件-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("计划任务:清理垃圾文件-失败");
|
||||
return ReturnT.FAIL;
|
||||
|
||||
}
|
||||
}
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
package com.itheima.sfbx.task.job;
|
||||
|
||||
import com.itheima.sfbx.framework.commons.utils.EmptyUtil;
|
||||
import com.itheima.sfbx.points.feign.BusinessReportFeign;
|
||||
import com.itheima.sfbx.points.feign.CustomerReportFeign;
|
||||
import com.itheima.sfbx.points.feign.SaleReportFeign;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @ClassName ReportHandlerJob.java
|
||||
* @Description 报表分析处理
|
||||
*/
|
||||
@Component
|
||||
public class ReportHandlerJob {
|
||||
|
||||
@Autowired
|
||||
BusinessReportFeign businessReportFeign;
|
||||
|
||||
@Autowired
|
||||
CustomerReportFeign customerReportFeign;
|
||||
|
||||
@Autowired
|
||||
SaleReportFeign saleReportFeign;
|
||||
|
||||
/**
|
||||
* 补全数据
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "complement")
|
||||
public ReturnT<String> complement(String param){
|
||||
businessReportFeign.doInsureDpvJob(param);
|
||||
businessReportFeign.doInsureDuvJob(param);
|
||||
businessReportFeign.categoryDpvJob(param);
|
||||
businessReportFeign.doInsureGenderDuvJob(param);
|
||||
businessReportFeign.doInsureCityDuvJob(param);
|
||||
businessReportFeign.doInsureConversionDpvJob(param);
|
||||
businessReportFeign.doInsureFailDpvJob(param);
|
||||
customerReportFeign.dnuJob(param);
|
||||
customerReportFeign.dnuCityJob(param);
|
||||
customerReportFeign.dauJob(param);
|
||||
customerReportFeign.dauTimeJob(param);
|
||||
customerReportFeign.dpvJob(param);
|
||||
customerReportFeign.duvJob(param);
|
||||
customerReportFeign.dauRangeJob(param);
|
||||
saleReportFeign.doInsureDetailsDayJob(param);
|
||||
saleReportFeign.doInsureCategoryJob(param);
|
||||
ReturnT.SUCCESS.setMsg("补全数据-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日投保访页面量
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureDpvJob")
|
||||
public ReturnT<String> doInsureDpvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureDpvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日投保访页面量-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日投保访页面量-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日投保用户访问数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureDuvJob")
|
||||
ReturnT<String> doInsureDuvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureDuvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日投保用户访问数-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日投保用户访问数-是吧");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日保险分类访问页面量
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "categoryDpvJob")
|
||||
ReturnT<String> categoryDpvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.categoryDpvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日保险分类访问页面量-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日保险分类访问页面量-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 性别日投保用户访问数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureGenderDuvJob")
|
||||
ReturnT<String> doInsureGenderDuvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureGenderDuvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("性别日投保用户访问数-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("性别日投保用户访问数-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 城市日投保用户访问数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureCityDuvJob")
|
||||
ReturnT<String> doInsureCityDuvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureCityDuvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("城市日投保用户访问数-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("城市日投保用户访问数-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 投保转换率
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureConversionDpvJob")
|
||||
ReturnT<String> doInsureConversionDpvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureConversionDpvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("城市日投保用户访问数-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("城市日投保用户访问数-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日投保访问失败页面量
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureFailDpvJob")
|
||||
ReturnT<String> doInsureFailDpvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = businessReportFeign.doInsureFailDpvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日投保访问失败页面量-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日投保访问失败页面量-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日新增用户数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dnuJob")
|
||||
ReturnT<String> dnuJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dnuJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日新增用户数-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日新增用户数-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日新增注册用户归属城市
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dnuCityJob")
|
||||
ReturnT<String> dnuCityJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dnuCityJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日新增注册用户归属城市-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日新增注册用户归属城市-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户日活跃数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dauJob")
|
||||
ReturnT<String> dauJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dauJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日新增注册用户归属城市-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日新增注册用户归属城市-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户每时活跃数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dauTimeJob")
|
||||
ReturnT<String> dauTimeJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dauTimeJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日新增注册用户归属城市-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日新增注册用户归属城市-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日访问量
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dpvJob")
|
||||
ReturnT<String> dpvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dpvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日访问量-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日访问量-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日用户访问数
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "duvJob")
|
||||
ReturnT<String> duvJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.duvJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日访问量-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日访问量-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户日活跃数范围
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "dauRangeJob")
|
||||
ReturnT<String> dauRangeJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = customerReportFeign.dauRangeJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("用户日活跃数范围-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("用户日活跃数范围-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日投保额度明细
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureDetailsDayJob")
|
||||
ReturnT<String> doInsureDetailsDayJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = saleReportFeign.doInsureDetailsDayJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日投保额度明细-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日投保额度明细-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日投保分类明细
|
||||
* @param param 统计时间
|
||||
* @return 是否执行成功
|
||||
*/
|
||||
@XxlJob(value = "doInsureCategoryJob")
|
||||
ReturnT<String> doInsureCategoryJob(String param){
|
||||
if (EmptyUtil.isNullOrEmpty(param)){
|
||||
param = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
}
|
||||
Boolean flag = saleReportFeign.doInsureCategoryJob(param);
|
||||
if (flag){
|
||||
ReturnT.SUCCESS.setMsg("日投保分类明细-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("日投保分类明细-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.itheima.sfbx.task.job;
|
||||
|
||||
import com.itheima.sfbx.framework.commons.dto.sms.SmsSendRecordVO;
|
||||
import com.itheima.sfbx.sms.feign.SmsSendFeign;
|
||||
import com.itheima.sfbx.sms.feign.SmsSendRecordFegin;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:同步短信发送结果
|
||||
*/
|
||||
@Component
|
||||
public class SmsSendHandlerJob {
|
||||
|
||||
@Autowired
|
||||
SmsSendFeign smsSendFeign;
|
||||
|
||||
@Autowired
|
||||
SmsSendRecordFegin smsSendRecordFegin;
|
||||
|
||||
/***
|
||||
* @description 短信发生接口同步
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob(value = "sendHandlerJob")
|
||||
public ReturnT<String> execute(String param) {
|
||||
List<SmsSendRecordVO> smsSendRecordVOs = smsSendRecordFegin.callBackSmsSendRecords();
|
||||
for (SmsSendRecordVO smsSendRecord : smsSendRecordVOs) {
|
||||
smsSendFeign.querySendSms(smsSendRecord);
|
||||
}
|
||||
ReturnT.SUCCESS.setMsg("执行-短信发送同步-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.itheima.sfbx.task.job;
|
||||
|
||||
import com.itheima.sfbx.trade.feign.CommonPayFeign;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @ClassName TradeHandlerJob.java
|
||||
* @Description TODO
|
||||
*/
|
||||
@Component
|
||||
public class TradeHandlerJob {
|
||||
|
||||
@Autowired
|
||||
CommonPayFeign commonPayFeign;
|
||||
|
||||
/**
|
||||
* 计划任务:同步支付结果
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob(value = "trade-sync-payment")
|
||||
public ReturnT<String> syncPayment(String param) {
|
||||
Boolean responseWrap = commonPayFeign.syncPaymentJob();
|
||||
if (responseWrap){
|
||||
ReturnT.SUCCESS.setMsg("计划任务:同步支付结果-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("计划任务:同步支付结果-失败");
|
||||
return ReturnT.FAIL;
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.itheima.sfbx.task.job;
|
||||
|
||||
import com.itheima.sfbx.instance.feign.WarrantyFeign;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @ClassName WarrantyHandlerJob.java
|
||||
* @Description 保险合同处理任务
|
||||
*/
|
||||
@Component
|
||||
public class WarrantyHandlerJob {
|
||||
|
||||
@Autowired
|
||||
WarrantyFeign warrantyFeign;
|
||||
|
||||
/**
|
||||
* 计划任务:周期代扣
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob(value = "warranty-periodic-pay")
|
||||
public ReturnT<String> execute(String param) {
|
||||
Boolean responseWrap = warrantyFeign.periodicPay();
|
||||
if (responseWrap){
|
||||
ReturnT.SUCCESS.setMsg("计划任务:周期代扣-成功");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
ReturnT.FAIL.setMsg("计划任务:周期代扣-失败");
|
||||
return ReturnT.FAIL;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
_ __ __
|
||||
(_) /__________ ______/ /_
|
||||
/ / __/ ___/ __ `/ ___/ __/
|
||||
/ / /_/ /__/ /_/ (__ ) /_
|
||||
/_/\__/\___/\__,_/____/\__/
|
||||
:: Spring Boot :: (v-2.7.10)
|
||||
:: Spring Cloud :: (v-2021.0.6)
|
||||
:: Spring Cloud Alibaba :: (v-2021.0.1.0)
|
||||
:: sfbx Cloud :: (v-2.0-SNAPSHOT)
|
||||
:: 献给可爱的传智人 ::
|
||||
@@ -0,0 +1,39 @@
|
||||
#服务配置
|
||||
server:
|
||||
#端口
|
||||
port: 7072
|
||||
#服务编码
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
config:
|
||||
activate:
|
||||
on-profile:
|
||||
- test
|
||||
#应用配置
|
||||
application:
|
||||
#应用名称
|
||||
name: task-job
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${NACOS_ADDRESS:nacos-service.yjy-public-sfbx-java.svc.cluster.local:20015} # nacos注册中心
|
||||
group: SEATA_GROUP
|
||||
service: ${spring.application.name}
|
||||
username: ${NACOS_USERNAME:nacos}
|
||||
password: ${NACOS_PASSWORD:PKsf*bxQ4;yP3a+}
|
||||
config:
|
||||
server-addr: ${NACOS_ADDRESS:nacos-service.yjy-public-sfbx-java.svc.cluster.local:20015} # nacos注册中心
|
||||
group: SEATA_GROUP
|
||||
file-extension: yml
|
||||
username: ${NACOS_USERNAME:nacos}
|
||||
password: ${NACOS_PASSWORD:PKsf*bxQ4;yP3a+}
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#服务配置
|
||||
server:
|
||||
#端口
|
||||
port: 7072
|
||||
#服务编码
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
profiles:
|
||||
active: dev
|
||||
#应用配置
|
||||
application:
|
||||
#应用名称
|
||||
name: task-job
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.12.129:8848 # nacos注册中心
|
||||
group: SEATA_GROUP
|
||||
service: ${spring.application.name}
|
||||
config:
|
||||
server-addr: 192.168.12.129:8848 # nacos配置中心地址
|
||||
group: SEATA_GROUP
|
||||
file-extension: yml
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
|
||||
<property name="LOG_HOME" value="/data/logs/task-job" />
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名 -->
|
||||
<FileNamePattern>${LOG_HOME}/task-job-01.log.%d{yyyy-MM-dd}.log
|
||||
</FileNamePattern>
|
||||
<!--日志文件保留天数 -->
|
||||
<MaxHistory>30</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern>
|
||||
</encoder>
|
||||
<!--日志文件最大的大小 -->
|
||||
<triggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>10MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
<!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
|
||||
<logger name="org.hibernate.type.descriptor.sql.BasicBinder"
|
||||
level="TRACE" />
|
||||
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor"
|
||||
level="DEBUG" />
|
||||
<logger name="org.hibernate.SQL" level="DEBUG" />
|
||||
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
|
||||
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
|
||||
|
||||
<!--myibatis log configure -->
|
||||
<logger name="com.apache.ibatis" level="TRACE" />
|
||||
<logger name="java.sql.Connection" level="DEBUG" />
|
||||
<logger name="java.sql.Statement" level="DEBUG" />
|
||||
<logger name="java.sql.PreparedStatement" level="DEBUG" />
|
||||
|
||||
<!-- 日志输出级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
<!--日志异步到数据库 -->
|
||||
</configuration>
|
||||
@@ -0,0 +1,21 @@
|
||||
FROM openjdk:11-jdk
|
||||
LABEL maintainer="研究院研发组 <research@itcast.cn>"
|
||||
|
||||
# 时区修改为东八区
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR /task-listener
|
||||
ARG PACKAGE_PATH=./target/task-listener.jar
|
||||
ADD ${PACKAGE_PATH:-./} task-listener.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENV JAVA_OPTS="\
|
||||
-server \
|
||||
-Xms256m \
|
||||
-Xmx512m \
|
||||
-XX:MetaspaceSize=256m \
|
||||
-XX:MaxMetaspaceSize=512m\
|
||||
-Dspring.profiles.active=test"
|
||||
ENTRYPOINT ["sh","-c","java -Djava.security.egd=file:/dev/./urandom -jar $JAVA_OPTS task-listener.jar"]
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>sfbx-task</artifactId>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<!--监听服务处理-->
|
||||
<artifactId>task-listener</artifactId>
|
||||
<name>task-listener</name>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>file-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>insurance-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>sms-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>points-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>framework-rabbitmq</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.itheima.sfbx</groupId>
|
||||
<artifactId>points-interface</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
</dependencies-->
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.properties</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.yaml</include>
|
||||
<include>**/*.txt</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>task-listener</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.itheima.sfbx.task;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 负责系统所有的消息队列监听 对应启动类
|
||||
*/
|
||||
@SpringBootApplication(scanBasePackages = "com.itheima.sfbx")
|
||||
public class TaskListenerStart {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TaskListenerStart.class);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.itheima.sfbx.task.binding;
|
||||
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.*;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
|
||||
/**
|
||||
* @ClassName Binding.java
|
||||
* @Description 绑定声明
|
||||
*/
|
||||
@EnableBinding({LogSink.class, SmsSink.class, FileSink.class, TradeSink.class, WarrantySink.class})
|
||||
public class SinkBinding {
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.itheima.sfbx.task.listen;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itheima.sfbx.file.feign.FileBusinessFeign;
|
||||
import com.itheima.sfbx.framework.commons.dto.file.FileVO;
|
||||
import com.itheima.sfbx.framework.rabbitmq.pojo.MqMessage;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.FileSink;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @ClassName FileLosten.java
|
||||
* @Description TODO
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class FileListen {
|
||||
|
||||
@Autowired
|
||||
FileBusinessFeign fileBusinessFeign;
|
||||
|
||||
@StreamListener(FileSink.FILE_INPUT)
|
||||
public void onMessage(@Payload MqMessage message,
|
||||
@Header(AmqpHeaders.CHANNEL) Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
|
||||
String jsonConten = message.getContent();
|
||||
log.info("[onMessage][线程编号:{} 消息内容:{}]", Thread.currentThread().getId(), message);
|
||||
FileVO fileVO= JSONObject.parseObject(jsonConten,FileVO.class);
|
||||
Boolean flag = fileBusinessFeign.clearFileById(fileVO.getId());
|
||||
//执行成功签收
|
||||
if (flag){
|
||||
channel.basicAck(deliveryTag,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.itheima.sfbx.task.listen;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itheima.sfbx.framework.commons.dto.log.LogBusinessVO;
|
||||
import com.itheima.sfbx.framework.rabbitmq.pojo.MqMessage;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.LogSink;
|
||||
import com.itheima.sfbx.points.feign.BusinessLogFeign;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.cloud.stream.messaging.Sink;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @ClassName LogListen.java
|
||||
* @Description 日志监听
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@EnableBinding(Sink.class)
|
||||
public class LogListen {
|
||||
|
||||
@Autowired
|
||||
BusinessLogFeign businessLogFeign;
|
||||
|
||||
@StreamListener(LogSink.LOG_INPUT)
|
||||
public void onMessage(@Payload MqMessage message,
|
||||
@Header(AmqpHeaders.CHANNEL) Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
|
||||
String jsonContent = message.getContent();
|
||||
log.info("[onMessage][线程编号:{} 消息内容:{}]", Thread.currentThread().getId(), message);
|
||||
LogBusinessVO logBusinessVO = JSONObject.parseObject(jsonContent, LogBusinessVO.class);
|
||||
Boolean flag = businessLogFeign.createBusinessLog(logBusinessVO);
|
||||
if (flag) {
|
||||
//日志记录成功直接消费消息
|
||||
channel.basicAck(deliveryTag, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.itheima.sfbx.task.listen;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itheima.sfbx.framework.commons.dto.sms.SendMessageVO;
|
||||
import com.itheima.sfbx.framework.rabbitmq.pojo.MqMessage;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.SmsSink;
|
||||
import com.itheima.sfbx.sms.feign.SmsSendFeign;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @ClassName SmsListen.java
|
||||
* @Description 短信监听
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SmsListen {
|
||||
|
||||
@Autowired
|
||||
SmsSendFeign smsSendFeign;
|
||||
|
||||
@StreamListener(SmsSink.SMS_INPUT)
|
||||
public void onMessage(@Payload MqMessage message,
|
||||
@Header(AmqpHeaders.CHANNEL) Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
|
||||
String jsonConten = message.getContent();
|
||||
log.info("[onMessage][线程编号:{} 消息内容:{}]", Thread.currentThread().getId(), message);
|
||||
SendMessageVO sendMessageVO = JSONObject.parseObject(jsonConten, SendMessageVO.class);
|
||||
Boolean flag = smsSendFeign.sendSms(sendMessageVO);
|
||||
if (flag){
|
||||
channel.basicAck(deliveryTag,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.itheima.sfbx.task.listen;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itheima.sfbx.framework.commons.dto.log.LogBusinessVO;
|
||||
import com.itheima.sfbx.framework.commons.dto.trade.TradeVO;
|
||||
import com.itheima.sfbx.framework.rabbitmq.pojo.MqMessage;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.TradeSink;
|
||||
import com.itheima.sfbx.instance.feign.WarrantyFeign;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @ClassName SmsListen.java
|
||||
* @Description 交易业务监听
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TradeListen {
|
||||
|
||||
@Autowired
|
||||
WarrantyFeign warrantyFeign;
|
||||
|
||||
@StreamListener(TradeSink.TRADE_INPUT)
|
||||
public void onMessage(@Payload MqMessage message,
|
||||
@Header(AmqpHeaders.CHANNEL) Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
|
||||
String jsonContent = message.getContent();
|
||||
log.info("========需要同步结果的合同订单:{}================", jsonContent);
|
||||
TradeVO tradeVO = JSONObject.parseObject(jsonContent, TradeVO.class);
|
||||
Boolean flag = warrantyFeign.syncPayment(String.valueOf(tradeVO.getProductOrderNo()),tradeVO.getTradeState());
|
||||
log.info("========执行结果:{}================", flag);
|
||||
//执行成功签收
|
||||
if (flag){
|
||||
channel.basicAck(deliveryTag,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.itheima.sfbx.task.listen;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.itheima.sfbx.file.feign.FileBusinessFeign;
|
||||
import com.itheima.sfbx.framework.commons.dto.file.FileVO;
|
||||
import com.itheima.sfbx.framework.rabbitmq.pojo.MqMessage;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.FileSink;
|
||||
import com.itheima.sfbx.framework.rabbitmq.sink.WarrantySink;
|
||||
import com.itheima.sfbx.instance.feign.WarrantyFeign;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @ClassName WarrantyListen.java
|
||||
* @Description 合同延迟处理监听
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WarrantyListen {
|
||||
|
||||
|
||||
@Autowired
|
||||
WarrantyFeign warrantyFeign;
|
||||
|
||||
@StreamListener(WarrantySink.WARRANTY_INPUT)
|
||||
public void onMessage(@Payload MqMessage message,
|
||||
@Header(AmqpHeaders.CHANNEL) Channel channel,
|
||||
@Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) throws IOException {
|
||||
String jsonContent = message.getContent();
|
||||
log.info("========需要处理的合同订单:{}================", jsonContent);
|
||||
Boolean flag = warrantyFeign.cleanWarranty(jsonContent);
|
||||
log.info("========执行结果:{}================", flag);
|
||||
//执行成功签收
|
||||
if (flag){
|
||||
channel.basicAck(deliveryTag,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
_ __ __
|
||||
(_) /__________ ______/ /_
|
||||
/ / __/ ___/ __ `/ ___/ __/
|
||||
/ / /_/ /__/ /_/ (__ ) /_
|
||||
/_/\__/\___/\__,_/____/\__/
|
||||
:: Spring Boot :: (v-2.7.10)
|
||||
:: Spring Cloud :: (v-2021.0.6)
|
||||
:: Spring Cloud Alibaba :: (v-2021.0.1.0)
|
||||
:: sfbx Cloud :: (v-2.0-SNAPSHOT)
|
||||
:: 传智教育---献给可爱的传智人 ::
|
||||
@@ -0,0 +1,51 @@
|
||||
#服务配置
|
||||
server:
|
||||
#端口
|
||||
port: 7076
|
||||
#服务编码
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
config:
|
||||
activate:
|
||||
on-profile:
|
||||
- test
|
||||
#应用配置
|
||||
application:
|
||||
#应用名称
|
||||
name: task-listener
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${NACOS_ADDRESS:nacos-service.yjy-public-sfbx-java.svc.cluster.local:20015} # nacos注册中心
|
||||
group: SEATA_GROUP7
|
||||
service: ${spring.application.name}
|
||||
username: ${NACOS_USERNAME:nacos}
|
||||
password: ${NACOS_PASSWORD:PKsf*bxQ4;yP3a+}
|
||||
config:
|
||||
server-addr: ${NACOS_ADDRESS:nacos-service.yjy-public-sfbx-java.svc.cluster.local:20015} # nacos注册中心
|
||||
group: SEATA_GROUP
|
||||
file-extension: yml
|
||||
shared-configs: # 共享配置
|
||||
- data-id: shared-stream-rabbit-basic.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-sms.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-log.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-file.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
username: ${NACOS_USERNAME:nacos}
|
||||
password: ${NACOS_PASSWORD:PKsf*bxQ4;yP3a+}
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
@@ -0,0 +1,51 @@
|
||||
#服务配置
|
||||
server:
|
||||
#端口
|
||||
port: 7076
|
||||
#服务编码
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
allow-circular-references: true
|
||||
profiles:
|
||||
active: dev
|
||||
#应用配置
|
||||
application:
|
||||
#应用名称
|
||||
name: task-listener
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.12.129:8848 # nacos注册中心
|
||||
group: SEATA_GROUP
|
||||
service: ${spring.application.name}
|
||||
config:
|
||||
server-addr: 192.168.12.129:8848 # nacos配置中心地址
|
||||
group: SEATA_GROUP
|
||||
file-extension: yml
|
||||
shared-configs: # 共享配置
|
||||
- data-id: shared-stream-rabbit-basic.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-sms.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-log.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-file.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-warranty.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-stream-rabbit-sink-trade.yml #配置文件名-DataId
|
||||
group: SEATA_GROUP
|
||||
refresh: false
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
|
||||
<property name="LOG_HOME" value="/data/logs/task-listener" />
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名 -->
|
||||
<FileNamePattern>${LOG_HOME}/task-listener-01.log.%d{yyyy-MM-dd}.log
|
||||
</FileNamePattern>
|
||||
<!--日志文件保留天数 -->
|
||||
<MaxHistory>30</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern>
|
||||
</encoder>
|
||||
<!--日志文件最大的大小 -->
|
||||
<triggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>10MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
<!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
|
||||
<logger name="org.hibernate.type.descriptor.sql.BasicBinder"
|
||||
level="TRACE" />
|
||||
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor"
|
||||
level="DEBUG" />
|
||||
<logger name="org.hibernate.SQL" level="DEBUG" />
|
||||
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
|
||||
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
|
||||
|
||||
<!--myibatis log configure -->
|
||||
<logger name="com.apache.ibatis" level="TRACE" />
|
||||
<logger name="java.sql.Connection" level="DEBUG" />
|
||||
<logger name="java.sql.Statement" level="DEBUG" />
|
||||
<logger name="java.sql.PreparedStatement" level="DEBUG" />
|
||||
|
||||
<!-- 日志输出级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
<!--日志异步到数据库 -->
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user