207 lines
9.4 KiB
Java
207 lines
9.4 KiB
Java
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.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.rabbitmq.client.Channel;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
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<String, Object> bussMap, Message message, Channel channel) throws Exception {
|
|
|
|
//数据字典数据组装
|
|
Map<String, Object> dicTypeEO = dicTypeEOService.getDicTypeListCode();
|
|
Map<String, String> dict = new HashMap<>();
|
|
List<Map<String, String>> arr = (List<Map<String, String>>) dicTypeEO.get("SYRZCLASS");
|
|
arr.forEach(stringStringMap -> {
|
|
dict.put(stringStringMap.get("label"), stringStringMap.get("value"));
|
|
});
|
|
|
|
|
|
//写修改逻辑
|
|
Thread.sleep(5000);
|
|
Hashtable<String, String> tool = (Hashtable<String, String>) bussMap.get("tableData");
|
|
List<String> remove = (List<String>) bussMap.get("remove");
|
|
List<String> add = (List<String>) bussMap.get("add");
|
|
remove.forEach(s -> {
|
|
QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>();
|
|
wrapper.eq("ID", s);
|
|
List<SarStandardsInfo> infos = sarStandardsInfoService.list(wrapper);
|
|
if (null != infos && infos.size() > 0) {
|
|
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
|
sarStandardsInfo.setId(s);
|
|
sarStandardsInfo.setIsRelateAccess("2");
|
|
sarStandardsInfo.setModifyTime(new Date());
|
|
Map<String, Object> bussAttrInfoMap = iSarStandAttrInfoService.getBussAttrInfo(s);
|
|
|
|
if (bussAttrInfoMap != null) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (null != tool.get(s)) {
|
|
if (tool.get(s).contains(",")) {
|
|
for (String e : tool.get(s).split(",")) {
|
|
stringBuilder.append(dict.get(e)+",");
|
|
}
|
|
} else {
|
|
stringBuilder.append(dict.get(tool.get(s))+",");
|
|
}
|
|
bussAttrInfoMap.put("SYRZ", stringBuilder.toString().substring(0,stringBuilder.length()-1));
|
|
} else {
|
|
bussAttrInfoMap.put("SYRZ", "");
|
|
}
|
|
}
|
|
sarStandardsInfo.setSarStandAttrEOStr(JSONObject.toJSONString(bussAttrInfoMap));
|
|
try {
|
|
sarStandardsInfoService.updateSarStandardsInfo(sarStandardsInfo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
QueryWrapper<SarLawsStandInfo> wrapper1 = new QueryWrapper<>();
|
|
wrapper1.eq("ID", s);
|
|
List<SarLawsStandInfo> infos1 = lawsStandInfoService.list(wrapper1);
|
|
if (null != infos1 && infos1.size() > 0) {
|
|
SarLawsStandInfo sarLawsStandInfo = new SarLawsStandInfo();
|
|
sarLawsStandInfo.setId(s);
|
|
sarLawsStandInfo.setIsRelateAccess("2");
|
|
sarLawsStandInfo.setModifyTime(new Date());
|
|
Map<String, Object> bussAttrInfoMap = lawsAttrInfoService.getBussAttrInfo(s);
|
|
if (bussAttrInfoMap != null) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (null != tool.get(s)) {
|
|
if (tool.get(s).contains(",")) {
|
|
for (String e : tool.get(s).split(",")) {
|
|
stringBuilder.append(dict.get(e)+",");
|
|
}
|
|
} else {
|
|
stringBuilder.append(dict.get(tool.get(s))+",");
|
|
}
|
|
} else {
|
|
bussAttrInfoMap.put("SYRZ", "");
|
|
}
|
|
bussAttrInfoMap.put("SYRZ", stringBuilder.toString().substring(0,stringBuilder.length()-1));
|
|
sarLawsStandInfo.setSarStandAttrEOStr(JSONObject.toJSONString(bussAttrInfoMap));
|
|
try {
|
|
lawsStandInfoService.updateSarLawsStandInfo(sarLawsStandInfo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
add.forEach(s -> {
|
|
QueryWrapper<SarStandardsInfo> wrapper = new QueryWrapper<>();
|
|
wrapper.eq("ID", s);
|
|
List<SarStandardsInfo> infos = sarStandardsInfoService.list(wrapper);
|
|
if (null != infos && infos.size() > 0) {
|
|
SarStandardsInfo sarStandardsInfo = new SarStandardsInfo();
|
|
sarStandardsInfo.setId(s);
|
|
sarStandardsInfo.setIsRelateAccess("1");
|
|
sarStandardsInfo.setModifyTime(new Date());
|
|
Map<String, Object> bussAttrInfoMap = iSarStandAttrInfoService.getBussAttrInfo(s);
|
|
if (bussAttrInfoMap != null) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (null != tool.get(s)) {
|
|
if (tool.get(s).contains(",")) {
|
|
for (String e : tool.get(s).split(",")) {
|
|
stringBuilder.append(dict.get(e)+",");
|
|
}
|
|
} else {
|
|
stringBuilder.append(dict.get(tool.get(s))+",");
|
|
}
|
|
bussAttrInfoMap.put("SYRZ",stringBuilder.toString().substring(0,stringBuilder.length()-1) );
|
|
} else {
|
|
bussAttrInfoMap.put("SYRZ", "");
|
|
}
|
|
sarStandardsInfo.setSarStandAttrEOStr(JSONObject.toJSONString(bussAttrInfoMap));
|
|
try {
|
|
sarStandardsInfoService.updateSarStandardsInfo(sarStandardsInfo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
QueryWrapper<SarLawsStandInfo> wrapper1 = new QueryWrapper<>();
|
|
wrapper.eq("ID", s);
|
|
List<SarLawsStandInfo> infos1 = lawsStandInfoService.list(wrapper1);
|
|
if (null != infos1 && infos1.size() > 0) {
|
|
SarLawsStandInfo sarLawsStandInfo = new SarLawsStandInfo();
|
|
sarLawsStandInfo.setId(s);
|
|
sarLawsStandInfo.setIsRelateAccess("1");
|
|
sarLawsStandInfo.setModifyTime(new Date());
|
|
Map<String, Object> bussAttrInfoMap = lawsAttrInfoService.getBussAttrInfo(s);
|
|
if (bussAttrInfoMap != null) {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (null != tool.get(s)) {
|
|
if (tool.get(s).contains(",")) {
|
|
for (String e : tool.get(s).split(",")) {
|
|
stringBuilder.append(dict.get(e)+",");
|
|
}
|
|
} else {
|
|
stringBuilder.append(dict.get(tool.get(s))+",");
|
|
}
|
|
bussAttrInfoMap.put("SYRZ", stringBuilder.toString().substring(0,stringBuilder.length()-1));
|
|
} else {
|
|
bussAttrInfoMap.put("SYRZ", "");
|
|
}
|
|
sarLawsStandInfo.setSarStandAttrEOStr(JSONObject.toJSONString(bussAttrInfoMap));
|
|
try {
|
|
lawsStandInfoService.updateSarLawsStandInfo(sarLawsStandInfo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
}
|