Commit bb16397e authored by 赵啸非's avatar 赵啸非

设备列表导出优化

parent be9eca1d
......@@ -18,6 +18,7 @@ import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
/**
* 消费连接池
*
......@@ -42,7 +43,7 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
public TbRabbitMqConsumerTemplate(TbRabbitMqSettings rabbitMqSettings, String topic, TbQueueMsgDecoder<T> decoder) {
super(topic);
this.decoder = decoder;
this.rabbitMqSettings=rabbitMqSettings;
this.rabbitMqSettings = rabbitMqSettings;
try {
connection = rabbitMqSettings.getConnectionFactory().newConnection();
channel = connection.createChannel();
......@@ -64,7 +65,7 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
GetResponse getResponse = channel.basicGet(queue, true);
return getResponse;
} catch (IOException e) {
log.error("Failed to get messages from queue: {},{}" , queue,e);
log.error("Failed to get messages from queue: {},{}", queue, e);
try {
channel = connection.createChannel();
Map<String, Object> args = new HashMap<>();
......@@ -119,7 +120,7 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
@Override
public String getChannelNumber() {
return channel.getChannelNumber()+"";
return channel.getChannelNumber() + "";
}
public T decode(GetResponse message) {
......@@ -127,18 +128,18 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
DefaultTbQueueMsg msg = new DefaultTbQueueMsg();
// DefaultTbQueueMsg msg = gson.fromJson(new String(message.getBody()), DefaultTbQueueMsg.class);
if(ObjectUtils.isEmpty(message.getBody())){
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");
log.info("payloadStr:{}",payloadStr);
byte[] payloadDecodeByte = Base64.getDecoder().decode(payloadStr);
msg.setKey((String) map.get("key"));
String payloadStr = (String) map.get("data");
//log.info("payloadStr:{}", payloadStr);
//byte[] payloadDecodeByte = Base64.getDecoder().decode(payloadStr);
msg.setData(payloadDecodeByte);
msg.setData(payloadStr.getBytes());
TbQueueMsgHeaders headers = new DefaultTbQueueMsgHeaders();
String headerStr = ((JSONObject) map.get("headers")).getString("data");
HashMap<String, String> hashMap = JSON.parseObject(headerStr, HashMap.class);
......@@ -148,7 +149,6 @@ public class TbRabbitMqConsumerTemplate<T extends TbQueueMsg> extends AbstractTb
return decoder.decode(msg);
} catch (Exception e) {
log.error("反序列化异常!", e);
log.error("message:",JSON.toJSONString(message));
return null;
}
......
......@@ -75,7 +75,8 @@ 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) COMMENT '产品编码',
`productCode` varchar(256) NOT NULL COMMENT '产品编码',
`homeUrl` varchar(512) NOT NULL COMMENT '首页地址',
`productRemark` varchar(256) COMMENT '备注',
`createUserId` bigint(20) NOT NULL COMMENT '创建用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
......@@ -86,6 +87,8 @@ PRIMARY KEY (`id`)
-- ----------------------------
-- 设备生产厂商表
-- ----------------------------
......
......@@ -12,6 +12,7 @@
<Field :span="22" label="产品名称" prop="productName" v-model="form.productName" placeholder="请输入产品名称,名称唯一"/>
<Field :span="22" label="产品编码" prop="productCode" v-model="form.productCode" placeholder="请输入产品编码"/>
<Field :span="22" label="首页地址" prop="homeUrl" v-model="form.homeUrl" placeholder="请输入首页地址"/>
<Field :span="22" label="备注" prop="productRemark" v-model="form.productRemark" type="textarea" placeholder="请输入备注"/>
</el-row>
......@@ -52,9 +53,14 @@
{required: true,message: "请输入产品名称,名称唯一", trigger: "blur" },
{max: 20,message: "最多只能录入20个字符",trigger: "blur",},
],
createTime: [
{required: true,message: "请选择创建时间" },
productCode: [
{required: true,message: "请输入产品编码", trigger: "blur" },
{max: 256,message: "最多只能录入256个字符",trigger: "blur",},
],
homeUrl: [
{required: true,message: "请输入首页地址", trigger: "blur" },
{max: 512,message: "最多只能录入512个字符",trigger: "blur",},
]
}
};
},
......
......@@ -146,7 +146,7 @@ public class DeviceApiController {
RegisterResp registerResp = new RegisterResp();
registerResp.setRabbmitInfo(authInfo);
ServerInfo serverInfo = new ServerInfo();
serverInfo.setHomeUrl(platformEntity.getHomeUrl());
serverInfo.setHomeUrl(productEntity.getHomeUrl());
serverInfo.setServerUrl(platformEntity.getSendUrl());
registerResp.setServiceInfo(serverInfo);
DeviceInfo deviceInfo = new DeviceInfo();
......@@ -347,7 +347,7 @@ public class DeviceApiController {
registerResp.setRabbmitInfo(authInfo);
ServerInfo serverInfo = new ServerInfo();
serverInfo.setHomeUrl(platformEntity.getHomeUrl());
serverInfo.setHomeUrl(productEntity.getHomeUrl());
serverInfo.setServerUrl(platformEntity.getSendUrl());
registerResp.setServiceInfo(serverInfo);
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.lang.PatternPool;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
......@@ -13,7 +14,9 @@ import com.mortals.xhx.busiz.req.DeviceReq;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.*;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
......@@ -51,6 +54,8 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
private PlatformService platformService;
@Autowired
private DefaultTbCoreConsumerService consumerService;
@Autowired
private ISiteFeign siteFeign;
@Override
protected String getExtKey(DeviceEntity data) {
......@@ -209,7 +214,6 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//注册rabbmit相关队列与绑定
registerRabbitQueue(entity, platformEntity, productEntity);
//新增设备通知第三方平台
// sendThirdParty(entity, productEntity, platformEntity, DeviceMethodEnum.ADD);
} else {
......@@ -396,6 +400,16 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
entity.setPlatformName(platformEntity.getPlatformName());
}
}
//如果负责人与电话为空,查询站点关联
if(ObjectUtils.isEmpty(entity.getLeadingOfficial())){
Rest<SitePdu> info = siteFeign.info(entity.getSiteId());
if(info.getCode()==YesNoEnum.YES.getValue()){
entity.setLeadingOfficial(info.getData().getLeadingOfficial());
entity.setLeadingOfficialTelephone(info.getData().getLeadingOfficialTelephone());
}
}
super.saveBefore(entity, context);
}
......
......@@ -10,7 +10,7 @@ import com.mortals.xhx.module.product.model.vo.ProductVo;
* 产品实体对象
*
* @author zxfei
* @date 2022-07-11
* @date 2022-07-14
*/
public class ProductEntity extends ProductVo {
......@@ -29,6 +29,10 @@ public class ProductEntity extends ProductVo {
* 产品编码
*/
private String productCode;
/**
* 首页地址
*/
private String homeUrl;
/**
* 备注
*/
......@@ -79,6 +83,20 @@ public class ProductEntity extends ProductVo {
public void setProductCode(String productCode){
this.productCode = productCode;
}
/**
* 获取 首页地址
* @return String
*/
public String getHomeUrl(){
return homeUrl;
}
/**
* 设置 首页地址
* @param homeUrl
*/
public void setHomeUrl(String homeUrl){
this.homeUrl = homeUrl;
}
/**
* 获取 备注
* @return String
......@@ -118,6 +136,7 @@ public class ProductEntity extends ProductVo {
sb.append(",platformId:").append(getPlatformId());
sb.append(",productName:").append(getProductName());
sb.append(",productCode:").append(getProductCode());
sb.append(",homeUrl:").append(getHomeUrl());
sb.append(",productRemark:").append(getProductRemark());
return sb.toString();
}
......@@ -130,6 +149,8 @@ public class ProductEntity extends ProductVo {
this.productCode = "";
this.homeUrl = "";
this.productRemark = "";
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ import com.mortals.xhx.module.product.model.ProductEntity;
* 产品查询对象
*
* @author zxfei
* @date 2022-07-11
* @date 2022-07-14
*/
public class ProductQuery extends ProductEntity {
/** 开始 主键ID,主键,自增长 */
......@@ -39,6 +39,9 @@ public class ProductQuery extends ProductEntity {
/** 产品编码 */
private List<String> productCodeList;
/** 首页地址 */
private List<String> homeUrlList;
/** 备注 */
private List<String> productRemarkList;
......@@ -244,6 +247,21 @@ public class ProductQuery extends ProductEntity {
public void setProductCodeList(List<String> productCodeList){
this.productCodeList = productCodeList;
}
/**
* 获取 首页地址
* @return homeUrlList
*/
public List<String> getHomeUrlList(){
return this.homeUrlList;
}
/**
* 设置 首页地址
* @param homeUrlList
*/
public void setHomeUrlList(List<String> homeUrlList){
this.homeUrlList = homeUrlList;
}
/**
* 获取 备注
* @return productRemarkList
......@@ -580,6 +598,25 @@ public class ProductQuery extends ProductEntity {
}
/**
* 设置 首页地址
* @param homeUrl
*/
public ProductQuery homeUrl(String homeUrl){
setHomeUrl(homeUrl);
return this;
}
/**
* 设置 首页地址
* @param homeUrlList
*/
public ProductQuery homeUrlList(List<String> homeUrlList){
this.homeUrlList = homeUrlList;
return this;
}
/**
* 设置 备注
* @param productRemark
......
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