From 9d08b1aaf88b835aab1f191ea55dcd1ce9a52f7d Mon Sep 17 00:00:00 2001 From: liuguijing <123456> Date: Mon, 15 Jan 2024 18:08:07 +0800 Subject: [PATCH] =?UTF-8?q?I2=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96ceshi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shxy/i2/Tool/AsyncMethod.java | 45 +- .../shxy/i2/serviceimpl/WebServiceImpl.java | 187 +- .../i2/serviceimpl/XydlI2ServiceImpl.java | 2149 +++++++++-------- .../com/shxy/i2/timeTask/ScheduledTask.java | 32 +- src/main/resources/application-test.yml | 6 +- .../resources/mappers/Data_Byq_JbfdDao.xml | 2 +- src/main/resources/mappers/Data_CnjDao.xml | 2 +- src/main/resources/mappers/Data_DcywDao.xml | 2 +- .../resources/mappers/Data_Dlq_JbfdDao.xml | 2 +- .../resources/mappers/Data_Dr_JyjcDao.xml | 2 +- src/main/resources/mappers/Data_FhdlbxDao.xml | 2 +- .../resources/mappers/Data_Jsyhw_JyjcDao.xml | 2 +- .../mappers/Data_MicroclimateDao.xml | 2 +- .../resources/mappers/Data_SF6_QtsfDao.xml | 2 +- src/main/resources/mappers/Data_TxDao.xml | 2 +- src/main/resources/mappers/Data_WsDao.xml | 2 +- src/main/resources/mappers/Data_YspDao.xml | 2 +- src/main/resources/mappers/data_FhzxqDao.xml | 2 +- 18 files changed, 1266 insertions(+), 1179 deletions(-) diff --git a/src/main/java/com/shxy/i2/Tool/AsyncMethod.java b/src/main/java/com/shxy/i2/Tool/AsyncMethod.java index e19e296..19a9845 100644 --- a/src/main/java/com/shxy/i2/Tool/AsyncMethod.java +++ b/src/main/java/com/shxy/i2/Tool/AsyncMethod.java @@ -166,28 +166,28 @@ public class AsyncMethod { @Async(value = "asyncServiceExecutor") public void sendData2(Client client, String xml) throws Exception { -// Object[] objects = client.invoke("uploadCACData", xml); -// String threadId = Thread.currentThread().getName(); -// log.info("线程序号: " + threadId + "当前时间:" + new Date()); -// if (objects != null && objects.length > 0) { -// String string = String.valueOf(objects[0]); -// log.info("返回的长度 : " + objects.length + " 返回的对象 : " + string); -// JSONObject jsonObject = XML.toJSONObject(string); -// if (jsonObject != null) { -// JSONObject response = (JSONObject) jsonObject.get("response"); -// if (response != null) { -// JSONObject result = (JSONObject) response.get("result"); -// if (result != null) { -// Integer code = (Integer) result.get("code"); -// if (code != null && code.intValue() == 0) { -// log.info("上传成功"); -// } else { -// log.info("上传失败"); -// } -// } -// } -// } -// } + Object[] objects = client.invoke("uploadCACData", xml); + String threadId = Thread.currentThread().getName(); + log.info("线程序号: " + threadId + "当前时间:" + new Date()); + if (objects != null && objects.length > 0) { + String string = String.valueOf(objects[0]); + log.info("返回的长度 : " + objects.length + " 返回的对象 : " + string); + JSONObject jsonObject = XML.toJSONObject(string); + if (jsonObject != null) { + JSONObject response = (JSONObject) jsonObject.get("response"); + if (response != null) { + JSONObject result = (JSONObject) response.get("result"); + if (result != null) { + Integer code = (Integer) result.get("code"); + if (code != null && code.intValue() == 0) { + log.info("上传成功"); + } else { + log.info("上传失败"); + } + } + } + } + } } @@ -218,6 +218,7 @@ public class AsyncMethod { // } } +// @Async(value = "asyncServiceExecutor") public void updateRecordId(BigInteger maxid,String type) { if (maxid != null && maxid.longValue() > 0) { upload_checkDao.updateByPrimaryKey(type, maxid, new Date()); diff --git a/src/main/java/com/shxy/i2/serviceimpl/WebServiceImpl.java b/src/main/java/com/shxy/i2/serviceimpl/WebServiceImpl.java index 9a6afb1..00ebd66 100644 --- a/src/main/java/com/shxy/i2/serviceimpl/WebServiceImpl.java +++ b/src/main/java/com/shxy/i2/serviceimpl/WebServiceImpl.java @@ -35,36 +35,38 @@ public class WebServiceImpl implements Webservcies { @Value("${webservice.address}") public String address; - +// @Value("${webservice.connecttime}") - public Integer connecttime; + public int connecttime; @Value("${webservice.receivetime}") - public Integer receivetime; - - + public int receivetime; +// private static String address = "http://10.238.71.98:18096/ppa/webservice/CAGAccessService?wsdl"; +// +// public static int receivetime = 60; +// +// public static int connecttime = 60; /** * 上传cac数据 */ @Override public void uploadData() { -// log.info("实时数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("实时数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("实时数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("实时数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); log.info("开始执行定时任务-查询数据库"); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); @@ -88,21 +90,20 @@ public class WebServiceImpl implements Webservcies { //放到配置文件 @Override public void uploadyspData() { -// log.info("油色谱数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("油色谱数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("油色谱数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("油色谱数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); log.info("开始执行定时任务-查询数据库"); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); @@ -115,21 +116,20 @@ public class WebServiceImpl implements Webservcies { @Override public void uploadjfjcData() { -// log.info("局放监测数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("局放监测数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("局放监测数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("局放监测数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); for (Niec_Sensors item : niec_sensors) { @@ -142,21 +142,20 @@ public class WebServiceImpl implements Webservcies { @Override public void uploadyxData() { - // log.info("实时数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("实时数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("实时数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("实时数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); log.info("开始执行定时任务-查询数据库"); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); @@ -169,21 +168,20 @@ public class WebServiceImpl implements Webservcies { @Override public void uploaddcywData() { - // log.info("实时数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("实时数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("实时数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("实时数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); log.info("开始执行定时任务-查询数据库"); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); @@ -196,21 +194,20 @@ public class WebServiceImpl implements Webservcies { @Override public void uploadjsyhwjyjcData() { - // log.info("实时数据定时任务启动"); -// // 动态客户端 -// JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); -// log.info("实时数据 publicsecurity webService url : {}", address); -// //根据WebServices接口地址创建client -// Client client = clientFactory.createClient(address); -// HTTPConduit conduit = (HTTPConduit) client.getConduit(); -// HTTPClientPolicy policy = new HTTPClientPolicy(); -// policy.setAllowChunking(false); -// // 连接服务器超时时间 60秒 -// policy.setConnectionTimeout(connecttime); -// // 等待服务器响应超时时间 60秒 -// policy.setReceiveTimeout(receivetime); -// conduit.setClient(policy); - Client client = null; + log.info("实时数据定时任务启动"); + // 动态客户端 + JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); + log.info("实时数据 publicsecurity webService url : {}", address); + //根据WebServices接口地址创建client + Client client = clientFactory.createClient(address); + HTTPConduit conduit = (HTTPConduit) client.getConduit(); + HTTPClientPolicy policy = new HTTPClientPolicy(); + policy.setAllowChunking(false); + // 连接服务器超时时间 60秒 + policy.setConnectionTimeout(connecttime); + // 等待服务器响应超时时间 60秒 + policy.setReceiveTimeout(receivetime); + conduit.setClient(policy); log.info("开始执行定时任务-查询数据库"); HashMap equipMap = new HashMap(); List niec_sensors = niec_sensorsDao.selectAll(); diff --git a/src/main/java/com/shxy/i2/serviceimpl/XydlI2ServiceImpl.java b/src/main/java/com/shxy/i2/serviceimpl/XydlI2ServiceImpl.java index b27c8c8..fe75a3e 100644 --- a/src/main/java/com/shxy/i2/serviceimpl/XydlI2ServiceImpl.java +++ b/src/main/java/com/shxy/i2/serviceimpl/XydlI2ServiceImpl.java @@ -4,13 +4,13 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.shxy.i2.Tool.AsyncMethod; import com.shxy.i2.Tool.GenerateI2Xml; import com.shxy.i2.bean.AttrBean; import com.shxy.i2.bean.SendDataBean; import com.shxy.i2.bean.YxAttrBean; -import com.shxy.i2.constant.CommonStatus; import com.shxy.i2.constant.Constant; import com.shxy.i2.dao.*; import com.shxy.i2.dto.Data_YxlDto; @@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Date; @@ -84,500 +85,807 @@ public class XydlI2ServiceImpl implements XydlI2Service { @Autowired AsyncMethod asyncMethod; - @Value("${webservice.receivetime}") - public int sendlimit; +// @Value("${webservice.sendlimit}") +// public int sendlimit; + + public static int sendlimit = 1000; @Override public void upload_byq_jbfd(Client client, HashMap equipMap) { - //查询目前上传的变压器局部放电的id 记录变压器局部放电上传的id大小 - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.BYQJBFDID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + Boolean iscontiue = true; + while (iscontiue) { + //查询目前上传的变压器局部放电的id 记录变压器局部放电上传的id大小 + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.BYQJBFDID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List data_byq_jbfdlist = data_byq_jbfdDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(data_byq_jbfdlist)) { - log.info("查询byq_jbfd的数据量:" + data_byq_jbfdlist.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < data_byq_jbfdlist.size(); index++) { - Data_Byq_Jbfd item = data_byq_jbfdlist.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List data_byq_jbfdlist = data_byq_jbfdDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(data_byq_jbfdlist)) { + log.info("查询byq_jbfd的数据量:" + data_byq_jbfdlist.size()); + log.info("查询byq_jbfd的数据量 sendlimit :" + sendlimit); + if (data_byq_jbfdlist.size() < 1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float dischargecapacity = item.getDischargecapacity(); - if (dischargecapacity != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargeCapacity"); - attr.setValue(dischargecapacity); - attrlist.add(attr); - } - Float dischargeposition = item.getDischargeposition(); - if (dischargeposition != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargePosition"); - attr.setValue(dischargeposition); - attrlist.add(attr); - } - Float pulsecount = item.getPulsecount(); - if (pulsecount != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("PulseCount"); - attr.setValue(pulsecount); - attrlist.add(attr); - } - byte[] dischargewaveform = item.getDischargewaveform(); - if (dischargewaveform != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargeWaveform"); - attr.setValue(dischargewaveform); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.BYQ_JBFD, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - BigInteger id = item.getId(); - SendDataBean sendDataBean = new SendDataBean(); - sendDataBean.setEqmid(item.getEqmid()); - sendDataBean.setMaxid(id); - if ((index != 0 && index % sendlimit == 0) || index == (data_byq_jbfdlist.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < data_byq_jbfdlist.size(); index++) { + Data_Byq_Jbfd item = data_byq_jbfdlist.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float dischargecapacity = item.getDischargecapacity(); + if (dischargecapacity != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargeCapacity"); + attr.setValue(dischargecapacity); + attrlist.add(attr); + } + Float dischargeposition = item.getDischargeposition(); + if (dischargeposition != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargePosition"); + attr.setValue(dischargeposition); + attrlist.add(attr); + } + Float pulsecount = item.getPulsecount(); + if (pulsecount != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("PulseCount"); + attr.setValue(pulsecount); + attrlist.add(attr); + } + byte[] dischargewaveform = item.getDischargewaveform(); + if (dischargewaveform != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargeWaveform"); + attr.setValue(dischargewaveform); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.BYQ_JBFD, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + BigInteger id = item.getId(); + SendDataBean sendDataBean = new SendDataBean(); + sendDataBean.setEqmid(item.getEqmid()); + sendDataBean.setMaxid(id); + if ((index != 0 && index % sendlimit == 0) || index == (data_byq_jbfdlist.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.BYQJBFDID); + } else { + iscontiue = false; + log.info("没有查询byq_jbfd的数据量"); } - asyncMethod.updateRecordId(maxid,Constant.BYQJBFDID); - } else { - log.info("没有查询byq_jbfd的数据量"); } } @Override public void upload_cnj(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.CNJID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.CNJID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List list = data_cnjDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询cnj的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Cnj item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_cnjDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询cnj的数据量:" + list.size()); + log.info("查询cnj的数据量 sendlimit :" + sendlimit); + if (list.size() < 1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float chargetime = item.getChargetime(); - if (chargetime != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("ChargeTime"); - attr.setValue(chargetime); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.CNJ, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Cnj item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float chargetime = item.getChargetime(); + if (chargetime != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("ChargeTime"); + attr.setValue(chargetime); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.CNJ, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.CNJID); + } else { + iscontiue = false; + log.info("没有查询cnj的数据量"); } - asyncMethod.updateRecordId(maxid,Constant.CNJID); - } else { - log.info("没有查询cnj的数据量"); } } @Override public void upload_dcyw(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DCYWID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DCYWID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List list = data_dcywDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询dcyw的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Dcyw item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_dcywDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询dcyw的数据量:" + list.size()); + if (list.size() < 1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float oiltemperature = item.getOiltemperature(); - if (oiltemperature != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("OilTemperature"); - attr.setValue(oiltemperature); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.DCYW, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Dcyw item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float oiltemperature = item.getOiltemperature(); + if (oiltemperature != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("OilTemperature"); + attr.setValue(oiltemperature); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.DCYW, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.DCYWID); + } else { + iscontiue = false; + log.info("没有查询dcyw的数据量"); } - asyncMethod.updateRecordId(maxid,Constant.DCYWID); - } else { - log.info("没有查询dcyw的数据量"); } } @Override public void upload_dlq_jbfd(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DLQJBFDID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DLQJBFDID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); - } - } - List list = data_dlq_jbfdDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询dlq_jbfd的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Dlq_Jbfd item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; - } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float dischargecapacity = item.getDischargecapacity(); - if (dischargecapacity != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargeCapacity"); - attr.setValue(dischargecapacity); - attrlist.add(attr); - } - Float dischargeposition = item.getDischargeposition(); - if (dischargeposition != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargePosition"); - attr.setValue(dischargeposition); - attrlist.add(attr); - } - Float pulsecount = item.getPulsecount(); - if (pulsecount != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("PulseCount"); - attr.setValue(pulsecount); - attrlist.add(attr); - } - byte[] dischargewaveform = item.getDischargewaveform(); - if (dischargewaveform != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("DischargeWaveform"); - attr.setValue(dischargewaveform); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.DLQJBFD, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - BigInteger id = item.getId(); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client,xml); - maxid = BigInteger.valueOf(0); - cacdatalist = new ArrayList<>(); - } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); - } + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); } } - asyncMethod.updateRecordId(maxid,Constant.DLQJBFDID); - } else { - log.info("没有查询到dlq的数据"); - } - } - - @Override - public void upload_dr_jyjc(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DRJYJCID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { - value = BigInteger.valueOf(0); - } - } - List list = data_dr_jyjcDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询dr_jyjc的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Dr_Jyjc item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_dlq_jbfdDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询dlq_jbfd的数据量:" + list.size()); + log.info("查询dlq_jbfd的数据量 sendlimit :" + sendlimit); + if (list.size() < 1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float capacitance = item.getCapacitance(); - if (capacitance != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Capacitance"); - attr.setValue(capacitance); - attrlist.add(attr); - } - Float lossfactor = item.getLossfactor(); - if (lossfactor != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("LossFactor"); - attr.setValue(lossfactor); - attrlist.add(attr); - } - Float unbalancecurrent = item.getUnbalancecurrent(); - if (unbalancecurrent != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("UnbalanceCurrent"); - attr.setValue(unbalancecurrent); - attrlist.add(attr); - } - Float unbalancevoltage = item.getUnbalancevoltage(); - if (unbalancevoltage != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("UnbalanceVoltage"); - attr.setValue(unbalancevoltage); - attrlist.add(attr); - } - Float totalcurrent = item.getTotalcurrent(); - if (totalcurrent != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("TotalCurrent"); - attr.setValue(totalcurrent); - attrlist.add(attr); - } - Float systemvoltage = item.getSystemvoltage(); - if (systemvoltage != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("SystemVoltage"); - attr.setValue(systemvoltage); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.DRJYJC, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - ArrayList list1 = new ArrayList<>(); - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Dlq_Jbfd item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float dischargecapacity = item.getDischargecapacity(); + if (dischargecapacity != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargeCapacity"); + attr.setValue(dischargecapacity); + attrlist.add(attr); + } + Float dischargeposition = item.getDischargeposition(); + if (dischargeposition != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargePosition"); + attr.setValue(dischargeposition); + attrlist.add(attr); + } + Float pulsecount = item.getPulsecount(); + if (pulsecount != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("PulseCount"); + attr.setValue(pulsecount); + attrlist.add(attr); + } + byte[] dischargewaveform = item.getDischargewaveform(); + if (dischargewaveform != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("DischargeWaveform"); + attr.setValue(dischargewaveform); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.DLQJBFD, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); + } + } + } + asyncMethod.updateRecordId(maxid, Constant.DLQJBFDID); + } else { + iscontiue = false; + log.info("没有查询到dlq的数据"); + } + } + } + + @Override + public void upload_dr_jyjc(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.DRJYJCID); + BigInteger value = null; + if (upload_check == null) { + value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } + } + List list = data_dr_jyjcDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询dr_jyjc的数据量:" + list.size()); + if (list.size() < 1000) { + iscontiue = false; + } + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Dr_Jyjc item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float capacitance = item.getCapacitance(); + if (capacitance != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Capacitance"); + attr.setValue(capacitance); + attrlist.add(attr); + } + Float lossfactor = item.getLossfactor(); + if (lossfactor != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("LossFactor"); + attr.setValue(lossfactor); + attrlist.add(attr); + } + Float unbalancecurrent = item.getUnbalancecurrent(); + if (unbalancecurrent != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("UnbalanceCurrent"); + attr.setValue(unbalancecurrent); + attrlist.add(attr); + } + Float unbalancevoltage = item.getUnbalancevoltage(); + if (unbalancevoltage != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("UnbalanceVoltage"); + attr.setValue(unbalancevoltage); + attrlist.add(attr); + } + Float totalcurrent = item.getTotalcurrent(); + if (totalcurrent != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("TotalCurrent"); + attr.setValue(totalcurrent); + attrlist.add(attr); + } + Float systemvoltage = item.getSystemvoltage(); + if (systemvoltage != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("SystemVoltage"); + attr.setValue(systemvoltage); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.DRJYJC, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + ArrayList list1 = new ArrayList<>(); + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); + } + } + } + asyncMethod.updateRecordId(maxid, Constant.DRJYJCID); + } else { + iscontiue = false; + log.info("没有查询dr_jyjc的数据量"); + } + } + } + + @Override + public void upload_fhdlbx(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.FHDLBXID); + BigInteger value = null; + if (upload_check == null) { + value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } + } + List list = data_fhdlbxDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询fhdlbx的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; + } + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Fhdlbx item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Integer action = item.getAction(); + if (action != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Action"); + attr.setValue(action); + attrlist.add(attr); + } + byte[] loadwaveform = item.getLoadwaveform(); + if (loadwaveform != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("LoadWaveform"); + attr.setValue(loadwaveform); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.FHDLBX, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); + } + } + } + asyncMethod.updateRecordId(maxid, Constant.FHDLBXID); + } else { + iscontiue = false; + log.info("没有查询fhdlbx的数据量"); + } + } + } + + @Override + public void upload_fhzxq(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.FHZXQID); + BigInteger value = null; + if (upload_check == null) { + value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } + } + List list = data_fhzxqDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询fhzxq的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; + } + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Fhzxq item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Integer action = item.getAction(); + if (action != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Action"); + attr.setValue(action); + attrlist.add(attr); + } + byte[] coilwaveform = item.getCoilwaveform(); + if (coilwaveform != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("CoilWaveform"); + attr.setValue(coilwaveform); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.FHZXQ, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); + } + } + } + asyncMethod.updateRecordId(maxid, Constant.FHZXQID); + } else { + iscontiue = false; + log.info("没有查询fhzxq的数据量"); + } + } + } + + @Override + public void upload_jsyhw_jyjc(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.JSYHWJYJCID); + BigInteger value = null; + if (upload_check == null) { + value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } + } + List list = data_jsyhw_jyjcDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询jsyhw_jyjc的数据量:" + list.size()); + log.info("查询jsyhw_jyjc的数据量 sendlimit :" + sendlimit); + if (list.size()<1000) { + iscontiue = false; + } + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Jsyhw_Jyjc item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float systemvoltage = item.getSystemvoltage(); + if (systemvoltage != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("SystemVoltage"); + attr.setValue(systemvoltage); + attrlist.add(attr); + } + Float totalcurrent = item.getTotalcurrent(); + if (totalcurrent != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("TotalCurrent"); + attr.setValue(totalcurrent); + attrlist.add(attr); + } + Float resistivecurrent = item.getResistivecurrent(); + if (resistivecurrent != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("ResistiveCurrent"); + attr.setValue(resistivecurrent); + attrlist.add(attr); + } + Float actioncount = item.getActioncount(); + if (actioncount != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("ActionCount"); + attr.setValue(actioncount); + attrlist.add(attr); + } + Date lastactiontime = item.getLastactiontime(); + if (lastactiontime != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("LastActionTime"); + attr.setValue(DateUtil.format(lastactiontime, DatePattern.NORM_DATETIME_PATTERN)); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.JSYHW, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.JSYHWJYJCID); + } else { + iscontiue = false; + log.info("没有查询jsyhw_jyjc的数据量"); } - asyncMethod.updateRecordId(maxid,Constant.DRJYJCID); - } else { - log.info("没有查询dr_jyjc的数据量"); } } @Override - public void upload_fhdlbx(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.FHDLBXID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + public void upload_sf6_qtsf(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.SF6QTSFID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List list = data_fhdlbxDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询fhdlbx的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Fhdlbx item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_sf6_qtsfDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询sf6_qtsf的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Integer action = item.getAction(); - if (action != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Action"); - attr.setValue(action); - attrlist.add(attr); - } - byte[] loadwaveform = item.getLoadwaveform(); - if (loadwaveform != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("LoadWaveform"); - attr.setValue(loadwaveform); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.FHDLBX, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client,xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_SF6_Qtsf item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float temperature = item.getTemperature(); + if (temperature != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Temperature"); + attr.setValue(temperature); + attrlist.add(attr); + } + Float moisture = item.getMoisture(); + if (moisture != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Moisture"); + attr.setValue(moisture); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.SF6_QTSF, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.SF6QTSFID); + } else { + iscontiue = false; + log.info("没有查询sf6_qtsf的数据量"); } - asyncMethod.updateRecordId(maxid,Constant.FHDLBXID); - } else { - log.info("没有查询fhdlbx的数据量"); } } @Override - public void upload_fhzxq(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.FHZXQID); + public void upload_sf6_qtyl(Client client, HashMap equipMap) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.SF6QTYLID); BigInteger value = null; if (upload_check == null) { value = BigInteger.valueOf(0); @@ -587,259 +895,262 @@ public class XydlI2ServiceImpl implements XydlI2Service { value = BigInteger.valueOf(0); } } - List list = data_fhzxqDao.selectUpload(CommonStatus.UNUPLOAD.value()); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询fhzxq的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Fhzxq item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + Boolean iscontiue = true; + while (iscontiue) { + List list = data_sf6_qtylDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询sf6_qtyl的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Integer action = item.getAction(); - if (action != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Action"); - attr.setValue(action); - attrlist.add(attr); - } - byte[] coilwaveform = item.getCoilwaveform(); - if (coilwaveform != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("CoilWaveform"); - attr.setValue(coilwaveform); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.FHZXQ, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + BigDecimal add = NumberUtil.add(value, list.size()); + value = add.toBigInteger(); + for (int index = 0; index < list.size(); index++) { + Data_SF6_Qtyl item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float temperature = item.getTemperature(); + if (temperature != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Temperature"); + attr.setValue(temperature); + attrlist.add(attr); + } + Float absolutepressure = item.getAbsolutepressure(); + if (absolutepressure != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("AbsolutePressure"); + attr.setValue(absolutepressure); + attrlist.add(attr); + } + Float density = item.getDensity(); + if (density != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Density"); + attr.setValue(density); + attrlist.add(attr); + } + Float pressure20c = item.getPressure20c(); + if (pressure20c != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Pressure20C"); + attr.setValue(pressure20c); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.SF6_QTYL, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + log.info("开始传输"); + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.SF6QTYLID); + } else { + iscontiue = false; + log.info("没有查询到sf6_qtyl的数据"); } - asyncMethod.updateRecordId(maxid,Constant.FHZXQID); - } else { - log.info("没有查询fhzxq的数据量"); } } @Override - public void upload_jsyhw_jyjc(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.JSYHWJYJCID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + public void upload_tx(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.TXID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List list = data_jsyhw_jyjcDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询jsyhw_jyjc的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Jsyhw_Jyjc item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_txDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询tx的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float systemvoltage = item.getSystemvoltage(); - if (systemvoltage != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("SystemVoltage"); - attr.setValue(systemvoltage); - attrlist.add(attr); - } - Float totalcurrent = item.getTotalcurrent(); - if (totalcurrent != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("TotalCurrent"); - attr.setValue(totalcurrent); - attrlist.add(attr); - } - Float resistivecurrent = item.getResistivecurrent(); - if (resistivecurrent != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("ResistiveCurrent"); - attr.setValue(resistivecurrent); - attrlist.add(attr); - } - Float actioncount = item.getActioncount(); - if (actioncount != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("ActionCount"); - attr.setValue(actioncount); - attrlist.add(attr); - } - Date lastactiontime = item.getLastactiontime(); - if (lastactiontime != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("LastActionTime"); - attr.setValue(DateUtil.format(lastactiontime, DatePattern.NORM_DATETIME_PATTERN)); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.JSYHW, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Tx item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float totalcorecurrent = item.getTotalcorecurrent(); + if (totalcorecurrent != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("TotalCoreCurrent"); + attr.setValue(totalcorecurrent); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.TX, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.TXID); + } else { + iscontiue = false; + log.info("没有查询到tx的数据"); } - asyncMethod.updateRecordId(maxid,Constant.JSYHWJYJCID); - } else { - log.info("没有查询jsyhw_jyjc的数据量"); } } @Override - public void upload_sf6_qtsf(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.SF6QTSFID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + public void upload_ws(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.WSID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); + } } - } - List list = data_sf6_qtsfDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询sf6_qtsf的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_SF6_Qtsf item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_wsDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询ws的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float temperature = item.getTemperature(); - if (temperature != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Temperature"); - attr.setValue(temperature); - attrlist.add(attr); - } - Float moisture = item.getMoisture(); - if (moisture != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Moisture"); - attr.setValue(moisture); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.SF6_QTSF, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Ws item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; + } + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float moisture = item.getMoisture(); + if (moisture != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Moisture"); + attr.setValue(moisture); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.WS, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.WSID); + } else { + iscontiue = false; + log.info("没有查询到ws的数据"); } - asyncMethod.updateRecordId(maxid,Constant.SF6QTSFID); - } else { - log.info("没有查询sf6_qtsf的数据量"); } } @Override - public void upload_sf6_qtyl(Client client, HashMap equipMap) { - + public void upload_ysp(Client client, HashMap equipMap) { Boolean iscontiue = true; while (iscontiue) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.SF6QTYLID); + //查询目前上传的油色谱的id 记录油色谱上传的id大小 + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.YSPID); BigInteger value = null; if (upload_check == null) { value = BigInteger.valueOf(0); - }else { + } else { value = upload_check.getValue(); if (value == null) { value = BigInteger.valueOf(0); } } - List list = data_sf6_qtylDao.selectUploadById(value); - if (list.size()<1000) { - iscontiue = false; - } + List list = data_yspDao.selectUploadById(value); if (CollectionUtil.isNotEmpty(list)) { - log.info("查询sf6_qtyl的数据量:" + list.size()); + log.info("查询ysp的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; + } ArrayList cacdatalist = new ArrayList<>(); BigInteger maxid = null; for (int index = 0; index < list.size(); index++) { - Data_SF6_Qtyl item = list.get(index); + Data_Ysp item = list.get(index); maxid = item.getId(); Niec_Sensors sensors = equipMap.get(item.getEqmid()); if (sensors == null) { @@ -862,39 +1173,84 @@ public class XydlI2ServiceImpl implements XydlI2Service { attr.setValue(phase); attrlist.add(attr); } - Float temperature = item.getTemperature(); - if (temperature != null) { + Float h2 = item.getH2(); + if (h2 != null) { AttrBean attr = new AttrBean<>(); - attr.setKey("Temperature"); - attr.setValue(temperature); + attr.setKey("H2"); + attr.setValue(h2); attrlist.add(attr); } - Float absolutepressure = item.getAbsolutepressure(); - if (absolutepressure != null) { + Float ch4 = item.getCh4(); + if (ch4 != null) { AttrBean attr = new AttrBean<>(); - attr.setKey("AbsolutePressure"); - attr.setValue(absolutepressure); + attr.setKey("CH4"); + attr.setValue(ch4); attrlist.add(attr); } - Float density = item.getDensity(); - if (density != null) { + Float c2h6 = item.getC2h6(); + if (c2h6 != null) { AttrBean attr = new AttrBean<>(); - attr.setKey("Density"); - attr.setValue(density); + attr.setKey("C2H6"); + attr.setValue(c2h6); attrlist.add(attr); } - Float pressure20c = item.getPressure20c(); - if (pressure20c != null) { + Float c2h4 = item.getC2h4(); + if (c2h4 != null) { AttrBean attr = new AttrBean<>(); - attr.setKey("Pressure20C"); - attr.setValue(pressure20c); + attr.setKey("C2H4"); + attr.setValue(c2h4); attrlist.add(attr); } - String cacdata = GenerateI2Xml.generateCacXml(Constant.SF6_QTYL, sensorid, equipmentid, timestamp, attrlist); + Float c2h2 = item.getC2h2(); + if (c2h2 != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("C2H2"); + attr.setValue(c2h2); + attrlist.add(attr); + } + Float co = item.getCo(); + if (co != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("CO"); + attr.setValue(co); + attrlist.add(attr); + } + Float co2 = item.getCo2(); + if (co2 != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("CO2"); + attr.setValue(co2); + attrlist.add(attr); + } + Float o2 = item.getO2(); + if (o2 != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("O2"); + attr.setValue(o2); + attrlist.add(attr); + } + Float n2 = item.getN2(); + if (n2 != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("N2"); + attr.setValue(n2); + attrlist.add(attr); + } + Float totalhydrocarbon = item.getTotalhydrocarbon(); + if (totalhydrocarbon != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("TotalHydrocarbon"); + attr.setValue(totalhydrocarbon); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.YSP, sensorid, equipmentid, timestamp, attrlist); cacdatalist.add(cacdata); + log.info("测试断点3"); if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - log.info("开始传输"); + log.info("测试断点4"); + ArrayList list1 = new ArrayList<>(); String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + log.info("ysp组装完成,开始上传"); asyncMethod.sendData2(client, xml); cacdatalist = new ArrayList<>(); } @@ -903,386 +1259,124 @@ public class XydlI2ServiceImpl implements XydlI2Service { } } } - asyncMethod.updateRecordId(maxid, Constant.SF6QTYLID); + asyncMethod.updateRecordId(maxid, Constant.YSPID); } else { - log.info("没有查询到sf6_qtyl的数据"); - } - } - } - - @Override - public void upload_tx(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.TXID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { - value = BigInteger.valueOf(0); - } - } - List list = data_txDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询tx的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Tx item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; - } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float totalcorecurrent = item.getTotalcorecurrent(); - if (totalcorecurrent != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("TotalCoreCurrent"); - attr.setValue(totalcorecurrent); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.TX, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); - } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); - } - } + iscontiue = false; + log.info("没有查询到ysp的数据"); } - asyncMethod.updateRecordId(maxid,Constant.TXID); - } else { - log.info("没有查询到tx的数据"); } } @Override - public void upload_ws(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.WSID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { + public void upload_microclimate(Client client, HashMap equipMap) { + Boolean iscontiue = true; + while (iscontiue) { + Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.MICROCLIMATEID); + BigInteger value = null; + if (upload_check == null) { value = BigInteger.valueOf(0); - } - } - List list = data_wsDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询ws的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Ws item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; - } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float moisture = item.getMoisture(); - if (moisture != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Moisture"); - attr.setValue(moisture); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.WS, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); - } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); - } + } else { + value = upload_check.getValue(); + if (value == null) { + value = BigInteger.valueOf(0); } } - asyncMethod.updateRecordId(maxid,Constant.WSID); - } else { - log.info("没有查询到ws的数据"); - } - } - - @Override - public void upload_ysp(Client client, HashMap equipMap) { - //查询目前上传的油色谱的id 记录油色谱上传的id大小 - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.YSPID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { - value = BigInteger.valueOf(0); - } - } - List dataYspList = data_yspDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(dataYspList)) { - log.info("查询ysp的数据量:" + dataYspList.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < dataYspList.size(); index++) { - Data_Ysp item = dataYspList.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; + List list = data_microclimateDao.selectUploadById(value); + if (CollectionUtil.isNotEmpty(list)) { + log.info("查询microclimate的数据量:" + list.size()); + if (list.size()<1000) { + iscontiue = false; } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float h2 = item.getH2(); - if (h2 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("H2"); - attr.setValue(h2); - attrlist.add(attr); - } - Float ch4 = item.getCh4(); - if (ch4 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("CH4"); - attr.setValue(ch4); - attrlist.add(attr); - } - Float c2h6 = item.getC2h6(); - if (c2h6 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("C2H6"); - attr.setValue(c2h6); - attrlist.add(attr); - } - Float c2h4 = item.getC2h4(); - if (c2h4 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("C2H4"); - attr.setValue(c2h4); - attrlist.add(attr); - } - Float c2h2 = item.getC2h2(); - if (c2h2 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("C2H2"); - attr.setValue(c2h2); - attrlist.add(attr); - } - Float co = item.getCo(); - if (co != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("CO"); - attr.setValue(co); - attrlist.add(attr); - } - Float co2 = item.getCo2(); - if (co2 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("CO2"); - attr.setValue(co2); - attrlist.add(attr); - } - Float o2 = item.getO2(); - if (o2 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("O2"); - attr.setValue(o2); - attrlist.add(attr); - } - Float n2 = item.getN2(); - if (n2 != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("N2"); - attr.setValue(n2); - attrlist.add(attr); - } - Float totalhydrocarbon = item.getTotalhydrocarbon(); - if (totalhydrocarbon != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("TotalHydrocarbon"); - attr.setValue(totalhydrocarbon); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.YSP, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - log.info("测试断点3"); - if ((index != 0 && index % sendlimit == 0) || index == (dataYspList.size() - 1)) { - log.info("测试断点4"); - ArrayList list1 = new ArrayList<>(); - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - log.info("ysp组装完成,开始上传"); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); - } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); + ArrayList cacdatalist = new ArrayList<>(); + BigInteger maxid = null; + for (int index = 0; index < list.size(); index++) { + Data_Microclimate item = list.get(index); + maxid = item.getId(); + Niec_Sensors sensors = equipMap.get(item.getEqmid()); + if (sensors == null) { + continue; } - } - } - asyncMethod.updateRecordId(maxid,Constant.YSPID); - } else { - log.info("没有查询到ysp的数据"); - } - - } - - @Override - public void upload_microclimate(Client client, HashMap equipMap) { - Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.MICROCLIMATEID); - BigInteger value = null; - if (upload_check == null) { - value = BigInteger.valueOf(0); - }else { - value = upload_check.getValue(); - if (value == null) { - value = BigInteger.valueOf(0); - } - } - List list = data_microclimateDao.selectUploadById(value); - if (CollectionUtil.isNotEmpty(list)) { - log.info("查询microclimate的数据量:" + list.size()); - ArrayList cacdatalist = new ArrayList<>(); - BigInteger maxid = null; - for (int index = 0; index < list.size(); index++) { - Data_Microclimate item = list.get(index); - maxid = item.getId(); - Niec_Sensors sensors = equipMap.get(item.getEqmid()); - if (sensors == null) { - continue; - } - String sensorid = sensors.getSensorCode(); - String equipmentid = sensors.getEquipmentId(); - String phase = sensors.getPhase(); - if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { - ArrayList attrlist = new ArrayList<>(); - try { - String timestamp = ""; - Date acquisitiontime = item.getAcquisitiontime(); - if (acquisitiontime != null) { - timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); - } - if (phase != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Phase"); - attr.setValue(phase); - attrlist.add(attr); - } - Float airtemperature = item.getAirtemperature(); - if (airtemperature != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("AirTemperature"); - attr.setValue(airtemperature); - attrlist.add(attr); - } - Float airpressure = item.getAirpressure(); - if (airpressure != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("AirPressure"); - attr.setValue(airpressure); - attrlist.add(attr); - } - Float humidity = item.getHumidity(); - if (humidity != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Humidity"); - attr.setValue(humidity); - attrlist.add(attr); - } - Float precipitation = item.getPrecipitation(); - if (precipitation != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("Precipitation"); - attr.setValue(precipitation); - attrlist.add(attr); - } - Float precipitationintensity = item.getPrecipitationintensity(); - if (precipitationintensity != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("PrecipitationIntensity"); - attr.setValue(precipitationintensity); - attrlist.add(attr); - } - Float radiationintensity = item.getRadiationintensity(); - if (radiationintensity != null) { - AttrBean attr = new AttrBean<>(); - attr.setKey("RadiationIntensity"); - attr.setValue(radiationintensity); - attrlist.add(attr); - } - String cacdata = GenerateI2Xml.generateCacXml(Constant.WQX, sensorid, equipmentid, timestamp, attrlist); - cacdatalist.add(cacdata); - if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { - String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); - asyncMethod.sendData2(client, xml); - cacdatalist = new ArrayList<>(); + String sensorid = sensors.getSensorCode(); + String equipmentid = sensors.getEquipmentId(); + String phase = sensors.getPhase(); + if (StrUtil.isNotEmpty(sensorid) && StrUtil.isNotEmpty(equipmentid)) { + ArrayList attrlist = new ArrayList<>(); + try { + String timestamp = ""; + Date acquisitiontime = item.getAcquisitiontime(); + if (acquisitiontime != null) { + timestamp = DateUtil.format(acquisitiontime, DatePattern.NORM_DATETIME_PATTERN); + } + if (phase != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Phase"); + attr.setValue(phase); + attrlist.add(attr); + } + Float airtemperature = item.getAirtemperature(); + if (airtemperature != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("AirTemperature"); + attr.setValue(airtemperature); + attrlist.add(attr); + } + Float airpressure = item.getAirpressure(); + if (airpressure != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("AirPressure"); + attr.setValue(airpressure); + attrlist.add(attr); + } + Float humidity = item.getHumidity(); + if (humidity != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Humidity"); + attr.setValue(humidity); + attrlist.add(attr); + } + Float precipitation = item.getPrecipitation(); + if (precipitation != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("Precipitation"); + attr.setValue(precipitation); + attrlist.add(attr); + } + Float precipitationintensity = item.getPrecipitationintensity(); + if (precipitationintensity != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("PrecipitationIntensity"); + attr.setValue(precipitationintensity); + attrlist.add(attr); + } + Float radiationintensity = item.getRadiationintensity(); + if (radiationintensity != null) { + AttrBean attr = new AttrBean<>(); + attr.setKey("RadiationIntensity"); + attr.setValue(radiationintensity); + attrlist.add(attr); + } + String cacdata = GenerateI2Xml.generateCacXml(Constant.WQX, sensorid, equipmentid, timestamp, attrlist); + cacdatalist.add(cacdata); + if ((index != 0 && index % sendlimit == 0) || index == (list.size() - 1)) { + String xml = GenerateI2Xml.generateEndCacXml(cacdatalist); + asyncMethod.sendData2(client, xml); + cacdatalist = new ArrayList<>(); + } + } catch (Exception e) { + log.error("抛出了异常:{}" + e.getMessage()); } - } catch (Exception e) { - log.error("抛出了异常:{}" + e.getMessage()); } } + asyncMethod.updateRecordId(maxid, Constant.MICROCLIMATEID); + } else { + iscontiue = false; + log.info("没有查询到microcimate的数据"); } - asyncMethod.updateRecordId(maxid,Constant.MICROCLIMATEID); - } else { - log.info("没有查询到microcimate的数据"); } } @Override public void upload_yx(Client client) { - - - Boolean iscontiue = true; while (iscontiue) { Upload_check upload_check = upload_checkDao.selectByPrimaryKey(Constant.YXID); @@ -1296,12 +1390,12 @@ public class XydlI2ServiceImpl implements XydlI2Service { } } List list = data_yxDao.selectByPrimaryKey(value); - if (list.size()<1000) { - iscontiue = false; - } if (CollectionUtil.isNotEmpty(list)) { log.info("查询yx的数据量:" + list.size()); - BigInteger maxid =null; + if (list.size() < 1000) { + iscontiue = false; + } + BigInteger maxid = null; for (int index = 0; index < list.size(); index++) { Data_YxlDto data_yxlDto = list.get(index); Date dtime = data_yxlDto.getDtime(); @@ -1358,14 +1452,17 @@ public class XydlI2ServiceImpl implements XydlI2Service { try { String xml = GenerateI2Xml.generateYxCacXml(attr); if (xml != null && !xml.equals("")) { - asyncMethod.sendData2(client, xml); + asyncMethod.sendData2(client, xml); } } catch (Exception e) { e.printStackTrace(); } } - asyncMethod.updateRecordId(maxid,Constant.YXID); + asyncMethod.updateRecordId(maxid, Constant.YXID); + } else { + iscontiue = false; + log.info("没有查询到yx的数据"); } } } @@ -1373,7 +1470,7 @@ public class XydlI2ServiceImpl implements XydlI2Service { @Override public void clear_history() { log.info("开启定时删除"); - DateTime dateTime = DateUtil.offsetDay(new Date(), -7); + DateTime dateTime = DateUtil.offsetDay(new Date(), -3); data_byq_jbfdDao.deleteData(dateTime); data_cnjDao.deleteData(dateTime); data_dcywDao.deleteData(dateTime); diff --git a/src/main/java/com/shxy/i2/timeTask/ScheduledTask.java b/src/main/java/com/shxy/i2/timeTask/ScheduledTask.java index 46d2701..16afa96 100644 --- a/src/main/java/com/shxy/i2/timeTask/ScheduledTask.java +++ b/src/main/java/com/shxy/i2/timeTask/ScheduledTask.java @@ -26,56 +26,48 @@ public class ScheduledTask { @Autowired XydlI2Service xydlI2Service; - private int i1 = 0; - private int i2 = 0; - private int i3 = 0; - private int i4 = 0; - private int i5 = 0; - private int i6 = 0; - private int i7 = 0; - private int i8 = 0; - private int i9 = 0; @Scheduled(fixedDelay = 60 * 60 * 1000) public void cacyspupload() { - log.error("cacyspupload执行" + (i1++) ); + log.info("cacyspupload执行" ); webservcies.uploadyspData(); } - @Scheduled(fixedDelay = 1 * 60 * 1000) + @Scheduled(fixedDelay = 10 * 60 * 1000) public void cacjfjcupload() { - log.error("cacjfjcupload执行" + (i2++) ); + log.info("cacjfjcupload执行" ); webservcies.uploadjfjcData(); } @Scheduled(fixedDelay = 1 * 30 * 1000) public void cacupload() { - log.error("cacupload执行" + (i3++) ); + log.info("cacupload执行" ); webservcies.uploadData(); } @Scheduled(fixedDelay = 1 * 30 * 1000) public void cacyxupload() { - log.error("cacyxupload执行" + (i4++) ); + log.info("cacyxupload执行" ); webservcies.uploadyxData(); } @Scheduled(fixedDelay = 1 * 30 * 1000) public void cacdcywupload() { - log.error("cacdcywupload执行" + (i5++) ); + log.info("cacdcywupload执行" ); webservcies.uploaddcywData(); } @Scheduled(fixedDelay = 1 * 30 * 1000) public void cacjsyhwjyjcupload() { - log.error("cacjsyhwjyjcupload执行" + (i6++) ); + log.info("cacjsyhwjyjcupload执行" ); webservcies.uploadjsyhwjyjcData(); } -// @Scheduled(cron = "0 0 13 * * ?") -// public void clear() { -// xydlI2Service.clear_history(); -// } + @Scheduled(cron = "0 0 13 * * ?") + public void clear() { + log.info("clear" ); + xydlI2Service.clear_history(); + } } diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index e0b85eb..652edde 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -9,7 +9,7 @@ spring: task: scheduling: pool: - size: 8 + size: 20 # 开发环境配置 server: @@ -36,6 +36,6 @@ mybatis: webservice: # 超高压中心地址 address: http://10.238.71.98:18096/ppa/webservice/CAGAccessService?wsdl - connecttime: 30 - receivetime: 30 + connecttime: 60000 + receivetime: 60000 sendlimit: 100 diff --git a/src/main/resources/mappers/Data_Byq_JbfdDao.xml b/src/main/resources/mappers/Data_Byq_JbfdDao.xml index a76fcc1..16c98c8 100644 --- a/src/main/resources/mappers/Data_Byq_JbfdDao.xml +++ b/src/main/resources/mappers/Data_Byq_JbfdDao.xml @@ -23,7 +23,7 @@ t1.id, t1.eqmid, t1.acquisitionTime, t1.dischargeCapacity, t1.dischargePosition, t1.pulseCount, t1.isupload, t1.dischargeWaveform,t1.create_time, t1.update_time FROM - data_byq_jbfd t1 where t1.id ]]> #{maxid} + data_byq_jbfd t1 where t1.id ]]> #{maxid} limit 1000 diff --git a/src/main/resources/mappers/data_FhzxqDao.xml b/src/main/resources/mappers/data_FhzxqDao.xml index b079a63..f0026be 100644 --- a/src/main/resources/mappers/data_FhzxqDao.xml +++ b/src/main/resources/mappers/data_FhzxqDao.xml @@ -18,7 +18,7 @@ select from data_fhzxq - where id ]]> #{maxid} + where id ]]> #{maxid} limit 1000