Browse Source

外部平台离线通知

develop
lau572 2 weeks ago
parent
commit
889be8a259
  1. 3
      ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java
  2. 53
      ruoyi-ui/src/api/monitor/externalPlatformOffline.js
  3. 302
      ruoyi-ui/src/views/monitor/externalPlatformOffline/index.vue
  4. 17
      zc-business/src/main/java/com/zc/business/controller/DcExternalPlatformHeartbeatController.java
  5. 94
      zc-business/src/main/java/com/zc/business/controller/DcExternalPlatformOfflineController.java
  6. 83
      zc-business/src/main/java/com/zc/business/domain/DcExternalPlatformOffline.java
  7. 5
      zc-business/src/main/java/com/zc/business/mapper/DcExternalPlatformHeartbeatMapper.java
  8. 63
      zc-business/src/main/java/com/zc/business/mapper/DcExternalPlatformOfflineMapper.java
  9. 11
      zc-business/src/main/java/com/zc/business/service/IDcExternalPlatformHeartbeatService.java
  10. 61
      zc-business/src/main/java/com/zc/business/service/IDcExternalPlatformOfflineService.java
  11. 31
      zc-business/src/main/java/com/zc/business/service/impl/DcExternalPlatformHeartbeatServiceImpl.java
  12. 93
      zc-business/src/main/java/com/zc/business/service/impl/DcExternalPlatformOfflineServiceImpl.java
  13. 16
      zc-business/src/main/resources/mapper/business/DcExternalPlatformHeartbeatMapper.xml
  14. 73
      zc-business/src/main/resources/mapper/business/DcExternalPlatformOfflineMapper.xml

3
ruoyi-common/src/main/java/com/zc/common/core/websocket/constant/WebSocketEvent.java

@ -22,4 +22,7 @@ public class WebSocketEvent {
//设备离线记录 //设备离线记录
public static final String DEVICE_OFFLINE_RECORD = "deviceOfflineRecord"; public static final String DEVICE_OFFLINE_RECORD = "deviceOfflineRecord";
//外部平台离线记录
public static final String EXTERNAL_PLATFORM_OFFLINE = "externalPlatformOffline";
} }

53
ruoyi-ui/src/api/monitor/externalPlatformOffline.js

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询外部平台离线记录列表
export function listExternalPlatformOffline(query) {
return request({
url: '/externalPlatformOffline/list',
method: 'get',
params: query
})
}
// 查询外部平台离线记录详细
export function getExternalPlatformOffline(id) {
return request({
url: '/externalPlatformOffline/' + id,
method: 'get'
})
}
// 新增外部平台离线记录
export function addExternalPlatformOffline(data) {
return request({
url: '/externalPlatformOffline',
method: 'post',
data: data
})
}
// 修改外部平台离线记录
export function updateExternalPlatformOffline(data) {
return request({
url: '/externalPlatformOffline',
method: 'put',
data: data
})
}
// 删除外部平台离线记录
export function delExternalPlatformOffline(id) {
return request({
url: '/externalPlatformOffline/' + id,
method: 'delete'
})
}
// 导出外部平台离线记录
export function exportExternalPlatformOffline(query) {
return request({
url: '/externalPlatformOffline/export',
method: 'get',
params: query
})
}

302
ruoyi-ui/src/views/monitor/externalPlatformOffline/index.vue

