diff --git a/xiuosiot-backend/pom.xml b/xiuosiot-backend/pom.xml index d90d422..f2d16df 100644 --- a/xiuosiot-backend/pom.xml +++ b/xiuosiot-backend/pom.xml @@ -75,6 +75,26 @@ 3.0.0 + + + org.springframework.integration + spring-integration-stream + + + org.springframework.integration + spring-integration-mqtt + + + org.springframework.boot + spring-boot-starter-integration + + + + org.springframework.boot + spring-boot-configuration-processor + true + + diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java index 2280ab1..715383d 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/LoginController.java @@ -6,6 +6,7 @@ import com.aiit.xiuos.Utils.ResultRespons; import com.aiit.xiuos.model.UserInfo; import com.aiit.xiuos.service.UserInfoService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @@ -41,4 +42,6 @@ public class LoginController { session.invalidate(); return new ResultRespons(Constant.SUCCESS_CODE,"用户登出"); } + + } diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java index a4345cb..8a8eb34 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/controller/ProtocolProductInfoController.java @@ -31,11 +31,17 @@ public class ProtocolProductInfoController { @PostMapping("/add") public ResultRespons addProtocolProduct(@RequestBody ProtocolProductVo protocolProductVo, HttpServletRequest request) throws ParseException { + UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user"); + if(userInfo==null){ + return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!"); + } ProtocolProductInfo productInfo = protocolService.getProtocolByName(protocolProductVo.getProductName()); + if (productInfo != null) { return new ResultRespons(Constant.ERROR_CODE, "该协议配方已存在!"); } productInfo = ProtocolProductVo.changeVoToModel(protocolProductVo); + productInfo.setOrg(userInfo.getOrg()); int res = protocolService.addProtocolProduct(productInfo); if (1 == res) { @@ -56,9 +62,13 @@ public class ProtocolProductInfoController { @GetMapping("/selectAll") public ResultRespons selectProtocolProductList(HttpServletRequest request) throws ParseException { - List protocolProductInfos = protocolService.getProtocolAll(); + UserInfo userInfo =(UserInfo) request.getSession().getAttribute("user"); + if(userInfo==null){ + return new ResultRespons(Constant.SessionTimeOut_CODE,"用户尚未登录,请先登录!"); + } + List protocolProductInfos = protocolService.getProtocolAll(userInfo.getOrg()); List protocolProductVos= new ArrayList<>(); - if (protocolProductInfos != null && protocolProductInfos.size() > 0) { + if (protocolProductInfos != null && protocolProductInfos.size() >= 0) { for(int i=0;i selectAll(); + @Select("select * from protocol_product_info where org =#{org}") + List selectAll(@Param("org") String org); + //暂未使用 @Select("select * from protocol_product_info where protocol_type =#{type}") List selectByType(@Param("type") String protocolType); diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/ProtocolProductInfo.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/ProtocolProductInfo.java index c241462..d84f8f7 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/ProtocolProductInfo.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/ProtocolProductInfo.java @@ -1,6 +1,8 @@ package com.aiit.xiuos.model; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Data; @@ -12,7 +14,7 @@ public class ProtocolProductInfo { private String protocolType; private String readItemList; - + @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date updatetime; private String deviceId; @@ -23,7 +25,9 @@ public class ProtocolProductInfo { private String readPeriod; - public ProtocolProductInfo(String productName, String protocolType, String readItemList, Date updatetime, String deviceId, String deviceName, String socketConfig, String readPeriod) { + private String org; + + public ProtocolProductInfo(String productName, String protocolType, String readItemList, Date updatetime, String deviceId, String deviceName, String socketConfig, String readPeriod, String org) { this.productName = productName; this.protocolType = protocolType; this.readItemList = readItemList; @@ -32,6 +36,7 @@ public class ProtocolProductInfo { this.deviceName = deviceName; this.socketConfig = socketConfig; this.readPeriod = readPeriod; + this.org = org; } public ProtocolProductInfo() { diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/UserInfo.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/UserInfo.java index 5904afb..f76bec1 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/UserInfo.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/model/UserInfo.java @@ -24,7 +24,13 @@ public class UserInfo { private String org; - public UserInfo(String id, String username, String password, String realname, Integer phonenum, String updatetime, String lastlogintime, String lastloginip, String org) { + private String corpname; + + private String abbrcorpname; + + private String permissions; + + public UserInfo(String id, String username, String password, String realname, Integer phonenum, String updatetime, String lastlogintime, String lastloginip, String org, String corpname, String abbrcorpname, String permissions) { this.id = id; this.username = username; this.password = password; @@ -34,6 +40,9 @@ public class UserInfo { this.lastlogintime = lastlogintime; this.lastloginip = lastloginip; this.org = org; + this.corpname = corpname; + this.abbrcorpname = abbrcorpname; + this.permissions = permissions; } public UserInfo() { diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/ProtocolService.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/ProtocolService.java index 94569a1..1023e72 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/ProtocolService.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/ProtocolService.java @@ -6,7 +6,7 @@ import java.util.List; public interface ProtocolService { List getProtocolByType(String protocolType); - List getProtocolAll(); + List getProtocolAll(String org); ProtocolProductInfo getProtocolByName(String productName); int addProtocolProduct(ProtocolProductInfo protocolProductInfo); int deleteProtocolProduct(String productName); diff --git a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/ProtocolServiceImpl.java b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/ProtocolServiceImpl.java index 10e5e55..b2d5194 100644 --- a/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/ProtocolServiceImpl.java +++ b/xiuosiot-backend/src/main/java/com/aiit/xiuos/service/impl/ProtocolServiceImpl.java @@ -11,14 +11,15 @@ import java.util.List; public class ProtocolServiceImpl implements ProtocolService { @Autowired ProtocolProductInfoMapper protocolProductInfoMapper; + //暂未使用 @Override public List getProtocolByType(String protocolType) { return protocolProductInfoMapper.selectByType(protocolType); } @Override - public List getProtocolAll() { - return protocolProductInfoMapper.selectAll(); + public List getProtocolAll(String org) { + return protocolProductInfoMapper.selectAll(org); } @Override diff --git a/xiuosiot-backend/src/main/resources/application.yml b/xiuosiot-backend/src/main/resources/application.yml index 13d5670..f71c18a 100644 --- a/xiuosiot-backend/src/main/resources/application.yml +++ b/xiuosiot-backend/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: nama: xiuosiot type: com.zaxxer.hikari.HikariDataSource driver-class-name: org.postgresql.Driver - url: jdbc:postgresql://localhost:5432/xiuosiot + url: jdbc:postgresql://115.238.53.59:5432/xiuosiot username: xiuosiot password: 123456 hikari: @@ -20,10 +20,27 @@ spring: connection-test-query: select 'x' pool-name: xiuosiots password: 123456 - jdbc-url: jdbc:postgresql://localhost:5432/xiuosiot + jdbc-url: jdbc:postgresql://115.238.53.59:5432/xiuosiot mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl map-underscore-to-camel-case: true mapper-locations: classpath:mappers/*.xml + +#MQTT Config +mqtt: + #MQTT-服务器连接地 + hostUrl: tcp://localhost:1883 + #MQTT-连接服务器默认客户端ID + clientId: xiuosiot-client + #MQTT-用户名 + username: xiuosiot + #MQTT-密码 + password: xiuosiot + #连接超时 + timeout: 100 + #设置会话心跳时间 + keepalive: 100 + #默认主题 + default-topic: xiuosiot/# diff --git a/xiuosiot-backend/src/main/resources/mappers/ProtocolProductInfoMapper.xml b/xiuosiot-backend/src/main/resources/mappers/ProtocolProductInfoMapper.xml index 001749c..5674a09 100644 --- a/xiuosiot-backend/src/main/resources/mappers/ProtocolProductInfoMapper.xml +++ b/xiuosiot-backend/src/main/resources/mappers/ProtocolProductInfoMapper.xml @@ -11,11 +11,12 @@ + product_name, protocol_type, read_item_list, updatetime, device_id, device_name, - socket_config, read_period + socket_config, read_period, org select @@ -31,11 +34,13 @@ insert into user_info (id, username, password, realname, phonenum, updatetime, - lastlogintime, lastloginip, org + lastlogintime, lastloginip, org, + corpname, abbrCorpName, permissions ) - values (#{id,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, + values (#{id,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{realname,jdbcType=VARCHAR}, #{phonenum,jdbcType=INTEGER}, #{updatetime,jdbcType=VARCHAR}, - #{lastlogintime,jdbcType=VARCHAR}, #{lastloginip,jdbcType=VARCHAR}, #{org,jdbcType=VARCHAR} + #{lastlogintime,jdbcType=VARCHAR}, #{lastloginip,jdbcType=VARCHAR}, #{org,jdbcType=VARCHAR}, + #{corpname,jdbcType=VARCHAR}, #{abbrcorpname,jdbcType=VARCHAR}, #{permissions,jdbcType=VARCHAR} ) @@ -68,6 +73,15 @@ org, + + corpname, + + + abbrCorpName, + + + permissions, + @@ -97,6 +111,15 @@ #{org,jdbcType=VARCHAR}, + + #{corpname,jdbcType=VARCHAR}, + + + #{abbrcorpname,jdbcType=VARCHAR}, + + + #{permissions,jdbcType=VARCHAR}, + @@ -126,6 +149,15 @@ org = #{org,jdbcType=VARCHAR}, + + corpname = #{corpname,jdbcType=VARCHAR}, + + + abbrCorpName = #{abbrcorpname,jdbcType=VARCHAR}, + + + permissions = #{permissions,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -138,7 +170,10 @@ updatetime = #{updatetime,jdbcType=VARCHAR}, lastlogintime = #{lastlogintime,jdbcType=VARCHAR}, lastloginip = #{lastloginip,jdbcType=VARCHAR}, - org = #{org,jdbcType=VARCHAR} + org = #{org,jdbcType=VARCHAR}, + corpname = #{corpname,jdbcType=VARCHAR}, + abbrCorpName = #{abbrcorpname,jdbcType=VARCHAR}, + permissions = #{permissions,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file