Commit 3707e4a5 authored by 赵啸非's avatar 赵啸非

修改消息组件

parent b6b3b740
......@@ -75,7 +75,6 @@ INSERT INTO `mortals_xhx_menu` VALUES (9104, '菜单信息', '/menu/list', 91, 4
INSERT INTO `mortals_xhx_menu` VALUES (9105, '参数信息', '/param/list', 91, 50, 1, 0, 0, NULL, NULL, NULL, NULL, 0, 0, 3, NULL, NULL, NULL);
INSERT INTO `mortals_xhx_menu` VALUES (9106, '任务信息', '/task/list', 91, 60, 1, 0, 0, NULL, NULL, NULL, NULL, 0, 0, 3, NULL, NULL, NULL);
INSERT INTO `mortals_xhx_menu` VALUES (9107, '操作日志', '/oper/log/list', 91, 70, 1, 0, 0, NULL, NULL, NULL, NULL, 0, 0, 3, NULL, NULL, NULL);
INSERT INTO `mortals_xhx_menu` VALUES (9133, '站点管理', '/site/list', 91, NULL, 1, 0, 1, NULL, 'view', NULL, NULL, 0, 0, 3, '2021-11-03 21:51:48', 1, '系统管理员');
-- ----------------------------
......
-- ----------------------------
-- 设备生产厂商菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备生产厂商', '/firm/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备生产厂商资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-查看', '/firm/list,/firm/view,/firm/info,/firm/export,/firm/exportExcel,/firm/downloadTemplate,/firm/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备生产厂商-菜单管理-维护', '/firm/add,/firm/edit,/firm/delete,/firm/logicDelete,/firm/save,/firm/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备', '/device/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备-菜单管理-查看', '/device/list,/device/view,/device/info,/device/export,/device/exportExcel,/device/downloadTemplate,/device/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '设备-菜单管理-维护', '/device/add,/device/edit,/device/delete,/device/logicDelete,/device/save,/device/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 平台系统菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '平台系统', '/platform/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 平台系统资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '平台系统-菜单管理-查看', '/platform/list,/platform/view,/platform/info,/platform/export,/platform/exportExcel,/platform/downloadTemplate,/platform/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '平台系统-菜单管理-维护', '/platform/add,/platform/edit,/platform/delete,/platform/logicDelete,/platform/save,/platform/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 产品菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '产品', '/product/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 产品资源路径 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_resource` VALUES (null, '产品-菜单管理-查看', '/product/list,/product/view,/product/info,/product/export,/product/exportExcel,/product/downloadTemplate,/product/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '产品-菜单管理-维护', '/product/add,/product/edit,/product/delete,/product/logicDelete,/product/save,/product/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 设备日志菜单 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_menu` VALUES (null, '设备日志', '/device/log/list', 0, 1, 1, 0, 0,'',NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL);
-- ----------------------------
-- 设备日志资源路径 SQL
-- ----------------------------
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);
This diff is collapsed.
-- ----------------------------
-- 设备生产厂商参数 SQL
-- ----------------------------
-- ----------------------------
-- 设备参数 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_param` VALUES (null, '在线状态 ', 'Device', 'deviceOnlineStatus', '0', '离线', 1, 4, 0, 'deviceOnlineStatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '在线状态 ', 'Device', 'deviceOnlineStatus', '1', '在线', 1, 4, 0, 'deviceOnlineStatus', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '启用状态 ', 'Device', 'status', '0', '停止', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '启用状态 ', 'Device', 'status', '1', '启用', 1, 4, 0, 'status', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '激活状态 ', 'Device', 'active', '0', '未激活', 1, 4, 0, 'active', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '激活状态 ', 'Device', 'active', '1', '已激活', 1, 4, 0, 'active', NULL, NULL, NULL);
-- ----------------------------
-- 平台系统参数 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_param` VALUES (null, '发送第三方平台消息类型', 'Platform', 'sendMsgType', '0', 'http', 1, 4, 0, 'sendMsgType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '发送第三方平台消息类型', 'Platform', 'sendMsgType', '1', 'jms', 1, 4, 0, 'sendMsgType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '是否启用发送消息', 'Platform', 'sendSwitch', '0', '停用', 1, 4, 0, 'sendSwitch', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '是否启用发送消息', 'Platform', 'sendSwitch', '1', '启用', 1, 4, 0, 'sendSwitch', NULL, NULL, NULL);
-- ----------------------------
-- 产品参数 SQL
-- ----------------------------
-- ----------------------------
-- 设备日志参数 SQL
-- ----------------------------
INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'logType', '0', '上报事件', 1, 4, 0, 'logType', NULL, NULL, NULL);
INSERT INTO `mortals_xhx_param` VALUES (null, '日志类型,', 'DeviceLog', 'logType', '1', '下发服务', 1, 4, 0, 'logType', NULL, NULL, NULL);
......@@ -61,7 +61,6 @@
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
......
......@@ -306,6 +306,32 @@ public class UserEntity extends UserEntityExt implements IUser {
public Integer getUserType() {
return this.userType;
}
@Override
public String getToken() {
return null;
}
@Override
public Long getLoginTime() {
return null;
}
@Override
public Long getExpireTime() {
return null;
}
@Override
public void setExpireTime(Long expireTime) {
}
@Override
public String getMenuUrl() {
return null;
}
/**
* 设置 用户类型,0:系统用户 1:普通用户 2:工作人员,默认2
* @param userType
......
......@@ -31,5 +31,15 @@ public class DeviceReq implements Serializable {
private String centernum;
private Boolean isAdmin;
private Boolean isManager;
public static void main(String[] args) {
// DeviceReq deviceReq = new DeviceReq();
// deviceReq.setIsAdmin();
// deviceReq.seti
}
}
......@@ -96,7 +96,7 @@ public class DeviceTokenService {
* @return 令牌
*/
public String createToken(DeviceEntity device) {
String token = IdUtil.fastUUID();
String token = IdUtil.fastSimpleUUID();
device.setToken(token);
refreshToken(device);
Map<String, Object> claims = new HashMap<>();
......
package com.mortals.xhx.busiz.security;
import com.mortals.framework.common.HttpStatus;
import com.mortals.framework.exception.AppException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
......
......@@ -10,6 +10,7 @@ import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.method.HandlerMethod;
import javax.servlet.http.HttpServletRequest;
......@@ -52,13 +53,11 @@ public class DeviceSubmitInterceptor extends BaseInterceptor {
public boolean verifyDevice(HttpServletRequest request) {
DeviceEntity device = deviceTokenService.getLoginDevice(request);
if (StringUtils.isNotNull(device) && StringUtils.isNull(SecurityUtils.getAuthentication())) {
if (!ObjectUtils.isEmpty(device) ) {
deviceTokenService.verifyToken(device);
return true;
}
return false;
}
}
......@@ -79,7 +79,7 @@ public class DeviceApiController {
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceEntity.setIp(req.getIp());
deviceEntity.setPort(req.getPort());
deviceEntity.setSiteNum(req.getSitenum());
//deviceEntity.setSiteNum(req.getSitenum());
deviceEntity.setCenternum(req.getCenternum());
deviceService.update(deviceEntity);
} else {
......@@ -90,7 +90,7 @@ public class DeviceApiController {
deviceEntity.setDeviceMac(req.getDeviceMac());
deviceEntity.setIp(req.getIp());
deviceEntity.setPort(req.getPort());
deviceEntity.setSiteNum(req.getSitenum());
//deviceEntity.set(req.getSitenum());
deviceEntity.setCenternum(req.getCenternum());
deviceEntity.setCreateUserId(1L);
deviceEntity.setCreateTime(new Date());
......
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 发送第三方平台消息类型(0.http,1.jms)枚举类
*
* @author zxfei
*/
public enum SendMsgTypeEnum {
http(0, "http"),
jms(1, "jms");
private Integer value;
private String desc;
SendMsgTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static SendMsgTypeEnum getByValue(Integer value) {
for (SendMsgTypeEnum sendMsgTypeEnum : SendMsgTypeEnum.values()) {
if (sendMsgTypeEnum.getValue() == value) {
return sendMsgTypeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (SendMsgTypeEnum item : SendMsgTypeEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 是否启用发送消息(0.停用,1.启用)枚举类
*
* @author zxfei
*/
public enum SendSwitchEnum {
停用(0, "停用"),
启用(1, "启用");
private Integer value;
private String desc;
SendSwitchEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static SendSwitchEnum getByValue(Integer value) {
for (SendSwitchEnum sendSwitchEnum : SendSwitchEnum.values()) {
if (sendSwitchEnum.getValue() == value) {
return sendSwitchEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (SendSwitchEnum item : SendSwitchEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
......@@ -84,7 +84,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceEntity.setIp(deviceReq.getIp());
deviceEntity.setPort(deviceReq.getPort());
deviceEntity.setSiteNum(deviceReq.getSitenum());
// deviceEntity.setSiteNum(deviceReq.getSitenum());
deviceEntity.setCenternum(deviceReq.getCenternum());
deviceService.update(deviceEntity);
......
......@@ -16,6 +16,7 @@ import com.mortals.xhx.module.device.model.DeviceLogEntity;
import com.mortals.xhx.module.device.model.DeviceLogQuery;
import com.mortals.xhx.module.device.service.DeviceLogService;
import com.mortals.xhx.module.device.service.DeviceService;
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;
......@@ -41,6 +42,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
private DeviceLogService deviceLogService;
@Autowired
private ParamService paramService;
@Autowired
private ProductService productService;
@Override
......@@ -56,7 +59,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
*/
private void doDeviceUpOrDown() {
int timeout = GlobalSysInfo.getParamIntValue(ParamKey.SYS_PARAM_HEADBEAT_TIMEOUT, 60) * 1000;
Map<String, String> deviceTypeMap = paramService.getParamBySecondOrganize("Device", "deviceType");
try {
//获取所有设备,针对每个设备查询最近指定秒的日志,如果没有则更新下线
deviceService.getCacheList().stream()
......@@ -71,7 +73,7 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
device.setOfflineTime(new Date());
device.setDeviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue());
deviceService.update(device);
String msg = String.format("%s设备:%s ,离线!", deviceTypeMap.get(device.getDeviceType().toString()), device.getDeviceCode());
String msg = String.format("%s设备:%s ,离线!", device.getProductName(), device.getDeviceCode());
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(msg));
}
......
......@@ -10,7 +10,7 @@ import com.mortals.xhx.module.device.model.vo.DeviceLogVo;
* 设备日志实体对象
*
* @author zxfei
* @date 2022-03-09
* @date 2022-04-25
*/
public class DeviceLogEntity extends DeviceLogVo {
......@@ -148,7 +148,7 @@ public class DeviceLogEntity extends DeviceLogVo {
this.deviceName = "";
this.logType = 0;
this.logType = null;
this.content = "";
}
......
......@@ -6,7 +6,7 @@ import com.mortals.xhx.module.device.model.DeviceLogEntity;
* 设备日志查询对象
*
* @author zxfei
* @date 2022-03-09
* @date 2022-04-25
*/
public class DeviceLogQuery extends DeviceLogEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -54,12 +54,42 @@ public class DeviceLogQuery extends DeviceLogEntity {
/** 内容 */
private List<String> contentList;
/** 开始 创建用户 */
private Long createUserIdStart;
/** 结束 创建用户 */
private Long createUserIdEnd;
/** 增加 创建用户 */
private Long createUserIdIncrement;
/** 创建用户列表 */
private List <Long> createUserIdList;
/** 开始 创建时间 */
private String createTimeStart;
/** 结束 创建时间 */
private String createTimeEnd;
/** 开始 更新用户 */
private Long updateUserIdStart;
/** 结束 更新用户 */
private Long updateUserIdEnd;
/** 增加 更新用户 */
private Long updateUserIdIncrement;
/** 更新用户列表 */
private List <Long> updateUserIdList;
/** 开始 更新时间 */
private String updateTimeStart;
/** 结束 更新时间 */
private String updateTimeEnd;
/** OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4) */
private List<DeviceLogQuery> orConditionList;
......@@ -305,6 +335,70 @@ public class DeviceLogQuery extends DeviceLogEntity {
public void setContentList(List<String> contentList){
this.contentList = contentList;
}
/**
* 获取 开始 创建用户
* @return createUserIdStart
*/
public Long getCreateUserIdStart(){
return this.createUserIdStart;
}
/**
* 设置 开始 创建用户
* @param createUserIdStart
*/
public void setCreateUserIdStart(Long createUserIdStart){
this.createUserIdStart = createUserIdStart;
}
/**
* 获取 结束 创建用户
* @return $createUserIdEnd
*/
public Long getCreateUserIdEnd(){
return this.createUserIdEnd;
}
/**
* 设置 结束 创建用户
* @param createUserIdEnd
*/
public void setCreateUserIdEnd(Long createUserIdEnd){
this.createUserIdEnd = createUserIdEnd;
}
/**
* 获取 增加 创建用户
* @return createUserIdIncrement
*/
public Long getCreateUserIdIncrement(){
return this.createUserIdIncrement;
}
/**
* 设置 增加 创建用户
* @param createUserIdIncrement
*/
public void setCreateUserIdIncrement(Long createUserIdIncrement){
this.createUserIdIncrement = createUserIdIncrement;
}
/**
* 获取 创建用户
* @return createUserIdList
*/
public List<Long> getCreateUserIdList(){
return this.createUserIdList;
}
/**
* 设置 创建用户
* @param createUserIdList
*/
public void setCreateUserIdList(List<Long> createUserIdList){
this.createUserIdList = createUserIdList;
}
/**
* 获取 开始 创建时间
* @return createTimeStart
......@@ -337,6 +431,102 @@ public class DeviceLogQuery extends DeviceLogEntity {
this.createTimeEnd = createTimeEnd;
}
/**
* 获取 开始 更新用户
* @return updateUserIdStart
*/
public Long getUpdateUserIdStart(){
return this.updateUserIdStart;
}
/**
* 设置 开始 更新用户
* @param updateUserIdStart
*/
public void setUpdateUserIdStart(Long updateUserIdStart){
this.updateUserIdStart = updateUserIdStart;
}
/**
* 获取 结束 更新用户
* @return $updateUserIdEnd
*/
public Long getUpdateUserIdEnd(){
return this.updateUserIdEnd;
}
/**
* 设置 结束 更新用户
* @param updateUserIdEnd
*/
public void setUpdateUserIdEnd(Long updateUserIdEnd){
this.updateUserIdEnd = updateUserIdEnd;
}
/**
* 获取 增加 更新用户
* @return updateUserIdIncrement
*/
public Long getUpdateUserIdIncrement(){
return this.updateUserIdIncrement;
}
/**
* 设置 增加 更新用户
* @param updateUserIdIncrement
*/
public void setUpdateUserIdIncrement(Long updateUserIdIncrement){
this.updateUserIdIncrement = updateUserIdIncrement;
}
/**
* 获取 更新用户
* @return updateUserIdList
*/
public List<Long> getUpdateUserIdList(){
return this.updateUserIdList;
}
/**
* 设置 更新用户
* @param updateUserIdList
*/
public void setUpdateUserIdList(List<Long> updateUserIdList){
this.updateUserIdList = updateUserIdList;
}
/**
* 获取 开始 更新时间
* @return updateTimeStart
*/
public String getUpdateTimeStart(){
return this.updateTimeStart;
}
/**
* 设置 开始 更新时间
* @param updateTimeStart
*/
public void setUpdateTimeStart(String updateTimeStart){
this.updateTimeStart = updateTimeStart;
}
/**
* 获取 结束 更新时间
* @return updateTimeEnd
*/
public String getUpdateTimeEnd(){
return this.updateTimeEnd;
}
/**
* 设置 结束 更新时间
* @param updateTimeEnd
*/
public void setUpdateTimeEnd(String updateTimeEnd){
this.updateTimeEnd = updateTimeEnd;
}
/**
* 设置 主键ID,主键,自增长
* @param id
......@@ -529,6 +719,97 @@ public class DeviceLogQuery extends DeviceLogEntity {
return this;
}
/**
* 设置 创建用户
* @param createUserId
*/
public DeviceLogQuery createUserId(Long createUserId){
setCreateUserId(createUserId);
return this;
}
/**
* 设置 开始 创建用户
* @param createUserIdStart
*/
public DeviceLogQuery createUserIdStart(Long createUserIdStart){
this.createUserIdStart = createUserIdStart;
return this;
}
/**
* 设置 结束 创建用户
* @param createUserIdEnd
*/
public DeviceLogQuery createUserIdEnd(Long createUserIdEnd){
this.createUserIdEnd = createUserIdEnd;
return this;
}
/**
* 设置 增加 创建用户
* @param createUserIdIncrement
*/
public DeviceLogQuery createUserIdIncrement(Long createUserIdIncrement){
this.createUserIdIncrement = createUserIdIncrement;
return this;
}
/**
* 设置 创建用户
* @param createUserIdList
*/
public DeviceLogQuery createUserIdList(List<Long> createUserIdList){
this.createUserIdList = createUserIdList;
return this;
}
/**
* 设置 更新用户
* @param updateUserId
*/
public DeviceLogQuery updateUserId(Long updateUserId){
setUpdateUserId(updateUserId);
return this;
}
/**
* 设置 开始 更新用户
* @param updateUserIdStart
*/
public DeviceLogQuery updateUserIdStart(Long updateUserIdStart){
this.updateUserIdStart = updateUserIdStart;
return this;
}
/**
* 设置 结束 更新用户
* @param updateUserIdEnd
*/
public DeviceLogQuery updateUserIdEnd(Long updateUserIdEnd){
this.updateUserIdEnd = updateUserIdEnd;
return this;
}
/**
* 设置 增加 更新用户
* @param updateUserIdIncrement
*/
public DeviceLogQuery updateUserIdIncrement(Long updateUserIdIncrement){
this.updateUserIdIncrement = updateUserIdIncrement;
return this;
}
/**
* 设置 更新用户
* @param updateUserIdList
*/
public DeviceLogQuery updateUserIdList(List<Long> updateUserIdList){
this.updateUserIdList = updateUserIdList;
return this;
}
/**
* 获取 OR条件集合,列表项之间是OR,项内容之间是AND,如:(list[0].1 and list[0].2) or (list[1].3 and list[1].4)
......
......@@ -9,7 +9,7 @@ import java.util.List;
* 设备日志视图对象
*
* @author zxfei
* @date 2022-03-09
* @date 2022-04-25
*/
@Data
public class DeviceLogVo extends BaseEntityLong {
......
package com.mortals.xhx.module.device.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.device.model.DeviceEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 设备视图对象
*
* @author zxfei
* @date 2022-03-09
*/
* 设备视图对象
*
* @author zxfei
* @date 2022-04-25
*/
@Data
public class DeviceVo extends BaseEntityLong {
/**
* 设备唯一标识
* 唯一标识
*/
private String token;
private String menuUrl;
/**
* 登录时间
*/
......
......@@ -16,6 +16,10 @@ import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.module.firm.model.FirmQuery;
import com.mortals.xhx.module.firm.service.FirmService;
import com.mortals.xhx.module.platform.model.PlatformQuery;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductQuery;
import com.mortals.xhx.module.product.service.ProductService;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import com.mortals.xhx.queue.TopicPartitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -58,6 +62,10 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
private ParamService paramService;
@Autowired
private FirmService firmService;
@Autowired
private ProductService productService;
@Autowired
private PlatformService platformService;
public DeviceController() {
super.setFormClass(DeviceForm.class);
......@@ -83,15 +91,20 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
this.addDict(model, "status", paramService.getParamBySecondOrganize("Device", "status"));
this.addDict(model, "active", paramService.getParamBySecondOrganize("Device", "active"));
this.addDict(model, "deviceFirmId", firmService.find(new FirmQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getFirmName())));
this.addDict(model, "platformId", platformService.find(new PlatformQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getPlatformName())));
this.addDict(model, "productId", productService.find(new ProductQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getProductName())));
Map<Boolean, Long> collect = this.service.find(new DeviceQuery().active(ActiveEnum.已激活.getValue())).stream().collect(Collectors.partitioningBy(item -> (item.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue()), Collectors.counting()));
model.put("onlineCount", collect.get(true));
model.put("offlineCount", collect.get(false));
//离线设备 按类型分组
if (collect.get(false) > 0) {
Map<String, Long> collectTwo = this.service.find(new DeviceQuery().deviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue()).active(ActiveEnum.已激活.getValue())).stream().collect(Collectors.groupingBy(x -> deviceTypeMap.get(x.getDeviceType().toString()), Collectors.counting()));
model.put("offlineDeviceType", collectTwo);
}
// if (collect.get(false) > 0) {
// Map<String, Long> collectTwo = this.service.find(new DeviceQuery().deviceOnlineStatus(DeviceOnlineStatusEnum.离线.getValue()).active(ActiveEnum.已激活.getValue())).stream().collect(Collectors.groupingBy(x -> deviceTypeMap.get(x.getDeviceType().toString()), Collectors.counting()));
// model.put("offlineDeviceType", collectTwo);
// }
super.init(request, response, form, model, context);
}
......
package com.mortals.xhx.module.platform.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import java.util.List;
/**
* 平台系统Dao
* 平台系统 DAO接口
*
* @author zxfei
* @date 2022-04-25
*/
public interface PlatformDao extends ICRUDDao<PlatformEntity,Long>{
}
package com.mortals.xhx.module.platform.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.platform.dao.PlatformDao;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 平台系统DaoImpl DAO接口
*
* @author zxfei
* @date 2022-04-25
*/
@Repository("platformDao")
public class PlatformDaoImpl extends BaseCRUDDaoMybatis<PlatformEntity,Long> implements PlatformDao {
}
package com.mortals.xhx.module.platform.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.platform.model.vo.PlatformVo;
/**
* 平台系统实体对象
*
* @author zxfei
* @date 2022-04-25
*/
public class PlatformEntity extends PlatformVo {
private static final long serialVersionUID = 1L;
/**
* 平台名称,名称唯一
*/
@Excel(name = "平台名称,名称唯一")
private String platformName;
/**
* 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
*/
private String platformSn;
/**
* 发送第三方平台消息类型(0.http,1.jms)
*/
private Integer sendMsgType;
/**
* 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
*/
private String sendConfig;
/**
* 是否启用发送消息(0.停用,1.启用)
*/
private Integer sendSwitch;
/**
* 备注
*/
private String platformRemark;
public PlatformEntity(){}
/**
* 获取 平台名称,名称唯一
* @return String
*/
public String getPlatformName(){
return platformName;
}
/**
* 设置 平台名称,名称唯一
* @param platformName
*/
public void setPlatformName(String platformName){
this.platformName = platformName;
}
/**
* 获取 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @return String
*/
public String getPlatformSn(){
return platformSn;
}
/**
* 设置 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @param platformSn
*/
public void setPlatformSn(String platformSn){
this.platformSn = platformSn;
}
/**
* 获取 发送第三方平台消息类型(0.http,1.jms)
* @return Integer
*/
public Integer getSendMsgType(){
return sendMsgType;
}
/**
* 设置 发送第三方平台消息类型(0.http,1.jms)
* @param sendMsgType
*/
public void setSendMsgType(Integer sendMsgType){
this.sendMsgType = sendMsgType;
}
/**
* 获取 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
* @return String
*/
public String getSendConfig(){
return sendConfig;
}
/**
* 设置 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
* @param sendConfig
*/
public void setSendConfig(String sendConfig){
this.sendConfig = sendConfig;
}
/**
* 获取 是否启用发送消息(0.停用,1.启用)
* @return Integer
*/
public Integer getSendSwitch(){
return sendSwitch;
}
/**
* 设置 是否启用发送消息(0.停用,1.启用)
* @param sendSwitch
*/
public void setSendSwitch(Integer sendSwitch){
this.sendSwitch = sendSwitch;
}
/**
* 获取 备注
* @return String
*/
public String getPlatformRemark(){
return platformRemark;
}
/**
* 设置 备注
* @param platformRemark
*/
public void setPlatformRemark(String platformRemark){
this.platformRemark = platformRemark;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof PlatformEntity) {
PlatformEntity tmp = (PlatformEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",platformName:").append(getPlatformName());
sb.append(",platformSn:").append(getPlatformSn());
sb.append(",sendMsgType:").append(getSendMsgType());
sb.append(",sendConfig:").append(getSendConfig());
sb.append(",sendSwitch:").append(getSendSwitch());
sb.append(",platformRemark:").append(getPlatformRemark());
return sb.toString();
}
public void initAttrValue(){
this.platformName = "";
this.platformSn = "";
this.sendMsgType = 0;
this.sendConfig = "";
this.sendSwitch = 0;
this.platformRemark = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.platform.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 平台系统视图对象
*
* @author zxfei
* @date 2022-04-25
*/
@Data
public class PlatformVo extends BaseEntityLong {
}
\ No newline at end of file
package com.mortals.xhx.module.platform.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
/**
* PlatformService
*
* 平台系统 service接口
*
* @author zxfei
* @date 2022-04-25
*/
public interface PlatformService extends ICRUDService<PlatformEntity,Long>{
}
\ No newline at end of file
package com.mortals.xhx.module.platform.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.platform.dao.PlatformDao;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
/**
* PlatformService
* 平台系统 service实现
*
* @author zxfei
* @date 2022-04-25
*/
@Service("platformService")
public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService {
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ POST {{baseUrl}}/api/active
Content-Type: application/json
{
"deviceNum":"a12345678",
"deviceNum":"b12345678",
"deviceMac":"AB:DD:DF:FD:AD:FA:DA:SS",
"action":"active"
}
......
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