提交修改
This commit is contained in:
parent
c57fee601b
commit
f80c846ab9
@ -56,7 +56,11 @@ public class MyBatisBaomidouServiceImpl implements MyBatisBaomidouService {
|
||||
|
||||
@Override
|
||||
public void info(String info) {
|
||||
// log.info(info);
|
||||
if(info.contains("api_post_code")){
|
||||
|
||||
}
|
||||
|
||||
// log.info(info);
|
||||
if (log.isDebugEnabled()) {
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
|
||||
package com.heyu.api.data.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.core.AcknowledgeMode;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author wutao
|
||||
* @description mq配置
|
||||
* @date 2020-12-25
|
||||
*/
|
||||
//@Configuration
|
||||
@Slf4j
|
||||
public class RabbitConfig {
|
||||
|
||||
@Autowired
|
||||
private CachingConnectionFactory connectionFactory;
|
||||
|
||||
@Bean
|
||||
public RabbitTemplate rabbitTemplate(){
|
||||
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
|
||||
rabbitTemplate.setConfirmCallback((correlationData,ack,cause)->{
|
||||
if(ack){
|
||||
log.info("消息发送成功 {}", correlationData);
|
||||
}else {
|
||||
log.info("消息发送到Exchange失败, {}, cause: {}", correlationData, cause);
|
||||
}
|
||||
});
|
||||
rabbitTemplate.setMandatory(true);
|
||||
rabbitTemplate.setReturnCallback(((message, replyCode, replyText, exchange, routingKey) -> {
|
||||
log.info("消息从Exchange路由到Queue失败: exchange: {}, route: {}, replyCode: {}, replyText: {}, message: {}", exchange, routingKey, replyCode, replyText, message);
|
||||
}));
|
||||
return rabbitTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue accountAmountQueue(@Value("${eb.config.rabbitQueue.accountAmountQueue}") String queueName) {
|
||||
return new Queue(queueName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean(name = "accountAmountQueueSimpleRabbitListenerContainerFactory")
|
||||
public SimpleRabbitListenerContainerFactory accountAmountQueueSimpleRabbitListenerContainerFactory() {
|
||||
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
||||
listenerContainerFactory.setConnectionFactory(connectionFactory);
|
||||
listenerContainerFactory.setConcurrentConsumers(50);
|
||||
listenerContainerFactory.setMaxConcurrentConsumers(100);
|
||||
listenerContainerFactory.setPrefetchCount(20);//预处理消息个数
|
||||
listenerContainerFactory.setAcknowledgeMode(AcknowledgeMode.MANUAL);//开启消息确认机制
|
||||
return listenerContainerFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue accountLogNameQueue(@Value("${eb.config.rabbitQueue.accountLogName}") String queueName) {
|
||||
return new Queue(queueName);
|
||||
}
|
||||
|
||||
|
||||
@Bean(name = "accountLogNameQueueSimpleRabbitListenerContainerFactory")
|
||||
public SimpleRabbitListenerContainerFactory accountLogNameQueueSimpleRabbitListenerContainerFactory() {
|
||||
SimpleRabbitListenerContainerFactory listenerContainerFactory = new SimpleRabbitListenerContainerFactory();
|
||||
listenerContainerFactory.setConnectionFactory(connectionFactory);
|
||||
listenerContainerFactory.setConcurrentConsumers(50);
|
||||
listenerContainerFactory.setMaxConcurrentConsumers(100);
|
||||
listenerContainerFactory.setPrefetchCount(20);//预处理消息个数
|
||||
listenerContainerFactory.setAcknowledgeMode(AcknowledgeMode.MANUAL);//开启消息确认机制
|
||||
return listenerContainerFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue postCodeDataNameQueue(@Value("${eb.config.rabbitQueue.postCodeData}") String queueName) {
|
||||
return new Queue(queueName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package com.heyu.api.data.dao.api;
|
||||
/**
|
||||
* <p>
|
||||
* 结果表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface ApiPostCodeDao extends BaseMapper<ApiPostCodeEntity> {
|
||||
|
||||
|
||||
ApiPostCodeEntity selectApiPostCodeById(@Param("id")Long id);
|
||||
|
||||
|
||||
Long insertApiPostCode(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
Long insertOrUpdateApiPostCode(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int updateApiPostCodeById(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int updateCoverApiPostCodeById(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int deleteApiPostCodeById(@Param("id")Long id);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,334 @@
|
||||
package com.heyu.api.data.entity.api;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.lz.mybatis.plugin.annotations.AS;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;import java.util.Date;
|
||||
/**
|
||||
*结果表
|
||||
* @author quyixiao
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("api_post_code")
|
||||
public class ApiPostCodeEntity implements java.io.Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public final static String CLASS_NAME ="com.heyu.api.data.entity.api.ApiPostCodeEntity:";
|
||||
|
||||
public final static String all = CLASS_NAME + "*";
|
||||
public final static String id_ = CLASS_NAME + "id"; //
|
||||
public final static String is_delete = CLASS_NAME + "is_delete"; // 是否删除:0 否 1 删除
|
||||
public final static String create_time = CLASS_NAME + "create_time"; // 创建时间
|
||||
public final static String modify_time = CLASS_NAME + "modify_time"; // 修改时间
|
||||
public final static String param1_ = CLASS_NAME + "param1"; //
|
||||
public final static String param2_ = CLASS_NAME + "param2"; //
|
||||
public final static String param3_ = CLASS_NAME + "param3"; //
|
||||
public final static String param4_ = CLASS_NAME + "param4"; //
|
||||
public final static String param5_ = CLASS_NAME + "param5"; //
|
||||
public final static String param6_ = CLASS_NAME + "param6"; //
|
||||
public final static String param7_ = CLASS_NAME + "param7"; //
|
||||
public final static String param8_ = CLASS_NAME + "param8"; //
|
||||
public final static String param9_ = CLASS_NAME + "param9"; //
|
||||
public final static String param10_ = CLASS_NAME + "param10"; //
|
||||
public final static String param11_ = CLASS_NAME + "param11"; //
|
||||
public final static String param12_ = CLASS_NAME + "param12"; //
|
||||
//
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
//是否删除:0 否 1 删除
|
||||
private Integer isDelete;
|
||||
//创建时间
|
||||
private Date createTime;
|
||||
//修改时间
|
||||
private Date modifyTime;
|
||||
//
|
||||
private String param1;
|
||||
//
|
||||
private String param2;
|
||||
//
|
||||
private String param3;
|
||||
//
|
||||
private String param4;
|
||||
//
|
||||
private String param5;
|
||||
//
|
||||
private String param6;
|
||||
//
|
||||
private String param7;
|
||||
//
|
||||
private String param8;
|
||||
//
|
||||
private String param9;
|
||||
//
|
||||
private String param10;
|
||||
//
|
||||
private String param11;
|
||||
//
|
||||
private String param12;
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否删除:0 否 1 删除
|
||||
* @return
|
||||
*/
|
||||
public Integer getIsDelete() {
|
||||
return isDelete;
|
||||
}
|
||||
/**
|
||||
* 是否删除:0 否 1 删除
|
||||
* @param isDelete
|
||||
*/
|
||||
public void setIsDelete(Integer isDelete) {
|
||||
this.isDelete = isDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
* @return
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
/**
|
||||
* 创建时间
|
||||
* @param createTime
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
* @return
|
||||
*/
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
/**
|
||||
* 修改时间
|
||||
* @param modifyTime
|
||||
*/
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam1() {
|
||||
return param1;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param1
|
||||
*/
|
||||
public void setParam1(String param1) {
|
||||
this.param1 = param1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam2() {
|
||||
return param2;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param2
|
||||
*/
|
||||
public void setParam2(String param2) {
|
||||
this.param2 = param2;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam3() {
|
||||
return param3;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param3
|
||||
*/
|
||||
public void setParam3(String param3) {
|
||||
this.param3 = param3;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam4() {
|
||||
return param4;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param4
|
||||
*/
|
||||
public void setParam4(String param4) {
|
||||
this.param4 = param4;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam5() {
|
||||
return param5;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param5
|
||||
*/
|
||||
public void setParam5(String param5) {
|
||||
this.param5 = param5;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam6() {
|
||||
return param6;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param6
|
||||
*/
|
||||
public void setParam6(String param6) {
|
||||
this.param6 = param6;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam7() {
|
||||
return param7;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param7
|
||||
*/
|
||||
public void setParam7(String param7) {
|
||||
this.param7 = param7;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam8() {
|
||||
return param8;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param8
|
||||
*/
|
||||
public void setParam8(String param8) {
|
||||
this.param8 = param8;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam9() {
|
||||
return param9;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param9
|
||||
*/
|
||||
public void setParam9(String param9) {
|
||||
this.param9 = param9;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam10() {
|
||||
return param10;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param10
|
||||
*/
|
||||
public void setParam10(String param10) {
|
||||
this.param10 = param10;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam11() {
|
||||
return param11;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param11
|
||||
*/
|
||||
public void setParam11(String param11) {
|
||||
this.param11 = param11;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getParam12() {
|
||||
return param12;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param param12
|
||||
*/
|
||||
public void setParam12(String param12) {
|
||||
this.param12 = param12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApiPostCodeEntity{" +
|
||||
",id=" + id +
|
||||
",isDelete=" + isDelete +
|
||||
",createTime=" + createTime +
|
||||
",modifyTime=" + modifyTime +
|
||||
",param1=" + param1 +
|
||||
",param2=" + param2 +
|
||||
",param3=" + param3 +
|
||||
",param4=" + param4 +
|
||||
",param5=" + param5 +
|
||||
",param6=" + param6 +
|
||||
",param7=" + param7 +
|
||||
",param8=" + param8 +
|
||||
",param9=" + param9 +
|
||||
",param10=" + param10 +
|
||||
",param11=" + param11 +
|
||||
",param12=" + param12 +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.heyu.api.data.service.api;
|
||||
/**
|
||||
* <p>
|
||||
* 结果表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
public interface ApiPostCodeService extends IService<ApiPostCodeEntity> {
|
||||
|
||||
|
||||
|
||||
ApiPostCodeEntity selectApiPostCodeById(Long id);
|
||||
|
||||
|
||||
Long insertApiPostCode(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
Long insertOrUpdateApiPostCode(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int updateApiPostCodeById(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int updateCoverApiPostCodeById(ApiPostCodeEntity apiPostCode);
|
||||
|
||||
|
||||
int deleteApiPostCodeById(Long id);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.heyu.api.data.service.impl.api;
|
||||
/**
|
||||
* <p>
|
||||
* 结果表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author quyixiao
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.heyu.api.data.dao.api.ApiPostCodeDao;
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
import com.heyu.api.data.service.api.ApiPostCodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class ApiPostCodeServiceImpl extends ServiceImpl<ApiPostCodeDao, ApiPostCodeEntity> implements ApiPostCodeService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ApiPostCodeDao apiPostCodeDao;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ApiPostCodeEntity selectApiPostCodeById(Long id){
|
||||
return apiPostCodeDao.selectApiPostCodeById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insertApiPostCode(ApiPostCodeEntity apiPostCode){
|
||||
return apiPostCodeDao.insertApiPostCode(apiPostCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Long insertOrUpdateApiPostCode(ApiPostCodeEntity apiPostCode){
|
||||
return apiPostCodeDao.insertOrUpdateApiPostCode(apiPostCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateApiPostCodeById(ApiPostCodeEntity apiPostCode){
|
||||
return apiPostCodeDao.updateApiPostCodeById(apiPostCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateCoverApiPostCodeById(ApiPostCodeEntity apiPostCode){
|
||||
return apiPostCodeDao.updateCoverApiPostCodeById(apiPostCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteApiPostCodeById(Long id){
|
||||
return apiPostCodeDao.deleteApiPostCodeById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
57
api-mapper/src/main/java/com/heyu/api/data/utils/Node.java
Normal file
57
api-mapper/src/main/java/com/heyu/api/data/utils/Node.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.heyu.api.data.utils;
|
||||
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.concurrent.Delayed;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Data
|
||||
public class Node implements Delayed {
|
||||
|
||||
|
||||
private ApiPostCodeEntity apiPostCodeEntity;
|
||||
private Long time;
|
||||
|
||||
public Node() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Node(ApiPostCodeEntity apiPostCodeEntity, Long time ) {
|
||||
this.apiPostCodeEntity = apiPostCodeEntity;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getDelay(TimeUnit unit) {
|
||||
return time - System.nanoTime();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Delayed o) {
|
||||
if (this.time == null) {
|
||||
if (((Node) o).getTime() == null) { // this.time==null && o.time == null -> return 0
|
||||
return 0;
|
||||
}
|
||||
return -1; // this.time == null && o.time !=null -> return -1
|
||||
}
|
||||
if (((Node) o).getTime() == null) { // this.time !=null && o.time == null -> return 1
|
||||
return 1;
|
||||
}
|
||||
return (int) (this.time - ((Node) o).getTime()); // return this.time - o.time
|
||||
}
|
||||
|
||||
|
||||
public Long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.heyu.api.data.dao.api.ApiPostCodeDao">
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -93,7 +93,7 @@ public class MysqlMain_insert {
|
||||
System.out.println(MysqlMain_insert.save_path);
|
||||
List<TablesBean> list = new ArrayList<TablesBean>();
|
||||
|
||||
list.add(new TablesBean("api_result"));
|
||||
list.add(new TablesBean("api_post_code"));
|
||||
|
||||
|
||||
List<TablesBean> list2 = new ArrayList<TablesBean>();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.test.xxx.mysql;
|
||||
|
||||
import com.heyu.api.data.dao.api.ApiResultDao;
|
||||
import com.heyu.api.data.dao.api.ApiPostCodeDao;
|
||||
import com.lz.mybatis.plugin.utils.TestParseUtils;
|
||||
import com.lz.mybatis.plugin.utils.t.Tuple2;
|
||||
import org.junit.Test;
|
||||
@ -12,7 +12,8 @@ SqlParseUtilsTest {
|
||||
public void test1() {
|
||||
|
||||
|
||||
Tuple2<Boolean, String> tuple = TestParseUtils.testSql(ApiResultDao::selectApiResultByUri).getData();
|
||||
Tuple2<Boolean, String> tuple = TestParseUtils.testSql(ApiPostCodeDao::insertApiPostCode).getData();
|
||||
|
||||
|
||||
|
||||
System.out.println(tuple.getSecond());
|
||||
|
||||
@ -4,20 +4,30 @@ package com.heyu.api.controller;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.calca.CalcaAccountEntity;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.data.utils.RedisUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/app/test")
|
||||
@NotIntercept
|
||||
public class TestController {
|
||||
public class TestController{
|
||||
|
||||
@Autowired
|
||||
private CalcaAccountDao calcaAccountDao;
|
||||
@ -25,6 +35,21 @@ public class TestController {
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ApiPostCodeDao apiPostCodeDao;
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
|
||||
|
||||
@Value("${eb.config.rabbitQueue.postCodeData}")
|
||||
private String accountLogNameQueue;
|
||||
|
||||
|
||||
// http://localhost:8888/app/test/contractFile
|
||||
@RequestMapping("/contractFile")
|
||||
public R contractFile() {
|
||||
@ -43,4 +68,143 @@ public class TestController {
|
||||
}
|
||||
|
||||
|
||||
// http://localhost:8888/app/test/email?key=AX
|
||||
@RequestMapping("/email")
|
||||
public R email(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 -> {
|
||||
int max_length = 32;
|
||||
String value = "";
|
||||
int index = -1;
|
||||
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) {
|
||||
try {
|
||||
sb.append("INSERT INTO api_post_code ( is_delete, create_time, modify_time, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12) VALUES\n" +
|
||||
" ( 0, '2025-03-11 00:36:20', '2025-03-11 00:36:20'" +
|
||||
", '"+a[0] +"'" +
|
||||
", '"+a[1]+"'" +
|
||||
", '"+a[2]+"'" +
|
||||
", '"+a[3]+"'" +
|
||||
", '"+a[4]+"'" +
|
||||
", '"+a[5]+"'" +
|
||||
", '"+a[6]+"'" +
|
||||
", '"+a[7]+"'" +
|
||||
", '"+a[8]+"'" +
|
||||
", '"+a[9]+"'" +
|
||||
", '"+a[10]+"'" +
|
||||
", '"+a[11]+"');");
|
||||
|
||||
sb.append("\n");
|
||||
|
||||
if(a[0].length()>32){
|
||||
max_length = a[0].length();
|
||||
value = a[0];
|
||||
index = 0 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[1].length()>64){
|
||||
max_length = a[1].length();
|
||||
value = a[1];
|
||||
index = 1 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[2].length()>255){
|
||||
max_length = a[2].length();
|
||||
value = a[2];
|
||||
index = 2 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
|
||||
if(a[3].length()>64){
|
||||
max_length = a[3].length();
|
||||
value = a[3];
|
||||
index = 3 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
|
||||
if(a[4].length()>64){
|
||||
max_length = a[4].length();
|
||||
value = a[4];
|
||||
index = 4;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[5].length()>64){
|
||||
max_length = a[5].length();
|
||||
value = a[5];
|
||||
index = 5 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[6].length()>64){
|
||||
max_length = a[6].length();
|
||||
value = a[6];
|
||||
index = 6 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[7].length()>64){
|
||||
max_length = a[7].length();
|
||||
value = a[7];
|
||||
index = 7 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if(a[8].length()>64){
|
||||
max_length = a[8].length();
|
||||
value = a[8];
|
||||
index = 8 ;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if (a[9].length() > 32) {
|
||||
max_length = a[9].length();
|
||||
value = a[9];
|
||||
index = 9;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if (a[10].length() > 32) {
|
||||
max_length = a[10].length();
|
||||
value = a[10];
|
||||
index = 10;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
if (a[11].length() > 32) {
|
||||
max_length = a[11].length();
|
||||
value = a[11];
|
||||
index = 11;
|
||||
System.out.println(" max_length:" + max_length + ",value:" + value + ",index:" + index);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.info("数据格式不正确 : " + ele + ",length" + a.length );
|
||||
}
|
||||
});
|
||||
String newFile = "/Users/quyixiao/Desktop/post_code.sql";
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
|
||||
Writer out = new OutputStreamWriter(fos, "UTF-8");
|
||||
out.write(sb.toString());
|
||||
out.close();
|
||||
fos.close();
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.heyu.api.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.data.dao.api.ApiPostCodeDao;
|
||||
import com.heyu.api.data.entity.api.ApiPostCodeEntity;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
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;
|
||||
|
||||
|
||||
//@Component
|
||||
@Slf4j
|
||||
public class PostCodeQueueSimpleRabbitListener {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ApiPostCodeDao apiPostCodeDao;
|
||||
|
||||
@RabbitHandler
|
||||
@RabbitListener(queues = "#{accountAmountQueue.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,7 +34,7 @@ spring:
|
||||
host: 121.40.41.240
|
||||
timeout: 5000
|
||||
rabbitmq:
|
||||
host: 121.40.41.240
|
||||
host: 172.16.5.230
|
||||
port: 15672
|
||||
username: user
|
||||
password: dk_eP^#fkLf30
|
||||
|
||||
@ -53,6 +53,7 @@ eb:
|
||||
rabbitQueue:
|
||||
accountAmountQueue: ACCOUNT_AMOUNT_QUEUE_NAME
|
||||
accountLogName: ACCOUNT_LOG_NAME
|
||||
postCodeData: post_code_data
|
||||
|
||||
|
||||
tencent:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user