Commit 91ac7bfe authored by 赵啸非's avatar 赵啸非

修改部分消息结构

parent 2a76bdb1
...@@ -110,6 +110,11 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb ...@@ -110,6 +110,11 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
try { try {
DefaultTbQueueMsg msg = new DefaultTbQueueMsg(); DefaultTbQueueMsg msg = new DefaultTbQueueMsg();
// DefaultTbQueueMsg msg = gson.fromJson(new String(message.getBody()), DefaultTbQueueMsg.class); // DefaultTbQueueMsg msg = gson.fromJson(new String(message.getBody()), DefaultTbQueueMsg.class);
if(ObjectUtils.isEmpty(message.getBody())){
log.info("message is empty");
return null;
}
Map<String, Object> map = JSON.parseObject(new String(message.getBody()), HashMap.class); Map<String, Object> map = JSON.parseObject(new String(message.getBody()), HashMap.class);
msg.setKey((String)map.get("key")); msg.setKey((String)map.get("key"));
String payloadStr = (String)map.get("data"); String payloadStr = (String)map.get("data");
...@@ -121,10 +126,11 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb ...@@ -121,10 +126,11 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
HashMap<String, String> hashMap = JSON.parseObject(headerStr, HashMap.class); HashMap<String, String> hashMap = JSON.parseObject(headerStr, HashMap.class);
headers.setData(hashMap); headers.setData(hashMap);
msg.setHeaders(headers); msg.setHeaders(headers);
log.debug("msg:" + msg.toString()); log.info("msg:" + msg.toString());
return decoder.decode(msg); return decoder.decode(msg);
} catch (Exception e) { } catch (Exception e) {
log.error("反序列化异常!", e); log.error("反序列化异常!", e);
log.error("message:",JSON.toJSONString(message));
return null; return null;
} }
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
DROP TABLE IF EXISTS `mortals_xhx_device`; DROP TABLE IF EXISTS `mortals_xhx_device`;
CREATE TABLE mortals_xhx_device( CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称', `deviceName` varchar(20) COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码,SN码等,默认为MAC地址', `deviceCode` varchar(256) NOT NULL COMMENT '设备编码,SN码等,默认为MAC地址',
`deviceMac` varchar(64) COMMENT '设备的MAC地址', `deviceMac` varchar(64) COMMENT '设备的MAC地址',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台', `siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`siteCode` varchar(256) COMMENT '站点编号,来源基础服务平台', `siteCode` varchar(256) COMMENT '站点编号,来源基础服务平台',
...@@ -37,7 +37,8 @@ CREATE TABLE mortals_xhx_device( ...@@ -37,7 +37,8 @@ CREATE TABLE mortals_xhx_device(
`deviceRemark` varchar(256) COMMENT '备注', `deviceRemark` varchar(256) COMMENT '备注',
`onlineTime` datetime COMMENT '最近上线时间', `onlineTime` datetime COMMENT '最近上线时间',
`offlineTime` datetime COMMENT '最近离线时间', `offlineTime` datetime COMMENT '最近离线时间',
`deleted` tinyint(2) COMMENT '是否删除,(0.否,1.是)', `deleted` tinyint(2) COMMENT '是否删除(0.否,1.是)',
`source` tinyint(2) COMMENT '收不来源(0.旧设备,1.新设备)',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户', `createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户', `updateUserId` bigint(20) COMMENT '更新用户',
...@@ -45,10 +46,6 @@ CREATE TABLE mortals_xhx_device( ...@@ -45,10 +46,6 @@ CREATE TABLE mortals_xhx_device(
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备';
-- ---------------------------- -- ----------------------------
-- 平台系统表 -- 平台系统表
-- ---------------------------- -- ----------------------------
...@@ -76,9 +73,9 @@ PRIMARY KEY (`id`) ...@@ -76,9 +73,9 @@ PRIMARY KEY (`id`)
DROP TABLE IF EXISTS `mortals_xhx_product`; DROP TABLE IF EXISTS `mortals_xhx_product`;
CREATE TABLE mortals_xhx_product( CREATE TABLE mortals_xhx_product(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长', `id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`platformId` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '关联平台',
`productName` varchar(20) NOT NULL COMMENT '产品名称,名称唯一', `productName` varchar(20) NOT NULL COMMENT '产品名称,名称唯一',
`productCode` varchar(256) NOT NULL COMMENT '产品编码', `productCode` varchar(256) COMMENT '产品编码',
`exchangeName` varchar(256) NOT NULL COMMENT '交换机名称,英文必填',
`productRemark` varchar(256) COMMENT '备注', `productRemark` varchar(256) COMMENT '备注',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户', `createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间', `createTime` datetime NOT NULL COMMENT '创建时间',
...@@ -87,6 +84,8 @@ CREATE TABLE mortals_xhx_product( ...@@ -87,6 +84,8 @@ CREATE TABLE mortals_xhx_product(
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='产品'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='产品';
-- ---------------------------- -- ----------------------------
-- 设备生产厂商表 -- 设备生产厂商表
-- ---------------------------- -- ----------------------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<Field :span="20" label="平台名称" prop="platformName" v-model="form.platformName" placeholder="请输入平台名称,名称唯一"/> <Field :span="20" label="平台名称" prop="platformName" v-model="form.platformName" placeholder="请输入平台名称,名称唯一"/>
<Field :span="20" label="平台编码" prop="platformSn" v-model="form.platformSn" placeholder="请输入平台编码,编码唯一"/> <Field :span="20" label="平台编码" prop="platformSn" v-model="form.platformSn" placeholder="请输入平台编码,编码唯一"/>
<Field :span="20" label="发送地址" prop="sendUrl" v-model="form.sendUrl" placeholder="请输入发送httpurl地址"/> <Field :span="20" label="发送地址" prop="sendUrl" v-model="form.sendUrl" placeholder="请输入发送httpurl地址"/>
<Field :span="20" label="首页地址" prop="homeUrl" v-model="form.homeUrl" placeholder="请输入首页地址"/> <!-- <Field :span="20" label="首页地址" prop="homeUrl" v-model="form.homeUrl" placeholder="请输入首页地址"/> -->
<!-- <Field :span="20" label="发送消息类型" prop="sendMsgType" v-model="form.sendMsgType" type="radio" :enumData="dict.sendMsgType" placeholder="请选择发送第三方平台消息类型"/> --> <!-- <Field :span="20" label="发送消息类型" prop="sendMsgType" v-model="form.sendMsgType" type="radio" :enumData="dict.sendMsgType" placeholder="请选择发送第三方平台消息类型"/> -->
<Field :span="20" label="是否发送消息" prop="sendSwitch" v-model="form.sendSwitch" type="radio" :enumData="dict.sendSwitch" placeholder="请选择是否启用发送消息"/> <Field :span="20" label="是否发送消息" prop="sendSwitch" v-model="form.sendSwitch" type="radio" :enumData="dict.sendSwitch" placeholder="请选择是否启用发送消息"/>
......
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
<LayoutTable :data="tableData" :config="tableConfig"> <LayoutTable :data="tableData" :config="tableConfig">
</LayoutTable> </LayoutTable>
<dialog-show ref="dialogform" @ok="getData" /> <drawer-show ref="drawerform" @ok="getData" />
</div> </div>
</template> </template>
<script> <script>
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import dialogShow from "./dialogshow"; import drawerShow from "./drawershow";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "Platform", name: "Platform",
components: {dialogShow }, components: {drawerShow },
mixins: [table], mixins: [table],
created() { created() {
}, },
...@@ -21,17 +21,17 @@ ...@@ -21,17 +21,17 @@
/** 重写新增方法 */ /** 重写新增方法 */
toAdd(row) { toAdd(row) {
this.$refs.dialogform.add(row); this.$refs.drawerform.add(row);
}, },
/** 重写编辑方法 */ /** 重写编辑方法 */
toEdit(row) { toEdit(row) {
this.$refs.dialogform.edit(row); this.$refs.drawerform.edit(row);
}, },
/** 重写查看方法 */ /** 重写查看方法 */
// toView(row) { toView(row) {
// this.$refs.dialogform.view(row); this.$refs.drawerform.view(row);
// }, },
}, },
data() { data() {
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<el-dialog :title="title" :visible.sync="open" width="90%" append-to-body> <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-row> <el-row>
<Field :span="20" label="产品名称" prop="productName" v-model="form.productName" placeholder="请输入产品名称,名称唯一,如排号机"/> <Field label="产品名称,名称唯一" prop="productName" v-model="form.productName" placeholder="请输入产品名称,名称唯一"/>
<Field :span="20" label="产品编码" prop="productCode" v-model="form.productCode" placeholder="请输入产品编码,编码唯已,如phj"/> <Field label="产品编码" prop="productCode" v-model="form.productCode" type="textarea" placeholder="请输入产品编码"/>
<Field :span="20" label="备注" prop="productRemark" v-model="form.productRemark" type="textarea" placeholder="请输入备注"/> <Field label="备注" prop="productRemark" v-model="form.productRemark" type="textarea" placeholder="请输入备注"/>
</el-row> </el-row>
...@@ -41,14 +41,6 @@ ...@@ -41,14 +41,6 @@
{required: true,message: "请输入产品名称,名称唯一", trigger: "blur" }, {required: true,message: "请输入产品名称,名称唯一", trigger: "blur" },
{max: 20,message: "最多只能录入20个字符",trigger: "blur",}, {max: 20,message: "最多只能录入20个字符",trigger: "blur",},
], ],
productCode: [
{required: true,message: "请输入产品编码,编码唯一", trigger: "blur" },
{max: 256,message: "最多只能录入256个字符",trigger: "blur",},
],
exchangeName: [
{required: true,message: "请输入交换机名称,英文必填,默认产品编码", trigger: "blur" },
{max: 256,message: "最多只能录入256个字符",trigger: "blur",},
],
createTime: [ createTime: [
{required: true,message: "请选择创建时间" }, {required: true,message: "请选择创建时间" },
], ],
...@@ -61,7 +53,7 @@ ...@@ -61,7 +53,7 @@
edit(row) { edit(row) {
this.reset() this.reset()
this.query = { id: row.id }; this.query = { id: row.id };
this.urls.currUrl =this.pageInfo.editUrl;; this.urls.currUrl ="product/edit";
this.getData(); this.getData();
this.pageInfo.type="edit" this.pageInfo.type="edit"
this.title = "修改产品"; this.title = "修改产品";
...@@ -69,8 +61,7 @@ ...@@ -69,8 +61,7 @@
/** 新增 */ /** 新增 */
add(row) { add(row) {
this.reset() this.reset()
this.query = { id: row.id }; this.urls.currUrl = "product/add";
this.urls.currUrl = this.pageInfo.addUrl;
this.getData(); this.getData();
this.pageInfo.type="add" this.pageInfo.type="add"
this.title = "新增产品"; this.title = "新增产品";
...@@ -79,7 +70,7 @@ ...@@ -79,7 +70,7 @@
view(row) { view(row) {
this.reset() this.reset()
this.query = { id: row.id }; this.query = { id: row.id };
this.urls.currUrl =this.pageInfo.viewUrl;; this.urls.currUrl ="product/view";
this.getData(); this.getData();
this.pageInfo.type="view" this.pageInfo.type="view"
this.title = "产品详细"; this.title = "产品详细";
...@@ -101,9 +92,9 @@ ...@@ -101,9 +92,9 @@
// 表单重置 // 表单重置
reset() { reset() {
this.form = { this.form = {
platformId : null,
productName : "", productName : "",
productCode : "", productCode : "",
exchangeName : "",
productRemark : "", productRemark : "",
}; };
this.resetForm("form"); this.resetForm("form");
......
<template> <template>
<div class="page"> <div class="page">
<LayoutTable :data="tableData" notAdd notDel notSearch :config="tableConfig"> <LayoutTable :data="tableData" notDel notSearch :config="tableConfig">
</LayoutTable> </LayoutTable>
<dialog-show ref="dialogform" @ok="getData" />
<drawer-show ref="drawerform" @ok="getData" />
</div> </div>
</template> </template>
<script> <script>
/** 表单弹出框模式需引入 */ /** 表单弹出框模式需引入 */
import dialogShow from "./dialogshow";
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table"; import table from "@/assets/mixins/table";
export default { export default {
name: "Product", name: "ProductList",
components: {dialogShow }, components: {
drawerShow
},
mixins: [table], mixins: [table],
created() { created() {
}, },
methods: { methods: {
/** 重写新增方法 */ /** 重写新增方法 */
toAdd(row) { toAdd(row) {
this.$refs.dialogform.add(row); this.$refs.drawerform.add(row);
}, },
/** 重写编辑方法 */ /** 重写编辑方法 */
toEdit(row) { toEdit(row) {
this.$refs.dialogform.edit(row); this.$refs.drawerform.edit(row);
}, },
/** 重写查看方法 */ /** 重写查看方法 */
// toView(row) { toView(row) {
// this.$refs.dialogform.view(row); this.$refs.drawerform.view(row);
// }, },
}, },
data() { data() {
...@@ -40,11 +42,25 @@ ...@@ -40,11 +42,25 @@
search: [ search: [
], ],
columns: [ columns: [
// {type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
{label: "关联平台", prop: "platformId", formatter: this.formatter},
{label: "产品名称", prop: "productName"}, {label: "产品名称", prop: "productName"},
{label: "产品编码", prop: "productCode"}, {label: "产品编码", prop: "productCode"},
{label: "备注", prop: "productRemark"},
{
label: "操作",
width: 240,
formatter: row => {
return (
<table-buttons noAdd row={row} onEdit={this.toEdit} onView={this.toView} onDel={this.toDel} />
);
}
}
] ]
} }
}; };
......
...@@ -18,14 +18,14 @@ public class DeviceReq implements Serializable { ...@@ -18,14 +18,14 @@ public class DeviceReq implements Serializable {
*/ */
private Integer receiveMethod; private Integer receiveMethod;
/** // /**
* 平台系统id // * 平台系统id
*/ // */
private Long platformId; // private Long platformId;
/** // /**
* 平台系统编码 // * 平台系统编码
*/ // */
private String platformCode; // private String platformCode;
/** /**
* 产品id * 产品id
*/ */
...@@ -121,4 +121,9 @@ public class DeviceReq implements Serializable { ...@@ -121,4 +121,9 @@ public class DeviceReq implements Serializable {
@JsonDeserialize(using = CustomJsonDateDeserializer.class) @JsonDeserialize(using = CustomJsonDateDeserializer.class)
private Date defectsLiabilityPeriod; private Date defectsLiabilityPeriod;
/**
* 设备来源(默认为新设备)
*/
private Integer source;
} }
package com.mortals.xhx.busiz.rsp;
import lombok.Data;
import java.io.Serializable;
/**
* 设备基础信息
* @author: zxfei
* @date: 2022/7/11 10:36
* @description:
**/
@Data
public class DeviceInfo implements Serializable {
/**
* 站点ID
*/
private Long siteId;
/**
* 站点编码
*/
private String siteCode;
/**
* 站点名称
*/
private String siteName;
/**
* 设备产品类型Id
*/
private Long productId;
/**
* 设备产品类型
*/
private String productName;
}
...@@ -17,6 +17,10 @@ public class RegisterResp implements Serializable { ...@@ -17,6 +17,10 @@ public class RegisterResp implements Serializable {
*/ */
private ServerInfo serviceInfo; private ServerInfo serviceInfo;
/**
* 设备基础信息
*/
private DeviceInfo deviceInfo;
} }
package com.mortals.xhx.common.exception.api;
import com.mortals.framework.exception.AppException;
/**
* @author: zxfei
* @date: 2022/7/11 10:16
* @description:
**/
public class DeviceRegisterException extends AppException {
public DeviceRegisterException(int code, String message) {
super(code, message);
}
}
...@@ -28,7 +28,10 @@ public interface ErrorCode { ...@@ -28,7 +28,10 @@ public interface ErrorCode {
public static final int STATUS_TEL_ALREADY_REGI = 12; public static final int STATUS_TEL_ALREADY_REGI = 12;
public static final int STATUS_SAFETY_RISK = 13; public static final int STATUS_SAFETY_RISK = 13;
public static final int STATUS_LOGIN_CODE = 15; public static final int STATUS_LOGIN_CODE = 15;
public static final int BOOK_FAKUAN_CODE = 16;//还有未付款的订单code public static final int BOOK_FAKUAN_CODE = 16;
public static final String ERROR_TOKEN_EXPIRED = "登陆过期,请重新登录"; public static final String ERROR_TOKEN_EXPIRED = "登陆过期,请重新登录";
public static final String ERROR_TRADE_PWD_OVER_THREE_TIME = "支付密码错误,请15分钟后再试"; public static final String ERROR_TRADE_PWD_OVER_THREE_TIME = "支付密码错误,请15分钟后再试";
...@@ -75,4 +78,27 @@ public interface ErrorCode { ...@@ -75,4 +78,27 @@ public interface ErrorCode {
public static final String NOWER="没有权限"; public static final String NOWER="没有权限";
public static final String PAGEDATA="分页参数不能为空"; public static final String PAGEDATA="分页参数不能为空";
public static final String CARADD_MEMBERS="该司机已有绑定车辆,不能绑定多个"; public static final String CARADD_MEMBERS="该司机已有绑定车辆,不能绑定多个";
public static final int DEVICE_CODE_IS_EMPTY = 1001;
public static final String DEVICE_CODE_IS_EMPTY_CONTENT = "当前设备编码不存在!";
public static final int DEVICE_CODE_IS_EXIST = 1002;
public static final String DEVICE_CODE_IS_EXIST_CONTENT = "当前设备编码已存在!";
public static final int PRODUCT_IS_EMPTY = 1003;
public static final String PRODUCT_IS_EMPTY_CONTENT = "所属产品编码不存在!";
public static final int DEVICE_UNACTIVE = 1004;
public static final String DEVICE_UNACTIVE_CONTENT = "当前设备未激活,请在后台配置后再激活!";
public static final int PLATFORM_IS_EMPTY = 1005;
public static final String PLATFORM_IS_EMPTY_CONTENT = "当前设备编码不存在!";
public static final int PLATFORM_UNEXIST = 1006;
public static final String PLATFORM_UNEXIST_CONTENT = "当前设备所属产品平台未配置,请在后台配置后再激活!";
public static final int SITEID_IS_EMPTY = 1007;
public static final String SITEID_IS_EMPTY_CONTENT = "站点ID为空!";
} }
...@@ -71,7 +71,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -71,7 +71,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
Set<TopicPartitionInfo> topicPartitionInfoSet = deviceService.find(new DeviceEntity() Set<TopicPartitionInfo> topicPartitionInfoSet = deviceService.find(new DeviceEntity()
//.active(ActiveEnum.已激活.getValue()) //.active(ActiveEnum.已激活.getValue())
//.status(StatusEnum.启用.getValue()) //.status(StatusEnum.启用.getValue())
) )
.stream() .stream()
.filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId()))) .filter(f -> !ObjectUtils.isEmpty(platformService.get(f.getPlatformId())))
.filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId()))) .filter(f -> !ObjectUtils.isEmpty(productService.get(f.getProductId())))
...@@ -83,7 +83,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -83,7 +83,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
} }
).collect(Collectors.toSet()); ).collect(Collectors.toSet());
mainConsumer.subscribe(topicPartitionInfoSet); mainConsumer.subscribe(topicPartitionInfoSet);
topicPartitionInfoSet.stream().forEach(item->{ topicPartitionInfoSet.stream().forEach(item -> {
log.info("消费线程订阅topic:{}", item.getTopic()); log.info("消费线程订阅topic:{}", item.getTopic());
}); });
this.consumersExecutor = Executors.newCachedThreadPool(IotThreadFactory.forName("消费queue线程")); this.consumersExecutor = Executors.newCachedThreadPool(IotThreadFactory.forName("消费queue线程"));
...@@ -156,9 +156,13 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -156,9 +156,13 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
for (TbQueueMsg queueMsg : messages) { for (TbQueueMsg queueMsg : messages) {
log.info("[WRITE MESSAGE] ->message:{}", JSON.toJSONString(queueMsg)); log.info("[WRITE MESSAGE] ->message:{}", JSON.toJSONString(queueMsg));
//做相应业务,做日志操作 //做相应业务,做日志操作
DeviceReq deviceReq = JSON.parseObject(new String(queueMsg.getData()), DeviceReq.class); // TODO: 2022/7/12 设备来源从设备编码中获取,内容不做处理
String deviceCode = queueMsg.getHeaders().get("deviceCode");
String messageType = queueMsg.getHeaders().get(MESSAGETYPE);
//DeviceReq deviceReq = JSON.parseObject(new String(queueMsg.getData()), DeviceReq.class);
boolean bool = false; boolean bool = false;
DeviceEntity deviceEntity = deviceService.getExtCache(deviceReq.getDeviceCode()); DeviceEntity deviceEntity = deviceService.getExtCache(deviceCode);
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
cacheService.setnx(RedisKey.KEY_DEVICE_ONLINE_CACHE + deviceEntity.getDeviceCode(), "", GlobalSysInfo.getParamIntValue(Constant.HEARTBEAT_TIMEOUT, 180)); cacheService.setnx(RedisKey.KEY_DEVICE_ONLINE_CACHE + deviceEntity.getDeviceCode(), "", GlobalSysInfo.getParamIntValue(Constant.HEARTBEAT_TIMEOUT, 180));
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) { if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.离线.getValue()) {
...@@ -176,14 +180,14 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -176,14 +180,14 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
} }
} }
if (!Constant.MESSAGETYPE_HEARTBEAT.equals(queueMsg.getHeaders().getData().get(MESSAGETYPE))) { if (!Constant.MESSAGETYPE_HEARTBEAT.equals(messageType)) {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
deviceLogEntity.setDeviceId(deviceEntity.getId()); deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName()); deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode()); deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(queueMsg.getHeaders().getData().get(MESSAGETYPE)); deviceLogEntity.setMessageHead(queueMsg.getHeaders().getData().get(MESSAGETYPE));
deviceLogEntity.setContent(JSONObject.toJSONString(deviceReq)); deviceLogEntity.setContent(new String(queueMsg.getData()));
deviceLogEntity.setLogType(LogTypeEnum.上报事件.getValue()); deviceLogEntity.setLogType(LogTypeEnum.上报事件.getValue());
deviceLogEntity.setCreateUserId(1L); deviceLogEntity.setCreateUserId(1L);
deviceLogEntity.setCreateTime(new Date()); deviceLogEntity.setCreateTime(new Date());
......
...@@ -210,7 +210,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D ...@@ -210,7 +210,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity)); BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(update.getValue()); deviceReq.setReceiveMethod(update.getValue());
deviceReq.setProductCode(productEntity.getProductCode()); deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn()); //deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) if (!ObjectUtils.isEmpty(platformEntity.getSendUrl())
//&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue() //&& platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()
&& entity.getSwitchSend()) { && entity.getSwitchSend()) {
......
package com.mortals.xhx.module.platform.service.impl; package com.mortals.xhx.module.platform.service.impl;
import cn.hutool.core.lang.PatternPool;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.platform.dao.PlatformDao; import com.mortals.xhx.module.platform.dao.PlatformDao;
import com.mortals.xhx.module.platform.model.PlatformEntity; import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService; import com.mortals.xhx.module.platform.service.PlatformService;
import org.springframework.util.ObjectUtils;
/** /**
* PlatformService * PlatformService
* 平台系统 service实现 * 平台系统 service实现
...@@ -13,5 +18,16 @@ import com.mortals.xhx.module.platform.service.PlatformService; ...@@ -13,5 +18,16 @@ import com.mortals.xhx.module.platform.service.PlatformService;
*/ */
@Service("platformService") @Service("platformService")
public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService { public class PlatformServiceImpl extends AbstractCRUDServiceImpl<PlatformDao, PlatformEntity, Long> implements PlatformService {
@Override
protected void validData(PlatformEntity entity, Context context) throws AppException {
if(!ObjectUtils.isEmpty(entity.getSendUrl())){
//UrlValidator urlValidator = new UrlValidator();
}
super.validData(entity, context);
}
} }
\ No newline at end of file
...@@ -7,89 +7,89 @@ import com.mortals.framework.annotation.Excel; ...@@ -7,89 +7,89 @@ import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.product.model.vo.ProductVo; import com.mortals.xhx.module.product.model.vo.ProductVo;
/** /**
* 产品实体对象 * 产品实体对象
* *
* @author zxfei * @author zxfei
* @date 2022-07-01 * @date 2022-07-11
*/ */
public class ProductEntity extends ProductVo { public class ProductEntity extends ProductVo {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 产品名称,名称唯一 * 关联平台
*/ */
private Long platformId;
/**
* 产品名称,名称唯一
*/
@Excel(name = "产品名称,名称唯一") @Excel(name = "产品名称,名称唯一")
private String productName; private String productName;
/** /**
* 产品编码 * 产品编码
*/ */
private String productCode; private String productCode;
/** /**
* 交换机名称,英文必填 * 备注
*/ */
private String exchangeName;
/**
* 备注
*/
private String productRemark; private String productRemark;
public ProductEntity(){} public ProductEntity(){}
/** /**
* 获取 产品名称,名称唯一 * 获取 关联平台
* @return String * @return Long
*/ */
public Long getPlatformId(){
return platformId;
}
/**
* 设置 关联平台
* @param platformId
*/
public void setPlatformId(Long platformId){
this.platformId = platformId;
}
/**
* 获取 产品名称,名称唯一
* @return String
*/
public String getProductName(){ public String getProductName(){
return productName; return productName;
} }
/** /**
* 设置 产品名称,名称唯一 * 设置 产品名称,名称唯一
* @param productName * @param productName
*/ */
public void setProductName(String productName){ public void setProductName(String productName){
this.productName = productName; this.productName = productName;
} }
/** /**
* 获取 产品编码 * 获取 产品编码
* @return String * @return String
*/ */
public String getProductCode(){ public String getProductCode(){
return productCode; return productCode;
} }
/** /**
* 设置 产品编码 * 设置 产品编码
* @param productCode * @param productCode
*/ */
public void setProductCode(String productCode){ public void setProductCode(String productCode){
this.productCode = productCode; this.productCode = productCode;
} }
/** /**
* 获取 交换机名称,英文必填 * 获取 备注
* @return String * @return String
*/ */
public String getExchangeName(){
return exchangeName;
}
/**
* 设置 交换机名称,英文必填
* @param exchangeName
*/
public void setExchangeName(String exchangeName){
this.exchangeName = exchangeName;
}
/**
* 获取 备注
* @return String
*/
public String getProductRemark(){ public String getProductRemark(){
return productRemark; return productRemark;
} }
/** /**
* 设置 备注 * 设置 备注
* @param productRemark * @param productRemark
*/ */
public void setProductRemark(String productRemark){ public void setProductRemark(String productRemark){
this.productRemark = productRemark; this.productRemark = productRemark;
} }
...@@ -99,7 +99,7 @@ public class ProductEntity extends ProductVo { ...@@ -99,7 +99,7 @@ public class ProductEntity extends ProductVo {
@Override @Override
public int hashCode() { public int hashCode() {
return this.getId().hashCode(); return this.getId().hashCode();
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
...@@ -107,7 +107,7 @@ public class ProductEntity extends ProductVo { ...@@ -107,7 +107,7 @@ public class ProductEntity extends ProductVo {
if (obj instanceof ProductEntity) { if (obj instanceof ProductEntity) {
ProductEntity tmp = (ProductEntity) obj; ProductEntity tmp = (ProductEntity) obj;
if (this.getId() == tmp.getId()) { if (this.getId() == tmp.getId()) {
return true; return true;
} }
} }
return false; return false;
...@@ -115,21 +115,21 @@ public class ProductEntity extends ProductVo { ...@@ -115,21 +115,21 @@ public class ProductEntity extends ProductVo {
public String toString(){ public String toString(){
StringBuilder sb = new StringBuilder(""); StringBuilder sb = new StringBuilder("");
sb.append(",platformId:").append(getPlatformId());
sb.append(",productName:").append(getProductName()); sb.append(",productName:").append(getProductName());
sb.append(",productCode:").append(getProductCode()); sb.append(",productCode:").append(getProductCode());
sb.append(",exchangeName:").append(getExchangeName());
sb.append(",productRemark:").append(getProductRemark()); sb.append(",productRemark:").append(getProductRemark());
return sb.toString(); return sb.toString();
} }
public void initAttrValue(){ public void initAttrValue(){
this.productName = ""; this.platformId = null;
this.productCode = ""; this.productName = "";
this.exchangeName = ""; this.productCode = "";
this.productRemark = ""; this.productRemark = "";
} }
} }
\ No newline at end of file
package com.mortals.xhx.module.product.service.impl; package com.mortals.xhx.module.product.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.product.model.ProductQuery;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.product.dao.ProductDao; import com.mortals.xhx.module.product.dao.ProductDao;
import com.mortals.xhx.module.product.model.ProductEntity; import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.util.ObjectUtils;
/** /**
* ProductService * ProductService
* 产品 service实现 * 产品 service实现
...@@ -13,5 +18,24 @@ import com.mortals.xhx.module.product.service.ProductService; ...@@ -13,5 +18,24 @@ import com.mortals.xhx.module.product.service.ProductService;
*/ */
@Service("productService") @Service("productService")
public class ProductServiceImpl extends AbstractCRUDServiceImpl<ProductDao, ProductEntity, Long> implements ProductService { public class ProductServiceImpl extends AbstractCRUDServiceImpl<ProductDao, ProductEntity, Long> implements ProductService {
@Override
protected void saveBefore(ProductEntity entity, Context context) throws AppException {
//新增产品编码不能重复
ProductEntity productEntity = this.selectOne(new ProductQuery().productCode(entity.getProductCode()));
if(!ObjectUtils.isEmpty(productEntity))throw new AppException("当前产品编码已存在!");
super.saveBefore(entity, context);
}
@Override
protected void updateBefore(ProductEntity entity, Context context) throws AppException {
ProductEntity productEntity = this.get(entity.getId());
if(!productEntity.getProductCode().equals(entity.getProductCode())){
ProductEntity productEntity1 = this.selectOne(new ProductQuery().productCode(entity.getProductCode()));
if(!ObjectUtils.isEmpty(productEntity1))throw new AppException("当前产品编码已存在!");
}
super.updateBefore(entity, context);
}
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.mortals.xhx.module.product.web; ...@@ -3,6 +3,8 @@ package com.mortals.xhx.module.product.web;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.platform.model.PlatformQuery;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity; import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -10,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* *
* 产品 * 产品
...@@ -23,6 +27,8 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product ...@@ -23,6 +27,8 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
@Autowired @Autowired
private ParamService paramService; private ParamService paramService;
@Autowired
private PlatformService platformService;
public ProductController(){ public ProductController(){
super.setModuleDesc( "产品"); super.setModuleDesc( "产品");
...@@ -30,6 +36,7 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product ...@@ -30,6 +36,7 @@ public class ProductController extends BaseCRUDJsonBodyMappingController<Product
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"platformId",platformService.find(new PlatformQuery()).stream().collect(Collectors.toMap(x->x.getId().toString(),y->y.getPlatformName())));
super.init(model, context); super.init(model, context);
} }
......
...@@ -77,7 +77,9 @@ cookie: ...@@ -77,7 +77,9 @@ cookie:
port: 11010 port: 11010
upload: upload:
path: @profiles.filepath@ path: @profiles.filepath@
feign:
hystrix:
enabled: true
queue: queue:
type: @profiles.queue.type@ # memory or kafka (Apache Kafka) or rabbitmq (RabbitMQ) type: @profiles.queue.type@ # memory or kafka (Apache Kafka) or rabbitmq (RabbitMQ)
core: core:
......
...@@ -136,7 +136,7 @@ Content-Type: application/json ...@@ -136,7 +136,7 @@ Content-Type: application/json
Authorization: {{authToken}} Authorization: {{authToken}}
{ {
"deviceCode": "c12345678", "deviceCode": "a101",
"action": "upload" "action": "upload"
} }
......
...@@ -315,9 +315,8 @@ data|object|数据对象|- ...@@ -315,9 +315,8 @@ data|object|数据对象|-
deviceName|String|否|设备名称 deviceName|String|否|设备名称
deviceCode|String|是|设备编码,默认为MAC地址 deviceCode|String|是|设备编码,默认为MAC地址
siteId|Long|是|站点Id siteId|Long|是|站点Id
siteCode|String|是|站点编号 siteCode|String|否|站点编号
siteName|String|是|站点名称 siteName|String|否|站点名称
platformId|Long|是|平台系统Id
productId|Long|是|产品Id productId|Long|是|产品Id
deviceFirmId|Long|否|设备生产厂商ID deviceFirmId|Long|否|设备生产厂商ID
deviceFirmname|String|否|设备生产厂商名称 deviceFirmname|String|否|设备生产厂商名称
...@@ -328,6 +327,7 @@ deviceInFloor|Integer|否|所属楼层 ...@@ -328,6 +327,7 @@ deviceInFloor|Integer|否|所属楼层
defectsLiabilityPeriod|Date|否|保修期,如2020-08-12 15:00:00 defectsLiabilityPeriod|Date|否|保修期,如2020-08-12 15:00:00
leadingOfficial|String|否|负责人 leadingOfficial|String|否|负责人
leadingOfficialTelephone|String|否|联系电话 leadingOfficialTelephone|String|否|联系电话
source|Integer|否|设备来源,默认1(0.旧设备,1.新设备)
**请求样例:** **请求样例:**
``` ```
...@@ -337,7 +337,6 @@ leadingOfficialTelephone|String|否|联系电话 ...@@ -337,7 +337,6 @@ leadingOfficialTelephone|String|否|联系电话
"siteId":1, "siteId":1,
"siteCode":"510105521000-0001", "siteCode":"510105521000-0001",
"siteName":"测试站点1", "siteName":"测试站点1",
"platformId":1,
"productId":1, "productId":1,
"deviceFirmId":1, "deviceFirmId":1,
"lon":"12", "lon":"12",
...@@ -346,7 +345,8 @@ leadingOfficialTelephone|String|否|联系电话 ...@@ -346,7 +345,8 @@ leadingOfficialTelephone|String|否|联系电话
"deviceInFloor":22, "deviceInFloor":22,
"defectsLiabilityPeriod":"2022-06-30", "defectsLiabilityPeriod":"2022-06-30",
"leadingOfficial":"张三", "leadingOfficial":"张三",
"leadingOfficialTelephone":"13281114856" "leadingOfficialTelephone":"13281114856",,
"source":1
} }
``` ```
...@@ -354,7 +354,7 @@ leadingOfficialTelephone|String|否|联系电话 ...@@ -354,7 +354,7 @@ leadingOfficialTelephone|String|否|联系电话
参数名称 |参数类型|备注|其它 参数名称 |参数类型|备注|其它
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|- code|Integer|结果码|见附录码表
msg|String|消息|- msg|String|消息|-
data|object|数据对象|- data|object|数据对象|-
&emsp;content|String|加密后的内容|AES加密 &emsp;content|String|加密后的内容|AES加密
...@@ -416,7 +416,7 @@ password|String|平台用户密码|是|- ...@@ -416,7 +416,7 @@ password|String|平台用户密码|是|-
参数名称 |参数类型|备注|其它 参数名称 |参数类型|备注|其它
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|- code|Integer|结果码|见附录码表
msg|String|消息|- msg|String|消息|-
data|object|数据对象|- data|object|数据对象|-
...@@ -464,7 +464,7 @@ deviceRemark|String|备注|是|- ...@@ -464,7 +464,7 @@ deviceRemark|String|备注|是|-
参数名称 |参数类型|备注|其它 参数名称 |参数类型|备注|其它
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|- code|Integer|结果码|见附录码表
msg|String|消息|- msg|String|消息|-
data|object|数据对象|- data|object|数据对象|-
...@@ -490,7 +490,7 @@ data|object|数据对象|- ...@@ -490,7 +490,7 @@ data|object|数据对象|-
:------|:---|:---|:---|:--- :------|:---|:---|:---|:---
deviceCode|String|设备编码,如MAC地址|是|- deviceCode|String|设备编码,如MAC地址|是|-
messageType|String|消息类型|是|如heart_beat messageType|String|消息类型|是|如heart_beat
timestamp|Long|产品编码|是|见产品编码附录 timestamp|Long|时间戳|是|-
data|String|数据体,内容自行定义|否|- data|String|数据体,内容自行定义|否|-
...@@ -516,7 +516,7 @@ data|String|数据体,内容自行定义|否|- ...@@ -516,7 +516,7 @@ data|String|数据体,内容自行定义|否|-
参数名称 |参数类型|备注|其它 参数名称 |参数类型|备注|其它
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.接收成功)|- code|Integer|结果码|见附录码表
msg|String|消息|- msg|String|消息|-
**响应消息样例:** **响应消息样例:**
...@@ -545,7 +545,6 @@ data|object|数据对象|是|- ...@@ -545,7 +545,6 @@ data|object|数据对象|是|-
&emsp;deviceStatus|Integer||是|状态,1:新增,2:修改,3:删除,4:激活,5:启用,6:停用,7:上线,8:下线 &emsp;deviceStatus|Integer||是|状态,1:新增,2:修改,3:删除,4:激活,5:启用,6:停用,7:上线,8:下线
&emsp;deviceName|String|设备名称|否|- &emsp;deviceName|String|设备名称|否|-
&emsp;deviceCode|String|设备编码,如MAC地址|是|- &emsp;deviceCode|String|设备编码,如MAC地址|是|-
&emsp;platformCode|String|平台系统编码|是|见附录
&emsp;productCode|String|产品编码|是|见附录 &emsp;productCode|String|产品编码|是|见附录
&emsp;ip|String|设备访问ip|否|- &emsp;ip|String|设备访问ip|否|-
&emsp;port|String|设备端口|否|- &emsp;port|String|设备端口|否|-
...@@ -563,7 +562,7 @@ data|object|数据对象|是|- ...@@ -563,7 +562,7 @@ data|object|数据对象|是|-
参数名称 |参数类型|备注|其它 参数名称 |参数类型|备注|其它
---|---|---|--- ---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|- code|Integer|结果码|见附录码表
msg|String|消息|- msg|String|消息|-
data|object|数据对象|- data|object|数据对象|-
...@@ -657,4 +656,26 @@ key|String|消息唯一标识|是|- ...@@ -657,4 +656,26 @@ key|String|消息唯一标识|是|-
} }
``` ```
## 码表
### 响应结果码表
结果码|结果|其它
---|---|---
1|成功|-
1001|当前设备编码不存在|-
1002|当前设备编码已存在|-
1003|所属产品编码不存在|-
1004|当前设备未激活,请在后台配置后再激活|-
1005|所属平台不存在!请在后台添加后再激活|-
1006|当前设备所属产品平台未配置,请在后台配置后再激活|-
1007|站点ID为空|-
-1|系统内部异常|-
## 附录
### 业务上行下行消息类型
编码|说明|其它
---|---|---
HEART_BEAT|设备心跳消息|设备上行发送
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