| | |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.TransactionSynchronization; |
| | | import org.springframework.transaction.support.TransactionSynchronizationManager; |
| | | import org.springframework.web.client.HttpStatusCodeException; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | |
| | | if (StringUtils.isNotBlank(task.getTaskCode())) { |
| | | rcsBusTaskNoticeService.notifyTaskStatus(task.getTaskCode(), task.getTaskStatus()); |
| | | } |
| | | final Long taskIdForFinish = task.getId(); |
| | | if (TransactionSynchronizationManager.isSynchronizationActive()) { |
| | | TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { |
| | | @Override |
| | | public void afterCommit() { |
| | | taskService.runStockFinishAfterManualComplete(taskIdForFinish); |
| | | } |
| | | }); |
| | | } |
| | | return task; |
| | | } |
| | | |
| | | @Override |
| | | public void runStockFinishAfterManualComplete(Long taskId) { |
| | | if (taskId == null) { |
| | | return; |
| | | } |
| | | try { |
| | | Task t = taskService.getById(taskId); |
| | | if (t == null) { |
| | | return; |
| | | } |
| | | if (Objects.equals(t.getTaskStatus(), TaskStsType.COMPLETE_IN.id)) { |
| | | taskService.complateInTask(Collections.singletonList(t)); |
| | | } else if (Objects.equals(t.getTaskStatus(), TaskStsType.COMPLETE_OUT.id)) { |
| | | taskService.completeTask(Collections.singletonList(t)); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("手动完结后立即库存收尾失败,将由定时任务重试,taskId={}:{}", taskId, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | } |
| | | // 出库仅云仓来源单据参与上报 |
| | | if (!isInbound) { |
| | | boolean hasCloudSource = taskItems.stream().anyMatch(this::hasCloudOrderRef); |
| | | if (!hasCloudSource) { |
| | | // log.info("入/出库结果上报待办跳过:无云仓来源单据,taskId={}", task.getId()); |
| | | log.info("入/出库结果上报待办跳过:手动创建出库单据不通知云仓,taskId={}", task.getId()); |
| | | return; |
| | | } |
| | | // 入/出库均仅云仓来源单据参与上报(明细需带 platOrderCode 或 platWorkCode) |
| | | boolean hasCloudSource = taskItems.stream().anyMatch(this::hasCloudOrderRef); |
| | | if (!hasCloudSource) { |
| | | log.info("入/出库结果上报待办跳过:无云仓来源单据,taskId={}", task.getId()); |
| | | return; |
| | | } |
| | | ObjectMapper om = new ObjectMapper(); |
| | | Date now = new Date(); |
| | | for (TaskItem item : taskItems) { |
| | | if (!isInbound && !hasCloudOrderRef(item)) { |
| | | if (!hasCloudOrderRef(item)) { |
| | | continue; |
| | | } |
| | | String orderNo = isInbound ? sourceToOrderNo.get(item.getSource()) : (item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode()); |