正在显示
8 个修改的文件
包含
90 行增加
和
10 行删除
| @@ -10,6 +10,8 @@ import com.zhonglai.luhui.device.analysis.dto.MessageCodeType; | @@ -10,6 +10,8 @@ import com.zhonglai.luhui.device.analysis.dto.MessageCodeType; | ||
| 10 | public class ClienConnectionImpl implements ClienConnection { | 10 | public class ClienConnectionImpl implements ClienConnection { |
| 11 | private Message message = new Message(MessageCode.DEFAULT_FAIL_CODE,"控制失败,请稍后重试!"); | 11 | private Message message = new Message(MessageCode.DEFAULT_FAIL_CODE,"控制失败,请稍后重试!"); |
| 12 | 12 | ||
| 13 | + private byte[] commd; | ||
| 14 | + | ||
| 13 | @Override | 15 | @Override |
| 14 | public void close() { | 16 | public void close() { |
| 15 | this.message.setCode(MessageCode.DEFAULT_FAIL_CODE); | 17 | this.message.setCode(MessageCode.DEFAULT_FAIL_CODE); |
| @@ -44,4 +46,12 @@ public class ClienConnectionImpl implements ClienConnection { | @@ -44,4 +46,12 @@ public class ClienConnectionImpl implements ClienConnection { | ||
| 44 | this.message.setMessage(message); | 46 | this.message.setMessage(message); |
| 45 | return this; | 47 | return this; |
| 46 | } | 48 | } |
| 49 | + | ||
| 50 | + public byte[] getCommd() { | ||
| 51 | + return commd; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setCommd(byte[] commd) { | ||
| 55 | + this.commd = commd; | ||
| 56 | + } | ||
| 47 | } | 57 | } |
| @@ -149,10 +149,12 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | @@ -149,10 +149,12 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | ||
| 149 | private Integer is_save_log; | 149 | private Integer is_save_log; |
| 150 | /** 模型类别(1-属性,2-功能,3-事件) */ | 150 | /** 模型类别(1-属性,2-功能,3-事件) */ |
| 151 | private Integer mode_type; | 151 | private Integer mode_type; |
| 152 | - /** 模型类别(1-属性,2-功能,3-事件) */ | 152 | + /** 对应配置属性名称集合(英文逗号分割) */ |
| 153 | private String config_names; | 153 | private String config_names; |
| 154 | /** 物模型id */ | 154 | /** 物模型id */ |
| 155 | private Integer mode_id; | 155 | private Integer mode_id; |
| 156 | + /** 页面展示类型 */ | ||
| 157 | + private String view_type; | ||
| 156 | public void conversionThingsModel(IotThingsModel thingsModel) | 158 | public void conversionThingsModel(IotThingsModel thingsModel) |
| 157 | { | 159 | { |
| 158 | id = thingsModel.getIdentifier(); | 160 | id = thingsModel.getIdentifier(); |
| @@ -164,6 +166,7 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | @@ -164,6 +166,7 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T> | ||
| 164 | mode_type = thingsModel.getType(); | 166 | mode_type = thingsModel.getType(); |
| 165 | config_names = thingsModel.getConfig_names(); | 167 | config_names = thingsModel.getConfig_names(); |
| 166 | mode_id = thingsModel.getModel_id(); | 168 | mode_id = thingsModel.getModel_id(); |
| 169 | + view_type = thingsModel.getView_type(); | ||
| 167 | } | 170 | } |
| 168 | 171 | ||
| 169 | } | 172 | } |
| @@ -176,9 +176,38 @@ public class IotDeviceController extends BaseController | @@ -176,9 +176,38 @@ public class IotDeviceController extends BaseController | ||
| 176 | 176 | ||
| 177 | if(iotDevice.getCompletion_auth()==1) | 177 | if(iotDevice.getCompletion_auth()==1) |
| 178 | { | 178 | { |
| 179 | + String name= ""; | ||
| 179 | for (int i=0;i<sts.length;i++) | 180 | for (int i=0;i<sts.length;i++) |
| 180 | { | 181 | { |
| 181 | - sts[i] = "/"+iotProduct.getRole_id()+"/"+iotProduct.getMqtt_username()+"/"+iotDevice.getClient_id()+"/"+iotDevice.getPayload_type()+"/"+sts[i]; | 182 | + name=sts[i]+": "; |
| 183 | + switch (sts[i].toUpperCase()) | ||
| 184 | + { | ||
| 185 | + case "ALL_POST": | ||
| 186 | + name+="【终端发布】全量上报数据"+": "; | ||
| 187 | + break; | ||
| 188 | + case "ADD_POST": | ||
| 189 | + name+="【终端发布】增量上报数据"+": "; | ||
| 190 | + break; | ||
| 191 | + case "PUT_REQ": | ||
| 192 | + name+="【终端发布】写数据的执行结果"+": "; | ||
| 193 | + break; | ||
| 194 | + case "GET": | ||
| 195 | + name+="【终端发布】获取数据"+": "; | ||
| 196 | + break; | ||
| 197 | + case "READ_REQ": | ||
| 198 | + name+="【终端发布】读数据的执行结果"+": "; | ||
| 199 | + break; | ||
| 200 | + case "PUT": | ||
| 201 | + name+="【终端订阅】写数据"+": "; | ||
| 202 | + break; | ||
| 203 | + case "GET_REQ": | ||
| 204 | + name+="【终端订阅】获取数据的返回结果"+": "; | ||
| 205 | + break; | ||
| 206 | + case "READ": | ||
| 207 | + name+="【终端订阅】读数据"+": "; | ||
| 208 | + break; | ||
| 209 | + } | ||
| 210 | + sts[i] = name+"/"+iotProduct.getRole_id()+"/"+iotProduct.getMqtt_username()+"/"+iotDevice.getClient_id()+"/"+iotDevice.getPayload_type()+"/"+sts[i]; | ||
| 182 | } | 211 | } |
| 183 | } | 212 | } |
| 184 | 213 |
| @@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse; | @@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse; | ||
| 8 | import com.google.gson.JsonObject; | 8 | import com.google.gson.JsonObject; |
| 9 | import com.zhonglai.luhui.action.BaseController; | 9 | import com.zhonglai.luhui.action.BaseController; |
| 10 | import com.zhonglai.luhui.dao.service.PublicService; | 10 | import com.zhonglai.luhui.dao.service.PublicService; |
| 11 | +import com.zhonglai.luhui.device.domain.IotDevice; | ||
| 11 | import com.zhonglai.luhui.security.utils.SecurityUtils; | 12 | import com.zhonglai.luhui.security.utils.SecurityUtils; |
| 12 | import com.zhonglai.luhui.sys.utils.ExcelUtil; | 13 | import com.zhonglai.luhui.sys.utils.ExcelUtil; |
| 13 | import io.swagger.annotations.Api; | 14 | import io.swagger.annotations.Api; |
| @@ -120,6 +121,18 @@ public class IotProductController extends BaseController | @@ -120,6 +121,18 @@ public class IotProductController extends BaseController | ||
| 120 | @DeleteMapping("/{ids}") | 121 | @DeleteMapping("/{ids}") |
| 121 | public AjaxResult remove(@PathVariable Integer[] ids) | 122 | public AjaxResult remove(@PathVariable Integer[] ids) |
| 122 | { | 123 | { |
| 124 | + for (Integer id:ids) | ||
| 125 | + { | ||
| 126 | + IotDevice iotDevice = new IotDevice(); | ||
| 127 | + iotDevice.setProduct_id(id); | ||
| 128 | + Long st = publicService.getObjectListTotle(iotDevice,null); | ||
| 129 | + if(st>0) | ||
| 130 | + { | ||
| 131 | + IotProduct iotProduct = IotProductService.selectIotProductById(id); | ||
| 132 | + return AjaxResult.error("产品"+iotProduct.getProduct_name()+"下存在设备,无法删除"); | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + | ||
| 123 | return toAjax(IotProductService.deleteIotProductByIds(ids)); | 136 | return toAjax(IotProductService.deleteIotProductByIds(ids)); |
| 124 | } | 137 | } |
| 125 | 138 |
| @@ -3,6 +3,8 @@ package com.zhonglai.luhui.device.protocol.plc004.analysis; | @@ -3,6 +3,8 @@ package com.zhonglai.luhui.device.protocol.plc004.analysis; | ||
| 3 | import com.google.gson.JsonObject; | 3 | import com.google.gson.JsonObject; |
| 4 | import com.ruoyi.common.utils.GsonConstructor; | 4 | import com.ruoyi.common.utils.GsonConstructor; |
| 5 | import com.ruoyi.common.utils.StringUtils; | 5 | import com.ruoyi.common.utils.StringUtils; |
| 6 | +import com.zhonglai.luhui.device.analysis.comm.clien.ClienConnection; | ||
| 7 | +import com.zhonglai.luhui.device.analysis.comm.clien.impl.ClienConnectionImpl; | ||
| 6 | import com.zhonglai.luhui.device.analysis.comm.dto.ApiClientRePlyDto; | 8 | import com.zhonglai.luhui.device.analysis.comm.dto.ApiClientRePlyDto; |
| 7 | import com.zhonglai.luhui.device.analysis.comm.factory.Topic; | 9 | import com.zhonglai.luhui.device.analysis.comm.factory.Topic; |
| 8 | import com.zhonglai.luhui.device.analysis.dto.Message; | 10 | import com.zhonglai.luhui.device.analysis.dto.Message; |
| @@ -13,6 +15,7 @@ import com.zhonglai.luhui.device.protocol.factory.analysis.ProtocolParserFactory | @@ -13,6 +15,7 @@ import com.zhonglai.luhui.device.protocol.factory.analysis.ProtocolParserFactory | ||
| 13 | import com.zhonglai.luhui.device.protocol.factory.analysis.topic.*; | 15 | import com.zhonglai.luhui.device.protocol.factory.analysis.topic.*; |
| 14 | import com.zhonglai.luhui.device.protocol.factory.config.DeviceCach; | 16 | import com.zhonglai.luhui.device.protocol.factory.config.DeviceCach; |
| 15 | import com.zhonglai.luhui.device.protocol.factory.config.ProductPayloadModelNumberCach; | 17 | import com.zhonglai.luhui.device.protocol.factory.config.ProductPayloadModelNumberCach; |
| 18 | +import com.zhonglai.luhui.device.protocol.factory.control.DeviceCommandListenService; | ||
| 16 | import com.zhonglai.luhui.device.protocol.factory.dto.AnalysisResult; | 19 | import com.zhonglai.luhui.device.protocol.factory.dto.AnalysisResult; |
| 17 | import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceHostDto; | 20 | import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceHostDto; |
| 18 | 21 | ||
| @@ -34,15 +37,29 @@ public class PLC004ProtocolParserFactoryImpl implements ProtocolParserFactory<by | @@ -34,15 +37,29 @@ public class PLC004ProtocolParserFactoryImpl implements ProtocolParserFactory<by | ||
| 34 | case "ONLINE": | 37 | case "ONLINE": |
| 35 | return new Online().analysisPayload(payload); | 38 | return new Online().analysisPayload(payload); |
| 36 | case "ADD_POST": | 39 | case "ADD_POST": |
| 37 | - return new AddPost().analysisPayload(toformatPayLoad(topic.getClientid(),payload)); | 40 | + return new AddPost().analysisPayload(toformatPayLoad(topic.getClientid(),GsonConstructor.get().fromJson(new String(payload),JsonObject.class))); |
| 38 | case "PUT_REQ": | 41 | case "PUT_REQ": |
| 42 | + JsonObject data = null; | ||
| 43 | + if(DeviceCommandListenService.hasClienConnection(topic.getClientid())) | ||
| 44 | + { | ||
| 45 | + ClienConnection clienConnection = DeviceCommandListenService.getClienConnection(topic.getClientid()); | ||
| 46 | + if(null != clienConnection && clienConnection instanceof ClienConnectionImpl) | ||
| 47 | + { | ||
| 48 | + ClienConnectionImpl clienConnectionImpl = (ClienConnectionImpl) clienConnection; | ||
| 49 | + if(null != clienConnectionImpl.getCommd()) | ||
| 50 | + { | ||
| 51 | + data = GsonConstructor.get().fromJson(toformatPayLoad(topic.getClientid(),GsonConstructor.get().fromJson(new String(clienConnectionImpl.getCommd()),JsonObject.class)),JsonObject.class); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + } | ||
| 39 | JsonObject jsonObject = GsonConstructor.get().fromJson(new String(payload),JsonObject.class); | 55 | JsonObject jsonObject = GsonConstructor.get().fromJson(new String(payload),JsonObject.class); |
| 40 | - return new AnalysisResult(false, false, null, new ApiClientRePlyDto() { | 56 | + return new AnalysisResult(false, true, data, new ApiClientRePlyDto() { |
| 41 | @Override | 57 | @Override |
| 42 | public void setReplyMessage(Message message) { | 58 | public void setReplyMessage(Message message) { |
| 43 | if(jsonObject.has("result") && "1".equals(jsonObject.get("result").getAsString())) | 59 | if(jsonObject.has("result") && "1".equals(jsonObject.get("result").getAsString())) |
| 44 | { | 60 | { |
| 45 | message.setCode(MessageCode.DEFAULT_SUCCESS_CODE); | 61 | message.setCode(MessageCode.DEFAULT_SUCCESS_CODE); |
| 62 | + message.setMessage("操作成功"); | ||
| 46 | } | 63 | } |
| 47 | } | 64 | } |
| 48 | }); | 65 | }); |
| @@ -51,14 +68,16 @@ public class PLC004ProtocolParserFactoryImpl implements ProtocolParserFactory<by | @@ -51,14 +68,16 @@ public class PLC004ProtocolParserFactoryImpl implements ProtocolParserFactory<by | ||
| 51 | } | 68 | } |
| 52 | } | 69 | } |
| 53 | 70 | ||
| 54 | - private String toformatPayLoad(String clientid,byte[] payload) | 71 | + private String toformatPayLoad(String clientid, JsonObject jsonObject) |
| 55 | { | 72 | { |
| 56 | - JsonObject jsonObject = GsonConstructor.get().fromJson(new String(payload),JsonObject.class); | ||
| 57 | ParserDeviceHostDto parserDeviceHostDto = DeviceCach.getDeviceHost(clientid); | 73 | ParserDeviceHostDto parserDeviceHostDto = DeviceCach.getDeviceHost(clientid); |
| 58 | if(null != parserDeviceHostDto && null != parserDeviceHostDto.getIotProduct()) | 74 | if(null != parserDeviceHostDto && null != parserDeviceHostDto.getIotProduct()) |
| 59 | { | 75 | { |
| 60 | Integer iotProductid = parserDeviceHostDto.getIotProduct().getId(); | 76 | Integer iotProductid = parserDeviceHostDto.getIotProduct().getId(); |
| 61 | - | 77 | + if(!ProductPayloadModelNumberCach.hasProduct(iotProductid)) |
| 78 | + { | ||
| 79 | + return jsonObject.toString(); | ||
| 80 | + } | ||
| 62 | JsonObject rj = new JsonObject(); | 81 | JsonObject rj = new JsonObject(); |
| 63 | for (String key : jsonObject.keySet()) | 82 | for (String key : jsonObject.keySet()) |
| 64 | { | 83 | { |
| @@ -40,4 +40,9 @@ public class ProductPayloadModelNumberCach { | @@ -40,4 +40,9 @@ public class ProductPayloadModelNumberCach { | ||
| 40 | productPayloadModelNumber.remove(model); | 40 | productPayloadModelNumber.remove(model); |
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | + | ||
| 44 | + public static boolean hasProduct(Integer product_id) | ||
| 45 | + { | ||
| 46 | + return map.containsKey(product_id); | ||
| 47 | + } | ||
| 43 | } | 48 | } |
| @@ -148,8 +148,9 @@ public class DeviceCommandListenService implements RocketMQReplyListener<Message | @@ -148,8 +148,9 @@ public class DeviceCommandListenService implements RocketMQReplyListener<Message | ||
| 148 | Topic topic = noticeMessageDomain.getTopic(); | 148 | Topic topic = noticeMessageDomain.getTopic(); |
| 149 | 149 | ||
| 150 | //设置通知渠道 | 150 | //设置通知渠道 |
| 151 | - ClienConnection clienConnection = new ClienConnectionImpl(); | 151 | + ClienConnectionImpl clienConnection = new ClienConnectionImpl(); |
| 152 | log.info("设置通知渠道 {} {}",topic.getClientid(),clienConnection); | 152 | log.info("设置通知渠道 {} {}",topic.getClientid(),clienConnection); |
| 153 | + clienConnection.setCommd(noticeMessageDomain.getCommd()); | ||
| 153 | clienConnectionMap.put(topic.getClientid(),clienConnection); | 154 | clienConnectionMap.put(topic.getClientid(),clienConnection); |
| 154 | clienNoticeServiceFactory.sendMessage(noticeMessageDomain); | 155 | clienNoticeServiceFactory.sendMessage(noticeMessageDomain); |
| 155 | synchronized(clienConnection) | 156 | synchronized(clienConnection) |
| @@ -166,7 +167,7 @@ public class DeviceCommandListenService implements RocketMQReplyListener<Message | @@ -166,7 +167,7 @@ public class DeviceCommandListenService implements RocketMQReplyListener<Message | ||
| 166 | return message; | 167 | return message; |
| 167 | } | 168 | } |
| 168 | 169 | ||
| 169 | - public ClienConnection getClienConnection(String clientid) | 170 | + public static ClienConnection getClienConnection(String clientid) |
| 170 | { | 171 | { |
| 171 | return clienConnectionMap.get(clientid); | 172 | return clienConnectionMap.get(clientid); |
| 172 | } | 173 | } |
-
请 注册 或 登录 后发表评论