威尔普斯采集数据BUG处理
This commit is contained in:
parent
97299bee61
commit
4841c936b2
|
@ -5,6 +5,7 @@ package com.isu.gaswellwatch.modbus.data.listener;
|
|||
* 2024/11/23 0:32
|
||||
*/
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.amqp.core.AmqpAdmin;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.core.QueueBuilder;
|
||||
|
@ -22,6 +23,7 @@ import java.util.stream.IntStream;
|
|||
public class DynamicRabbitListener implements ApplicationRunner {
|
||||
|
||||
private final AmqpAdmin amqpAdmin;
|
||||
@Getter
|
||||
private final ComposeModbusMessageListener composeListener;
|
||||
private final ComposeModbusMessageListener businessMessageListener;
|
||||
private final SimpleMessageListenerContainer modbusMessageListenerContainer;
|
||||
|
|
|
@ -207,8 +207,12 @@ public class ModbusMessagePersistListener implements BatchMessageListener {
|
|||
} else if (stepSize <= 1) {
|
||||
messagePoint = modbusMessage.getMessagePointMap()
|
||||
.get(StringUtils.leftPad(String.valueOf(startAddress), 4, '0'));
|
||||
decodeMessage(decodeName, point, messagePoint);
|
||||
value = messagePoint.getValue();
|
||||
if (Objects.isNull(messagePoint)) {
|
||||
value = StringUtils.EMPTY;
|
||||
} else {
|
||||
decodeMessage(decodeName, point, messagePoint);
|
||||
value = messagePoint.getValue();
|
||||
}
|
||||
} else {
|
||||
value = decodeStepCommandPoint(modbusMessage.getMessagePointMap(), decodeName, point, startAddress, stepSize);
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
@ -66,7 +67,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
|
||||
@Override
|
||||
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName, Long deviceTypeId, Long blockId, Integer product) {
|
||||
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId,product);
|
||||
Page<DeviceVO> page = this.deviceDao.page(new Page<>(currentPage, pageSize), gasWellName, gasStationName, deviceTypeId, blockId, product);
|
||||
List<DeviceVO> deviceVOList = page.getRecords();
|
||||
// 从Redis获取设备运行数据
|
||||
if (CollectionUtil.isNotEmpty(deviceVOList)) {
|
||||
|
@ -93,7 +94,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Object online = this.redisTemplate.opsForHash().get(deviceKey, "online");
|
||||
deviceVO.setOnline(online == null ? "" : online.toString());
|
||||
|
||||
if(PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())){
|
||||
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());
|
||||
|
||||
|
@ -104,7 +105,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Dictionary runMode1 = controlModeMap.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
}else if(PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())){
|
||||
} else if (PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(deviceVO.getProduct().getCode())) {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "firstSolenoidStatus");
|
||||
deviceVO.setWellStatus(gas_status == null ? "" : gas_status.toString());
|
||||
|
||||
|
@ -115,7 +116,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
Dictionary runMode1 = ctlModeMap.get(runMode.toString());
|
||||
deviceVO.setRunMode(runMode1 == null ? "" : runMode1.getName());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Object gas_status = this.redisTemplate.opsForHash().get(deviceKey, "wellStatus");
|
||||
deviceVO.setWellStatus(gas_status == null ? "" : gas_status.toString());
|
||||
|
||||
|
@ -185,7 +186,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
this.gasWellService.unbindDevice(gasWellId);
|
||||
|
||||
//删除t_data_设备历史数据表 删除缓存和MQ
|
||||
cacheService.cleanDeviceCache(id);
|
||||
this.cacheService.cleanDeviceCache(id);
|
||||
|
||||
}
|
||||
|
||||
|
@ -221,13 +222,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
@Override
|
||||
public List<DeviceHistoryVO> getPressureChartData(Long deviceId, String startTime, String endTime) {
|
||||
String tableName = Redis2DBPersistenceService.DEFAULT_DATA_TABLE + deviceId;
|
||||
return deviceDao.getPressureChartData(deviceId,startTime,endTime,tableName);
|
||||
return this.deviceDao.getPressureChartData(deviceId, startTime, endTime, tableName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime,String deviceProduct) {
|
||||
public List<DeviceHistoryVO> getSwitchStatusData(Long deviceId, String startTime, String endTime, String deviceProduct) {
|
||||
String tableName = Redis2DBPersistenceService.DEFAULT_DATA_TABLE + deviceId;
|
||||
return deviceDao.getSwitchStatusData(deviceId,startTime,endTime,tableName,deviceProduct);
|
||||
return this.deviceDao.getSwitchStatusData(deviceId, startTime, endTime, tableName, deviceProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -244,18 +245,21 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
}
|
||||
//判断设备品牌
|
||||
DeviceVO device = this.getDevice(deviceId);
|
||||
List<DeviceHistoryVO> list = this.deviceDao.getDeviceHistoryData(start, end,deviceId,tableName,device.getProduct().getCode());
|
||||
List<DeviceHistoryVO> list = this.deviceDao.getDeviceHistoryData(start, end, deviceId, tableName, device.getProduct().getCode());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
Map<String, Dictionary> runModeMap = this.dictionaryService.getValueMapByType("runMode");
|
||||
if(PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())){
|
||||
if (PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())) {
|
||||
runModeMap = this.dictionaryService.getValueMapByType("controlMode");
|
||||
}else if(PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())){
|
||||
} else if (PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())) {
|
||||
runModeMap = this.dictionaryService.getValueMapByType("ctlMode");
|
||||
}
|
||||
Map<String, Dictionary> plugStatusMap = this.dictionaryService.getValueMapByType("plugStatus");
|
||||
|
||||
for (DeviceHistoryVO deviceVO : list) {
|
||||
if (Objects.equals(deviceVO.getType(), PersistenceHandler.WEPS_PLUG_MODBUS_TYPE)) {
|
||||
continue;
|
||||
}
|
||||
deviceVO.setRunMode(StringUtils.isEmpty(deviceVO.getRunMode()) ? "" : runModeMap.get(deviceVO.getRunMode()).getName());
|
||||
deviceVO.setPlugStatus(StringUtils.isEmpty(deviceVO.getPlugStatus()) ? "" : plugStatusMap.get(deviceVO.getPlugStatus()).getName());
|
||||
}
|
||||
|
@ -268,8 +272,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
String fileName = null;
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
fileName = URLEncoder.encode(device.getGasWell().getName()+"|"+simpleDateFormat.format(new Date()), StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
|
||||
fileName = URLEncoder.encode(device.getGasWell().getName() + "|" + simpleDateFormat.format(new Date()), StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
EasyExcel.write(outputStream)
|
||||
// 这里放入动态头
|
||||
|
@ -277,7 +281,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
// 当然这里数据也可以用 List<List<String>> 去传入
|
||||
.doWrite(export);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
this.log.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -287,9 +291,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
UserLoginInfoVO userLoginInfoVO = (UserLoginInfoVO) StpUtil.getTokenSession().get(UserConstant.TOKEN_SESSION);
|
||||
UserVO userVO = userService.selectUserInfo(userLoginInfoVO.getUserVO().getUsername());
|
||||
UserVO userVO = this.userService.selectUserInfo(userLoginInfoVO.getUserVO().getUsername());
|
||||
|
||||
List<SwitchStatusExport> list = switchStatusExportService.getSwitchStatusExport(startTime, endTime,userVO.getDepartment().getId());
|
||||
List<SwitchStatusExport> list = this.switchStatusExportService.getSwitchStatusExport(startTime, endTime, userVO.getDepartment().getId());
|
||||
|
||||
List<SwitchStatusExportVO> export = ConverterUtil.convert(list, SwitchStatusExportVO.class);
|
||||
|
||||
|
@ -298,8 +302,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
String fileName = null;
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
fileName = URLEncoder.encode("全井数据-"+simpleDateFormat.format(new Date()), StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
response.setHeader("Access-Control-Expose-Headers","Content-Disposition");
|
||||
fileName = URLEncoder.encode("全井数据-" + simpleDateFormat.format(new Date()), StandardCharsets.UTF_8).replaceAll("\\+", "%20");
|
||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
EasyExcel.write(outputStream)
|
||||
// 这里放入动态头
|
||||
|
@ -307,7 +311,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
// 当然这里数据也可以用 List<List<String>> 去传入
|
||||
.doWrite(export);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
this.log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,13 +332,13 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
|||
//判断设备品牌
|
||||
DeviceVO device = this.getDevice(deviceId);
|
||||
|
||||
Page<DeviceHistoryVO> page = this.deviceDao.historyPage(new Page<>(currentPage, pageSize), start, end, deviceId, tableName,device.getProduct().getCode());
|
||||
Page<DeviceHistoryVO> page = this.deviceDao.historyPage(new Page<>(currentPage, pageSize), start, end, deviceId, tableName, device.getProduct().getCode());
|
||||
List<DeviceHistoryVO> deviceHistoryVO = page.getRecords();
|
||||
if (CollectionUtil.isNotEmpty(deviceHistoryVO)) {
|
||||
Map<String, Dictionary> runModeMap = this.dictionaryService.getValueMapByType("runMode");
|
||||
if(PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())){
|
||||
if (PersistenceHandler.ETC_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())) {
|
||||
runModeMap = this.dictionaryService.getValueMapByType("controlMode");
|
||||
}else if(PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())){
|
||||
} else if (PersistenceHandler.SCSS_MODBUS_TYPE.equalsIgnoreCase(device.getProduct().getCode())) {
|
||||
runModeMap = this.dictionaryService.getValueMapByType("ctlMode");
|
||||
}
|
||||
Map<String, Dictionary> plugStatusMap = this.dictionaryService.getValueMapByType("plugStatus");
|
||||
|
|
|
@ -23,7 +23,7 @@ import static com.isu.gaswellwatch.modbus.data.PersistenceHandler.*;
|
|||
@Service("summaryService")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Slf4j
|
||||
public class SummaryServiceImpl implements SummaryService {
|
||||
public class SummaryServiceImpl implements SummaryService {
|
||||
|
||||
@Resource(name = "stringRedisTemplate")
|
||||
private RedisTemplate redisTemplate;
|
||||
|
@ -34,27 +34,27 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
@Override
|
||||
public List<PieSummaryVO> getIndexPieSummary() {
|
||||
Map<String,String> onlineMap = new HashMap<>();
|
||||
try{
|
||||
onlineMap = redisTemplate.opsForHash().entries(ONLINE_DEVICE_CACHE);
|
||||
}catch (RedisConnectionFailureException e){
|
||||
log.error("获取在线设备缓存失败",e);
|
||||
return getPieSummaryVOS();
|
||||
Map<String, String> onlineMap = new HashMap<>();
|
||||
try {
|
||||
onlineMap = this.redisTemplate.opsForHash().entries(ONLINE_DEVICE_CACHE);
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
log.error("获取在线设备缓存失败", e);
|
||||
return getPieSummaryVOS();
|
||||
}
|
||||
|
||||
if(onlineMap.isEmpty()){
|
||||
if (onlineMap.isEmpty()) {
|
||||
return getPieSummaryVOS();
|
||||
}
|
||||
// List<Long> deviceIdList = onlineMap.keySet().stream().map(Long::parseLong).toList();
|
||||
|
||||
List<DeviceVO> deviceVOList = deviceService.getDeviceVOByIds(null);
|
||||
List<DeviceVO> deviceVOList = this.deviceService.getDeviceVOByIds(null);
|
||||
|
||||
//将所有设备按不同的设备品牌进行分组
|
||||
Map<String,List<DeviceVO>> deviceGroup = new HashMap<>();
|
||||
Map<String, List<DeviceVO>> deviceGroup = new HashMap<>();
|
||||
for (DeviceVO deviceVO : deviceVOList) {
|
||||
if(deviceGroup.containsKey(deviceVO.getProduct().getCode())){
|
||||
if (deviceGroup.containsKey(deviceVO.getProduct().getCode())) {
|
||||
deviceGroup.get(deviceVO.getProduct().getCode()).add(deviceVO);
|
||||
}else {
|
||||
} else {
|
||||
List<DeviceVO> deviceVOList1 = new ArrayList<>();
|
||||
deviceVOList1.add(deviceVO);
|
||||
deviceGroup.put(deviceVO.getProduct().getCode(), deviceVOList1);
|
||||
|
@ -63,9 +63,11 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
List<PieSummaryVO> pieSummaryVOList = new ArrayList<>();
|
||||
|
||||
addKNPCDeviceSummary(KNPCV1_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"KNPCV1");
|
||||
addKNPCDeviceSummary(ETC_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"ETC");
|
||||
addKNPCDeviceSummary(SCSS_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"四川双晟");
|
||||
addKNPCDeviceSummary(KNPCV1_MODBUS_TYPE, deviceGroup, onlineMap, pieSummaryVOList, "KNPCV1");
|
||||
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, "维尔普斯");
|
||||
|
||||
//计算总数
|
||||
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||
|
@ -76,16 +78,16 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
Integer offLineCount = 0;
|
||||
|
||||
|
||||
for(DeviceVO deviceVO : deviceVOList){
|
||||
if("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))){
|
||||
for (DeviceVO deviceVO : deviceVOList) {
|
||||
if ("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))) {
|
||||
onLineCount++;
|
||||
}else {
|
||||
} else {
|
||||
offLineCount++;
|
||||
}
|
||||
}
|
||||
PieDataVO onlinePieDataVO = new PieDataVO("在线",onLineCount);
|
||||
PieDataVO offlinePieDataVO = new PieDataVO("离线",offLineCount);
|
||||
pieSummaryVO.setData(List.of(onlinePieDataVO,offlinePieDataVO));
|
||||
PieDataVO onlinePieDataVO = new PieDataVO("在线", onLineCount);
|
||||
PieDataVO offlinePieDataVO = new PieDataVO("离线", offLineCount);
|
||||
pieSummaryVO.setData(List.of(onlinePieDataVO, offlinePieDataVO));
|
||||
|
||||
pieSummaryVOList.add(pieSummaryVO);
|
||||
|
||||
|
@ -95,13 +97,13 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
@Override
|
||||
public LineSummaryVO getPressureChartData(String startTime, String endTime, Long deviceId) {
|
||||
//根据设备ID、时间范围查询设备历史数据表的油压 套压
|
||||
DeviceVO deviceVO = deviceService.getDevice(deviceId);
|
||||
if(deviceVO == null){
|
||||
DeviceVO deviceVO = this.deviceService.getDevice(deviceId);
|
||||
if (deviceVO == null) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
List<String> xAxisData = new ArrayList<>();
|
||||
|
||||
List<DeviceHistoryVO> dataList = deviceService.getPressureChartData(deviceId,startTime,endTime);
|
||||
List<DeviceHistoryVO> dataList = this.deviceService.getPressureChartData(deviceId, startTime, endTime);
|
||||
//将查询到的结果组装成LineSummaryVO返回给前端
|
||||
LineSummaryVO lineSummaryVO = new LineSummaryVO();
|
||||
lineSummaryVO.setTitle(deviceVO.getGasWell().getName());
|
||||
|
@ -117,11 +119,11 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
List<String> casPressureData = new ArrayList<>();
|
||||
List<String> prePressureData = new ArrayList<>();
|
||||
|
||||
for(DeviceHistoryVO deviceHistoryVO : dataList){
|
||||
for (DeviceHistoryVO deviceHistoryVO : dataList) {
|
||||
xAxisData.add(deviceHistoryVO.getCollectionTime());
|
||||
oilPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getOilPressure())?"0":deviceHistoryVO.getOilPressure());
|
||||
casPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getCasPressure())?"0":deviceHistoryVO.getCasPressure());
|
||||
prePressureData.add(StringUtils.isEmpty(deviceHistoryVO.getPrePressure())?"0":deviceHistoryVO.getPrePressure());
|
||||
oilPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getOilPressure()) ? "0" : deviceHistoryVO.getOilPressure());
|
||||
casPressureData.add(StringUtils.isEmpty(deviceHistoryVO.getCasPressure()) ? "0" : deviceHistoryVO.getCasPressure());
|
||||
prePressureData.add(StringUtils.isEmpty(deviceHistoryVO.getPrePressure()) ? "0" : deviceHistoryVO.getPrePressure());
|
||||
}
|
||||
|
||||
//设置x轴数据(日期)
|
||||
|
@ -175,13 +177,13 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
@Override
|
||||
public LineSummaryVO getSwitchChartData(String startTime, String endTime, Long deviceId) {
|
||||
DeviceVO deviceVO = deviceService.getDevice(deviceId);
|
||||
if(deviceVO == null){
|
||||
DeviceVO deviceVO = this.deviceService.getDevice(deviceId);
|
||||
if (deviceVO == null) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
List<String> xAxisData = new ArrayList<>();
|
||||
|
||||
List<DeviceHistoryVO> dataList = deviceService.getSwitchStatusData(deviceId,startTime,endTime,deviceVO.getProduct().getCode());
|
||||
List<DeviceHistoryVO> dataList = this.deviceService.getSwitchStatusData(deviceId, startTime, endTime, deviceVO.getProduct().getCode());
|
||||
LineSummaryVO lineSummaryVO = new LineSummaryVO();
|
||||
lineSummaryVO.setTitle(deviceVO.getGasWell().getName());
|
||||
|
||||
|
@ -192,9 +194,9 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
|
||||
List<String> switchStatusData = new ArrayList<>();
|
||||
|
||||
for(DeviceHistoryVO deviceHistoryVO : dataList){
|
||||
for (DeviceHistoryVO deviceHistoryVO : dataList) {
|
||||
xAxisData.add(deviceHistoryVO.getCollectionTime());
|
||||
switchStatusData.add(StringUtils.isEmpty(deviceHistoryVO.getWellStatus())?"0":deviceHistoryVO.getWellStatus());
|
||||
switchStatusData.add(StringUtils.isEmpty(deviceHistoryVO.getWellStatus()) ? "0" : deviceHistoryVO.getWellStatus());
|
||||
}
|
||||
|
||||
//设置x轴数据(日期)
|
||||
|
@ -245,21 +247,21 @@ public class SummaryServiceImpl implements SummaryService {
|
|||
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||
pieSummaryVO.setChartName(productName);
|
||||
pieSummaryVO.setTitle(title);
|
||||
if(knpcDeviceList != null){
|
||||
if (knpcDeviceList != null) {
|
||||
//根据设备列表查找在线map中的状态进行统计在线数量
|
||||
Integer onLineCount = 0;
|
||||
Integer offLineCount = 0;
|
||||
for(DeviceVO deviceVO : knpcDeviceList){
|
||||
if("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))){
|
||||
for (DeviceVO deviceVO : knpcDeviceList) {
|
||||
if ("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))) {
|
||||
onLineCount++;
|
||||
}else {
|
||||
} else {
|
||||
offLineCount++;
|
||||
}
|
||||
}
|
||||
PieDataVO onlinePieDataVO = new PieDataVO("在线",onLineCount);
|
||||
PieDataVO offlinePieDataVO = new PieDataVO("离线",offLineCount);
|
||||
pieSummaryVO.setData(List.of(onlinePieDataVO,offlinePieDataVO));
|
||||
}else{
|
||||
PieDataVO onlinePieDataVO = new PieDataVO("在线", onLineCount);
|
||||
PieDataVO offlinePieDataVO = new PieDataVO("离线", offLineCount);
|
||||
pieSummaryVO.setData(List.of(onlinePieDataVO, offlinePieDataVO));
|
||||
} else {
|
||||
//无值时需要构建空值结构
|
||||
pieSummaryVO.setData(new ArrayList<>());
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
/**
|
||||
* 设备对象 Device
|
||||
*
|
||||
*
|
||||
* @author scwsl
|
||||
* @date 2024-11-17
|
||||
*/
|
||||
|
@ -21,37 +21,65 @@ public class DeviceHistoryVO extends Model<DeviceHistoryVO> {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 采集时间 */
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 采集时间
|
||||
*/
|
||||
private String collectionTime;
|
||||
|
||||
/** 油压 */
|
||||
/**
|
||||
* 油压
|
||||
*/
|
||||
private String oilPressure;
|
||||
|
||||
/** 套压 */
|
||||
/**
|
||||
* 套压
|
||||
*/
|
||||
private String casPressure;
|
||||
|
||||
/** 输压 */
|
||||
/**
|
||||
* 输压
|
||||
*/
|
||||
private String prePressure;
|
||||
|
||||
/** 运行模式 */
|
||||
/**
|
||||
* 运行模式
|
||||
*/
|
||||
private String runMode;
|
||||
|
||||
/** 柱塞状态 */
|
||||
/**
|
||||
* 柱塞状态
|
||||
*/
|
||||
private String plugStatus;
|
||||
|
||||
/** 气井状态 */
|
||||
/**
|
||||
* 气井状态
|
||||
*/
|
||||
private String wellStatus;
|
||||
|
||||
/** 倒计时 */
|
||||
/**
|
||||
* 倒计时
|
||||
*/
|
||||
private String statusEndTime;
|
||||
|
||||
/** 温度 */
|
||||
/**
|
||||
* 温度
|
||||
*/
|
||||
private String temperature;
|
||||
|
||||
/** 湿度 */
|
||||
/**
|
||||
* 湿度
|
||||
*/
|
||||
private String humidity;
|
||||
|
||||
/** 太阳能电压 */
|
||||
/**
|
||||
* 太阳能电压
|
||||
*/
|
||||
private String solarVoltage;
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ spring:
|
|||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
url: jdbc:mysql://localhost:3306/gas_well_watch?characterEncoding=UTF-8&useUnicode=true&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: cq
|
||||
password: cq
|
||||
username: dev
|
||||
password: 1qaz@WSX
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
@ -171,15 +171,26 @@
|
|||
|
||||
<select id="getDeviceHistoryData" resultType="com.isu.gaswellwatch.vo.DeviceHistoryVO">
|
||||
select t.collection_time,t.oil_pressure,t.cas_pressure,t.pre_pressure
|
||||
<if test="deviceProduct!=null and deviceProduct=='knpc'">
|
||||
,t.run_mode,t.status_end_time,t.temperature,t.humidity,t.well_status,t.plug_status
|
||||
</if>
|
||||
<if test="deviceProduct!=null and deviceProduct=='etc'">,t.current_status_remaining_time as
|
||||
statusEndTime,t.controller_current_status as runMode,t.solenoid_valve_status as wellStatus
|
||||
</if>
|
||||
<if test="deviceProduct!=null and deviceProduct=='scss'">,t.ctl_model as runMode,t.remaining_time_action as
|
||||
statusEndTime,t.solar_voltage,t.first_solenoid_status as wellStatus
|
||||
</if>
|
||||
<choose>
|
||||
<when test="deviceProduct!=null and deviceProduct=='knpc'">
|
||||
,'knpc' as type,t.run_mode,t.status_end_time,t.temperature,t.humidity,t.well_status,t.plug_status
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='etc'">
|
||||
,'etc' as type,t.current_status_remaining_time as statusEndTime
|
||||
,t.controller_current_status as runMode,t.solenoid_valve_status as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='scss'">
|
||||
,'scss' as type,t.ctl_model as runMode,t.remaining_time_action as statusEndTime
|
||||
,t.solar_voltage,t.first_solenoid_status as wellStatus
|
||||
</when>
|
||||
<when test="deviceProduct!=null and deviceProduct=='weps_plug'">
|
||||
,'weps_plug' as type,case t.run_mode when 1 then '定时开关井模式'
|
||||
when 2 then '压力优化微升模式' when 3 then '自动优化模式' else '未知' end as runMode
|
||||
,case t.solenoid_valve_status when 2 then t.open_well_remaining_time
|
||||
when 1 then t.close_well_remaining_time else null end as statusEndTime
|
||||
,case t.solenoid_valve_status when 2 then '关井' when 1 then '开井' else null end as wellStatus
|
||||
</when>
|
||||
</choose>
|
||||
from ${tableName} t
|
||||
<where>
|
||||
t.device_id = #{deviceId}
|
||||
|
|
|
@ -8,37 +8,39 @@ INSERT INTO `$TableName$`(`id`, `device_id`, `created_time`, `collection_time`,
|
|||
`close_well_time`, `open_well_cas_pressure`, `little_rise_cas_pressure`,
|
||||
`check_stability_time`, `min_close_well_time`, `max_close_well_time`, `min_open_well_time`,
|
||||
`max_open_well_time`, `well_depth`, `produce_mode`)
|
||||
VALUES (?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE receive_time=VALUES(receive_time),
|
||||
cas_pressure=VALUES(cas_pressure),
|
||||
oil_pressure=VALUES(oil_pressure),
|
||||
alarm=VALUES(alarm),
|
||||
solenoid_valve_status=VALUES(solenoid_valve_status),
|
||||
open_well_remaining_time=VALUES(open_well_remaining_time),
|
||||
close_well_remaining_time=VALUES(close_well_remaining_time),
|
||||
plug_arrival_status=VALUES(plug_arrival_status),
|
||||
plug_too_fast_count=VALUES(plug_too_fast_count),
|
||||
plug_rising_speed=VALUES(plug_rising_speed),
|
||||
downstream_pressure=VALUES(downstream_pressure),
|
||||
solenoid_valve_opening=VALUES(solenoid_valve_opening),
|
||||
reserve=VALUES(reserve),
|
||||
pre_pressure=VALUES(pre_pressure),
|
||||
run_mode=VALUES(run_mode),
|
||||
well_status=VALUES(well_status),
|
||||
gas_collection_method=VALUES(gas_collection_method),
|
||||
high_pressure_protection=VALUES(high_pressure_protection),
|
||||
low_pressure_protection=VALUES(low_pressure_protection),
|
||||
too_fast_count=VALUES(too_fast_count),
|
||||
dangerous_rise_time=VALUES(dangerous_rise_time),
|
||||
too_fast_rise_time=VALUES(too_fast_rise_time),
|
||||
open_well_time=VALUES(open_well_time),
|
||||
close_well_time=VALUES(close_well_time),
|
||||
open_well_cas_pressure=VALUES(open_well_cas_pressure),
|
||||
little_rise_cas_pressure=VALUES(little_rise_cas_pressure),
|
||||
check_stability_time=VALUES(check_stability_time),
|
||||
min_close_well_time=VALUES(min_close_well_time),
|
||||
max_close_well_time=VALUES(max_close_well_time),
|
||||
min_open_well_time=VALUES(min_open_well_time),
|
||||
max_open_well_time=VALUES(max_open_well_time),
|
||||
well_depth=VALUES(well_depth),
|
||||
produce_mode=VALUES(produce_mode)
|
||||
VALUES (?, ?, NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?) ON DUPLICATE KEY
|
||||
UPDATE receive_time=
|
||||
VALUES (receive_time), cas_pressure=
|
||||
VALUES (cas_pressure), oil_pressure=
|
||||
VALUES (oil_pressure), alarm=
|
||||
VALUES (alarm), solenoid_valve_status=
|
||||
VALUES (solenoid_valve_status), open_well_remaining_time=
|
||||
VALUES (open_well_remaining_time), close_well_remaining_time=
|
||||
VALUES (close_well_remaining_time), plug_arrival_status=
|
||||
VALUES (plug_arrival_status), plug_too_fast_count=
|
||||
VALUES (plug_too_fast_count), plug_rising_speed=
|
||||
VALUES (plug_rising_speed), downstream_pressure=
|
||||
VALUES (downstream_pressure), solenoid_valve_opening=
|
||||
VALUES (solenoid_valve_opening), reserve=
|
||||
VALUES (reserve), pre_pressure=
|
||||
VALUES (pre_pressure), run_mode=
|
||||
VALUES (run_mode), well_status=
|
||||
VALUES (well_status), gas_collection_method=
|
||||
VALUES (gas_collection_method), high_pressure_protection=
|
||||
VALUES (high_pressure_protection), low_pressure_protection=
|
||||
VALUES (low_pressure_protection), too_fast_count=
|
||||
VALUES (too_fast_count), dangerous_rise_time=
|
||||
VALUES (dangerous_rise_time), too_fast_rise_time=
|
||||
VALUES (too_fast_rise_time), open_well_time=
|
||||
VALUES (open_well_time), close_well_time=
|
||||
VALUES (close_well_time), open_well_cas_pressure=
|
||||
VALUES (open_well_cas_pressure), little_rise_cas_pressure=
|
||||
VALUES (little_rise_cas_pressure), check_stability_time=
|
||||
VALUES (check_stability_time), min_close_well_time=
|
||||
VALUES (min_close_well_time), max_close_well_time=
|
||||
VALUES (max_close_well_time), min_open_well_time=
|
||||
VALUES (min_open_well_time), max_open_well_time=
|
||||
VALUES (max_open_well_time), well_depth=
|
||||
VALUES (well_depth), produce_mode=
|
||||
VALUES (produce_mode)
|
||||
|
|
Loading…
Reference in New Issue