Browse Source

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

FinalYu 2 years ago
parent
commit
78665e358d
27 changed files with 885 additions and 104 deletions
  1. 46 0
      chuanyi-admin/src/api/system/auth.js
  2. 56 0
      chuanyi-admin/src/api/system/dept.js
  3. 36 0
      chuanyi-admin/src/api/system/user.js
  4. 215 0
      chuanyi-admin/src/views/system/auth/index.vue
  5. 240 0
      chuanyi-admin/src/views/system/dept/index.vue
  6. 1 1
      chuanyi-admin/src/views/system/menu/index.vue
  7. 6 8
      chuanyi-admin/src/views/system/role/index.vue
  8. 72 29
      chuanyi-admin/src/views/system/role/user-auth.vue
  9. 38 14
      chuanyi-admin/src/views/system/role/user-select.vue
  10. 15 9
      chuanyi_server/src/main/java/com/judong/chuanyiserver/annotation/WebLogAspect.java
  11. 1 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/InterceptorConfig.java
  12. 7 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/KepOpcServerPoolFactory.java
  13. 7 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcServerUaPoolFactory.java
  14. 10 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ConnectController.java
  15. 2 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/PermissionController.java
  16. 12 5
      chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/UserController.java
  17. 2 2
      chuanyi_server/src/main/java/com/judong/chuanyiserver/dao/ConnectDao.java
  18. 19 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/entity/AddUserRole.java
  19. 1 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/enums/ResultEnum.java
  20. 2 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/ConnectService.java
  21. 68 10
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ConnectServiceImpl.java
  22. 2 1
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/DepartmentServiceImpl.java
  23. 0 12
      chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/LogServiceImpl.java
  24. 11 5
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/KepOpcServerUtil.java
  25. 11 0
      chuanyi_server/src/main/java/com/judong/chuanyiserver/util/OpcServerUaUtil.java
  26. 4 2
      chuanyi_server/src/main/resources/mapper/ConnectDao.xml
  27. 1 1
      chuanyi_server/src/main/resources/mapper/DepartmentDao.xml

+ 46 - 0
chuanyi-admin/src/api/system/auth.js

@@ -0,0 +1,46 @@
+import request from '@/utils/request'
+
+// 获取权限列表
+export function getAuthList(query) {
+  return request({
+    url: '/permission/getPermissionListByPage',
+    method: 'get',
+    params: query
+  })
+}
+
+// 新增权限
+export function addAuthList(data) {
+  return request({
+    url: '/permission/addPermission',
+    method: 'post',
+    data
+  })
+}
+
+// 查看权限
+export function getAuthListById(query) {
+  return request({
+    url: '/permission/getPermissionById',
+    method: 'get',
+    params: query
+  })
+}
+
+// 修改权限
+export function emitAuthList(data) {
+  return request({
+    url: '/permission/updatePermission',
+    method: 'post',
+    data
+  })
+}
+
+// 删除权限
+export function deleteAuthList(data) {
+  return request({
+    url: '/permission/deletePermissionById',
+    method: 'post',
+    data
+  })
+}

+ 56 - 0
chuanyi-admin/src/api/system/dept.js

@@ -0,0 +1,56 @@
+import request from '@/utils/request'
+
+// 获取部门列表
+export function getDeptList(query) {
+  return request({
+    url: '/department/getDepartmentListByPage',
+    method: 'get',
+    params: query
+  })
+}
+
+// 新增部门
+export function addDept(data) {
+  return request({
+    url: '/department/addDepartment',
+    method: 'post',
+    data
+  })
+}
+
+// 通过id查看部门
+export function getDeptById(query) {
+  return request({
+    url: '/department/getDepartmentById',
+    method: 'get',
+    params: query
+  })
+}
+
+// 编辑部门
+export function editDept(data) {
+  return request({
+    url: '/department/updateDepartment',
+    method: 'post',
+    data
+  })
+}
+
+// 删除部门
+export function delDept(data) {
+  return request({
+    url: '/department/isDeleteById',
+    method: 'post',
+    data
+  })
+}
+
+export function getSonMenuList() {
+  return request({
+    url: '/department/queryAllChildren',
+    method: 'get',
+    params: {
+      parenId: 1
+    }
+  })
+}

+ 36 - 0
chuanyi-admin/src/api/system/user.js

@@ -51,3 +51,39 @@ export function delUserById(data) {
     data
   })
 }
+
+// 根据角色ID查询该角色下人员
+export function getUserListById(query) {
+  return request({
+    url: '/user/getUserListByRoleId',
+    method: 'get',
+    params: query
+  })
+}
+
+// 取消角色授权
+export function cancelRoleAuth(query) {
+  return request({
+    url: '/user/relieveUserRole',
+    method: 'get',
+    params: query
+  })
+}
+
+// 批量取消角色授权
+export function cancelAllRoleAuth(data) {
+  return request({
+    url: '/user/relieveUserRoles',
+    method: 'post',
+    data
+  })
+}
+
+// 添加用户为授权角色
+export function addUserToAuthRole(data) {
+  return request({
+    url: '/user/assignUserListByRoleId',
+    method: 'post',
+    data
+  })
+}

+ 215 - 0
chuanyi-admin/src/views/system/auth/index.vue

