parent
147bb6e9e4
commit
cc98960c7e
@ -0,0 +1,87 @@ |
||||
package com.jianshui.invoice.task; |
||||
|
||||
import cn.hutool.http.HttpUtil; |
||||
import cn.hutool.json.JSONUtil; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.jianshui.common.core.domain.entity.Companyservice; |
||||
import com.jianshui.common.core.redis.RedisCache; |
||||
import com.jianshui.common.utils.StringUtils; |
||||
import com.jianshui.common.utils.spring.SpringUtils; |
||||
import com.jianshui.framework.manager.AsyncManager; |
||||
import com.jianshui.invoice.domain.BillInfo; |
||||
import com.jianshui.invoice.domain.Invoice; |
||||
import com.jianshui.invoice.domain.dto.QueryBillInfoDTO; |
||||
import com.jianshui.invoice.mapper.InvoiceMapper; |
||||
import com.jianshui.invoice.service.IInvoiceApiService; |
||||
import com.jianshui.queue.utils.RedisQueueUtil; |
||||
import lombok.SneakyThrows; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import java.util.TimerTask; |
||||
|
||||
/** |
||||
* @Description 重汽开票回调 |
||||
**/ |
||||
@Slf4j |
||||
public class QueryBackZhongQiTask extends TimerTask { |
||||
|
||||
private String callBackUrl; |
||||
private Long id; |
||||
|
||||
|
||||
public QueryBackZhongQiTask(String callBackUrl, Long id) { |
||||
this.callBackUrl = callBackUrl; |
||||
this.id = id; |
||||
} |
||||
|
||||
@SneakyThrows |
||||
@Override |
||||
public void run() { |
||||
RedisCache redisCache = SpringUtils.getBean(RedisCache.class); |
||||
|
||||
|
||||
InvoiceMapper invoiceMapper = SpringUtils.getBean(InvoiceMapper.class); |
||||
Invoice invoice = invoiceMapper.selectInvoiceById(id); |
||||
if (invoice == null) { |
||||
log.info("【控制台】发票信息未查询到,id={}", id); |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
log.info("【控制台】发票回调接口,发送数据开始,id={}", id); |
||||
String result = HttpUtil.post(callBackUrl, JSONUtil.toJsonStr(invoice)); |
||||
|
||||
log.info("【控制台】发票回调接口,发送数据结束,id={},接口返回信息={}", id, JSONUtil.toJsonStr(invoice)); |
||||
} catch (Exception e) { |
||||
log.info("【控制台】发票回调接口,发送数据异常,id={}", id); |
||||
return; |
||||
} |
||||
|
||||
// TODO: 2023/10/25 回调队列看一下怎么处理
|
||||
|
||||
|
||||
/* if (invoice == null || StringUtils.equalsAny(Integer.toString(invoice.getState()), "0", "20")) { |
||||
// 查询下失败队列,是否有次数
|
||||
String keys = "invoice_query_times_" + this.companyservice.getCompanyid() + "_" + this.finalBillInfo.getSystemOrderno(); |
||||
Integer queryTimes = redisCache.getCacheObject(keys); |
||||
// 查询重试次数超过20次,就不查了
|
||||
if (queryTimes != null && queryTimes > 20) { |
||||
log.error("【定时任务】【发票查询】发票信息始终不存在,不再进行查询:{}", JSONObject.toJSONString(this.finalBillInfo)); |
||||
redisCache.deleteObject(keys); |
||||
return; |
||||
} |
||||
if (queryTimes == null) { |
||||
queryTimes = 0; |
||||
} |
||||
queryTimes += 1; |
||||
redisCache.setCacheObject(keys, queryTimes); |
||||
log.error("【定时任务】【发票查询】发票信息不存在或还在开票中,再次进入查询:{}", JSONObject.toJSONString(this.finalBillInfo)); |
||||
AsyncManager.me().execute(new QueryBackZhongQiTask(this.finalBillInfo, companyservice, this.invoiceApiService)); |
||||
} |
||||
|
||||
RedisQueueUtil.build().setData(invoice).onQueue("invoice_add_callback_consumer").retry(0).dispatch();*/ |
||||
} |
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue