提交修改
This commit is contained in:
parent
f80c846ab9
commit
3dccd71916
@ -10,13 +10,14 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author wutao
|
||||
* @description mq配置
|
||||
* @date 2020-12-25
|
||||
*/
|
||||
//@Configuration
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class RabbitConfig {
|
||||
|
||||
|
||||
@ -6,9 +6,11 @@ import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.constants.RedisConstans;
|
||||
import com.heyu.api.data.dao.api.ApiPostCodeDao;
|
||||
import com.heyu.api.data.dao.calca.CalcaAccountDao;
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
import com.heyu.api.data.entity.calca.CalcaAccountEntity;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.data.utils.RedisUtils;
|
||||
import com.heyu.api.data.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -187,6 +189,9 @@ public class TestController{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
@ -207,4 +212,64 @@ public class TestController{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// http://localhost:8888/app/test/email2?key=AD
|
||||
@RequestMapping("/email2")
|
||||
public R email2(String key ) throws Exception {
|
||||
String fileName = "/Users/quyixiao/Desktop/"+key+"/"+key+".txt";
|
||||
|
||||
// 读取文件内容到Stream流中,按行读取
|
||||
Stream<String> lines = Files.lines(Paths.get(fileName));
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
|
||||
// 随机行顺序进行数据处理
|
||||
lines.forEach(ele -> {
|
||||
|
||||
String a[] = ele.split("\t");
|
||||
String b[] = new String[12];
|
||||
if (a != null && a.length == 11){
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
b[i] = a[i];
|
||||
}
|
||||
b[11] = "";
|
||||
a = b ;
|
||||
}
|
||||
|
||||
|
||||
if (a != null && a.length == 12) {
|
||||
ApiPostCodeEntity apiPostCodeEntity = new ApiPostCodeEntity();
|
||||
apiPostCodeEntity.setParam1(getValue(a[0]));
|
||||
apiPostCodeEntity.setParam2(getValue(a[1]));
|
||||
apiPostCodeEntity.setParam3(getValue(a[2]));
|
||||
apiPostCodeEntity.setParam4(getValue(a[3]));
|
||||
apiPostCodeEntity.setParam5(getValue(a[4]));
|
||||
apiPostCodeEntity.setParam6(getValue(a[5]));
|
||||
apiPostCodeEntity.setParam7(getValue(a[6]));
|
||||
apiPostCodeEntity.setParam8(getValue(a[7]));
|
||||
apiPostCodeEntity.setParam9(getValue(a[8]));
|
||||
apiPostCodeEntity.setParam10(getValue(a[9]));
|
||||
apiPostCodeEntity.setParam11(getValue(a[10]));
|
||||
apiPostCodeEntity.setParam12(getValue(a[11]));
|
||||
|
||||
rabbitTemplate.convertAndSend(accountLogNameQueue, JSON.toJSONString(apiPostCodeEntity));
|
||||
}
|
||||
});
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
public String getValue(String value ) {
|
||||
if(StringUtils.isBlank(value)){
|
||||
return "null";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -11,9 +11,10 @@ import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
//@Component
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PostCodeQueueSimpleRabbitListener {
|
||||
|
||||
@ -22,13 +23,13 @@ public class PostCodeQueueSimpleRabbitListener {
|
||||
private ApiPostCodeDao apiPostCodeDao;
|
||||
|
||||
@RabbitHandler
|
||||
@RabbitListener(queues = "#{accountAmountQueue.name}", containerFactory = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
||||
@RabbitListener(queues = "#{postCodeDataNameQueue.name}", containerFactory = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
||||
public void consumeMessage(@Payload String message, @Header(AmqpHeaders.DELIVERY_TAG) long delivertTag, Channel channel) {
|
||||
try {
|
||||
ApiPostCodeEntity apiPostCodeEntity = JSON.parseObject(message, ApiPostCodeEntity.class);
|
||||
apiPostCodeDao.insertApiPostCode(apiPostCodeEntity);
|
||||
} catch (Exception e) {
|
||||
log.error("exception e", e);
|
||||
log.error("exception e " + message, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,10 +34,10 @@ spring:
|
||||
host: 121.40.41.240
|
||||
timeout: 5000
|
||||
rabbitmq:
|
||||
host: 172.16.5.230
|
||||
port: 15672
|
||||
username: user
|
||||
password: dk_eP^#fkLf30
|
||||
host: rabit.iwulin.tech
|
||||
port: 32407
|
||||
username: admin
|
||||
password: Ij_klfJ^$^_3IBs
|
||||
listener:
|
||||
simple:
|
||||
# 设置手动ack回复
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user