@@ -0,0 +1,215 @@
+<template>
+  <div class="sy-content">
+    <el-row>
+      <el-col :span="24">
+        <!-- 表单查询 -->
+        <el-form ref="queryForm" :model="queryParams" :inline="true" size="small">
+          <el-form-item label="权限名称" prop="permissionName">
+            <el-input v-model="queryParams.permissionName" placeholder="请输入菜单名称" clear />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handelSearch">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="handelReset">重置</el-button>
+          </el-form-item>
+        </el-form>
+
+        <el-button size="mini" icon="el-icon-plus" type="primary" plain @click="handelAdd">新增</el-button>
+
+        <!-- 表格数据信息 -->
+        <el-table v-loading="loading" :data="authList">
+          <el-table-column type="index" width="50" align="center" />
+          <el-table-column key="permissionName" label="权限名称" align="center" prop="permissionName" />
+          <el-table-column key="permissionUrl" label="权限路径" align="center" prop="permissionUrl" />
+          <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
+            <template slot-scope="scope">
+              <el-button size="mini" type="text" icon="el-icon-edit" @click="handelEdit(scope.row.id)">修改
+              </el-button>
+              <el-button size="mini" type="text" icon="el-icon-delete" @click="handelDel(scope.row.id)">删除
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <!-- 分页信息 -->
+        <pagination
+          v-show="total > 0"
+          :total="total"
+          :page.sync="queryParams.page"
+          :limit.sync="queryParams.limit"
+          align="right"
+          @pagination="getAuthList"
+        />
+      </el-col>
+    </el-row>
+
+    <!-- 弹出框 -->
+    <el-dialog :title="title" :visible.sync="dialogVisible" width="35%">
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="权限名称" prop="permissionName">
+              <el-input v-model="form.permissionName" placeholder="请输入权限名称" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="权限路径" prop="permissionUrl">
+              <el-input v-model="form.permissionUrl" placeholder="请输入权限路径" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="handelSubmit('form')">确 定</el-button>
+        <el-button @click="handelCancel('form')">取 消</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { getAuthList, addAuthList, getAuthListById, emitAuthList, deleteAuthList } from '@/api/system/auth.js'
+export default {
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 查询参数
+      queryParams: {
+        page: 1,
+        limit: 10
+      },
+      // 总条数
+      total: 0,
+      // 表格数据
+      authList: [],
+      // 弹出框
+      dialogVisible: false,
+      // 弹出框标题
+      title: '',
+      // 弹出框表单
+      form: {},
+      // 菜单类别
+      options: [],
+      // 表单验证
+      rules: {
+        permissionName: [
+          { required: true, message: '权限名称不能为空', trigger: 'blur' }
+        ],
+        permissionUrl: [
+          { required: true, message: '权限路径不能为空', trigger: 'blur' }
+        ]
+      },
+      // 修改菜单id
+      id: null
+    }
+  },
+  created() {
+    this.getAuthList()
+  },
+  methods: {
+    /** 获取权限表格数据 */
+    getAuthList() {
+      getAuthList(this.queryParams).then(res => {
+        const data = res.data
+        this.authList = data.permissionList
+        this.total = data.count
+        this.loading = false
+      })
+    },
+    /** 搜索 */
+    handelSearch() {
+      this.queryParams.page = 1
+      this.getAuthList()
+    },
+    /** 重置按钮操作 */
+    handelReset() {
+      this.$refs['queryForm'].resetFields()
+      this.handelSearch()
+    },
+    /** 新增按钮 */
+    handelAdd() {
+      this.reset()
+      this.dialogVisible = true
+      this.title = '添加权限'
+    },
+    /** 修改按钮 */
+    handelEdit(id) {
+      this.id = id
+      getAuthListById({ id }).then(res => {
+        this.form = res.data
+      })
+      this.dialogVisible = true
+      this.title = '修改权限'
+    },
+    /** 删除按钮 */
+    handelDel(id) {
+      this.$confirm('是否删除该权限?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteAuthList({ id }).then(res => {
+          if (res.code === 200) {
+            this.$message({
+              type: 'success',
+              message: res.data
+            })
+            this.getAuthList()
+          }
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        })
+      })
+    },
+    /** 表单提交 */
+    handelSubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          if (this.title === '添加权限') {
+            addAuthList(this.form).then(res => {
+              if (res.code === 200) {
+                this.$message({
+                  message: res.data,
+                  type: 'success'
+                })
+                this.getAuthList()
+                this.dialogVisible = false
+              }
+            })
+          } else {
+            this.form.id = this.id
+            emitAuthList(this.form).then(res => {
+              if (res.code === 200) {
+                this.$message({
+                  message: res.data,
+                  type: 'success'
+                })
+                this.getAuthList()
+                this.dialogVisible = false
+              }
+            })
+          }
+        }
+      })
+    },
+    /** 表单取消 */
+    handelCancel() {
+      this.dialogVisible = false
+      this.reset()
+    },
+    /** 表单重置 */
+    reset() {
+      if (this.$refs['form']) {
+        this.$refs['form'].resetFields()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" rel="stylesheet/scss" scoped>
+
+</style>

+ 240 - 0
chuanyi-admin/src/views/system/dept/index.vue

@@ -0,0 +1,240 @@
+<template>
+  <div class="sy-content">
+    <el-row>
+      <el-col :span="24">
+        <!-- 表单查询 -->
+        <el-form ref="queryForm" :model="queryParams" :inline="true" size="small">
+          <el-form-item label="部门名称" prop="menuName">
+            <el-input v-model="queryParams.menuName" placeholder="请输入部门名称" clear />
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="handelSearch">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="handelReset">重置</el-button>
+          </el-form-item>
+        </el-form>
+
+        <el-button size="mini" icon="el-icon-plus" type="primary" plain @click="handelAdd">新增</el-button>
+
+        <!-- 表格数据信息 -->
+        <el-table v-loading="loading" :data="deptList">
+          <el-table-column type="index" width="50" align="center" />
+          <el-table-column key="menuName" label="部门名称" align="center" prop="menuName" />
+          <el-table-column key="menuIcon" label="部门描述" align="center" prop="menuIcon" />
+          <el-table-column key="sortNum" label="排序号" align="center" prop="sortNum" />
+          <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
+            <template slot-scope="scope">
+              <el-button size="mini" type="text" icon="el-icon-edit" @click="handelEdit(scope.row.id)">修改
+              </el-button>
+              <el-button size="mini" type="text" icon="el-icon-delete" @click="handelDel(scope.row.id)">删除
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <!-- 分页信息 -->
+        <pagination
+          v-show="total > 0"
+          :total="total"
+          :page.sync="queryParams.page"
+          :limit.sync="queryParams.limit"
+          align="right"
+          @pagination="getDeptList"
+        />
+      </el-col>
+    </el-row>
+
+    <!-- 弹出框 -->
+    <el-dialog :title="title" :visible.sync="dialogVisible" width="35%">
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="上级部门" prop="parentId">
+              <el-select v-model="form.parentId" clearable placeholder="请选择" style="width:100%">
+                <el-option v-for="item in options" :key="item.id" :label="item.departmentName" :value="item.id" />
+              </el-select>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="部门名称" prop="departmentName">
+              <el-input v-model="form.departmentName" placeholder="请输入部门名称" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="12">
+            <el-form-item label="部门描述" prop="departmentDescribe">
+              <el-input v-model="form.departmentDescribe" placeholder="请输入部门描述" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="显示排序" prop="departmentNum">
+              <el-input-number
+                v-model="form.departmentNum"
+                placeholder="0"
+                controls-position="right"
+                :min="1"
+                :max="10"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="handelSubmit('form')">确 定</el-button>
+        <el-button @click="handelCancel('form')">取 消</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { getDeptList, addDept, getDeptById, editDept, delDept } from '@/api/system/dept.js'
+export default {
+  data() {
+    return {
+      // 遮罩层
+      loading: false,
+      // 查询参数
+      queryParams: {
+        page: 1,
+        limit: 10
+      },
+      // 总条数
+      total: 0,
+      // 表格数据
+      deptList: [],
+      // 弹出框
+      dialogVisible: false,
+      // 弹出框标题
+      title: '',
+      // 弹出框表单
+      form: {},
+      // 菜单类别
+      options: [],
+      // 表单验证
+      rules: {
+        departmentName: [
+          { required: true, message: '部门单名称不能为空', trigger: 'blur' }
+        ],
+        departmentDescribe: [
+          { required: true, message: '部门描述不能为空', trigger: 'blur' }
+        ],
+        departmentNum: [
+          { required: true, message: '排序不能为空', trigger: ['change', 'blur'] }
+        ]
+      },
+      // 修改菜单id
+      id: null
+    }
+  },
+  created() {
+    this.getDeptList()
+  },
+  methods: {
+    /** 获取表格数据 */
+    getDeptList() {
+      getDeptList(this.queryParams).then(res => {
+        console.log(res)
+      })
+    },
+    /** 搜索 */
+    handelSearch() {
+      this.queryParams.page = 1
+      this.getDeptList()
+    },
+    /** 重置按钮操作 */
+    handelReset() {
+      this.$refs['queryForm'].resetFields()
+      this.handelSearch()
+    },
+    /** 新增按钮 */
+    handelAdd() {
+      this.reset()
+      this.dialogVisible = true
+      this.title = '添加部门'
+    },
+    /** 修改按钮 */
+    handelEdit(id) {
+      this.id = id
+      getDeptById({ id }).then(res => {
+        this.form = res.data
+      })
+      this.dialogVisible = true
+      this.title = '修改部门'
+    },
+    /** 删除按钮 */
+    handelDel(id) {
+      this.$confirm('是否删除该菜单?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        delDept({ id }).then(res => {
+          if (res.code === 200) {
+            this.$message({
+              type: 'success',
+              message: res.data
+            })
+            this.getDeptList()
+          }
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        })
+      })
+    },
+    /** 表单提交 */
+    handelSubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          if (this.title === '添加部门') {
+            this.form.parentId = this.form.parentId || 0
+            console.log(this.form)
+            addDept(this.form).then(res => {
+              console.log(res)
+              if (res.code === 200) {
+                this.$message({
+                  message: res.data,
+                  type: 'success'
+                })
+                this.dialogVisible = false
+              }
+            })
+          } else {
+            this.form.id = this.id
+            editDept(this.form).then(res => {
+              if (res.code === 200) {
+                this.$message({
+                  message: res.data,
+                  type: 'success'
+                })
+                this.getDeptList()
+                this.dialogVisible = false
+              }
+            })
+          }
+        }
+      })
+    },
+    /** 表单取消 */
+    handelCancel() {
+      this.dialogVisible = false
+      this.reset()
+    },
+    /** 表单重置 */
+    reset() {
+      if (this.$refs['form']) {
+        this.$refs['form'].resetFields()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="scss" rel="stylesheet/scss" scoped>
+
+</style>

+ 1 - 1
chuanyi-admin/src/views/system/menu/index.vue

@@ -139,7 +139,7 @@ export default {
           { required: true, message: '菜单名称不能为空', trigger: 'blur' }
         ],
         sortNum: [
-          { required: true, message: '显示排序不能为空', trigger: 'change' }
+          { required: true, message: '显示排序不能为空', trigger: ['change', 'blur'] }
         ],
         menuUrl: [
           { required: true, message: '路由地址不能为空', trigger: 'blur' }

+ 6 - 8
chuanyi-admin/src/views/system/role/index.vue

@@ -3,7 +3,7 @@
     <el-row>
       <el-col>
         <!-- 搜索信息 -->
-        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
+        <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="68px">
           <el-form-item label="角色名称" prop="roleName">
             <el-input
               v-model="queryParams.roleName"
@@ -51,17 +51,17 @@
         </el-row>
         <!-- 表格数据信息 -->
         <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
-          <el-table-column type="selection" width="50" align="center"/>
-          <el-table-column label="角色编号" align="center" key="id" prop="id" v-if="false"/>
-          <el-table-column label="角色名称" align="center" key="roleName" prop="roleName" :show-overflow-tooltip="true"/>
-          <el-table-column label="权限字符" align="center" key="roleCode" prop="roleCode" :show-overflow-tooltip="true"/>
+          <el-table-column type="selection" width="50" align="center" />
+          <el-table-column v-if="false" key="id" label="角色编号" align="center" prop="id" />
+          <el-table-column key="roleName" label="角色名称" align="center" prop="roleName" :show-overflow-tooltip="true" />
+          <el-table-column key="roleCode" label="权限字符" align="center" prop="roleCode" :show-overflow-tooltip="true" />
           <el-table-column
             label="操作"
             align="center"
             width="350"
             class-name="small-padding fixed-width"
           >
-            <template slot-scope="scope" v-if="scope.row.userId !== 1">
+            <template v-if="scope.row.userId !== 1" slot-scope="scope">
               <el-button
                 size="mini"
                 type="text"
@@ -269,8 +269,6 @@ export default {
     /** 分配角色人员 */
     handleAuthUser(row) {
       const roleId = row.id
-      console.log(row)
-      console.log('/system/role/user-auth/role/' + roleId)
       this.$router.push('/system/role/user-auth/role/' + roleId)
     },
     /** 分配角色菜单 */

+ 72 - 29
chuanyi-admin/src/views/system/role/user-auth.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
+    <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
       <el-form-item label="用户名称" prop="userName">
         <el-input
           v-model="queryParams.userName"
@@ -18,13 +18,7 @@
 
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="openSelectUser"
-        >添加用户</el-button>
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openSelectUser">添加用户</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -37,13 +31,7 @@
         >批量取消授权</el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button
-          type="warning"
-          plain
-          icon="el-icon-close"
-          size="mini"
-          @click="handleClose"
-        >关闭</el-button>
+        <el-button type="warning" plain icon="el-icon-close" size="mini" @click="handleClose">关闭</el-button>
       </el-col>
     </el-row>
 
@@ -60,16 +48,12 @@
           <span>{{ convertUserType(scope.row.userType) }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="最后登录时间" prop="lastLoginTime" width="160"/>
-      <el-table-column label="创建时间" prop="createTime" width="160"/>
+      <el-table-column label="最后登录时间" prop="lastLoginTime" width="160" />
+      <el-table-column label="创建时间" prop="createTime" width="160" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-circle-close"
-            @click="cancelAuthUser(scope.row)"
-          >取消授权</el-button>
+          <el-button size="mini" type="text" icon="el-icon-circle-close" @click="cancelAuthUser(scope.row)">取消授权
+          </el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -79,22 +63,23 @@
       :total="total"
       :page.sync="queryParams.page"
       :limit.sync="queryParams.limit"
+      align="right"
       @pagination="getList"
     />
-    <select-user ref="select" :roleId="queryParams.roleId" @ok="handleQuery" />
+    <select-user ref="select" :role-id="queryParams.roleId" @updateUserList="getList()" />
   </div>
 </template>
 
 <script>
 import selectUser from './user-select'
-
+import { getUserListById, cancelRoleAuth, cancelAllRoleAuth } from '@/api/system/user'
 export default {
   name: 'UserAuth',
   components: { selectUser },
   data() {
     return {
       // 遮罩层
-      loading: true,
+      loading: false,
       // 选中用户组
       userIds: [],
       // 非多个禁用
@@ -117,7 +102,7 @@ export default {
     }
   },
   created() {
-    const roleId = this.$route.params && this.$route.params.roleId
+    const roleId = this.$route.params.userId
     if (roleId) {
       this.queryParams.roleId = roleId
       this.getList()
@@ -146,9 +131,18 @@ export default {
     },
     /** 查询授权用户列表 */
     getList() {
+      getUserListById(this.queryParams).then(res => {
+        if (res.code === 200) {
+          const data = res.data
+          this.userList = data.userList
+          this.total = data.count
+          this.loading = false
+        }
+      })
     },
     /** 返回按钮 */
     handleClose() {
+      this.$router.push('/system/role')
     },
     /** 搜索按钮操作 */
     handleQuery() {
@@ -164,7 +158,12 @@ export default {
     },
     /** 多选框选中数据 */
     handleSelectionChange(selection) {
-      this.userIds = selection.map(item => item.userId)
+      this.userIds = selection.map(item => {
+        return {
+          userId: item.userId,
+          roleId: this.queryParams.roleId
+        }
+      })
       this.multiple = !selection.length
     },
     /** 打开授权用户表弹窗 */
@@ -173,9 +172,53 @@ export default {
     },
     /** 取消授权按钮操作 */
     cancelAuthUser(row) {
+      const query = {
+        roleId: this.queryParams.roleId,
+        userId: row.userId
+      }
+      this.$confirm('是否取消授权?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        cancelRoleAuth(query).then(res => {
+          if (res.code === 200) {
+            this.getList()
+            this.$message({
+              type: 'success',
+              message: res.data
+            })
+          }
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '取消操作'
+        })
+      })
     },
     /** 批量取消授权按钮操作 */
-    cancelAuthUserAll(row) {
+    cancelAuthUserAll() {
+      this.$confirm('是否取消授权?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        cancelAllRoleAuth(this.userIds).then(res => {
+          if (res.code === 200) {
+            this.getList()
+            this.$message({
+              type: 'success',
+              message: '已取消授权'
+            })
+          }
+        })
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '取消操作'
+        })
+      })
     }
   }
 }

+ 38 - 14
chuanyi-admin/src/views/system/role/user-select.vue

@@ -1,14 +1,9 @@
 <template>
   <!-- 授权用户 -->
   <el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
-    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
+    <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
       <el-form-item label="用户名称" prop="userName">
-        <el-input
-          v-model="queryParams.userName"
-          placeholder="请输入用户名称"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -16,8 +11,14 @@
       </el-form-item>
     </el-form>
     <el-row>
-      <el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
-        <el-table-column type="selection" width="55"></el-table-column>
+      <el-table
+        ref="table"
+        :data="userList"
+        height="260px"
+        @row-click="clickRow"
+        @selection-change="handleSelectionChange"
+      >
+        <el-table-column type="selection" width="55" />
         <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
         <el-table-column label="用户状态" prop="state" :show-overflow-tooltip="true">
           <template slot-scope="scope">
@@ -29,8 +30,8 @@
             <span>{{ convertUserType(scope.row.userType) }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="最后登录时间" prop="lastLoginTime" width="160"/>
-        <el-table-column label="创建时间" prop="createTime" width="160"/>
+        <el-table-column label="最后登录时间" prop="lastLoginTime" width="160" />
+        <el-table-column label="创建时间" prop="createTime" width="160" />
       </el-table>
       <pagination
         v-show="total > 0"
@@ -48,6 +49,7 @@
 </template>
 
 <script>
+import { getUserList, addUserToAuthRole } from '@/api/system/user'
 export default {
   props: {
     // 角色编号
@@ -78,6 +80,9 @@ export default {
       }
     }
   },
+  created() {
+    this.getList()
+  },
   methods: {
     /** 用户状态转换 */
     convertUserStatus(val) {
@@ -115,6 +120,13 @@ export default {
     },
     /** 查询用户列表 */
     getList() {
+      getUserList(this.queryParams).then(res => {
+        if (res.code === 200) {
+          const data = res.data
+          this.userList = data.userList
+          this.total = data.count
+        }
+      })
     },
     /** 搜索按钮操作 */
     handleQuery() {
@@ -130,14 +142,26 @@ export default {
     },
     /** 选择授权用户操作 */
     handleSelectUser() {
-      const roleId = this.queryParams.roleId
-      const userIds = this.userIds.join(',')
-      if (userIds === '') {
+      const query = {
+        roleId: Number(this.queryParams.roleId),
+        userIdList: this.userIds
+      }
+      if (this.userIds.length === 0) {
         this.$message({
           message: '请选择要分配的用户',
           type: 'warning'
         })
         return
+      } else {
+        addUserToAuthRole(query).then(res => {
+          if (res.code === 200) {
+            this.$message({
+              message: res.data,
+              type: 'warning'
+            })
+            this.$emit('updateUserList')
+          }
+        })
       }
     }
   }

+ 15 - 9
chuanyi_server/src/main/java/com/judong/chuanyiserver/annotation/WebLogAspect.java

@@ -1,7 +1,10 @@
 package com.judong.chuanyiserver.annotation;
 
+import cn.hutool.core.convert.Convert;
 import cn.hutool.extra.servlet.ServletUtil;
+import com.judong.chuanyiserver.dao.UserDao;
 import com.judong.chuanyiserver.entity.Log;
+import com.judong.chuanyiserver.entity.User;
 import com.judong.chuanyiserver.service.LogService;
 import com.judong.chuanyiserver.util.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -34,6 +37,9 @@ public class WebLogAspect {
     @Resource
     private HttpServletRequest request;
 
+    @Resource
+    private UserDao userDao;
+
     private String methodName;
 
     private String requestArgs;
@@ -84,7 +90,6 @@ public class WebLogAspect {
     @AfterReturning(value = "webLog() && @annotation(WebLog)", returning = "result")
     public void doAfterReturning(JoinPoint joinPoint, Object result) {
         Log log = new Log();
-
         //获取抽象方法
         Signature signature = joinPoint.getSignature();
         MethodSignature methodSignature = (MethodSignature) signature;
@@ -98,19 +103,20 @@ public class WebLogAspect {
         }
         log.setMethodName(methodName);
         log.setOperationStatus(1);
-        log.setContent("操作:" + webLog.OperationEnum().getValue() + "<br>请求的参数有:" + requestArgs + "<br>返回的结果为:" + result.toString());
-        log.setUserId((String) redisUtil.get(request.getHeader("token")));
-        ServletUtil.getClientIP(request, null);
-        log.setIpAddress(ServletUtil.getClientIP(request, null));
-        // 处理完请求,返回内容
-//        System.out.println("AfterReturning ");
-//        System.out.println("方法的返回值 : " + result);
+        log.setContent("操作类型:" + webLog.OperationEnum().getValue() + "\n请求参数:" + requestArgs + "\n响应结果:" + result.toString());
+        String userId = Convert.toStr(redisUtil.get(request.getHeader("token")));
+        User user = userDao.getUserById(userId);
+        String userName = user == null ? "" : (user.getUserName() + "@");
+        log.setUserId(userName + userId);
+        String clientIP = ServletUtil.getClientIP(request, "");
+        clientIP = "0:0:0:0:0:0:0:1".equals(clientIP) ? "127.0.0.1" : clientIP;
+        log.setIpAddress(clientIP);
         logService.insertLog(log);
     }
 
     //后置异常通知
     @AfterThrowing(value = "webLog() && @annotation(WebLog)")
-    public void afterThrowing(JoinPoint jp) {
+    public void afterThrowing(JoinPoint joinPoint) {
         System.out.println("AfterThrowing");
     }
 

+ 1 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/InterceptorConfig.java

@@ -29,6 +29,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
                 .excludePathPatterns("/user/frontUserLogin")
                 .excludePathPatterns("/user/backUserLogin")
                 .excludePathPatterns("/connect/testConnect")
+                .excludePathPatterns("/user/assignUserListByRoleId")
         ;
     }
 }

+ 7 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/KepOpcServerPoolFactory.java

@@ -90,6 +90,13 @@ public class KepOpcServerPoolFactory {
         pool.returnObject(key, server);
     }
 
+    public static void closeServer(String key) {
+        if (pool == null) {
+            init();
+        }
+        pool.clear(key);
+    }
+
     /**
      * 获取池中闲置状态的实例数
      *

+ 7 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/config/OpcServerUaPoolFactory.java

@@ -91,6 +91,13 @@ public class OpcServerUaPoolFactory {
         pool.returnObject(key, opcUaClient);
     }
 
+    public static void closeServer(String key) {
+        if (pool == null) {
+            init();
+        }
+        pool.clear(key);
+    }
+
     /**
      * 获取池中闲置状态的实例数
      *

+ 10 - 2
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/ConnectController.java

@@ -79,13 +79,21 @@ public class ConnectController {
      * @throws AddFailedException
      */
     @GetMapping("/openConnect")
-    public Result openConnect(int id) throws Exception {
+    public Result openConnect(Integer id) throws Exception {
         if (Blank.isEmpty(id)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
         return connectService.openConnect(id);
     }
 
+    @PostMapping("/closeConnect/{id}")
+    public Result closeConnect(@PathVariable Integer id) throws Exception {
+        if (Blank.isEmpty(id)) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        }
+        return connectService.closeConnect(id);
+    }
+
     /**
      * 通过传入服务器id和项名称,读取响应的数据
      *
@@ -115,7 +123,7 @@ public class ConnectController {
      */
     @PostMapping("/editConnect")
     public Result editConnect(@RequestBody ServerInformation serverInformation) {
-        if (Blank.isEmpty(serverInformation, serverInformation.getConnectName(), serverInformation.getConnectMode(), serverInformation.getIpAddress())) {
+        if (Blank.isEmpty(serverInformation, serverInformation.getId(), serverInformation.getConnectName(), serverInformation.getConnectMode(), serverInformation.getIpAddress())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
         return connectService.editConnect(serverInformation);

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

@@ -31,7 +31,7 @@ public class PermissionController {
     @PostMapping("/addPermission")
     @PermissionControl
     @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.PERMISSION, OperationEnum = OperationEnum.ADD)
-    public Result addPermission(Permission permission) {
+    public Result addPermission( @RequestBody Permission permission) {
         if (Blank.isEmpty(permission)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
@@ -47,7 +47,7 @@ public class PermissionController {
     @PostMapping("/updatePermission")
     @PermissionControl
     @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.PERMISSION, OperationEnum = OperationEnum.UPDATE)
-    public Result updatePermission(Permission permission) {
+    public Result updatePermission(@RequestBody Permission permission) {
         if (Blank.isEmpty(permission)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }

+ 12 - 5
chuanyi_server/src/main/java/com/judong/chuanyiserver/controller/UserController.java

@@ -2,6 +2,7 @@ package com.judong.chuanyiserver.controller;
 
 import com.judong.chuanyiserver.annotation.PermissionControl;
 import com.judong.chuanyiserver.annotation.WebLog;
+import com.judong.chuanyiserver.entity.AddUserRole;
 import com.judong.chuanyiserver.entity.User;
 import com.judong.chuanyiserver.entity.UserRole;
 import com.judong.chuanyiserver.enums.ModelEnum;
@@ -219,18 +220,17 @@ public class UserController {
     /**
      * 根据用户列表授权某一个角色
      *
-     * @param userIdList
-     * @param roleId
+     * @param addUserRole
      * @return
      */
     @PostMapping("/assignUserListByRoleId")
     @PermissionControl
     @WebLog(ServerEnum = ServerEnum.SERVER, ModelEnum = ModelEnum.USER, OperationEnum = OperationEnum.ASSIGN)
-    public Result assignUserListByRoleId(@RequestBody List<String> userIdList, Integer roleId) {
-        if (Blank.isEmpty(userIdList, roleId)) {
+    public Result assignUserListByRoleId(@RequestBody AddUserRole addUserRole ) {
+        if (Blank.isEmpty(addUserRole.getUserIdList(), addUserRole.getRoleId())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
         }
-        return userService.assignUserListByRoleId(userIdList, roleId);
+        return userService.assignUserListByRoleId(addUserRole.getUserIdList(), addUserRole.getRoleId());
     }
 
     /**
@@ -267,4 +267,11 @@ public class UserController {
         return  userService.relieveUserRoles(userRoles);
     }
 
+    @PostMapping("/test")
+    public Result test(@RequestBody List<String> userIdList){
+        System.out.println(userIdList);
+//        System.out.println(roleId);
+        return null;
+    }
+
 }

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

@@ -10,13 +10,13 @@ public interface ConnectDao {
 
     Integer saveConnect(ServerInformation serverInformation);
 
-    ServerInformation getServerInformation(String userId, String ipAddress);
+    ServerInformation getServerInformation(String userId, String connectName, Integer connectMode);
 
     ServerInformation getServerInformationById(int id);
 
     List<ServerInformation> selectAllConnect(String userId);
 
-    ServerInformation getServerInformationEdit(int id, String userId, String ipAddress);
+    ServerInformation getServerInformationEdit(int id, String userId, String connectName, Integer connectMode);
 
     Integer editConnect(ServerInformation serverInformation);
 

+ 19 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/entity/AddUserRole.java

@@ -0,0 +1,19 @@
+package com.judong.chuanyiserver.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class AddUserRole {
+
+    /**
+     * 用户id列表
+     */
+    private List<String> userIdList;
+
+    /**
+     * roleid
+     */
+    private Integer roleId;
+}

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

@@ -2,7 +2,7 @@ package com.judong.chuanyiserver.enums;
 
 public enum ResultEnum {
 
-    SUCCESS(200, "成功"),
+    SUCCESS(200, "success"),
 
     REQUEST_WRONGPARAMS(400, "参数错误"),
     LOGIN_EXPIRED(401, "登录信息过期,请重新登录"),

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

@@ -22,4 +22,6 @@ public interface ConnectService {
     Result editConnect(ServerInformation serverInformation);
 
     Result deleteConnect(int id);
+
+    Result closeConnect(int id) throws Exception;
 }

+ 68 - 10
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/ConnectServiceImpl.java

@@ -50,16 +50,36 @@ public class ConnectServiceImpl implements ConnectService {
 
     @Override
     public synchronized Result saveConnect(ServerInformation serverInformation) {
+        try {
+            RSAUtil.decrypt(serverInformation.getIpPassword(), "UTF-8");
+        } catch (Exception e) {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "密码错误");
+        }
         String userId = userUtil.getCurrentUserId();
         serverInformation.setUserId(userId);
-        ServerInformation si = connectDao.getServerInformation(userId, serverInformation.getIpAddress());
+        ServerInformation si = connectDao.getServerInformation(userId, serverInformation.getConnectName(), serverInformation.getConnectMode());
         if (Blank.isNotEmpty(si)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该用户下此ip已被使保存,请更换其他ip");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该用户下此连接名称和类型已被使用,请更换其他连接名称和类型");
         }
-        if (connectDao.saveConnect(serverInformation) <= 0) {
-            return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "保存连接失败");
+        if (serverInformation.getConnectMode() == ConnectModeEnum.KEPOPCSERVER.getValue()) {
+            if (KepOpcServerUtil.validationServerInformation(serverInformation)) {
+                if (connectDao.saveConnect(serverInformation) <= 0) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "保存连接失败");
+                }
+                return Result.ok("保存连接成功");
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else if (serverInformation.getConnectMode() == ConnectModeEnum.KingOPCServer.getValue()) {
+            if (OpcServerUaUtil.validationServerInformation(serverInformation)) {
+                if (connectDao.saveConnect(serverInformation) <= 0) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "保存连接失败");
+                }
+                return Result.ok("保存连接成功");
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "没有此连接方式");
         }
-        return Result.ok("保存连接成功");
     }
 
     @Override
@@ -70,14 +90,29 @@ public class ConnectServiceImpl implements ConnectService {
     @Override
     public synchronized Result editConnect(ServerInformation serverInformation) {
         String userId = userUtil.getCurrentUserId();
-        ServerInformation si = connectDao.getServerInformationEdit(serverInformation.getId(), userId, serverInformation.getIpAddress());
+        ServerInformation si = connectDao.getServerInformationEdit(serverInformation.getId(), userId, serverInformation.getConnectName(), serverInformation.getConnectMode());
         if (Blank.isNotEmpty(si)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该用户下此ip已被使保存,请更换其他ip");
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该用户下此连接名称和类型已被使用,请更换其他连接名称和类型");
         }
-        if (connectDao.editConnect(serverInformation) <= 0) {
-            return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "编辑连接失败");
+        if (serverInformation.getConnectMode() == ConnectModeEnum.KEPOPCSERVER.getValue()) {
+            if (KepOpcServerUtil.validationServerInformation(serverInformation)) {
+                if (connectDao.editConnect(serverInformation) <= 0) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "编辑连接失败");
+                }
+                return Result.ok("编辑连接成功");
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else if (serverInformation.getConnectMode() == ConnectModeEnum.KingOPCServer.getValue()) {
+            if (OpcServerUaUtil.validationServerInformation(serverInformation)) {
+                if (connectDao.editConnect(serverInformation) <= 0) {
+                    return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "编辑连接失败");
+                }
+                return Result.ok("编辑连接成功");
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else {
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "没有此连接方式");
         }
-        return Result.ok("编辑连接成功");
     }
 
     @Override
@@ -90,6 +125,29 @@ public class ConnectServiceImpl implements ConnectService {
     }
 
     @Override
+    public Result closeConnect(int id) throws Exception {
+        ServerInformation serverInformation = connectDao.getServerInformationById(id);
+        if (Blank.isEmpty(serverInformation)) {
+            return Result.no(ResultEnum.NOT_FOUND.getRespCode(), ResultEnum.NOT_FOUND.getRespMsg());
+        }
+        serverInformation.setIpPassword(RSAUtil.decrypt(serverInformation.getIpPassword(), "utf-8"));
+        //如果连接方式为kepserver
+        if (serverInformation.getConnectMode() == ConnectModeEnum.KEPOPCSERVER.getValue()) {
+            if (KepOpcServerUtil.validationServerInformation(serverInformation)) {
+                return KepOpcServerUtil.closeConnect(serverInformation);
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else if (serverInformation.getConnectMode() == ConnectModeEnum.KingOPCServer.getValue()) {
+            if (OpcServerUaUtil.validationServerInformation(serverInformation)) {
+                return OpcServerUaUtil.closeConnect(serverInformation);
+            }
+            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+        } else {
+            throw new CustomException(ResultEnum.NOT_FOUND.getRespCode(), "没有此连接方式");
+        }
+    }
+
+    @Override
     public Result openConnect(int id) throws Exception {
         ServerInformation serverInformation = connectDao.getServerInformationById(id);
         if (Blank.isEmpty(serverInformation)) {

+ 2 - 1
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/DepartmentServiceImpl.java

@@ -26,7 +26,8 @@ public class DepartmentServiceImpl implements DepartmentService {
         if (Blank.isEmpty(department.getParentId(), department.getDepartmentName())) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "父id,部门名称不能为空");
         }
-        if (Blank.isEmpty(departmentDao.getDepartmentByName(department.getDepartmentName()).getDepartmentName())) {
+        Department dept = departmentDao.getDepartmentByName(department.getDepartmentName());
+        if (Blank.isNotEmpty(dept)) {
             return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "该部门名称已被使用,请更换其他部门名称");
         }
         if (departmentDao.addDepartment(department) <= 0) {

+ 0 - 12
chuanyi_server/src/main/java/com/judong/chuanyiserver/service/impl/LogServiceImpl.java

@@ -2,13 +2,10 @@ package com.judong.chuanyiserver.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.judong.chuanyiserver.dao.LogDao;
-import com.judong.chuanyiserver.dao.UserDao;
 import com.judong.chuanyiserver.entity.Log;
-import com.judong.chuanyiserver.entity.User;
 import com.judong.chuanyiserver.enums.ResultEnum;
 import com.judong.chuanyiserver.service.LogService;
 import com.judong.chuanyiserver.util.Result;
-import com.judong.chuanyiserver.util.UserUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -24,12 +21,6 @@ public class LogServiceImpl implements LogService {
     @Resource
     private LogDao logDao;
 
-    @Resource
-    private UserDao userDao;
-
-    @Resource
-    private UserUtil userUtil;
-
     @Override
     public Result getLogPage(int page, int limit, String serverName, String modelName, String content, String userId,String ipAddress, String methodName,String startDate,String endDate) {
         JSONObject jsonObject = new JSONObject();
@@ -46,9 +37,6 @@ public class LogServiceImpl implements LogService {
         if (logDao.insertLog(log) <= 0) {
             return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "添加日志失败");
         }
-        //获取当前登陆人的信息
-        User User = userUtil.getCurrentUser();
-        log.setUserId(User.getUserName()+"@"+User.getUserId());
         return Result.ok("添加日志成功");
     }
 

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

@@ -29,7 +29,7 @@ import java.util.concurrent.Executors;
 public class KepOpcServerUtil {
 
     /**
-     * 通过传入的serverInformation,判断是否符合生成键
+     * 通过传入的serverInformation,判断是否符合KepOpcServe连接
      *
      * @param serverInformation
      * @return
@@ -184,6 +184,15 @@ public class KepOpcServerUtil {
         return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
     }
 
+    public static Result closeConnect(ServerInformation serverInformation) {
+        String opcServerDaPoolKey = KepOpcServerUtil.generateOpcPoolKey(serverInformation);
+        if (KepOpcServerUtil.validationKey(opcServerDaPoolKey)) {
+            KepOpcServerPoolFactory.closeServer(opcServerDaPoolKey);
+            return Result.ok("关闭连接成功");
+        }
+        return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+    }
+
     /**
      * 通过服务器信息和标签名称读取响应的数据
      *
@@ -201,14 +210,11 @@ public class KepOpcServerUtil {
                     return Result.no(ResultEnum.NOT_FOUND.getRespCode(), "连接失败");
                 }
                 if (OPCSERVERSTATE.OPC_STATUS_RUNNING == server.getServerState().getServerState()) {
-                    JSONObject jsonObject = new JSONObject();
                     Group group = server.addGroup();
                     Item item = group.addItem(itemName);
                     Map<String, Object> value = getVal(item.read(true).getValue());
-                    jsonObject.put("javaType", value.get("javaType"));
-                    jsonObject.put("value", value);
                     KepOpcServerUtil.returnServer(opcServerDaPoolKey, server);
-                    return Result.ok(jsonObject);
+                    return Result.ok(value);
                 }
             }
         } catch (Exception e) {

+ 11 - 0
chuanyi_server/src/main/java/com/judong/chuanyiserver/util/OpcServerUaUtil.java

@@ -1,6 +1,7 @@
 package com.judong.chuanyiserver.util;
 
 import com.alibaba.fastjson.JSONObject;
+import com.judong.chuanyiserver.config.KepOpcServerPoolFactory;
 import com.judong.chuanyiserver.config.OpcServerUaPoolFactory;
 import com.judong.chuanyiserver.entity.ServerInformation;
 import com.judong.chuanyiserver.enums.ConnectModeEnum;
@@ -260,4 +261,14 @@ public class OpcServerUaUtil {
         return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
     }
 
+    public static Result closeConnect(ServerInformation serverInformation) {
+        String opcServerDaPoolKey = OpcServerUaUtil.generateOpcPoolKey(serverInformation);
+        if (OpcServerUaUtil.validationKey(opcServerDaPoolKey)) {
+            OpcServerUaPoolFactory.closeServer(opcServerDaPoolKey);
+            return Result.ok("关闭连接成功");
+        }
+        return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
+    }
+
+
 }

+ 4 - 2
chuanyi_server/src/main/resources/mapper/ConnectDao.xml

@@ -40,7 +40,8 @@
                create_time
         from sys_server_information
         where user_id = #{userId}
-          and ip_address = #{ipAddress}
+          and connect_name = #{connectName}
+          and connect_mode = #{connectMode}
     </select>
     <select id="getServerInformationById" resultType="com.judong.chuanyiserver.entity.ServerInformation">
         select id,
@@ -87,7 +88,8 @@
                create_time
         from sys_server_information
         where user_id = #{userId}
-          and ip_address = #{ipAddress}
+          and connect_name = #{connectName}
+          and connect_mode = #{connectMode}
           and id != #{id}
     </select>
 </mapper>

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

@@ -5,7 +5,7 @@
     <insert id="addDepartment">
         insert into sys_department (parent_id, department_name, department_describe, department_num, create_time,
                                     is_delete)
-            VALUE (#{parentId}, #{departmentName}, #{departmentDescribe}, #{departmentNum}, now(), #{isDelete})
+            VALUE (#{parentId}, #{departmentName}, #{departmentDescribe}, #{departmentNum}, now(), 0)
     </insert>
     <update id="updateDepartment">
         update sys_department