feat: There is no way the Buss and Convert
This commit is contained in:
@@ -0,0 +1,290 @@
|
||||
package com.adc.da.mq;
|
||||
|
||||
import com.adc.da.slrs.otSvpps.service.IOtSvppsService;
|
||||
import com.adc.da.slrs.sarBussionessStand.entity.SarBussionessStand;
|
||||
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
|
||||
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
|
||||
import com.adc.da.sys.dao.DicTypeEODao;
|
||||
import com.adc.da.utils.util.InitStandAttrUtil;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.json.JSONTokener;
|
||||
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.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class SendBussMQService {
|
||||
|
||||
@Autowired
|
||||
private ISarStandardsInfoService sarStandardsInfoService;
|
||||
|
||||
@Autowired
|
||||
private SysInfoEOService sysInfoEOService;
|
||||
|
||||
@Autowired
|
||||
private DicTypeEODao dicTypeEODao;
|
||||
|
||||
@Autowired
|
||||
private IOtSvppsService otSvppsEOService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SendBussMQService.class);
|
||||
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = "createBussMQ_SQ_GSAR", durable = "true"),
|
||||
exchange = @Exchange(value = "buss-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
|
||||
key = "buss-key_SQ_GSAR"))
|
||||
public void createMQ(Map<String,Object> bussMap, Message message, Channel channel) throws Exception{
|
||||
try{
|
||||
try{
|
||||
Thread.sleep(5000);
|
||||
insertOrUpdateBussInfo(bussMap);
|
||||
}catch(InterruptedException e){
|
||||
logger.error(e.toString());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("搜索中心企业标准消息队列进入转换前失败!");
|
||||
logger.error(e.getMessage(),e);
|
||||
} finally {
|
||||
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
|
||||
channel.basicAck(tag,false);
|
||||
logger.debug("消息确认成功!!!!!!!!!");
|
||||
}
|
||||
}
|
||||
|
||||
public void insertOrUpdateBussInfo(Map<String,Object> bussMap) throws Exception {
|
||||
String addOrUpdate = bussMap.get("addOrUpdate").toString();
|
||||
String FZRQFSRQ = null;
|
||||
if ("updateFromAct".equals(addOrUpdate)){
|
||||
addOrUpdate = "update";
|
||||
FZRQFSRQ = "1";
|
||||
}
|
||||
String sarBuss = bussMap.get("sarBuss").toString();
|
||||
JSONObject jsonobject = JSONObject.fromObject(sarBuss);
|
||||
SarBussionessStand infoEO = (SarBussionessStand) JSONObject.toBean(jsonobject, SarBussionessStand.class);
|
||||
String jsonobject1 = infoEO.getSarStandAttrEOStr();
|
||||
Map<String,Object> map1 = new HashMap<>();
|
||||
if (StringUtils.isEmpty(jsonobject1)){
|
||||
map1.put("null","null");
|
||||
}else {
|
||||
map1 = JSONObject.fromObject(jsonobject1);
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
//修改索引信息表
|
||||
// 往索引表中插入数据
|
||||
String baseSearchContent = "";
|
||||
String getCodeName = "";
|
||||
Map<String,Object> saveMap = new HashMap<>();
|
||||
String a = null;
|
||||
try{
|
||||
a = sdf.format(infoEO.getIssueTime());
|
||||
saveMap.put("issue_time"," "+a);
|
||||
}catch (Exception e){
|
||||
saveMap.put("issue_time"," ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//发布日期 高级查询
|
||||
Date issue_time_data = null;
|
||||
if (StringUtils.isNotBlank(a)) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
issue_time_data = format.parse(saveMap.get("issue_time")+" 00:00:00");
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
}
|
||||
if (issue_time_data != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(issue_time_data);
|
||||
int month = calendar.get(Calendar.MONTH)+1;
|
||||
String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
|
||||
saveMap.put("issue_time_data",Long.valueOf(times));
|
||||
}else{
|
||||
saveMap.put("issue_time_data",-1000000000000000000L);
|
||||
}
|
||||
|
||||
try{
|
||||
saveMap.put("put_time"," "+ sdf.format(infoEO.getPutTime()));
|
||||
}catch (Exception e){
|
||||
saveMap.put("put_time"," ");
|
||||
}
|
||||
|
||||
//实施日期 高级查询
|
||||
Date put_time_data = null;
|
||||
if (StringUtils.isNotBlank(a)) {
|
||||
try {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
put_time_data = format.parse(saveMap.get("put_time")+" 00:00:00");
|
||||
} catch (ParseException ignored) {
|
||||
}
|
||||
}
|
||||
if (put_time_data != null) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(put_time_data);
|
||||
int month = calendar.get(Calendar.MONTH)+1;
|
||||
String times = calendar.get(Calendar.YEAR) + String.format("%02d", month) + String.format("%02d",calendar.get(Calendar.DAY_OF_MONTH));
|
||||
saveMap.put("put_time_data",Long.valueOf(times));
|
||||
}else{
|
||||
saveMap.put("put_time_data",-1000000000000000000L);
|
||||
}
|
||||
// saveMap.put("put_time",sdf.format(infoEO.getPutTime()));
|
||||
|
||||
saveMap.put("id",infoEO.getId());
|
||||
saveMap.put("standSort",infoEO.getStandSort());
|
||||
saveMap.put("stand_sort",infoEO.getStandSort());
|
||||
if(StringUtils.isNotEmpty(infoEO.getStandSort())){
|
||||
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort());
|
||||
saveMap.put("standSortShow",codeName);
|
||||
getCodeName = codeName;
|
||||
}
|
||||
saveMap.put("standYear",infoEO.getStandYear());
|
||||
saveMap.put("stand_year",infoEO.getStandYear());
|
||||
saveMap.put("standNumber",infoEO.getStandCode());
|
||||
saveMap.put("stand_code",infoEO.getStandCode());
|
||||
saveMap = dealNumberMsg(saveMap,infoEO,getCodeName);
|
||||
saveMap.put("nameshow",infoEO.getStandName());
|
||||
saveMap.put("stand_name",infoEO.getStandName());
|
||||
saveMap.put("standEnName",infoEO.getStandEnName());
|
||||
saveMap.put("stand_en_name",infoEO.getStandEnName());
|
||||
saveMap.put("replaceStandNum",infoEO.getReplaceStandNum());
|
||||
saveMap.put("replace_stand_num",infoEO.getReplaceStandNum());
|
||||
saveMap.put("replacedStandNum",infoEO.getReplacedStandNum());
|
||||
saveMap.put("replaced_stand_num",infoEO.getReplacedStandNum());
|
||||
saveMap.put("statecode",infoEO.getStandStatus());
|
||||
saveMap.put("stand_status",infoEO.getStandStatus());
|
||||
if (StringUtils.isNotEmpty(infoEO.getStandStatus())) {
|
||||
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandStatus());
|
||||
saveMap.put("standstateshow",codeName);
|
||||
}
|
||||
//新加字段
|
||||
saveMap.put("country",infoEO.getApplyCountry());
|
||||
if(StringUtils.isNotEmpty(infoEO.getApplyCountry())){
|
||||
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getApplyCountry());
|
||||
saveMap.put("countryShow",codeName);
|
||||
}
|
||||
// 自定义属性字段
|
||||
String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
|
||||
Map<String,Object> attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
|
||||
Map<String,Object> infoMap = infoEO.getAttrInfoMap();
|
||||
|
||||
if (attrInfoMap != null && !attrInfoMap.isEmpty()) {
|
||||
attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "stand",baseSearchContent);
|
||||
saveMap.putAll(attrInfoMap);
|
||||
}
|
||||
|
||||
saveMap.put("type","bussstand");
|
||||
saveMap.put("validFlag","0");
|
||||
saveMap.put("content",infoEO.getFileIds());
|
||||
|
||||
String fieldInfo = InitStandAttrUtil.queryField;
|
||||
List<String> fieldInfoList = Arrays.asList(fieldInfo .split(",")).stream().map(s -> (s.trim())).collect(Collectors.toList());
|
||||
|
||||
// 动态存储属性字段
|
||||
for (String field : fieldInfoList) {
|
||||
saveMap.put(field,attrInfoMap.getOrDefault(field,""));
|
||||
String fieldValue = "";
|
||||
if(infoMap.get(field) != null && StringUtils.isNotBlank(infoMap.get(field).toString())){
|
||||
Object json= new JSONTokener(infoMap.get(field).toString()).nextValue();
|
||||
if(!json.toString().equals("null")){
|
||||
fieldValue = infoMap.get(field).toString();
|
||||
}
|
||||
}
|
||||
saveMap.put(field+"Name",fieldValue);
|
||||
}
|
||||
|
||||
//当建立代替时,产生的没有文件的问题
|
||||
if (StringUtils.isBlank(String.valueOf(saveMap.get("content")))) {
|
||||
String context = filterStringIsNotBlank(String.valueOf(saveMap.get("FBGBUSS")),true)
|
||||
+ filterStringIsNotBlank(String.valueOf(saveMap.get("BZSMBUSS")),true)
|
||||
+ filterStringIsNotBlank(String.valueOf(saveMap.get("LSBBBUSS")),true)
|
||||
+ filterStringIsNotBlank(String.valueOf(saveMap.get("QTWJBUSS")),true)
|
||||
+ filterStringIsNotBlank(String.valueOf(saveMap.get("GLWJBUSS")),true);
|
||||
context = context.replace(",,", ",");
|
||||
saveMap.put("content", context);
|
||||
}
|
||||
if("add".equals(addOrUpdate)){
|
||||
sarStandardsInfoService.insertIntoIndexForMap(saveMap);
|
||||
} else {
|
||||
sarStandardsInfoService.updateIntoIndexForMap(saveMap);
|
||||
}
|
||||
}
|
||||
|
||||
private String filterStringIsNotBlank(String str,boolean boo){
|
||||
String f = ",";
|
||||
return (str == null || str.equals("") || str.equals("null")) ? "" : (boo ? str+f : str);
|
||||
}
|
||||
|
||||
private String dateFormatToStr(String dateStr){
|
||||
if(dateStr == null || dateStr.equals("")){
|
||||
return "";
|
||||
}
|
||||
String dateToStr = "";
|
||||
try {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
dateToStr = dateFormat.format(dateFormat.parse(dateStr.trim().substring(0,10)));
|
||||
}catch (Exception e){
|
||||
e.getMessage();
|
||||
}
|
||||
return dateToStr;
|
||||
}
|
||||
|
||||
public Map<String,Object> dealNumberMsg (Map<String,Object> saveMap,SarBussionessStand infoEO,String getCodeName) {
|
||||
/*if(StringUtils.isNotEmpty(infoEO.getStandYear())){
|
||||
String num = getCodeName + " " + infoEO.getStandCode() + "-" + infoEO.getStandYear();
|
||||
saveMap.put("numbershow",num);
|
||||
int index = infoEO.getStandCode().indexOf(".");
|
||||
int index1 = infoEO.getStandCode().indexOf(":");
|
||||
String numberExpNull = "";
|
||||
if(index > -1){
|
||||
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
|
||||
}else if(index1 > -1){
|
||||
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index1) + "-" + infoEO.getStandCode().substring(0,index1);
|
||||
}else{
|
||||
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + num.replaceAll(" ","");
|
||||
}
|
||||
} else {
|
||||
String number = getCodeName + " " + infoEO.getStandCode();
|
||||
saveMap.put("numbershow",number);
|
||||
String numberExpNull = "";
|
||||
int index = infoEO.getStandCode().indexOf(".");
|
||||
if(index > -1){
|
||||
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","")
|
||||
+ "-" + getCodeName + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
|
||||
}else{
|
||||
numberExpNull = getCodeName + infoEO.getStandCode() + "-" + number.replaceAll(" ","");
|
||||
}
|
||||
saveMap.put("numberExpNull",numberExpNull);
|
||||
}*/
|
||||
String number = infoEO.getStandCode();
|
||||
saveMap.put("numbershow",number);
|
||||
String numberExpNull = "";
|
||||
int index = infoEO.getStandCode().indexOf(".");
|
||||
if(index > -1){
|
||||
numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","")
|
||||
+ "-" + infoEO.getStandCode().substring(0,index) + "-" + infoEO.getStandCode().substring(0,index);
|
||||
}else{
|
||||
numberExpNull = infoEO.getStandCode() + "-" + number.replaceAll(" ","");
|
||||
}
|
||||
saveMap.put("numberExpNull",numberExpNull);
|
||||
return saveMap;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user