浏览代码

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

FinalYu 2 年之前
父节点
当前提交
d9572d52d7

+ 0 - 17
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/AsyncTask.java

@@ -1,17 +0,0 @@
-package com.judong.chuanyiserver.config;
-
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-@Component
-@Async
-public class AsyncTask {
-
-    public void testA() {
-        System.out.println("异步任务A在执行");
-    }
-
-    public void testB() {
-        System.out.println("异步任务B在执行");
-    }
-}

+ 26 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcAsyncTask.java

@@ -0,0 +1,26 @@
+package com.judong.chuanyiserver.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.AsyncResult;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.Future;
+
+@Component
+@Async("opcThreadPoolTaskExecutor")
+@Slf4j
+public class OpcAsyncTask {
+
+    public void testA() {
+        log.info("异步任务A在执行,时间是:" + System.currentTimeMillis());
+    }
+
+    public void testB() {
+        log.info("异步任务B在执行,时间是:" + System.currentTimeMillis());
+    }
+
+    public Future<String> testC(String xx){
+        return new AsyncResult(xx);
+    }
+}

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

@@ -18,9 +18,9 @@ public class OpcThreadPoolConfig {
     private static final int queueCapacity = 200;            // 缓冲队列数
     private static final boolean waitForTasksToCompleteOnShutdown = false;// 当任务完成后,长时间无待处理任务时,销毁线程池
     private static final int awaitTerminationSeconds = 0;
-    private static final String threadNamePrefix = "thread-"; // 线程池名前缀
+    private static final String threadNamePrefix = "Opc-Thread-"; // 线程池名前缀
 
-    @Bean("threadPoolTaskExecutor") // bean的名称,默认为首字母小写的方法名
+    @Bean("opcThreadPoolTaskExecutor") // bean的名称,默认为首字母小写的方法名
     public ThreadPoolTaskExecutor taskExecutor(){
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(corePoolSize);

+ 29 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ChannelSettingController.java

@@ -1,7 +1,11 @@
 package com.judong.chuanyiserver.controller;
 
+import com.judong.chuanyiserver.annotation.WebLog;
 import com.judong.chuanyiserver.entity.ChannelSetting;
+import com.judong.chuanyiserver.enums.ModelEnum;
+import com.judong.chuanyiserver.enums.OperationEnum;
 import com.judong.chuanyiserver.enums.ResultEnum;
+import com.judong.chuanyiserver.enums.ServerEnum;
 import com.judong.chuanyiserver.service.ChannelSettingService;
 import com.judong.chuanyiserver.util.Blank;
 import com.judong.chuanyiserver.util.Result;
@@ -25,8 +29,9 @@ public class ChannelSettingController {
      * @return
      */
     @PostMapping("/channelSetting")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.PASSAGEWAY, OperationEnum = OperationEnum.ADD)
     public Result channelSetting(@RequestBody ChannelSetting channelSetting) {
-        if (Blank.isEmpty(channelSetting, channelSetting.getServerId(), channelSetting.getChannelName())) {
+        if (Blank.isEmpty(channelSetting, channelSetting.getServerId(), channelSetting.getChannelName(), channelSetting.getReadMechanism(), channelSetting.getReadPolicy(), channelSetting.getPolicyValue())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
         return channelSettingService.channelSetting(channelSetting);
@@ -40,6 +45,7 @@ public class ChannelSettingController {
      * @return
      */
     @GetMapping("/getChannelSetting")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.PASSAGEWAY, OperationEnum = OperationEnum.SELECT)
     public Result getChannelSetting(Integer serverId, String channelName) {
         if (Blank.isEmpty(serverId, channelName)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -54,6 +60,7 @@ public class ChannelSettingController {
      * @return
      */
     @GetMapping("/getConnectTree")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.SELECT)
     public Result getConnectTree(Integer serverId) throws Exception {
         if (Blank.isEmpty(serverId)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -68,6 +75,7 @@ public class ChannelSettingController {
      * @return
      */
     @PostMapping("/assignChannelSettingList")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.ADD)
     public Result assignChannelSettingList(@RequestBody ChannelSetting channelSetting) {
         if (Blank.isEmpty(channelSetting, channelSetting.getServerId(), channelSetting.getChannelNameList(), channelSetting.getConfigName())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -83,6 +91,7 @@ public class ChannelSettingController {
      * @return
      */
     @PostMapping("/renameConfig")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.UPDATE)
     public Result renameConfig(Integer configId, String configName) {
         if (Blank.isEmpty(configId, configName)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -97,6 +106,7 @@ public class ChannelSettingController {
      * @return
      */
     @GetMapping("/selectConfig/{configId}")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.SELECT)
     public Result selectConfig(@PathVariable Integer configId) {
         if (Blank.isEmpty(configId)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -111,6 +121,7 @@ public class ChannelSettingController {
      * @return
      */
     @PostMapping("/deleteConfig/{configId}")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.DELETE)
     public Result deleteConfig(@PathVariable Integer configId) {
         if (Blank.isEmpty(configId)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -126,10 +137,27 @@ public class ChannelSettingController {
      * @return
      */
     @PostMapping("/runConfigById")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.RUNNING, OperationEnum = OperationEnum.READ)
     public Result runConfigById(Integer configId, Integer runState) throws Exception {
         if (Blank.isEmpty(configId, runState)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
         return channelSettingService.runConfigById(configId, runState);
     }
+
+    /**
+     * 传入服务器id从新获取配置信息
+     *
+     * @param serverId
+     * @return
+     */
+    @GetMapping("/getConfigList")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONFIGURE, OperationEnum = OperationEnum.SELECT)
+    public Result getConfigList(Integer serverId) {
+        if (Blank.isEmpty(serverId)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        }
+        return channelSettingService.getConfigList(serverId);
+    }
+
 }

+ 12 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ConnectController.java

@@ -1,7 +1,11 @@
 package com.judong.chuanyiserver.controller;
 
+import com.judong.chuanyiserver.annotation.WebLog;
 import com.judong.chuanyiserver.entity.ServerInformation;
+import com.judong.chuanyiserver.enums.ModelEnum;
+import com.judong.chuanyiserver.enums.OperationEnum;
 import com.judong.chuanyiserver.enums.ResultEnum;
+import com.judong.chuanyiserver.enums.ServerEnum;
 import com.judong.chuanyiserver.service.ConnectService;
 import com.judong.chuanyiserver.util.Blank;
 import com.judong.chuanyiserver.util.Result;
@@ -34,6 +38,7 @@ public class ConnectController {
      * @throws UnknownHostException
      */
     @PostMapping("/testConnect")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.TEST)
     public Result testConnect(@RequestBody ServerInformation serverInformation) {
         if (Blank.isEmpty(serverInformation, serverInformation.getConnectName(), serverInformation.getConnectMode(), serverInformation.getIpAddress())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -49,6 +54,7 @@ public class ConnectController {
      */
     @PostMapping("/saveConnect")
 //    @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.ADD)
     public Result saveConnect(@RequestBody ServerInformation serverInformation) {
         if (Blank.isEmpty(serverInformation, serverInformation.getConnectName(), serverInformation.getConnectMode(), serverInformation.getIpAddress())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -62,6 +68,7 @@ public class ConnectController {
      * @return
      */
     @GetMapping("/selectAllConnect")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.SELECT)
     public Result selectAllConnect() {
         return connectService.selectAllConnect();
     }
@@ -79,6 +86,7 @@ public class ConnectController {
      * @throws AddFailedException
      */
     @GetMapping("/openConnect")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.OPEN)
     public Result openConnect(Integer id) throws Exception {
         if (Blank.isEmpty(id)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -87,6 +95,7 @@ public class ConnectController {
     }
 
     @PostMapping("/closeConnect/{id}")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.CLOSE)
     public Result closeConnect(@PathVariable Integer id) throws Exception {
         if (Blank.isEmpty(id)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -108,6 +117,7 @@ public class ConnectController {
      * @throws DuplicateGroupException
      */
     @GetMapping("/readItemValue")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.READ)
     public Result readItemValue(int id, String itemName) throws Exception {
         if (Blank.isEmpty(id, itemName)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -122,6 +132,7 @@ public class ConnectController {
      * @return
      */
     @PostMapping("/editConnect")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.UPDATE)
     public Result editConnect(@RequestBody ServerInformation serverInformation) {
         if (Blank.isEmpty(serverInformation, serverInformation.getId(), serverInformation.getConnectName(), serverInformation.getConnectMode(), serverInformation.getIpAddress())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -136,6 +147,7 @@ public class ConnectController {
      * @return
      */
     @PostMapping("/deleteConnect/{id}")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.CONNECT, OperationEnum = OperationEnum.DELETE)
     public Result deleteConnect(@PathVariable Integer id) {
         if (Blank.isEmpty(id)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());

+ 11 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/DepartmentController.java

@@ -2,8 +2,12 @@ package com.judong.chuanyiserver.controller;
 
 import com.judong.chuanyiserver.annotation.PermissionControl;
 
+import com.judong.chuanyiserver.annotation.WebLog;
 import com.judong.chuanyiserver.entity.Department;
+import com.judong.chuanyiserver.enums.ModelEnum;
+import com.judong.chuanyiserver.enums.OperationEnum;
 import com.judong.chuanyiserver.enums.ResultEnum;
+import com.judong.chuanyiserver.enums.ServerEnum;
 import com.judong.chuanyiserver.service.DepartmentService;
 import com.judong.chuanyiserver.util.Blank;
 import com.judong.chuanyiserver.util.Result;
@@ -26,6 +30,7 @@ public class DepartmentController {
      */
     @PostMapping("/addDepartment")
     @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.ADD)
     public Result addDepartment(@RequestBody Department department) {
         if (Blank.isEmpty(department)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -41,6 +46,7 @@ public class DepartmentController {
      */
     @PostMapping("/updateDepartment")
     @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.UPDATE)
     public Result updateDepartment(@RequestBody Department department) {
         if (Blank.isEmpty(department)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -59,6 +65,7 @@ public class DepartmentController {
      */
     @GetMapping("/getDepartmentListByPage")
     @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.SELECT)
     public Result getDepartmentListByPage(Integer page, Integer limit, String departmentName, String createTime) {
         if (Blank.isEmpty(page, limit) || page < 1 || limit < 1) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -74,6 +81,7 @@ public class DepartmentController {
      */
     @GetMapping("/getDepartmentById")
     @PermissionControl
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.SELECT)
     public Result getDepartmentById(Integer id) {
         if (Blank.isEmpty(id)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -85,6 +93,7 @@ public class DepartmentController {
      * 根据父亲id查子节点(一级查询)
      */
     @GetMapping("/queryChildren")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.SELECT)
     public Result queryDepartmentChildren(Integer parenId){
         if (Blank.isEmpty(parenId)){
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -97,6 +106,7 @@ public class DepartmentController {
      * 根据父亲id查所有子节点
      */
     @GetMapping("/queryAllChildren")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.SELECT)
     public Result queryDepartmentAllChildren(Integer parenId){
         if (Blank.isEmpty(parenId)){
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
@@ -109,6 +119,7 @@ public class DepartmentController {
      * 逻辑删除(批量删除)
      */
     @PostMapping("/isDeleteById")
+    @WebLog(ServerEnum = ServerEnum.CLIENT, ModelEnum = ModelEnum.DEPARTMENT, OperationEnum = OperationEnum.DELETE)
     public Result isDeleteByid(@RequestBody List<Integer> ids){
         if (ids.size()<=0){
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());

+ 5 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/ChannelSettingDao.java

@@ -21,7 +21,7 @@ public interface ChannelSettingDao {
 
     List<Config> getConfigList(int serverId);
 
-    Integer addConfigByName(Integer serverId, String configName,Integer runState);
+    Integer addConfigByName(Config config);
 
     Config getConfigByName(Integer serverId, String configName);
 
@@ -44,4 +44,8 @@ public interface ChannelSettingDao {
     Config getConfigById(Integer configId);
 
     List<ChannelSetting> getChannelListBySeCoId(Integer serverId, Integer configId);
+
+    List<ChannelSetting> getChannelBySeChNameList(Integer serverId, List<String> channelNameList);
+
+    Integer addChannelSettingList(Integer serverId, List<String> channelNameList);
 }

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

@@ -5,10 +5,13 @@ public enum ModelEnum {
     UNKNOWN("未知模块", "UNKNOWN"),
 
     USER("用户管理", "USER"), ROLE("角色管理", "ROLE"), BASIC_DATA("基础数据", "BASIC_DATA"), MENU("菜单管理", "MENU"),PERMISSION("接口权限管理", "PERMISSION"),
-    DEPT("组织机构管理", "DEPT"), GROUP("用户组管理", "GROUP"), PERSON("人员管理", "PERSON"),
-    MOBILE("移动端", "MOBILE"),
-    WEBSITE("站点管理", "WEBSITE"),
-    COLUMN("栏目管理", "COLUMN"),
+    DEPARTMENT("部门管理", "DEPARTMENT"), GROUP("用户组管理", "GROUP"), PERSON("人员管理", "PERSON"),
+
+    CONNECT("连接","CONNECT"),
+    PASSAGEWAY("通道","PASSAGEWAY"),
+    CONFIGURE("配置","CONFIGURE"),
+    RUNNING("运行","RUNNING"),
+    DATASOURCE("数据源","DATASOURCE"),
 
     SIGNIN("登录", "SIGNIN"), LOGOUT("退出登录", "LOGOUT"), REGISTER("注册", "REGISTER"), HOMEBYPAGE("首页", "HOMEBYPAGE"),
     UPDATECODE("发送验证码", "UPDATECODE"), SEARCH("房源搜索", "SEARCH");

+ 4 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/enums/OperationEnum.java

@@ -6,9 +6,11 @@ public enum OperationEnum {
 
     LOGIN("登录", "LOGIN"), LOGOUT("退出登录", "LOGOUT"), UPDATEPASSWORD("修改密码", "UPDATEPASSWORD"),
     ADD("新增", "ADD"), SELECT("查看", "SELECT"), UPDATE("编辑", "UPDATE"), DELETE("删除", "DELETE"),
-    ASSIGN("分配", "ASSIGN"),RELIEVE("解除", "RELIEVE"),
+    ASSIGN("分配", "ASSIGN"), RELIEVE("解除", "RELIEVE"),
     IMPORT("导入", "IMPORT"), EXPORT("导出", "EXPORT"),
-    REGISTER("注册", "REGISTER");
+    REGISTER("注册", "REGISTER"),
+    TEST("测试", "TEST"), OPEN("打开", "OPEN"), CLOSE("关闭", "CLOSE"),
+    READ("读取", "READ");
 
     private String value;
 

+ 2 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/ChannelSettingService.java

@@ -22,4 +22,6 @@ public interface ChannelSettingService {
     Result deleteConfig(Integer configId);
 
     Result runConfigById(Integer configId, Integer runState) throws Exception;
+
+    Result getConfigList(Integer serverId);
 }

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

@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -81,15 +82,38 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
 
     @Override
     public synchronized Result assignChannelSettingList(Integer configId, Integer serverId, List<String> channelNameList, String configName) {
+        List<ChannelSetting> channelSettings = channelSettingDao.getChannelBySeChNameList(serverId, channelNameList);
+        List<String> newChannelNameList = new ArrayList<>();
+        if (Blank.isNotEmpty(channelSettings)) {
+            for (String channelName : channelNameList) {
+                Boolean flage = true;
+                for (int i = 0; i < channelSettings.size(); i++) {
+                    if (channelName.equals(channelSettings.get(i).getChannelName())) {
+                        flage = false;
+                        break;
+                    }
+                }
+                if (flage) {
+                    newChannelNameList.add(channelName);
+                }
+            }
+        } else {
+            newChannelNameList = channelNameList;
+        }
+        if (Blank.isNotEmpty(newChannelNameList)) {
+            channelSettingDao.addChannelSettingList(serverId, newChannelNameList);
+        }
         if (Blank.isEmpty(configId)) {
             Config config = channelSettingDao.getConfigByName(serverId, configName);
             if (Blank.isEmpty(config)) {
-                if (channelSettingDao.addConfigByName(serverId, configName, ConstantStr.STOP_IT) <= 0) {
-                    throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "保存配置失败");
-                }
-                configId = channelSettingDao.getConfigId(serverId, configName);
+                config = new Config();
+                config.setServerId(serverId);
+                config.setConfigurationName(configName);
+                config.setRunState(ConstantStr.STOP_IT);
+                channelSettingDao.addConfigByName(config);
+                configId = config.getId();
                 if (channelSettingDao.addChannelConfigList(serverId, channelNameList, configId) <= 0) {
-                    throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "保存配置失败,可能是选择的配置中,没有一个进行标签映射");
+                    throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "保存配置失败");
                 }
                 return Result.ok("保存配置成功");
             } else {
@@ -98,7 +122,7 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
         } else {
             channelSettingDao.clearChannelConfig(configId);
             if (channelSettingDao.addChannelConfigList(serverId, channelNameList, configId) <= 0) {
-                throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "保存配置失败,可能是选择的配置中,没有一个进行标签映射");
+                throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "保存配置失败");
             }
             return Result.ok("保存配置成功");
         }
@@ -143,7 +167,7 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
         }
         Config config = channelSettingDao.getConfigById(configId);
         ServerInformation serverInformation = connectDao.getServerInformationById(config.getServerId());
-        List<ChannelSetting> channelSettingList=channelSettingDao.getChannelListBySeCoId(config.getServerId(),configId);
+        List<ChannelSetting> channelSettingList = channelSettingDao.getChannelListBySeCoId(config.getServerId(), configId);
         serverInformation.setIpPassword(RSAUtil.decrypt(serverInformation.getIpPassword(), "utf-8"));
         if (serverInformation.getConnectMode() == ConnectModeEnum.KEPOPCSERVER.getValue()) {
             if (KepOpcServerUtil.validationServerInformation(serverInformation)) {
@@ -160,4 +184,9 @@ public class ChannelSettingServiceImpl implements ChannelSettingService {
         }
     }
 
+    @Override
+    public Result getConfigList(Integer serverId) {
+        return Result.ok(channelSettingDao.getConfigList(serverId));
+    }
+
 }

+ 5 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/KepOpcServerUtil.java

@@ -253,13 +253,13 @@ public class KepOpcServerUtil {
                 if (OPCSERVERSTATE.OPC_STATUS_RUNNING == server.getServerState().getServerState()) {
                     Group group = server.addGroup();
                     //循环读值需要使用到的
-                    final AccessBase access=new SyncAccess(server,1000);
+                    final AccessBase access = new SyncAccess(server, 1000);
                     //开始读值
                     access.bind();
                     //停止读值
                     access.unbind();
                     Iterator<ChannelSetting> iterator = channelSettingList.iterator();
-                    while (iterator.hasNext()){
+                    while (iterator.hasNext()) {
                         Item item = group.addItem(iterator.next().getChannelName());
                         Map<String, Object> value = getVal(item.read(true).getValue());
                     }
@@ -345,6 +345,7 @@ public class KepOpcServerUtil {
                     if (iterator.next().getChannelName().equals(branchName)) {
                         flage = false;
                         iterator.remove();
+                        break;
                     }
                 }
                 if (flage) {
@@ -368,6 +369,7 @@ public class KepOpcServerUtil {
                 if (iterator.next().getChannelName().equals(newBranchName)) {
                     flage = false;
                     iterator.remove();
+                    break;
                 }
             }
             if (flage) {
@@ -393,6 +395,7 @@ public class KepOpcServerUtil {
             while (iterator.hasNext()) {
                 if (iterator.next().getChannelName().equals(newBranchName)) {
                     flage = false;
+                    break;
                 }
             }
             if (flage) {

+ 19 - 3
chuanyi_server/src/main/resources/mapper/ChannelSettingDao.xml

@@ -22,10 +22,18 @@
         )
     </insert>
 
-    <update id="addConfigByName">
+    <insert id="addChannelSettingList">
+        insert into t_channel_setting(server_id, channel_name, channel_map_name, create_time)
+        VALUES
+        <foreach collection="channelNameList" item="channelName" index="index" separator=",">
+            (#{serverId},#{channelName},#{channelName},now())
+        </foreach>
+    </insert>
+
+    <insert id="addConfigByName" parameterType="com.judong.chuanyiserver.entity.Config" useGeneratedKeys="true" keyProperty="id">
         insert into t_config (server_id, configuration_name, run_state, create_time)
-            VALUE (#{serverId}, #{configName}, #{runState}, now())
-    </update>
+            VALUE (#{serverId}, #{configurationName}, #{runState}, now())
+    </insert>
 
     <update id="updateChannelSetting">
         update t_channel_setting
@@ -160,4 +168,12 @@
           and config_id = #{configId}
     </select>
 
+    <select id="getChannelBySeChNameList" resultType="com.judong.chuanyiserver.entity.ChannelSetting">
+        select * from t_channel_setting where server_id=#{serverId} and channel_name in (
+        <foreach collection="channelNameList" item="channelName" index="index" separator=",">
+            #{channelName}
+        </foreach>
+        )
+    </select>
+
 </mapper>