From 289c35071b1d174a96cd852c6606860199f63c4f Mon Sep 17 00:00:00 2001 From: qiezi <15576055375@163.com> Date: Mon, 23 Sep 2024 13:47:44 +0800 Subject: [PATCH] 2024-09-23 --- .../modules/cdc/task/GatherDataTask.java | 175 ------------------ 1 file changed, 175 deletions(-) diff --git a/src/main/java/com/spring/modules/cdc/task/GatherDataTask.java b/src/main/java/com/spring/modules/cdc/task/GatherDataTask.java index 24fd532a..0db40e35 100644 --- a/src/main/java/com/spring/modules/cdc/task/GatherDataTask.java +++ b/src/main/java/com/spring/modules/cdc/task/GatherDataTask.java @@ -96,179 +96,4 @@ public class GatherDataTask { log.info("数据采集完成:总条数{}",deviceVos.size()); } - -// public void execute() { -// if (!flag){ -// return; -// } -// // TODO: 这里可以写数据采集的逻辑 -// log.info("数据采集接口"); -// // 获取三种类型设备 -// List list = deviceService.lambdaQuery().eq(Device::getActive, "Y").list(); -// // 读取信息 每条线调用方式不同 -// log.info("设备信息:共{}台设备",list.size()); -// // 1、涂布设备-大线 -// // 2、涂布设备-小线 -// // 3、配妆间设备 -// Map> map = list.stream().collect(Collectors.groupingBy(Device::getDeviceAddress)); -// for (String ip : map.keySet()) { -// if (ip.equals(line1IP)){ -// List deviceList = map.get(ip); -// SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200,ip); -// OperateResult connect = siemensS7Net.ConnectServer(); -// if (connect.IsSuccess) { -// log.info("IP:{} 连接成功!!!",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -// int i = CollectUtils.readXMZValue(siemensS7Net, device.getDeviceIp()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),i); -// CollectRecord collectRecord = getCollectRecord(device, c1, i); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// siemensS7Net.ConnectClose(); -// }else { -// log.info("IP:{} 连接失败",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -//// int i = CollectUtils.readSLValue(melsecMcNet, device.getDeviceAddress()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),line1Value); -// CollectRecord collectRecord = getCollectRecord(device, c1, line1Value); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// } -// }else if (ip.equals(line2IP)){ -// List deviceList = map.get(ip); -// MelsecMcNet melsecMcNet = new MelsecMcNet(ip, line2Port); -// OperateResult connect = melsecMcNet.ConnectServer(); -// if (connect.IsSuccess) { -// log.info("IP:{} 连接成功!!!",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -// int i = CollectUtils.readSLValue(melsecMcNet, device.getDeviceIp()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),i); -// CollectRecord collectRecord = getCollectRecord(device, c1, i); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// melsecMcNet.ConnectClose(); -// }else { -// log.info("IP:{} 连接失败",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -//// int i = CollectUtils.readSLValue(melsecMcNet, device.getDeviceAddress()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),line2Value); -// CollectRecord collectRecord = getCollectRecord(device, c1, line2Value); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// } -// }else if (ip.equals(line3IP)){ -// List deviceList = map.get(ip); -// MelsecMcNet melsecMcNet = new MelsecMcNet(ip, 1010); -// OperateResult connect = melsecMcNet.ConnectServer(); -// if (connect.IsSuccess) { -// log.info("IP:{} 连接成功!!!",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -// int i = CollectUtils.readSLValue(melsecMcNet, device.getDeviceIp()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),i); -// CollectRecord collectRecord = getCollectRecord(device, c1, i); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// melsecMcNet.ConnectClose(); -// }else { -// log.info("IP:{} 连接失败",ip); -// for (Device device : deviceList) { -// List c1 = collectService.lambdaQuery().in(Collect::getCollectDesc, device.getDeviceType()).eq(Collect::getActive, "Y").list(); -//// int i = CollectUtils.readSLValue(melsecMcNet, device.getDeviceAddress()); -// log.info("设备:{} 读取值:{}",device.getDeviceDesc(),line3Value); -// CollectRecord collectRecord = getCollectRecord(device, c1, line3Value); -// collectRecordService.insertCollectRecord(collectRecord); -// collectRecordService.updateCollectCurrentValue(collectRecord); -// } -// } -// }else { -// log.info("不存在IP"); -// } -// } -// // 存储采集的数据 -// -// -// // 采集数据与设置数据对比 -// -// -//// Date lastSendTime = lineCollectList1.get(0).getLastSendTime(); -//// if (Objects.nonNull(lastSendTime)){ -//// log.info("最终时间:{}", lastSendTime.toLocaleString()); -//// // 校验短时间内是否发送给 邮件/短信 -//// int time = cdcBaseDataService.getLongCdcBaseData(BASE_NO); -//// lastSendTime.setTime(lastSendTime.getTime() + (long) time * 60 * 1000); -//// // 最后一次发送时间 与 当前时间比较 是否大于当前时间 -//// if (new Date().before(lastSendTime)){ -//// // 记录信息 距离最后一次发送时间 在规定范围内,不发送短信 -//// return; -//// } -//// } -//// -//// // 达到预警情况下,发送预警邮件,短信等 -//// List detailList = collectDetailService -//// .lambdaQuery() -//// .eq(CollectDetail::getCollectId, lineCollectList1.get(0).getCollectId()) -//// .eq(CollectDetail::getSite, lineCollectList1.get(0).getSite()) -//// .list(); -//// log.info("设置的 电话/邮箱 详情:{}", detailList); -//// // 处理结果集 -//// Map> map = detailList.stream().collect(Collectors.groupingBy(CollectDetail::getType)); -//// // 发送预警邮件,短信等 -//// for (String s : map.keySet()) { -//// if ("mail".equals(s)){ -//// // 发送邮件 -//// List mailList = map.get(s).stream().map(CollectDetail::getItemValue).collect(Collectors.toList()); -//// log.info("发送邮件:{}", mailList); -//// if (mailList.isEmpty()){ -//// continue; -//// } -////// try { -////// mailConfigService.send(mailList.toArray(new String[0]), "数据采集预警", "数据采集预警",1); -////// } catch (MessagingException | UnsupportedEncodingException e) { -////// log.error("发送邮件失败:{}", e.getMessage()); -////// throw new RuntimeException(e); -////// } -//// } -//// if ("phone".equals(s)){ -//// // 发送短信 -////// List phoneList = map.get(s).stream().map(CollectDetail::getItemValue).collect(Collectors.toList()); -////// log.info("发送短信:{}", phoneList); -////// if (phoneList.isEmpty()){ -////// continue; -////// } -////// String[] array = phoneList.toArray(new String[0]); -////// mobileService.send(String.join(",", array), "【数据采集预警】数据采集预警"); -//// } -//// } -// } -// -// private static CollectRecord getCollectRecord(Device device, List c1, int i) { -// CollectRecord collectRecord = new CollectRecord(); -// collectRecord.setDeviceNo(device.getDeviceNo()); -// collectRecord.setCollectId(c1.get(0).getCollectId()); -// collectRecord.setItemValue(new BigDecimal(i)); -// collectRecord.setSite(device.getSite()); -// if (device.getDeviceType().contains("浓度")){ -// if (new BigDecimal(i).compareTo(c1.get(0).getMinValue()) < 0){ -// collectRecord.setWarnFlag("Y"); -// } -// if (c1.get(0).getMaxValue().compareTo(new BigDecimal(i)) < 0){ -// collectRecord.setWarnFlag("Y"); -// } -// }else { -// if (c1.get(0).getMaxValue().compareTo(new BigDecimal(i)) < 0){ -// collectRecord.setWarnFlag("Y"); -// } -// } -// return collectRecord; -// } }