Commit 5a8363f1 authored by 赵啸非's avatar 赵啸非

首页添加站点分别请求,消息模块改造,添加客户端版本管理。

parent 8b1ae536
...@@ -5,4 +5,12 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `deviceSN` varchar (512) COMMENT ' ...@@ -5,4 +5,12 @@ ALTER TABLE mortals_xhx_device ADD COLUMN `deviceSN` varchar (512) COMMENT '
ALTER TABLE mortals_xhx_product ADD COLUMN `skinId` bigint (20) COMMENT '皮肤id' AFTER productCode; ALTER TABLE mortals_xhx_product ADD COLUMN `skinId` bigint (20) COMMENT '皮肤id' AFTER productCode;
ALTER TABLE mortals_xhx_product ADD COLUMN `skinName` varchar (512) COMMENT '皮肤名称' AFTER skinId; ALTER TABLE mortals_xhx_product ADD COLUMN `skinName` varchar (512) COMMENT '皮肤名称' AFTER skinId;
\ No newline at end of file
-- ----------------------------
2022-08-20
-- ----------------------------
ALTER TABLE mortals_xhx_device ADD COLUMN `deviceVersion` varchar (64) COMMENT '设备版本' AFTER deleted;
...@@ -5,7 +5,7 @@ DROP TABLE IF EXISTS `mortals_xhx_device`; ...@@ -5,7 +5,7 @@ DROP TABLE IF EXISTS `mortals_xhx_device`;
CREATE TABLE mortals_xhx_device( CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称', `deviceName` varchar(20) NOT NULL COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码,默认为MAC地址', `deviceCode` varchar(256) COMMENT '设备编码,SN码等,默认为MAC地址',
`deviceSN` varchar(256) COMMENT '设备SN码', `deviceSN` varchar(256) COMMENT '设备SN码',
`deviceMac` varchar(64) COMMENT '设备的MAC地址', `deviceMac` varchar(64) COMMENT '设备的MAC地址',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台', `siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
...@@ -42,6 +42,7 @@ CREATE TABLE mortals_xhx_device( ...@@ -42,6 +42,7 @@ CREATE TABLE mortals_xhx_device(
`onlineTime` datetime COMMENT '最近上线时间', `onlineTime` datetime COMMENT '最近上线时间',
`offlineTime` datetime COMMENT '最近离线时间', `offlineTime` datetime COMMENT '最近离线时间',
`deleted` tinyint(2) COMMENT '是否删除(0.否,1.是)', `deleted` tinyint(2) COMMENT '是否删除(0.否,1.是)',
`deviceVersion` varchar(64) COMMENT '设备版本',
`source` tinyint(2) COMMENT '设备来源(0.旧设备,1.新设备)', `source` tinyint(2) COMMENT '设备来源(0.旧设备,1.新设备)',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户', `createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
...@@ -52,6 +53,8 @@ PRIMARY KEY (`id`) ...@@ -52,6 +53,8 @@ PRIMARY KEY (`id`)
-- ---------------------------- -- ----------------------------
-- 平台系统表 -- 平台系统表
-- ---------------------------- -- ----------------------------
...@@ -118,7 +121,8 @@ DROP TABLE IF EXISTS `mortals_xhx_device_alarm_info`; ...@@ -118,7 +121,8 @@ DROP TABLE IF EXISTS `mortals_xhx_device_alarm_info`;
CREATE TABLE mortals_xhx_device_alarm_info( CREATE TABLE mortals_xhx_device_alarm_info(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`alarmTime` datetime NOT NULL COMMENT '告警时间', `alarmTime` datetime NOT NULL COMMENT '告警时间',
`alarmDevice` bigint(20) NOT NULL COMMENT '告警设备', `alarmDevice` bigint(20) NOT NULL COMMENT '告警设备Id',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`alarmType` tinyint(2) NOT NULL COMMENT '告警类型,(0.离线)', `alarmType` tinyint(2) NOT NULL COMMENT '告警类型,(0.离线)',
`alarmLevel` tinyint(2) NOT NULL COMMENT '告警级别(0.危险,1.次要,2.一般)', `alarmLevel` tinyint(2) NOT NULL COMMENT '告警级别(0.危险,1.次要,2.一般)',
`alarmReceivePersonnel` varchar(32) NOT NULL COMMENT '接收人员[设备管理的责任人]', `alarmReceivePersonnel` varchar(32) NOT NULL COMMENT '接收人员[设备管理的责任人]',
...@@ -131,6 +135,8 @@ CREATE TABLE mortals_xhx_device_alarm_info( ...@@ -131,6 +135,8 @@ CREATE TABLE mortals_xhx_device_alarm_info(
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备告警日志'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备告警日志';
-- ---------------------------- -- ----------------------------
-- 设备模块信息表 -- 设备模块信息表
-- ---------------------------- -- ----------------------------
...@@ -190,17 +196,19 @@ PRIMARY KEY (`id`) ...@@ -190,17 +196,19 @@ PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `mortals_xhx_alarm_sms_send`; DROP TABLE IF EXISTS `mortals_xhx_alarm_sms_send`;
CREATE TABLE mortals_xhx_alarm_sms_send( CREATE TABLE mortals_xhx_alarm_sms_send(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`mobile` varchar(11) NOT NULL COMMENT '电话号码', `mobile` varchar(11) NOT NULL COMMENT '联系电话',
`receiver` varchar(200) NOT NULL COMMENT '接收人员',
`sendMess` varchar(200) NOT NULL COMMENT '发送内容', `sendMess` varchar(200) NOT NULL COMMENT '发送内容',
`sendStatus` tinyint(2) NOT NULL COMMENT '发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)', `sendStatus` tinyint(2) NOT NULL COMMENT '发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)',
`sendTime` datetime NOT NULL COMMENT '发送时间', `sendTime` datetime NOT NULL COMMENT '发送时间',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户', `updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间', `updateTime` datetime COMMENT '更新时间',
`receiver` varchar(200) NOT NULL COMMENT '接收人',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='短信发送记录'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='短信发送记录';
-- ---------------------------- -- ----------------------------
-- 设备日志表 -- 设备日志表
-- ---------------------------- -- ----------------------------
...@@ -208,6 +216,7 @@ DROP TABLE IF EXISTS `mortals_xhx_device_log`; ...@@ -208,6 +216,7 @@ DROP TABLE IF EXISTS `mortals_xhx_device_log`;
CREATE TABLE mortals_xhx_device_log( CREATE TABLE mortals_xhx_device_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`traceID` varchar(64) COMMENT 'traceId,日志追踪id', `traceID` varchar(64) COMMENT 'traceId,日志追踪id',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`deviceId` bigint(20) COMMENT '设备ID', `deviceId` bigint(20) COMMENT '设备ID',
`deviceCode` varchar(32) NOT NULL COMMENT '设备编号', `deviceCode` varchar(32) NOT NULL COMMENT '设备编号',
`deviceName` varchar(32) NOT NULL COMMENT '设备名称,设置设备名称。', `deviceName` varchar(32) NOT NULL COMMENT '设备名称,设置设备名称。',
...@@ -223,6 +232,8 @@ PRIMARY KEY (`id`) ...@@ -223,6 +232,8 @@ PRIMARY KEY (`id`)
-- ---------------------------- -- ----------------------------
-- 站点统计表 -- 站点统计表
-- ---------------------------- -- ----------------------------
...@@ -249,16 +260,19 @@ PRIMARY KEY (`id`) ...@@ -249,16 +260,19 @@ PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `mortals_xhx_device_stat`; DROP TABLE IF EXISTS `mortals_xhx_device_stat`;
CREATE TABLE mortals_xhx_device_stat( CREATE TABLE mortals_xhx_device_stat(
`id` bigint(20) AUTO_INCREMENT COMMENT 'ID', `id` bigint(20) AUTO_INCREMENT COMMENT 'ID',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`deviceTotalCount` int(9) COMMENT '设备总数', `deviceTotalCount` int(9) COMMENT '设备总数',
`deviceAddCount` int(9) COMMENT '昨日新增减少设备数量', `deviceAddCount` int(9) COMMENT '昨日新增减少设备数量',
`siteTotalCount` int(9) COMMENT '监控站点数量', `siteTotalCount` int(9) COMMENT '监控站点数量',
`siteAddCount` int(9) COMMENT '昨日新增站点数量', `siteAddCount` int(9) COMMENT '昨日新增站点数量',
`deviceOnlineCount` int(9) COMMENT '在线设备数量', `deviceOnlineCount` int(9) COMMENT '在线设备数量',
`deviceOnlineRatio` double COMMENT '在线率', `deviceOnlineRatio` double(6,2) COMMENT '在线率',
`deviceOfflineCount` int(9) NOT NULL COMMENT '离线设备数量', `deviceOfflineCount` int(9) NOT NULL COMMENT '离线设备数量',
`deviceOfflineRatio` double NOT NULL COMMENT '离线率', `deviceOfflineRatio` double(6,2) NOT NULL COMMENT '离线率',
`deviceStopCount` int(9) NOT NULL COMMENT '停用设备数量', `deviceStopCount` int(9) NOT NULL COMMENT '停用设备数量',
`deviceStopRatio` double NOT NULL COMMENT '停用率', `deviceStopRatio` double(6,2) NOT NULL COMMENT '停用率',
`deviceUnActiveCount` int(9) NOT NULL COMMENT '未激活设备数量',
`deviceUnActiveRatio` double(6,2) NOT NULL COMMENT '未激活率',
`alarmTotalCount` int(9) NOT NULL COMMENT '今日告警数量', `alarmTotalCount` int(9) NOT NULL COMMENT '今日告警数量',
`alarmAddCount` int(9) NOT NULL COMMENT '昨日新增减少数量', `alarmAddCount` int(9) NOT NULL COMMENT '昨日新增减少数量',
`pushTotalCount` int(9) NOT NULL COMMENT '今日消息推送数量', `pushTotalCount` int(9) NOT NULL COMMENT '今日消息推送数量',
...@@ -274,3 +288,26 @@ CREATE TABLE mortals_xhx_device_stat( ...@@ -274,3 +288,26 @@ CREATE TABLE mortals_xhx_device_stat(
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备统计'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备统计';
-- ----------------------------
-- 产品客户端版本表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_product_version`;
CREATE TABLE mortals_xhx_product_version(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`productId` bigint(20) COMMENT '产品Id',
`productCode` varchar(256) COMMENT '产品编码',
`productName` varchar(256) COMMENT '产品名称',
`filePath` varchar(256) COMMENT '文件相对路径地址',
`version` int(4) COMMENT '版本号',
`remark` varchar(256) COMMENT '备注信息',
`createTime` datetime COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='产品客户端版本';
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"js-cookie": "2.2.1", "js-cookie": "2.2.1",
"jsencrypt": "3.0.0-rc.1", "jsencrypt": "3.0.0-rc.1",
"json-bigint": "^0.3.0", "json-bigint": "^0.3.0",
"moment": "^2.29.4",
"muse-ui": "^3.0.2", "muse-ui": "^3.0.2",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"quill": "1.3.7", "quill": "1.3.7",
......
...@@ -54,6 +54,8 @@ const router = new Router({ ...@@ -54,6 +54,8 @@ const router = new Router({
...restBuilder('alarm/config', 'alarm/config'),//设备告警配置 ...restBuilder('alarm/config', 'alarm/config'),//设备告警配置
...restBuilder('alarm/sms/send', 'alarm/sms/send'),//设备告警短信 ...restBuilder('alarm/sms/send', 'alarm/sms/send'),//设备告警短信
...restBuilder('product/version', 'product/version'),//产品
//以下为基础路由配置 //以下为基础路由配置
builder('', 'Home'), builder('', 'Home'),
builder('index', 'Home'), builder('index', 'Home'),
......
...@@ -120,11 +120,11 @@ ...@@ -120,11 +120,11 @@
</div> </div>
<!-- 未激活设备 --> <!-- 未激活设备 -->
<div class="total-item"> <div class="total-item">
<p class="total-item-count">{{ statData.deviceStopRatio }}</p> <p class="total-item-count">{{ statData.deviceUnActiveRatio }}</p>
<span style="font-size: 12px" <span style="font-size: 12px"
><span style="color: #6182f6">未激活率 </span ><span style="color: #6182f6">未激活率 </span
><span v-bind:class="{ warn: statData.deviceStopRatio >= 0 }" ><span v-bind:class="{ warn: statData.deviceUnActiveRatio >= 0 }"
>{{ statData.deviceStopRatio * 100 }}%</span >{{ statData.deviceUnActiveRatio * 100 }}%</span
></span ></span
> >
<p class="total-item-title"> <p class="total-item-title">
...@@ -424,6 +424,7 @@ ...@@ -424,6 +424,7 @@
</template> </template>
<script> <script>
import { formatterDate } from "@/assets/utils/index";
export default { export default {
computed: { computed: {
userData() { userData() {
...@@ -478,6 +479,7 @@ export default { ...@@ -478,6 +479,7 @@ export default {
this.findDevicePush(beforeday); this.findDevicePush(beforeday);
}, },
methods: { methods: {
formatterDate,
// echarts 适配函数 // echarts 适配函数
adapterEcharts() { adapterEcharts() {
this.deviceTotalChart.resize(); this.deviceTotalChart.resize();
...@@ -487,7 +489,7 @@ export default { ...@@ -487,7 +489,7 @@ export default {
this.pushChart.resize(); this.pushChart.resize();
}, },
syncDeviceStat() { syncDeviceStat() {
this.$post("/device/stat/syncDeviceStat", {}) this.$post("/device/stat/syncDeviceStat", {siteId:1})
.then((res) => { .then((res) => {
console.log(res.data); console.log(res.data);
if (res.code == 1) { if (res.code == 1) {
...@@ -503,6 +505,8 @@ export default { ...@@ -503,6 +505,8 @@ export default {
findDeviceTotalStat(beforeday) { findDeviceTotalStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) }; let query = { createTimeStart: this.formatterDate(beforeday) };
//当前选择站点id
query.siteId=1
console.log(query); console.log(query);
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
.then((res) => { .then((res) => {
...@@ -534,6 +538,7 @@ export default { ...@@ -534,6 +538,7 @@ export default {
findDeviceStat(beforeday) { findDeviceStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) }; let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
.then((res) => { .then((res) => {
if (res.code == 1) { if (res.code == 1) {
...@@ -563,6 +568,7 @@ export default { ...@@ -563,6 +568,7 @@ export default {
findDeviceAlarm(beforeday) { findDeviceAlarm(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) }; let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
.then((res) => { .then((res) => {
if (res.code == 1) { if (res.code == 1) {
...@@ -591,6 +597,7 @@ export default { ...@@ -591,6 +597,7 @@ export default {
findDevicePush(beforeday) { findDevicePush(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) }; let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query) this.$post("/device/stat/list", query)
.then((res) => { .then((res) => {
if (res.code == 1) { if (res.code == 1) {
...@@ -616,37 +623,6 @@ export default { ...@@ -616,37 +623,6 @@ export default {
}); });
}, },
formatterDate(time) {
let date = new Date(Number(time));
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = this.panLeft(date.getDate()) + " ";
let h = this.panLeft(date.getHours()) + ":";
let m = this.panLeft(date.getMinutes()) + ":";
let s = this.panLeft(date.getSeconds());
return Y + M + D + h + m + s;
},
getYear(time) {
let date = new Date(Number(time));
let Y = date.getFullYear() + "-";
let M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
let D = this.panLeft(date.getDate()) + " ";
let h = this.panLeft(date.getHours()) + ":";
let m = this.panLeft(date.getMinutes()) + ":";
let s = this.panLeft(date.getSeconds());
return Y + M + D + h + m + s;
},
panLeft(num) {
return num < 10 ? "0" + num : num;
},
// 设备数据图 // 设备数据图
myEcharts() { myEcharts() {
// 基于准备好的dom,初始化echarts实例 // 基于准备好的dom,初始化echarts实例
......
...@@ -24,7 +24,11 @@ export default { ...@@ -24,7 +24,11 @@ export default {
name: "AlarmSmsSend", name: "AlarmSmsSend",
components: { drawerShow }, components: { drawerShow },
mixins: [table], mixins: [table],
created() {}, created() {
this.query= Object.assign({}, this.query, {siteId:1});
},
methods: { methods: {
/** 重写新增方法 */ /** 重写新增方法 */
toAdd(row) { toAdd(row) {
......
...@@ -66,6 +66,8 @@ export default { ...@@ -66,6 +66,8 @@ export default {
this.query["alarmDevice"] = this.queryIn.alarmDevice; this.query["alarmDevice"] = this.queryIn.alarmDevice;
} }
this.changePath("/device/alarm/info"); this.changePath("/device/alarm/info");
this.query= Object.assign({}, this.query, {siteId:1});
}, },
methods: { methods: {
/** 重写新增方法 */ /** 重写新增方法 */
......
...@@ -15,7 +15,10 @@ export default { ...@@ -15,7 +15,10 @@ export default {
name: "DeviceLog", name: "DeviceLog",
components: { dialogShow }, components: { dialogShow },
mixins: [table], mixins: [table],
created() {}, created() {
this.query= Object.assign({}, this.query, {siteId:1});
},
methods: { methods: {
/** 重写新增方法 */ /** 重写新增方法 */
toAdd(row) { toAdd(row) {
......
...@@ -17,7 +17,7 @@ module.exports = { ...@@ -17,7 +17,7 @@ module.exports = {
hot: true,//自动保存 hot: true,//自动保存
proxy: { proxy: {
'/m': { '/m': {
target: 'http://192.168.0.98:11091', target: 'http://localhost:18222',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
cookieDomainRewrite: 'plm.testnew.com', cookieDomainRewrite: 'plm.testnew.com',
......
This diff is collapsed.
...@@ -46,138 +46,16 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService { ...@@ -46,138 +46,16 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
@Autowired @Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceStatService deviceStatService;
@Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
@Autowired
private DeviceAlarmInfoService deviceAlarmInfoService;
@Autowired
private AlarmSmsSendService alarmSmsSendService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
deviceService.deviceStat(null); //统计所有站点
//doDeviceStat(); siteFeign.list(new SitePdu()).getData().getData().parallelStream().forEach(item -> {
deviceService.deviceStat(item.getId(), null);
});
} }
/**
* 统计设备
* 全部设备-》激活设备与未激活-》启用与停用设备-》离线与在线设备
*/
private void doDeviceStat() {
//查询当天统计,如果有 则更新统计结果,否则新增
DeviceStatEntity deviceStatEntity = deviceStatService.selectOne(new DeviceStatQuery()
.year(DateUtil.year(new Date()))
.month(DateUtil.month(new Date()) + 1)
.day(DateUtil.dayOfMonth(new Date())));
if (ObjectUtils.isEmpty(deviceStatEntity)) {
deviceStatEntity = new DeviceStatEntity();
deviceStatEntity.initAttrValue();
deviceStatEntity.setCreateTime(new Date());
deviceStatEntity.setYear(DateUtil.year(new Date()));
deviceStatEntity.setMonth(DateUtil.month(new Date()) + 1);
deviceStatEntity.setDay(DateUtil.dayOfMonth(new Date()));
}
//获取昨天统计数据
DeviceStatEntity yesterdayDeviceStat = deviceStatService.selectOne(new DeviceStatQuery()
.year(DateUtil.year(DateUtil.yesterday()))
.month(DateUtil.month(DateUtil.yesterday()) + 1)
.day(DateUtil.dayOfMonth(DateUtil.yesterday())));
if (ObjectUtils.isEmpty(yesterdayDeviceStat)) {
yesterdayDeviceStat = new DeviceStatEntity();
yesterdayDeviceStat.initAttrValue();
}
try {
//获取设备总数
List<DeviceEntity> deviceList = deviceService.find(new DeviceQuery());
Integer deviceTotalCount = deviceList.size();
deviceStatEntity.setDeviceTotalCount(deviceTotalCount);
deviceStatEntity.setDeviceAddCount(deviceTotalCount - yesterdayDeviceStat.getDeviceTotalCount());
//站点数量
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if(resp.getCode()==1) {
List<SitePdu> sitePduList = resp.getData().getData();
deviceStatEntity.setSiteTotalCount(sitePduList.size());
deviceStatEntity.setSiteAddCount(sitePduList.size() - yesterdayDeviceStat.getSiteTotalCount());
}
//在线数量
Long deviceOnlineCount = deviceList.parallelStream()
.filter(f->f.getDeviceStatus()>DeviceStatusEnum.未激活.getValue())
.filter(f->f.getEnabled()== EnabledEnum.启用.getValue())
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue())
.count();
deviceStatEntity.setDeviceOnlineCount(deviceOnlineCount.intValue());
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceList.size()),ROUND_HALF_DOWN).setScale(2));
//离线数量
Long deviceOfflineCount = deviceList.parallelStream()
.filter(f->f.getDeviceStatus()>DeviceStatusEnum.未激活.getValue())
.filter(f->f.getEnabled()== EnabledEnum.启用.getValue())
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue())
.count();
deviceStatEntity.setDeviceOfflineCount(deviceOfflineCount.intValue());
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceList.size()),ROUND_HALF_DOWN).setScale(2));
//停用数量
Long deviceStopCount = deviceList.parallelStream()
.filter(f->f.getDeviceStatus()>DeviceStatusEnum.未激活.getValue())
.filter(f -> f.getEnabled() == YesNoEnum.NO.getValue())
.count();
deviceStatEntity.setDeviceStopCount(deviceStopCount.intValue());
deviceStatEntity.setDeviceStopRatio(new BigDecimal(deviceStopCount).divide(new BigDecimal(deviceList.size()),ROUND_HALF_DOWN).setScale(2));
//今日告警数量
DeviceAlarmInfoQuery deviceAlarmInfoQuery = new DeviceAlarmInfoQuery();
deviceAlarmInfoQuery.setCreateTimeStart(DateUtils.getCurrStrDate());
deviceAlarmInfoQuery.setCreateTimeEnd(DateUtils.getCurrStrDate());
List<DeviceAlarmInfoEntity> deviceAlarmInfoList = deviceAlarmInfoService.find(deviceAlarmInfoQuery);
deviceStatEntity.setAlarmTotalCount(deviceAlarmInfoList.size());
deviceStatEntity.setAlarmAddCount(deviceAlarmInfoList.size() - yesterdayDeviceStat.getAlarmTotalCount());
//推送数量
AlarmSmsSendQuery alarmSmsSendQuery = new AlarmSmsSendQuery();
alarmSmsSendQuery.setSendTimeStart(DateUtils.getCurrStrDate());
alarmSmsSendQuery.setSendTimeEnd(DateUtils.getCurrStrDate());
alarmSmsSendQuery.setSendStatus(SendStatusEnum.发送成功.getValue());
List<AlarmSmsSendEntity> alarmSmsSendEntities = alarmSmsSendService.find(alarmSmsSendQuery);
deviceStatEntity.setPushTotalCount(alarmSmsSendEntities.size());
deviceStatEntity.setPushAddCount(alarmSmsSendEntities.size()-yesterdayDeviceStat.getPushTotalCount());
//上行下行数量
DeviceLogQuery deviceLogQuery = new DeviceLogQuery();
deviceLogQuery.setCreateTimeStart(DateUtils.getCurrStrDate());
deviceLogQuery.setCreateTimeEnd(DateUtils.getCurrStrDate());
Map<Boolean, Long> collect = deviceLogService.find(deviceLogQuery).parallelStream().collect(Collectors.partitioningBy(x -> x.getLogType() == LogTypeEnum.上报事件.getValue(), counting()));
deviceStatEntity.setUploadMessageTotalCount(collect.getOrDefault(true,0L).intValue());
deviceStatEntity.setDownloadMessageTotalCount(collect.getOrDefault(false,0L).intValue());
if (deviceStatEntity.newEntity()) {
deviceStatEntity.setCreateTime(new Date());
deviceStatService.save(deviceStatEntity);
} else {
deviceStatEntity.setUpdateTime(new Date());
deviceStatService.update(deviceStatEntity);
}
} catch (Exception e) {
log.error("更新任务异常,结束执行", e);
}
}
@Override @Override
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
......
...@@ -8,108 +8,130 @@ import com.mortals.framework.annotation.Excel; ...@@ -8,108 +8,130 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.alarm.model.vo.AlarmSmsSendVo; import com.mortals.xhx.module.alarm.model.vo.AlarmSmsSendVo;
/** /**
* 短信发送记录实体对象 * 短信发送记录实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-01 * @date 2022-08-22
*/ */
public class AlarmSmsSendEntity extends AlarmSmsSendVo { public class AlarmSmsSendEntity extends AlarmSmsSendVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 电话号码 * 联系电话
*/ */
@Excel(name = "联系电话")
private String mobile; private String mobile;
/** /**
* 发送内容 * 接收人员
*/ */
@Excel(name = "接收人员")
private String receiver;
/**
* 发送内容
*/
@Excel(name = "发送内容")
private String sendMess; private String sendMess;
/** /**
* 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败) * 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
*/ */
@Excel(name = "发送状态", readConverterExp = "0=未发送,1=提交,2=发送成功,3=发生失败")
private Integer sendStatus; private Integer sendStatus;
/** /**
* 发送时间 * 发送时间
*/ */
private Date sendTime; private Date sendTime;
/** /**
* 接收人 * 站点Id,来源基础服务平台
*/ */
private String receiver; private Long siteId;
public AlarmSmsSendEntity(){} public AlarmSmsSendEntity(){}
/** /**
* 获取 电话号码 * 获取 联系电话
* @return String * @return String
*/ */
public String getMobile(){ public String getMobile(){
return mobile; return mobile;
} }
/** /**
* 设置 电话号码 * 设置 联系电话
* @param mobile * @param mobile
*/ */
public void setMobile(String mobile){ public void setMobile(String mobile){
this.mobile = mobile; this.mobile = mobile;
} }
/** /**
* 获取 发送内容 * 获取 接收人员
* @return String * @return String
*/ */
public String getReceiver(){
return receiver;
}
/**
* 设置 接收人员
* @param receiver
*/
public void setReceiver(String receiver){
this.receiver = receiver;
}
/**
* 获取 发送内容
* @return String
*/
public String getSendMess(){ public String getSendMess(){
return sendMess; return sendMess;
} }
/** /**
* 设置 发送内容 * 设置 发送内容
* @param sendMess * @param sendMess
*/ */
public void setSendMess(String sendMess){ public void setSendMess(String sendMess){
this.sendMess = sendMess; this.sendMess = sendMess;
} }
/** /**
* 获取 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败) * 获取 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @return Integer * @return Integer
*/ */
public Integer getSendStatus(){ public Integer getSendStatus(){
return sendStatus; return sendStatus;
} }
/** /**
* 设置 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败) * 设置 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @param sendStatus * @param sendStatus
*/ */
public void setSendStatus(Integer sendStatus){ public void setSendStatus(Integer sendStatus){
this.sendStatus = sendStatus; this.sendStatus = sendStatus;
} }
/** /**
* 获取 发送时间 * 获取 发送时间
* @return Date * @return Date
*/ */
public Date getSendTime(){ public Date getSendTime(){
return sendTime; return sendTime;
} }
/** /**
* 设置 发送时间 * 设置 发送时间
* @param sendTime * @param sendTime
*/ */
public void setSendTime(Date sendTime){ public void setSendTime(Date sendTime){
this.sendTime = sendTime; this.sendTime = sendTime;
} }
/** /**
* 获取 接收人 * 获取 站点Id,来源基础服务平台
* @return String * @return Long
*/ */
public String getReceiver(){ public Long getSiteId(){
return receiver; return siteId;
} }
/** /**
* 设置 接收人 * 设置 站点Id,来源基础服务平台
* @param receiver * @param siteId
*/ */
public void setReceiver(String receiver){ public void setSiteId(Long siteId){
this.receiver = receiver; this.siteId = siteId;
} }
...@@ -117,7 +139,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo { ...@@ -117,7 +139,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -125,7 +147,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo { ...@@ -125,7 +147,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
if (obj instanceof AlarmSmsSendEntity) { if (obj instanceof AlarmSmsSendEntity) {
AlarmSmsSendEntity tmp = (AlarmSmsSendEntity) obj; AlarmSmsSendEntity tmp = (AlarmSmsSendEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
...@@ -134,23 +156,26 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo { ...@@ -134,23 +156,26 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(""); StringBuilder sb = new StringBuilder("");
sb.append(",mobile:").append(getMobile()); sb.append(",mobile:").append(getMobile());
sb.append(",receiver:").append(getReceiver());
sb.append(",sendMess:").append(getSendMess()); sb.append(",sendMess:").append(getSendMess());
sb.append(",sendStatus:").append(getSendStatus()); sb.append(",sendStatus:").append(getSendStatus());
sb.append(",sendTime:").append(getSendTime()); sb.append(",sendTime:").append(getSendTime());
sb.append(",receiver:").append(getReceiver()); sb.append(",siteId:").append(getSiteId());
return sb.toString(); return sb.toString();
} }
public void initAttrValue(){ public void initAttrValue(){
this.mobile = ""; this.mobile = "";
this.receiver = "";
this.sendMess = ""; this.sendMess = "";
this.sendStatus = null; this.sendStatus = null;
this.sendTime = null; this.sendTime = null;
this.receiver = ""; this.siteId = null;
} }
} }
\ No newline at end of file
...@@ -8,160 +8,178 @@ import com.mortals.framework.annotation.Excel; ...@@ -8,160 +8,178 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceAlarmInfoVo; import com.mortals.xhx.module.device.model.vo.DeviceAlarmInfoVo;
/** /**
* 设备告警日志实体对象 * 设备告警日志实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-01 * @date 2022-08-22
*/ */
public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 告警时间 * 告警时间
*/ */
private Date alarmTime; private Date alarmTime;
/** /**
* 告警设备 * 告警设备Id
*/ */
private Long alarmDevice; private Long alarmDevice;
/** /**
* 告警类型,(0.离线) * 站点Id,来源基础服务平台
*/ */
private Long siteId;
/**
* 告警类型,(0.离线)
*/
private Integer alarmType; private Integer alarmType;
/** /**
* 告警级别(0.危险,1.次要,2.一般) * 告警级别(0.危险,1.次要,2.一般)
*/ */
private Integer alarmLevel; private Integer alarmLevel;
/** /**
* 接收人员[设备管理的责任人] * 接收人员[设备管理的责任人]
*/ */
private String alarmReceivePersonnel; private String alarmReceivePersonnel;
/** /**
* 接收人员电话 * 接收人员电话
*/ */
private String receivePersonnelTelephone; private String receivePersonnelTelephone;
/** /**
* 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认) * 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
*/ */
private Integer alarmStatus; private Integer alarmStatus;
/** /**
* 告警详细内容 * 告警详细内容
*/ */
private String alarmContent; private String alarmContent;
public DeviceAlarmInfoEntity(){} public DeviceAlarmInfoEntity(){}
/** /**
* 获取 告警时间 * 获取 告警时间
* @return Date * @return Date
*/ */
public Date getAlarmTime(){ public Date getAlarmTime(){
return alarmTime; return alarmTime;
} }
/** /**
* 设置 告警时间 * 设置 告警时间
* @param alarmTime * @param alarmTime
*/ */
public void setAlarmTime(Date alarmTime){ public void setAlarmTime(Date alarmTime){
this.alarmTime = alarmTime; this.alarmTime = alarmTime;
} }
/** /**
* 获取 告警设备 * 获取 告警设备Id
* @return Long * @return Long
*/ */
public Long getAlarmDevice(){ public Long getAlarmDevice(){
return alarmDevice; return alarmDevice;
} }
/** /**
* 设置 告警设备 * 设置 告警设备Id
* @param alarmDevice * @param alarmDevice
*/ */
public void setAlarmDevice(Long alarmDevice){ public void setAlarmDevice(Long alarmDevice){
this.alarmDevice = alarmDevice; this.alarmDevice = alarmDevice;
} }
/** /**
* 获取 告警类型,(0.离线) * 获取 站点Id,来源基础服务平台
* @return Integer * @return Long
*/ */
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 告警类型,(0.离线)
* @return Integer
*/
public Integer getAlarmType(){ public Integer getAlarmType(){
return alarmType; return alarmType;
} }
/** /**
* 设置 告警类型,(0.离线) * 设置 告警类型,(0.离线)
* @param alarmType * @param alarmType
*/ */
public void setAlarmType(Integer alarmType){ public void setAlarmType(Integer alarmType){
this.alarmType = alarmType; this.alarmType = alarmType;
} }
/** /**
* 获取 告警级别(0.危险,1.次要,2.一般) * 获取 告警级别(0.危险,1.次要,2.一般)
* @return Integer * @return Integer
*/ */
public Integer getAlarmLevel(){ public Integer getAlarmLevel(){
return alarmLevel; return alarmLevel;
} }
/** /**
* 设置 告警级别(0.危险,1.次要,2.一般) * 设置 告警级别(0.危险,1.次要,2.一般)
* @param alarmLevel * @param alarmLevel
*/ */
public void setAlarmLevel(Integer alarmLevel){ public void setAlarmLevel(Integer alarmLevel){
this.alarmLevel = alarmLevel; this.alarmLevel = alarmLevel;
} }
/** /**
* 获取 接收人员[设备管理的责任人] * 获取 接收人员[设备管理的责任人]
* @return String * @return String
*/ */
public String getAlarmReceivePersonnel(){ public String getAlarmReceivePersonnel(){
return alarmReceivePersonnel; return alarmReceivePersonnel;
} }
/** /**
* 设置 接收人员[设备管理的责任人] * 设置 接收人员[设备管理的责任人]
* @param alarmReceivePersonnel * @param alarmReceivePersonnel
*/ */
public void setAlarmReceivePersonnel(String alarmReceivePersonnel){ public void setAlarmReceivePersonnel(String alarmReceivePersonnel){
this.alarmReceivePersonnel = alarmReceivePersonnel; this.alarmReceivePersonnel = alarmReceivePersonnel;
} }
/** /**
* 获取 接收人员电话 * 获取 接收人员电话
* @return String * @return String
*/ */
public String getReceivePersonnelTelephone(){ public String getReceivePersonnelTelephone(){
return receivePersonnelTelephone; return receivePersonnelTelephone;
} }
/** /**
* 设置 接收人员电话 * 设置 接收人员电话
* @param receivePersonnelTelephone * @param receivePersonnelTelephone
*/ */
public void setReceivePersonnelTelephone(String receivePersonnelTelephone){ public void setReceivePersonnelTelephone(String receivePersonnelTelephone){
this.receivePersonnelTelephone = receivePersonnelTelephone; this.receivePersonnelTelephone = receivePersonnelTelephone;
} }
/** /**
* 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认) * 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @return Integer * @return Integer
*/ */
public Integer getAlarmStatus(){ public Integer getAlarmStatus(){
return alarmStatus; return alarmStatus;
} }
/** /**
* 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认) * 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @param alarmStatus * @param alarmStatus
*/ */
public void setAlarmStatus(Integer alarmStatus){ public void setAlarmStatus(Integer alarmStatus){
this.alarmStatus = alarmStatus; this.alarmStatus = alarmStatus;
} }
/** /**
* 获取 告警详细内容 * 获取 告警详细内容
* @return String * @return String
*/ */
public String getAlarmContent(){ public String getAlarmContent(){
return alarmContent; return alarmContent;
} }
/** /**
* 设置 告警详细内容 * 设置 告警详细内容
* @param alarmContent * @param alarmContent
*/ */
public void setAlarmContent(String alarmContent){ public void setAlarmContent(String alarmContent){
this.alarmContent = alarmContent; this.alarmContent = alarmContent;
} }
...@@ -171,7 +189,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -171,7 +189,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -179,7 +197,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -179,7 +197,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
if (obj instanceof DeviceAlarmInfoEntity) { if (obj instanceof DeviceAlarmInfoEntity) {
DeviceAlarmInfoEntity tmp = (DeviceAlarmInfoEntity) obj; DeviceAlarmInfoEntity tmp = (DeviceAlarmInfoEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
...@@ -189,6 +207,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -189,6 +207,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
StringBuilder sb = new StringBuilder(""); StringBuilder sb = new StringBuilder("");
sb.append(",alarmTime:").append(getAlarmTime()); sb.append(",alarmTime:").append(getAlarmTime());
sb.append(",alarmDevice:").append(getAlarmDevice()); sb.append(",alarmDevice:").append(getAlarmDevice());
sb.append(",siteId:").append(getSiteId());
sb.append(",alarmType:").append(getAlarmType()); sb.append(",alarmType:").append(getAlarmType());
sb.append(",alarmLevel:").append(getAlarmLevel()); sb.append(",alarmLevel:").append(getAlarmLevel());
sb.append(",alarmReceivePersonnel:").append(getAlarmReceivePersonnel()); sb.append(",alarmReceivePersonnel:").append(getAlarmReceivePersonnel());
...@@ -200,20 +219,22 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo { ...@@ -200,20 +219,22 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
public void initAttrValue(){ public void initAttrValue(){
this.alarmTime = null; this.alarmTime = null;
this.alarmDevice = null;
this.alarmDevice = null; this.siteId = null;
this.alarmType = null; this.alarmType = null;
this.alarmLevel = null; this.alarmLevel = null;
this.alarmReceivePersonnel = ""; this.alarmReceivePersonnel = "";
this.receivePersonnelTelephone = ""; this.receivePersonnelTelephone = "";
this.alarmStatus = 0; this.alarmStatus = 0;
this.alarmContent = ""; this.alarmContent = "";
} }
} }
\ No newline at end of file
...@@ -188,6 +188,11 @@ public class DeviceEntity extends DeviceVo { ...@@ -188,6 +188,11 @@ public class DeviceEntity extends DeviceVo {
*/ */
private String homeUrl; private String homeUrl;
/**
* 设备版本
*/
private String deviceVersion;
public DeviceEntity(){} public DeviceEntity(){}
...@@ -715,6 +720,14 @@ public class DeviceEntity extends DeviceVo { ...@@ -715,6 +720,14 @@ public class DeviceEntity extends DeviceVo {
this.deviceSN = deviceSN; this.deviceSN = deviceSN;
} }
public String getDeviceVersion() {
return deviceVersion;
}
public void setDeviceVersion(String deviceVersion) {
this.deviceVersion = deviceVersion;
}
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
...@@ -849,6 +862,8 @@ public class DeviceEntity extends DeviceVo { ...@@ -849,6 +862,8 @@ public class DeviceEntity extends DeviceVo {
this.skinName = ""; this.skinName = "";
this.deviceVersion = "";
this.homeUrl = ""; this.homeUrl = "";
} }
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ import com.mortals.xhx.module.device.model.vo.DeviceLogVo; ...@@ -10,7 +10,7 @@ import com.mortals.xhx.module.device.model.vo.DeviceLogVo;
* 设备日志实体对象 * 设备日志实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-02 * @date 2022-08-22
*/ */
public class DeviceLogEntity extends DeviceLogVo { public class DeviceLogEntity extends DeviceLogVo {
...@@ -20,6 +20,10 @@ public class DeviceLogEntity extends DeviceLogVo { ...@@ -20,6 +20,10 @@ public class DeviceLogEntity extends DeviceLogVo {
* traceId,日志追踪id * traceId,日志追踪id
*/ */
private String traceID; private String traceID;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/** /**
* 设备ID * 设备ID
*/ */
...@@ -62,6 +66,20 @@ public class DeviceLogEntity extends DeviceLogVo { ...@@ -62,6 +66,20 @@ public class DeviceLogEntity extends DeviceLogVo {
public void setTraceID(String traceID){ public void setTraceID(String traceID){
this.traceID = traceID; this.traceID = traceID;
} }
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/** /**
* 获取 设备ID * 获取 设备ID
* @return Long * @return Long
...@@ -169,6 +187,7 @@ public class DeviceLogEntity extends DeviceLogVo { ...@@ -169,6 +187,7 @@ public class DeviceLogEntity extends DeviceLogVo {
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(""); StringBuilder sb = new StringBuilder("");
sb.append(",traceID:").append(getTraceID()); sb.append(",traceID:").append(getTraceID());
sb.append(",siteId:").append(getSiteId());
sb.append(",deviceId:").append(getDeviceId()); sb.append(",deviceId:").append(getDeviceId());
sb.append(",deviceCode:").append(getDeviceCode()); sb.append(",deviceCode:").append(getDeviceCode());
sb.append(",deviceName:").append(getDeviceName()); sb.append(",deviceName:").append(getDeviceName());
...@@ -182,6 +201,8 @@ public class DeviceLogEntity extends DeviceLogVo { ...@@ -182,6 +201,8 @@ public class DeviceLogEntity extends DeviceLogVo {
this.traceID = ""; this.traceID = "";
this.siteId = null;
this.deviceId = null; this.deviceId = null;
this.deviceCode = ""; this.deviceCode = "";
......
...@@ -6,7 +6,7 @@ import com.mortals.xhx.module.device.model.DeviceLogEntity; ...@@ -6,7 +6,7 @@ import com.mortals.xhx.module.device.model.DeviceLogEntity;
* 设备日志查询对象 * 设备日志查询对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-02 * @date 2022-08-22
*/ */
public class DeviceLogQuery extends DeviceLogEntity { public class DeviceLogQuery extends DeviceLogEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
...@@ -24,6 +24,18 @@ public class DeviceLogQuery extends DeviceLogEntity { ...@@ -24,6 +24,18 @@ public class DeviceLogQuery extends DeviceLogEntity {
/** traceId,日志追踪id */ /** traceId,日志追踪id */
private List<String> traceIDList; private List<String> traceIDList;
/** 开始 站点Id,来源基础服务平台 */
private Long siteIdStart;
/** 结束 站点Id,来源基础服务平台 */
private Long siteIdEnd;
/** 增加 站点Id,来源基础服务平台 */
private Long siteIdIncrement;
/** 站点Id,来源基础服务平台列表 */
private List <Long> siteIdList;
/** 开始 设备ID */ /** 开始 设备ID */
private Long deviceIdStart; private Long deviceIdStart;
...@@ -183,6 +195,70 @@ public class DeviceLogQuery extends DeviceLogEntity { ...@@ -183,6 +195,70 @@ public class DeviceLogQuery extends DeviceLogEntity {
public void setTraceIDList(List<String> traceIDList){ public void setTraceIDList(List<String> traceIDList){
this.traceIDList = traceIDList; this.traceIDList = traceIDList;
} }
/**
* 获取 开始 站点Id,来源基础服务平台
* @return siteIdStart
*/
public Long getSiteIdStart(){
return this.siteIdStart;
}
/**
* 设置 开始 站点Id,来源基础服务平台
* @param siteIdStart
*/
public void setSiteIdStart(Long siteIdStart){
this.siteIdStart = siteIdStart;
}
/**
* 获取 结束 站点Id,来源基础服务平台
* @return $siteIdEnd
*/
public Long getSiteIdEnd(){
return this.siteIdEnd;
}
/**
* 设置 结束 站点Id,来源基础服务平台
* @param siteIdEnd
*/
public void setSiteIdEnd(Long siteIdEnd){
this.siteIdEnd = siteIdEnd;
}
/**
* 获取 增加 站点Id,来源基础服务平台
* @return siteIdIncrement
*/
public Long getSiteIdIncrement(){
return this.siteIdIncrement;
}
/**
* 设置 增加 站点Id,来源基础服务平台
* @param siteIdIncrement
*/
public void setSiteIdIncrement(Long siteIdIncrement){
this.siteIdIncrement = siteIdIncrement;
}
/**
* 获取 站点Id,来源基础服务平台
* @return siteIdList
*/
public List<Long> getSiteIdList(){
return this.siteIdList;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteIdList
*/
public void setSiteIdList(List<Long> siteIdList){
this.siteIdList = siteIdList;
}
/** /**
* 获取 开始 设备ID * 获取 开始 设备ID
* @return deviceIdStart * @return deviceIdStart
...@@ -627,6 +703,51 @@ public class DeviceLogQuery extends DeviceLogEntity { ...@@ -627,6 +703,51 @@ public class DeviceLogQuery extends DeviceLogEntity {
return this; return this;
} }
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public DeviceLogQuery siteId(Long siteId){
setSiteId(siteId);
return this;
}
/**
* 设置 开始 站点Id,来源基础服务平台
* @param siteIdStart
*/
public DeviceLogQuery siteIdStart(Long siteIdStart){
this.siteIdStart = siteIdStart;
return this;
}
/**
* 设置 结束 站点Id,来源基础服务平台
* @param siteIdEnd
*/
public DeviceLogQuery siteIdEnd(Long siteIdEnd){
this.siteIdEnd = siteIdEnd;
return this;
}
/**
* 设置 增加 站点Id,来源基础服务平台
* @param siteIdIncrement
*/
public DeviceLogQuery siteIdIncrement(Long siteIdIncrement){
this.siteIdIncrement = siteIdIncrement;
return this;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteIdList
*/
public DeviceLogQuery siteIdList(List<Long> siteIdList){
this.siteIdList = siteIdList;
return this;
}
/** /**
* 设置 设备ID * 设置 设备ID
* @param deviceId * @param deviceId
......
...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.device.model.DeviceEntity; ...@@ -7,7 +7,7 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
* 设备查询对象 * 设备查询对象
* *
* @author zxfei * @author zxfei
* @date 2022-08-12 * @date 2022-08-22
*/ */
public class DeviceQuery extends DeviceEntity { public class DeviceQuery extends DeviceEntity {
/** 开始 主键ID,主键,自增长 */ /** 开始 主键ID,主键,自增长 */
...@@ -28,6 +28,9 @@ public class DeviceQuery extends DeviceEntity { ...@@ -28,6 +28,9 @@ public class DeviceQuery extends DeviceEntity {
/** 设备编码,SN码等,默认为MAC地址 */ /** 设备编码,SN码等,默认为MAC地址 */
private List<String> deviceCodeList; private List<String> deviceCodeList;
/** 设备SN码 */
private List<String> deviceSNList;
/** 设备的MAC地址 */ /** 设备的MAC地址 */
private List<String> deviceMacList; private List<String> deviceMacList;
...@@ -259,6 +262,9 @@ public class DeviceQuery extends DeviceEntity { ...@@ -259,6 +262,9 @@ public class DeviceQuery extends DeviceEntity {
/** 是否删除(0.否,1.是)列表 */ /** 是否删除(0.否,1.是)列表 */
private List <Integer> deletedList; private List <Integer> deletedList;
/** 设备版本 */
private List<String> deviceVersionList;
/** 开始 设备来源(0.旧设备,1.新设备) */ /** 开始 设备来源(0.旧设备,1.新设备) */
private Integer sourceStart; private Integer sourceStart;
...@@ -307,9 +313,6 @@ public class DeviceQuery extends DeviceEntity { ...@@ -307,9 +313,6 @@ public class DeviceQuery extends DeviceEntity {
/** 结束 更新时间 */ /** 结束 更新时间 */
private String updateTimeEnd; private String updateTimeEnd;
/** 设备SN码 */
private List<String> deviceSNList;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */ /** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<DeviceQuery> orConditionList; private List<DeviceQuery> orConditionList;
...@@ -412,6 +415,21 @@ public class DeviceQuery extends DeviceEntity { ...@@ -412,6 +415,21 @@ public class DeviceQuery extends DeviceEntity {
public void setDeviceCodeList(List<String> deviceCodeList){ public void setDeviceCodeList(List<String> deviceCodeList){
this.deviceCodeList = deviceCodeList; this.deviceCodeList = deviceCodeList;
} }
/**
* 获取 设备SN码
* @return deviceSNList
*/
public List<String> getDeviceSNList(){
return this.deviceSNList;
}
/**
* 设置 设备SN码
* @param deviceSNList
*/
public void setDeviceSNList(List<String> deviceSNList){
this.deviceSNList = deviceSNList;
}
/** /**
* 获取 设备的MAC地址 * 获取 设备的MAC地址
* @return deviceMacList * @return deviceMacList
...@@ -1625,6 +1643,21 @@ public class DeviceQuery extends DeviceEntity { ...@@ -1625,6 +1643,21 @@ public class DeviceQuery extends DeviceEntity {
this.deletedList = deletedList; this.deletedList = deletedList;
} }
/**
* 获取 设备版本
* @return deviceVersionList
*/
public List<String> getDeviceVersionList(){
return this.deviceVersionList;
}
/**
* 设置 设备版本
* @param deviceVersionList
*/
public void setDeviceVersionList(List<String> deviceVersionList){
this.deviceVersionList = deviceVersionList;
}
/** /**
* 获取 开始 设备来源(0.旧设备,1.新设备) * 获取 开始 设备来源(0.旧设备,1.新设备)
* @return sourceStart * @return sourceStart
...@@ -1881,21 +1914,6 @@ public class DeviceQuery extends DeviceEntity { ...@@ -1881,21 +1914,6 @@ public class DeviceQuery extends DeviceEntity {
this.updateTimeEnd = updateTimeEnd; this.updateTimeEnd = updateTimeEnd;
} }
/**
* 获取 设备SN码
* @return deviceSNList
*/
public List<String> getDeviceSNList(){
return this.deviceSNList;
}
/**
* 设置 设备SN码
* @param deviceSNList
*/
public void setDeviceSNList(List<String> deviceSNList){
this.deviceSNList = deviceSNList;
}
/** /**
* 设置 主键ID,主键,自增长 * 设置 主键ID,主键,自增长
* @param id * @param id
...@@ -1980,6 +1998,25 @@ public class DeviceQuery extends DeviceEntity { ...@@ -1980,6 +1998,25 @@ public class DeviceQuery extends DeviceEntity {
} }
/**
* 设置 设备SN码
* @param deviceSN
*/
public DeviceQuery deviceSN(String deviceSN){
setDeviceSN(deviceSN);
return this;
}
/**
* 设置 设备SN码
* @param deviceSNList
*/
public DeviceQuery deviceSNList(List<String> deviceSNList){
this.deviceSNList = deviceSNList;
return this;
}
/** /**
* 设置 设备的MAC地址 * 设置 设备的MAC地址
* @param deviceMac * @param deviceMac
...@@ -2928,6 +2965,25 @@ public class DeviceQuery extends DeviceEntity { ...@@ -2928,6 +2965,25 @@ public class DeviceQuery extends DeviceEntity {
return this; return this;
} }
/**
* 设置 设备版本
* @param deviceVersion
*/
public DeviceQuery deviceVersion(String deviceVersion){
setDeviceVersion(deviceVersion);
return this;
}
/**
* 设置 设备版本
* @param deviceVersionList
*/
public DeviceQuery deviceVersionList(List<String> deviceVersionList){
this.deviceVersionList = deviceVersionList;
return this;
}
/** /**
* 设置 设备来源(0.旧设备,1.新设备) * 设置 设备来源(0.旧设备,1.新设备)
* @param source * @param source
...@@ -3065,25 +3121,6 @@ public class DeviceQuery extends DeviceEntity { ...@@ -3065,25 +3121,6 @@ public class DeviceQuery extends DeviceEntity {
} }
/**
* 设置 设备SN码
* @param deviceSN
*/
public DeviceQuery deviceSN(String deviceSN){
setDeviceSN(deviceSN);
return this;
}
/**
* 设置 设备SN码
* @param deviceSNList
*/
public DeviceQuery deviceSNList(List<String> deviceSNList){
this.deviceSNList = deviceSNList;
return this;
}
/** /**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) * 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
* @return orConditionList * @return orConditionList
......
...@@ -11,12 +11,16 @@ import com.mortals.xhx.module.device.model.vo.DeviceStatVo; ...@@ -11,12 +11,16 @@ import com.mortals.xhx.module.device.model.vo.DeviceStatVo;
* 设备统计实体对象 * 设备统计实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-05 * @date 2022-08-22
*/ */
public class DeviceStatEntity extends DeviceStatVo { public class DeviceStatEntity extends DeviceStatVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/** /**
* 设备总数 * 设备总数
*/ */
...@@ -57,6 +61,14 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -57,6 +61,14 @@ public class DeviceStatEntity extends DeviceStatVo {
* 停用率 * 停用率
*/ */
private BigDecimal deviceStopRatio; private BigDecimal deviceStopRatio;
/**
* 未激活设备数量
*/
private Integer deviceUnActiveCount;
/**
* 未激活率
*/
private BigDecimal deviceUnActiveRatio;
/** /**
* 今日告警数量 * 今日告警数量
*/ */
...@@ -97,6 +109,20 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -97,6 +109,20 @@ public class DeviceStatEntity extends DeviceStatVo {
public DeviceStatEntity(){} public DeviceStatEntity(){}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/** /**
* 获取 设备总数 * 获取 设备总数
* @return Integer * @return Integer
...@@ -237,6 +263,34 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -237,6 +263,34 @@ public class DeviceStatEntity extends DeviceStatVo {
public void setDeviceStopRatio(BigDecimal deviceStopRatio){ public void setDeviceStopRatio(BigDecimal deviceStopRatio){
this.deviceStopRatio = deviceStopRatio; this.deviceStopRatio = deviceStopRatio;
} }
/**
* 获取 未激活设备数量
* @return Integer
*/
public Integer getDeviceUnActiveCount(){
return deviceUnActiveCount;
}
/**
* 设置 未激活设备数量
* @param deviceUnActiveCount
*/
public void setDeviceUnActiveCount(Integer deviceUnActiveCount){
this.deviceUnActiveCount = deviceUnActiveCount;
}
/**
* 获取 未激活率
* @return BigDecimal
*/
public BigDecimal getDeviceUnActiveRatio(){
return deviceUnActiveRatio;
}
/**
* 设置 未激活率
* @param deviceUnActiveRatio
*/
public void setDeviceUnActiveRatio(BigDecimal deviceUnActiveRatio){
this.deviceUnActiveRatio = deviceUnActiveRatio;
}
/** /**
* 获取 今日告警数量 * 获取 今日告警数量
* @return Integer * @return Integer
...@@ -385,6 +439,7 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -385,6 +439,7 @@ public class DeviceStatEntity extends DeviceStatVo {
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(""); StringBuilder sb = new StringBuilder("");
sb.append(",siteId:").append(getSiteId());
sb.append(",deviceTotalCount:").append(getDeviceTotalCount()); sb.append(",deviceTotalCount:").append(getDeviceTotalCount());
sb.append(",deviceAddCount:").append(getDeviceAddCount()); sb.append(",deviceAddCount:").append(getDeviceAddCount());
sb.append(",siteTotalCount:").append(getSiteTotalCount()); sb.append(",siteTotalCount:").append(getSiteTotalCount());
...@@ -395,6 +450,8 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -395,6 +450,8 @@ public class DeviceStatEntity extends DeviceStatVo {
sb.append(",deviceOfflineRatio:").append(getDeviceOfflineRatio()); sb.append(",deviceOfflineRatio:").append(getDeviceOfflineRatio());
sb.append(",deviceStopCount:").append(getDeviceStopCount()); sb.append(",deviceStopCount:").append(getDeviceStopCount());
sb.append(",deviceStopRatio:").append(getDeviceStopRatio()); sb.append(",deviceStopRatio:").append(getDeviceStopRatio());
sb.append(",deviceUnActiveCount:").append(getDeviceUnActiveCount());
sb.append(",deviceUnActiveRatio:").append(getDeviceUnActiveRatio());
sb.append(",alarmTotalCount:").append(getAlarmTotalCount()); sb.append(",alarmTotalCount:").append(getAlarmTotalCount());
sb.append(",alarmAddCount:").append(getAlarmAddCount()); sb.append(",alarmAddCount:").append(getAlarmAddCount());
sb.append(",pushTotalCount:").append(getPushTotalCount()); sb.append(",pushTotalCount:").append(getPushTotalCount());
...@@ -409,6 +466,8 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -409,6 +466,8 @@ public class DeviceStatEntity extends DeviceStatVo {
public void initAttrValue(){ public void initAttrValue(){
this.siteId = null;
this.deviceTotalCount = 0; this.deviceTotalCount = 0;
this.deviceAddCount = 0; this.deviceAddCount = 0;
...@@ -429,6 +488,10 @@ public class DeviceStatEntity extends DeviceStatVo { ...@@ -429,6 +488,10 @@ public class DeviceStatEntity extends DeviceStatVo {
this.deviceStopRatio = BigDecimal.valueOf(0.00); this.deviceStopRatio = BigDecimal.valueOf(0.00);
this.deviceUnActiveCount = 0;
this.deviceUnActiveRatio = BigDecimal.valueOf(0.00);
this.alarmTotalCount = 0; this.alarmTotalCount = 0;
this.alarmAddCount = 0; this.alarmAddCount = 0;
......
...@@ -58,7 +58,7 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{ ...@@ -58,7 +58,7 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
* 设备统计当天情况 * 设备统计当天情况
* @param context * @param context
*/ */
void deviceStat(Context context); void deviceStat(Long siteId,Context context);
List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context); List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context);
......
...@@ -337,15 +337,17 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -337,15 +337,17 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
* @param context * @param context
*/ */
@Override @Override
public void deviceStat(Context context) { public void deviceStat(Long siteId,Context context) {
//查询当天统计,如果有 则更新统计结果,否则新增 //查询当天统计,如果有 则更新统计结果,否则新增
DeviceStatEntity deviceStatEntity = deviceStatService.selectOne(new DeviceStatQuery() DeviceStatEntity deviceStatEntity = deviceStatService.selectOne(new DeviceStatQuery()
.siteId(siteId)
.year(DateUtil.year(new Date())) .year(DateUtil.year(new Date()))
.month(DateUtil.month(new Date()) + 1) .month(DateUtil.month(new Date()) + 1)
.day(DateUtil.dayOfMonth(new Date()))); .day(DateUtil.dayOfMonth(new Date())));
if (ObjectUtils.isEmpty(deviceStatEntity)) { if (ObjectUtils.isEmpty(deviceStatEntity)) {
deviceStatEntity = new DeviceStatEntity(); deviceStatEntity = new DeviceStatEntity();
deviceStatEntity.initAttrValue(); deviceStatEntity.initAttrValue();
deviceStatEntity.setSiteId(siteId);
deviceStatEntity.setCreateTime(new Date()); deviceStatEntity.setCreateTime(new Date());
deviceStatEntity.setYear(DateUtil.year(new Date())); deviceStatEntity.setYear(DateUtil.year(new Date()));
deviceStatEntity.setMonth(DateUtil.month(new Date()) + 1); deviceStatEntity.setMonth(DateUtil.month(new Date()) + 1);
...@@ -354,28 +356,40 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -354,28 +356,40 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//获取昨天统计数据 //获取昨天统计数据
DeviceStatEntity yesterdayDeviceStat = deviceStatService.selectOne(new DeviceStatQuery() DeviceStatEntity yesterdayDeviceStat = deviceStatService.selectOne(new DeviceStatQuery()
.siteId(siteId)
.year(DateUtil.year(DateUtil.yesterday())) .year(DateUtil.year(DateUtil.yesterday()))
.month(DateUtil.month(DateUtil.yesterday()) + 1) .month(DateUtil.month(DateUtil.yesterday()) + 1)
.day(DateUtil.dayOfMonth(DateUtil.yesterday()))); .day(DateUtil.dayOfMonth(DateUtil.yesterday())));
if (ObjectUtils.isEmpty(yesterdayDeviceStat)) { if (ObjectUtils.isEmpty(yesterdayDeviceStat)) {
yesterdayDeviceStat = new DeviceStatEntity(); yesterdayDeviceStat = new DeviceStatEntity();
yesterdayDeviceStat.initAttrValue(); yesterdayDeviceStat.initAttrValue();
yesterdayDeviceStat.setSiteId(siteId);
yesterdayDeviceStat.setYear(DateUtil.year(DateUtil.yesterday()));
} }
try { try {
//获取设备总数 //获取设备总数
List<DeviceEntity> deviceList = this.find(new DeviceQuery()); List<DeviceEntity> deviceList = this.find(new DeviceQuery().siteId(siteId));
Integer deviceTotalCount = deviceList.size(); Integer deviceTotalCount = deviceList.size();
//未激活数量
Long deviceUnActiveCount = deviceList.parallelStream()
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.未激活.getValue())
.count();
//激活设备
Integer deviceActiveCount = deviceList.size() - deviceUnActiveCount.intValue();
deviceStatEntity.setDeviceTotalCount(deviceTotalCount); deviceStatEntity.setDeviceTotalCount(deviceTotalCount);
deviceStatEntity.setDeviceAddCount(deviceTotalCount - yesterdayDeviceStat.getDeviceTotalCount()); deviceStatEntity.setDeviceAddCount(deviceTotalCount - yesterdayDeviceStat.getDeviceTotalCount());
//站点数量 ///统计按当前站点归集 // TODO: 2022/8/22
SitePdu sitePdu = new SitePdu(); Rest<List<SitePdu>> resp = siteFeign.getFlatSitesBySiteId(new SitePdu().id(siteId));
sitePdu.setSize(-1); // SitePdu sitePdu = new SitePdu();
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); // sitePdu.setSize(-1);
// Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
//
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData();
deviceStatEntity.setSiteTotalCount(sitePduList.size()); deviceStatEntity.setSiteTotalCount(sitePduList.size());
deviceStatEntity.setSiteAddCount(sitePduList.size() - yesterdayDeviceStat.getSiteTotalCount()); deviceStatEntity.setSiteAddCount(sitePduList.size() - yesterdayDeviceStat.getSiteTotalCount());
} }
...@@ -387,7 +401,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -387,7 +401,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()) .filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue())
.count(); .count();
deviceStatEntity.setDeviceOnlineCount(deviceOnlineCount.intValue()); deviceStatEntity.setDeviceOnlineCount(deviceOnlineCount.intValue());
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceList.size()), ROUND_HALF_DOWN).setScale(2)); //在线率=在线设备/所有激活设备
if(deviceActiveCount>0){
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceActiveCount), ROUND_HALF_DOWN).setScale(2));
}
//离线数量 //离线数量
Long deviceOfflineCount = deviceList.parallelStream() Long deviceOfflineCount = deviceList.parallelStream()
...@@ -396,15 +413,24 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -396,15 +413,24 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) .filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue())
.count(); .count();
deviceStatEntity.setDeviceOfflineCount(deviceOfflineCount.intValue()); deviceStatEntity.setDeviceOfflineCount(deviceOfflineCount.intValue());
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceList.size()), ROUND_HALF_DOWN).setScale(2)); if(deviceActiveCount>0) {
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceActiveCount), ROUND_HALF_DOWN).setScale(2));
}
//停用数量 //停用数量
Long deviceStopCount = deviceList.parallelStream() Long deviceStopCount = deviceList.parallelStream()
.filter(f -> f.getDeviceStatus() > DeviceStatusEnum.未激活.getValue()) .filter(f -> f.getDeviceStatus() > DeviceStatusEnum.未激活.getValue())
.filter(f -> f.getEnabled() == YesNoEnum.NO.getValue()) .filter(f -> f.getEnabled() == YesNoEnum.NO.getValue())
.count(); .count();
deviceStatEntity.setDeviceStopCount(deviceStopCount.intValue()); deviceStatEntity.setDeviceStopCount(deviceStopCount.intValue());
deviceStatEntity.setDeviceStopRatio(new BigDecimal(deviceStopCount).divide(new BigDecimal(deviceList.size()), ROUND_HALF_DOWN).setScale(2)); if(deviceActiveCount>0) {
deviceStatEntity.setDeviceStopRatio(new BigDecimal(deviceStopCount).divide(new BigDecimal(deviceActiveCount), ROUND_HALF_DOWN).setScale(2));
}
deviceStatEntity.setDeviceUnActiveCount(deviceUnActiveCount.intValue());
if(deviceActiveCount>0) {
deviceStatEntity.setDeviceUnActiveRatio(new BigDecimal(deviceUnActiveCount).divide(new BigDecimal(deviceActiveCount), ROUND_HALF_DOWN).setScale(2));
}
//今日告警数量 //今日告警数量
DeviceAlarmInfoQuery deviceAlarmInfoQuery = new DeviceAlarmInfoQuery(); DeviceAlarmInfoQuery deviceAlarmInfoQuery = new DeviceAlarmInfoQuery();
...@@ -432,6 +458,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -432,6 +458,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceStatEntity.setUploadMessageTotalCount(collect.getOrDefault(true, 0L).intValue()); deviceStatEntity.setUploadMessageTotalCount(collect.getOrDefault(true, 0L).intValue());
deviceStatEntity.setDownloadMessageTotalCount(collect.getOrDefault(false, 0L).intValue()); deviceStatEntity.setDownloadMessageTotalCount(collect.getOrDefault(false, 0L).intValue());
deviceStatEntity.setSiteId(siteId);
if (deviceStatEntity.newEntity()) { if (deviceStatEntity.newEntity()) {
deviceStatEntity.setCreateTime(new Date()); deviceStatEntity.setCreateTime(new Date());
deviceStatService.save(deviceStatEntity); deviceStatService.save(deviceStatEntity);
......
package com.mortals.xhx.module.device.service.impl; package com.mortals.xhx.module.device.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.feign.site.ISiteFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.device.dao.DeviceStatDao; import com.mortals.xhx.module.device.dao.DeviceStatDao;
import com.mortals.xhx.module.device.model.DeviceStatEntity; import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.service.DeviceStatService; import com.mortals.xhx.module.device.service.DeviceStatService;
import org.springframework.util.ObjectUtils; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* DeviceStatService * DeviceStatService
......
...@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
...@@ -297,4 +298,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe ...@@ -297,4 +298,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
} }
return super.editAfter(id, model, entity, context); return super.editAfter(id, model, entity, context);
} }
public static void main(String[] args) {
String str2 = "510000000000".replaceAll("(0)+$", "");
System.out.println(str2);
//System.out.println(new BigDecimal("510105000000").stripTrailingZeros().toPlainString());
}
} }
\ No newline at end of file
...@@ -2,12 +2,15 @@ package com.mortals.xhx.module.device.web; ...@@ -2,12 +2,15 @@ package com.mortals.xhx.module.device.web;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.model.DeviceStatQuery; import com.mortals.xhx.module.device.model.DeviceStatQuery;
import com.mortals.xhx.module.device.service.DeviceService; import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.sitestat.model.SitestatQuery; import com.mortals.xhx.module.sitestat.model.SitestatQuery;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -45,6 +48,8 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi ...@@ -45,6 +48,8 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
@Autowired @Autowired
private DeviceService deviceService; private DeviceService deviceService;
public DeviceStatController() { public DeviceStatController() {
super.setModuleDesc("设备统计"); super.setModuleDesc("设备统计");
} }
...@@ -56,17 +61,19 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi ...@@ -56,17 +61,19 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
/** /**
* 站点信息 * 同步当前站点
*/ */
@PostMapping(value = "syncDeviceStat") @PostMapping(value = "syncDeviceStat")
public Rest<Object> syncDeviceStat() { public Rest<Object> syncDeviceStat(@RequestBody DeviceQuery deviceQuery) {
try { try {
//刷新成功,返回列表 if(ObjectUtils.isEmpty(deviceQuery)||ObjectUtils.isEmpty(deviceQuery.getSiteId())) throw new AppException("请求站点Id不能为空!");
deviceService.deviceStat(getContext()); //刷新成功,返回列
deviceService.deviceStat(deviceQuery.getSiteId(),getContext());
DeviceStatQuery deviceStatQuery = new DeviceStatQuery(); DeviceStatQuery deviceStatQuery = new DeviceStatQuery();
deviceStatQuery.setYear(DateUtil.year(new Date())); deviceStatQuery.setYear(DateUtil.year(new Date()));
deviceStatQuery.setMonth(DateUtil.month(new Date()) + 1); deviceStatQuery.setMonth(DateUtil.month(new Date()) + 1);
deviceStatQuery.setDay(DateUtil.dayOfMonth(new Date())); deviceStatQuery.setDay(DateUtil.dayOfMonth(new Date()));
deviceStatQuery.setSiteId(deviceQuery.getSiteId());
Rest<Object> resp = this.list(deviceStatQuery); Rest<Object> resp = this.list(deviceStatQuery);
return resp; return resp;
} catch (Exception e) { } catch (Exception e) {
......
package com.mortals.xhx.module.product.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import java.util.List;
/**
* 产品客户端版本Dao
* 产品客户端版本 DAO接口
*
* @author zxfei
* @date 2022-08-22
*/
public interface ProductVersionDao extends ICRUDDao<ProductVersionEntity,Long>{
}
package com.mortals.xhx.module.product.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.product.dao.ProductVersionDao;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 产品客户端版本DaoImpl DAO接口
*
* @author zxfei
* @date 2022-08-22
*/
@Repository("productVersionDao")
public class ProductVersionDaoImpl extends BaseCRUDDaoMybatis<ProductVersionEntity,Long> implements ProductVersionDao {
}
package com.mortals.xhx.module.product.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.product.model.vo.ProductVersionVo;
/**
* 产品客户端版本实体对象
*
* @author zxfei
* @date 2022-08-22
*/
public class ProductVersionEntity extends ProductVersionVo {
private static final long serialVersionUID = 1L;
/**
* 产品Id
*/
private Long productId;
/**
* 产品编码
*/
private String productCode;
/**
* 产品名称
*/
private String productName;
/**
* 文件相对路径地址
*/
@Excel(name = "文件相对路径地址")
private String filePath;
/**
* 版本号
*/
@Excel(name = "版本号")
private Integer version;
/**
* 备注信息
*/
@Excel(name = "备注信息")
private String remark;
public ProductVersionEntity(){}
/**
* 获取 产品Id
* @return Long
*/
public Long getProductId(){
return productId;
}
/**
* 设置 产品Id
* @param productId
*/
public void setProductId(Long productId){
this.productId = productId;
}
/**
* 获取 产品编码
* @return String
*/
public String getProductCode(){
return productCode;
}
/**
* 设置 产品编码
* @param productCode
*/
public void setProductCode(String productCode){
this.productCode = productCode;
}
/**
* 获取 产品名称
* @return String
*/
public String getProductName(){
return productName;
}
/**
* 设置 产品名称
* @param productName
*/
public void setProductName(String productName){
this.productName = productName;
}
/**
* 获取 文件相对路径地址
* @return String
*/
public String getFilePath(){
return filePath;
}
/**
* 设置 文件相对路径地址
* @param filePath
*/
public void setFilePath(String filePath){
this.filePath = filePath;
}
/**
* 获取 版本号
* @return Integer
*/
public Integer getVersion(){
return version;
}
/**
* 设置 版本号
* @param version
*/
public void setVersion(Integer version){
this.version = version;
}
/**
* 获取 备注信息
* @return String
*/
public String getRemark(){
return remark;
}
/**
* 设置 备注信息
* @param remark
*/
public void setRemark(String remark){
this.remark = remark;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof ProductVersionEntity) {
ProductVersionEntity tmp = (ProductVersionEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",productId:").append(getProductId());
sb.append(",productCode:").append(getProductCode());
sb.append(",productName:").append(getProductName());
sb.append(",filePath:").append(getFilePath());
sb.append(",version:").append(getVersion());
sb.append(",remark:").append(getRemark());
return sb.toString();
}
public void initAttrValue(){
this.productId = null;
this.productCode = "";
this.productName = "";
this.filePath = "";
this.version = null;
this.remark = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.product.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 产品客户端版本视图对象
*
* @author zxfei
* @date 2022-08-22
*/
public class ProductVersionVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.product.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
/**
* ProductVersionService
*
* 产品客户端版本 service接口
*
* @author zxfei
* @date 2022-08-22
*/
public interface ProductVersionService extends ICRUDService<ProductVersionEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.product.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.product.dao.ProductVersionDao;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductVersionService;
/**
* ProductVersionService
* 产品客户端版本 service实现
*
* @author zxfei
* @date 2022-08-22
*/
@Service("productVersionService")
public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVersionDao, ProductVersionEntity, Long> implements ProductVersionService {
}
\ No newline at end of file
package com.mortals.xhx.module.product.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductVersionService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 产品客户端版本
*
* @author zxfei
* @date 2022-08-22
*/
@RestController
@RequestMapping("product/version")
public class ProductVersionController extends BaseCRUDJsonBodyMappingController<ProductVersionService,ProductVersionEntity,Long> {
@Autowired
private ParamService paramService;
public ProductVersionController(){
super.setModuleDesc( "产品客户端版本");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<resultMap type="DeviceLogEntity" id="DeviceLogEntity-Map"> <resultMap type="DeviceLogEntity" id="DeviceLogEntity-Map">
<id property="id" column="id" /> <id property="id" column="id" />
<result property="traceID" column="traceID" /> <result property="traceID" column="traceID" />
<result property="siteId" column="siteId" />
<result property="deviceId" column="deviceId" /> <result property="deviceId" column="deviceId" />
<result property="deviceCode" column="deviceCode" /> <result property="deviceCode" column="deviceCode" />
<result property="deviceName" column="deviceName" /> <result property="deviceName" column="deviceName" />
...@@ -30,6 +31,9 @@ ...@@ -30,6 +31,9 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('traceID') or colPickMode == 1 and data.containsKey('traceID')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('traceID') or colPickMode == 1 and data.containsKey('traceID')))">
a.traceID, a.traceID,
</if> </if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteId') or colPickMode == 1 and data.containsKey('siteId')))">
a.siteId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceId') or colPickMode == 1 and data.containsKey('deviceId')))"> <if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceId') or colPickMode == 1 and data.containsKey('deviceId')))">
a.deviceId, a.deviceId,
</if> </if>
...@@ -65,18 +69,18 @@ ...@@ -65,18 +69,18 @@
<!-- 新增 区分主键自增加还是业务插入 --> <!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="DeviceLogEntity" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="DeviceLogEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_device_log insert into mortals_xhx_device_log
(traceID,deviceId,deviceCode,deviceName,messageHead,logType,content,createUserId,createTime,updateUserId,updateTime) (traceID,siteId,deviceId,deviceCode,deviceName,messageHead,logType,content,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
(#{traceID},#{deviceId},#{deviceCode},#{deviceName},#{messageHead},#{logType},#{content},#{createUserId},#{createTime},#{updateUserId},#{updateTime}) (#{traceID},#{siteId},#{deviceId},#{deviceCode},#{deviceName},#{messageHead},#{logType},#{content},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
</insert> </insert>
<!-- 批量新增 --> <!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto"> <insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_device_log insert into mortals_xhx_device_log
(traceID,deviceId,deviceCode,deviceName,messageHead,logType,content,createUserId,createTime,updateUserId,updateTime) (traceID,siteId,deviceId,deviceCode,deviceName,messageHead,logType,content,createUserId,createTime,updateUserId,updateTime)
VALUES VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," > <foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.traceID},#{item.deviceId},#{item.deviceCode},#{item.deviceName},#{item.messageHead},#{item.logType},#{item.content},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime}) (#{item.traceID},#{item.siteId},#{item.deviceId},#{item.deviceCode},#{item.deviceName},#{item.messageHead},#{item.logType},#{item.content},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
</foreach> </foreach>
</insert> </insert>
...@@ -89,6 +93,12 @@ ...@@ -89,6 +93,12 @@
<if test="(colPickMode==0 and data.containsKey('traceID')) or (colPickMode==1 and !data.containsKey('traceID'))"> <if test="(colPickMode==0 and data.containsKey('traceID')) or (colPickMode==1 and !data.containsKey('traceID'))">
a.traceID=#{data.traceID}, a.traceID=#{data.traceID},
</if> </if>
<if test="(colPickMode==0 and data.containsKey('siteId')) or (colPickMode==1 and !data.containsKey('siteId'))">
a.siteId=#{data.siteId},
</if>
<if test="(colPickMode==0 and data.containsKey('siteIdIncrement')) or (colPickMode==1 and !data.containsKey('siteIdIncrement'))">
a.siteId=ifnull(a.siteId,0) + #{data.siteIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('deviceId')) or (colPickMode==1 and !data.containsKey('deviceId'))"> <if test="(colPickMode==0 and data.containsKey('deviceId')) or (colPickMode==1 and !data.containsKey('deviceId'))">
a.deviceId=#{data.deviceId}, a.deviceId=#{data.deviceId},
</if> </if>
...@@ -150,6 +160,18 @@ ...@@ -150,6 +160,18 @@
</if> </if>
</foreach> </foreach>
</trim> </trim>
<trim prefix="siteId=(case" suffix="ELSE siteId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('siteId')) or (colPickMode==1 and !item.containsKey('siteId'))">
when a.id=#{item.id} then #{item.siteId}
</when>
<when test="(colPickMode==0 and item.containsKey('siteIdIncrement')) or (colPickMode==1 and !item.containsKey('siteIdIncrement'))">
when a.id=#{item.id} then ifnull(a.siteId,0) + #{item.siteIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="deviceId=(case" suffix="ELSE deviceId end),"> <trim prefix="deviceId=(case" suffix="ELSE deviceId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" > <foreach collection="data.dataList" item="item" index="index" separator="" >
<choose> <choose>
...@@ -377,6 +399,27 @@ ...@@ -377,6 +399,27 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="conditionParamRef.containsKey('siteId')">
<if test="conditionParamRef.siteId != null ">
${_conditionType_} a.siteId = #{${_conditionParam_}.siteId}
</if>
<if test="conditionParamRef.siteId == null">
${_conditionType_} a.siteId is null
</if>
</if>
<if test="conditionParamRef.containsKey('siteIdList')">
${_conditionType_} a.siteId in
<foreach collection="conditionParamRef.siteIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('siteIdStart') and conditionParamRef.siteIdStart != null">
${_conditionType_} a.siteId <![CDATA[ >= ]]> #{${_conditionParam_}.siteIdStart}
</if>
<if test="conditionParamRef.containsKey('siteIdEnd') and conditionParamRef.siteIdEnd != null">
${_conditionType_} a.siteId <![CDATA[ <= ]]> #{${_conditionParam_}.siteIdEnd}
</if>
<if test="conditionParamRef.containsKey('deviceId')"> <if test="conditionParamRef.containsKey('deviceId')">
<if test="conditionParamRef.deviceId != null "> <if test="conditionParamRef.deviceId != null ">
${_conditionType_} a.deviceId = #{${_conditionParam_}.deviceId} ${_conditionType_} a.deviceId = #{${_conditionParam_}.deviceId}
...@@ -574,6 +617,11 @@ ...@@ -574,6 +617,11 @@
<if test='orderCol.traceID != null and "DESC".equalsIgnoreCase(orderCol.traceID)'>DESC</if> <if test='orderCol.traceID != null and "DESC".equalsIgnoreCase(orderCol.traceID)'>DESC</if>
, ,
</if> </if>
<if test="orderCol.containsKey('siteId')">
a.siteId
<if test='orderCol.siteId != null and "DESC".equalsIgnoreCase(orderCol.siteId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('deviceId')"> <if test="orderCol.containsKey('deviceId')">
a.deviceId a.deviceId
<if test='orderCol.deviceId != null and "DESC".equalsIgnoreCase(orderCol.deviceId)'>DESC</if> <if test='orderCol.deviceId != null and "DESC".equalsIgnoreCase(orderCol.deviceId)'>DESC</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment