Просмотр исходного кода

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

ljh 2 лет назад
Родитель
Сommit
b5c833123f
20 измененных файлов с 373 добавлено и 95 удалено
  1. 6 0
      chuanyi_server/pom.xml
  2. 0 23
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/KepOpcServerTimerTask.java
  3. 8 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcAsyncTask.java
  4. 3 3
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/ThreadPoolConfig.java
  5. 16 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/RoleController.java
  6. 10 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/FileDao.java
  7. 15 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/RoleDao.java
  8. 44 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/entity/FileEntity.java
  9. 6 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RoleService.java
  10. 0 7
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ChannelSettingServiceImpl.java
  11. 6 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/MenuServiceImpl.java
  12. 34 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RoleServiceImpl.java
  13. 17 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/task/KepServerTimerTask.java
  14. 17 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/task/OpcUaTimerTask.java
  15. 98 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/FileUtil.java
  16. 0 54
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/Test.java
  17. 53 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/TestUtil.java
  18. 1 1
      chuanyi_server/src/main/resources/mapper/DepartmentDao.xml
  19. 10 0
      chuanyi_server/src/main/resources/mapper/FileDao.xml
  20. 29 0
      chuanyi_server/src/main/resources/mapper/RoleDao.xml

+ 6 - 0
chuanyi_server/pom.xml

@@ -164,6 +164,12 @@
             <version>0.6.3</version>
         </dependency>
         <!--opcUa读取依赖-->
+
+        <!--Test依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 0 - 23
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/KepOpcServerTimerTask.java

@@ -1,23 +0,0 @@
-package com.judong.chuanyiserver.config;
-
-import com.judong.chuanyiserver.entity.ChannelSetting;
-import com.judong.chuanyiserver.entity.ServerInformation;
-
-import java.util.List;
-import java.util.TimerTask;
-
-public class KepOpcServerTimerTask extends TimerTask {
-
-    public ServerInformation serverInformation;
-    public List<ChannelSetting> channelSettingList;
-
-    public KepOpcServerTimerTask(ServerInformation serverInformation, List<ChannelSetting> channelSettingList) {
-        this.serverInformation = serverInformation;
-        this.channelSettingList = channelSettingList;
-    }
-
-    @Override
-    public void run() {
-        System.out.println("----");
-    }
-}

+ 8 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcAsyncTask.java

@@ -7,6 +7,8 @@ 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.task.KepServerTimerTask;
+import com.judong.chuanyiserver.task.OpcUaTimerTask;
 import com.judong.chuanyiserver.util.*;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
@@ -32,7 +34,7 @@ import java.util.concurrent.Future;
 import static com.judong.chuanyiserver.util.KepOpcServerUtil.getVal;
 
 @Component
-@Async("asyncThreadPoolTaskExecutor")
+@Async("threadPoolTaskExecutor")
 @Slf4j
 public class OpcAsyncTask {
 
@@ -58,6 +60,11 @@ public class OpcAsyncTask {
         log.info("异步任务B在执行,时间是:" + System.currentTimeMillis());
     }
 
+    public void testXXX(){
+        Timer timer = new Timer();
+        timer.schedule(new OpcUaTimerTask(),1000,2000);
+    }
+
     public Future<String> testC(String xx) {
         return new AsyncResult(xx);
     }

+ 3 - 3
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/AsyncThreadPoolConfig.java → chuanyi_server/src/main/java/com/judong/chuanyiserver/config/ThreadPoolConfig.java

@@ -7,10 +7,10 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 
 /**
- * OPC线程池配置
+ * 线程池配置
  */
 @Configuration
-public class AsyncThreadPoolConfig {
+public class ThreadPoolConfig {
 
     private static final int corePoolSize = 10;               // 默认线程数
     private static final int maxPoolSize = 100;                // 最大线程数
@@ -20,7 +20,7 @@ public class AsyncThreadPoolConfig {
     private static final int awaitTerminationSeconds = 0;
     private static final String threadNamePrefix = "Async-Thread-"; // 线程池名前缀
 
-    @Bean("asyncThreadPoolTaskExecutor") // bean的名称,默认为首字母小写的方法名
+    @Bean("threadPoolTaskExecutor") // bean的名称,默认为首字母小写的方法名
     public ThreadPoolTaskExecutor taskExecutor(){
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(corePoolSize);

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

@@ -201,11 +201,25 @@ public class RoleController {
     @GetMapping("/queryRoleAndMenuId")
     @PermissionControl
     @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.ROLE, OperationEnum = OperationEnum.SELECT)
-    public Result queryRoleAndMenuId(Integer roleId){
+    public Result queryRoleAndMenuId(Integer roleId,Integer page,Integer num){
         if (Blank.isEmpty(roleId)){
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
-        return roleService.queryRoleAndMenuId(roleId);
+        return roleService.queryRoleAndMenuId(roleId,page,num);
+    }
+
+    /**
+     * 查看角色未有的菜单
+     *
+     */
+    @GetMapping("/queryNotRoleAndMenu")
+    @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.ROLE, OperationEnum = OperationEnum.SELECT)
+    public Result queryNotRoleAndMenu(Integer roleId,Integer page,Integer num){
+        if (Blank.isEmpty(roleId)){
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        }
+        return roleService.queryNotRoleAndMenu(roleId,page,num);
     }
 
 

+ 10 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/FileDao.java

@@ -0,0 +1,10 @@
+package com.judong.chuanyiserver.dao;
+
+import com.judong.chuanyiserver.entity.FileEntity;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface FileDao {
+
+    Integer saveFile(FileEntity fileEntity);
+}

+ 15 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/RoleDao.java

@@ -62,7 +62,7 @@ public interface RoleDao {
     List<Role> queryRoleByRoleIds(@Param("ids") List<Integer> ids);
 
     /**
-     * 查询角色对应菜单的角色菜单id
+     * 查询角色对应菜单
      */
     List<Integer> queryRoleAndMenuId(Integer roleId);
 
@@ -76,5 +76,19 @@ public interface RoleDao {
      */
     Integer deleteRoleAndMenu(@Param("role") Role role);
 
+    /**
+     * 查询角色未有菜单
+     */
+    List<Menu> queryNotRoleAndMenu(Integer roleId,Integer page,Integer num);
+
+    Integer queryNotRoleAndMenuNum(Integer roleId);
+
+    /**
+     * 查询角色已有菜单分页
+     */
+    List<Menu> queryRoleAndMenuIdPage(Integer roleId,Integer page,Integer num);
+
+    Integer queryRoleAndMenuIdNum(Integer roleId);
+
 
 }

+ 44 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/entity/FileEntity.java

@@ -0,0 +1,44 @@
+package com.judong.chuanyiserver.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class FileEntity implements Serializable {
+
+    private static final long serialVersionUID = -96536212774977561L;
+
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 保存的路径
+     */
+    private String filePath;
+    /**
+     * 文件原始名称
+     */
+    private String originalFileName;
+    /**
+     * 保存的文件名称
+     */
+    private String saveFileName;
+    /**
+     * 文件后缀名
+     */
+    private String suffixName;
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+    public FileEntity(String filePath, String originalFileName, String saveFileName, String suffixName) {
+        this.filePath = filePath;
+        this.originalFileName = originalFileName;
+        this.saveFileName = saveFileName;
+        this.suffixName = suffixName;
+    }
+
+}

+ 6 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/RoleService.java

@@ -42,5 +42,10 @@ public interface RoleService {
     /**
      * 查询角色已有菜单
      */
-    Result queryRoleAndMenuId(Integer roleId);
+    Result queryRoleAndMenuId(Integer roleId,Integer page,Integer num);
+
+    /**
+     * 查询角色未有菜单
+     */
+    Result queryNotRoleAndMenu(Integer roleId,Integer page,Integer num);
 }

+ 0 - 7
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ChannelSettingServiceImpl.java

@@ -1,7 +1,6 @@
 package com.judong.chuanyiserver.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
-import com.judong.chuanyiserver.config.KepOpcServerTimerTask;
 import com.judong.chuanyiserver.config.OpcAsyncTask;
 import com.judong.chuanyiserver.dao.ChannelSettingDao;
 import com.judong.chuanyiserver.dao.ConnectDao;
@@ -19,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Timer;
 
 @Service
 @Transactional
@@ -179,14 +177,11 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
             if (KepOpcServerUtil.validationServerInformation(serverInformation)) {
                 if (runState==ConstantStr.START_UP){
                     //将配置的状态更换为运行
-                    Timer timer = new Timer(true);
-                    timer.scheduleAtFixedRate(new KepOpcServerTimerTask(serverInformation,channelSettingList),0,1*1000);
 
 //                    opcAsyncTask.KepServerReadItemList(serverInformation, channelSettingList);
                 }else{
                     //将配置的状态更换为停止
 
-                    opcAsyncTask.KepServerCloseReadItemList(serverInformation, channelSettingList);
                 }
                 return Result.ok("操作成功");
             }
@@ -194,9 +189,7 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
         } else if (serverInformation.getConnectMode() == ConnectModeEnum.KingOPCServer.getValue()) {
             if (OpcServerUaUtil.validationServerInformation(serverInformation)) {
                 if (runState==ConstantStr.START_UP){
-                    opcAsyncTask.OpcServerUaReadItemList(serverInformation, channelSettingList);
                 }else{
-                    opcAsyncTask.OpcServerUaCloseReadItemList(serverInformation, channelSettingList);
                 }
                 return Result.ok("操作成功");
             }

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

@@ -28,6 +28,9 @@ public class MenuServiceImpl implements MenuService {
         if (Blank.isEmpty(menu.getParentId(), menu.getMenuName(), menu.getMenuUrl())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "父id,菜单名称,菜单路径不能为空");
         }
+        if (menu.getId()==menu.getParentId()){
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "无效菜单,请重试!");
+        }
         if (menu.getParentId() == ConstantStr.TOP_LEVEL_MENU) {
             if (Blank.isNotEmpty(menuDao.getMenuByName(menu.getMenuName(),0))) {
                 return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该顶级菜单名称已被使用,请更换其他顶级菜单名称");
@@ -53,6 +56,9 @@ public class MenuServiceImpl implements MenuService {
         if (Blank.isEmpty(menu.getId(), menu.getMenuName(), menu.getMenuUrl(), menu.getMenuStatus())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "id,菜单名称,菜单路径,菜单状态不能为空");
         }
+        if (menu.getId()==menu.getParentId()){
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "无效菜单,请重试!");
+        }
         Menu oldMenu = menuDao.getMenuById(menu.getId());
         if (oldMenu.getParentId() == ConstantStr.TOP_LEVEL_MENU) {
             if (Blank.isNotEmpty(menuDao.getMenuByNoIdName(menu.getId(), menu.getMenuName(),0))) {

+ 34 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/RoleServiceImpl.java

@@ -1,6 +1,7 @@
 package com.judong.chuanyiserver.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.judong.chuanyiserver.dao.MenuDao;
 import com.judong.chuanyiserver.dao.RoleDao;
 import com.judong.chuanyiserver.entity.Menu;
 import com.judong.chuanyiserver.entity.Role;
@@ -27,6 +28,9 @@ public class RoleServiceImpl implements RoleService {
     @Resource
     private UserUtil userUtil;
 
+    @Resource
+    private MenuDao menuDao;
+
     @Override
     public synchronized Result addRole(Role role) {
         if (Blank.isNotEmpty(roleDao.getRoleByName(role.getRoleName()))) {
@@ -211,10 +215,38 @@ public class RoleServiceImpl implements RoleService {
     }
 
     @Override
-    public Result queryRoleAndMenuId(Integer roleId) {
-        return Result.ok(roleDao.queryRoleAndMenuId(roleId));
+    public Result queryRoleAndMenuId(Integer roleId,Integer page,Integer num) {
+        JSONObject jsonObject = new JSONObject();
+        Integer count = roleDao.queryRoleAndMenuIdNum(roleId);
+        Integer stattPage=(page-1)*num;
+        List<Menu> menuList = roleDao.queryRoleAndMenuIdPage(roleId, stattPage, num);
+        jsonObject.put("count",count);
+        jsonObject.put("menuList",menuList);
+        return Result.ok(jsonObject);
     }
 
+    @Override
+    public Result queryNotRoleAndMenu(Integer roleId, Integer page, Integer num) {
+        JSONObject jsonObject = new JSONObject();
+        Integer count = roleDao.queryNotRoleAndMenuNum(roleId);
+        Integer stattPage=(page-1)*num;
+        List<Menu> menuList = roleDao.queryNotRoleAndMenu(roleId, stattPage, num);
+        jsonObject.put("count",count);
+        jsonObject.put("menuList",menuList);
+        return Result.ok(jsonObject);
+    }
+
+    public List<Menu> menuChildren(Integer parentId){
+        List<Menu> menus = new ArrayList<>();
+        List<Menu> menuList = menuDao.queryAllMenuTree(parentId);
+        for (Menu menu:menuList){
+            menu.setChildren(menuChildren(menu.getId()));
+            menus.add(menu);
+        }
+        return menus;
+    }
+
+
     public List<JSONObject> gennerMenuTree(List<Menu> menuList, Integer parentId) {
         List<JSONObject> jsonObjectList = new ArrayList<>();
         if (Blank.isEmpty(menuList)) {

+ 17 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/task/KepServerTimerTask.java

@@ -0,0 +1,17 @@
+package com.judong.chuanyiserver.task;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.TimerTask;
+
+@Slf4j
+public class KepServerTimerTask extends TimerTask {
+
+    @Override
+    public void run() {
+        for (int i = 0; i < 1000; i++) {
+
+        }
+        log.info("前面是kepserver线程的信息,请查看");
+    }
+}

+ 17 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/task/OpcUaTimerTask.java

@@ -0,0 +1,17 @@
+package com.judong.chuanyiserver.task;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+
+import java.util.TimerTask;
+
+@Slf4j
+public class OpcUaTimerTask extends TimerTask {
+    @Override
+    public void run() {
+        for (int i = 0; i < 1000; i++) {
+
+        }
+        log.info("前面opcUa执行的线程信息,请查看");
+    }
+}

+ 98 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/FileUtil.java

@@ -0,0 +1,98 @@
+package com.judong.chuanyiserver.util;
+
+import cn.hutool.core.io.FileTypeUtil;
+import com.judong.chuanyiserver.dao.FileDao;
+import com.judong.chuanyiserver.entity.FileEntity;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.util.Calendar;
+import java.util.Date;
+
+@Slf4j
+@Component
+@Transactional
+public class FileUtil {
+
+    @Value("${file.path}")
+    private String filePath;
+
+    @Resource
+    private FileDao fileDao;
+
+    /**
+     * 上传单个上传文件
+     *
+     * @param file
+     */
+    public void fileOneUpload(MultipartFile file) {
+        if (Blank.isEmpty(file)) {
+            return;
+        }
+        Calendar cal = Calendar.getInstance();
+        Date date = new Date();//现在的日期
+        cal.setTime(date);
+        Integer year = cal.get(Calendar.YEAR);//获取年
+        Integer month = cal.get(Calendar.MONTH) + 1;//获取月(月份从0开始,如果按照中国的习惯,需要加一)
+        Integer day_moneth = cal.get(Calendar.DAY_OF_MONTH);//获取日(月中的某一天)
+        String fileSavePath = filePath + "\\" + year + "\\" + month + "\\" + day_moneth;
+        File file1 = new File(fileSavePath);
+        if (!file1.exists() && !file1.isDirectory()) {
+            file1.mkdirs();
+        }
+        String originalFileName = file.getOriginalFilename();
+        String suffixName = FileTypeUtil.getType((File) file);
+        String saveFileName = (new Date()).getTime() + ((int) (Math.random() * 90000) + 10000) + "." + suffixName;
+        FileEntity fileEntity = new FileEntity(fileSavePath, originalFileName, saveFileName, suffixName);
+        if (fileDao.saveFile(fileEntity) <= 0) {
+            return;
+        }
+        File newFile = new File(fileSavePath + "\\" + saveFileName);
+        try {
+            file.transferTo(newFile);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 上传多个文件
+     *
+     * @param files
+     */
+    public void fileManyUpload(MultipartFile[] files) {
+        if (Blank.isEmpty(files)) {
+            return;
+        }
+        Calendar cal = Calendar.getInstance();
+        Date date = new Date();//现在的日期
+        cal.setTime(date);
+        Integer year = cal.get(Calendar.YEAR);//获取年
+        Integer month = cal.get(Calendar.MONTH) + 1;//获取月(月份从0开始,如果按照中国的习惯,需要加一)
+        Integer day_moneth = cal.get(Calendar.DAY_OF_MONTH);//获取日(月中的某一天)
+//        Integer day_week=cal.get(Calendar.DAY_OF_WEEK);//获取一周内的某一天
+        for (MultipartFile file : files) {
+            String fileSavePath = filePath + "\\" + year + "\\" + month + "\\" + day_moneth;
+            String originalFileName = file.getOriginalFilename();
+            String suffixName = FileTypeUtil.getType((File) file);
+            String saveFileName = (new Date()).getTime() + ((int) (Math.random() * 90000) + 10000) + "." + suffixName;
+            FileEntity fileEntity = new FileEntity(fileSavePath, originalFileName, saveFileName, suffixName);
+            Integer integer = fileDao.saveFile(fileEntity);
+        }
+    }
+
+    public void fileUpload(HttpServletRequest request, HttpServletResponse response) {
+
+    }
+
+    public static void fileDownload(MultipartFile[] files) {
+
+    }
+}

+ 0 - 54
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/Test.java

@@ -1,54 +0,0 @@
-package com.judong.chuanyiserver.util;
-
-import com.alibaba.fastjson.JSONObject;
-import com.judong.chuanyiserver.enums.ConnectModeEnum;
-import com.judong.chuanyiserver.enums.ResultEnum;
-import com.judong.chuanyiserver.exception.CustomException;
-import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
-import org.eclipse.milo.opcua.sdk.client.api.UaClient;
-import org.eclipse.milo.opcua.stack.core.Stack;
-import org.openscada.opc.dcom.da.OPCSERVERSTATE;
-import org.openscada.opc.lib.common.ConnectionInformation;
-import org.openscada.opc.lib.da.Server;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-
-public class Test {
-
-    private static Logger logger = LoggerFactory.getLogger(Test.class);
-
-    public static void main(String[] args) throws Exception {
-        final ConnectionInformation ci = new ConnectionInformation();
-        ci.setHost("192.168.0.252"); // 安装opc电脑IP
-        ci.setDomain(""); // 域,为空就行
-        ci.setUser("administrator"); // 电脑上自己建好的用户名
-        ci.setPassword("jd123456"); // 用户名的密码
-        // 使用KepOPC Server的配置
-        ci.setClsid(ConnectModeEnum.KEPOPCSERVER.getName()); // KEPServer的注册表ID,可以在“组件服务”里看到
-        Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
-        try {
-            // 连接到服务
-            long start = System.currentTimeMillis();
-            server.connect();
-            long finish = System.currentTimeMillis();
-            if (null == server.getServerState()) {
-                logger.info("连接失败");
-            }
-            if (OPCSERVERSTATE.OPC_STATUS_RUNNING == server.getServerState().getServerState()) {
-                logger.info("连接成功");
-            }
-        } catch (Exception e) {
-            logger.info(e.getMessage());
-        } finally {
-            //关闭连接使用
-            server.dispose();
-        }
-    }
-
-
-}

+ 53 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/TestUtil.java

@@ -0,0 +1,53 @@
+package com.judong.chuanyiserver.util;
+
+import com.judong.chuanyiserver.config.OpcAsyncTask;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+@Slf4j
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class TestUtil {
+
+    @Resource
+    public OpcAsyncTask opcAsyncTask;
+
+    @Test
+    public void test() {
+//        opcAsyncTask.testA();
+//        opcAsyncTask.testB();
+
+        TimerTask timerTask = new TimerTask() {
+            @Override
+            public void run() {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
+                int n = 0;
+                long l1 = System.currentTimeMillis();
+                for (int i = 0; i <100000000 ; i++) {
+                    for (int j = 0; j < 100000000; j++) {
+                        n=i*j;
+//                        System.out.println(n);
+                    }
+                }
+                System.out.println(n);
+                long l2 = System.currentTimeMillis();
+                System.out.println(l2 - l1);
+                log.info(sdf.format(new Date(System.currentTimeMillis())));
+            }
+        };
+        Timer timer = new Timer();
+        timer.schedule(timerTask, 0, 1000);
+        //        timer.cancel();
+    }
+
+
+}

+ 1 - 1
chuanyi_server/src/main/resources/mapper/DepartmentDao.xml

@@ -75,7 +75,7 @@
     <!--根据父id查子数据-->
     <select id="queryDepartmentListByparentId" resultType="com.judong.chuanyiserver.entity.Department">
         SELECT id, parent_id, department_name, department_describe, department_num, create_time, update_time
-        FROM sys_department WHERE parent_id=#{parentId} and is_delete !=1
+        FROM sys_department WHERE parent_id=#{parentId} and is_delete !=1 order by department_num ASC
     </select>
 
     <!--根据id查自己是哪些的父亲-->

+ 10 - 0
chuanyi_server/src/main/resources/mapper/FileDao.xml

@@ -0,0 +1,10 @@
+<?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.FileDao">
+
+
+    <insert id="saveFile">
+        insert into t_file(file_path, original_file_name, save_file_name, suffix_name, create_time)
+            value (#{filePath}, #{originalFileName}, #{saveFileName}, #{suffixName}, now())
+    </insert>
+</mapper>

+ 29 - 0
chuanyi_server/src/main/resources/mapper/RoleDao.xml

@@ -187,4 +187,33 @@
         </foreach>)
     </delete>
 
+    <select id="queryNotRoleAndMenu" resultType="com.judong.chuanyiserver.entity.Menu">
+        SELECT id,parent_id,menu_name,menu_url,menu_icon,sort_num,menu_status,update_time FROM sys_menu WHERE id NOT IN
+        (SELECT menu_id from sys_role_menu WHERE role_id=#{roleId})
+        and menu_status=1
+        ORDER BY sort_num ASC
+        LIMIT #{page},#{num}
+    </select>
+
+    <select id="queryNotRoleAndMenuNum" resultType="java.lang.Integer">
+        SELECT count(*) FROM sys_menu WHERE id NOT IN
+        (SELECT menu_id from sys_role_menu WHERE role_id=#{roleId})
+        and menu_status=1
+    </select>
+
+    <select id="queryRoleAndMenuIdPage" resultType="com.judong.chuanyiserver.entity.Menu">
+        SELECT id,parent_id,menu_name,menu_url,menu_icon,sort_num,menu_status,update_time FROM sys_menu WHERE id  IN
+        (SELECT menu_id from sys_role_menu WHERE role_id=#{roleId})
+        and menu_status=1
+        ORDER BY sort_num ASC
+        LIMIT #{page},#{num}
+    </select>
+
+    <select id="queryRoleAndMenuIdNum" resultType="java.lang.Integer">
+        SELECT count(*) FROM sys_menu WHERE id  IN
+        (SELECT menu_id from sys_role_menu WHERE role_id=#{roleId})
+--         AND parent_id=0
+        and menu_status=1
+    </select>
+
 </mapper>