| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.crm.service.quotation.listener; |
| | | |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO; |
| | | import cn.iocoder.yudao.module.crm.dal.mysql.quotation.CrmSaleQuotationMapper; |
| | | import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum; |
| | | import cn.iocoder.yudao.module.crm.service.quotation.CrmSaleQuotationService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * é宿¥ä»·å®¡æ¹çç»æçå¬å¨ |
| | | * |
| | | * éè¿ businessKeyï¼æ¥ä»·å IDï¼å¹é
ï¼è䏿¯åºå®çæµç¨å®ä¹ Keyï¼ |
| | | * è¿æ ·å¯ä»¥æ¯æãé宿¥ä»·å®¡æ¹ãåç±»ä¸ä»»æ Key çæµç¨æ¨¡åã |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class CrmSaleQuotationStatusListener implements ApplicationListener<BpmProcessInstanceStatusEvent> { |
| | | |
| | | @Resource |
| | | private CrmSaleQuotationService saleQuotationService; |
| | | @Resource |
| | | private CrmSaleQuotationMapper saleQuotationMapper; |
| | | |
| | | @Override |
| | | public void onApplicationEvent(BpmProcessInstanceStatusEvent event) { |
| | | // éè¿ businessKey æ¥è¯¢æ¥ä»·å |
| | | Long quotationId; |
| | | try { |
| | | quotationId = Long.parseLong(event.getBusinessKey()); |
| | | } catch (NumberFormatException e) { |
| | | return; // businessKey 䏿¯æ°åï¼å¿½ç¥ |
| | | } |
| | | |
| | | CrmSaleQuotationDO quotation = saleQuotationMapper.selectById(quotationId); |
| | | if (quotation == null) { |
| | | return; // 䏿¯æ¥ä»·åï¼å¿½ç¥ |
| | | } |
| | | // åªæå®¡æ¹ä¸ç¶æçæ¥ä»·åæå¤ç |
| | | if (!CrmSaleQuotationStatusEnum.PROCESS.getStatus().equals(quotation.getStatus())) { |
| | | log.warn("[onApplicationEvent] æ¥ä»·å({}) ä¸å¤äºå®¡æ¹ä¸ç¶æï¼å½åç¶æ: {}", quotationId, quotation.getStatus()); |
| | | return; |
| | | } |
| | | |
| | | log.info("[onApplicationEvent] æ¥ä»·å({}) 审æ¹ç¶ææ´æ°: {}", quotationId, event.getStatus()); |
| | | saleQuotationService.updateSaleQuotationAuditStatus(quotationId, event.getStatus()); |
| | | } |
| | | |
| | | } |