Commit 09e82548 authored by 赵啸非's avatar 赵啸非

短信界面修改

parent e8c9f5de
......@@ -48,3 +48,10 @@ INSERT INTO `mortals_xhx_menu` VALUES (null, '设备日志', '/device/log/list',
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备日志-菜单管理-查看', '/device/log/list,/device/log/view,/device/log/info,/device/log/export,/device/log/exportExcel,/device/log/downloadTemplate,/device/log/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备日志-菜单管理-维护', '/device/log/add,/device/log/edit,/device/log/delete,/device/log/logicDelete,/device/log/save,/device/log/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备统计资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备统计-菜单管理-查看', '/device/stat/list,/device/stat/view,/device/stat/info,/device/stat/export,/device/stat/exportExcel,/device/stat/downloadTemplate,/device/stat/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备统计-菜单管理-维护', '/device/stat/add,/device/stat/edit,/device/stat/delete,/device/stat/logicDelete,/device/stat/save,/device/stat/importData', 3, 0, NULL, NULL, NULL, 0);
......@@ -235,3 +235,34 @@ CREATE TABLE mortals_xhx_sitestat(
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='站点统计';
-- ----------------------------
-- 设备统计表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_device_stat`;
CREATE TABLE mortals_xhx_device_stat(
`id` bigint(20) AUTO_INCREMENT 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 '在线率',
`deviceOfflineCount` int(9) NOT NULL COMMENT '离线设备数量',
`deviceOfflineRatio` double NOT NULL COMMENT '离线率',
`deviceStopCount` int(9) NOT NULL COMMENT '停用设备数量',
`deviceStopRatio` double NOT NULL COMMENT '停用率',
`alarmTotalCount` int(9) NOT NULL COMMENT '今日告警数量',
`alarmAddCount` int(9) NOT NULL COMMENT '昨日新增减少数量',
`pushTotalCount` int(9) NOT NULL COMMENT '今日消息推送数量',
`pushAddCount` int(9) NOT NULL COMMENT '昨日新增减少数量',
`uploadMessageTotalCount` int(9) NOT NULL COMMENT '今日上行消息数量',
`downloadMessageTotalCount` int(9) NOT NULL COMMENT '今日下行消息数量',
`year` int(9) NOT NULL COMMENT '年',
`month` int(9) NOT NULL COMMENT '月',
`day` int(9) NOT NULL COMMENT '日',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备统计';
......@@ -11,6 +11,7 @@
"dependencies": {
"@chenfengyuan/vue-qrcode": "^1.0.2",
"@riophae/vue-treeselect": "0.4.0",
"@vue/babel-preset-app": "^4.5.13",
"@xunlei/vue-context-menu": "^1.0.2",
"axios": "^0.18.0",
"core-js": "3.8.1",
......@@ -21,6 +22,7 @@
"js-cookie": "2.2.1",
"jsencrypt": "3.0.0-rc.1",
"json-bigint": "^0.3.0",
"muse-ui": "^3.0.2",
"nprogress": "0.2.0",
"quill": "1.3.7",
"screenfull": "5.0.2",
......
<template>
<div class="page page-home" style="min-height: 100vh;">
欢迎你,{{userData}}
</div>
<div class="page page-home" style="min-height: 100vh">
<el-row :gutter="10" >
<el-row style="margin-left:50px;margin-right:50px" type="flex" justify="end" :gutter="10" >
<el-button type="text">数据更新:{{ statData.updateTime}}</el-button>
<el-button icon='el-icon-refresh' type="text">手动刷新</el-button>
</el-row>
<el-card style="margin-left:50px;margin-right:50px;margin-top:10px">
<el-col :span="3" >
<span style="font-size:20px"><b>{{ statData.deviceTotalCount}}</b></span>
<el-row><span style="font-size:14px">昨日 {{ statData.deviceAddCount}}</span></el-row>
<el-button icon='el-icon-mobile' type="text">设备总数</el-button>
<!-- <el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">设备总数</span></el-row> -->
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:20px"><b>{{ statData.siteTotalCount}}</b></span></el-row>
<el-row><span style="font-size:14px">昨日 {{ statData.siteAddCount}}</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:13px">监控站点数</span></el-row>
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:20px"><b>{{ statData.deviceOnlineCount}}</b></span></el-row>
<el-row><span style="font-size:14px">昨日 {{ statData.deviceOnlineRatio}}</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">在线设备</span></el-row>
</el-col>
<el-col :span="3">
<el-row><span style="font-size:20px"><b>{{ statData.deviceOfflineCount}}</b></span></el-row>
<el-row><span style="font-size:14px">在线率 {{ statData.deviceOfflineRatio*100}}%</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">离线设备</span></el-row>
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:20px"><b>{{ statData.deviceStopRatio}}</b></span></el-row>
<el-row><span style="font-size:14px">停用率 {{ statData.deviceStopRatio}}</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">停用设备</span></el-row>
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:20px"><b>{{ statData.alarmTotalCount}}</b></span></el-row>
<el-row><span style="font-size:14px">昨日 {{ statData.alarmAddCount}}</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">今日告警次数</span></el-row>
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:20px"><b>{{ statData.pushTotalCount}}</b></span></el-row>
<el-row><span style="font-size:14px">昨日 {{ statData.pushAddCount}}</span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">今日消息推送</span></el-row>
</el-col>
<el-col :span="3" >
<el-row><span style="font-size:14px">今日下发命令 <b>{{ statData.uploadMessageTotalCount}}</b></span></el-row>
<el-row><span style="font-size:14px">今日下发命令 <b>{{ statData.downloadMessageTotalCount}}</b></span></el-row>
<el-row > <i size="mini" :class="'el-icon-mobile'"> </i><span style="font-size:14px">数据获取</span></el-row>
</el-col>
</el-card>
</el-row>
</div>
</template>
<script>
export default {
computed: {
userData() {
return this.$store.state.userData.currUserName;
},
computed: {
userData() {
return this.$store.state.userData.currUserName;
},
},
created() {
let query={year:2022,month:7,day:5}
//查询今日设备统计
this.loading=true;
this.$post("/device/stat/list", query)
.then((res) => {
if (res.code == 1) {
console.log("res",res)
this.statData=res.data.data[0]
console.log("statData",this.statData)
}
this.loading=false;
})
.catch((error) => {
this.$message.error(error.message);
});
},
data() {
return {
loading: false,
indexStatInfo: {},
recordListLoading: false,
statData: {},
dayProjectList: [],
pendList: [],
weekPerDay: {
xData: [],
yData: [],
},
dict: {},
value: new Date(),
};
},
};
</script>
\ No newline at end of file
</script>
This diff is collapsed.
......@@ -8,6 +8,10 @@ import java.io.Serializable;
@Data
public class ServerInfo implements Serializable {
private String ip;
private Integer port;
/**
* 设备注册API
*/
......
package com.mortals.xhx.daemon.netty.server.controlserver.handler;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.GlobalSysInfo;
......@@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import java.net.InetSocketAddress;
import java.net.URL;
import static com.mortals.xhx.common.key.Constant.*;
......@@ -72,12 +74,16 @@ public class NettyUDPServerHandler extends SimpleChannelInboundHandler<DatagramP
resp.setMsg("获取服务端地址成功!");
if (!ObjectUtils.isEmpty(action) && "findserver".equals(action)) {
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
String deviceRegisterApi = domain + servletPath + registerApiPath;
String deviceInitApi = domain + servletPath + deviceInitApiPath;
String deviceUpdateApi = domain + servletPath + deviceUpdateApiPath;
String domain = GlobalSysInfo.getParamValue(PARAM_SERVER_HTTP_URL, "http://192.168.0.98:11091");
URL url = URLUtil.url(domain);
String deviceRegisterApi = servletPath + registerApiPath;
String deviceInitApi = servletPath + deviceInitApiPath;
String deviceUpdateApi = servletPath + deviceUpdateApiPath;
ServerInfo serverInfo = new ServerInfo();
serverInfo.setIp(url.getHost());
serverInfo.setPort(url.getPort());
serverInfo.setDeviceRegisterApi(deviceRegisterApi);
serverInfo.setDeviceInitApi(deviceInitApi);
serverInfo.setDeviceUpdateApi(deviceUpdateApi);
......
package com.mortals.xhx.daemon.task;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.base.framework.ws.message.SendToAllRequest;
import com.mortals.xhx.base.framework.ws.util.WebSocketUtil;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum;
import com.mortals.xhx.common.code.DeviceMethodEnum;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.key.ParamKey;
import com.mortals.xhx.module.device.model.*;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceModuleService;
import com.mortals.xhx.module.device.service.DeviceModuleUseService;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 设备模块使用统计任务
*
* @author: zxfei
* @date: 2022/3/9 15:19
*/
@CommonsLog
@Service("DeviceModuleUseTask")
public class DeviceModuleUseTaskImpl implements ITaskExcuteService {
@Autowired
private DeviceService deviceService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceModuleUseService deviceModuleUseService;
@Autowired
private ProductService productService;
@Autowired
private PlatformService platformService;
@Autowired
private DeviceModuleService moduleService;
@Override
public void excuteTask(ITask task) throws AppException {
log.debug("设备统计,开始执行");
doDeviceModuleUse();
//doDeviceUpOrDown();
//doDeviceLogDel();
log.debug("设备统计,结束执行");
}
/**
* 统计设备模块使用率
*/
private void doDeviceModuleUse() {
Map<String, DeviceModuleEntity> moduleMap = moduleService.find(new DeviceModuleQuery()).stream().collect(Collectors.toMap(x -> x.getModuleMsgCode(), y -> y, (o, n) -> n));
try {
// TODO: 2022/7/2 根据每个设备单独查询统计 计算数据量会减少
List<DeviceModuleUseEntity> moduleUseEntityList = deviceService.getCacheList().stream().flatMap(device -> {
//查询当前设备日志
List<DeviceLogEntity> deviceLogList = deviceLogService.find(new DeviceLogQuery().deviceId(device.getId()));
//分组统计每个模块头使用率
Map<String, Long> modelCollect = deviceLogList.parallelStream().collect(Collectors.groupingBy(DeviceLogEntity::getMessageHead, Collectors.counting()));
return modelCollect.entrySet().stream().map(item -> {
if (moduleMap.containsKey(item.getKey())) {
DeviceModuleUseEntity deviceModuleUseEntity = new DeviceModuleUseEntity();
deviceModuleUseEntity.initAttrValue();
DeviceModuleEntity deviceModuleEntity = moduleMap.get(item.getKey());
deviceModuleUseEntity.setDeviceId(device.getId());
deviceModuleUseEntity.setModuleMsgCode(deviceModuleEntity.getModuleMsgCode());
deviceModuleUseEntity.setModuleName(deviceModuleEntity.getModuleName());
deviceModuleUseEntity.setUseNum(item.getValue());
deviceModuleUseEntity.setCreateUserId(1L);
deviceModuleUseEntity.setCreateTime(new Date());
return deviceModuleUseEntity;
}
return null;
}).filter(f -> f != null);
}).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(moduleUseEntityList)) {
//遍历,更新统计数据表 标识 设备id与消息头
Map<String, DeviceModuleUseEntity> collect = deviceModuleUseService.find(new DeviceModuleUseQuery()).stream().collect(Collectors.toMap(x -> x.getDeviceId() + "#" + x.getModuleMsgCode(), y -> y, (o, n) -> n));
moduleUseEntityList.stream().forEach(mudule -> {
String key = mudule.getDeviceId() + "#" + mudule.getModuleMsgCode();
if (collect.containsKey(key)) {
//更新
DeviceModuleUseEntity deviceModuleUseEntity = collect.get(key);
mudule.setId(deviceModuleUseEntity.getId());
mudule.setUpdateTime(new Date());
mudule.setUpdateUserId(1L);
deviceModuleUseService.update(mudule, null);
} else {
//新增
deviceModuleUseService.save(mudule, null);
}
});
}
} catch (Exception e) {
log.error("更新任务异常,结束执行", e);
}
}
/**
* 统计更新设备状态
*/
private void doDeviceUpOrDown() {
int timeout = GlobalSysInfo.getParamIntValue(ParamKey.SYS_PARAM_HEADBEAT_TIMEOUT, 60) * 1000;
try {
//获取所有设备,针对每个设备查询最近指定秒的日志,如果没有则更新下线
deviceService.getCacheList().stream()
.filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue())
.peek(device -> {
DeviceLogQuery query = new DeviceLogQuery();
query.setCreateTimeStart(DateUtils.getStrDateTime(new Date(System.currentTimeMillis() - timeout)));
DeviceLogEntity deviceLogEntity = deviceLogService.selectOne(query);
if (ObjectUtils.isEmpty(deviceLogEntity)) {
//更新设备下线
device.setOfflineTime(new Date());
device.setDeviceStatus(DeviceStatusEnum.离线.getValue());
deviceService.update(device);
String msg = String.format("%s设备:%s ,离线!", device.getProductName(), device.getDeviceCode());
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(msg));
PlatformEntity platformEntity = platformService.get(device.getPlatformId());
ProductEntity productEntity = productService.get(device.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
deviceService.sendThirdParty(device, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
}
}
}).count();
} catch (Exception e) {
log.error("更新设备状态任务异常,结束执行", e);
}
log.debug("更新设备状态任务,结束执行");
}
/**
* 定时清除设备日志
*/
private void doDeviceLogDel() {
//默认保存30天日志
int timeout = -GlobalSysInfo.getParamIntValue(ParamKey.SYS_PARAM_LOG_TIME, 30);
try {
DeviceLogQuery query = new DeviceLogQuery();
query.setCreateTimeEnd(DateUtils.getStrDateTime(DateUtils.addCurrDate(timeout)));
Long[] ids = deviceLogService.find(query).stream().map(DeviceLogEntity::getId).toArray(Long[]::new);
if (!ObjectUtils.isEmpty(ids)) {
deviceLogService.remove(ids, null);
}
} catch (Exception e) {
log.error("设备日志删除任务异常,结束执行", e);
}
log.debug("设备日志删除任务,结束执行");
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.common.code.SendStatusEnum;
import com.mortals.xhx.common.utils.SendSmsTask;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendEntity;
import com.mortals.xhx.module.alarm.model.AlarmSmsSendQuery;
import com.mortals.xhx.module.alarm.service.AlarmSmsSendService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.security.DenyAll;
import java.util.List;
/**
* 短信发送任务
*
* @author: zxfei
* @date: 2022/3/9 15:19
*/
@CommonsLog
@Service("SmsSendTask")
public class SmsSendTaskImpl implements ITaskExcuteService {
@Autowired
private AlarmSmsSendService alarmSmsSendService;
@Autowired
private SendTaskThreadPool sendTaskThreadPool;
@Override
public void excuteTask(ITask task) throws AppException {
List<AlarmSmsSendEntity> sendList = alarmSmsSendService.find(new AlarmSmsSendQuery().sendStatus(SendStatusEnum.未发送.getValue()));
sendList.stream().forEach(sms->{
SendSmsTask sendSmsTask = new SendSmsTask(sms, "xxx");
sendTaskThreadPool.execute(sendSmsTask);
});
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.module.device.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import java.util.List;
/**
* 设备统计Dao
* 设备统计 DAO接口
*
* @author zxfei
* @date 2022-07-05
*/
public interface DeviceStatDao extends ICRUDDao<DeviceStatEntity,Long>{
}
package com.mortals.xhx.module.device.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.device.dao.DeviceStatDao;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 设备统计DaoImpl DAO接口
*
* @author zxfei
* @date 2022-07-05
*/
@Repository("deviceStatDao")
public class DeviceStatDaoImpl extends BaseCRUDDaoMybatis<DeviceStatEntity,Long> implements DeviceStatDao {
}
package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 设备统计视图对象
*
* @author zxfei
* @date 2022-07-05
*/
public class DeviceStatVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.device.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
/**
* DeviceStatService
*
* 设备统计 service接口
*
* @author zxfei
* @date 2022-07-05
*/
public interface DeviceStatService extends ICRUDService<DeviceStatEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.device.service.impl;
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;
/**
* DeviceStatService
* 设备统计 service实现
*
* @author zxfei
* @date 2022-07-05
*/
@Service("deviceStatService")
public class DeviceStatServiceImpl extends AbstractCRUDServiceImpl<DeviceStatDao, DeviceStatEntity, Long> implements DeviceStatService {
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.DeviceStatusEnum;
......@@ -18,6 +19,7 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.firm.model.FirmEntity;
import com.mortals.xhx.module.firm.service.FirmService;
......@@ -190,4 +192,56 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
}
return super.doListAfter(query, model, context);
}
/**
* 首页统计
*/
@PostMapping(value = "indexStat")
public String indexStat() {
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<>();
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "");
try {
//设备基础统计
/*UserEntity userEntity = userService.get(getContext().getUser().getId());
if(userEntity == null){
throw new AppException("暂未登录!");
}
//登录名
model.put("loginName", userEntity.getRealName());
//最后登陆时间
model.put("LastLoginTime", userEntity.getLastLoginTime());
//供应商数量
model.put("supplierCount", supplierService.count(new SupplierQuery(),getContext()));
//工作人员数量
model.put("workmanCount", workmanService.count(new WorkmanQuery(), getContext()));
//房间数量
model.put("roomCount", roomService.count(new RoomQuery(), getContext()));
//设备数量
model.put("deviceCount", deviceService.count(new DeviceQuery(), getContext()));
//专家数量
model.put("specialistCount", specialistService.count(new SpecialistQuery(), getContext()));
//待办
List<ProjectEntity> list = this.service.pendTask(getContext());
model.put("pendList", list);
//统计信息
ProjectStat projectStat = this.service.projectStat(getContext());
model.put("projectStat", projectStat);
//查询当天项目情况
List<ProjectEntity> dayProjectList = this.service.getProjectByDay(null, getContext());
model.put("dayProjectList", dayProjectList);
this.init(request, response, null, model, getContext());*/
jsonObject.put(KEY_RESULT_DATA, model);
recordSysLog(request, "首页统计 【成功】");
} catch (Exception e) {
log.error("异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.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.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.service.DeviceStatService;
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-07-05
*/
@RestController
@RequestMapping("device/stat")
public class DeviceStatController extends BaseCRUDJsonBodyMappingController<DeviceStatService,DeviceStatEntity,Long> {
@Autowired
private ParamService paramService;
public DeviceStatController(){
super.setModuleDesc( "设备统计");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
}
\ No newline at end of file
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###设备统计列表
POST {{baseUrl}}/device/stat/list
Authorization: {{authToken}}
Content-Type: application/json
{
"page":1,
"size":10
}
###设备统计更新与保存
POST {{baseUrl}}/device/stat/save
Authorization: {{authToken}}
Content-Type: application/json
{
"deviceTotalCount":0,
"deviceAddCount":0,
"siteTotalCount":0,
"siteAddCount":0,
"deviceOnlineCount":0,
"deviceOnlineRatio":0.00,
"deviceOfflineCount":0,
"deviceOfflineRatio":0.00,
"deviceStopCount":0,
"deviceStopRatio":0.00,
"alarmTotalCount":0,
"alarmAddCount":0,
"pushTotalCount":0,
"pushAddCount":0,
"uploadMessageTotalCount":0,
"downloadMessageTotalCount":0,
"year":164,
"month":627,
"day":805,
}
> {%
client.global.set("DeviceStat_id", JSON.parse(response.body).data.id);
%}
###设备统计查看
GET {{baseUrl}}/device/stat/info?id={{DeviceStat_id}}
Authorization: {{authToken}}
Accept: application/json
###设备统计编辑
GET {{baseUrl}}/device/stat/edit?id={{DeviceStat_id}}
Authorization: {{authToken}}
Accept: application/json
###设备统计删除
GET {{baseUrl}}/device/stat/delete?id={{DeviceStat_id}}
Authorization: {{authToken}}
Accept: application/json
......@@ -49,6 +49,8 @@ deviceNum|String|设备编码|是|-
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|Object|数据对象|-
&emsp;ip|String|ip|-
&emsp;port|Integer|port|-
&emsp;deviceRegisterApi|String|设备注册API|-
&emsp;deviceInitApi|String|设备初始化信息API|-
&emsp;deviceUpdateApi|String|设备页面修改API|-
......@@ -61,9 +63,12 @@ data|Object|数据对象|-
"msg":"获取服务端地址成功",
"code":1,
"data":{
"deviceRegisterApi":"http://192.168.0.98:11071/m/api/register",
"deviceInitApi":"http://192.168.0.98:11071/m/api/deviceInit",
"deviceUpdateApi":"http://192.168.0.98:11071/m/api/deviceUpdate"
"ip":"192.168.0.98",
"port":11091,
"deviceRegisterApi":"/m/api/register",
"deviceRegisterApi":"/m/api/register",
"deviceInitApi":"/m/api/deviceInit",
"deviceUpdateApi":"/m/api/deviceUpdate"
}
}
```
......
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