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

修改设备新增等

parent eb40276b
......@@ -21,6 +21,7 @@ CREATE TABLE mortals_xhx_device(
`id` bigint(20) AUTO_INCREMENT COMMENT '主键ID,主键,自增长',
`deviceName` varchar(20) NOT NULL COMMENT '设备名称',
`deviceCode` varchar(256) COMMENT '设备编码',
`siteId` bigint(20) COMMENT '站点Id,来源基础服务平台',
`siteCode` varchar(256) COMMENT '站点编号,来源基础服务平台',
`siteName` varchar(256) COMMENT '站点名称',
`deviceMac` varchar(64) COMMENT '设备的MAC地址',
......
......@@ -8,7 +8,9 @@
<Field :span="20" label="平台类型" prop="platformId" v-model="form.platformId" type="select" :enumData="dict.platformId" placeholder="请选择平台类型"/>
<Field :span="20" label="产品类型" prop="productId" v-model="form.productId" type="select" :enumData="dict.productId" placeholder="请选择产品类型"/>
<Field :span="20" label="设备的MAC地址" prop="deviceMac" v-model="form.deviceMac" placeholder="请输入设备的MAC地址"/>
<!-- <Field :span="20" label="中心设备编码" v-model="form.centernum" placeholder="请输入中心设备编码"/> -->
<Field :span="20" disabled label="设备访问ip" v-model="form.ip" />
<Field :span="20" disabled label="端口" v-model="form.port" />
<Field :span="20" disabled label="站点编号" v-model="form.siteNum" />
<Field
:span="20"
......@@ -20,7 +22,6 @@
:enumData="dict.deviceFirmId"
/>
<Field :span="20" label="备注" prop="deviceRemark" v-model="form.deviceRemark" type="textarea" placeholder="请输入备注"/>
<Field :span="20" label="启用状态 " prop="status" v-model="form.status" type="radio" :enumData="dict.status" placeholder="请选择启用状态 "/>
......
......@@ -46,9 +46,21 @@ public interface MessageService {
*/
String siteTree();
ApiResp<String> sendThirdParty(String sendUrl,Integer messageType, DeviceReq deviceReq);
/**
* 发送第三方平台crud消息
* @param sendUrl
* @param deviceReq
* @return
*/
ApiResp<String> sendThirdParty(String sendUrl, DeviceReq deviceReq);
/**
* 发送第三方平台四二班透传消息
* @param sendUrl
* @param content
* @return
*/
void sendThirdParty(String sendUrl, String content);
}
\ No newline at end of file
......@@ -9,16 +9,20 @@ import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.HttpUtil;
import com.mortals.framework.util.ThreadPool;
import com.mortals.xhx.base.system.message.MessageService;
import com.mortals.xhx.busiz.req.ApiReq;
import com.mortals.xhx.busiz.req.ApiThirdPartyReq;
import com.mortals.xhx.busiz.req.DeviceReq;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.MessageTypeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders;
import com.mortals.xhx.common.model.MessageHeader;
import com.mortals.xhx.common.utils.SendTask;
import com.mortals.xhx.common.utils.SendTaskThreadPool;
import com.mortals.xhx.module.device.dao.DeviceDao;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
......@@ -59,6 +63,8 @@ public class MessageServiceImpl implements MessageService {
private String password;
@Autowired
private ICacheService cacheService;
@Autowired
private SendTaskThreadPool sendTaskThreadPool;
@Autowired
......@@ -79,7 +85,7 @@ public class MessageServiceImpl implements MessageService {
}
@Override
public void delQueue(String queue , TbQueueCallback callback) {
public void delQueue(String queue, TbQueueCallback callback) {
TbQueueProducer<TbQueueMsg> producer = producerProvider.getTbCoreMsgProducer();
producer.queueDel(queue, callback);
}
......@@ -103,7 +109,7 @@ public class MessageServiceImpl implements MessageService {
if (code == YesNoEnum.YES.getValue()) {
JSONObject dataObj = jsonObject.getJSONObject("data");
String authtoken = dataObj.getString("token");
cacheService.setnx(Constant.BASEPLATFORM_AUTHTOKEN,authtoken,7*24*60);
cacheService.setnx(Constant.BASEPLATFORM_AUTHTOKEN, authtoken, 7 * 24 * 60);
return authtoken;
} else {
throw new AppException("异常");
......@@ -126,7 +132,7 @@ public class MessageServiceImpl implements MessageService {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
header.put("Authorization", Constant.TOKEN_PREFIX + authToken);
resp = HttpUtil.doGet(httpUrl + PATH_SITETREE, header,new HashMap<>());
resp = HttpUtil.doGet(httpUrl + PATH_SITETREE, header, new HashMap<>());
JSONObject jsonObject = JSON.parseObject(resp);
Integer code = jsonObject.getInteger("code");
......@@ -147,20 +153,27 @@ public class MessageServiceImpl implements MessageService {
}
@Override
public ApiResp<String> sendThirdParty(String sendUrl,Integer messageType, DeviceReq deviceReq) {
public ApiResp<String> sendThirdParty(String sendUrl, DeviceReq deviceReq) {
ApiThirdPartyReq<DeviceReq> deviceReqApiReq = new ApiThirdPartyReq<>();
deviceReqApiReq.setCode(YesNoEnum.YES.getValue());
deviceReqApiReq.setType(messageType);
deviceReqApiReq.setType(MessageTypeEnum.CRUD.getValue());
deviceReqApiReq.setData(deviceReq);
String resp = null;
try {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
resp = HttpUtil.doPost(sendUrl, header, JSON.toJSONString(deviceReqApiReq));
return JSON.parseObject(resp,ApiResp.class);
return JSON.parseObject(resp, ApiResp.class);
} catch (Exception e) {
log.error("异常:", e);
}
return null;
}
@Override
public void sendThirdParty(String sendUrl, String content) {
SendTask sendTask = new SendTask(sendUrl, content);
sendTaskThreadPool.execute(sendTask);
}
}
\ No newline at end of file
......@@ -30,6 +30,10 @@ public class DeviceReq implements Serializable {
* 设备编码(暂定mac地址)
*/
private String deviceCode;
/**
* 所属站点Id
*/
private Long siteId;
/**
* 所属站点编码
*/
......@@ -46,6 +50,18 @@ public class DeviceReq implements Serializable {
* 设备
*/
private String homeUrl;
/**
* 设备访问ip
*/
private String ip;
/**
* 中心设备编码
*/
private String centernum;
/**
* 端口
*/
private String port;
}
......@@ -310,12 +310,16 @@ public class DeviceApiController {
deviceEntity.setDeviceName(req.getDeviceName());
deviceEntity.setDeviceCode(req.getDeviceCode());
deviceEntity.setDeviceMac(req.getDeviceCode());
deviceEntity.setSiteId(req.getSiteId());
deviceEntity.setSiteCode(req.getSiteCode());
deviceEntity.setSiteName(req.getSiteName());
deviceEntity.setPlatformId(platformEntity.getId());
deviceEntity.setPlatformName(platformEntity.getPlatformName());
deviceEntity.setProductId(productEntity.getId());
deviceEntity.setProductName(productEntity.getProductName());
deviceEntity.setIp(req.getIp());
deviceEntity.setCenternum(req.getCenternum());
deviceEntity.setPort(req.getPort());
deviceEntity.setDeviceRemark(req.getDeviceRemark());
deviceEntity.setCreateUserId(1L);
deviceEntity.setCreateTime(new Date());
......@@ -351,12 +355,16 @@ public class DeviceApiController {
deviceEntity.setDeviceName(req.getDeviceName());
deviceEntity.setDeviceCode(req.getDeviceCode());
deviceEntity.setDeviceMac(req.getDeviceCode());
deviceEntity.setSiteId(req.getSiteId());
deviceEntity.setSiteCode(req.getSiteCode());
deviceEntity.setSiteName(req.getSiteName());
deviceEntity.setPlatformId(platformEntity.getId());
deviceEntity.setPlatformName(platformEntity.getPlatformName());
deviceEntity.setProductId(productEntity.getId());
deviceEntity.setProductName(productEntity.getProductName());
deviceEntity.setIp(req.getIp());
deviceEntity.setCenternum(req.getCenternum());
deviceEntity.setPort(req.getPort());
deviceEntity.setDeviceRemark(req.getDeviceRemark());
deviceEntity.setUpdateUserId(1L);
deviceEntity.setUpdateTime(new Date());
......
......@@ -14,7 +14,10 @@ public enum DeviceStatusEnum {
DEL(3, "删除"),
ACTIVE(4, "激活"),
ENABLED(5, "启用"),
STOP(6, "停用");
STOP(6, "停用"),
ONLINE(7, "上线"),
OFFLINE(8, "下线")
;
private Integer value;
private String desc;
......
......@@ -27,8 +27,8 @@ import static com.mortals.framework.util.HttpUtil.HEADER_CONTENT_TYPE;
@AllArgsConstructor
public class SendTask implements Runnable {
private String sendUrl;
private String content;
@Override
public void run() {
ApiThirdPartyReq<String> deviceReqApiReq = new ApiThirdPartyReq<>();
......@@ -40,6 +40,7 @@ public class SendTask implements Runnable {
Map<String, String> header = new HashMap<>();
header.put(HEADER_CONTENT_TYPE, "application/json");
resp = HttpUtil.doPost(sendUrl, header, JSON.toJSONString(deviceReqApiReq));
log.debug("resp:{}", resp);
} catch (Exception e) {
log.error("异常:", e);
}
......
......@@ -161,9 +161,20 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
if (deviceEntity.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.离线.getValue()) {
bool = true;
}
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceService.update(deviceEntity);
if(deviceEntity.getDeviceOnlineStatus()==DeviceOnlineStatusEnum.在线.getValue()){
deviceEntity.setOnlineTime(new Date());
deviceEntity.setDeviceOnlineStatus(DeviceOnlineStatusEnum.在线.getValue());
deviceService.update(deviceEntity);
PlatformEntity platformEntity = platformService.get(deviceEntity.getPlatformId());
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceStatusEnum.OFFLINE);
}
}
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue();
......
......@@ -11,11 +11,15 @@ import com.mortals.xhx.base.framework.ws.message.UserJoinNoticeRequest;
import com.mortals.xhx.base.framework.ws.util.WebSocketUtil;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DeviceOnlineStatusEnum;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.common.key.ParamKey;
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.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -44,6 +48,8 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
private ParamService paramService;
@Autowired
private ProductService productService;
@Autowired
private PlatformService platformService;
@Override
......@@ -65,7 +71,6 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
.filter(f -> f.getDeviceOnlineStatus() == DeviceOnlineStatusEnum.在线.getValue())
.peek(device -> {
DeviceLogQuery query = new DeviceLogQuery();
query.setCreateTimeStart(DateUtils.getStrDateTime(new Date(System.currentTimeMillis() - timeout)));
DeviceLogEntity deviceLogEntity = deviceLogService.selectOne(query);
if (ObjectUtils.isEmpty(deviceLogEntity)) {
......@@ -76,6 +81,12 @@ public class DeviceStatTaskImpl implements ITaskExcuteService {
String msg = String.format("%s设备:%s ,离线!", device.getProductName(), device.getDeviceCode());
WebSocketUtil.broadcast(SendToAllRequest.TYPE, new SendToAllRequest().setContent(msg));
PlatformEntity platformEntity = platformService.get(device.getPlatformId());
ProductEntity productEntity = productService.get(device.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
deviceService.sendThirdParty(device, productEntity, platformEntity, DeviceStatusEnum.OFFLINE);
}
}
}).count();
} catch (Exception e) {
......
......@@ -11,7 +11,7 @@ import com.mortals.xhx.module.device.model.vo.DeviceVo;
* 设备实体对象
*
* @author zxfei
* @date 2022-04-25
* @date 2022-05-31
*/
public class DeviceEntity extends DeviceVo {
......@@ -26,6 +26,10 @@ public class DeviceEntity extends DeviceVo {
* 设备编码
*/
private String deviceCode;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/**
* 站点编号,来源基础服务平台
*/
......@@ -78,7 +82,6 @@ public class DeviceEntity extends DeviceVo {
/**
* 在线状态 (0.离线,1.在线)
*/
@Excel(name = "在线状态 ", readConverterExp = "0=离线,1=在线")
private Integer deviceOnlineStatus;
/**
* 启用状态 (0.停止,1.启用)
......@@ -87,7 +90,6 @@ public class DeviceEntity extends DeviceVo {
/**
* 激活状态 (0.未激活,1.已激活)
*/
@Excel(name = "激活状态 ", readConverterExp = "0=未激活,1=已激活")
private Integer active;
/**
* 备注
......@@ -133,6 +135,20 @@ public class DeviceEntity extends DeviceVo {
public void setDeviceCode(String deviceCode){
this.deviceCode = deviceCode;
}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 站点编号,来源基础服务平台
* @return String
......@@ -409,6 +425,7 @@ public class DeviceEntity extends DeviceVo {
StringBuilder sb = new StringBuilder("");
sb.append(",deviceName:").append(getDeviceName());
sb.append(",deviceCode:").append(getDeviceCode());
sb.append(",siteId:").append(getSiteId());
sb.append(",siteCode:").append(getSiteCode());
sb.append(",siteName:").append(getSiteName());
sb.append(",deviceMac:").append(getDeviceMac());
......@@ -436,6 +453,8 @@ public class DeviceEntity extends DeviceVo {
this.deviceCode = "";
this.siteId = null;
this.siteCode = "";
this.siteName = "";
......
......@@ -2,7 +2,10 @@ package com.mortals.xhx.module.device.service;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.common.code.DeviceStatusEnum;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.queue.TbQueueMsgHeaders;
import com.mortals.xhx.queue.TopicPartitionInfo;
......@@ -38,5 +41,8 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/
void deviceEnabled(String deviceCode,Integer status,Context context);
void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceStatusEnum update);
}
\ No newline at end of file
......@@ -109,18 +109,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(deviceEntity, deviceReq, BeanUtil.getNullPropertyNames(deviceEntity));
deviceReq.setReceiveMethod(DeviceStatusEnum.ACTIVE.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) && platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()) {
if (PatternPool.URL_HTTP.matcher(platformEntity.getSendUrl()).find()) {
ApiResp<String> resp = messageService.sendThirdParty(platformEntity.getSendUrl(), MessageTypeEnum.CRUD.getValue(), deviceReq);
} else {
throw new AppException("http send url 不合法!" + platformEntity.getSendUrl());
}
}
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceStatusEnum.ACTIVE);
}
}
......@@ -167,18 +156,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
messageService.queueDeclare(info, callback);
//新增设备通知第三方平台
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(DeviceStatusEnum.ADD.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) && platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()) {
if (PatternPool.URL_HTTP.matcher(platformEntity.getSendUrl()).find()) {
ApiResp<String> resp = messageService.sendThirdParty(platformEntity.getSendUrl(), MessageTypeEnum.CRUD.getValue(), deviceReq);
} else {
throw new AppException("http send url 不合法!" + platformEntity.getSendUrl());
}
}
sendThirdParty(entity, productEntity, platformEntity, DeviceStatusEnum.ADD);
} else {
throw new AppException("产品或平台不存在!");
}
......@@ -192,23 +170,27 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
ProductEntity productEntity = productService.get(entity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(DeviceStatusEnum.UPDATE.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) && platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()) {
if (PatternPool.URL_HTTP.matcher(platformEntity.getSendUrl()).find()) {
ApiResp<String> resp = messageService.sendThirdParty(platformEntity.getSendUrl(), MessageTypeEnum.CRUD.getValue(), deviceReq);
} else {
throw new AppException("http send url 不合法!" + platformEntity.getSendUrl());
}
}
sendThirdParty(entity, productEntity, platformEntity, DeviceStatusEnum.UPDATE);
}
super.updateAfter(entity, context);
}
@Override
public void sendThirdParty(DeviceEntity entity, ProductEntity productEntity, PlatformEntity platformEntity, DeviceStatusEnum update) {
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(entity, deviceReq, BeanUtil.getNullPropertyNames(entity));
deviceReq.setReceiveMethod(update.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) && platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()) {
if (PatternPool.URL_HTTP.matcher(platformEntity.getSendUrl()).find()) {
ApiResp<String> resp = messageService.sendThirdParty(platformEntity.getSendUrl(), deviceReq);
} else {
throw new AppException("http send url 不合法!" + platformEntity.getSendUrl());
}
}
}
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
Arrays.asList(ids).stream().forEach(id -> {
......@@ -233,18 +215,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
ProductEntity productEntity = productService.get(deviceEntity.getProductId());
if (!ObjectUtils.isEmpty(platformEntity) && !ObjectUtils.isEmpty(productEntity)) {
//新增设备通知第三方平台
DeviceReq deviceReq = new DeviceReq();
BeanUtils.copyProperties(deviceEntity, deviceReq, BeanUtil.getNullPropertyNames(deviceEntity));
deviceReq.setReceiveMethod(DeviceStatusEnum.DEL.getValue());
deviceReq.setProductCode(productEntity.getProductCode());
deviceReq.setPlatformCode(platformEntity.getPlatformSn());
if (!ObjectUtils.isEmpty(platformEntity.getSendUrl()) && platformEntity.getSendSwitch() == SendSwitchEnum.启用.getValue()) {
if (PatternPool.URL_HTTP.matcher(platformEntity.getSendUrl()).find()) {
ApiResp<String> resp = messageService.sendThirdParty(platformEntity.getSendUrl(), MessageTypeEnum.CRUD.getValue(), deviceReq);
} else {
throw new AppException("http send url 不合法!" + platformEntity.getSendUrl());
}
}
sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceStatusEnum.DEL);
}
......
......@@ -8,6 +8,7 @@
<id property="id" column="id" />
<result property="deviceName" column="deviceName" />
<result property="deviceCode" column="deviceCode" />
<result property="siteId" column="siteId" />
<result property="siteCode" column="siteCode" />
<result property="siteName" column="siteName" />
<result property="deviceMac" column="deviceMac" />
......@@ -46,6 +47,9 @@
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('deviceCode') or colPickMode == 1 and data.containsKey('deviceCode')))">
a.deviceCode,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteId') or colPickMode == 1 and data.containsKey('siteId')))">
a.siteId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('siteCode') or colPickMode == 1 and data.containsKey('siteCode')))">
a.siteCode,
</if>
......@@ -117,18 +121,18 @@
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="DeviceEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_device
(deviceName,deviceCode,siteCode,siteName,deviceMac,platformId,platformName,productId,productName,deviceFirmId,deviceFirmname,ip,centernum,port,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
(deviceName,deviceCode,siteId,siteCode,siteName,deviceMac,platformId,platformName,productId,productName,deviceFirmId,deviceFirmname,ip,centernum,port,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
VALUES
(#{deviceName},#{deviceCode},#{siteCode},#{siteName},#{deviceMac},#{platformId},#{platformName},#{productId},#{productName},#{deviceFirmId},#{deviceFirmname},#{ip},#{centernum},#{port},#{deviceOnlineStatus},#{status},#{active},#{deviceRemark},#{onlineTime},#{offlineTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
(#{deviceName},#{deviceCode},#{siteId},#{siteCode},#{siteName},#{deviceMac},#{platformId},#{platformName},#{productId},#{productName},#{deviceFirmId},#{deviceFirmname},#{ip},#{centernum},#{port},#{deviceOnlineStatus},#{status},#{active},#{deviceRemark},#{onlineTime},#{offlineTime},#{createUserId},#{createTime},#{updateUserId},#{updateTime})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_device
(deviceName,deviceCode,siteCode,siteName,deviceMac,platformId,platformName,productId,productName,deviceFirmId,deviceFirmname,ip,centernum,port,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
(deviceName,deviceCode,siteId,siteCode,siteName,deviceMac,platformId,platformName,productId,productName,deviceFirmId,deviceFirmname,ip,centernum,port,deviceOnlineStatus,status,active,deviceRemark,onlineTime,offlineTime,createUserId,createTime,updateUserId,updateTime)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.deviceName},#{item.deviceCode},#{item.siteCode},#{item.siteName},#{item.deviceMac},#{item.platformId},#{item.platformName},#{item.productId},#{item.productName},#{item.deviceFirmId},#{item.deviceFirmname},#{item.ip},#{item.centernum},#{item.port},#{item.deviceOnlineStatus},#{item.status},#{item.active},#{item.deviceRemark},#{item.onlineTime},#{item.offlineTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
(#{item.deviceName},#{item.deviceCode},#{item.siteId},#{item.siteCode},#{item.siteName},#{item.deviceMac},#{item.platformId},#{item.platformName},#{item.productId},#{item.productName},#{item.deviceFirmId},#{item.deviceFirmname},#{item.ip},#{item.centernum},#{item.port},#{item.deviceOnlineStatus},#{item.status},#{item.active},#{item.deviceRemark},#{item.onlineTime},#{item.offlineTime},#{item.createUserId},#{item.createTime},#{item.updateUserId},#{item.updateTime})
</foreach>
</insert>
......@@ -144,6 +148,12 @@
<if test="(colPickMode==0 and data.containsKey('deviceCode')) or (colPickMode==1 and !data.containsKey('deviceCode'))">
a.deviceCode=#{data.deviceCode},
</if>
<if test="(colPickMode==0 and data.containsKey('siteId')) or (colPickMode==1 and !data.containsKey('siteId'))">
a.siteId=#{data.siteId},
</if>
<if test="(colPickMode==0 and data.containsKey('siteIdIncrement')) or (colPickMode==1 and !data.containsKey('siteIdIncrement'))">
a.siteId=ifnull(a.siteId,0) + #{data.siteIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('siteCode')) or (colPickMode==1 and !data.containsKey('siteCode'))">
a.siteCode=#{data.siteCode},
</if>
......@@ -260,6 +270,18 @@
</if>
</foreach>
</trim>
<trim prefix="siteId=(case" suffix="ELSE siteId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('siteId')) or (colPickMode==1 and !item.containsKey('siteId'))">
when a.id=#{item.id} then #{item.siteId}
</when>
<when test="(colPickMode==0 and item.containsKey('siteIdIncrement')) or (colPickMode==1 and !item.containsKey('siteIdIncrement'))">
when a.id=#{item.id} then ifnull(a.siteId,0) + #{item.siteIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="siteCode=(case" suffix="ELSE siteCode end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('siteCode')) or (colPickMode==1 and !item.containsKey('siteCode'))">
......@@ -606,6 +628,27 @@
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('siteId')">
<if test="conditionParamRef.siteId != null ">
${_conditionType_} a.siteId = #{${_conditionParam_}.siteId}
</if>
<if test="conditionParamRef.siteId == null">
${_conditionType_} a.siteId is null
</if>
</if>
<if test="conditionParamRef.containsKey('siteIdList')">
${_conditionType_} a.siteId in
<foreach collection="conditionParamRef.siteIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('siteIdStart') and conditionParamRef.siteIdStart != null">
${_conditionType_} a.siteId <![CDATA[ >= ]]> #{${_conditionParam_}.siteIdStart}
</if>
<if test="conditionParamRef.containsKey('siteIdEnd') and conditionParamRef.siteIdEnd != null">
${_conditionType_} a.siteId <![CDATA[ <= ]]> #{${_conditionParam_}.siteIdEnd}
</if>
<if test="conditionParamRef.containsKey('siteCode')">
<if test="conditionParamRef.siteCode != null and conditionParamRef.siteCode != ''">
......@@ -1012,6 +1055,11 @@
<if test='orderCol.deviceCode != null and "DESC".equalsIgnoreCase(orderCol.deviceCode)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('siteId')">
a.siteId
<if test='orderCol.siteId != null and "DESC".equalsIgnoreCase(orderCol.siteId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('siteCode')">
a.siteCode
<if test='orderCol.siteCode != null and "DESC".equalsIgnoreCase(orderCol.siteCode)'>DESC</if>
......
......@@ -137,7 +137,6 @@ exchangeName|String|交换机名称|-
loginName|String|平台用户名称|是|-
password|String|平台用户密码|是|-
**请求样例:**
```
......@@ -156,8 +155,6 @@ data|object|数据对象|-
```
### 接收第三方平台设备消息
**请求URL:** m/api/receive
......@@ -173,12 +170,15 @@ data|object|数据对象|-
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
:------|:---|:---|:---|:---
receiveMethod|Integer|1:新增,2:修改,3:删除,4:激活,5:启用,6:停用|是|-
deviceName|String|设备名称|否|-
deviceCode|String|设备编码,如MAC地址|是|-
platformCode|String|平台系统编码|是|见平台编码附录
productCode|String|产品编码|是|见产品编码附录
ip|String|设备访问ip|否|-
port|String|设备端口|否|-
siteId|Long|站点ID,来源基础服务平台|是|-
siteCode|String|站点编号,来源基础服务平台|是|-
siteName|String|站点名称|是|-
homeUrl|String|首页地址|否|-
......@@ -186,8 +186,7 @@ deviceRemark|String|备注|是|-
**请求样例:**
```
{
}
{}
```
**响应参数:**
......@@ -213,29 +212,30 @@ data|object|数据对象|-
**内容类型:** application/json;charset=utf-8
**简要描述:** 设备新增激活下线等消息通知各个平台,当配置了地址时候
**简要描述:** 设备消息通知各个平台,当配置了地址时候
**请求参数:**
参数名称|类型|备注|必填|其它
:---|:---|:---|:---|:---
code|Integer|结果码(-1.失败,1.成功)|是|-
msg|String|消息|否|-
:------|:---|:---|:---|:---
type|Integer|消息类型|是|0:设备增删改查,data数据域封装具体设备消息,1:设备消息类,数据域透传设备上行消息体。
msg|String|消息|否|-
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|设备端口|否|-
&emsp;siteId|Long|站点ID,来源基础服务平台|是|-
&emsp;siteCode|String|站点编号,来源基础服务平台|是|-
&emsp;siteName|String|站点名称|是|-
&emsp;deviceRemark|String|备注|是|-
**请求样例:**
```
{
}
{}
```
**响应参数:**
......
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