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

修改部分消息结构

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