eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/rest/ApproveEventController.java
@@ -15,12 +15,12 @@ */ package me.zhengjie.modules.approval.rest; import me.zhengjie.annotation.AnonymousAccess; import me.zhengjie.annotation.Log; import me.zhengjie.modules.approval.domain.ApproveEvent; import me.zhengjie.modules.approval.service.ApproveEventService; import me.zhengjie.modules.approval.service.dto.ApproveEventQueryCriteria; import me.zhengjie.modules.temp.event.ChangeApprovalStatusEvent; import me.zhengjie.modules.temp.service.WechatSendHistoryService; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; @@ -45,6 +45,7 @@ public class ApproveEventController { private final ApproveEventService approveEventService; private final WechatSendHistoryService wechatSendHistoryService; private final ApplicationEventPublisher applicationEventPublisher; @Log("导出数据") @@ -89,11 +90,16 @@ return new ResponseEntity<>(HttpStatus.OK); } @AnonymousAccess @GetMapping(value = "/test/{id}") public ResponseEntity<Object> test(@PathVariable Long id) { @GetMapping(value = "/changeById/{id}") public ResponseEntity<Object> changeById(@PathVariable Long id) { ChangeApprovalStatusEvent event = new ChangeApprovalStatusEvent(new Object(), id); applicationEventPublisher.publishEvent(event); return new ResponseEntity<>(HttpStatus.OK); } @GetMapping(value = "/changeBySpNo/{spNo}") public ResponseEntity<Object> changeBySpNo(@PathVariable String spNo) { wechatSendHistoryService.handleWechatSendHistoryBySpNo(spNo); return new ResponseEntity<>(HttpStatus.OK); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/WechatSendHistoryService.java
@@ -103,4 +103,10 @@ * @return String */ void handleApprovalCallback(String msgSignature, String timestamp, String nonce, HttpServletRequest request, HttpServletResponse response); /** * 用SpNo处理下发企微消息 * @param spNo / */ void handleWechatSendHistoryBySpNo(String spNo); } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/dto/WechatSendHistoryQueryCriteria.java
@@ -26,4 +26,7 @@ **/ @Data public class WechatSendHistoryQueryCriteria{ /** 模糊 */ @Query(type = Query.Type.INNER_LIKE, propName = "content") private String contentInnerLike; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatSendHistoryServiceImpl.java
@@ -30,6 +30,7 @@ import org.json.JSONObject; import org.json.XML; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; @@ -202,6 +203,22 @@ } } @Override public void handleWechatSendHistoryBySpNo(String spNo) { if (StringUtils.isNotBlank(spNo)) { WechatSendHistoryQueryCriteria criteria = new WechatSendHistoryQueryCriteria(); criteria.setContentInnerLike(spNo); List<WechatSendHistory> historyList = wechatSendHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), Sort.by(Sort.Direction.DESC, "id")); if (historyList.size() > 0) { WechatSendHistory filterData = historyList.stream().filter(h -> h.getContent().startsWith("{\"ApprovalInfo\"")).findFirst().orElseGet(WechatSendHistory::new); if (StringUtils.isNotBlank(filterData.getContent())) { ChangeApprovalStatusEvent event = new ChangeApprovalStatusEvent(new Object(), filterData.getId()); applicationEventPublisher.publishEvent(event); } } } } /** * 判断字符串是不是Json格式 *