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

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

parent 8b1ae536
......@@ -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 `skinName` varchar (512) COMMENT '皮肤名称' AFTER skinId;
\ No newline at end of file
ALTER TABLE mortals_xhx_product ADD COLUMN `skinName` varchar (512) COMMENT '皮肤名称' AFTER skinId;
-- ----------------------------
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`;
CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码,默认为MAC地址',
`deviceCode` varchar(256) COMMENT '设备编码,SN码等,默认为MAC地址',
`deviceSN` varchar(256) COMMENT '设备SN码',
`deviceMac` varchar(64) COMMENT '设备的MAC地址',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
......@@ -42,6 +42,7 @@ CREATE TABLE mortals_xhx_device(
`onlineTime` datetime COMMENT '最近上线时间',
`offlineTime` datetime COMMENT '最近离线时间',
`deleted` tinyint(2) COMMENT '是否删除(0.否,1.是)',
`deviceVersion` varchar(64) COMMENT '设备版本',
`source` tinyint(2) COMMENT '设备来源(0.旧设备,1.新设备)',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
......@@ -52,6 +53,8 @@ PRIMARY KEY (`id`)
-- ----------------------------
-- 平台系统表
-- ----------------------------
......@@ -118,7 +121,8 @@ DROP TABLE IF EXISTS `mortals_xhx_device_alarm_info`;
CREATE TABLE mortals_xhx_device_alarm_info(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`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.离线)',
`alarmLevel` tinyint(2) NOT NULL COMMENT '告警级别(0.危险,1.次要,2.一般)',
`alarmReceivePersonnel` varchar(32) NOT NULL COMMENT '接收人员[设备管理的责任人]',
......@@ -131,6 +135,8 @@ CREATE TABLE mortals_xhx_device_alarm_info(
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备告警日志';
-- ----------------------------
-- 设备模块信息表
-- ----------------------------
......@@ -190,17 +196,19 @@ PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `mortals_xhx_alarm_sms_send`;
CREATE TABLE mortals_xhx_alarm_sms_send(
`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 '发送内容',
`sendStatus` tinyint(2) NOT NULL COMMENT '发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)',
`sendTime` datetime NOT NULL COMMENT '发送时间',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
`receiver` varchar(200) NOT NULL COMMENT '接收人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='短信发送记录';
-- ----------------------------
-- 设备日志表
-- ----------------------------
......@@ -208,6 +216,7 @@ DROP TABLE IF EXISTS `mortals_xhx_device_log`;
CREATE TABLE mortals_xhx_device_log(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`traceID` varchar(64) COMMENT 'traceId,日志追踪id',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`deviceId` bigint(20) COMMENT '设备ID',
`deviceCode` varchar(32) NOT NULL COMMENT '设备编号',
`deviceName` varchar(32) NOT NULL COMMENT '设备名称,设置设备名称。',
......@@ -223,6 +232,8 @@ PRIMARY KEY (`id`)
-- ----------------------------
-- 站点统计表
-- ----------------------------
......@@ -249,16 +260,19 @@ PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `mortals_xhx_device_stat`;
CREATE TABLE mortals_xhx_device_stat(
`id` bigint(20) AUTO_INCREMENT COMMENT 'ID',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`deviceTotalCount` int(9) COMMENT '设备总数',
`deviceAddCount` int(9) COMMENT '昨日新增减少设备数量',
`siteTotalCount` int(9) COMMENT '监控站点数量',
`siteAddCount` int(9) COMMENT '昨日新增站点数量',
`deviceOnlineCount` int(9) COMMENT '在线设备数量',
`deviceOnlineRatio` double COMMENT '在线率',
`deviceOnlineRatio` double(6,2) 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 '停用设备数量',
`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 '今日告警数量',
`alarmAddCount` int(9) NOT NULL COMMENT '昨日新增减少数量',
`pushTotalCount` int(9) NOT NULL COMMENT '今日消息推送数量',
......@@ -274,3 +288,26 @@ CREATE TABLE mortals_xhx_device_stat(
PRIMARY KEY (`id`)
) 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 @@
"js-cookie": "2.2.1",
"jsencrypt": "3.0.0-rc.1",
"json-bigint": "^0.3.0",
"moment": "^2.29.4",
"muse-ui": "^3.0.2",
"nprogress": "^0.2.0",
"quill": "1.3.7",
......
......@@ -54,6 +54,8 @@ const router = new Router({
...restBuilder('alarm/config', 'alarm/config'),//设备告警配置
...restBuilder('alarm/sms/send', 'alarm/sms/send'),//设备告警短信
...restBuilder('product/version', 'product/version'),//产品
//以下为基础路由配置
builder('', 'Home'),
builder('index', 'Home'),
......
......@@ -120,11 +120,11 @@
</div>
<!-- 未激活设备 -->
<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="color: #6182f6">未激活率 </span
><span v-bind:class="{ warn: statData.deviceStopRatio >= 0 }"
>{{ statData.deviceStopRatio * 100 }}%</span
><span v-bind:class="{ warn: statData.deviceUnActiveRatio >= 0 }"
>{{ statData.deviceUnActiveRatio * 100 }}%</span
></span
>
<p class="total-item-title">
......@@ -424,6 +424,7 @@
</template>
<script>
import { formatterDate } from "@/assets/utils/index";
export default {
computed: {
userData() {
......@@ -478,6 +479,7 @@ export default {
this.findDevicePush(beforeday);
},
methods: {
formatterDate,
// echarts 适配函数
adapterEcharts() {
this.deviceTotalChart.resize();
......@@ -487,7 +489,7 @@ export default {
this.pushChart.resize();
},
syncDeviceStat() {
this.$post("/device/stat/syncDeviceStat", {})
this.$post("/device/stat/syncDeviceStat", {siteId:1})
.then((res) => {
console.log(res.data);
if (res.code == 1) {
......@@ -503,6 +505,8 @@ export default {
findDeviceTotalStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
//当前选择站点id
query.siteId=1
console.log(query);
this.$post("/device/stat/list", query)
.then((res) => {
......@@ -534,6 +538,7 @@ export default {
findDeviceStat(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
......@@ -563,6 +568,7 @@ export default {
findDeviceAlarm(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
......@@ -591,6 +597,7 @@ export default {
findDevicePush(beforeday) {
let query = { createTimeStart: this.formatterDate(beforeday) };
query.siteId=1
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
......@@ -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() {
// 基于准备好的dom,初始化echarts实例
......
......@@ -24,7 +24,11 @@ export default {
name: "AlarmSmsSend",
components: { drawerShow },
mixins: [table],
created() {},
created() {
this.query= Object.assign({}, this.query, {siteId:1});
},
methods: {
/** 重写新增方法 */
toAdd(row) {
......
......@@ -66,6 +66,8 @@ export default {
this.query["alarmDevice"] = this.queryIn.alarmDevice;
}
this.changePath("/device/alarm/info");
this.query= Object.assign({}, this.query, {siteId:1});
},
methods: {
/** 重写新增方法 */
......
......@@ -15,7 +15,10 @@ export default {
name: "DeviceLog",
components: { dialogShow },
mixins: [table],
created() {},
created() {
this.query= Object.assign({}, this.query, {siteId:1});
},
methods: {
/** 重写新增方法 */
toAdd(row) {
......
......@@ -17,7 +17,7 @@ module.exports = {
hot: true,//自动保存
proxy: {
'/m': {
target: 'http://192.168.0.98:11091',
target: 'http://localhost:18222',
changeOrigin: true,
secure: false,
cookieDomainRewrite: 'plm.testnew.com',
......
This diff is collapsed.
......@@ -46,138 +46,16 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Autowired
private DeviceService deviceService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceStatService deviceStatService;
@Autowired
private ISiteFeign siteFeign;
@Autowired
private DeviceAlarmInfoService deviceAlarmInfoService;
@Autowired
private AlarmSmsSendService alarmSmsSendService;
@Override
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
public void stopTask(ITask task) throws AppException {
......
......@@ -8,108 +8,130 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.alarm.model.vo.AlarmSmsSendVo;
/**
* 短信发送记录实体对象
*
* @author zxfei
* @date 2022-07-01
*/
* 短信发送记录实体对象
*
* @author zxfei
* @date 2022-08-22
*/
public class AlarmSmsSendEntity extends AlarmSmsSendVo {
private static final long serialVersionUID = 1L;
/**
* 电话号码
*/
* 联系电话
*/
@Excel(name = "联系电话")
private String mobile;
/**
* 发送内容
*/
* 接收人员
*/
@Excel(name = "接收人员")
private String receiver;
/**
* 发送内容
*/
@Excel(name = "发送内容")
private String sendMess;
/**
* 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
*/
* 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
*/
@Excel(name = "发送状态", readConverterExp = "0=未发送,1=提交,2=发送成功,3=发生失败")
private Integer sendStatus;
/**
* 发送时间
*/
* 发送时间
*/
private Date sendTime;
/**
* 接收人
*/
private String receiver;
* 站点Id,来源基础服务平台
*/
private Long siteId;
public AlarmSmsSendEntity(){}
/**
* 获取 电话号码
* @return String
*/
* 获取 联系电话
* @return String
*/
public String getMobile(){
return mobile;
}
/**
* 设置 电话号码
* @param mobile
*/
* 设置 联系电话
* @param mobile
*/
public void setMobile(String 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(){
return sendMess;
}
/**
* 设置 发送内容
* @param sendMess
*/
* 设置 发送内容
* @param sendMess
*/
public void setSendMess(String sendMess){
this.sendMess = sendMess;
}
/**
* 获取 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @return Integer
*/
* 获取 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @return Integer
*/
public Integer getSendStatus(){
return sendStatus;
}
/**
* 设置 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @param sendStatus
*/
* 设置 发送状态(0.未发送,1.提交,2.发送成功,3.发生失败)
* @param sendStatus
*/
public void setSendStatus(Integer sendStatus){
this.sendStatus = sendStatus;
}
/**
* 获取 发送时间
* @return Date
*/
* 获取 发送时间
* @return Date
*/
public Date getSendTime(){
return sendTime;
}
/**
* 设置 发送时间
* @param sendTime
*/
* 设置 发送时间
* @param sendTime
*/
public void setSendTime(Date sendTime){
this.sendTime = sendTime;
}
/**
* 获取 接收人
* @return String
*/
public String getReceiver(){
return receiver;
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 接收人
* @param receiver
*/
public void setReceiver(String receiver){
this.receiver = receiver;
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
......@@ -117,7 +139,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
@Override
public int hashCode() {
return this.getId().hashCode();
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
......@@ -125,7 +147,7 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
if (obj instanceof AlarmSmsSendEntity) {
AlarmSmsSendEntity tmp = (AlarmSmsSendEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
return true;
}
}
return false;
......@@ -134,23 +156,26 @@ public class AlarmSmsSendEntity extends AlarmSmsSendVo {
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",mobile:").append(getMobile());
sb.append(",receiver:").append(getReceiver());
sb.append(",sendMess:").append(getSendMess());
sb.append(",sendStatus:").append(getSendStatus());
sb.append(",sendTime:").append(getSendTime());
sb.append(",receiver:").append(getReceiver());
sb.append(",siteId:").append(getSiteId());
return sb.toString();
}
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;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.vo.DeviceAlarmInfoVo;
/**
* 设备告警日志实体对象
*
* @author zxfei
* @date 2022-07-01
*/
* 设备告警日志实体对象
*
* @author zxfei
* @date 2022-08-22
*/
public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
private static final long serialVersionUID = 1L;
/**
* 告警时间
*/
* 告警时间
*/
private Date alarmTime;
/**
* 告警设备
*/
* 告警设备Id
*/
private Long alarmDevice;
/**
* 告警类型,(0.离线)
*/
* 站点Id,来源基础服务平台
*/
private Long siteId;
/**
* 告警类型,(0.离线)
*/
private Integer alarmType;
/**
* 告警级别(0.危险,1.次要,2.一般)
*/
* 告警级别(0.危险,1.次要,2.一般)
*/
private Integer alarmLevel;
/**
* 接收人员[设备管理的责任人]
*/
* 接收人员[设备管理的责任人]
*/
private String alarmReceivePersonnel;
/**
* 接收人员电话
*/
* 接收人员电话
*/
private String receivePersonnelTelephone;
/**
* 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
*/
* 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
*/
private Integer alarmStatus;
/**
* 告警详细内容
*/
* 告警详细内容
*/
private String alarmContent;
public DeviceAlarmInfoEntity(){}
/**
* 获取 告警时间
* @return Date
*/
* 获取 告警时间
* @return Date
*/
public Date getAlarmTime(){
return alarmTime;
}
/**
* 设置 告警时间
* @param alarmTime
*/
* 设置 告警时间
* @param alarmTime
*/
public void setAlarmTime(Date alarmTime){
this.alarmTime = alarmTime;
}
/**
* 获取 告警设备
* @return Long
*/
* 获取 告警设备Id
* @return Long
*/
public Long getAlarmDevice(){
return alarmDevice;
}
/**
* 设置 告警设备
* @param alarmDevice
*/
* 设置 告警设备Id
* @param alarmDevice
*/
public void setAlarmDevice(Long alarmDevice){
this.alarmDevice = alarmDevice;
}
/**
* 获取 告警类型,(0.离线)
* @return Integer
*/
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 告警类型,(0.离线)
* @return Integer
*/
public Integer getAlarmType(){
return alarmType;
}
/**
* 设置 告警类型,(0.离线)
* @param alarmType
*/
* 设置 告警类型,(0.离线)
* @param alarmType
*/
public void setAlarmType(Integer alarmType){
this.alarmType = alarmType;
}
/**
* 获取 告警级别(0.危险,1.次要,2.一般)
* @return Integer
*/
* 获取 告警级别(0.危险,1.次要,2.一般)
* @return Integer
*/
public Integer getAlarmLevel(){
return alarmLevel;
}
/**
* 设置 告警级别(0.危险,1.次要,2.一般)
* @param alarmLevel
*/
* 设置 告警级别(0.危险,1.次要,2.一般)
* @param alarmLevel
*/
public void setAlarmLevel(Integer alarmLevel){
this.alarmLevel = alarmLevel;
}
/**
* 获取 接收人员[设备管理的责任人]
* @return String
*/
* 获取 接收人员[设备管理的责任人]
* @return String
*/
public String getAlarmReceivePersonnel(){
return alarmReceivePersonnel;
}
/**
* 设置 接收人员[设备管理的责任人]
* @param alarmReceivePersonnel
*/
* 设置 接收人员[设备管理的责任人]
* @param alarmReceivePersonnel
*/
public void setAlarmReceivePersonnel(String alarmReceivePersonnel){
this.alarmReceivePersonnel = alarmReceivePersonnel;
}
/**
* 获取 接收人员电话
* @return String
*/
* 获取 接收人员电话
* @return String
*/
public String getReceivePersonnelTelephone(){
return receivePersonnelTelephone;
}
/**
* 设置 接收人员电话
* @param receivePersonnelTelephone
*/
* 设置 接收人员电话
* @param receivePersonnelTelephone
*/
public void setReceivePersonnelTelephone(String receivePersonnelTelephone){
this.receivePersonnelTelephone = receivePersonnelTelephone;
}
/**
* 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @return Integer
*/
* 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @return Integer
*/
public Integer getAlarmStatus(){
return alarmStatus;
}
/**
* 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @param alarmStatus
*/
* 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @param alarmStatus
*/
public void setAlarmStatus(Integer alarmStatus){
this.alarmStatus = alarmStatus;
}
/**
* 获取 告警详细内容
* @return String
*/
* 获取 告警详细内容
* @return String
*/
public String getAlarmContent(){
return alarmContent;
}
/**
* 设置 告警详细内容
* @param alarmContent
*/
* 设置 告警详细内容
* @param alarmContent
*/
public void setAlarmContent(String alarmContent){
this.alarmContent = alarmContent;
}
......@@ -171,7 +189,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
@Override
public int hashCode() {
return this.getId().hashCode();
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
......@@ -179,7 +197,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
if (obj instanceof DeviceAlarmInfoEntity) {
DeviceAlarmInfoEntity tmp = (DeviceAlarmInfoEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
return true;
}
}
return false;
......@@ -189,6 +207,7 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
StringBuilder sb = new StringBuilder("");
sb.append(",alarmTime:").append(getAlarmTime());
sb.append(",alarmDevice:").append(getAlarmDevice());
sb.append(",siteId:").append(getSiteId());
sb.append(",alarmType:").append(getAlarmType());
sb.append(",alarmLevel:").append(getAlarmLevel());
sb.append(",alarmReceivePersonnel:").append(getAlarmReceivePersonnel());
......@@ -200,20 +219,22 @@ public class DeviceAlarmInfoEntity extends DeviceAlarmInfoVo {
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 {
*/
private String homeUrl;
/**
* 设备版本
*/
private String deviceVersion;
public DeviceEntity(){}
......@@ -715,6 +720,14 @@ public class DeviceEntity extends DeviceVo {
this.deviceSN = deviceSN;
}
public String getDeviceVersion() {
return deviceVersion;
}
public void setDeviceVersion(String deviceVersion) {
this.deviceVersion = deviceVersion;
}
@Override
public int hashCode() {
return this.getId().hashCode();
......@@ -849,6 +862,8 @@ public class DeviceEntity extends DeviceVo {
this.skinName = "";
this.deviceVersion = "";
this.homeUrl = "";
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ import com.mortals.xhx.module.device.model.vo.DeviceLogVo;
* 设备日志实体对象
*
* @author zxfei
* @date 2022-07-02
* @date 2022-08-22
*/
public class DeviceLogEntity extends DeviceLogVo {
......@@ -20,6 +20,10 @@ public class DeviceLogEntity extends DeviceLogVo {
* traceId,日志追踪id
*/
private String traceID;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/**
* 设备ID
*/
......@@ -62,6 +66,20 @@ public class DeviceLogEntity extends DeviceLogVo {
public void setTraceID(String traceID){
this.traceID = traceID;
}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 设备ID
* @return Long
......@@ -169,6 +187,7 @@ public class DeviceLogEntity extends DeviceLogVo {
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",traceID:").append(getTraceID());
sb.append(",siteId:").append(getSiteId());
sb.append(",deviceId:").append(getDeviceId());
sb.append(",deviceCode:").append(getDeviceCode());
sb.append(",deviceName:").append(getDeviceName());
......@@ -182,6 +201,8 @@ public class DeviceLogEntity extends DeviceLogVo {
this.traceID = "";
this.siteId = null;
this.deviceId = null;
this.deviceCode = "";
......
......@@ -6,7 +6,7 @@ import com.mortals.xhx.module.device.model.DeviceLogEntity;
* 设备日志查询对象
*
* @author zxfei
* @date 2022-07-02
* @date 2022-08-22
*/
public class DeviceLogQuery extends DeviceLogEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -24,6 +24,18 @@ public class DeviceLogQuery extends DeviceLogEntity {
/** traceId,日志追踪id */
private List<String> traceIDList;
/** 开始 站点Id,来源基础服务平台 */
private Long siteIdStart;
/** 结束 站点Id,来源基础服务平台 */
private Long siteIdEnd;
/** 增加 站点Id,来源基础服务平台 */
private Long siteIdIncrement;
/** 站点Id,来源基础服务平台列表 */
private List <Long> siteIdList;
/** 开始 设备ID */
private Long deviceIdStart;
......@@ -183,6 +195,70 @@ public class DeviceLogQuery extends DeviceLogEntity {
public void setTraceIDList(List<String> 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
* @return deviceIdStart
......@@ -627,6 +703,51 @@ public class DeviceLogQuery extends DeviceLogEntity {
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
* @param deviceId
......
......@@ -7,7 +7,7 @@ import com.mortals.xhx.module.device.model.DeviceEntity;
* 设备查询对象
*
* @author zxfei
* @date 2022-08-12
* @date 2022-08-22
*/
public class DeviceQuery extends DeviceEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -28,6 +28,9 @@ public class DeviceQuery extends DeviceEntity {
/** 设备编码,SN码等,默认为MAC地址 */
private List<String> deviceCodeList;
/** 设备SN码 */
private List<String> deviceSNList;
/** 设备的MAC地址 */
private List<String> deviceMacList;
......@@ -259,6 +262,9 @@ public class DeviceQuery extends DeviceEntity {
/** 是否删除(0.否,1.是)列表 */
private List <Integer> deletedList;
/** 设备版本 */
private List<String> deviceVersionList;
/** 开始 设备来源(0.旧设备,1.新设备) */
private Integer sourceStart;
......@@ -307,9 +313,6 @@ public class DeviceQuery extends DeviceEntity {
/** 结束 更新时间 */
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) */
private List<DeviceQuery> orConditionList;
......@@ -412,6 +415,21 @@ public class DeviceQuery extends DeviceEntity {
public void setDeviceCodeList(List<String> 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地址
* @return deviceMacList
......@@ -1625,6 +1643,21 @@ public class DeviceQuery extends DeviceEntity {
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.新设备)
* @return sourceStart
......@@ -1881,21 +1914,6 @@ public class DeviceQuery extends DeviceEntity {
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,主键,自增长
* @param id
......@@ -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地址
* @param deviceMac
......@@ -2928,6 +2965,25 @@ public class DeviceQuery extends DeviceEntity {
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.新设备)
* @param source
......@@ -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)
* @return orConditionList
......
......@@ -11,12 +11,16 @@ import com.mortals.xhx.module.device.model.vo.DeviceStatVo;
* 设备统计实体对象
*
* @author zxfei
* @date 2022-07-05
* @date 2022-08-22
*/
public class DeviceStatEntity extends DeviceStatVo {
private static final long serialVersionUID = 1L;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/**
* 设备总数
*/
......@@ -57,6 +61,14 @@ public class DeviceStatEntity extends DeviceStatVo {
* 停用率
*/
private BigDecimal deviceStopRatio;
/**
* 未激活设备数量
*/
private Integer deviceUnActiveCount;
/**
* 未激活率
*/
private BigDecimal deviceUnActiveRatio;
/**
* 今日告警数量
*/
......@@ -97,6 +109,20 @@ public class DeviceStatEntity extends DeviceStatVo {
public DeviceStatEntity(){}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 设备总数
* @return Integer
......@@ -237,6 +263,34 @@ public class DeviceStatEntity extends DeviceStatVo {
public void setDeviceStopRatio(BigDecimal 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
......@@ -385,6 +439,7 @@ public class DeviceStatEntity extends DeviceStatVo {
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",siteId:").append(getSiteId());
sb.append(",deviceTotalCount:").append(getDeviceTotalCount());
sb.append(",deviceAddCount:").append(getDeviceAddCount());
sb.append(",siteTotalCount:").append(getSiteTotalCount());
......@@ -395,6 +450,8 @@ public class DeviceStatEntity extends DeviceStatVo {
sb.append(",deviceOfflineRatio:").append(getDeviceOfflineRatio());
sb.append(",deviceStopCount:").append(getDeviceStopCount());
sb.append(",deviceStopRatio:").append(getDeviceStopRatio());
sb.append(",deviceUnActiveCount:").append(getDeviceUnActiveCount());
sb.append(",deviceUnActiveRatio:").append(getDeviceUnActiveRatio());
sb.append(",alarmTotalCount:").append(getAlarmTotalCount());
sb.append(",alarmAddCount:").append(getAlarmAddCount());
sb.append(",pushTotalCount:").append(getPushTotalCount());
......@@ -409,6 +466,8 @@ public class DeviceStatEntity extends DeviceStatVo {
public void initAttrValue(){
this.siteId = null;
this.deviceTotalCount = 0;
this.deviceAddCount = 0;
......@@ -429,6 +488,10 @@ public class DeviceStatEntity extends DeviceStatVo {
this.deviceStopRatio = BigDecimal.valueOf(0.00);
this.deviceUnActiveCount = 0;
this.deviceUnActiveRatio = BigDecimal.valueOf(0.00);
this.alarmTotalCount = 0;
this.alarmAddCount = 0;
......
......@@ -58,7 +58,7 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
* 设备统计当天情况
* @param context
*/
void deviceStat(Context context);
void deviceStat(Long siteId,Context context);
List<DeviceMapEntity> deviceMap(DeviceEntity query, Context context);
......
......@@ -337,15 +337,17 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
* @param context
*/
@Override
public void deviceStat(Context context) {
public void deviceStat(Long siteId,Context context) {
//查询当天统计,如果有 则更新统计结果,否则新增
DeviceStatEntity deviceStatEntity = deviceStatService.selectOne(new DeviceStatQuery()
.siteId(siteId)
.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.setSiteId(siteId);
deviceStatEntity.setCreateTime(new Date());
deviceStatEntity.setYear(DateUtil.year(new Date()));
deviceStatEntity.setMonth(DateUtil.month(new Date()) + 1);
......@@ -354,28 +356,40 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//获取昨天统计数据
DeviceStatEntity yesterdayDeviceStat = deviceStatService.selectOne(new DeviceStatQuery()
.siteId(siteId)
.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();
yesterdayDeviceStat.setSiteId(siteId);
yesterdayDeviceStat.setYear(DateUtil.year(DateUtil.yesterday()));
}
try {
//获取设备总数
List<DeviceEntity> deviceList = this.find(new DeviceQuery());
List<DeviceEntity> deviceList = this.find(new DeviceQuery().siteId(siteId));
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.setDeviceAddCount(deviceTotalCount - yesterdayDeviceStat.getDeviceTotalCount());
//站点数量
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
///统计按当前站点归集 // TODO: 2022/8/22
Rest<List<SitePdu>> resp = siteFeign.getFlatSitesBySiteId(new SitePdu().id(siteId));
// 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();
List<SitePdu> sitePduList = resp.getData();
deviceStatEntity.setSiteTotalCount(sitePduList.size());
deviceStatEntity.setSiteAddCount(sitePduList.size() - yesterdayDeviceStat.getSiteTotalCount());
}
......@@ -387,7 +401,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.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));
//在线率=在线设备/所有激活设备
if(deviceActiveCount>0){
deviceStatEntity.setDeviceOnlineRatio(new BigDecimal(deviceOnlineCount).divide(new BigDecimal(deviceActiveCount), ROUND_HALF_DOWN).setScale(2));
}
//离线数量
Long deviceOfflineCount = deviceList.parallelStream()
......@@ -396,15 +413,24 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
.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));
if(deviceActiveCount>0) {
deviceStatEntity.setDeviceOfflineRatio(new BigDecimal(deviceOfflineCount).divide(new BigDecimal(deviceActiveCount), 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));
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();
......@@ -432,6 +458,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
deviceStatEntity.setUploadMessageTotalCount(collect.getOrDefault(true, 0L).intValue());
deviceStatEntity.setDownloadMessageTotalCount(collect.getOrDefault(false, 0L).intValue());
deviceStatEntity.setSiteId(siteId);
if (deviceStatEntity.newEntity()) {
deviceStatEntity.setCreateTime(new Date());
deviceStatService.save(deviceStatEntity);
......
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.xhx.module.device.dao.DeviceStatDao;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.service.DeviceStatService;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
/**
* DeviceStatService
......
......@@ -51,6 +51,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
......@@ -297,4 +298,10 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
}
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;
import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
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.service.DeviceService;
import com.mortals.xhx.module.sitestat.model.SitestatQuery;
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.RestController;
import org.springframework.web.bind.annotation.*;
......@@ -45,6 +48,8 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
@Autowired
private DeviceService deviceService;
public DeviceStatController() {
super.setModuleDesc("设备统计");
}
......@@ -56,17 +61,19 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
/**
* 站点信息
* 同步当前站点
*/
@PostMapping(value = "syncDeviceStat")
public Rest<Object> syncDeviceStat() {
public Rest<Object> syncDeviceStat(@RequestBody DeviceQuery deviceQuery) {
try {
//刷新成功,返回列表
deviceService.deviceStat(getContext());
if(ObjectUtils.isEmpty(deviceQuery)||ObjectUtils.isEmpty(deviceQuery.getSiteId())) throw new AppException("请求站点Id不能为空!");
//刷新成功,返回列
deviceService.deviceStat(deviceQuery.getSiteId(),getContext());
DeviceStatQuery deviceStatQuery = new DeviceStatQuery();
deviceStatQuery.setYear(DateUtil.year(new Date()));
deviceStatQuery.setMonth(DateUtil.month(new Date()) + 1);
deviceStatQuery.setDay(DateUtil.dayOfMonth(new Date()));
deviceStatQuery.setSiteId(deviceQuery.getSiteId());
Rest<Object> resp = this.list(deviceStatQuery);
return resp;
} 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 @@
<resultMap type="DeviceLogEntity" id="DeviceLogEntity-Map">
<id property="id" column="id" />
<result property="traceID" column="traceID" />
<result property="siteId" column="siteId" />
<result property="deviceId" column="deviceId" />
<result property="deviceCode" column="deviceCode" />
<result property="deviceName" column="deviceName" />
......@@ -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')))">
a.traceID,
</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')))">
a.deviceId,
</if>
......@@ -65,18 +69,18 @@
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="DeviceLogEntity" useGeneratedKeys="true" keyProperty="id">
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
(#{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 id="insertBatch" parameterType="paramDto">
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
<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>
</insert>
......@@ -89,6 +93,12 @@
<if test="(colPickMode==0 and data.containsKey('traceID')) or (colPickMode==1 and !data.containsKey('traceID'))">
a.traceID=#{data.traceID},
</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'))">
a.deviceId=#{data.deviceId},
</if>
......@@ -150,6 +160,18 @@
</if>
</foreach>
</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),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
......@@ -377,6 +399,27 @@
#{item}
</foreach>
</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.deviceId != null ">
${_conditionType_} a.deviceId = #{${_conditionParam_}.deviceId}
......@@ -574,6 +617,11 @@
<if test='orderCol.traceID != null and "DESC".equalsIgnoreCase(orderCol.traceID)'>DESC</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')">
a.deviceId
<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