Commit d1e29e6a authored by chenying's avatar chenying

3.14:网关,通道,主题的增删改查

parent 71ccf766
This diff is collapsed.
package com.example.tdl.domain.vo;
public class AddGatewayVo {
private String SN;
private String name;
private String type;
private String modelName;
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.example.tdl.domain.vo;
public class AddProbesVo {
private String SN;
private String gType;
private Integer port;
private String unit;
private String description;
private String alias;
private String type;
private Integer alarmUp;
private Integer alarmDown;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
}
package com.example.tdl.domain.vo;
public class AddTopicConfigVo {
private String topicName;
private Integer port;
private String SN;
private String type;
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.example.tdl.domain.vo;
public class AddTopicVo {
private String SN;
private String gType;
private String topicName;
private Integer type;
private Integer intervalTime;
private Integer frequency;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public Integer getFrequency() {
return frequency;
}
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
}
package com.example.tdl.domain.vo;
public class DelAProbesVo {
private String SN;
private String type;
private Integer port;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
}
package com.example.tdl.domain.vo;
public class DelGatewayVo {
private String SN;
private String type;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.example.tdl.domain.vo;
public class DelTopicVo {
private String SN;
private String type;
private String topicName;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
}
package com.example.tdl.domain.vo;
public class DeployProbesVo {
private String SN;
private String type;
private String modelName;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
}
package com.example.tdl.domain.vo;
public class GatewaySNAndTypeVo {
private String SN;
private String type;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.example.tdl.domain.vo;
public class ResultProbesVo {
private Integer port;
private String unit;
private String description;
private String alias;
private String pType;
private Integer alarmUp;
private Integer alarmDown;
private String SN;
private String gType;
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getpType() {
return pType;
}
public void setpType(String pType) {
this.pType = pType;
}
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
}
package com.example.tdl.domain.vo;
public class ResultTopicConfigVo {
private Integer port;
private String unti;
private String description;
private String alias;
private String type;
private Integer alarmUp;
private Integer alarmDown;
private String topicName;
private Integer tType;
private Integer intervalTime;
private String frequency;
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
public String getUnti() {
return unti;
}
public void setUnti(String unti) {
this.unti = unti;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer gettType() {
return tType;
}
public void settType(Integer tType) {
this.tType = tType;
}
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public String getFrequency() {
return frequency;
}
public void setFrequency(String frequency) {
this.frequency = frequency;
}
}
package com.example.tdl.domain.vo;
public class ResultTopicVo {
private String topicName;
private Integer type;
private Integer intervalTime;
private Integer frequency;
private String SN;
private String gType;
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public Integer getFrequency() {
return frequency;
}
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
}
package com.example.tdl.domain.vo;
public class UpdateGatewayVo {
private String SN;
private String name;
private String type;
private Long updateTime;
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
}
package com.example.tdl.domain.vo;
public class UpdateProbesVo {
private String unit;
private String description;
private String alias;
private String type;
private Integer alarmUp;
private Integer alarmDown;
private Long updateTime;
private String SN;
private String gType;
private Integer port;
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getAlarmUp() {
return alarmUp;
}
public void setAlarmUp(Integer alarmUp) {
this.alarmUp = alarmUp;
}
public Integer getAlarmDown() {
return alarmDown;
}
public void setAlarmDown(Integer alarmDown) {
this.alarmDown = alarmDown;
}
public Long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
}
package com.example.tdl.domain.vo;
public class UpdateTopicVo {
private String topicName;
private Integer type;
private Integer intervalTime;
private Integer frequency;
private String oldTopicName;
private String SN;
private String gType;
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getIntervalTime() {
return intervalTime;
}
public void setIntervalTime(Integer intervalTime) {
this.intervalTime = intervalTime;
}
public Integer getFrequency() {
return frequency;
}
public void setFrequency(Integer frequency) {
this.frequency = frequency;
}
public String getOldTopicName() {
return oldTopicName;
}
public void setOldTopicName(String oldTopicName) {
this.oldTopicName = oldTopicName;
}
public String getSN() {
return SN;
}
public void setSN(String SN) {
this.SN = SN;
}
public String getgType() {
return gType;
}
public void setgType(String gType) {
this.gType = gType;
}
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface GatewayMapper {
List<ResultGatewayVo> getAll();
int addGateway(Map<Object,Object> map);
int updateGateway(UpdateGatewayVo updateGatewayVo);
int delGateway(Map<Object,Object> map);
ResultGatewayVo getBySNAndType(@Param("SN") String SN,@Param("type") String type);
int getIdBySNAndType(@Param("SN") String SN,@Param("type") String type);
int deployGateway(Map<Object,Object> map);
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.ResultProbesVo;
import com.example.tdl.domain.vo.UpdateProbesVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface ProbesMapper {
List<ResultProbesVo> getProbesByGateway(@Param("SN") String SN, @Param("type") String type);
ResultProbesVo getByPortAndGateway(@Param("SN") String SN, @Param("type") String type, @Param("port") int port);
ResultProbesVo getByAliasAndGateway(@Param("SN") String SN, @Param("type") String type, @Param("alias") String alias);
ResultProbesVo getByDescriptionAndGateway(@Param("SN") String SN, @Param("type") String type, @Param("description") String description);
List<Integer> getAllPort(@Param("SN") String SN, @Param("type") String type);
List<String> getAllAlias(@Param("SN") String SN, @Param("type") String type);
List<String> getUnitByAlias(@Param("SN") String SN, @Param("type") String type);
List<String> getNameByAliasList(@Param("SN") String SN, @Param("type") String type, @Param("aliasList") List<String> aliasList);
Integer getCountByGateway(@Param("SN") String SN, @Param("type") String type);
int addProbes(Map<String, Object> map);
int updateProbes(UpdateProbesVo updateProbesVo);
int delAProbes(Map<String, Object> map);
int delAllProbes(Map<String, Object> map);
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.AddTopicConfigVo;
import com.example.tdl.domain.vo.ResultTopicConfigVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TopicConfigMapper {
List<ResultTopicConfigVo> getByTopicName(String topicName);
int addTopicConfig(AddTopicConfigVo addTopicConfigVo);
int delTopicConfig(AddTopicConfigVo addTopicConfigVo);
// int addTopicConfig(Map<String,Object> map);
// List<DevChannelVo> getChannelByTopicName(@Param("topicName") String topicName, @Param("SN") String SN, @Param("type") String type);
// int updateTopicConfig(TopicConfig topicConfig);
// TopicConfig getByDevChannelId(Integer devChannelId);
}
package com.example.tdl.mapper;
import com.example.tdl.domain.vo.GatewaySNAndTypeVo;
import com.example.tdl.domain.vo.ResultTopicVo;
import com.example.tdl.domain.vo.UpdateTopicVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface TopicMapper{
List<ResultTopicVo> getByGateway(GatewaySNAndTypeVo gatewaySNAndTypeVo);
ResultTopicVo getByTopicName(@Param("SN") String SN, @Param("type") String type,@Param("topicName") String topicName);
int addTopic(Map<String, Object> map);
int updateTopic(UpdateTopicVo updateTopicVo);
int delTopic(Map<String, Object> map);
// List<TopicResultVo> getTopicByCompanyName(String companyName);
// List<TopicVo> getTypeByDevcie(String SN, String type);
// List<Topic> getAll(Device device);
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.AddGatewayVo;
import com.example.tdl.domain.vo.DelGatewayVo;
import com.example.tdl.domain.vo.ResultGatewayVo;
import com.example.tdl.domain.vo.UpdateGatewayVo;
import com.example.tdl.mapper.GatewayMapper;
import com.example.tdl.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class GatewayService {
@Autowired
private GatewayMapper gatewayMapper;
public List<ResultGatewayVo> getAll(){
return gatewayMapper.getAll();
}
public int addGateway(Map<Object,Object> map){
return gatewayMapper.addGateway(map);
}
public int updateGateway(UpdateGatewayVo updateGatewayVo){
return gatewayMapper.updateGateway(updateGatewayVo);
}
public int delGateway(Map<Object,Object> map){
return gatewayMapper.delGateway(map);
}
public ResultGatewayVo getBySNAndType(String SN,String type){
return gatewayMapper.getBySNAndType(SN,type);
}
public int getIdBySNAndType(String SN,String type){
return gatewayMapper.getIdBySNAndType(SN,type);
}
public int deployGateway(Map<Object,Object> map){
return gatewayMapper.deployGateway(map);
}
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.ResultProbesVo;
import com.example.tdl.domain.vo.UpdateProbesVo;
import com.example.tdl.mapper.ProbesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class ProbesService {
@Autowired
private ProbesMapper probesMapper;
public List<ResultProbesVo> getProbesByGateway(String SN, String type){
return probesMapper.getProbesByGateway(SN,type);
}
public ResultProbesVo getByPortAndGateway(String SN,String type,int port){
return probesMapper.getByPortAndGateway(SN,type,port);
}
public ResultProbesVo getByAliasAndGateway(String SN,String type,String alias){
return probesMapper.getByAliasAndGateway(SN,type,alias);
}
public ResultProbesVo getByDescriptionAndGateway(String SN,String type,String description){
return probesMapper.getByDescriptionAndGateway(SN,type,description);
}
public List<Integer> getAllPort(String SN, String type){
return probesMapper.getAllPort(SN, type);
}
public List<String> getAllAlias(String SN, String type){
return probesMapper.getAllAlias(SN, type);
}
public List<String> getUnitByAlias(String SN, String type){
return probesMapper.getUnitByAlias(SN, type);
}
public List<String> getNameByAliasList(String SN, String type,List<String> aliasList){
return probesMapper.getNameByAliasList(SN, type,aliasList);
}
public Integer getCountByGateway(String SN, String type){
return probesMapper.getCountByGateway(SN,type);
}
public int addProbes(Map<String,Object> map){
return probesMapper.addProbes(map);
}
public int updateProbes(UpdateProbesVo updateProbesVo){
return probesMapper.updateProbes(updateProbesVo);
}
public int delAProbes(Map<String,Object> map){
return probesMapper.delAProbes(map);
}
public int delAllProbes(Map<String,Object> map){
return probesMapper.delAllProbes(map);
}
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.AddTopicConfigVo;
import com.example.tdl.domain.vo.ResultTopicConfigVo;
import com.example.tdl.mapper.TopicConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TopicConfigService {
@Autowired
private TopicConfigMapper topicConfigMapper;
public List<ResultTopicConfigVo> getByTopicName(String topicName){
return topicConfigMapper.getByTopicName(topicName);
}
public int addTopicConfig(AddTopicConfigVo addTopicConfigVo){
return topicConfigMapper.addTopicConfig(addTopicConfigVo);
}
public int delTopicConfig(AddTopicConfigVo addTopicConfigVo){
return topicConfigMapper.delTopicConfig(addTopicConfigVo);
}
// public int updateTopicConfig(TopicConfig topicConfig){
// return topicConfigMapper.updateTopicConfig(topicConfig);
// }
// public List<ResultTopicConfigVo> getChannelByTopicName(String topicName, String SN, String type){
// return topicConfigMapper.getChannelByTopicName(topicName,SN,type);
// }
// public TopicConfig getByDevChannelId(Integer devChannelId){
// return topicConfigMapper.getByDevChannelId(devChannelId);
// }
}
package com.example.tdl.service;
import com.example.tdl.domain.vo.GatewaySNAndTypeVo;
import com.example.tdl.domain.vo.ResultTopicVo;
import com.example.tdl.domain.vo.UpdateTopicVo;
import com.example.tdl.mapper.TopicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class TopicService {
@Autowired
private TopicMapper topicMapper;
//获取一设备所有的主题
public List<ResultTopicVo> getByGateway(GatewaySNAndTypeVo gatewaySNAndTypeVo){
return topicMapper.getByGateway(gatewaySNAndTypeVo);
}
public ResultTopicVo getByTopicName(String SN,String type,String topicName){
return topicMapper.getByTopicName(SN,type,topicName);
}
//新增主题
public int addTopic(Map<String,Object> map){
return topicMapper.addTopic(map);
}
public int updateTopic(UpdateTopicVo updateTopicVo){
return topicMapper.updateTopic(updateTopicVo);
}
public int delTopic(Map<String,Object> map){
return topicMapper.delTopic(map);
}
// public List<TopicResultVo> getTopicByCompanyName(String companyName){
// return topicMapper.getTopicByCompanyName(companyName);
// }
// public List<Topic> getAll(Device device){
// return topicMapper.getAll(device);
// }
////根据设备查询主题
// public List<TopicVo> getTypeByDevcie(String SN, String type){
// return topicMapper.getTypeByDevcie(SN,type);
// }
}
This diff is collapsed.
package com.example.tdl.web;
import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddTopicConfigVo;
import com.example.tdl.domain.vo.ResultTopicConfigVo;
import com.example.tdl.service.TokenRedisService;
import com.example.tdl.service.TopicConfigService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/topicConfig")
public class TopicConfigController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
Gson gson = new Gson();
CommFeedback fb = new CommFeedback();
@Autowired
private TopicConfigService topicConfigService;
@Autowired
private TokenRedisService tokenRedisService;
@ApiOperation(value = "根据主题名查看该主题下所有的通道",notes = "需要传主题名,返回值:" +
" port:通道编号," +
" unit:通道单位," +
" description:通道描述," +
" alias:通道别名," +
" type:通道类型," +
" alarmUp:报警上限," +
" alarmDown:报警下限," +
" topicName:主题名," +
" tType:主题类型," +
" intervalTime:间隔时间," +
" frequency:发送次数")
@RequestMapping(value = "/getAll",method = RequestMethod.POST)
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public Object getAll(@RequestBody String topicName){
//创建JSONObject对象
JSONObject json =JSONObject.parseObject(topicName);
topicName=(String)json.get("topicName");
if (StringUtils.isEmpty(topicName)){
fb.setCode(0);
fb.setMessage("查询的主题名不能为空");
return gson.toJson(fb);
}
List<ResultTopicConfigVo> list = topicConfigService.getByTopicName(topicName);
return list;
}
@ApiOperation(value = "添加主题配置",notes = "根据主题名和通道编号添加主题配置,sn,type不用传,传递参数:" +
" topicName:主题名," +
" port:通道编号,")
@RequestMapping(value="/addTopicConfig",method = RequestMethod.POST)
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public String addTopicConfig(@RequestBody AddTopicConfigVo addTopicConfigVo){
if (StringUtils.isEmpty(addTopicConfigVo.getTopicName())){
fb.setCode(0);
fb.setMessage("添加的主题名不能为空");
return gson.toJson(fb);
}
if (addTopicConfigVo.getPort()==null){
fb.setCode(0);
fb.setMessage("添加的通道编号不能为空");
return gson.toJson(fb);
}
String SN =addTopicConfigVo.getTopicName().split("/")[2];
String type =addTopicConfigVo.getTopicName().split("/")[1];
addTopicConfigVo.setSN(SN);
addTopicConfigVo.setType(type);
int a =topicConfigService.addTopicConfig(addTopicConfigVo);
if (a>0){
fb.setCode(1);
fb.setMessage("添加主题配置成功");
}else {
fb.setCode(0);
fb.setMessage("添加主题配置失败");
}
return gson.toJson(fb);
}
@ApiOperation(value = "删除主题配置",notes = "根据主题名和通道编号删除主题配置,SN,type不用传,传递参数:" +
" topicName:主题名," +
" port:通道编号")
@RequestMapping(value = "/delTopicConfig",method = RequestMethod.POST)
@ApiImplicitParams({
@ApiImplicitParam(paramType="header", name = "Account_token", value = "token", required = true, dataType = "String"),
})
public String delTopicConfig(@RequestBody AddTopicConfigVo addTopicConfigVo){
if (StringUtils.isEmpty(addTopicConfigVo.getTopicName())){
fb.setCode(0);
fb.setMessage("删除的主题名不能为空");
return gson.toJson(fb);
}
if (addTopicConfigVo.getPort()==null){
fb.setCode(0);
fb.setMessage("删除的通道编号不能为空");
return gson.toJson(fb);
}
String SN =addTopicConfigVo.getTopicName().split("/")[2];
String type =addTopicConfigVo.getTopicName().split("/")[1];
addTopicConfigVo.setSN(SN);
addTopicConfigVo.setType(type);
int i =topicConfigService.delTopicConfig(addTopicConfigVo);
if(i>0){
fb.setCode(1);
fb.setMessage("删除成功");
}else{
fb.setCode(0);
fb.setMessage("删除失败");
}
return gson.toJson(fb);
}
// @RequestMapping(value = "/updateTopicConfig",method = RequestMethod.POST)
// public String updateTopicConfig(@RequestBody TopicConfigVo topicConfigVo,HttpServletRequest request){
// String token = request.getHeader("Account_token");
// String datum = tokenRedisService.get("TOKEN_" +token);
// if(datum == null){
// fb.setCode(0);
// fb.setMessage("对不起您未登录");
// return gson.toJson(fb);
// }
// UserRedisVo user = gson.fromJson(datum,UserRedisVo.class);
// TopicConfig topicConfig = new TopicConfig();
// int i = topicConfigService.updateTopicConfig(topicConfig);
// if(i == 0){
// fb.setCode(0);
// fb.setMessage("修改失败");
// }else{
// fb.setCode(1);
// fb.setMessage("修改成功");
// }
// return gson.toJson(fb);
// }
}
This diff is collapsed.
......@@ -2,22 +2,82 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.GatewayMapper">
<select id="getAll" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,(SELECT useScene from tdldevice where gateway_id=g.id limit 1) useScene
from gateway g
SELECT SN,name,type,state,bConfig,useScene
from gateway
</select>
<!-- <insert id="addGateway" parameterType="">
INSERT into gateway VALUES (
NULL ,
#{SN,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
0,
0,
<insert id="addGateway" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addGateway(
#{SN,mode=IN,jdbcType=VARCHAR},
#{name,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{updateTime,mode=IN,jdbcType=BIGINT},
#{modelName,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<update id="updateGateway" parameterType="com.example.tdl.domain.vo.UpdateGatewayVo">
UPDATE gateway SET
name=#{name,jdbcType=VARCHAR},
updateTime=#{updateTime,jdbcType=BIGINT}
WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
</update>
)
</insert>-->
<delete id="delGateway" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_delGateway(
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</delete>
<select id="getBySNAndType" parameterType="String" resultType="com.example.tdl.domain.vo.ResultGatewayVo">
SELECT SN,name,type,state,bConfig,useScene
from gateway WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
</select>
<select id="getIdBySNAndType" parameterType="String" resultType="java.lang.Integer">
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR}
AND type=#{type,jdbcType=VARCHAR}
</select>
<update id="deployGateway" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_deployGateway(
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{modelName,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</update>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES (
NULL ,
#{SN,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
0,
0,
0,
#{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}
)
</insert>-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.ProbesMapper">
<select id="getProbesByGateway" resultType="com.example.tdl.domain.vo.ResultProbesVo" parameterType="String">
select p.port,p.unit,p.description,p.alias,p.type pType,p.alarmUp,p.alarmDown,g.SN,g.type gType
from probes p INNER JOIN gateway g ON p.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
</select>
<select id="getByPortAndGateway" resultType="com.example.tdl.domain.vo.ResultProbesVo">
select p.port,p.unit,p.description,p.alias,p.type pType,p.alarmUp,p.alarmDown,g.SN,g.type gType
from probes p INNER JOIN gateway g ON p.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
AND p.port=#{port,jdbcType=INTEGER}
</select>
<select id="getByAliasAndGateway" parameterType="String" resultType="com.example.tdl.domain.vo.ResultProbesVo">
select p.port,p.unit,p.description,p.alias,p.type pType,p.alarmUp,p.alarmDown,g.SN,g.type gType
from probes p INNER JOIN gateway g ON p.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
AND alias=#{alias,jdbcType=INTEGER}
</select>
<select id="getByDescriptionAndGateway" parameterType="String" resultType="com.example.tdl.domain.vo.ResultProbesVo">
select p.port,p.unit,p.description,p.alias,p.type pType,p.alarmUp,p.alarmDown,g.SN,g.type gType
from probes p INNER JOIN gateway g ON p.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
AND description=#{description,jdbcType=VARCHAR}
</select>
<select id="getAllPort" parameterType="String" resultType="java.lang.Integer">
select port from probes where gateway_id =(
SELECT id FROM gateway WHERE SN = #{SN,jdbcType=VARCHAR} AND type = #{type,jdbcType=VARCHAR})
</select>
<select id="getAllAlias" parameterType="String" resultType="String">
select alias from probes where gateway_id =(
select id from gateway where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
</select>
<select id="getAllUnit" parameterType="String" resultType="String">
select unit from probes where gateway_id =(
select id from gateway where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
and alias =#{alias,jdbcType=VARCHAR}
</select>
<select id="getNameByAliasList" resultType="String" parameterType="String" >
select description from probes where gateway_id =(
select id from gateway where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
and alias in
<foreach collection="aliasList" item="alias" open="(" close=")" separator=",">
#{alias,jdbcType=VARCHAR}
</foreach>
ORDER BY FIELD(alias,
<foreach collection="aliasList" item="alias" separator=",">
#{alias,jdbcType=VARCHAR}
</foreach>)
</select>
<select id="getCountByGateway" parameterType="String" resultType="java.lang.Integer">
select COUNT(*) from probes where gateway_id =(
SELECT id FROM gateway WHERE SN = #{SN,jdbcType=VARCHAR} AND type = #{type,jdbcType=VARCHAR})
</select>
<insert id="addProbes" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addProbes(
#{SN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{port,mode=IN,jdbcType=INTEGER},
#{unit,mode=IN,jdbcType=VARCHAR},
#{description,mode=IN,jdbcType=VARCHAR},
#{alias,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{alarmUp,mode=IN,jdbcType=INTEGER},
#{alarmDown,mode=IN,jdbcType=INTEGER},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<update id="updateProbes" parameterType="com.example.tdl.domain.vo.UpdateProbesVo">
UPDATE probes SET
unit=#{unit,jdbcType=VARCHAR},
description=#{description,jdbcType=VARCHAR},
alias=#{alias,jdbcType=VARCHAR},
type=#{type,jdbcType=VARCHAR},
alarmUp=#{alarmUp,jdbcType=INTEGER},
alarmDown=#{alarmDown,jdbcType=INTEGER}
WHERE gateway_id = (SELECT id FROM gateway WHERE SN= #{SN,jdbcType=VARCHAR} AND type= #{gType,jdbcType=VARCHAR})
AND port=#{port,jdbcType=INTEGER}
</update>
<delete id="delAProbes" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_delAProbes(
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{port,mode=IN,jdbcType=INTEGER},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</delete>
<delete id="delAllProbes" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_delAllProbes(
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</delete>
<!--<select id="getMessageByAlias" resultType="com.example.demo.domain.vo.ResultDevChannelVo" parameterType="String" >-->
<!--select dc.port,dc.unit,dc.description,dc.type from devchannel dc,device d-->
<!--where d.id = dc.device_id-->
<!--and d.SN=#{SN,jdbcType=VARCHAR}-->
<!--and d.type= #{type,jdbcType=VARCHAR}-->
<!--and dc.alias =#{alias,jdbcType=VARCHAR}-->
<!--</select>-->
<!-- <select id="getAlias" parameterType="String" resultType="String">
select alias from devchannel where device_id =(
select id from device where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
</select>-->
<!-- <select id="getAllChannelByDevice" parameterType="String" resultType="com.example.demo.domain.vo.DevChannelVo">
select port,unit,alias,description,type
from devchannel
where device_id = (select id from device where SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR})
</select>-->
<!--<select id="getByAlias" parameterType="com.example.demo.entity.DevChannel" resultType="com.example.demo.entity.DevChannel">-->
<!--SELECT * FROM devchannel WHERE device_id= #{device.id,jdbcType=INTEGER} AND description LIKE CONCAT(CONCAT('%',#{description,jdbcType=VARCHAR}), '%')-->
<!--</select>-->
<!-- <select id="getChannelBySN" parameterType="String" resultType="java.lang.Integer">
select count(*) from devchannel
where device_id= (select id from device where SN=#{SN,jdbcType=VARCHAR} and type=#{type,jdbcType=VARCHAR})
</select>-->
<!--<select id="getAllByDeviceID" resultType="com.example.demo.entity.DevChannel" parameterType="java.lang.Integer">-->
<!--select * from devchannel where device_id=#{device.id,jdbcType=INTEGER}-->
<!--</select>-->
<!-- <select id="getDevChannelIdByDeviceIdAndPort" parameterType="com.example.demo.entity.DevChannel" resultType="com.example.demo.entity.DevChannel">
SELECT id from devchannel WHERE `port`=#{port,jdbcType=INTEGER}
AND device_id = (SELECT id FROM device WHERE SN= #{SN,jdbcType=VARCHAR} AND type= #{type,jdbcType=VARCHAR} LIMIT 1)
</select>-->
<!-- <select id="getDeviceId" parameterType="com.example.demo.entity.Device" resultType="com.example.demo.entity.Device">
SELECT id FROM device
WHERE SN = #{SN,jdbcType=VARCHAR}
AND type = #{type,jdbcType=VARCHAR}
</select>-->
<!-- <select id="getDevchannelByalias" parameterType="com.example.demo.entity.DevChannel" resultType="com.example.demo.entity.DevChannel">
select unit,type,description from devchannel where description LIKE CONCAT(CONCAT('%',#{description,jdbcType=VARCHAR}), '%') AND device_id=#{device.id,jdbcType=INTEGER}
</select>
-->
<!-- <select id="getIdByPort" resultType="java.lang.Integer">
select id from devchannel
where device_id = (SELECT id FROM device WHERE SN= #{SN,jdbcType=VARCHAR} AND type= #{type,jdbcType=VARCHAR})
AND port=#{port,jdbcType=INTEGER}
</select>
<select id="getIdByAlias" parameterType="String" resultType="com.example.demo.entity.DevChannel">
select * from devchannel
where device_id = (SELECT id FROM device WHERE SN= #{SN,jdbcType=VARCHAR} AND type= #{type,jdbcType=VARCHAR})
AND alias=#{alias,jdbcType=VARCHAR}
</select>-->
<!-- <select id="getIdByDesc" parameterType="String" resultType="com.example.demo.entity.DevChannel">
select * from devchannel
where device_id = (SELECT id FROM device WHERE SN= #{SN,jdbcType=VARCHAR} AND type= #{type,jdbcType=VARCHAR})
AND description=#{description,jdbcType=VARCHAR}
</select>-->
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.TopicConfigMapper">
<select id="getByTopicName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTopicConfigVo">
SELECT p.port,p.unit,p.description,p.alias,p.type,p.alarmUp,p.alarmDown,t.topicName,t.type tType,t.intervalTime,t.frequency
FROM topic_config tc,topic t,probes p
WHERE tc.probes_id=p.id
AND tc.topic_id=t.id
AND t.topicName =#{topicName,jdbcType=VARCHAR}
</select>
<insert id="addTopicConfig" parameterType="com.example.tdl.domain.vo.AddTopicConfigVo">
INSERT INTO topic_config VALUES (
null,
(SELECT id from topic WHERE topicName=#{topicName,jdbcType=VARCHAR}),
(SELECT id from probes WHERE `port`=#{port,jdbcType=INTEGER} AND gateway_id=(
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}))
)
</insert>
<delete id="delTopicConfig" parameterType="com.example.tdl.domain.vo.AddTopicConfigVo">
DELETE from topic_config
WHERE topic_id=(SELECT id from topic WHERE topicName=#{topicName,jdbcType=VARCHAR})
AND probes_id=(SELECT id from probes WHERE `port`=#{port,jdbcType=INTEGER} AND gateway_id=(
SELECT id from gateway WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}))
</delete>
<!-- <select id="getChannelByTopicName" parameterType="String" resultType="com.example.demo.domain.vo.DevChannelVo">
SELECT dc.port,dc.unit,dc.description,dc.alias
FROM topic_config tc,topic t,devchannel dc
WHERE tc.devchannel_id=dc.id
AND tc.topic_id=t.id
AND dc.device_id = (select id from device where SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR})
AND t.topicName =#{topicName,jdbcType=VARCHAR}
</select>-->
<!-- <insert id="addTopicConfig" statementType="CALLABLE" parameterType="java.util.Map">
<![CDATA[
{
call pro_addTopicConfig(
#{topicName,mode=IN,jdbcType=VARCHAR},
#{portVar,mode=IN,jdbcType=VARCHAR},
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,jdbcType=VARCHAR},
#{companyName,jdbcType=VARCHAR},
#{num,jdbcType=INTEGER},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>-->
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.tdl.mapper.TopicMapper">
<select id="getByGateway" parameterType="com.example.tdl.domain.vo.GatewaySNAndTypeVo" resultType="com.example.tdl.domain.vo.ResultTopicVo">
select t.topicName,t.type,t.intervalTime,t.frequency,g.SN,g.type gType
from topic t INNER JOIN gateway g ON t.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
</select>
<select id="getByTopicName" parameterType="String" resultType="com.example.tdl.domain.vo.ResultTopicVo">
select t.topicName,t.type,t.intervalTime,t.frequency,g.SN,g.type gType
from topic t INNER JOIN gateway g ON t.gateway_id=g.id
where g.SN=#{SN,jdbcType=VARCHAR}
AND g.type=#{type,jdbcType=VARCHAR}
AND topicName =#{topicName,jdbcType=VARCHAR}
</select>
<insert id="addTopic" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_addTopic(
#{SN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{topicName,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=INTEGER},
#{intervalTime,mode=IN,jdbcType=INTEGER},
#{frequency,mode=IN,jdbcType=INTEGER},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
<update id="updateTopic" parameterType="com.example.tdl.domain.vo.UpdateTopicVo">
update topic set
topicName=#{topicName,jdbcType=VARCHAR},
type=#{type,jdbcType=INTEGER},
intervalTime=#{intervalTime,jdbcType=INTEGER},
frequency=#{frequency,jdbcType=INTEGER}
where gateway_id=(SELECT id from gateway where SN=#{SN,jdbcType=VARCHAR} AND type=#{gType,jdbcType=VARCHAR})
AND topicName=#{oldTopicName,jdbcType=VARCHAR}
</update>
<delete id="delTopic" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
{
call pro_delTopic(
#{SN,mode=IN,jdbcType=VARCHAR},
#{type,mode=IN,jdbcType=VARCHAR},
#{topicName,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</delete>
<!--
<select id ="getTopicByCompanyName" parameterType="java.lang.String" resultType="com.example.demo.domain.vo.TopicResultVo">
select topicName,type,intervalTime from topic
where device_id in(select id from device where company_id =(select id from company where companyName=#{companyName,jdbcType=VARCHAR}))
</select>-->
<!-- <select id="getAll" parameterType="com.example.demo.entity.Device" resultType="com.example.demo.domain.vo.TopicVo">
select topicName,type,intervalTime from topic
where device_id =(select id from device where SN=#{SN,jdbcType=VARCHAR} and type=#{type,jdbcType=VARCHAR})
</select>-->
<!-- <select id="getTypeByDevcie" parameterType="String" resultType="com.example.demo.domain.vo.TopicVo">
select topicName,type,intervalTime,SN,dtype from topic
where device_id =(select id from device where SN=#{SN,jdbcType=VARCHAR} and type=#{type,jdbcType=VARCHAR})
</select>-->
</mapper>
\ No newline at end of file
......@@ -41,6 +41,9 @@
<mapper resource="mapper/ProbesModelInfoMapper.xml"/>
<mapper resource="mapper/ModelMapper.xml"/>
<mapper resource="mapper/ModelInfoMapper.xml"/>
<mapper resource="mapper/ProbesMapper.xml"/>
<mapper resource="mapper/TopicMapper.xml"/>
<mapper resource="mapper/TopicConfigMapper.xml"/>
</mappers>
</configuration>
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