7 changed files with 175 additions and 11 deletions
@ -0,0 +1,55 @@ |
|||||
|
package org.nl.quartz.task; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import jodd.util.StringUtil; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.ext.wms.data.feedBackTaskStatus.FeedBackTaskStatusRequest; |
||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
||||
|
import org.nl.common.utils.RedisUtils; |
||||
|
import org.nl.config.SpringContextHolder; |
||||
|
import org.nl.config.thread.ThreadPoolExecutorUtil; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.CompletableFuture; |
||||
|
import java.util.concurrent.ThreadPoolExecutor; |
||||
|
|
||||
|
/** |
||||
|
* @author liejiu |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
public class ResendRequestWCS { |
||||
|
|
||||
|
@Resource |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
@Resource |
||||
|
AcsToWmsService acstowmsService; |
||||
|
|
||||
|
|
||||
|
public void run() throws Exception { |
||||
|
if (redisUtils.hasKey("ResendRequestWCS")) { |
||||
|
Map<Object, Object> resendRequestWCS = redisUtils.hmget("ResendRequestWCS"); |
||||
|
resendRequestWCS.forEach((k, v) -> { |
||||
|
|
||||
|
FeedBackTaskStatusRequest request = (FeedBackTaskStatusRequest) v; |
||||
|
String resp = acstowmsService.feedTaskStatus(request); |
||||
|
JSONObject result = JSONObject.parseObject(resp); |
||||
|
if (StringUtil.isNotBlank(result.getString("status")) && "200".equals(result.getString("status"))) { |
||||
|
log.info("任务号" + request.getTask_code() + "开始反馈wcs任务完成状态" + "成功。"); |
||||
|
redisUtils.hdel("ResendRequestWCS", request.getTask_code()); |
||||
|
} else if (StringUtil.isNotBlank(result.getString("status")) && !"200".equals(result.getString("status"))) { |
||||
|
log.info("任务号" + request.getTask_code() + "开始反馈wcs任务完成状态" + "失败,服务器响应的失败原因为:" + result.getString("message")); |
||||
|
redisUtils.hdel("ResendRequestWCS", request.getTask_code()); |
||||
|
} else if (StringUtil.isNotBlank(result.getString("code")) && "500".equals(result.getString("code"))) { |
||||
|
log.info("任务号" + request.getTask_code() + "请求不通" + "失败,服务器响应的失败原因为:" + result.getString("message")); |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<included> |
||||
|
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/> |
||||
|
<property name="LOG_HOME" value="${logPath}"/> |
||||
|
<!-- 按照每天生成日志文件 --> |
||||
|
<appender name="ResendRequestWCS" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--日志文件输出的文件名--> |
||||
|
<FileNamePattern>${LOG_HOME}/ACS请求WMS重发/%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
<!--单个日志最大容量 至少10MB才能看得出来--> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
<!--所有日志最多占多大容量--> |
||||
|
<totalSizeCap>2GB</totalSizeCap> |
||||
|
</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> |
||||
|
<charset>${log.charset}</charset> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender"> |
||||
|
<appender-ref ref="ResendRequestWCS" /> |
||||
|
<!-- 设置队列大小,根据您的需求调整 --> |
||||
|
<queueSize>512</queueSize> |
||||
|
</appender> |
||||
|
<logger name="org.nl.quartz.task.ResendRequestWCS" level="info" additivity="true"> |
||||
|
<appender-ref ref="asyncFileAppender"/> |
||||
|
</logger> |
||||
|
</included> |
Loading…
Reference in new issue