1
This commit is contained in:
@@ -4,15 +4,20 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.jarvis.domain.WeComShareLinkLogisticsJob;
|
||||
import com.ruoyi.jarvis.mapper.WeComShareLinkLogisticsJobMapper;
|
||||
import com.ruoyi.jarvis.service.ILogisticsService;
|
||||
import com.ruoyi.jarvis.service.IWeComShareLinkLogisticsJobService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -22,6 +27,10 @@ public class WeComShareLinkLogisticsJobController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IWeComShareLinkLogisticsJobService weComShareLinkLogisticsJobService;
|
||||
@Resource
|
||||
private ILogisticsService logisticsService;
|
||||
@Resource
|
||||
private WeComShareLinkLogisticsJobMapper weComShareLinkLogisticsJobMapper;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:wecom:shareLinkLog:list')")
|
||||
@GetMapping("/list")
|
||||
@@ -43,4 +52,56 @@ public class WeComShareLinkLogisticsJobController extends BaseController {
|
||||
Map<String, Object> r = weComShareLinkLogisticsJobService.backfillImportedFromInboundTrace();
|
||||
return success(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* 与订单列表「获取物流」一致:立即请求物流接口,有运单则推送分享链模板,并回写任务行。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:wecom:shareLinkLog:list')")
|
||||
@PostMapping("/fetchShareLinkManually")
|
||||
public AjaxResult fetchShareLinkManually(@RequestBody Map<String, Object> body) {
|
||||
if (body == null || body.get("jobKey") == null) {
|
||||
return AjaxResult.error("jobKey 不能为空");
|
||||
}
|
||||
String jobKey = body.get("jobKey").toString().trim();
|
||||
if (!StringUtils.hasText(jobKey)) {
|
||||
return AjaxResult.error("jobKey 不能为空");
|
||||
}
|
||||
WeComShareLinkLogisticsJob job = weComShareLinkLogisticsJobService.selectByJobKey(jobKey);
|
||||
if (job == null) {
|
||||
return AjaxResult.error("任务不存在");
|
||||
}
|
||||
if (!StringUtils.hasText(job.getTrackingUrl())) {
|
||||
return AjaxResult.error("该任务无物流短链");
|
||||
}
|
||||
String remark = job.getUserRemark() != null ? job.getUserRemark() : "";
|
||||
String touser = job.getTouserPush() != null ? job.getTouserPush() : "";
|
||||
Map<String, Object> data = logisticsService.adminFetchShareLinkLogisticsDebug(
|
||||
job.getTrackingUrl(), remark, touser);
|
||||
data.put("jobKey", jobKey);
|
||||
|
||||
int nextAttempts = job.getScanAttempts() == null ? 1 : job.getScanAttempts() + 1;
|
||||
String adhocNote = data.get("adhocNote") != null ? data.get("adhocNote").toString() : "";
|
||||
String note = "manual:" + adhocNote;
|
||||
if (Boolean.TRUE.equals(data.get("terminalSuccess"))) {
|
||||
String wb = data.get("waybillNo") != null ? data.get("waybillNo").toString() : null;
|
||||
weComShareLinkLogisticsJobMapper.updateByJobKey(jobKey, "PUSHED", note, nextAttempts,
|
||||
StringUtils.hasText(wb) ? wb : null);
|
||||
} else {
|
||||
weComShareLinkLogisticsJobMapper.updateByJobKey(jobKey, "WAITING", note, nextAttempts, null);
|
||||
}
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动执行一轮与定时任务相同的 Redis 待队列弹出(条数上限同 adhoc-pending-batch-size)。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('jarvis:wecom:shareLinkLog:list')")
|
||||
@PostMapping("/drainPendingQueueOnce")
|
||||
public AjaxResult drainPendingQueueOnce() {
|
||||
int n = logisticsService.drainPendingShareLinkQueue();
|
||||
Map<String, Object> r = new LinkedHashMap<>();
|
||||
r.put("processedFromQueue", n);
|
||||
r.put("hint", "为单次弹栈处理条数;每项内部仍可能因未出单重新入队");
|
||||
return AjaxResult.success(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user