feat: There is no way the Buss and Convert
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.adc.da.mq;
|
||||
|
||||
import com.adc.da.slrs.otConvertMq.dao.OtConvertMqDao;
|
||||
import com.adc.da.slrs.otConvertMq.entity.OtConvertMq;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CreateMQService {
|
||||
@Autowired
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
||||
@Autowired
|
||||
private OtConvertMqDao otConvertEODao;
|
||||
/**
|
||||
* @Author yangxuenan
|
||||
* @Description 创建消息队列
|
||||
* Date 2018/8/24 13:59
|
||||
* @Param [convert, convertType]
|
||||
* @return int
|
||||
**/
|
||||
public void sendMQ(OtConvertMq convert) throws Exception{
|
||||
String otId = UUIDUtils.randomUUID20();
|
||||
//向OT_CONVERT_EO表中添加/修改数据
|
||||
//判断用户是初次发送还是重新发送,初次将添加到数据库,重新发送将修改原数据信息
|
||||
convert.setMqState(0);
|
||||
convert.setModifyTime(new Date());
|
||||
if("0".equals(convert.getAddOrUp()) && StringUtils.isEmpty(convert.getId())){
|
||||
convert.setId(otId);
|
||||
convert.setMqCode(convert.getConvertType());
|
||||
convert.setCreationTime(new Date());
|
||||
convert.setValidFlag(0);
|
||||
otConvertEODao.insert(convert);
|
||||
} else {
|
||||
otConvertEODao.updateById(convert);
|
||||
}
|
||||
|
||||
//将数据信息保存并发送给消息队列
|
||||
Map<String,Object> convertInfo = new HashMap<String,Object>();
|
||||
//标准/政策ID
|
||||
convertInfo.put("lawsId", convert.getLawsId());
|
||||
//标准/政策关联的res表ID
|
||||
convertInfo.put("resId", convert.getResId());
|
||||
//文档的ID
|
||||
convertInfo.put("attId", convert.getAttId());
|
||||
//判断当前操作是新增还是修改
|
||||
convertInfo.put("addUpFlag", convert.getAddOrUp());
|
||||
//资源类型(标准,政策,企标)
|
||||
convertInfo.put("convertType", convert.getConvertType());
|
||||
//文档路径
|
||||
convertInfo.put("path", convert.getFilePath());
|
||||
convertInfo.put("standFileClassify", convert.getStandFileClassify());
|
||||
convertInfo.put("lawsFileClassify", convert.getLawsFileClassify());
|
||||
if("0".equals(convert.getAddOrUp())){
|
||||
//otId在转换表中数据ID
|
||||
convertInfo.put("otId", otId);
|
||||
//在stand_file等资源与文件关联表中转换成功的pdf数据ID
|
||||
convertInfo.put("standFilePdfId", UUIDUtils.randomUUID20());
|
||||
convertInfo.put("againNum",0);
|
||||
} else {
|
||||
convertInfo.put("otId", convert.getId());
|
||||
convertInfo.put("standFilePdfId", convert.getPdfId());
|
||||
convertInfo.put("againNum",convert.getAgainNum());
|
||||
}
|
||||
|
||||
//发送消息队列
|
||||
this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", convertInfo);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user