Ver código fonte

Merge branch 'master' of http://116.63.33.55/git/read_opc

ljh 2 anos atrás
pai
commit
c38104da28
21 arquivos alterados com 245 adições e 37 exclusões
  1. 29 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/MessageReceiver.java
  2. 43 20
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcAsyncTask.java
  3. 30 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/RedisConfig.java
  4. 8 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/RawDataController.java
  5. 17 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ReportTableController.java
  6. 16 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/RoleController.java
  7. 7 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/ReportTableDao.java
  8. 2 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/UserDao.java
  9. 1 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/enums/ModelEnum.java
  10. 6 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RawDataService.java
  11. 4 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/ReportTableService.java
  12. 5 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RoleService.java
  13. 8 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RawDataServiceImpl.java
  14. 16 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ReportTableServiceImpl.java
  15. 5 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RoleServiceImpl.java
  16. 16 11
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/UserServiceImpl.java
  17. 6 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/MathUtil.java
  18. 14 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/OpcUaUtil.java
  19. 5 0
      chuanyi_server/src/main/resources/mapper/ReportTableDao.xml
  20. 3 1
      chuanyi_server/src/main/resources/mapper/RoleDao.xml
  21. 4 0
      chuanyi_server/src/main/resources/mapper/UserDao.xml

+ 29 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/MessageReceiver.java

@@ -0,0 +1,29 @@
+package com.judong.chuanyiserver.config;
+
+import com.judong.chuanyiserver.util.Result;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.connection.Message;
+import org.springframework.data.redis.connection.MessageListener;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class MessageReceiver implements MessageListener {
+
+    private static Logger logger = LoggerFactory.getLogger(MessageReceiver.class);
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    @Override
+    public void onMessage(Message message, byte[] pattern) {
+        logger.info("channel:" + new String(pattern));
+        Result result = (Result) redisTemplate.getValueSerializer().deserialize(message.getBody());
+        System.out.println("接收到的消息是:" + result);
+        logger.info("Received <" + result + ">");
+    }
+}

+ 43 - 20
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcAsyncTask.java

@@ -4,14 +4,19 @@ import com.judong.chuanyiserver.dao.DataSourceDao;
 import com.judong.chuanyiserver.dao.ItemGroupDao;
 import com.judong.chuanyiserver.dao.RawDataDao;
 import com.judong.chuanyiserver.entity.*;
+import com.judong.chuanyiserver.enums.DataSourceTypeEnum;
 import com.judong.chuanyiserver.enums.ResultEnum;
 import com.judong.chuanyiserver.exception.CustomException;
 import com.judong.chuanyiserver.util.*;
 import lombok.extern.slf4j.Slf4j;
-import lombok.val;
 import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
 import org.eclipse.milo.opcua.stack.core.types.builtin.*;
+import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
 import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
+import org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResponse;
+import org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadResult;
+import org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadValueId;
+import org.eclipse.milo.opcua.stack.core.types.structured.ReadRawModifiedDetails;
 import org.openscada.opc.dcom.da.OPCSERVERSTATE;
 import org.openscada.opc.lib.da.Item;
 import org.openscada.opc.lib.da.*;
@@ -22,7 +27,6 @@ import org.springframework.stereotype.Component;
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Future;
 
 import static com.judong.chuanyiserver.util.KepOpcServerUtil.getVal;
@@ -139,6 +143,7 @@ public class OpcAsyncTask {
             }
         } catch (Exception e) {
             e.printStackTrace();
+            redisUtil.convertAndSend(ConstantStr.ITEM_GROUP, Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "组" + itemGroup.getGroupName() + "运行异常,错误信息为:" + e.getMessage()));
         } finally {
             server.dispose();
             redisUtil.del(ConstantStr.ITEM_GROUP + id);
@@ -149,35 +154,53 @@ public class OpcAsyncTask {
     //异步读取OpcUa
     public void runOpcUa(ItemGroup itemGroup, DataSource dataSource) throws Exception {
         Integer id = itemGroup.getId();
+        DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getId());
         OpcUaClient opcUaClient = OpcUaUtil.createClient(dataSource);
         List<com.judong.chuanyiserver.entity.Item> itemList = itemGroupDao.getItemListByGroupId(id);
-        List<NodeId> nodeIdList = OpcUaUtil.genNodeId(itemList);
         try {
             opcUaClient.connect().get();
-            Boolean flage = true;
-            while (flage) {
-                List<RawData> rawDataList = new ArrayList<>();
-                List<DataValue> valueList = opcUaClient.readValues(0.0, TimestampsToReturn.Neither, nodeIdList).get();
-                Date date = new Date();
-                for (DataValue dataValue : valueList) {
-                    StatusCode statusCode = dataValue.getStatusCode();
-                    if (Blank.isNotEmpty(statusCode)) {
-                        if (statusCode.isGood()) {
-                            Variant value = dataValue.getValue();
-                            ExpandedNodeId expandedNodeId = value.getDataType().get();
-                            rawDataList.add(new RawData(itemGroup.getDataSourceId(), expandedNodeId.getIdentifier().toString(), expandedNodeId.getType().toString(), value.getValue().toString(), date));
+            if (dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_UA_REAL.getValue())) {
+                Boolean flage = true;
+                List<NodeId> nodeIdList = OpcUaUtil.genNodeId(itemList);
+                while (flage) {
+                    List<RawData> rawDataList = new ArrayList<>();
+                    List<DataValue> valueList = opcUaClient.readValues(0.0, TimestampsToReturn.Neither, nodeIdList).get();
+                    Date date = new Date();
+                    for (DataValue dataValue : valueList) {
+                        StatusCode statusCode = dataValue.getStatusCode();
+                        if (Blank.isNotEmpty(statusCode)) {
+                            if (statusCode.isGood()) {
+                                Variant value = dataValue.getValue();
+                                ExpandedNodeId expandedNodeId = value.getDataType().get();
+                                rawDataList.add(new RawData(itemGroup.getDataSourceId(), expandedNodeId.getIdentifier().toString(), expandedNodeId.getType().toString(), value.getValue().toString(), date));
+                            }
                         }
                     }
+                    addRawDataList(id, rawDataList);
+                    Thread.sleep(itemGroup.getModeValue() * 1000);
+                    flage = (Boolean) redisUtil.get(ConstantStr.ITEM_GROUP + id);
+                    if (Blank.isEmpty(flage)) {
+                        flage = false;
+                    }
                 }
-                addRawDataList(id, rawDataList);
-                Thread.sleep(itemGroup.getModeValue() * 1000);
-                flage = (Boolean) redisUtil.get(ConstantStr.ITEM_GROUP + id);
-                if (Blank.isEmpty(flage)) {
-                    flage = false;
+            } else if (dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_UA_HISTORY.getValue())) {
+                List<HistoryReadValueId> historyReadValueIdList = OpcUaUtil.genHisNodeId(itemList);
+                List<RawData> rawDataList = new ArrayList<>();
+                Date date = new Date();
+                HistoryReadResponse historyReadResponse = opcUaClient.historyRead(new ReadRawModifiedDetails(false, DateTime.MIN_VALUE, DateTime.MIN_VALUE, UInteger.MAX, false),
+                        TimestampsToReturn.Both, true, historyReadValueIdList).get();
+                HistoryReadResult[] results = historyReadResponse.getResults();
+                for (HistoryReadResult historyReadResult : results) {
+                    System.out.println(historyReadResult);
+//                    rawDataList.add(new RawData(itemGroup.getDataSourceId(), expandedNodeId.getIdentifier().toString(), expandedNodeId.getType().toString(), value.getValue().toString(), date));
                 }
+                addRawDataList(id, rawDataList);
+            } else {
+                throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "目前还没有此种类型的连接方式");
             }
         } catch (Exception e) {
             e.printStackTrace();
+            redisUtil.convertAndSend(ConstantStr.ITEM_GROUP, Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "组" + itemGroup.getGroupName() + "运行异常,错误信息为:" + e.getMessage()));
         } finally {
             if (Blank.isNotEmpty(opcUaClient)) {
                 opcUaClient.disconnect();

+ 30 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/RedisConfig.java

@@ -1,17 +1,46 @@
 package com.judong.chuanyiserver.config;
 
+import com.judong.chuanyiserver.util.ConstantStr;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.listener.PatternTopic;
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
+import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
 import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 @Configuration
 public class RedisConfig {
 
+    /*
+     * Redis消息监听器容器
+     * 这个容器加载了RedisConnectionFactory和消息监听器
+     * 可以添加多个监听不同话题的redis监听器,只需要把消息监听器和相应的消息订阅处理器绑定,该消息监听器
+     * 通过反射技术调用消息订阅处理器的相关方法进行一些业务处理
+     */
     @Bean
-    public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+    public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, MessageListenerAdapter adapter) {
+        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
+        container.setConnectionFactory(connectionFactory);
+        //可以添加多个 messageListener
+        container.addMessageListener(adapter, new PatternTopic(ConstantStr.ITEM_GROUP));
+        return container;
+    }
+
+    /*
+     * 消息监听器适配器,绑定消息处理器,利用反射技术调用消息处理器的业务方法
+     * 将MessageReceiver注册为一个消息监听器,可以自定义消息接收的方法(handleMessage)
+     * 如果不指定消息接收的方法,消息监听器会默认的寻找MessageReceiver中的onMessage这个方法作为消息接收的方法
+     */
+    @Bean
+    public MessageListenerAdapter adapter(MessageReceiver messageReceiver) {
+        return new MessageListenerAdapter(messageReceiver, "onMessage");
+    }
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
         RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
         //key value序列化方式
         redisTemplate.setKeySerializer(new StringRedisSerializer());
@@ -22,6 +51,5 @@ public class RedisConfig {
         //注入连接工厂
         redisTemplate.setConnectionFactory(redisConnectionFactory);
         return redisTemplate;
-
     }
 }

+ 8 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/RawDataController.java

@@ -1,11 +1,14 @@
 package com.judong.chuanyiserver.controller;
 
 import com.judong.chuanyiserver.service.RawDataService;
+import com.judong.chuanyiserver.util.Result;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @RestController
 @RequestMapping("rawData")
@@ -14,4 +17,9 @@ public class RawDataController {
 
     @Resource
     private RawDataService rawDataService;
+
+    @GetMapping("/getDataByTimeType")
+    public Result getDataByTimeType(List<Integer> itemGroupIdList) {
+        return rawDataService.getDataByTimeType(itemGroupIdList);
+    }
 }

+ 17 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ReportTableController.java

@@ -0,0 +1,17 @@
+package com.judong.chuanyiserver.controller;
+
+import com.judong.chuanyiserver.service.ReportTableService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping("reportTable")
+@Slf4j
+public class ReportTableController {
+
+    @Resource
+    private ReportTableService reportTableService;
+}

+ 16 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/RoleController.java

@@ -193,4 +193,20 @@ public class RoleController {
         }
         return roleService.assignRoleAndMenu(role);
     }
+
+    /**
+     * 查看角色已有的菜单
+     *
+     */
+    @GetMapping("/queryRoleAndMenuId")
+    @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.ROLE, OperationEnum = OperationEnum.SELECT)
+    public Result queryRoleAndMenuId(Integer roleId){
+        if (Blank.isEmpty(roleId)){
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        }
+        return roleService.queryRoleAndMenuId(roleId);
+    }
+
+
 }

+ 7 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/ReportTableDao.java

@@ -0,0 +1,7 @@
+package com.judong.chuanyiserver.dao;
+
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ReportTableDao {
+}

+ 2 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/UserDao.java

@@ -70,6 +70,8 @@ public interface UserDao {
      */
     Integer updatePassWord(@Param("user") User user);
 
+    Integer queryUserName(String name);
+
 
 
 

+ 1 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/enums/ModelEnum.java

@@ -14,7 +14,7 @@ public enum ModelEnum {
     DATASOURCE("数据源","DATASOURCE"),
 
     SIGNIN("登录", "SIGNIN"), LOGOUT("退出登录", "LOGOUT"), REGISTER("注册", "REGISTER"), HOMEBYPAGE("首页", "HOMEBYPAGE"),
-    UPDATECODE("发送验证码", "UPDATECODE"), SEARCH("房源搜索", "SEARCH");
+    UPDATECODE("发送验证码", "UPDATECODE");
 
     private String value;
 

+ 6 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RawDataService.java

@@ -1,4 +1,10 @@
 package com.judong.chuanyiserver.service;
 
+import com.judong.chuanyiserver.util.Result;
+
+import java.util.List;
+
 public interface RawDataService {
+
+    Result getDataByTimeType(List<Integer> itemGroupIdList);
 }

+ 4 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/ReportTableService.java

@@ -0,0 +1,4 @@
+package com.judong.chuanyiserver.service;
+
+public interface ReportTableService {
+}

+ 5 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RoleService.java

@@ -38,4 +38,9 @@ public interface RoleService {
      * 为角色分配菜单
      */
     Result assignRoleAndMenu(Role role);
+
+    /**
+     * 查询角色已有菜单
+     */
+    Result queryRoleAndMenuId(Integer roleId);
 }

+ 8 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RawDataServiceImpl.java

@@ -2,10 +2,12 @@ package com.judong.chuanyiserver.service.impl;
 
 import com.judong.chuanyiserver.dao.RawDataDao;
 import com.judong.chuanyiserver.service.RawDataService;
+import com.judong.chuanyiserver.util.Result;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @Service
 @Transactional
@@ -13,4 +15,10 @@ public class RawDataServiceImpl implements RawDataService {
 
     @Resource
     private RawDataDao rawDataDao;
+
+    @Override
+    public Result getDataByTimeType(List<Integer> itemGroupIdList) {
+
+        return null;
+    }
 }

+ 16 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ReportTableServiceImpl.java

@@ -0,0 +1,16 @@
+package com.judong.chuanyiserver.service.impl;
+
+import com.judong.chuanyiserver.dao.ReportTableDao;
+import com.judong.chuanyiserver.service.ReportTableService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+
+@Service
+@Transactional
+public class ReportTableServiceImpl implements ReportTableService {
+
+    @Resource
+    private ReportTableDao reportTableDao;
+}

+ 5 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RoleServiceImpl.java

@@ -210,6 +210,11 @@ public class RoleServiceImpl implements RoleService {
         return Result.ok(jsonObject);
     }
 
+    @Override
+    public Result queryRoleAndMenuId(Integer roleId) {
+        return Result.ok(roleDao.queryRoleAndMenuId(roleId));
+    }
+
     public List<JSONObject> gennerMenuTree(List<Menu> menuList, Integer parentId) {
         List<JSONObject> jsonObjectList = new ArrayList<>();
         if (Blank.isEmpty(menuList)) {

+ 16 - 11
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/UserServiceImpl.java

@@ -120,10 +120,15 @@ public class UserServiceImpl implements UserService {
      */
     @Override
     public Result backUserLogin(User user) {
+        //判断账号是否存在
+        Integer userName = userDao.queryUserName(user.getUserName());
+        if (userName<=0){
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "用户名不存在");
+        }
         //获取登陆失败次数
         Integer count = (Integer) redisUtil.get("Number of password errors:" + user.getUserName());
-        if (Blank.isEmpty(count)){
-            count=0;
+        if (Blank.isEmpty(count)) {
+            count = 0;
         }
         try {
             user.setPassword(RSAUtil.decrypt(user.getPassword(), "UTF-8"));
@@ -134,8 +139,8 @@ public class UserServiceImpl implements UserService {
         if (Blank.isEmpty(isExistUser)) {
             //记录登陆失败次数
             count++;
-            if (count>=5){
-                if (count.equals(5)){
+            if (count >= 5) {
+                if (count.equals(5)) {
                     //账号锁定5分钟
                     redisUtil.set("Number of password errors:" + user.getUserName(), count, 300);
                 }
@@ -143,9 +148,9 @@ public class UserServiceImpl implements UserService {
                 long minutes = expire / 60;
                 long second = expire % 60;
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "密码错误次数过多账号已锁定,请" + minutes + "分" + second + "秒后再试");
-            }else {
+            } else {
                 redisUtil.set("Number of password errors:" + user.getUserName(), count, 300);
-                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(),  "密码错误,还可尝试" + (5 - count) + "次");
+                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "密码错误,还可尝试" + (5 - count) + "次");
             }
         }
         if (isExistUser.getUserType() != ConstantStr.BACK_USER) {
@@ -375,7 +380,7 @@ public class UserServiceImpl implements UserService {
     @Override
     public Result relieveUserRoles(List<UserRole> userRoles) {
         Integer num = userDao.deleteByUserIdRoleIds(userRoles);
-        if (num<=0){
+        if (num <= 0) {
             return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "解除角色失败");
         }
         return Result.ok(num);
@@ -391,12 +396,12 @@ public class UserServiceImpl implements UserService {
         } catch (Exception e) {
             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
-        if (Blank.isEmpty(oldPassword,newPassword)){
+        if (Blank.isEmpty(oldPassword, newPassword)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据有误");
         }
         //判断原始密码是否正确
         User isExistUser = userDao.getUserByNamePass(user.getUserName(), EncryptUtils.StrToMD5(oldPassword));
-        if (isExistUser==null){
+        if (isExistUser == null) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "旧密码输入错误");
         }
         //修改密码
@@ -408,7 +413,7 @@ public class UserServiceImpl implements UserService {
     @Override
     public Result updatePasswordByAdmin(User user) {
         //判断当前登陆人是否是管理员
-        if (! userUtil.haveAdminRights()){
+        if (!userUtil.haveAdminRights()) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "没有操作权限");
         }
         String newPassword;
@@ -417,7 +422,7 @@ public class UserServiceImpl implements UserService {
         } catch (Exception e) {
             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
-        if (Blank.isEmpty(newPassword)){
+        if (Blank.isEmpty(newPassword)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据有误");
         }
         user.setNewPassword(EncryptUtils.StrToMD5(newPassword));

+ 6 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/MathUtil.java

@@ -12,11 +12,15 @@ public class MathUtil {
 
     /**
      * 四则混合运算
+     *
+     * @param parameter  变量代表字符串
+     * @param MathString 数学表达式字符串
+     * @param value      变量值
+     * @return
+     * @throws ParseException
      */
     public static BigDecimal quadricOperation(String parameter, String MathString, Long value) throws ParseException {
         Scope scope = new Scope();
-//        Variable a = scope.getVariable("BBC");
-//        Expression expr = Parser.parse("-2*(BBC+25)+2/7+18*2^2", scope);
         Variable a = scope.getVariable(parameter);
         Expression expr = Parser.parse(MathString, scope);
         a.setValue(value);

+ 14 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/OpcUaUtil.java

@@ -22,6 +22,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned;
 import org.eclipse.milo.opcua.stack.core.types.enumerated.IdType;
 import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
 import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
+import org.eclipse.milo.opcua.stack.core.types.structured.HistoryReadValueId;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -196,6 +197,19 @@ public class OpcUaUtil {
         return nodeIdList;
     }
 
+    public static List<HistoryReadValueId> genHisNodeId(List<Item> itemList) {
+        if (Blank.isEmpty(itemList)) {
+            return null;
+        }
+        List<HistoryReadValueId> historyReadValueIdList = new ArrayList<>();
+        for (Item item : itemList) {
+            HistoryReadValueId historyReadValueId = new HistoryReadValueId(new NodeId(item.getNodeIndex(), item.getNodeIdentifier()),
+                    null, QualifiedName.NULL_VALUE, null);
+            historyReadValueIdList.add(historyReadValueId);
+        }
+        return historyReadValueIdList;
+    }
+
     public static List<JSONObject> opcUaReadNodeIdList(DataSource dataSource, List<NodeId> nodeIdList) {
         OpcUaClient client = null;
         try {

+ 5 - 0
chuanyi_server/src/main/resources/mapper/ReportTableDao.xml

@@ -0,0 +1,5 @@
+<?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.judong.chuanyiserver.dao.ReportTableDao">
+
+</mapper>

+ 3 - 1
chuanyi_server/src/main/resources/mapper/RoleDao.xml

@@ -46,13 +46,15 @@
                role_code
         FROM sys_role
         WHERE role_name = #{roleName}
+        and is_delete !=1
     </select>
 
     <select id="getRoleByNoIdName" resultType="com.judong.chuanyiserver.entity.Role">
         select id, role_name
         from sys_role
         where id != #{id}
-          and role_name = #{roleName}
+        and role_name = #{roleName}
+        and is_delete !=1
     </select>
 
     <select id="getRoleCount" resultType="java.lang.Long">

+ 4 - 0
chuanyi_server/src/main/resources/mapper/UserDao.xml

@@ -225,6 +225,10 @@
         where user_id = #{user.userId}
     </update>
 
+    <select id="queryUserName" resultType="java.lang.Integer">
+        SELECT count(*) FROM sys_user WHERE BINARY user_name=#{name} and state!=2
+    </select>
+