威尔普斯名称修改;统计查询修改
This commit is contained in:
parent
2b4bd351b7
commit
1a82fdd52d
|
@ -194,28 +194,32 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
.ofInstant(Instant.ofEpochMilli(modbusMessage.getCollectionTime()), ZoneOffset.systemDefault())
|
||||
.format(LocalDateTimeDecodeHandler.OUT_FORMATTER));
|
||||
for (Map<String, Object> point : commandPointList) {
|
||||
fieldName = MapUtil.getStr(point, "field");
|
||||
stepSize = MapUtil.getInt(point, "step_size");
|
||||
decodeName = MapUtil.getStr(point, "decode_name");
|
||||
startAddress = MapUtil.getInt(point, "start_address");
|
||||
String value;
|
||||
if (StringUtils.equals(decodeName, HighLowBinDecodeHandler.NAME)) {
|
||||
value = decodeHighLowCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress);
|
||||
} else if (StringUtils.contains(decodeName, ",") && StringUtils.startsWith(decodeName, HighLowBinDecodeHandler.NAME)) {
|
||||
value = decodeHighLowStepCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress, stepSize / 2);
|
||||
} else if (stepSize <= 1) {
|
||||
messagePoint = modbusMessage.getMessagePointMap()
|
||||
.get(StringUtils.leftPad(String.valueOf(startAddress), 4, '0'));
|
||||
if (Objects.isNull(messagePoint)) {
|
||||
value = StringUtils.EMPTY;
|
||||
try {
|
||||
fieldName = MapUtil.getStr(point, "field");
|
||||
stepSize = MapUtil.getInt(point, "step_size");
|
||||
decodeName = MapUtil.getStr(point, "decode_name");
|
||||
startAddress = MapUtil.getInt(point, "start_address");
|
||||
String value;
|
||||
if (StringUtils.equals(decodeName, HighLowBinDecodeHandler.NAME)) {
|
||||
value = decodeHighLowCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress);
|
||||
} else if (StringUtils.contains(decodeName, ",") && StringUtils.startsWith(decodeName, HighLowBinDecodeHandler.NAME)) {
|
||||
value = decodeHighLowStepCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress, stepSize / 2);
|
||||
} else if (stepSize <= 1) {
|
||||
messagePoint = modbusMessage.getMessagePointMap()
|
||||
.get(StringUtils.leftPad(String.valueOf(startAddress), 4, '0'));
|
||||
if (Objects.isNull(messagePoint)) {
|
||||
value = StringUtils.EMPTY;
|
||||
} else {
|
||||
decodeMessage(decodeName, point, messagePoint);
|
||||
value = messagePoint.getValue();
|
||||
}
|
||||
} else {
|
||||
decodeMessage(decodeName, point, messagePoint);
|
||||
value = messagePoint.getValue();
|
||||
value = decodeStepCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress, stepSize);
|
||||
}
|
||||
} else {
|
||||
value = decodeStepCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress, stepSize);
|
||||
hashOperations.put(deviceDataCacheName, fieldName, value);
|
||||
} catch (Exception e) {
|
||||
log.error("数据解析失败,message: {}, point: {}", JSONUtil.toJsonStr(modbusMessage), JSONUtil.toJsonStr(point), e);
|
||||
}
|
||||
hashOperations.put(deviceDataCacheName, fieldName, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Service("deviceService")
|
||||
|
@ -74,6 +75,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Map<String, Dictionary> plugStatusMap = this.dictionaryService.getValueMapByType("plugStatus");
|
||||
Map<String, Dictionary> controlModeMap = this.dictionaryService.getValueMapByType("controlMode");
|
||||
Map<String, Dictionary> ctlModeMap = this.dictionaryService.getValueMapByType("ctlMode");
|
||||
Map<String, Dictionary> wepsRunMode = this.dictionaryService.getValueMapByType("wepsRunMode");
|
||||
Map<String, Dictionary> miWepsRunMode = this.dictionaryService.getValueMapByType("miWepsRunMode");
|
||||
Map<String, Dictionary> miWepsPlugStatus = this.dictionaryService.getValueMapByType("miWepsPlugStatus");
|
||||
|
||||
try {
|
||||
for (DeviceVO deviceVO : deviceVOList) {
|
||||
|
@ -93,6 +97,14 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Object online = this.redisTemplate.opsForHash().get(deviceKey, "online");
|
||||
deviceVO.setOnline(online == null ? "" : online.toString());
|
||||
|
||||
Object plugStatus = this.redisTemplate.opsForHash().get(deviceKey, "plugStatus");
|
||||
if (plugStatus == null) {
|
||||
deviceVO.setPlugStatus("");
|
||||
} else {
|
||||
Dictionary plugStatus1 = plugStatusMap.get(plugStatus.toString());
|
||||
deviceVO.setPlugStatus(plugStatus1 == null ? "" : plugStatus1.getName());
|
||||
}
|
||||
|
||||
if (PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())) {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "solenoidValveStatus");
|
||||
deviceVO.setWellStatus(gas_status == null ? "" : gas_status.toString());
|
||||
|
@ -115,6 +127,44 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Dictionary runMode1 = ctlModeMap.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
} else if (PersistenceHandler.WEPS_PLUG_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())) {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "solenoidValveStatus");
|
||||
String wellStatus = "";
|
||||
if (Objects.nonNull(gas_status)) {
|
||||
if (StringUtils.equals("2", gas_status.toString())) {
|
||||
wellStatus = "1";
|
||||
} else if (StringUtils.equals("1", gas_status.toString())) {
|
||||
wellStatus = "0";
|
||||
}
|
||||
}
|
||||
deviceVO.setWellStatus(wellStatus);
|
||||
|
||||
Object runMode = this.redisTemplate.opsForHash().get(deviceKey, "runMode");
|
||||
if (runMode == null) {
|
||||
deviceVO.setRunMode("");
|
||||
} else {
|
||||
Dictionary runMode1 = wepsRunMode.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
} else if (PersistenceHandler.MI_WEPS_PLUG_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())) {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "currentStatus");
|
||||
deviceVO.setWellStatus(gas_status == null ? "" : Objects.equals("0", gas_status.toString()) ? "0" : "1");
|
||||
|
||||
Object runMode = this.redisTemplate.opsForHash().get(deviceKey, "produceMode");
|
||||
if (runMode == null) {
|
||||
deviceVO.setRunMode("");
|
||||
} else {
|
||||
Dictionary runMode1 = miWepsRunMode.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
|
||||
plugStatus = this.redisTemplate.opsForHash().get(deviceKey, "currentStatus");
|
||||
if (plugStatus == null) {
|
||||
deviceVO.setPlugStatus("");
|
||||
} else {
|
||||
Dictionary plugStatus1 = miWepsPlugStatus.get(plugStatus.toString());
|
||||
deviceVO.setPlugStatus(plugStatus1 == null ? "" : plugStatus1.getName());
|
||||
}
|
||||
} else {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "wellStatus");
|
||||
deviceVO.setWellStatus(gas_status == null ? "" : gas_status.toString());
|
||||
|
@ -123,20 +173,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
if (runMode == null) {
|
||||
deviceVO.setRunMode("");
|
||||
} else {
|
||||
Dictionary runMode1 = runModeMap.get(runMode.toString());
|
||||
Dictionary runMode1 = miWepsRunMode.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Object plugStatus = this.redisTemplate.opsForHash().get(deviceKey, "plugStatus");
|
||||
if (plugStatus == null) {
|
||||
deviceVO.setPlugStatus("");
|
||||
} else {
|
||||
Dictionary plugStatus1 = plugStatusMap.get(plugStatus.toString());
|
||||
deviceVO.setPlugStatus(plugStatus1 == null ? "" : plugStatus1.getName());
|
||||
}
|
||||
|
||||
}
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
this.log.error("redis连接失败,请检查redis连接");
|
||||
|
|
|
@ -7,16 +7,14 @@ import com.isu.gaswellwatch.vo.DeviceVO;
|
|||
import com.isu.gaswellwatch.vo.summary.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.isu.gaswellwatch.modbus.data.PersistenceHandler.*;
|
||||
|
||||
|
@ -63,11 +61,10 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
List<PieSummaryVO> pieSummaryVOList = new ArrayList<>();
|
||||
|
||||
addKNPCDeviceSummary(KNPCV1_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "KNPCV1");
|
||||
addKNPCDeviceSummary(KNPCV1_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "KNPC");
|
||||
addKNPCDeviceSummary(ETC_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "ETC");
|
||||
addKNPCDeviceSummary(SCSS_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "四川双晟");
|
||||
addKNPCDeviceSummary(WEPS_PLUG_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "维尔普斯");
|
||||
addKNPCDeviceSummary(MI_WEPS_PLUG_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "MI维尔普斯");
|
||||
addKNPCDeviceSummary(WEPS_PLUG_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "威尔普斯");
|
||||
|
||||
//计算总数
|
||||
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||
|
@ -241,13 +238,13 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
PieSummaryVO pieSummaryVO4 = new PieSummaryVO();
|
||||
pieSummaryVO4.setChartName(WEPS_PLUG_MODBUS_TYPE);
|
||||
pieSummaryVO4.setTitle("维尔普斯");
|
||||
pieSummaryVO4.setTitle("威尔普斯");
|
||||
pieSummaryVO4.setData(List.of());
|
||||
result.add(pieSummaryVO4);
|
||||
|
||||
PieSummaryVO pieSummaryVO5 = new PieSummaryVO();
|
||||
pieSummaryVO5.setChartName(MI_WEPS_PLUG_MODBUS_TYPE);
|
||||
pieSummaryVO5.setTitle("MI维尔普斯");
|
||||
pieSummaryVO5.setTitle("MI威尔普斯");
|
||||
pieSummaryVO5.setData(List.of());
|
||||
result.add(pieSummaryVO5);
|
||||
|
||||
|
@ -256,13 +253,19 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
private static void addKNPCDeviceSummary(String productName, Map<String, List<DeviceVO>> deviceGroup, Map<String, String> onlineMap, List<PieSummaryVO> pieSummaryVOList, String title) {
|
||||
List<DeviceVO> knpcDeviceList = deviceGroup.get(productName);
|
||||
if (Objects.equals(WEPS_PLUG_MODBUS_TYPE, productName)) {
|
||||
if (ObjectUtils.isNotEmpty(knpcDeviceList)) {
|
||||
knpcDeviceList = deviceGroup.get(MI_WEPS_PLUG_MODBUS_TYPE);
|
||||
} else {
|
||||
knpcDeviceList.addAll(Optional.ofNullable(deviceGroup.get(MI_WEPS_PLUG_MODBUS_TYPE)).orElse(List.of()));
|
||||
}
|
||||
}
|
||||
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||
pieSummaryVO.setChartName(productName);
|
||||
pieSummaryVO.setTitle(title);
|
||||
if (knpcDeviceList != null) {
|
||||
if (Objects.isNull(knpcDeviceList)) {
|
||||
//根据设备列表查找在线map中的状态进行统计在线数量
|
||||
Integer onLineCount = 0;
|
||||
Integer offLineCount = 0;
|
||||
int onLineCount = 0, offLineCount = 0;
|
||||
for (DeviceVO deviceVO : knpcDeviceList) {
|
||||
if ("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))) {
|
||||
onLineCount++;
|
||||
|
@ -270,9 +273,8 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
offLineCount++;
|
||||
}
|
||||
}
|
||||
PieDataVO onlinePieDataVO = new PieDataVO("在线", onLineCount);
|
||||
PieDataVO offlinePieDataVO = new PieDataVO("离线", offLineCount);
|
||||
pieSummaryVO.setData(List.of(onlinePieDataVO, offlinePieDataVO));
|
||||
pieSummaryVO.setData(List.of(new PieDataVO("在线", onLineCount),
|
||||
new PieDataVO("离线", offLineCount)));
|
||||
} else {
|
||||
//无值时需要构建空值结构
|
||||
pieSummaryVO.setData(new ArrayList<>());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (29, 'deviceProduct', 'mi_weps_plug', 'MI维尔普斯', '5', 5, now(), now());
|
||||
VALUES (29, 'deviceProduct', 'mi_weps_plug', 'MI威尔普斯', '5', 5, now(), now());
|
||||
|
||||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (30, 'wepsRunMode', 'unknow', '未知', '0', 1, now(), now());
|
||||
|
@ -23,11 +23,11 @@ VALUES (38, 'miWepsRunMode', 'yldlms', '压力跌落模式', '4', 5, now(), now(
|
|||
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
|
||||
`start_address`, `message_length`, `details`)
|
||||
VALUES (10301, 'DEVICE_PRODUCT_CODE', 29, '采集实时数据地址表', 'READ_REAL_TIME_DATA', 'COLLECTION', 30, '010300000016',
|
||||
0, 98, '(老板)维尔普斯控制器实时数据地址表');
|
||||
0, 98, '(老板)威尔普斯控制器实时数据地址表');
|
||||
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
|
||||
`start_address`, `message_length`, `details`)
|
||||
VALUES (10302, 'DEVICE_PRODUCT_CODE', 29, '采集控制器参数地址表', 'READ_CONTROL_PARAM_DATA', 'COLLECTION', 30,
|
||||
'010303EC0047', 1004, 294, '(老板)维尔普斯控制器参数地址表数据采集');
|
||||
'010303EC0047', 1004, 294, '(老板)威尔普斯控制器参数地址表数据采集');
|
||||
|
||||
|
||||
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
|
||||
|
@ -230,7 +230,7 @@ SET `ref_type` = 'DEVICE_PRODUCT_CODE',
|
|||
`command` = '010303EC0048',
|
||||
`start_address` = 1004,
|
||||
`message_length` = 202,
|
||||
`details` = '(老板)维尔普斯控制器参数地址表数据采集'
|
||||
`details` = '(老板)威尔普斯控制器参数地址表数据采集'
|
||||
WHERE `id` = 10302;
|
||||
|
||||
ALTER TABLE `command_points`
|
||||
|
@ -333,7 +333,7 @@ WHERE `id` = 13104;
|
|||
|
||||
update command_points
|
||||
set `precision` = 2
|
||||
where decode_name like '%IEEE754Double%';
|
||||
where decode_name like '%IEEE754Float%';
|
||||
|
||||
UPDATE `gas_well_watch`.`command_points`
|
||||
SET `command_id` = 10302,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (28, 'deviceProduct', 'weps_plug', '维尔普斯', '4', 4, now(), now());
|
||||
VALUES (28, 'deviceProduct', 'weps_plug', '威尔普斯', '4', 4, now(), now());
|
||||
|
||||
INSERT INTO `commands` (`id`, `ref_type`, `ref_id`, `name`, `code`, `type`, `collection_frequency`, `command`,
|
||||
`start_address`, `message_length`, `details`)
|
||||
VALUES (10300, 'DEVICE_PRODUCT_CODE', 28, '采集柱塞模式数据', 'READ_DATA', 'COLLECTION', 30, '010300320020', 32, 138,
|
||||
'(新版)维尔普斯控制器柱塞模式数据全量采集');
|
||||
'(新版)威尔普斯控制器柱塞模式数据全量采集');
|
||||
|
||||
INSERT INTO `command_points` (`id`, `command_id`, `field`, `name`, `details`, `start_address`, `step_size`, `factor`,
|
||||
`precision`, `format`, `decode_name`)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (39, 'miWepsPlugStatus', 'gj', '关井', '0', 0, now(), now());
|
||||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (40, 'miWepsPlugStatus', 'ss', '上升', '1', 1, now(), now());
|
||||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (41, 'miWepsPlugStatus', 'xl', '续流', '2', 2, now(), now());
|
||||
INSERT INTO `dictionary` (`id`, `type`, `code`, `name`, `value`, `sort`, `create_time`, `update_time`)
|
||||
VALUES (42, 'miWepsPlugStatus', 'tj', '停机', '3', 3, now(), now());
|
|
@ -61,4 +61,4 @@ CREATE TABLE `$TableName$`
|
|||
`protection_pressure` decimal(12, 4) NULL DEFAULT NULL COMMENT '保护压力 - 单位:MPa',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `udx_device_create_time` (`device_id` ASC, `collection_time` ASC) USING BTREE COMMENT '设备采集数据唯一键'
|
||||
) ENGINE = InnoDB COMMENT = '维尔普斯设备ID:$DeviceId$的采集数据'
|
||||
) ENGINE = InnoDB COMMENT = '威尔普斯设备ID:$DeviceId$的采集数据'
|
|
@ -39,4 +39,4 @@ CREATE TABLE `$TableName$`
|
|||
`produce_mode` int NULL DEFAULT NULL COMMENT '生产制度;1-常开;2-常关;3-柱塞气举',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `udx_device_create_time` (`device_id` ASC, `collection_time` ASC) USING BTREE COMMENT '设备采集数据唯一键'
|
||||
) ENGINE = InnoDB COMMENT = '维尔普斯设备ID:$DeviceId$的采集数据'
|
||||
) ENGINE = InnoDB COMMENT = '威尔普斯设备ID:$DeviceId$的采集数据'
|
Loading…
Reference in New Issue