| 
						
						
						
					 | 
					@ -1,12 +1,17 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					package com.epmet.opendata.mq.listener; | 
					 | 
					 | 
					package com.epmet.opendata.mq.listener; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.rocketmq.constants.MQUserPropertys; | 
					 | 
					 | 
					import com.epmet.commons.rocketmq.constants.MQUserPropertys; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.rocketmq.messages.StaffPatrolMQMsg; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.distributedlock.DistributedLock; | 
					 | 
					 | 
					import com.epmet.commons.tools.distributedlock.DistributedLock; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.redis.RedisKeys; | 
					 | 
					 | 
					import com.epmet.commons.tools.redis.RedisKeys; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.redis.RedisUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.redis.RedisUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.SpringContextUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.SpringContextUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.opendata.dto.form.UpsertPatrolRecordForm; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.opendata.service.UserPatrolRecordService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; | 
					 | 
					 | 
					import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; | 
					 | 
					 | 
					import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -17,12 +22,14 @@ import org.slf4j.Logger; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.slf4j.LoggerFactory; | 
					 | 
					 | 
					import org.slf4j.LoggerFactory; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.List; | 
					 | 
					 | 
					import java.util.List; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.util.concurrent.TimeUnit; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/** | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 * @Description 系统对接中间库,巡查信息变更监听器 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 * @author wxz | 
					 | 
					 | 
					 * @author wxz | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					 * @Description 系统对接中间库,巡查信息变更监听器 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 * @date 2021.10.13 15:21:48 | 
					 | 
					 | 
					 * @date 2021.10.13 15:21:48 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					*/ | 
					 | 
					 | 
					 */ | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					@Slf4j | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					public class OpenDataPatrolChangeEventListener implements MessageListenerConcurrently { | 
					 | 
					 | 
					public class OpenDataPatrolChangeEventListener implements MessageListenerConcurrently { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private Logger logger = LoggerFactory.getLogger(getClass()); | 
					 | 
					 | 
					    private Logger logger = LoggerFactory.getLogger(getClass()); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -54,13 +61,23 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.PENDING_MSG_LABEL); | 
					 | 
					 | 
					        String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.PENDING_MSG_LABEL); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        logger.info("【开放数据事件监听器】-巡查记录信息变更-收到消息内容:{}, 操作:{}", msg, tags); | 
					 | 
					 | 
					        logger.info("【开放数据事件监听器】-巡查记录信息变更-收到消息内容:{}, 操作:{}", msg, tags); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					
 | 
					 | 
					 | 
					        StaffPatrolMQMsg msgObj = JSON.parseObject(msg, StaffPatrolMQMsg.class); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (msgObj == null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.warn("consumeMessage msg body is blank"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            return; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        DistributedLock distributedLock = null; | 
					 | 
					 | 
					        DistributedLock distributedLock = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        RLock lock = null; | 
					 | 
					 | 
					        RLock lock = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        try { | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            //distributedLock = SpringContextUtils.getBean(DistributedLock.class);
 | 
					 | 
					 | 
					            distributedLock = SpringContextUtils.getBean(DistributedLock.class); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            //lock = distributedLock.getLock(String.format("lock:open_data_staff:%s", staffId),
 | 
					 | 
					 | 
					            lock = distributedLock.getLock(String.format("lock:open_data_patrol:%s", msgObj.getPatrolId()), | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            //        30L, 30L, TimeUnit.SECONDS);
 | 
					 | 
					 | 
					                    30L, 30L, TimeUnit.SECONDS); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            UpsertPatrolRecordForm patrolRecordForm = new UpsertPatrolRecordForm(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            patrolRecordForm.setCustomerId(msgObj.getCustomerId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            patrolRecordForm.setPatrolId(msgObj.getPatrolId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            patrolRecordForm.setActionType(msgObj.getActionType()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            Boolean aBoolean = SpringContextUtils.getBean(UserPatrolRecordService.class).upsertPatrolRecord(patrolRecordForm); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } catch (RenException e) { | 
					 | 
					 | 
					        } catch (RenException e) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
 | 
					 | 
					 | 
					            // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            logger.error("【开放数据事件监听器】-巡查记录信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); | 
					 | 
					 | 
					            logger.error("【开放数据事件监听器】-巡查记录信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -69,7 +86,7 @@ public class OpenDataPatrolChangeEventListener implements MessageListenerConcurr | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            logger.error("【开放数据事件监听器】-巡查记录信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); | 
					 | 
					 | 
					            logger.error("【开放数据事件监听器】-巡查记录信息变更-初始化客户组织失败:".concat(ExceptionUtils.getErrorStackTrace(e))); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            throw e; | 
					 | 
					 | 
					            throw e; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } finally { | 
					 | 
					 | 
					        } finally { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            //distributedLock.unLock(lock);
 | 
					 | 
					 | 
					            distributedLock.unLock(lock); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (StringUtils.isNotBlank(pendingMsgLabel)) { | 
					 | 
					 | 
					        if (StringUtils.isNotBlank(pendingMsgLabel)) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |