package com.adc.da.mq; import com.adc.da.slrs.sarLawsAttrInfo.service.ISarLawsAttrInfoService; import com.adc.da.slrs.sarLawsStandInfo.entity.SarLawsStandInfo; import com.adc.da.slrs.sarLawsStandInfo.service.ISarLawsStandInfoService; import com.adc.da.slrs.sarStandAttrInfo.service.ISarStandAttrInfoService; import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo; import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService; import com.adc.da.sys.service.IDicTypeEOService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.rabbitmq.client.Channel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; import org.springframework.amqp.rabbit.annotation.QueueBinding; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.Message; import org.springframework.stereotype.Component; import java.util.*; @Component public class SendQdUpdateMQService { @Autowired private ISarStandAttrInfoService iSarStandAttrInfoService; @Autowired private ISarStandardsInfoService sarStandardsInfoService; @Autowired private ISarLawsStandInfoService lawsStandInfoService; @Autowired private ISarLawsAttrInfoService lawsAttrInfoService; //查询数据字典 @Autowired private IDicTypeEOService dicTypeEOService; private static final Logger logger = LoggerFactory.getLogger(SendQdUpdateMQService.class); @RabbitListener(bindings = @QueueBinding( value = @Queue(value = "createQdUpdateMQ_SQ_GSAR_RELEASE", durable = "true"), exchange = @Exchange(value = "qd-update-exchange_SQ_GSAR_RELEASE", ignoreDeclarationExceptions = "true"), key = "qd-update-key_SQ_GSAR_RELEASE")) public void createMQ(Map bussMap, Message message, Channel channel) throws Exception{ //数据字典数据组装 Map dicTypeEO = dicTypeEOService.getDicTypeListCode(); Map dict=new HashMap<>(); List> arr = (List>) dicTypeEO.get("SYRZCLASS"); arr.forEach(stringStringMap -> { dict.put(stringStringMap.get("label"),stringStringMap.get("value")); }); //写修改逻辑 Thread.sleep(5000); Hashtable tool= (Hashtable) bussMap.get("table"); List remove= (List) bussMap.get("remove"); List add= (List) bussMap.get("add"); remove.forEach(s -> { QueryWrapper wrapper=new QueryWrapper<>(); wrapper.eq("ID",s); List infos=sarStandardsInfoService.list(wrapper); if (null!=infos && infos.size()>0) { SarStandardsInfo sarStandardsInfo = new SarStandardsInfo(); sarStandardsInfo.setId(s); sarStandardsInfo.setIsRelateAccess("2"); Map bussAttrInfoMap = iSarStandAttrInfoService.getBussAttrInfo(s); if (bussAttrInfoMap != null) { StringBuilder stringBuilder = new StringBuilder(); if (tool.get(s).contains(",")) { for (String e : tool.get(s).split(",")) { stringBuilder.append(dict.get(e)); } } else { stringBuilder.append(dict.get(s)); } bussAttrInfoMap.replace("SYRZ", stringBuilder.toString()); } } QueryWrapper wrapper1=new QueryWrapper<>(); wrapper.eq("ID",s); List infos1=lawsStandInfoService.list(wrapper1); if (null!=infos1 && infos1.size()>0) { SarLawsStandInfo sarLawsStandInfo = new SarLawsStandInfo(); sarLawsStandInfo.setId(s); sarLawsStandInfo.setIsRelateAccess("2"); Map bussAttrInfoMap = lawsAttrInfoService.getBussAttrInfo(s); if (bussAttrInfoMap != null) { StringBuilder stringBuilder = new StringBuilder(); if (tool.get(s).contains(",")) { for (String e : tool.get(s).split(",")) { stringBuilder.append(dict.get(e)); } } else { stringBuilder.append(dict.get(s)); } bussAttrInfoMap.replace("SYRZ", stringBuilder.toString()); } } }); add.forEach(s -> { QueryWrapper wrapper=new QueryWrapper<>(); wrapper.eq("ID",s); List infos=sarStandardsInfoService.list(wrapper); if (null!=infos && infos.size()>0) { SarStandardsInfo sarStandardsInfo = new SarStandardsInfo(); sarStandardsInfo.setId(s); sarStandardsInfo.setIsRelateAccess("1"); Map bussAttrInfoMap = iSarStandAttrInfoService.getBussAttrInfo(s); if (bussAttrInfoMap != null) { StringBuilder stringBuilder = new StringBuilder(); if (tool.get(s).contains(",")) { for (String e : tool.get(s).split(",")) { stringBuilder.append(dict.get(e)); } } else { stringBuilder.append(dict.get(s)); } bussAttrInfoMap.replace("SYRZ", stringBuilder.toString()); } } QueryWrapper wrapper1=new QueryWrapper<>(); wrapper.eq("ID",s); List infos1=lawsStandInfoService.list(wrapper1); if (null!=infos1 && infos1.size()>0) { SarLawsStandInfo sarLawsStandInfo = new SarLawsStandInfo(); sarLawsStandInfo.setId(s); sarLawsStandInfo.setIsRelateAccess("1"); Map bussAttrInfoMap = lawsAttrInfoService.getBussAttrInfo(s); if (bussAttrInfoMap != null) { StringBuilder stringBuilder = new StringBuilder(); if (tool.get(s).contains(",")) { for (String e : tool.get(s).split(",")) { stringBuilder.append(dict.get(e)); } } else { stringBuilder.append(dict.get(s)); } bussAttrInfoMap.replace("SYRZ", stringBuilder.toString()); } } }); } }