@ -0,0 +1,302 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="类型" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择类型" clearable>
<el-option
v-for="type in typeList"
:key="type.value"
:label="type.label"
:value="type.value"
/>
</el-select>
</el-form-item>
<el-form-item label="离线时间" prop="offlineTime">
<el-date-picker clearable
v-model="queryParams.offlineTime"
type="date"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择离线时间"
:picker-options="pickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<!--<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>-->
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="externalPlatformOfflineList" >
<!--<el-table-column type="selection" width="55" align="center" />
<el-table-column label="id" align="center" prop="id" />-->
<el-table-column label="平台类型" align="center" prop="type" >
<template slot-scope="scope">
<span v-if="scope.row.type == '1'">GIS+BIM</span>
<span v-if="scope.row.type == '2'">数字孪生</span>
<span v-if="scope.row.type == '3'">收费运营</span>
<span v-if="scope.row.type == '4'">桥梁监测</span>
<span v-if="scope.row.type == '5'">光纤</span>
</template>
</el-table-column>
<el-table-column label="离线时间" align="center" prop="offlineTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.offlineTime, '{y}-{m}-{d} {h}:{i}:{s}') }} </span>
<span v-if="scope.row.endTime"> {{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
<span v-else> 当前</span>
</template>
</el-table-column>
<!--<el-table-column label="结束时间" align="center" prop="endTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>-->
<!--<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>-->
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改外部平台离线记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="离线时间" prop="offlineTime">
<el-date-picker clearable
v-model="form.offlineTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择离线时间">
</el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker clearable
v-model="form.endTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择结束时间">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listExternalPlatformOffline, getExternalPlatformOffline, delExternalPlatformOffline, addExternalPlatformOffline, updateExternalPlatformOffline } from "@/api/monitor/externalPlatformOffline";
export default {
name: "ExternalPlatformOffline",
data() {
return {
typeList:[
{value:'1',label:'GIS+BIM'},
{value:'2',label:'数字孪生'},
{value:'3',label:'收费运营'},
{value:'4',label:'桥梁监测'},
{value:'5',label:'光纤'},
],
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
// 线
externalPlatformOfflineList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
type: null,
offlineTime: null,
endTime: null
},
//
form: {},
//
rules: {
},
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
}
},
};
},
created() {
this.getList();
},
methods: {
/** 查询外部平台离线记录列表 */
getList() {
this.loading = true;
listExternalPlatformOffline(this.queryParams).then(response => {
this.externalPlatformOfflineList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
type: null,
offlineTime: null,
endTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加外部平台离线记录";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getExternalPlatformOffline(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改外部平台离线记录";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateExternalPlatformOffline(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addExternalPlatformOffline(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除外部平台离线记录编号为"' + ids + '"的数据项?').then(function() {
return delExternalPlatformOffline(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('externalPlatformOffline/export', {
...this.queryParams
}, `外部系统离线记录_${new Date().getTime()}.xlsx`)
}
}
};
</script>

17
zc-business/src/main/java/com/zc/business/controller/DcExternalPlatformHeartbeatController.java

@ -11,10 +11,14 @@ import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.common.utils.ip.IpUtils;
import com.zc.business.domain.DcExternalPlatformHeartbeat; import com.zc.business.domain.DcExternalPlatformHeartbeat;
import com.zc.business.domain.DcExternalPlatformOffline;
import com.zc.business.enums.UniversalEnum; import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcExternalPlatformHeartbeatService; import com.zc.business.service.IDcExternalPlatformHeartbeatService;
import com.zc.business.service.IDcExternalPlatformOfflineService;
import com.zc.common.core.httpclient.OkHttp; import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.websocket.WebSocketService;
import com.zc.common.core.websocket.constant.WebSocketEvent;
import okhttp3.Response; import okhttp3.Response;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -46,6 +50,8 @@ public class DcExternalPlatformHeartbeatController extends BaseController
{ {
@Autowired @Autowired
private IDcExternalPlatformHeartbeatService dcExternalPlatformHeartbeatService; private IDcExternalPlatformHeartbeatService dcExternalPlatformHeartbeatService;
@Autowired
private IDcExternalPlatformOfflineService dcExternalPlatformOfflineService;
/** /**
* 查询外部平台心跳日志列表 * 查询外部平台心跳日志列表
@ -127,5 +133,16 @@ public class DcExternalPlatformHeartbeatController extends BaseController
} }
} }
List<DcExternalPlatformOffline> offlineList = dcExternalPlatformHeartbeatService.selectOfflineList();
if (offlineList != null){
for (DcExternalPlatformOffline dcExternalPlatformOffline : offlineList) {
int i = dcExternalPlatformHeartbeatService.selectRepeatRecord(dcExternalPlatformOffline.getType());
if (i == 0){
dcExternalPlatformOfflineService.insertDcExternalPlatformOffline(dcExternalPlatformOffline);
WebSocketService.broadcast(WebSocketEvent.EXTERNAL_PLATFORM_OFFLINE, dcExternalPlatformOffline);
}
}
}
} }
} }

94
zc-business/src/main/java/com/zc/business/controller/DcExternalPlatformOfflineController.java

@ -0,0 +1,94 @@
package com.zc.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcExternalPlatformOffline;
import com.zc.business.service.IDcExternalPlatformOfflineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 外部平台离线记录Controller
*
* @author ruoyi
* @date 2024-11-14
*/
@RestController
@RequestMapping("/externalPlatformOffline")
public class DcExternalPlatformOfflineController extends BaseController
{
@Autowired
private IDcExternalPlatformOfflineService dcExternalPlatformOfflineService;
/**
* 查询外部平台离线记录列表
*/
@GetMapping("/list")
public TableDataInfo list(DcExternalPlatformOffline dcExternalPlatformOffline)
{
startPage();
List<DcExternalPlatformOffline> list = dcExternalPlatformOfflineService.selectDcExternalPlatformOfflineList(dcExternalPlatformOffline);
return getDataTable(list);
}
/**
* 导出外部平台离线记录列表
*/
@PostMapping("/export")
public void export(HttpServletResponse response, DcExternalPlatformOffline dcExternalPlatformOffline)
{
List<DcExternalPlatformOffline> list = dcExternalPlatformOfflineService.selectDcExternalPlatformOfflineList(dcExternalPlatformOffline);
ExcelUtil<DcExternalPlatformOffline> util = new ExcelUtil<>(DcExternalPlatformOffline.class);
util.exportExcel(response, list, "外部平台离线记录数据");
}
/**
* 获取外部平台离线记录详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(dcExternalPlatformOfflineService.selectDcExternalPlatformOfflineById(id));
}
/**
* 新增外部平台离线记录
*/
@PostMapping
public AjaxResult add(@RequestBody DcExternalPlatformOffline dcExternalPlatformOffline)
{
return toAjax(dcExternalPlatformOfflineService.insertDcExternalPlatformOffline(dcExternalPlatformOffline));
}
/**
* 修改外部平台离线记录
*/
@PutMapping
public AjaxResult edit(@RequestBody DcExternalPlatformOffline dcExternalPlatformOffline)
{
return toAjax(dcExternalPlatformOfflineService.updateDcExternalPlatformOffline(dcExternalPlatformOffline));
}
/**
* 删除外部平台离线记录
*/
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(dcExternalPlatformOfflineService.deleteDcExternalPlatformOfflineByIds(ids));
}
}

83
zc-business/src/main/java/com/zc/business/domain/DcExternalPlatformOffline.java

@ -0,0 +1,83 @@
package com.zc.business.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 外部平台离线记录对象 dc_external_platform_offline
*
* @author ruoyi
* @date 2024-11-14
*/
public class DcExternalPlatformOffline extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 平台类型(1gis+bim 2数字孪生 3收费运营 4桥梁监测 5光纤) */
@Excel(name = "平台类型",readConverterExp = "1=GIS+BIM,2=数字孪生,3=收费运营,4=桥梁监测,5=光纤监测")
private String type;
/** 离线时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@Excel(name = "离线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date offlineTime;
/** 结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setType(String type)
{
this.type = type;
}
public String getType()
{
return type;
}
public void setOfflineTime(Date offlineTime)
{
this.offlineTime = offlineTime;
}
public Date getOfflineTime()
{
return offlineTime;
}
public void setEndTime(Date endTime)
{
this.endTime = endTime;
}
public Date getEndTime()
{
return endTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("type", getType())
.append("offlineTime", getOfflineTime())
.append("endTime", getEndTime())
.toString();
}
}

5
zc-business/src/main/java/com/zc/business/mapper/DcExternalPlatformHeartbeatMapper.java

@ -1,6 +1,7 @@
package com.zc.business.mapper; package com.zc.business.mapper;
import com.zc.business.domain.DcExternalPlatformHeartbeat; import com.zc.business.domain.DcExternalPlatformHeartbeat;
import com.zc.business.domain.DcExternalPlatformOffline;
import java.util.List; import java.util.List;
@ -59,4 +60,8 @@ public interface DcExternalPlatformHeartbeatMapper
* @return 结果 * @return 结果
*/ */
int deleteDcExternalPlatformHeartbeatByIds(Long[] ids); int deleteDcExternalPlatformHeartbeatByIds(Long[] ids);
List<DcExternalPlatformOffline> selectOfflineList();
int selectRepeatRecord(String type);
} }

63
zc-business/src/main/java/com/zc/business/mapper/DcExternalPlatformOfflineMapper.java

@ -0,0 +1,63 @@
package com.zc.business.mapper;
import java.util.List;
import com.zc.business.domain.DcExternalPlatformOffline;
/**
* 外部平台离线记录Mapper接口
*
* @author ruoyi
* @date 2024-11-14
*/
public interface DcExternalPlatformOfflineMapper
{
/**
* 查询外部平台离线记录
*
* @param id 外部平台离线记录主键
* @return 外部平台离线记录
*/
public DcExternalPlatformOffline selectDcExternalPlatformOfflineById(Long id);
/**
* 查询外部平台离线记录列表
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 外部平台离线记录集合
*/
List<DcExternalPlatformOffline> selectDcExternalPlatformOfflineList(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 新增外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
int insertDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 修改外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
int updateDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 删除外部平台离线记录
*
* @param id 外部平台离线记录主键
* @return 结果
*/
int deleteDcExternalPlatformOfflineById(Long id);
/**
* 批量删除外部平台离线记录
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteDcExternalPlatformOfflineByIds(Long[] ids);
int updateEndTimeByType(String type);
}

11
zc-business/src/main/java/com/zc/business/service/IDcExternalPlatformHeartbeatService.java

@ -1,6 +1,7 @@
package com.zc.business.service; package com.zc.business.service;
import com.zc.business.domain.DcExternalPlatformHeartbeat; import com.zc.business.domain.DcExternalPlatformHeartbeat;
import com.zc.business.domain.DcExternalPlatformOffline;
import java.util.List; import java.util.List;
@ -59,4 +60,14 @@ public interface IDcExternalPlatformHeartbeatService
* @return 结果 * @return 结果
*/ */
int deleteDcExternalPlatformHeartbeatById(Long id); int deleteDcExternalPlatformHeartbeatById(Long id);
/**
* 查询外部平台心跳超过5分钟的
*
* @param
* @return 结果
*/
List<DcExternalPlatformOffline> selectOfflineList();
int selectRepeatRecord(String type);
} }

61
zc-business/src/main/java/com/zc/business/service/IDcExternalPlatformOfflineService.java

@ -0,0 +1,61 @@
package com.zc.business.service;
import java.util.List;
import com.zc.business.domain.DcExternalPlatformOffline;
/**
* 外部平台离线记录Service接口
*
* @author ruoyi
* @date 2024-11-14
*/
public interface IDcExternalPlatformOfflineService
{
/**
* 查询外部平台离线记录
*
* @param id 外部平台离线记录主键
* @return 外部平台离线记录
*/
public DcExternalPlatformOffline selectDcExternalPlatformOfflineById(Long id);
/**
* 查询外部平台离线记录列表
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 外部平台离线记录集合
*/
List<DcExternalPlatformOffline> selectDcExternalPlatformOfflineList(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 新增外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
int insertDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 修改外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
int updateDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline);
/**
* 批量删除外部平台离线记录
*
* @param ids 需要删除的外部平台离线记录主键集合
* @return 结果
*/
int deleteDcExternalPlatformOfflineByIds(Long[] ids);
/**
* 删除外部平台离线记录信息
*
* @param id 外部平台离线记录主键
* @return 结果
*/
int deleteDcExternalPlatformOfflineById(Long id);
}

31
zc-business/src/main/java/com/zc/business/service/impl/DcExternalPlatformHeartbeatServiceImpl.java

@ -3,7 +3,9 @@ package com.zc.business.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.zc.business.domain.DcExternalPlatformHeartbeat; import com.zc.business.domain.DcExternalPlatformHeartbeat;
import com.zc.business.domain.DcExternalPlatformOffline;
import com.zc.business.mapper.DcExternalPlatformHeartbeatMapper; import com.zc.business.mapper.DcExternalPlatformHeartbeatMapper;
import com.zc.business.mapper.DcExternalPlatformOfflineMapper;
import com.zc.business.service.IDcExternalPlatformHeartbeatService; import com.zc.business.service.IDcExternalPlatformHeartbeatService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,6 +21,8 @@ public class DcExternalPlatformHeartbeatServiceImpl implements IDcExternalPlatfo
{ {
@Autowired @Autowired
private DcExternalPlatformHeartbeatMapper dcExternalPlatformHeartbeatMapper; private DcExternalPlatformHeartbeatMapper dcExternalPlatformHeartbeatMapper;
@Autowired
private DcExternalPlatformOfflineMapper dcExternalPlatformOfflineMapper;
/** /**
* 查询外部平台心跳日志 * 查询外部平台心跳日志
@ -54,7 +58,14 @@ public class DcExternalPlatformHeartbeatServiceImpl implements IDcExternalPlatfo
public int insertDcExternalPlatformHeartbeat(DcExternalPlatformHeartbeat dcExternalPlatformHeartbeat) public int insertDcExternalPlatformHeartbeat(DcExternalPlatformHeartbeat dcExternalPlatformHeartbeat)
{ {
dcExternalPlatformHeartbeat.setCreateTime(DateUtils.getNowDate()); dcExternalPlatformHeartbeat.setCreateTime(DateUtils.getNowDate());
return dcExternalPlatformHeartbeatMapper.insertDcExternalPlatformHeartbeat(dcExternalPlatformHeartbeat); int i = dcExternalPlatformHeartbeatMapper.insertDcExternalPlatformHeartbeat(dcExternalPlatformHeartbeat);
int rows = selectRepeatRecord(dcExternalPlatformHeartbeat.getType());
if (rows > 0){
dcExternalPlatformOfflineMapper.updateEndTimeByType(dcExternalPlatformHeartbeat.getType());
}
return i;
} }
/** /**
@ -92,4 +103,22 @@ public class DcExternalPlatformHeartbeatServiceImpl implements IDcExternalPlatfo
{ {
return dcExternalPlatformHeartbeatMapper.deleteDcExternalPlatformHeartbeatById(id); return dcExternalPlatformHeartbeatMapper.deleteDcExternalPlatformHeartbeatById(id);
} }
/**
* 查询外部平台心跳超过5分钟的
*
* @param
* @return 结果
*/
@Override
public List<DcExternalPlatformOffline> selectOfflineList()
{
return dcExternalPlatformHeartbeatMapper.selectOfflineList();
}
@Override
public int selectRepeatRecord(String type){
return dcExternalPlatformHeartbeatMapper.selectRepeatRecord(type);
}
} }

93
zc-business/src/main/java/com/zc/business/service/impl/DcExternalPlatformOfflineServiceImpl.java

@ -0,0 +1,93 @@
package com.zc.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zc.business.mapper.DcExternalPlatformOfflineMapper;
import com.zc.business.domain.DcExternalPlatformOffline;
import com.zc.business.service.IDcExternalPlatformOfflineService;
/**
* 外部平台离线记录Service业务层处理
*
* @author ruoyi
* @date 2024-11-14
*/
@Service
public class DcExternalPlatformOfflineServiceImpl implements IDcExternalPlatformOfflineService
{
@Autowired
private DcExternalPlatformOfflineMapper dcExternalPlatformOfflineMapper;
/**
* 查询外部平台离线记录
*
* @param id 外部平台离线记录主键
* @return 外部平台离线记录
*/
@Override
public DcExternalPlatformOffline selectDcExternalPlatformOfflineById(Long id)
{
return dcExternalPlatformOfflineMapper.selectDcExternalPlatformOfflineById(id);
}
/**
* 查询外部平台离线记录列表
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 外部平台离线记录
*/
@Override
public List<DcExternalPlatformOffline> selectDcExternalPlatformOfflineList(DcExternalPlatformOffline dcExternalPlatformOffline)
{
return dcExternalPlatformOfflineMapper.selectDcExternalPlatformOfflineList(dcExternalPlatformOffline);
}
/**
* 新增外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
@Override
public int insertDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline)
{
return dcExternalPlatformOfflineMapper.insertDcExternalPlatformOffline(dcExternalPlatformOffline);
}
/**
* 修改外部平台离线记录
*
* @param dcExternalPlatformOffline 外部平台离线记录
* @return 结果
*/
@Override
public int updateDcExternalPlatformOffline(DcExternalPlatformOffline dcExternalPlatformOffline)
{
return dcExternalPlatformOfflineMapper.updateDcExternalPlatformOffline(dcExternalPlatformOffline);
}
/**
* 批量删除外部平台离线记录
*
* @param ids 需要删除的外部平台离线记录主键
* @return 结果
*/
@Override
public int deleteDcExternalPlatformOfflineByIds(Long[] ids)
{
return dcExternalPlatformOfflineMapper.deleteDcExternalPlatformOfflineByIds(ids);
}
/**
* 删除外部平台离线记录信息
*
* @param id 外部平台离线记录主键
* @return 结果
*/
@Override
public int deleteDcExternalPlatformOfflineById(Long id)
{
return dcExternalPlatformOfflineMapper.deleteDcExternalPlatformOfflineById(id);
}
}

16
zc-business/src/main/resources/mapper/business/DcExternalPlatformHeartbeatMapper.xml

@ -28,7 +28,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDcExternalPlatformHeartbeatVo"/> <include refid="selectDcExternalPlatformHeartbeatVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="selectOfflineList" resultType="com.zc.business.domain.DcExternalPlatformOffline">
SELECT
type,offlineTime
FROM
(SELECT
MAX(create_time) offlineTime,type,ip,create_time
FROM dc_external_platform_heartbeat
GROUP BY type) t
WHERE
t.offlineTime &lt; DATE_SUB(NOW(), INTERVAL 6 MINUTE)
</select>
<select id="selectRepeatRecord" resultType="java.lang.Integer">
select count(*) from dc_external_platform_offline where type = #{type} and isnull(end_time)
</select>
<insert id="insertDcExternalPlatformHeartbeat" parameterType="DcExternalPlatformHeartbeat" useGeneratedKeys="true" keyProperty="id"> <insert id="insertDcExternalPlatformHeartbeat" parameterType="DcExternalPlatformHeartbeat" useGeneratedKeys="true" keyProperty="id">
insert into dc_external_platform_heartbeat insert into dc_external_platform_heartbeat
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

73
zc-business/src/main/resources/mapper/business/DcExternalPlatformOfflineMapper.xml

@ -0,0 +1,73 @@
<?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.zc.business.mapper.DcExternalPlatformOfflineMapper">
<resultMap type="DcExternalPlatformOffline" id="DcExternalPlatformOfflineResult">
<result property="id" column="id" />
<result property="type" column="type" />
<result property="offlineTime" column="offline_time" />
<result property="endTime" column="end_time" />
</resultMap>
<sql id="selectDcExternalPlatformOfflineVo">
select id, type, offline_time, end_time from dc_external_platform_offline
</sql>
<select id="selectDcExternalPlatformOfflineList" parameterType="DcExternalPlatformOffline" resultMap="DcExternalPlatformOfflineResult">
<include refid="selectDcExternalPlatformOfflineVo"/>
<where>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="offlineTime != null ">
and date_format(offline_time,'%Y-%m-%d') &lt;= date_format(#{offlineTime},'%Y-%m-%d')
and (date_format(end_time,'%Y-%m-%d') >= date_format(#{offlineTime},'%Y-%m-%d') or isnull(end_time))
</if>
</where>
order by id desc
</select>
<select id="selectDcExternalPlatformOfflineById" parameterType="Long" resultMap="DcExternalPlatformOfflineResult">
<include refid="selectDcExternalPlatformOfflineVo"/>
where id = #{id}
</select>
<insert id="insertDcExternalPlatformOffline" parameterType="DcExternalPlatformOffline" useGeneratedKeys="true" keyProperty="id">
insert into dc_external_platform_offline
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="type != null">type,</if>
<if test="offlineTime != null">offline_time,</if>
<if test="endTime != null">end_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null">#{type},</if>
<if test="offlineTime != null">#{offlineTime},</if>
<if test="endTime != null">#{endTime},</if>
</trim>
</insert>
<update id="updateDcExternalPlatformOffline" parameterType="DcExternalPlatformOffline">
update dc_external_platform_offline
<trim prefix="SET" suffixOverrides=",">
<if test="type != null">type = #{type},</if>
<if test="offlineTime != null">offline_time = #{offlineTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
</trim>
where id = #{id}
</update>
<update id="updateEndTimeByType">
update dc_external_platform_offline set end_time = now()
where isnull(end_time) and type = #{type}
</update>
<delete id="deleteDcExternalPlatformOfflineById" parameterType="Long">
delete from dc_external_platform_offline where id = #{id}
</delete>
<delete id="deleteDcExternalPlatformOfflineByIds" parameterType="String">
delete from dc_external_platform_offline where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save