Compare commits
4 Commits
4f11b686c5
...
e875693d8c
| Author | SHA1 | Date |
|---|---|---|
|
|
e875693d8c | |
|
|
ea8b0b473d | |
|
|
4e39e6a5a4 | |
|
|
1264526a2b |
23
pom.xml
23
pom.xml
|
|
@ -5,12 +5,12 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zcloud</groupId>
|
||||
<artifactId>integrated_yjb_scheduled</artifactId>
|
||||
<artifactId>sx_yjb_scheduled</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging><!-- 以war运行是改成war -->
|
||||
|
||||
<name>integrated_yjb_scheduled</name>
|
||||
<description>integrated_yjb_scheduled for Spring Boot</description>
|
||||
<name>sx_yjb_scheduled</name>
|
||||
<description>sx_yjb_scheduled for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -435,10 +435,23 @@
|
|||
<version>3.14.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Oracle JDBC驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.jdbc</groupId>
|
||||
<artifactId>ojdbc8</artifactId>
|
||||
<version>19.3.0.0</version> <!-- 19c版本 -->
|
||||
</dependency>
|
||||
|
||||
<!-- 字符集支持库(必须与JDBC驱动版本一致) -->
|
||||
<dependency>
|
||||
<groupId>com.oracle.database.nls</groupId>
|
||||
<artifactId>orai18n</artifactId>
|
||||
<version>19.3.0.0</version> <!-- 与ojdbc8版本保持一致 -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- <finalName>integrated_yjb_scheduled</finalName>
|
||||
<!-- <finalName>sx_yjb_scheduled</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
@ -465,7 +478,7 @@
|
|||
</includes>
|
||||
</resource>
|
||||
</resources> -->
|
||||
<finalName>integrated_yjb_scheduled</finalName>
|
||||
<finalName>sx_yjb_scheduled</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.zcloud.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* 说明:MES数据源配置
|
||||
*/
|
||||
@Configuration
|
||||
@MapperScan(basePackages = Mes2DataSourceConfig.PACKAGE, sqlSessionFactoryRef = "mes2SqlSessionFactory")
|
||||
public class Mes2DataSourceConfig {
|
||||
|
||||
static final String PACKAGE = "com.zcloud.mapper.dsno2.monitoring2"; //mapper 目录
|
||||
static final String MAPPER_LOCATION = "classpath:mybatis/dsno2/monitoring2/*.xml"; //扫描的 xml 目录
|
||||
static final String CONFIG_LOCATION = "classpath:mybatis/dsno2/mybatis-config.xml"; //自定义的mybatis config 文件位置
|
||||
static final String TYPE_ALIASES_PACKAGE = "com.zcloud.entity"; //扫描的 实体类 目录
|
||||
|
||||
@Value("${datasource.mes2.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${datasource.mes2.username}")
|
||||
private String user;
|
||||
|
||||
@Value("${datasource.mes2.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${datasource.mes2.driver-class-name}")
|
||||
private String driverClass;
|
||||
|
||||
@Bean(name = "mes2DataSource")
|
||||
public DataSource mesDataSource() throws SQLException {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setDriverClassName(driverClass);
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@Bean(name = "mes2TransactionManager")
|
||||
public DataSourceTransactionManager mesTransactionManager() throws SQLException {
|
||||
return new DataSourceTransactionManager(mesDataSource());
|
||||
}
|
||||
|
||||
@Bean(name = "mes2SqlSessionFactory")
|
||||
public SqlSessionFactory mesSqlSessionFactory(@Qualifier("mes2DataSource") DataSource mesDataSource) throws Exception {
|
||||
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
||||
sessionFactory.setDataSource(mesDataSource);
|
||||
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(Mes2DataSourceConfig.MAPPER_LOCATION));
|
||||
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(Mes2DataSourceConfig.CONFIG_LOCATION));
|
||||
sessionFactory.setTypeAliasesPackage(Mes2DataSourceConfig.TYPE_ALIASES_PACKAGE);
|
||||
return sessionFactory.getObject();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,283 @@
|
|||
package com.zcloud.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.zcloud.entity.PageData;
|
||||
import com.zcloud.mapper.datasource.tbIron.TbIronPlcMapper;
|
||||
import com.zcloud.mapper.dsno2.target.MesDeviceMonitoringMapper;
|
||||
import com.zcloud.util.*;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("app")
|
||||
public class AppPosiDeviceController {
|
||||
@Resource
|
||||
private TbIronPlcMapper tbIronPlcMapper;
|
||||
|
||||
@Resource
|
||||
private MesDeviceMonitoringMapper mesDeviceMonitoringMapper;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@PostMapping("/test1")
|
||||
public R test1(@RequestBody HashMap<String, String> parma) throws Exception {
|
||||
System.out.println("测试接口,请更换正式接口!");
|
||||
// 打印接收的数据 排序分类显示
|
||||
printReceiveData(parma);
|
||||
// 批量存储数据
|
||||
batchInsert(parma);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/receiver")
|
||||
public R receiver(@RequestBody HashMap<String, String> parma) throws Exception {
|
||||
// 打印接收的数据 排序分类显示
|
||||
printReceiveData(parma);
|
||||
// 批量存储数据
|
||||
batchInsert(parma);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
void printReceiveData(HashMap<String, String> parma) {
|
||||
System.out.println("———————————————————————————————————————————————————————————————————————————————————————————————————————————");
|
||||
// 1. 初始化分组Map,确保键唯一(使用LinkedHashMap保持插入顺序,可选)
|
||||
Map<String, List<Map.Entry<String, String>>> groupMap = new LinkedHashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : parma.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
// 提取前缀(统一处理为trimmed字符串,避免隐式空格导致的重复)
|
||||
String[] keyParts = splitKeyIntoPrefixAndNumber(key);
|
||||
String prefix = keyParts[0].trim(); // 去除可能的空格,确保键唯一
|
||||
|
||||
// 强制使用唯一键:若已存在该前缀,直接添加到现有列表;否则创建新列表
|
||||
groupMap.computeIfAbsent(prefix, k -> new ArrayList<>()).add(entry);
|
||||
}
|
||||
|
||||
// 2. 组内按数字排序(空数字视为0)
|
||||
for (List<Map.Entry<String, String>> group : groupMap.values()) {
|
||||
group.sort((e1, e2) -> {
|
||||
String[] parts1 = splitKeyIntoPrefixAndNumber(e1.getKey());
|
||||
String[] parts2 = splitKeyIntoPrefixAndNumber(e2.getKey());
|
||||
int num1 = parseNumber(parts1[1]);
|
||||
int num2 = parseNumber(parts2[1]);
|
||||
return Integer.compare(num1, num2);
|
||||
});
|
||||
}
|
||||
|
||||
// 3. 打印分组(每个组只输出一次)
|
||||
System.out.println("===== 传感器设备数据(去重分组输出) =====");
|
||||
|
||||
// 遍历分组Map(已去重,每个组只输出一次)
|
||||
groupMap.forEach((prefix, sortedGroup) -> {
|
||||
StringBuilder groupContent = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : sortedGroup) {
|
||||
groupContent.append(entry.getKey()).append(": ").append(entry.getValue()).append(",");
|
||||
}
|
||||
// 移除末尾多余的逗号
|
||||
if (groupContent.length() > 0) {
|
||||
groupContent.setLength(groupContent.length() - 1);
|
||||
}
|
||||
// 输出分组
|
||||
System.out.println("【" + prefix + "组】:" + groupContent);
|
||||
});
|
||||
System.out.println("———————————————————————————————————————————————————————————————————————————————————————————————————————————");
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析数字部分(空或非数字均视为0)
|
||||
*/
|
||||
private int parseNumber(String numberPart) {
|
||||
if (numberPart == null || numberPart.trim().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(numberPart.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆分键为前缀和数字部分(扩展匹配 z2zt、t2td、T2td、td,确保不同前缀正确分组)
|
||||
*/
|
||||
private String[] splitKeyIntoPrefixAndNumber(String key) {
|
||||
if (key == null) {
|
||||
return new String[]{"", null};
|
||||
}
|
||||
String trimmedKey = key.trim(); // 去除首尾空格,避免干扰
|
||||
|
||||
// 优先匹配 T2zt 前缀
|
||||
if (trimmedKey.startsWith("T2zt")) {
|
||||
String numberPart = trimmedKey.substring(4); // 截取 z2zt 后的内容作为数字部分
|
||||
return new String[]{"T2zt", numberPart};
|
||||
}
|
||||
|
||||
// 匹配 t2zt 前缀
|
||||
if (trimmedKey.startsWith("t2zt")) {
|
||||
String numberPart = trimmedKey.substring(4); // 截取 z2zt 后的内容作为数字部分
|
||||
return new String[]{"t2zt", numberPart};
|
||||
}
|
||||
// 匹配 t2td 前缀
|
||||
else if (trimmedKey.startsWith("t2td")) {
|
||||
String numberPart = trimmedKey.substring(4); // 截取 t2td 后的内容作为数字部分
|
||||
return new String[]{"t2td", numberPart};
|
||||
}
|
||||
// 匹配 T2td 前缀(原逻辑保留)
|
||||
else if (trimmedKey.startsWith("T2td")) {
|
||||
String numberPart = trimmedKey.substring(4); // 截取 T2td 后的内容作为数字部分
|
||||
return new String[]{"T2td", numberPart};
|
||||
}
|
||||
// 匹配 td 前缀(原逻辑保留)
|
||||
else if (trimmedKey.startsWith("td")) {
|
||||
String numberPart = trimmedKey.substring(2); // 截取 td 后的内容作为数字部分
|
||||
return new String[]{"td", numberPart};
|
||||
}
|
||||
// 其他键:前缀为自身,无数字部分
|
||||
else {
|
||||
return new String[]{trimmedKey, null};
|
||||
}
|
||||
}
|
||||
|
||||
void batchInsert(HashMap<String, String> parma) {
|
||||
// 定义处理批次数据 ID
|
||||
String processingBatchId = UuidUtil.get32UUID();
|
||||
// 批处理时间
|
||||
String processingTime = DateUtil.date2Str(new Date());
|
||||
// td1 和 t2td1 的值是一氧化碳浓度 每次数据至多两条(安装在一起的设备)
|
||||
String location = parma.get("location");
|
||||
// 根据设备的地点和td1或者是t2td1判断出设备对应系统中的哪个
|
||||
// 查出所有一氧化碳设备的阈值配置
|
||||
PageData equPd = new PageData();
|
||||
List<PageData> targetAllList = tbIronPlcMapper.listTargetByEquId(equPd);
|
||||
// 定义一个存储集合用于存储要入库的数据
|
||||
List<Map<String, Object>> dataList = new ArrayList<>();
|
||||
if (location.equals("1#高炉中控室")) {
|
||||
// 如果是1#高炉中控室,td1的值为1#高炉中控室(上)的CO浓度,t2td1的值为1#高炉中控室(下)的CO浓度。
|
||||
if (parma.containsKey("td1")) {
|
||||
// 如果包含td1,证明1#高炉中控室(上)的CO浓度有值 将一氧化碳的浓度值、所属设备编码(EQUIPMENT_ID)、预警阈值传入方法
|
||||
dataList.add(saveData(parma.get("td1"), "8eab7aff5585192b028e9592e2a6c6e9", targetAllList, processingBatchId, processingTime));
|
||||
} else if (parma.containsKey("t2td1")) {
|
||||
dataList.add(saveData(parma.get("t2td1"), "cf0c414e21e0413aac3ac53e53c33058", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
} else if (location.equals("2#高炉中控室")) {
|
||||
if (parma.containsKey("t2td1")) {
|
||||
dataList.add(saveData(parma.get("t2td1"), "90313d5f6a22cefcd2ea44c871481723", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
} else if (location.equals("3#高炉中控室")) {
|
||||
if (parma.containsKey("t2td1")) {
|
||||
dataList.add(saveData(parma.get("t2td1"), "8cf0093ec99a1d09cac2e8bc207c0d8b", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
} else if (location.equals("型钢中控室")) {
|
||||
if (parma.containsKey("td1")) {
|
||||
dataList.add(saveData(parma.get("td1"), "da04c8ae4e7b2bacaafae391a3baa0aa", targetAllList, processingBatchId, processingTime));
|
||||
} else if (parma.containsKey("t2td1")) {
|
||||
dataList.add(saveData(parma.get("t2td1"), "60ef896d9f6af5705430cf6aa8d52174", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
} else if (location.equals("15万高炉煤气柜中控室")) {
|
||||
if (parma.containsKey("td1")) {
|
||||
dataList.add(saveData(parma.get("td1"), "07d5be0f912ae11418772b39d447665b", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
} else if (location.equals("新跨大包热修")) {
|
||||
if (parma.containsKey("td1")) {
|
||||
dataList.add(saveData(parma.get("td1"), "188624b575d36e4bc2cffd57c78b3314", targetAllList, processingBatchId, processingTime));
|
||||
}
|
||||
}
|
||||
// 存储集合中处理好的数据
|
||||
mesDeviceMonitoringMapper.saveBatchFromMes(dataList);
|
||||
|
||||
// 将物联网数据存入Redis缓存
|
||||
redisUtil.set("WMK_DATA_LIST", JSONObject.toJSONString(dataList));
|
||||
XxlJobHelper.log("成功保存{}条物联网模块数据到本地数据库", dataList.size());
|
||||
}
|
||||
|
||||
// 定义一个通用的保存数据的方法
|
||||
HashMap<String, Object> saveData(String CURRENT_VALUE, String EQUIPMENT_ID, List<PageData> targetAllList, String processingBatchId, String processingTime) {
|
||||
// 根据给出的设备ID,找出对应设备的预警阈值数据
|
||||
List<PageData> collect = targetAllList.stream().filter(item -> !Tools.isEmpty(item.get("EQUIPMENT_ID")) && item.get("EQUIPMENT_ID").equals(EQUIPMENT_ID)).collect(Collectors.toList());
|
||||
// 定义数据Map
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("MONITORING_ID", UuidUtil.get32UUID());
|
||||
data.put("CURRENT_VALUE", CURRENT_VALUE);
|
||||
data.put("PROCESSING_TIME", processingTime);
|
||||
data.put("PROCESSING_BATCH_ID", processingBatchId);
|
||||
data.put("INSERT_TIME", DateUtil.date2Str(new Date()));
|
||||
data.put("WARNING", 0); // 是否告警 要完善相关告警逻辑进行判断
|
||||
data.put("GATHER_TIME", 5);
|
||||
data.put("PLC_NAME", "");
|
||||
data.put("OVERVIEW_OF_ALERTS", "");
|
||||
data.put("EQUIPMENT_ID", EQUIPMENT_ID);
|
||||
// 每个设备只有一个监测数据阈值,也就是一氧化碳浓度
|
||||
if (collect.size() > 0) {
|
||||
PageData pageData = collect.get(0);
|
||||
data.put("TARGET_NAME", pageData.getString("TARGET_NAME"));
|
||||
data.put("IPCDEVICE_ID", pageData.getString("IPCDEVICE_ID"));
|
||||
data.put("PLC_ID", pageData.getString("PLC_ID"));
|
||||
data.put("TARGET_TYPE", pageData.getString("TARGET_TYPE"));
|
||||
data.put("TARGET_PLACE", pageData.getString("TARGET_PLACE"));
|
||||
data.put("TARGET_UNIT", pageData.getString("TARGET_UNIT"));
|
||||
data.put("THRESHOLD_UP_LIMIT", pageData.getString("THRESHOLD_UP_LIMIT"));
|
||||
data.put("THRESHOLD_UP_UP_LIMIT", pageData.getString("THRESHOLD_UP_UP_LIMIT"));
|
||||
data.put("THRESHOLD_DOWN_LIMIT", pageData.getString("THRESHOLD_DOWN_LIMIT"));
|
||||
data.put("THRESHOLD_DOWN_DOWN_LIMIT", pageData.getString("THRESHOLD_DOWN_DOWN_LIMIT"));
|
||||
data.put("RANGE_UP", pageData.getString("RANGE_UP"));
|
||||
data.put("RANGE_DOWN", pageData.getString("RANGE_DOWN"));
|
||||
data.put("TARGET_DESCRIPTION", pageData.getString("TARGET_DESCRIPTION"));
|
||||
data.put("BIT_NO", pageData.getString("BIT_NO"));
|
||||
data.put("SIGNAL_TYPE", pageData.getString("SIGNAL_TYPE"));
|
||||
data.put("ALARM_VALUE", pageData.getString("ALARM_VALUE"));
|
||||
data.put("TARGET_STATUS", pageData.getString("TARGET_STATUS"));
|
||||
data.put("CORPINFO_ID", pageData.getString("CORPINFO_ID"));
|
||||
data.put("REPORT_ID", pageData.getString("REPORT_ID"));
|
||||
} else {
|
||||
data.put("IPCDEVICE_ID", "");
|
||||
data.put("PLC_ID", "");
|
||||
data.put("TARGET_TYPE", "");
|
||||
data.put("TARGET_PLACE", "");
|
||||
data.put("TARGET_UNIT", "");
|
||||
data.put("THRESHOLD_UP_LIMIT", "");
|
||||
data.put("THRESHOLD_UP_UP_LIMIT", "");
|
||||
data.put("THRESHOLD_DOWN_LIMIT", "");
|
||||
data.put("THRESHOLD_DOWN_DOWN_LIMIT", "");
|
||||
data.put("RANGE_UP", "");
|
||||
data.put("RANGE_DOWN", "");
|
||||
data.put("TARGET_DESCRIPTION", "");
|
||||
data.put("BIT_NO", "");
|
||||
data.put("SIGNAL_TYPE", "");
|
||||
data.put("ALARM_VALUE", "");
|
||||
data.put("TARGET_STATUS", "");
|
||||
data.put("CORPINFO_ID", "");
|
||||
data.put("REPORT_ID", "");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// 参数示例
|
||||
// {
|
||||
// "td1": "node0101", -》设备的CO浓度
|
||||
// "workshop": "高炉区域", -》车间
|
||||
// "equipment": "气体检测报警控制器", -》设备名称
|
||||
// "mode!": "ZD-Y32", -》
|
||||
// "vendor": "南京智达", -》设备厂家
|
||||
// "location": "1#高炉中控室", -》安装地点
|
||||
// "display area": "1#高炉中控室", -》安装地点
|
||||
// "host id": "T001", -》
|
||||
|
||||
// "t2td1": "node0201", -》设备的CO浓度
|
||||
// "t2zt1": "node0209", -》设备的状态 (不用管)
|
||||
// "workshop": "高炉区域", -》车间
|
||||
// "equipment": "CO报警仪", -》设备名称
|
||||
// "mode!": "CL-9100", -》
|
||||
// "vendor": "深圳市科陆", -》设备厂家
|
||||
// "location": "1#高炉中控室", -》安装地点
|
||||
// "display area": "1#高炉中控室", -》安装地点
|
||||
// "host id": "T001-T002" -》
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
package com.zcloud.mapper.datasource.tbIron;
|
||||
|
||||
import com.zcloud.entity.PageData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public interface TbIronPlcMapper {
|
||||
|
||||
|
||||
ArrayList<HashMap<String,String>> listAll ();
|
||||
|
||||
List<PageData> listTargetByEquId(PageData pd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,23 +12,10 @@ import java.util.Map;
|
|||
*/
|
||||
@Repository
|
||||
public interface MesDataMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 获取MES系统中的所有数据点
|
||||
* @return 数据点列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllMesData();
|
||||
|
||||
/**
|
||||
* 根据条件查询MES数据
|
||||
* @param pd 查询条件
|
||||
* @return 数据列表
|
||||
*/
|
||||
List<PageData> listMesDataByCondition(PageData pd);
|
||||
|
||||
/**
|
||||
* 批量保存从MES获取的数据
|
||||
* @param dataList 数据列表
|
||||
*/
|
||||
void saveBatchFromMes(List<Map<String, Object>> dataList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.zcloud.mapper.dsno2.monitoring2;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MES数据访问接口
|
||||
*/
|
||||
@Repository
|
||||
public interface MesDataMapper2 {
|
||||
|
||||
/**
|
||||
* 获取MES系统中的所有数据点
|
||||
* @return 数据点列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllMesData();
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.zcloud.mapper.dsno2.target;
|
||||
|
||||
import com.zcloud.entity.PageData;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MES数据访问接口
|
||||
*/
|
||||
@Repository
|
||||
public interface MesDeviceMonitoringMapper {
|
||||
|
||||
/**
|
||||
* 根据条件查询MES数据
|
||||
* @param pd 查询条件
|
||||
* @return 数据列表
|
||||
*/
|
||||
List<PageData> listMesDataByCondition(PageData pd);
|
||||
|
||||
/**
|
||||
* 批量保存从MES获取的数据
|
||||
* @param dataList 数据列表
|
||||
*/
|
||||
void saveBatchFromMes(List<Map<String, Object>> dataList);
|
||||
}
|
||||
|
|
@ -4,7 +4,11 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.xxl.job.core.context.XxlJobHelper;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zcloud.entity.PageData;
|
||||
import com.zcloud.mapper.datasource.tbIron.TbIronPlcMapper;
|
||||
import com.zcloud.mapper.dsno2.monitoring.MesDataMapper;
|
||||
import com.zcloud.mapper.dsno2.monitoring2.MesDataMapper2;
|
||||
import com.zcloud.mapper.dsno2.target.MesDeviceMonitoringMapper;
|
||||
import com.zcloud.util.DateUtil;
|
||||
import com.zcloud.util.RedisUtil;
|
||||
import com.zcloud.util.UuidUtil;
|
||||
|
|
@ -13,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* MES系统数据对接定时任务
|
||||
|
|
@ -26,6 +31,15 @@ public class MesDataScheduled extends IJobHandler {
|
|||
@Resource
|
||||
private MesDataMapper mesDataMapper;
|
||||
|
||||
@Resource
|
||||
private MesDataMapper2 mesDataMapper2;
|
||||
|
||||
@Resource
|
||||
private TbIronPlcMapper tbIronPlcMapper;
|
||||
|
||||
@Resource
|
||||
private MesDeviceMonitoringMapper mesDeviceMonitoringMapper;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
|
|
@ -34,36 +48,13 @@ public class MesDataScheduled extends IJobHandler {
|
|||
public void execute() throws Exception {
|
||||
XxlJobHelper.log("开始执行MES系统数据对接任务");
|
||||
|
||||
// 处理批次 ID
|
||||
String processingBatchId = UuidUtil.get32UUID();
|
||||
// 批处理时间
|
||||
String processingTime = DateUtil.date2Str(new Date());
|
||||
|
||||
try {
|
||||
// 从MES系统获取数据
|
||||
List<Map<String, Object>> mesDataList = mesDataMapper.listAllMesData();
|
||||
XxlJobHelper.log("从MES系统获取到{}条数据", mesDataList.size());
|
||||
|
||||
// 处理数据
|
||||
for (Map<String, Object> item : mesDataList) {
|
||||
// 添加处理时间和批次ID
|
||||
item.put("PROCESSING_TIME", processingTime);
|
||||
item.put("PROCESSING_BATCH_ID", processingBatchId);
|
||||
|
||||
// 处理空值
|
||||
item.replaceAll((k, v) -> v == null ? "" : v);
|
||||
}
|
||||
|
||||
// 保存数据到数据库
|
||||
// if (!mesDataList.isEmpty()) {
|
||||
// mesDataMapper.saveBatchFromMes(mesDataList);
|
||||
// XxlJobHelper.log("成功保存{}条MES数据到本地数据库", mesDataList.size());
|
||||
//
|
||||
// // 将数据存入Redis缓存
|
||||
// redisUtil.set("MES_DATA_LIST", JSONObject.toJSONString(mesDataList));
|
||||
// XxlJobHelper.log("已将MES数据存入Redis缓存");
|
||||
// }
|
||||
|
||||
// 处理批次 ID
|
||||
String processingBatchId = UuidUtil.get32UUID();
|
||||
// 批处理时间
|
||||
String processingTime = DateUtil.date2Str(new Date());
|
||||
// 保存转炉和精炼炉的数据
|
||||
this.jllAndZlSaveMethod(processingBatchId, processingTime);
|
||||
XxlJobHelper.log("MES系统数据对接任务执行完成");
|
||||
} catch (Exception e) {
|
||||
XxlJobHelper.log("MES系统数据对接任务执行异常: {}", e.getMessage());
|
||||
|
|
@ -82,12 +73,169 @@ public class MesDataScheduled extends IJobHandler {
|
|||
}
|
||||
|
||||
@Scheduled(cron ="*/5 * * * * ?")
|
||||
public void scheduled(){
|
||||
try {
|
||||
System.out.println( "============定时查询MES数据==========");
|
||||
List<Map<String, Object>> mesDataList = mesDataMapper.listAllMesData();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// @Scheduled(cron ="0 0/5 * * * ?")
|
||||
public void scheduled() throws Exception {
|
||||
this.execute();
|
||||
}
|
||||
|
||||
// 存储转炉和精炼炉数据
|
||||
void jllAndZlSaveMethod(String processingBatchId, String processingTime) {
|
||||
// 转炉和精炼炉MES对接过来的数据
|
||||
List<Map<String, Object>> mesDataList = mesDataMapper.listAllMesData();
|
||||
// 高炉MES对接过来的数据
|
||||
List<Map<String, Object>> mesRawDataList = mesDataMapper2.listAllMesData();
|
||||
// 使用枚举参照编码将高炉数据放入mesData总数据中
|
||||
for (Map<String, Object> map : mesRawDataList) {
|
||||
HashMap<String, Object> mesPreMap = new HashMap<>();
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
if (TagDescription.getDescriptionByTag(key) != "未找到对应的高炉变量key描述信息") {
|
||||
mesPreMap.put(TagDescription.getDescriptionByTag(key), map.get(key));
|
||||
}
|
||||
}
|
||||
mesDataList.add(mesPreMap);
|
||||
}
|
||||
|
||||
XxlJobHelper.log("从MES系统获取到{}条数据", mesDataList.size());
|
||||
|
||||
// 查询填报的所有阈值数据
|
||||
PageData equPd = new PageData();
|
||||
List<PageData> targetAllList = tbIronPlcMapper.listTargetByEquId(equPd);
|
||||
|
||||
// 1#精炼炉
|
||||
List<PageData> jll1TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("ee8263519520e35fd18168a531f0837a"))
|
||||
.collect(Collectors.toList());
|
||||
// 2#精炼炉
|
||||
List<PageData> jll2TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("ede5a2e669ea08b3d7dbb22dce05c583"))
|
||||
.collect(Collectors.toList());
|
||||
// 1#转炉
|
||||
List<PageData> zl1TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("21a32f0f65a41f2949ac832ac39714f0"))
|
||||
.collect(Collectors.toList());
|
||||
// 2#转炉
|
||||
List<PageData> zl2TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("2c83b99df54e80a674be5657b11db55c"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1#高炉
|
||||
List<PageData> gl1TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("67c2e8315ca57d68201762e4ce9db351"))
|
||||
.collect(Collectors.toList());
|
||||
// 2#高炉
|
||||
List<PageData> gl2TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("2cb052450581597064b510118c076e2a"))
|
||||
.collect(Collectors.toList());
|
||||
// 3#高炉
|
||||
List<PageData> gl3TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("7face71b8cb7b47872cbe94f9b16831d"))
|
||||
.collect(Collectors.toList());
|
||||
// 4#高炉
|
||||
List<PageData> gl4TargetList = targetAllList.stream()
|
||||
.filter(item -> item.get("EQUIPMENT_ID") != null && item.get("EQUIPMENT_ID").equals("c6825a6e1c959c3e5c800433516b2e8d"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 保存数据到数据库
|
||||
if (!mesDataList.isEmpty()) {
|
||||
ArrayList<Map<String, Object>> mesSaveList = new ArrayList<>();
|
||||
for (Map<String, Object> map : mesDataList) {
|
||||
Set<String> keySet = map.keySet();
|
||||
for (String key : keySet) {
|
||||
HashMap<String, Object> mesData = new HashMap<>();
|
||||
mesData.put("MONITORING_ID", UuidUtil.get32UUID());
|
||||
mesData.put("TARGET_NAME", key);
|
||||
mesData.put("CURRENT_VALUE", map.get(key));
|
||||
mesData.put("PROCESSING_TIME", processingTime);
|
||||
mesData.put("PROCESSING_BATCH_ID", processingBatchId);
|
||||
mesData.put("INSERT_TIME", DateUtil.date2Str(new Date()));
|
||||
mesData.put("WARNING", 0); // 是否告警 要完善相关告警逻辑进行判断
|
||||
mesData.put("GATHER_TIME", 5);
|
||||
mesData.put("PLC_NAME", "");
|
||||
mesData.put("OVERVIEW_OF_ALERTS", "");
|
||||
// 下面是在已经填报的
|
||||
String[] parts = key.split("_", 2); // split("_", 2) 限制分割为2部分
|
||||
String suffix = "";
|
||||
if (parts.length > 1) {
|
||||
suffix = parts[1]; // 下划线后面:1LFS
|
||||
}
|
||||
List<PageData> collect = new ArrayList<>();
|
||||
if (suffix.equals("1LFS")) {
|
||||
mesData.put("EQUIPMENT_ID", "ede5a2e669ea08b3d7dbb22dce05c583");
|
||||
collect = jll1TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (suffix.equals("2LFS")) {
|
||||
mesData.put("EQUIPMENT_ID", "ee8263519520e35fd18168a531f0837a");
|
||||
collect = jll2TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (suffix.equals("A1") || suffix.equals("B1")) {
|
||||
mesData.put("EQUIPMENT_ID", "21a32f0f65a41f2949ac832ac39714f0");
|
||||
collect = zl1TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (suffix.equals("A2") || suffix.equals("B2")) {
|
||||
mesData.put("EQUIPMENT_ID", "2c83b99df54e80a674be5657b11db55c");
|
||||
collect = zl2TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (key.contains("1#")) {
|
||||
mesData.put("EQUIPMENT_ID", "c6825a6e1c959c3e5c800433516b2e8d");
|
||||
collect = gl1TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (key.contains("2#")) {
|
||||
mesData.put("EQUIPMENT_ID", "7face71b8cb7b47872cbe94f9b16831d");
|
||||
collect = gl2TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (key.contains("3#")) {
|
||||
mesData.put("EQUIPMENT_ID", "2cb052450581597064b510118c076e2a");
|
||||
collect = gl3TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
} else if (key.contains("4#")) {
|
||||
mesData.put("EQUIPMENT_ID", "67c2e8315ca57d68201762e4ce9db351");
|
||||
collect = gl4TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
|
||||
}
|
||||
if (collect.size() > 0) {
|
||||
PageData pageData = collect.get(0);
|
||||
mesData.put("IPCDEVICE_ID", pageData.getString("IPCDEVICE_ID"));
|
||||
mesData.put("PLC_ID", pageData.getString("PLC_ID"));
|
||||
mesData.put("TARGET_TYPE", pageData.getString("TARGET_TYPE"));
|
||||
mesData.put("TARGET_PLACE", pageData.getString("TARGET_PLACE"));
|
||||
mesData.put("TARGET_UNIT", pageData.getString("TARGET_UNIT"));
|
||||
mesData.put("THRESHOLD_UP_LIMIT", pageData.getString("THRESHOLD_UP_LIMIT"));
|
||||
mesData.put("THRESHOLD_UP_UP_LIMIT", pageData.getString("THRESHOLD_UP_UP_LIMIT"));
|
||||
mesData.put("THRESHOLD_DOWN_LIMIT", pageData.getString("THRESHOLD_DOWN_LIMIT"));
|
||||
mesData.put("THRESHOLD_DOWN_DOWN_LIMIT", pageData.getString("THRESHOLD_DOWN_DOWN_LIMIT"));
|
||||
mesData.put("RANGE_UP", pageData.getString("RANGE_UP"));
|
||||
mesData.put("RANGE_DOWN", pageData.getString("RANGE_DOWN"));
|
||||
mesData.put("TARGET_DESCRIPTION", pageData.getString("TARGET_DESCRIPTION"));
|
||||
mesData.put("BIT_NO", pageData.getString("BIT_NO"));
|
||||
mesData.put("SIGNAL_TYPE", pageData.getString("SIGNAL_TYPE"));
|
||||
mesData.put("ALARM_VALUE", pageData.getString("ALARM_VALUE"));
|
||||
mesData.put("TARGET_STATUS", pageData.getString("TARGET_STATUS"));
|
||||
mesData.put("CORPINFO_ID", pageData.getString("CORPINFO_ID"));
|
||||
mesData.put("REPORT_ID", pageData.getString("REPORT_ID"));
|
||||
} else {
|
||||
mesData.put("IPCDEVICE_ID", "");
|
||||
mesData.put("PLC_ID", "");
|
||||
mesData.put("TARGET_TYPE", "");
|
||||
mesData.put("TARGET_PLACE", "");
|
||||
mesData.put("TARGET_UNIT", "");
|
||||
mesData.put("THRESHOLD_UP_LIMIT", "");
|
||||
mesData.put("THRESHOLD_UP_UP_LIMIT", "");
|
||||
mesData.put("THRESHOLD_DOWN_LIMIT", "");
|
||||
mesData.put("THRESHOLD_DOWN_DOWN_LIMIT", "");
|
||||
mesData.put("RANGE_UP", "");
|
||||
mesData.put("RANGE_DOWN", "");
|
||||
mesData.put("TARGET_DESCRIPTION", "");
|
||||
mesData.put("BIT_NO", "");
|
||||
mesData.put("SIGNAL_TYPE", "");
|
||||
mesData.put("ALARM_VALUE", "");
|
||||
mesData.put("TARGET_STATUS", "");
|
||||
mesData.put("CORPINFO_ID", "");
|
||||
mesData.put("REPORT_ID", "");
|
||||
}
|
||||
mesSaveList.add(mesData);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理接过来的MES数据
|
||||
mesDeviceMonitoringMapper.saveBatchFromMes(mesSaveList);
|
||||
XxlJobHelper.log("成功保存{}条MES数据到本地数据库", mesSaveList.size());
|
||||
|
||||
// 将数据存入Redis缓存
|
||||
redisUtil.set("MES_DATA_LIST", JSONObject.toJSONString(mesSaveList));
|
||||
XxlJobHelper.log("已将MES数据存入Redis缓存");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.zcloud.scheduled.dataDocking;
|
||||
|
||||
public enum TagDescription {
|
||||
// 定义枚举常量,TAG值作为名称,描述作为参数
|
||||
TAG325("1#炉顶西压力"),
|
||||
TAG326("1#炉顶东压力"),
|
||||
TAG317("1#高炉南放散开关"),
|
||||
TAG318("1#高炉北放散开关"),
|
||||
TAG327("2#炉顶西压力"),
|
||||
TAG328("2#炉顶东压力"),
|
||||
TAG319("2#高炉南放散开关"),
|
||||
TAG320("2#高炉北放散开关"),
|
||||
TAG329("3#炉顶西压力"),
|
||||
TAG330("3#炉顶东压力"),
|
||||
TAG321("3#高炉南放散开关"),
|
||||
TAG322("3#高炉北放散开关"),
|
||||
TAG331("4#煤气上升管东北压力"),
|
||||
TAG332("4#煤气上升管东南压力"),
|
||||
TAG333("4#煤气上升管西北压力"),
|
||||
TAG334("4#煤气上升管西南压力"),
|
||||
TAG323("4#高炉南放散开关"),
|
||||
TAG324("4#高炉北放散开关");
|
||||
|
||||
// 存储描述信息的成员变量
|
||||
private final String description;
|
||||
|
||||
// 构造方法
|
||||
TagDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
// 获取描述信息的方法
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
// 根据TAG字符串获取对应的描述
|
||||
public static String getDescriptionByTag(String tag) {
|
||||
try {
|
||||
// 通过valueOf方法查找对应的枚举常量
|
||||
return TagDescription.valueOf(tag).getDescription();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// 如果没有找到对应的TAG,返回默认信息或抛出异常
|
||||
return "未找到对应的高炉变量key描述信息";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
|
||||
|
||||
package com.zcloud.util;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public R() {
|
||||
put("code", 200);
|
||||
put("result", "success");
|
||||
}
|
||||
|
||||
public static R error() {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static R error(String msg) {
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
|
||||
}
|
||||
|
||||
public static R error(int code, String msg) {
|
||||
R r = new R();
|
||||
r.put("code", code);
|
||||
r.put("result", "failed");
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(String msg) {
|
||||
R r = new R();
|
||||
r.put("msg", msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok(Map<String, Object> map) {
|
||||
R r = new R();
|
||||
r.putAll(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static R ok() {
|
||||
return new R();
|
||||
}
|
||||
|
||||
public R put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,25 @@
|
|||
datasource.no1.driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
datasource.no1.url=jdbc:mysql://127.0.0.1:3306/integrated_yjb?allowPublicKeyRetrieval=true&serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8
|
||||
datasource.no1.url=jdbc:mysql://172.16.70.228:33080/sx_yjb?allowPublicKeyRetrieval=true&serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8
|
||||
datasource.no1.username=root
|
||||
datasource.no1.password=Mysql@zcloud33080
|
||||
#
|
||||
datasource.no2.driver-class-name:org.postgresql.Driver
|
||||
datasource.no2.url=jdbc:postgresql://127.0.0.1:3306/postgres?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=UTC
|
||||
datasource.no2.url=jdbc:postgresql://172.16.70.228:15431/postgres?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=UTC
|
||||
datasource.no2.username=postgres
|
||||
datasource.no2.password=DjIGYM8k0h
|
||||
datasource.no2.password=Mysql@zcloud15431
|
||||
#MES系统数据库配置
|
||||
datasource.mes.driver-class-name=oracle.jdbc.OracleDriver
|
||||
datasource.mes.driver-class-name=oracle.jdbc.driver.OracleDriver
|
||||
datasource.mes.url=jdbc:oracle:thin:@172.16.90.252:1521/jymes
|
||||
datasource.mes.username=drzf
|
||||
datasource.mes.password=drzf
|
||||
datasource.mes2.driver-class-name=oracle.jdbc.driver.OracleDriver
|
||||
datasource.mes2.url=jdbc:oracle:thin:@172.16.90.227:1521/emsdb
|
||||
datasource.mes2.username=drzf
|
||||
datasource.mes2.password=drzf
|
||||
#redis
|
||||
spring.redis.host=10.199.64.30
|
||||
spring.redis.password=5.5pYdZqHxpR#9%W.
|
||||
spring.redis.database=4
|
||||
spring.redis.host=172.16.70.226
|
||||
spring.redis.password=Zcloud@redis16379
|
||||
spring.redis.database=10
|
||||
spring.redis.port=16379
|
||||
|
||||
#druidè¿æ¥æ±
|
||||
|
|
@ -60,3 +64,5 @@ xxl.job.accessToken=yjb.prod
|
|||
xxl.job.port=1211
|
||||
xxl.job.executor.appname=yjb-job-normal-task
|
||||
xxl.job.executor.logretentiondays=30
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,4 +30,44 @@
|
|||
WHERE
|
||||
p.CORPINFO_ID = '499d43c24fab49f59391ce49fb401837' and p.ISDELETE = 0 and mt.ISDELETE = 0
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!-- 查询填报的数据上下限高低值范围 -->
|
||||
<select id="listTargetByEquId" parameterType="com.zcloud.entity.PageData" resultType="com.zcloud.entity.PageData">
|
||||
select
|
||||
p.MONITORING_ID,
|
||||
p.IPCDEVICE_ID,
|
||||
p.PLC_ID,
|
||||
plc.EQUIPMENT_ID,
|
||||
p.TARGET_NAME,
|
||||
p.TARGET_TYPE,
|
||||
p.TARGET_PLACE,
|
||||
p.TARGET_UNIT,
|
||||
p.THRESHOLD_UP_LIMIT,
|
||||
p.THRESHOLD_UP_UP_LIMIT,
|
||||
p.THRESHOLD_DOWN_LIMIT,
|
||||
p.THRESHOLD_DOWN_DOWN_LIMIT,
|
||||
p.RANGE_UP,
|
||||
p.RANGE_DOWN,
|
||||
p.TARGET_DESCRIPTION,
|
||||
p.BIT_NO,
|
||||
p.SIGNAL_TYPE,
|
||||
p.ALARM_VALUE,
|
||||
p.TARGET_STATUS,
|
||||
p.CORPINFO_ID,
|
||||
p.CREATOR,
|
||||
p.CREATTIME,
|
||||
p.OPERATOR,
|
||||
p.OPERATTIME,
|
||||
p.ISDELETE,
|
||||
p.REPORT_ID
|
||||
from
|
||||
tb_iron_monitoring_target p
|
||||
left join tb_iron_plc plc ON p.PLC_ID = plc.PLC_ID
|
||||
where
|
||||
p.ISDELETE = 0
|
||||
and
|
||||
plc.ISDELETE = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -4,43 +4,6 @@
|
|||
|
||||
<!-- 查询所有MES数据,使用MyBatis自动映射功能 -->
|
||||
<select id="listAllMesData" resultType="java.util.HashMap">
|
||||
select * from drzf_view
|
||||
select * from jymes.drzf_view
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询MES数据 -->
|
||||
<select id="listMesDataByCondition" parameterType="com.zcloud.entity.PageData" resultType="com.zcloud.entity.PageData">
|
||||
SELECT * FROM mes_data_view
|
||||
WHERE 1=1
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
AND DEVICE_ID = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
AND DEVICE_NAME LIKE CONCAT('%', #{deviceName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量保存从MES获取的数据 -->
|
||||
<insert id="saveBatchFromMes" parameterType="java.util.List">
|
||||
INSERT INTO target_table (
|
||||
ID,
|
||||
DEVICE_ID,
|
||||
DEVICE_NAME,
|
||||
CURRENT_VALUE,
|
||||
GATHER_TIME,
|
||||
PROCESSING_TIME,
|
||||
PROCESSING_BATCH_ID
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.ID, jdbcType=VARCHAR},
|
||||
#{item.DEVICE_ID, jdbcType=VARCHAR},
|
||||
#{item.DEVICE_NAME, jdbcType=VARCHAR},
|
||||
#{item.CURRENT_VALUE, jdbcType=VARCHAR},
|
||||
#{item.GATHER_TIME, jdbcType=TIMESTAMP},
|
||||
#{item.PROCESSING_TIME, jdbcType=TIMESTAMP},
|
||||
#{item.PROCESSING_BATCH_ID, jdbcType=VARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zcloud.mapper.dsno2.monitoring2.MesDataMapper2">
|
||||
|
||||
<!-- 查询所有MES数据,使用MyBatis自动映射功能 -->
|
||||
<select id="listAllMesData" resultType="java.util.HashMap">
|
||||
select * from ems.drzf_view
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zcloud.mapper.dsno2.target.MesDeviceMonitoringMapper">
|
||||
|
||||
<!-- 根据条件查询MES数据 -->
|
||||
<select id="listMesDataByCondition" parameterType="com.zcloud.entity.PageData" resultType="com.zcloud.entity.PageData">
|
||||
SELECT * FROM mes_data_view
|
||||
WHERE 1=1
|
||||
<if test="deviceId != null and deviceId != ''">
|
||||
AND DEVICE_ID = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
AND DEVICE_NAME LIKE CONCAT('%', #{deviceName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 批量保存从MES获取的数据 注意列名加双引号,防止自动转换为小写导致无法匹配pg数据库的大写列名,pg数据库严格按照大小写进行字段匹配。 -->
|
||||
<insert id="saveBatchFromMes" parameterType="java.util.List">
|
||||
INSERT INTO "sx_yjb".device_monitoring_sxgt (
|
||||
"MONITORING_ID",
|
||||
"TARGET_NAME",
|
||||
"TARGET_PLACE",
|
||||
"TARGET_UNIT",
|
||||
"SIGNAL_TYPE",
|
||||
"CURRENT_VALUE",
|
||||
"ALARM_VALUE",
|
||||
"THRESHOLD_UP_LIMIT",
|
||||
"THRESHOLD_UP_UP_LIMIT",
|
||||
"THRESHOLD_DOWN_LIMIT",
|
||||
"THRESHOLD_DOWN_DOWN_LIMIT",
|
||||
"RANGE_UP",
|
||||
"RANGE_DOWN",
|
||||
"PROCESSING_TIME",
|
||||
"INSERT_TIME",
|
||||
"PLC_ID",
|
||||
"WARNING",
|
||||
"GATHER_TIME",
|
||||
"CORPINFO_ID",
|
||||
"IPCDEVICE_ID",
|
||||
"PLC_NAME",
|
||||
"PROCESSING_BATCH_ID",
|
||||
"OVERVIEW_OF_ALERTS",
|
||||
"EQUIPMENT_ID"
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.MONITORING_ID, jdbcType=CHAR},
|
||||
#{item.TARGET_NAME, jdbcType=VARCHAR},
|
||||
#{item.TARGET_PLACE, jdbcType=VARCHAR},
|
||||
#{item.TARGET_UNIT, jdbcType=VARCHAR},
|
||||
#{item.SIGNAL_TYPE, jdbcType=VARCHAR},
|
||||
#{item.CURRENT_VALUE, jdbcType=VARCHAR},
|
||||
#{item.ALARM_VALUE, jdbcType=VARCHAR},
|
||||
#{item.THRESHOLD_UP_LIMIT, jdbcType=VARCHAR},
|
||||
#{item.THRESHOLD_UP_UP_LIMIT, jdbcType=VARCHAR},
|
||||
#{item.THRESHOLD_DOWN_LIMIT, jdbcType=VARCHAR},
|
||||
#{item.THRESHOLD_DOWN_DOWN_LIMIT, jdbcType=VARCHAR},
|
||||
#{item.RANGE_UP, jdbcType=VARCHAR},
|
||||
#{item.RANGE_DOWN, jdbcType=VARCHAR},
|
||||
#{item.PROCESSING_TIME, jdbcType=VARCHAR},
|
||||
to_timestamp(#{item.INSERT_TIME}, 'yyyy-MM-dd HH24:mi:ss'),
|
||||
#{item.PLC_ID, jdbcType=CHAR},
|
||||
#{item.WARNING, jdbcType=CHAR},
|
||||
#{item.GATHER_TIME, jdbcType=VARCHAR},
|
||||
#{item.CORPINFO_ID, jdbcType=VARCHAR},
|
||||
#{item.IPCDEVICE_ID, jdbcType=VARCHAR},
|
||||
#{item.PLC_NAME, jdbcType=VARCHAR},
|
||||
#{item.PROCESSING_BATCH_ID, jdbcType=VARCHAR},
|
||||
#{item.OVERVIEW_OF_ALERTS, jdbcType=VARCHAR},
|
||||
#{item.EQUIPMENT_ID, jdbcType=VARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue