I2代码优化ceshi

master
liuguijing 1 year ago
parent 4a2096b570
commit 82f307293f

@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigInteger; import java.math.BigInteger;
@ -20,6 +21,7 @@ import java.util.List;
@Slf4j @Slf4j
@Component @Component
@EnableAsync
public class AsyncMethod { public class AsyncMethod {
@Autowired @Autowired
private Data_Dlq_JbfdDao data_dlq_jbfdDao; private Data_Dlq_JbfdDao data_dlq_jbfdDao;
@ -164,7 +166,7 @@ public class AsyncMethod {
} }
} }
// @Async(value = "asyncServiceExecutor") @Async(value = "asyncServiceExecutor")
public void sendData2(Client client, String xml) throws Exception { public void sendData2(Client client, String xml) throws Exception {
Object[] objects = client.invoke("uploadCACData", xml); Object[] objects = client.invoke("uploadCACData", xml);
String threadId = Thread.currentThread().getName(); String threadId = Thread.currentThread().getName();

@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.cxf.endpoint.Client; import org.apache.cxf.endpoint.Client;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -31,6 +32,7 @@ import java.util.List;
@Service @Service
@Slf4j @Slf4j
@EnableAsync
public class XydlI2ServiceImpl implements XydlI2Service { public class XydlI2ServiceImpl implements XydlI2Service {
@Autowired @Autowired
@ -88,7 +90,7 @@ public class XydlI2ServiceImpl implements XydlI2Service {
// @Value("${webservice.sendlimit}") // @Value("${webservice.sendlimit}")
// public int sendlimit; // public int sendlimit;
public static int sendlimit = 500; public static int sendlimit = 1000;
@Override @Override
public void upload_byq_jbfd(Client client, HashMap<Integer, Niec_Sensors> equipMap) { public void upload_byq_jbfd(Client client, HashMap<Integer, Niec_Sensors> equipMap) {
@ -558,7 +560,6 @@ public class XydlI2ServiceImpl implements XydlI2Service {
String cacdata = GenerateI2Xml.generateCacXml(Constant.DRJYJC, sensorid, equipmentid, timestamp, attrlist); String cacdata = GenerateI2Xml.generateCacXml(Constant.DRJYJC, sensorid, equipmentid, timestamp, attrlist);
cacdatalist.add(cacdata); cacdatalist.add(cacdata);
if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) {
ArrayList<BigInteger> list1 = new ArrayList<>();
String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); String xml = GenerateI2Xml.generateEndCacXml(cacdatalist);
asyncMethod.sendData2(client, xml); asyncMethod.sendData2(client, xml);
cacdatalist = new ArrayList<>(); cacdatalist = new ArrayList<>();
@ -1499,7 +1500,6 @@ public class XydlI2ServiceImpl implements XydlI2Service {
maxid = ids; maxid = ids;
} }
} }
YxAttrBean<Integer> attr = new YxAttrBean<>(); YxAttrBean<Integer> attr = new YxAttrBean<>();
attr.setSensorid(sensorid); attr.setSensorid(sensorid);
attr.setEquipmentid(equipmentid); attr.setEquipmentid(equipmentid);

@ -17,7 +17,7 @@ import org.springframework.stereotype.Component;
@Component @Component
@EnableScheduling @EnableScheduling
@Slf4j @Slf4j
@EnableAsync //@EnableAsync
public class ScheduledTask { public class ScheduledTask {
@Autowired @Autowired
@ -33,7 +33,7 @@ public class ScheduledTask {
webservcies.uploadyspData(); webservcies.uploadyspData();
} }
@Scheduled(fixedDelay = 10 * 60 * 1000) @Scheduled(fixedDelay = 5 * 60 * 1000)
public void cacjfjcupload() { public void cacjfjcupload() {
log.info("cacjfjcupload执行" ); log.info("cacjfjcupload执行" );
webservcies.uploadjfjcData(); webservcies.uploadjfjcData();

@ -22,30 +22,19 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
druid: druid:
# 主库数据源 # 主库数据源
master:
# url: jdbc:mysql://192.168.200.63:3306/xymp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# username: xymp
# password: xymp@123
url: jdbc:mysql://127.0.0.1:3306/iec104?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:3306/iec104?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: 123456 password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数 # 初始连接数
initialSize: 20 initialSize: 10
# 最小连接池数量 # 最小连接池数量
minIdle: 20 minIdle: 20
# 最大连接池数量 # 最大连接池数量
maxActive: 40 maxActive: 50
# 配置获取连接等待超时的时间 # 配置获取连接等待超时的时间
maxWait: 60000 maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000 timeBetweenEvictionRunsMillis: 30000
# 配置一个连接在池中最小生存的时间,单位是毫秒 # 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒 # 配置一个连接在池中最大生存的时间,单位是毫秒

Loading…
Cancel
Save