XNMS项目-用户管理,包括添加、修改、删除、查询、邮箱配置等功能

文章目录

一、背景

XNMS(Extended Network Management System,增强型网络管理系统)是一款远程监控和管理常规中转台的软件。

中转台是系统的核心设备,所有业务都通过其进行中转。因此,只要对中转台进行监控,就能全面掌握系统的运行状况。而中转台通常部署室外,容易受到日晒雨淋等自然条件影响,造成设备损坏。为保证通讯系统正常运行,工作人员需要对中转台进行实时监控,发现中转台的异常问题,从而采取相关措施进行补救。

通过XNMS软件,工作人员可实时监控常规中转台的各项参数和告警情况,对异常问题进行排查;还可以查询或统计某时间段内中转台或终端的业务,从而全面了解常规系统的运行状况。

用户管理模块规范:

  1. 添加用户弹窗:用户名标签提示"用户名不能为空!",如果存在提示"用户已存在!",邮箱信息校验提示"邮箱格式不合法",告警类型为空提示"告警类型不能为空"
  2. 是否保存邮箱信息判断依据是邮箱地址栏是否有值
  3. 除了一级二级用户,其它级别账户禁用【添加、修改、删除】按钮操作
  4. admin账户添加用户时有上级管理员下拉列表,其他账户登录没有
  5. 修改用户弹窗:用户名是禁止修改的,
  6. 添加用户成功后弹窗
  7. 添加用户功能中操作权限封装完整的list传参,不勾选默认值为0,勾选则为1,且根节点默认为0
  8. 查看权限展示用户名+上级管理员+功能权限列表+中转台列表,标签栏都是只读
  9. Admin账号登录,添加弹窗都有,且上级管理员改变后->中转台列表也改变;
    修改弹窗,用户无法修改,其他可修改
    查看弹窗,基本信息都无可修改,且邮箱信息也隐藏
    二级账户登录,添加弹窗没有上级管理员列表
    修改也无上级管理员列表
    查看有上级管理员列表
    非一二级账户,只有刷新按钮
  10. 右下角可以选择展示条数【10/20/30/40/50每页】


二、页面

用户管理

添加


编辑


查看

三、代码

UserManage.vue

java 复制代码
<template>
  <layout_1>
    <a-spin
        :size="80"
        :loading="uploadeLoading"
        :tip="$t('Loading')"
        style="width: 100%; height: 100%"
    >
      <div class="--search-line">
        <a-button class="huge" @click="openAddUser" v-if="operationAuthorityDisabled" :disabled="threeLevelAccount">
          <template #icon>
            <icon-plus size="18" />
          </template>{{$t('Add')}}</a-button>
        <a-button class="huge" @click="openUpdateUser" v-if="operationAuthorityDisabled"  :disabled="updateUserButtonDisabled || threeLevelAccount">
          <template #icon>
            <icon-edit size="18" />
          </template>{{$t('Edit')}}</a-button>
        <a-button class="huge" @click="deleteTable" v-if="operationAuthorityDisabled"  :disabled="deleteUserButtonDisabled || threeLevelAccount">
          <template #icon>
            <icon-delete size="18" />
          </template>{{$t('Delete')}}</a-button>

        <a-button class="huge" @click="refreshUser">
          <template #icon>
            <icon-refresh size="18" />
          </template>{{$t('Refresh')}}</a-button>
      </div>
      <div class="table-line">
      <a-table :data="tableData" :bordered="false" :pagination="false" :loading="tableLoading"
               :scroll="{ x: '100%', y: '684' }" :row-selection="rowSelection" v-model:selected-keys="selectedKeys" row-key="name" class="--arco-table">
        <template #empty>
          <div style="text-align: center">{{ $t('NoData') }}</div>
        </template>
        <template #columns>
          <a-table-column dataIndex="userId" :tooltip="true" v-if="false"></a-table-column>
          <a-table-column dataIndex="name" :title="$t('UserName')" :tooltip="true" ellipsis="true" :width="170"></a-table-column>
          <a-table-column dataIndex="pUserName" :title="$t('Supervisor')" :tooltip="true"></a-table-column>
          <a-table-column dataIndex="functions" :title="$t('Authority')" :tooltip="true" :bordered="{wrapper: true, cell: true}">
            <template #cell="{ record }">
              <div><a-button @click="viewPermission(record.name)">{{$t('Read')}}</a-button></div>
            </template>
          </a-table-column>
          <a-table-column dataIndex="emails" :title="$t('Email')" :tooltip="true">
            <template #cell="{ record }">
              <div>
                <template v-for="(item, index) in record.emails" :key="item.id">
                  <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;" :title="item.email">{{ item.email }}</div>
                  <div v-if="index < record.emails.length - 1"><br /></div>
                </template>
              </div>
            </template>
          </a-table-column>

          <a-table-column dataIndex="noticeLanguage" :title="$t('EmailLanguage')" :tooltip="true">
            <template #cell="{ record }">
              <div>
                <template v-for="(item, index) in record.emails" :key="item.id">
                  <div>{{ $t(noticeLanguage[item.noticeLanguage]) }}</div>
                  <div v-if="index < record.emails.length - 1"><br /></div>
                </template>
              </div>
            </template>
          </a-table-column>

          <a-table-column dataIndex="warningNotice" :title="$t('AlaramType')" :tooltip="true">
            <template #cell="{ record }">
              <div>
                <template v-for="(item, index) in record.emails" :key="item.id">
                  <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;" :title="parseWarningNotice(item.warningNotice)">{{ parseWarningNotice(item.warningNotice) }}</div>
                  <div v-if="index < record.emails.length - 1"><br /></div>
                </template>
              </div>
            </template>
          </a-table-column>
          <a-table-column dataIndex="isNeedEmail" :title="$t('IsSendOrNot')" :tooltip="true">
            <template #cell="{ record }">
              <div>
                <template v-for="(item, index) in record.emails" :key="item.id">
                  <div>{{  $t(isNeedEmail[item.isNeedEmail]) }}</div>
                  <div v-if="index < record.emails.length - 1"><br /></div>
                </template>
              </div>
            </template>
          </a-table-column>
          <a-table-column dataIndex="description" :title="$t('Description')" :tooltip="true" ellipsis="true" :width="200">
            <template #cell="{ record }">
              <div>
                <template v-for="(item, index) in record.emails" :key="item.id">
                  <div style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;" :title="item.description">{{ item.description }}</div>
                  <div v-if="index < record.emails.length - 1"><br /></div>
                </template>
              </div>
            </template>
          </a-table-column>
        </template>
      </a-table>
      <div class="--table-pager">
        <a-pagination :total="page.total" v-model:current="page.currentPage" v-model:page-size="page.pageSize"
                      @change="getTableData" @page-size-change="getTableData" show-total show-page-size />
      </div>
    </div>
    </a-spin>
  </layout_1>
  <add-user v-model:visible="addUserModal" v-if="addUserModal" ref="addUserRef" @refresh-flag="successFresh"  :view-no-displaymailbox="viewNoDisplaymailbox"></add-user>
</template>

<script setup>
import Layout_1 from "@/views/pages/_common/layout_1.vue";
import {reactive, ref, provide, inject, computed, nextTick} from "vue";
import {getUserManageList, deleteUser} from "@/views/pages/system/system.js";
import { commonResponse } from "@/views/pages/_common";
import { noticeLanguage, isNeedEmail, warningNotice } from "@/views/pages/_common/enum";
import { Message } from "@arco-design/web-vue";
import AddUser from "./userManage/AddUser.vue";

const t = inject('t')
const uploadeLoading = ref(false);
const page = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 0
})
const rowSelection = reactive({
  type: 'checkbox',
  showCheckedAll: true,
  onlyCurrent: false,
});

const operationAuthorityDisabled = inject("changeUserManagementDisabled")

const selectedKeys = ref([])
const tableData = ref([])
const tableLoading = ref(false)

const getTableData = async () => {
  tableLoading.value = true
  await getUserManageList({
    currentPage: page.currentPage,
    pageSize: page.pageSize
  }).then(response => {
    tableLoading.value = false
    commonResponse({
      response,
      onSuccess: () => {
        tableData.value = response.data
        page.total = response.pagination.totalRecords
        selectedKeys.value = []
      }
    })
  }).catch(e => tableLoading.value = true)
}

const addUserModal = ref(false)
const changeShowSuperiorAdministratorDropDownList = ref(true)
const changeDisableUserName = ref(false)
const addUserRef = ref(null)
const viewNoDisplaymailbox = ref(true)

provide('changeShowSuperiorAdministratorDropDownList', changeShowSuperiorAdministratorDropDownList)
provide('changeDisableUserName', changeDisableUserName)
const changeDisableSuperiorAdministratorList = ref(false)
provide('changeDisableSuperiorAdministratorList', changeDisableSuperiorAdministratorList)
const changeDisableFunctionOperate = ref(false)
provide('changeDisableFunctionOperate', changeDisableFunctionOperate)
const changeDdisableCanLook = ref(false)
provide('changeDdisableCanLook', changeDdisableCanLook)
const changeDisableCanEdit = ref(false)
provide('changeDisableCanEdit', changeDisableCanEdit)
const checkDisableTransferNodeCheckedAll = ref(false)
provide('checkDisableTransferNodeCheckedAll', checkDisableTransferNodeCheckedAll)
const checkDisableTransferNodeChecked = ref(false)
provide('checkDisableTransferNodeChecked', checkDisableTransferNodeChecked)
const changeShowEmailInfo = ref(true)
provide('changeShowEmailInfo', changeShowEmailInfo)
const changeShowOkButton = ref(true)
provide('changeShowOkButton', changeShowOkButton)

const openAddUser = () => {
  addUserModal.value = true;
  changeDisableUserName.value = false
  changeDisableSuperiorAdministratorList.value = false
  changeDisableFunctionOperate.value = false
  changeDdisableCanLook.value = false
  changeDisableCanEdit.value = false
  checkDisableTransferNodeCheckedAll.value = false
  checkDisableTransferNodeChecked.value = false
  changeShowEmailInfo.value = true
  changeShowOkButton.value = true
  viewNoDisplaymailbox.value = true
  const title = t('Add')
  let record = null
  nextTick(() => {
    addUserRef.value.setData(record, title)
  })
  getTableData()
  const principal = sessionStorage.getItem('principal');
  if (principal) {
    const principalObject = JSON.parse(principal);
    if (principalObject.pUserId == -1) {
      changeShowSuperiorAdministratorDropDownList.value = true
    } else {
      changeShowSuperiorAdministratorDropDownList.value = false
    }
  }
}


const openUpdateUser = async () => {
  addUserModal.value = true;
  changeDisableUserName.value = true
  changeShowEmailInfo.value = true
  changeShowOkButton.value = true
  changeDisableSuperiorAdministratorList.value = false
  changeDisableFunctionOperate.value = false
  changeDdisableCanLook.value = false
  changeDisableCanEdit.value = false
  checkDisableTransferNodeCheckedAll.value = false
  checkDisableTransferNodeChecked.value = false
  viewNoDisplaymailbox.value = true
  const title = t('Modify')
  nextTick(() => {
    addUserRef.value.setData(selectedKeys.value, title)
  })
}

const deleteTable = () => {
  deleteUser(selectedKeys.value).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        Message.success(t('Deleting'));
        getTableData()
      }
    })
  })
}

const threeLevelAccount = computed(() => {
  const principal = sessionStorage.getItem('principal');
  if (principal) {
    const principalObject = JSON.parse(principal);
    return principalObject.pUserId != -1 && principalObject.pUserId != 1;
  }
  return false;
});

const updateUserButtonDisabled = computed(() => {
  return selectedKeys.value.length != 1;
});

const deleteUserButtonDisabled = computed(() => {
  return selectedKeys.value.length <= 0;
});

const refreshUser = () => {
  getTableData()
}

const successFresh = () => {
  addUserModal.value = false;
  getTableData();
}

const viewPermission = (name) => {
  addUserModal.value = true;
  changeDisableUserName.value = true
  changeDisableSuperiorAdministratorList.value = true
  changeDisableFunctionOperate.value = true
  changeDdisableCanLook.value = true
  changeDisableCanEdit.value = true
  checkDisableTransferNodeCheckedAll.value = true
  viewNoDisplaymailbox.value = false
  const title = t('Read')
  nextTick(() => {
    addUserRef.value.setData(name, title)
  })
  changeShowEmailInfo.value = false
}

const parseWarningNotice = (fieldValue) => {
  if (fieldValue == "0,1,2,3,4") {
    return t("Custom_Report_SenderReceive-1")
  } else {
    const values = fieldValue.split(',');
    const contentArray = values.map(value => t(warningNotice[value.trim()]));
    return contentArray.join(', ');
  }
}

const init = async () => {
  uploadeLoading.value = true;
  getTableData()
  setTimeout(()=>{
    uploadeLoading.value = false;
  }, 1000)
}

init()
</script>

<style scoped lang="less">
.table-line {
  white-space: nowrap;
  box-sizing: border-box;
  margin-top: 20px;
  height: calc(100% - 60px);
}
</style>

AddUser.vue

java 复制代码
 <template>
  <a-modal :width="1000" :align-center="true" :title=openTitle>
    <a-radio-group v-model="activeKey" type="button" @change="activeKeyChange">
      <a-radio :value="1">{{$t('BaseInfo')}}</a-radio>
      <a-radio  v-if="props.viewNoDisplaymailbox"  :value="2">{{$t('EmailInfo')}}</a-radio>
    </a-radio-group>
    <div style="box-sizing: border-box; height: 582px;">
      <div v-show="activeKey === 1" style="margin-top: 22px; height: 100%">
        <a-spin :size="80" :loading="uploadeLoading" :tip="$t('Loading')">
          <base-info ref="baseInfoRef"></base-info>
        </a-spin>
      </div>
      <div v-show="activeKey === 2 && showEmailInfo" style="margin-top: 22px; height: 100%">
        <email-info ref="emailInfoRef"></email-info>
      </div>
    </div>
    <template #footer>
      <a-button type="primary" @click="saveUser()" v-show="showOkButton">{{$t('ExportTaskEnter')}}</a-button>
      <a-button @click="closeUser()">{{$t('cancelLabel')}}</a-button>
    </template>

    <a-modal :closable="false" :hideCancel="true" v-model:visible="createUserSucceedVisible" @ok="createUserSucceedHandleOk" @cancel="createUserSucceedHandleCancel" :ok-text="$t('ButtonOK')" :cancel-text="$t('ButtonCancel')">
      <template #title>
        {{$t('CreateUserSucceed')}}
      </template>
      <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 20px;">
        <div>{{$t('UserName')}}:{{userNameParam}}</div>
        <div>{{$t('Password')}}:888888</div>
      </div>
    </a-modal>
  </a-modal>

</template>

<script setup>
import {reactive, ref,defineProps , defineExpose, defineEmits, inject, onMounted, nextTick} from "vue";
import { addUser, queryUser, editUser, querySuperiorAdministratorDropDownList } from "@/views/pages/system/system.js";
import { commonResponse } from "@/views/pages/_common";
import BaseInfo from './addUser/BaseInfo.vue'
import EmailInfo from './addUser/EmailInfo.vue'
const t = inject('t')
import {Message} from "@arco-design/web-vue";

const props = defineProps({
  viewNoDisplaymailbox: {
    type: Boolean,
    default: true
  }
});

const openTitle = ref('')
const addFlag = ref(true)//true是添加,false是编辑
const emits = defineEmits(['refresh-flag'])

const baseInfoRef = ref(null)
const emailInfoRef = ref(null)
const activeKey = ref(1)
const userNameParam = ref("")
const createUserSucceedVisible = ref(false)
const showEmailInfo = ref(true)
const showOkButton = ref(true)
const uploadeLoading = ref(false)
const activeKeyChange = (val) => {
  activeKey.value = val
}


const createUserSucceedHandleOk = () => {
  createUserSucceedVisible.value = false
  emits('refresh-flag', 1)
}

const createUserSucceedHandleCancel = () => {
  createUserSucceedVisible.value = false
  emits('refresh-flag', 1)
}

const addUserParam = reactive({
  "userName" : "",
  "pUserID" : null,
  "functions" : [],
  "repeaters" : [],
  "emails" : []
});

const setData = (record, title) => {
  if (title == "查看" || title == "Вид" || title == "View") {
    showOkButton.value = false;
  } else {
    showOkButton.value = true;
  }
  uploadeLoading.value = true;
  openTitle.value = title
  if (null != record) {
    addFlag.value = false
    setTimeout(async () => {
      await queryUserDetailGetPUserName(record)
      await baseInfoRef.value.handleSelectChange(baseInfoRef.value.getData().param.pUserName)
      await queryUserDetail(record)
      uploadeLoading.value = false;
    }, 1000)
  } else {
    setTimeout(() => {uploadeLoading.value = false;}, 1500)
  }
}

const setCreateUserSucceedVisible = () => {
  createUserSucceedVisible.value = true
}

const querySuperiorAdministratorDropDown = () => {
  querySuperiorAdministratorDropDownList(addUserParam).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        const responseArr = response.data;
        let arr = []
        for (let i = 0; i < responseArr.length; i++) {
          arr.push({"name": responseArr[i].name, "userId": responseArr[i].userId, "pUserName": responseArr[i].pUserName, "pUserId": responseArr[i].pUserId})
        }
        baseInfoRef.value.setSuperiorAdministratorDropDownList(arr)
      }
    })
  }).catch(() => {})
}

const saveUser = () => {
  if (baseInfoRef.value.getData().userNameParam == "" || baseInfoRef.value.getData().userNameParam == null) {
    Message.error(t('UserNameCanNotEmpty'))
    return
  }
  if (Array.from(baseInfoRef.value.getData().userNameParam).length > 20) {
    Message.error(t('LimitUserNameError'))
    return
  }
  const emailItems = emailInfoRef.value.getData().emailItems;
  const emailSet = new Set();
  for (const item of emailItems) {
    if (item.isNeedEmail) {
      if (item.email == "" || item.email == null) {
        Message.error(t('EmailNameCanNotEmpty'))
        return
      }
    }
    if (item.email) {
      const regex = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      if (!regex.test(item.email)) {
        Message.error(t('EmailNotTrue'))
        return
      }
    }
    if (Array.from(item.email).length > 25) {
      Message.error(t('LimitEmailAddressError'))
      return
    }
    if (Array.from(item.description).length > 25) {
      Message.error(t('LimitDescriptionError'))
      return
    }

    if (emailSet.has(item.email)) {
      Message.error(t('EmailNameIsExist', [item.email]))
      return
    }
    emailSet.add(item.email)

    if (item.warningNotice.length == 0) {
      Message.error(t('AlarmInfoCanNotEmpty'))
      return
    }
  }

  let functionOperationAuthority = []
  const functionArr = baseInfoRef.value.getData().functionArr;
  for(let key in functionArr) {
    if (key.length > 3) {
      functionOperationAuthority.push({
        "funModuleId" : key,
        "canLook" : functionArr[key].canLook == true ? 1 : 0,
        "canEdit" : functionArr[key].canEdit == true ? 1 : 0
      })
    } else {
      functionOperationAuthority.push({
        "funModuleId" : key,
        "canLook" : 0,
        "canEdit" : 0
      })
    }
  }

  userNameParam.value = baseInfoRef.value.getData().userNameParam
  let emailsParams = [];
  for (const item of emailInfoRef.value.getData().emailItems) {
    if (item.email) {
      emailsParams.push({ email: item.email, warningNotice: item.warningNotice.length > 0 ? item.warningNotice.join(",") : item.warningNotice, isNeedEmail: item.isNeedEmail == true ? 1 : 0, noticeLanguage: item.noticeLanguage, description: item.description })
    }
  }
  let repeaters = baseInfoRef.value.getData().transferArr;

  const systemTypeParam = baseInfoRef.value.getData().systemTypeParam;
  const transferNodeListParam = baseInfoRef.value.getData().transferNodeListParam
  if (systemTypeParam == 1) {
    for (let i = 0; i < repeaters.length; i++) {
      for (let j = 0; j < transferNodeListParam.length; j++) {
        if (transferNodeListParam[j].repeaterId == repeaters[i]) {
          const childrenArr = transferNodeListParam[j].children
          for (let k = 0; k < childrenArr.length; k++) {
            repeaters.push(childrenArr[k].repeaterId)
          }
        }
      }
    }
  }

  const addUserParams = {
    userName: baseInfoRef.value.getData().userNameParam,
    userId : baseInfoRef.value.getData().param.userId,
    pUserId : baseInfoRef.value.getData().param.pUserId,
    pUserName : baseInfoRef.value.getData().param.pUserName,
    functions: functionOperationAuthority,
    repeaters: repeaters,
    emails: emailsParams
  }

  if (addFlag.value) {
    addUser(addUserParams).then(response => {
      commonResponse({
        response,
        onSuccess: () => {
          createUserSucceedVisible.value = true
        }
      })
    })
  } else {
    editUser(addUserParams).then(response => {
      commonResponse({
        response,
        onSuccess: () => {
          Message.success(t('PasswordChangeSuccess'));
          closeUser()
        }
      })
    })
  }

}

const closeUser =() => {
  emits('refresh-flag', 1)
}

const queryUserDetailGetPUserName = async (record) => {
  await queryUser(record).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        if (baseInfoRef.value && baseInfoRef.value.setUpdateParams) {
          baseInfoRef.value.setUpdateParams(response.data);
        }
      }
    })
  })
}
const queryUserDetail = async (record) => {
  await queryUser(record).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        if (baseInfoRef.value && baseInfoRef.value.setUpdateParams) {
          baseInfoRef.value.setUpdateParams(response.data);
        }
        if (response.data.emails.length == 0) {
          if (emailInfoRef.value && emailInfoRef.value.setUpdateParams) {
            emailInfoRef.value.setUpdateParams([{ email: '', warningNotice: ["0","1","2","3","4"], isNeedEmail: 0, noticeLanguage: '0', description: '' }]);
          }
        } else {
          if (emailInfoRef.value && emailInfoRef.value.setUpdateParams) {
            emailInfoRef.value.setUpdateParams(response.data.emails);
          }
        }
        baseInfoRef.value.setCheckRepeaterIds(response.data.repeaters, response.data.pUserName)
        baseInfoRef.value.setFunctionOperateCheckNodes(response.data.functions)
      }
    })
  })
}

onMounted(() => {
  showEmailInfo.value = inject("changeShowEmailInfo").value
  showOkButton.value = inject("changeShowOkButton").value
})

defineExpose({
  setData,
  setCreateUserSucceedVisible,
})

const init = () => {
  querySuperiorAdministratorDropDown()
}


init()
</script>

<style scoped lang="less">
.label {
  position: relative;
  line-height: 38px;
}

.wrapper {
  width: 400px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #adb5c4;
  font-family: 'PingFang TC';
}

.parent {
  align-self: stretch;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2px;
  justify-content: space-between;
}


.frameParent {
  flex: 1;
  width: 100%;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  text-align: left;
  font-size: 14px;
  color: #778091;
  font-family: 'PingFang SC';
}
</style>

BaseInfo.vue

java 复制代码
<template>
  <div class="base-info">
    <div class="base-info-item inline">
      <div class="key inline">{{$t('UserName')}}:</div>
      <div class="val inline">
        <a-input style="margin-left: 8px; width: 260px" max-length="20" v-model="userName" :disabled="disableUserName" @blur="handleUserName"></a-input>
      </div>
    </div>
    <div class="base-info-item inline" style="margin-left: 24px" v-show="showSuperiorAdministratorDropDownList">
      <div class="key inline">{{$t('Supervisor')}}:</div>
      <div class="val inline">
        <a-select v-model="param.pUserName" style="margin-left: 8px; width: 260px;" @change="handleSelectChange" :disabled="disableSuperiorAdministratorList">
          <a-option v-for="(item, index) in superiorAdministratorDropDownList" :value="item.name" :key="index">{{ item.name }}</a-option>
        </a-select>
      </div>
    </div>
  </div>
  <div class="content-info">
    <div class="content-info-item">
      <div class="title-box">
        <div class="title-name">{{$t('FunctionalOperatioPermissions')}}</div>
        <div style="margin-top: 2px"><a-checkbox v-model="isFuncOperateCheckAll" @change="functionOperateCheckAll" :disabled="disableFunctionOperate">{{$t('SelectAll')}}</a-checkbox></div>
      </div>
      <div class="box">
        <a-table
            size="medium"
            style="height: 100%"
            :data="functionOperateTable"
            row-key="code"
            :bordered="false"
            :scroll="{ x: '100%', y: 550 }"
            :default-expanded-keys="expandedKeys"
            :pagination="false">
          <template #expand-icon="{expanded}">
            <icon-caret-down v-if="expanded"/>
            <icon-caret-right v-else/>
          </template>
          <template #empty>
            <div style="text-align: center">{{ $t('NoData') }}</div>
          </template>
          <template #columns>
            <a-table-column :title="$t('Function')" data-index="key">
              <template #cell="{record}">
                <div style="position: relative; height: 28px">
                  <div style="position: absolute; top: 50%; transform: translateY(-50%)" >
                    <div class="inline" style="margin-right: -2px; height: 22px" v-if="record.children?.length">
                      <img :src="require('@/assets/img/folder.png')">
                    </div>
                    <div class="inline" style="margin-left: 8px">{{$t(record.name)}}</div>
                  </div>
                </div>
              </template>
            </a-table-column>
            <a-table-column :title="$t('Read')" data-index="hasRead" width="120">
              <template #cell="{record}">
                <div style="position: relative; height: 100%" v-if="record.id.length > 3 && record.hasRead && record.canLook">
                  <a-checkbox style="position: absolute; top: 50%; transform: translateY(-50%)" @click="clickCanLook(record.code, functionOperateCheckNodes[record.code].canLook)" v-model="functionOperateCheckNodes[record.code].canLook" :disabled="disableCanLook"></a-checkbox>
                </div>
              </template>
            </a-table-column>
            <a-table-column :title="$t('Write')" data-index="hasWrite" width="120">
              <template #cell="{record}">
                <div style="position: relative; height: 100%" v-if="record.id.length > 3 && record.hasWrite && record.canEdit">
                  <a-checkbox style="position: absolute; top: 50%; transform: translateY(-50%)" @click="clickCanEdit(record.code, functionOperateCheckNodes[record.code].canEdit)" v-model="functionOperateCheckNodes[record.code].canEdit" :disabled="disableCanEdit"></a-checkbox>
                </div>
              </template>
            </a-table-column>
          </template>
        </a-table>
      </div>
    </div>
    <div class="content-info-item">
      <transfer-desk-manage-n-o-r v-if="useStore().getMode() === 0" ref="transferDeskManageRef"></transfer-desk-manage-n-o-r>
      <transfer-desk-manage-x-p-t v-else ref="transferDeskManageRef"></transfer-desk-manage-x-p-t>
    </div>
  </div>
</template>

<script setup>


import {computed, onMounted, reactive, ref, inject} from "vue";
import {commonResponse, treeFormatChild} from "@/views/pages/_common";
import TransferDeskManageNOR from "@/views/pages/system/userManage/addUser/TransferDeskManage-NOR.vue";
import TransferDeskManageXPT from "@/views/pages/system/userManage/addUser/TransferDeskManage-XPT.vue";
import {useStore} from "@/stores";
import {getOperatePermission} from "@/views/pages/system/system";
import {Message} from "@arco-design/web-vue";

const param = reactive({
  userId: 1,
  pUserId: 1,
  pUserName: "Admin",
})
const userName = ref("")
const t = inject('t')
const showSuperiorAdministratorDropDownList = ref(true)
const disableUserName = ref(false)
const disableSuperiorAdministratorList = ref(false)
const disableFunctionOperate = ref(false)
const disableCanLook = ref(false)
const disableCanEdit = ref(false)
const functionOperateTable = ref([])
const superiorAdministratorDropDownList = ref([])
const functionOperateCheckNodes = reactive({})
const expandedKeys = reactive([])

showSuperiorAdministratorDropDownList.value = inject("changeShowSuperiorAdministratorDropDownList").value
disableUserName.value = inject("changeDisableUserName").value
disableSuperiorAdministratorList.value = inject("changeDisableSuperiorAdministratorList").value
disableFunctionOperate.value = inject("changeDisableFunctionOperate").value
disableCanLook.value = inject("changeDdisableCanLook").value
disableCanEdit.value = inject("changeDisableCanEdit").value

const handleUserName = () => {
  if (userName.value == "" || userName.value == null) {
    Message.error(t('UserNameCanNotEmpty'))
    return
  }
  if (Array.from(userName.value).length > 20) {
    Message.error(t('LimitUserNameError'))
    return
  }
}
const clickCanLook = (code, oldCanLookFlag) => {
  if (functionOperateCheckNodes[code].hasLookCheckBox && functionOperateCheckNodes[code].hasEditCheckBox) {
    if (oldCanLookFlag && functionOperateCheckNodes[code].canLook && functionOperateCheckNodes[code].canEdit) {
      functionOperateCheckNodes[code].canEdit = !oldCanLookFlag;
    }
  }
}
const clickCanEdit = (code, oldCanEditFlag) => {
  if (functionOperateCheckNodes[code].hasLookCheckBox && functionOperateCheckNodes[code].hasEditCheckBox) {
    if (!oldCanEditFlag && !functionOperateCheckNodes[code].canLook && !functionOperateCheckNodes[code].canEdit) {
      functionOperateCheckNodes[code].canLook = !oldCanEditFlag;
    }
  }
}

const setFunctionOperateCheckNodes = (functionsArr) => {
  for (let key in functionOperateCheckNodes) {
    for (let i = 0; i < functionsArr.length; i++) {
      if (functionsArr[i].code == key) {
        if (functionsArr[i].canLook == 1) {
          functionOperateCheckNodes[key].canLook = true
        }
        if (functionsArr[i].canEdit == 1) {
          functionOperateCheckNodes[key].canEdit = true
        }
      }
    }
  }
}

const setUpdateParams = (response) => {
  userName.value = response.name
  param.userId = response.userId
  param.pUserName = response.pUserName
  param.pUserId = response.pUserId
}
const setSuperiorAdministratorDropDownList = (args) => {
  superiorAdministratorDropDownList.value = args
}
const handleSelectChange = async (value) => {
  const selectedItem = superiorAdministratorDropDownList.value.find(item => item.name === value);
  if (selectedItem) {
    param.pUserId = selectedItem.userId;
    param.pUserName = selectedItem.name;
  }
  await getFunctionOperateTable(value);
  await transferDeskManageRef.value.getTransferNodeList(value)
}

const getFunctionOperateTable = async (userName) => {
  if (userName == "" || userName == null) {
    const principal = sessionStorage.getItem('principal');
    if (principal) {
      const principalObject = JSON.parse(principal);
      userName = principalObject.userName
    }
  }
  await getOperatePermission({"userName": userName}).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        expandedKeys.length = 0
        functionOperateTable.value = treeFormatChild(response.data, 'children',true)
        functionOperateTable.value.forEach(t => {
          expandedKeys.push(t.code)
        })
        const calcCheckNodes = (node, rootNode = false) => {
          if (rootNode) {
            node.forEach(item => {
              functionOperateCheckNodes[item.code] = {
                canLook: false,
                canEdit: false,
                hasLookCheckBox: item.hasRead && item.canLook,
                hasEditCheckBox: item.hasWrite && item.canEdit
              }
              calcCheckNodes(item)
            })
          } else {
            node.children?.forEach(item => {
              functionOperateCheckNodes[item.code] = {
                canLook: false,
                canEdit: false,
                hasLookCheckBox: item.hasRead == 1 && item.canLook == 1,
                hasEditCheckBox: item.hasWrite == 1 && item.canEdit == 1
              }
              calcCheckNodes(item)
            })
          }
        }
        calcCheckNodes(functionOperateTable.value, true)
      }
    })
  })
}
const isFuncOperateCheckAll = computed(() => {
  let checkAll = true
  for (let key in functionOperateCheckNodes) {
    if ((functionOperateCheckNodes[key].hasLookCheckBox && !functionOperateCheckNodes[key].canLook)
        || (functionOperateCheckNodes[key].hasEditCheckBox && !functionOperateCheckNodes[key].canEdit)) {
      checkAll = false
      break
    }
  }
  return checkAll
})
const functionOperateCheckAll = () => {
  const all = isFuncOperateCheckAll.value
  for(let key in functionOperateCheckNodes) {
    if (functionOperateCheckNodes[key].hasLookCheckBox) functionOperateCheckNodes[key].canLook = !all
    if (functionOperateCheckNodes[key].hasEditCheckBox) functionOperateCheckNodes[key].canEdit = !all
  }
}

const transferDeskManageRef = ref(null)
const getData = () => {
  const functionArr = functionOperateCheckNodes
  const transferArr = transferDeskManageRef.value.getData()
  const systemTypeParam = transferDeskManageRef.value.getTransferDeskManagerSystemType()
  const transferNodeListParam = transferDeskManageRef.value.getTransferDeskManagerTransferNodeList()
  const userNameParam = userName.value
  return {functionArr, transferArr, userNameParam, param, systemTypeParam, transferNodeListParam}
}

const setCheckRepeaterIds = (repeaters, pUserName) => {
  transferDeskManageRef.value.setCheckRepeaterIds(repeaters, pUserName)
}

const initPrincipal = () => {
  const principal = sessionStorage.getItem('principal');
  if (principal) {
    const principalObject = JSON.parse(principal);
    param.pUserName = principalObject.userName
    param.pUserId = principalObject.userId
  }
}

const init = () => {
  if (!disableUserName.value) getFunctionOperateTable()
  initPrincipal()
}

init()

defineExpose({
  getData,
  setSuperiorAdministratorDropDownList,
  setUpdateParams,
  setCheckRepeaterIds,
  setFunctionOperateCheckNodes,
  handleSelectChange,
})
</script>

<style scoped lang="less">
.base-info {
  &-item {
    .key {
      line-height: 40px;
      color: var(--N60, #778091);
      font-feature-settings: 'liga' off, 'clig' off;
      font-family: "PingFang SC";
      font-size: 14px;
      font-style: normal;
      font-weight: 400;
    }
  }
}
.content-info {
  display: flex;
  gap: 46px;
  margin-top: 24px;
  &-item {
    flex: 1;
    .title-box {
      display: flex;
      justify-content: space-between;
      .title-name {
        color: var(--Grey-80, #202B40);
        font-feature-settings: 'liga' off, 'clig' off;
        font-family: "PingFang SC";
        font-size: 18px;
        font-style: normal;
        font-weight: 500;
        line-height: 22px; /* 122.222% */
      }
    }
    .box {
      margin-top: 12px;
      height: 484px;
    }
  }
}
</style>

EmailInfo.vue

java 复制代码
<template>
  <div v-for="(item, index) in emailItems" :key="index">
    <div class="email-info">
      <div class="email-info-item inline">
        <div class="val inline">
          <a-input style="margin-left: 8px; width: 260px" v-model="item.email" :placeholder="$t('Email')"></a-input>
        </div>
      </div>
      <div class="email-info-item inline" style="margin-left: 24px">
        <div class="val inline">
          <a-select v-model="item.warningNotice" style="width: 500px;margin-top: -8px" multiple allow-clear>
            <a-option value="0" :label="$t('Voltage')"></a-option>
            <a-option value="1" :label="$t('Temperature')"></a-option>
            <a-option value="2" :label="$t('Vswr')"></a-option>
            <a-option value="3" :label="$t('TxPll')"></a-option>
            <a-option value="4" :label="$t('RxPll')"></a-option>
          </a-select>
        </div>
      </div>
    </div>
    <div class="email-info">
      <div class="email-info-item inline">
        <div class="val inline">
          <a-checkbox v-model="item.isNeedEmail" style="margin-left: 26px;margin-top: -8px;margin-right: 8px"></a-checkbox>{{$t('IsSendOrNot')}}
        </div>
      </div>
      <div class="email-info-item inline" style="margin-left: 24px">
        <div class="val inline">
          <a-select v-model="item.noticeLanguage" style="width: 150px;margin-left: 26px;margin-top: -8px" >
            <a-option value="0" :label="$t('English')"></a-option>
            <a-option value="1" :label="$t('Chinese')"></a-option>
          </a-select>
        </div>
      </div>
      <div class="email-info-item inline">
        <div class="val inline">
          <a-input style="margin-left: 8px; width: 450px;margin-top: -8px" v-model="item.description" :placeholder="$t('Alaram_HeadDesciption')"></a-input>
          <a-button v-show="index > 0" style="margin-left: 8px" type="primary" @click="deleteItem(index)">x</a-button>
        </div>
      </div>
    </div>
    <div class="email-info">
      <div class="email-info-item inline">
        <div class="val inline">
          <a-button type="primary" @click="addItem()">+</a-button>
        </div>
      </div>
    </div>
  </div>

</template>

<script setup>


import {reactive} from "vue";

const emailItems = reactive([
  { email: '', warningNotice: ["0","1","2","3","4"], isNeedEmail: false, noticeLanguage: '0', description: '' },
]);

const deleteItem = (index) => {
  if (index >= 0 && index < emailItems.length) {
    emailItems.splice(index, 1);
  }
};
const addItem = () => {
  if (emailItems.length < 3) {
    emailItems.push({ email: '', warningNotice: ["0","1","2","3","4"], isNeedEmail: false, noticeLanguage: '0', description: '' });
  }
};

const setUpdateParams = (response) => {
  emailItems.splice(0, emailItems.length);
  for (const item of response) {
    let warningNotice = item.warningNotice;
    if (warningNotice.includes(",")) {
      warningNotice = warningNotice.split(",")
    }
    emailItems.push({ email: item.email, warningNotice: warningNotice, isNeedEmail: item.isNeedEmail == 1 ? true :false, noticeLanguage: item.noticeLanguage, description: item.description })
  }

}

const getData = () => {
  return {emailItems}
}

const init = () => {
}

init()

defineExpose({
  getData,
  setUpdateParams
})
</script>

<style scoped lang="less">
.email-info {
  margin-top: 20px;
  display: flex;
  align-items: center;
  &-item {
    .key {
      line-height: 40px;
      color: var(--N60, #778091);
      font-feature-settings: 'liga' off, 'clig' off;
      font-family: "PingFang SC";
      font-size: 14px;
      font-style: normal;
      font-weight: 400;
    }
  }
}
</style>

TransferDeskManage-NOR.vue

java 复制代码
<template>
  <div class="title-box">
    <div class="title-name">{{$t('RepeaterAdministrativeAuthority')}}</div>
    <div style="margin-top: 2px"><a-checkbox @change="checkAll" v-model="isCheckedAll" :disabled="disableTransferNodeCheckedAll">{{$t('SelectAll')}}</a-checkbox></div>
  </div>
  <div class="box">
    <a-table
        size="medium"
        style="height: 100%"
        :data="transferNodeList"
        row-key="repeaterId"
        :bordered="false"
        :scroll="{ x: '100%', y: 550 }"
        :default-expanded-keys="expandedKeys"
        :defaultExpandAllRows="true"
        :pagination="false">
      <template #empty>
        <div style="text-align: center">{{ $t('NoData') }}</div>
      </template>
      <template #expand-icon="{expanded}">
        <icon-caret-up v-if="expanded"/>
        <icon-caret-down v-else/>
      </template>
      <template #columns>
        <a-table-column title="" width="60">
          <template #cell="{record}">
            <div style="position: relative; height: 100%">
              <a-checkbox style="position: absolute; top: 50%; transform: translateY(-50%)" v-if="!record.repeaterId.includes('virtual_')" v-model="checkedList[record.repeaterId]" :disabled="disableTransferNodeChecked"></a-checkbox>
            </div>
          </template>
        </a-table-column>
        <a-table-column ellipsis="true" :tooltip="true" :title="$t('RadioAlias')" data-index="name" width="120"></a-table-column>
        <a-table-column ellipsis="true" :tooltip="true" :title="$t('SerialNo')" data-index="serialNo" width="120"></a-table-column>
      </template>
    </a-table>
  </div>
</template>

<script setup>
import {computed, inject, onMounted, reactive, ref} from "vue";
import {qryTransferNodeList} from "@/views/pages/topology/_request";
import {commonResponse, treeFormatChild} from "@/views/pages/_common";

const disableUserName = ref(false)
const transferNodeList = ref([])
const systemType = ref(0)
const disableTransferNodeCheckedAll = ref(false)
const disableTransferNodeChecked = ref(false)
const checkRepeaterIds = ref([])
const expandedKeys = reactive([])
const checkedList = reactive({})

disableUserName.value = inject("changeDisableUserName").value

const setCheckRepeaterIds = (repeaters, pUserName) => {
  checkRepeaterIds.value.splice(0, checkRepeaterIds.value.length);
  checkRepeaterIds.value = repeaters
  for (let key in checkedList) {
    for (let i = 0; i < checkRepeaterIds.value.length; i++) {
      if (key == (checkRepeaterIds.value)[i]) {
        checkedList[key] = true;
      }
    }
  }
}

const getTransferNodeList = async (userName) => {
  if (userName == "" || userName == null) {
    const principal = sessionStorage.getItem('principal');
    if (principal) {
      const principalObject = JSON.parse(principal);
      userName = principalObject.userName
    }
  }
  await qryTransferNodeList({"userName": userName}).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        expandedKeys.length = 0
        transferNodeList.value = []
        Object.keys(checkedList).forEach(key => {
          delete checkedList[key];
        });
        const tree = treeFormatChild(response.data, 'children',true)
        tree.forEach(t => {
          expandedKeys.push(t.repeaterId)
        })
        tree?.forEach(item => {
          transferNodeList.value.push(item)
          if (!item.repeaterId.includes('virtual_')) {
            checkedList[item.repeaterId] = false
          }
          if (item.children != null && item.children != '' && item.children != undefined) {
            item.children.forEach(itemChild => {
              if (itemChild.children?.length) {
                itemChild.children.forEach(itemChildChild => {
                  checkedList[itemChildChild.repeaterId] = false
                })
              }
              checkedList[itemChild.repeaterId] = false
            })
          }
        })
      }
    })
  })
}

const isCheckedAll = computed(() => {
  let checkAll = true
  for(let key in checkedList) {
    if (!checkedList[key]) {
      checkAll = false
      break
    }
  }
  return checkAll
})
const checkAll = () => {
  const all = !isCheckedAll.value
  for(let key in checkedList) {
    checkedList[key] = all
  }
}

const getData = () => {
  const res = []
  for (let key in checkedList) {
    if (checkedList[key]) {
      res.push(key)
    }
  }
  return res
}

const getTransferDeskManagerSystemType = () => {
  const systemTypeParam = systemType.value;
  return systemTypeParam
}
const getTransferDeskManagerTransferNodeList = () => {
  const transferNodeListParam = transferNodeList.value;
  return transferNodeListParam
}

onMounted(() => {
  disableTransferNodeCheckedAll.value = inject("checkDisableTransferNodeCheckedAll").value
  disableTransferNodeChecked.value = inject("checkDisableTransferNodeChecked").value
})

const init = () => {
  if (!disableUserName.value) getTransferNodeList();
}

init()

defineExpose({
  getData,
  getTransferNodeList,
  setCheckRepeaterIds,
  getTransferDeskManagerSystemType,
  getTransferDeskManagerTransferNodeList
})
</script>

<style scoped lang="less">
.title-box {
  display: flex;
  justify-content: space-between;
  .title-name {
    color: var(--Grey-80, #202B40);
    font-feature-settings: 'liga' off, 'clig' off;
    font-family: "PingFang SC";
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 22px; /* 122.222% */
  }
}
.box {
  margin-top: 12px;
  height: 484px;
}
</style>

TransferDeskManage-XPT.vue

java 复制代码
<template>
  <div class="title-box">
    <div class="title-name">{{$t('RepeaterAdministrativeAuthority')}}</div>
    <div style="margin-top: 2px"><a-checkbox @change="checkAll" v-model="isCheckedAll" :disabled="disableTransferNodeCheckedAll">{{$t('SelectAll')}}</a-checkbox></div>
  </div>
  <div class="box">
    <a-table
        size="medium"
        style="height: 100%"
        :data="transferNodeList"
        row-key="repeaterId"
        :bordered="false"
        :scroll="{ x: '100%', y: 550 }"
        :default-expanded-keys="expandedKeys"
        :pagination="false">
      <template #empty>
        <div style="text-align: center">{{ $t('NoData') }}</div>
      </template>
      <template #expand-icon="{expanded}">
        <icon-caret-up v-if="expanded"/>
        <icon-caret-down v-else/>
      </template>
      <template #columns>
        <a-table-column title="" width="60">
          <template #cell="{record}">
            <div style="position: relative; height: 100%" v-if="record.repeaterId.includes('site_')">
              <a-checkbox style="position: absolute; top: 50%; transform: translateY(-50%)" v-model="checkedList[record.repeaterId]" :disabled="disableTransferNodeChecked"></a-checkbox>
            </div>
          </template>
        </a-table-column>
        <a-table-column ellipsis="true" :tooltip="true" :title="$t('RadioAlias')" data-index="name" width="120"></a-table-column>
        <a-table-column ellipsis="true" :tooltip="true" :title="$t('SerialNo')" data-index="serialNo" width="120"></a-table-column>
      </template>
    </a-table>
  </div>
</template>

<script setup>
import {computed, inject, onMounted, reactive, ref} from "vue";
import {qryTransferNodeList} from "@/views/pages/topology/_request";
import {commonResponse, treeFormatChild} from "@/views/pages/_common";

const disableUserName = ref(false)
const systemType = ref(1)
const transferNodeList = ref([])
const disableTransferNodeCheckedAll = ref(false)
const disableTransferNodeChecked = ref(false)
const siteMap = ref(new Map())
const checkRepeaterIds = ref([])
const expandedKeys = reactive([])
const checkedList = reactive({})

disableUserName.value = inject("changeDisableUserName").value

const setCheckRepeaterIds = (repeaters, pUserName) => {
  checkRepeaterIds.value.splice(0, checkRepeaterIds.value.length);
  checkRepeaterIds.value = repeaters
  for (let key in checkedList) {
    for (let i = 0; i < checkRepeaterIds.value.length; i++) {
      if (key == (checkRepeaterIds.value)[i]) {
        checkedList[key] = true;
      }
    }
  }
}

const getTransferNodeList = async (userName) => {
  if (userName == "" || userName == null) {
    const principal = sessionStorage.getItem('principal');
    if (principal) {
      const principalObject = JSON.parse(principal);
      userName = principalObject.userName
    }
  }
  await qryTransferNodeList({"userName": userName}).then(response => {
    commonResponse({
      response,
      onSuccess: () => {
        expandedKeys.length = 0
        transferNodeList.value = []
        Object.keys(checkedList).forEach(key => {
          delete checkedList[key];
        });
        const tree = treeFormatChild(response.data, 'repeaterInfos',true)
        tree.forEach(t => {
          expandedKeys.push(t.repeaterId)
        })
        tree?.forEach(item => {
          transferNodeList.value.push(item)
          checkedList[item.repeaterId] = false
        })
      }
    })
  })
}

const isCheckedAll = computed(() => {
  let checkAll = true
  for(let key in checkedList) {
    if (!checkedList[key]) {
      checkAll = false
      break
    }
  }
  return checkAll
})
const checkAll = () => {
  const all = !isCheckedAll.value
  for(let key in checkedList) {
    checkedList[key] = all
  }
}

const getData = () => {
  let res = []
  for (let key in checkedList) {
    if (checkedList[key]) {
      res.push(key)
      // res = [...res, ...siteMap.value.get(key)]
    }
  }
  return res
}

const getTransferDeskManagerSystemType = () => {
  const systemTypeParam = systemType.value;
  return systemTypeParam
}
const getTransferDeskManagerTransferNodeList = () => {
  const transferNodeListParam = transferNodeList.value;
  return transferNodeListParam
}

onMounted(() => {
  disableTransferNodeCheckedAll.value = inject("checkDisableTransferNodeCheckedAll").value
  disableTransferNodeChecked.value = inject("checkDisableTransferNodeChecked").value
})


const init = () => {
  if (!disableUserName.value) getTransferNodeList();
}

init()

defineExpose({
  getData,
  getTransferNodeList,
  setCheckRepeaterIds,
  getTransferDeskManagerSystemType,
  getTransferDeskManagerTransferNodeList
})
</script>

<style scoped lang="less">
.title-box {
  display: flex;
  justify-content: space-between;
  .title-name {
    color: var(--Grey-80, #202B40);
    font-feature-settings: 'liga' off, 'clig' off;
    font-family: "PingFang SC";
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 22px; /* 122.222% */
  }
}
.box {
  margin-top: 12px;
  height: 484px;
}
</style>

UserManageControl

java 复制代码
package com.xnms.client.service.controller.system.management;

import com.xnms.client.service.controller.common.ResponseModel;
import com.xnms.client.service.view.system.mangment.UserManageMentUserControl;
import com.xnms.data.contract.database.db.EmailInfoModel;
import com.xnms.data.contract.database.db.FunctionModule;
import com.xnms.data.contract.database.db.Pagination;
import com.xnms.data.contract.database.db.QueryConditionBase;
import com.xnms.data.contract.database.db.QueryPageBase;
import com.xnms.data.contract.database.db.QueryUserManageParams;
import com.xnms.data.contract.database.db.TopoRepeaterData;
import com.xnms.data.contract.database.db.UserVo;
import com.xnms.data.contract.database.db.WarningNotice;
import com.xnms.data.service.util.language.LanguageFind;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

@Api(tags = "系统管理-用户管理")
@RestController
@RequestMapping("/api/userManage")
public class UserManageControl {

    private static final Logger logger = LoggerFactory.getLogger(UserManageControl.class);

    @Autowired
    private LanguageFind languageFind;

    @Autowired
    private UserManageMentUserControl userManageMentUserControl;

    private final static String EMAIL_REGULAR = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";

    @Operation(summary = "批量查询")
    @PostMapping(value = "/queryUserList")
    public ResponseModel<List<UserVo>> queryUserList(@RequestBody QueryConditionBase query) {
        logger.info("-queryUserList-query:{}", query);
        QueryPageBase<UserVo> responseModel = userManageMentUserControl.queryUserList(query);
        return ResponseModel.ofSuccess(responseModel.getData(), Pagination.of(query.getCurrentPage(), query.getPageSize(), responseModel.getTotalCount()));
    }

    @Operation(summary = "详情查询")
    @GetMapping(value = "/queryUser/{userName}")
    public ResponseModel<UserVo> queryUser(@PathVariable String userName) {
        logger.info("-queryUser-userName:{}", userName);
        return userManageMentUserControl.queryUser(userName);
    }

    @Operation(summary = "告警通知类型下拉列表")
    @GetMapping(value = "/queryWarningNoticeDropDownList")
    public ResponseModel<List<WarningNotice>> queryWarningNoticeDropDownList() {
        List<WarningNotice> list = new ArrayList<>();
        list.add(new WarningNotice(languageFind.findKey("Voltage"), "0"));
        list.add(new WarningNotice(languageFind.findKey("Temperature"), "1"));
        list.add(new WarningNotice(languageFind.findKey("Vswr"), "2"));
        list.add(new WarningNotice(languageFind.findKey("TxPll"), "3"));
        list.add(new WarningNotice(languageFind.findKey("RxPll"), "4"));
        return ResponseModel.ofSuccess(list);
    }

    @Operation(summary = "上级管理员下拉列表")
    @GetMapping(value = "/querySuperiorAdministratorDropDownList")
    public ResponseModel<List<UserVo>> querySuperiorAdministratorDropDownList() {
        return userManageMentUserControl.querySuperiorAdministratorDropDownList();
    }

    @Operation(summary = "查询完整功能操作权限列表")
    @GetMapping(value = "/queryFunctionOperationAuthority")
    public ResponseModel<List<FunctionModule>> queryFunctionOperationAuthority(@RequestParam String userName) {
        return userManageMentUserControl.queryFunctionOperationAuthority(userName);
    }

    @Operation(summary = "添加用户")
    @PostMapping(value = "/addUser")
    public ResponseModel addUser(@RequestBody QueryUserManageParams params) {
        logger.info("-addUser-params:{}", params);
        if (StringUtils.isEmpty(params.getUserName())) {
            return ResponseModel.ofError(languageFind.findKey("UserNameCanNotEmpty"));
        }
        Pattern pattern = Pattern.compile(EMAIL_REGULAR);
        for (EmailInfoModel emailInfoModel: params.getEmails()) {
            if (StringUtils.isEmpty(emailInfoModel.getWarningNotice())) {
                return ResponseModel.ofError(languageFind.findKey("AlarmInfoCanNotEmpty"));
            }
            if (!pattern.matcher(emailInfoModel.getEmail()).find()) {
                return ResponseModel.ofError(languageFind.findKey("EmailNotTrue"));
            }
        }
        return userManageMentUserControl.addUser(params);
    }

    @Operation(summary = "修改用户")
    @PutMapping(value = "/editUser")
    public ResponseModel editUser(@RequestBody QueryUserManageParams params) {
        logger.info("-editUser-params:{}", params);
        Pattern pattern = Pattern.compile(EMAIL_REGULAR);
        for (EmailInfoModel emailInfoModel: params.getEmails()) {
            if (StringUtils.isEmpty(emailInfoModel.getWarningNotice())) {
                return ResponseModel.ofError(languageFind.findKey("AlarmInfoCanNotEmpty"));
            }
            if (!pattern.matcher(emailInfoModel.getEmail()).find()) {
                return ResponseModel.ofError(languageFind.findKey("EmailNotTrue"));
            }
        }
        return userManageMentUserControl.editUser(params);
    }

    @Operation(summary = "删除用户")
    @DeleteMapping(value = "/deleteUser")
    public ResponseModel deleteRepeaterByUserNames(@RequestBody List<String> userNames) {
        logger.info("-deleteRepeaterByUserNames-serialNos:{}", userNames);
        if (userNames.isEmpty()) {
            return ResponseModel.ofError(languageFind.findKey("UserNameCanNotEmpty"));
        }
        return userManageMentUserControl.deleteRepeaterByUserNames(userNames);
    }

    @Operation(summary = "查询中转台管理权限列表")
    @GetMapping(value = "/queryRepeaterAdministrativeAuthority")
    public ResponseModel<List<TopoRepeaterData>> queryRepeaterAdministrativeAuthority(@RequestParam String userName) {
        return userManageMentUserControl.queryRepeaterAdministrativeAuthority(userName);
    }

//    @Operation(summary = "查询用户菜单列表")
//    @GetMapping(value = "/queryUserMenu/{userName}")
//    public ResponseModel<List<FunctionModule>> queryUserMenu(@PathVariable String userName) {
//        return userManageMentUserControl.queryUserMenu(userName);
//    }

    @Operation(summary = "查询用户菜单列表")
    @GetMapping(value = "/queryUserMenu/{userName}")
    public ResponseModel<List<FunctionModule>> queryUserMenu(@PathVariable String userName) {
        return userManageMentUserControl.queryUserMenu(userName);
    }
}

UserManageMentUserControl

java 复制代码
package com.xnms.client.service.view.system.mangment;

import com.xnms.client.service.controller.common.ResponseModel;
import com.xnms.client.service.dao.dsI.commonl.CommonIClient;
import com.xnms.client.service.security.FunctionCodeClient;
import com.xnms.client.service.utils.RepeaterCache;
import com.xnms.client.service.view.topo.view.page.TopologyUserControl;
import com.xnms.data.contract.MultiResponse;
import com.xnms.data.contract.SingleResponse;
import com.xnms.data.contract.Utility;
import com.xnms.data.contract.database.db.*;
import com.xnms.data.service.api.client.ClientService;
import com.xnms.data.service.api.common.CommonService;
import com.xnms.data.service.util.language.LanguageFind;
import com.xnms.service.center.utility.ConfigValue;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

@Component
public class UserManageMentUserControl {

    private static final Logger logger = LoggerFactory.getLogger(UserManageMentUserControl.class);

    @Autowired
    private ClientService clientService;

    @Autowired
    private LanguageFind languageFind;

    @Autowired
    private FunctionNodeService functionNodeService;

    @Autowired
    private ConfigValue configValue;

    private static final String DEFAULT_PASSWORD = "888888";

    @Autowired
    private CommonService commonService;

    @Autowired
    private TopologyUserControl topologyUserControl;

    @Autowired
    private FunctionCodeClient functionCodeClient;

    @Autowired
    private CommonIClient commonIClient;


    /**
     * 用户管理批量查询
     *
     * @param query 请求参数
     * @return 结果
     */
    public QueryPageBase<UserVo> queryUserList(QueryConditionBase query) {
        Account account = (Account) SecurityUtils.getSubject().getPrincipal();
        Integer pUserId = account.getpUserId();
        if (!account.getUserId().equals("1")) {
            pUserId = Integer.valueOf(account.getUserId());
        }
        MultiResponse<UserRoleData> remoteUsersResponse = clientService.getUsersByPUserId(pUserId);
        MultiResponse<UserRoleData> allUsersResponse = clientService.getUsers();
        if (!remoteUsersResponse.isSuccess() || remoteUsersResponse.getData().isEmpty() || !allUsersResponse.isSuccess() || allUsersResponse.getData().isEmpty()) {
            return new QueryPageBase();
        }
        List<UserRoleData> remoteUsersList = remoteUsersResponse.getData();
        List<UserVo> remoteUsersListCopy = new ArrayList<>();
        for (UserRoleData user : remoteUsersList) {
            UserVo userVo = new UserVo();
            BeanUtils.copyProperties(user, userVo);
            List<EmailInfoModel> emails = clientService.getUserNoticeByUserName(user.getName()).getData();
            userVo.setEmails(emails);
            remoteUsersListCopy.add(userVo);
        }
        remoteUsersListCopy = remoteUsersListCopy.stream().filter(item -> !item.isAdmin()).collect(Collectors.toList());
        for (UserVo userVo : remoteUsersListCopy) {
            Optional<UserRoleData> matchUser = allUsersResponse.getData().stream().filter(item -> item.getUserId() == userVo.getpUserId()).findFirst();
            if (matchUser.isPresent()) {
                userVo.setpUserName(matchUser.get().getName());
            }
        }

        QueryPageBase<UserVo> queryPageBase = new QueryPageBase<>().paginate(remoteUsersListCopy, query.getCurrentPage(), query.getPageSize());
        return queryPageBase;
    }

    /**
     * 上级管理员下拉列表
     *
     * @return 结果
     */
    public ResponseModel<List<UserVo>> querySuperiorAdministratorDropDownList() {
        Account account = (Account) SecurityUtils.getSubject().getPrincipal();
        MultiResponse<UserRoleData> remoteUsersResponse = clientService.getUsersByPUserId(account.getpUserId());
        MultiResponse<UserRoleData> allUsersResponse = clientService.getUsers();
        if (!remoteUsersResponse.isSuccess() || remoteUsersResponse.getData().isEmpty() || !allUsersResponse.isSuccess() || allUsersResponse.getData().isEmpty()) {
            return ResponseModel.ofSuccess();
        }
        List<UserRoleData> remoteUsersList = remoteUsersResponse.getData();
        List<UserVo> remoteUsersListCopy = new ArrayList<>();
        for (UserRoleData user : remoteUsersList) {
            if (user.getpUserId() == -1 || user.getpUserId() == 1) {
                UserVo userVo = new UserVo();
                BeanUtils.copyProperties(user, userVo);
                remoteUsersListCopy.add(userVo);
            }
        }
        for (UserVo userVo : remoteUsersListCopy) {
            Optional<UserRoleData> matchUser = allUsersResponse.getData().stream().filter(item -> item.getUserId() == userVo.getpUserId()).findFirst();
            if (matchUser.isPresent()) {
                userVo.setpUserName(matchUser.get().getName());
            }
        }
        return ResponseModel.ofSuccess(remoteUsersListCopy);
    }

    /**
     * 查询完整功能操作权限列表
     *
     * @return 结果
     */
    public ResponseModel<List<FunctionModule>> queryFunctionOperationAuthority(String userName) {
        List<FunctionModule> list = new ArrayList<>();
        List<FunctionModule> functionModuleList = new ArrayList<>();
        try {
            list = functionCodeClient.getFunctionModule(userName);
            Integer systemType = Integer.parseInt(configValue.obtainConfigValue("xnms.service.center.WorkMode"));
            if (systemType == Utility.EnumSystemType.XPT.getValue() || systemType == Utility.EnumSystemType.CPT.getValue()) {
                list = list.stream().filter(item -> item.getSystemType() == 2 || item.getSystemType() == 1).collect(Collectors.toList());
            } else {
                list = list.stream().filter(item -> item.getSystemType() == 2 || item.getSystemType() == 0).collect(Collectors.toList());
            }
            for (FunctionModule functionModule : list) {
                FunctionModule exist = functionModuleList.stream().filter(item -> item.getCode().equals(functionModule.getPid())).findFirst().orElse(null);
                if (exist == null) {
                    functionModuleList.add(functionModule);
                } else {
                    if (CollectionUtils.isEmpty(exist.getChildren())) {
                        exist.setChildren(new ArrayList<>());
                    }
                    exist.getChildren().add(functionModule);
                }
            }
        } catch (Exception e) {
            logger.error("queryFunctionOperationAuthority-IOException:{}", e);
        }
        return ResponseModel.ofSuccess(functionModuleList);
    }

    public ResponseModel addUser(QueryUserManageParams params) {
        Account account = (Account) SecurityUtils.getSubject().getPrincipal();
        User user = new User();
        user.setName(params.getUserName());
        user.setpUserId(params.getpUserId());
        user.setPassword(new Md5Hash(DEFAULT_PASSWORD).toString().toUpperCase());

        List<UserFunModule> functions = params.getFunctions();
        // 验证三级权限是否大于二级权限
        if (params.getpUserId() != 1) {
            List<UserFunModule> permission = clientService.getUserFunModule(params.getpUserName()).getData();
            for (UserFunModule userFunModule : functions) {
                String funModuleId = userFunModule.getFunModuleId();
                Integer canLook = userFunModule.getCanLook();
                Integer canEdit = userFunModule.getCanEdit();
                List<UserFunModule> pUserFun = permission.stream().filter(item -> item.getFunModuleId().equals(funModuleId)).collect(Collectors.toList());
                if (pUserFun.size() == 0 || (canLook == 1 && pUserFun.get(0).getCanLook() == 0) || (canEdit == 1 && pUserFun.get(0).getCanEdit() == 0)) {
                    return ResponseModel.ofError(languageFind.findKey("UserFunctionLessThanSuperior"));
                }
            }

            List<Repeater> pUserRepeater = commonIClient.getAuthorityRepeaters(params.getpUserName());
            List<String> cUserRepeater = params.getRepeaters();
            for (String repeaterId : cUserRepeater) {
                if (repeaterId.indexOf("site_") >= 0) {
                    continue;
                }
                List<Repeater> pRepeater = pUserRepeater.stream().filter(item -> item.getRepeaterId().toString().equals(repeaterId)).collect(Collectors.toList());
                if (pRepeater.size() == 0) {
                    return ResponseModel.ofError(languageFind.findKey("UserRepeaterLessThanSuperior"));
                }
            }
        }
        SingleResponse<Integer> response = clientService.addUser(user);
        if (response.getData().equals(-2)) {
            return ResponseModel.ofError(languageFind.findKey("UserNameIsExist"));
        }
        if (!response.isSuccess() || !response.getData().equals(0)) {
            return ResponseModel.ofError(languageFind.findKey("AddUserFailed"));
        }

        for (UserFunModule userFunModule : functions) {
            userFunModule.setUserId(params.getUserName());
        }

        clientService.delUserFunModule(params.getUserName());
        clientService.addUserFunModule(params.getUserName(), functions);
        clientService.delUserRepeater(params.getUserName());
        clientService.addUserRepeater(params.getUserName(), params.getRepeaters());
        List<Repeater> authorityRepeaters = commonIClient.getAuthorityRepeaters(account.getUserName());
        List<String> serialNoList = authorityRepeaters.stream()
                .map(Repeater::getSerialNo)
                .collect(Collectors.toList());
        RepeaterCache.getInstance().updateUserRepeater(account.getUserName(), serialNoList);
        clientService.deleteUserNotice(params.getUserName());
        for (EmailInfoModel emailInfoModel : params.getEmails()) {
            UserNotice userNotice = new UserNotice();
            userNotice.setUserName(params.getUserName());
            userNotice.setDescription(emailInfoModel.getDescription());
            userNotice.setEmail(emailInfoModel.getEmail());
            userNotice.setWarningNotice(emailInfoModel.getWarningNotice());
            userNotice.setNoticeLanguage(emailInfoModel.getNoticeLanguage());
            userNotice.setIsNeedEmail(emailInfoModel.getIsNeedEmail());
            clientService.addUserNotice(userNotice);
        }

        clientService.clientLog(account.getUserName(), ClientLogType.LogUserManager, ClientSubLogType.LogUserManager_AddUser, "AddUserSuccess" + "**||**" + params.getUserName(), account.getIp());
        topologyUserControl.initUpdateUserRepeater();
        return ResponseModel.ofSuccess();
    }

    public ResponseModel editUser(QueryUserManageParams params) {
        Account account = (Account) SecurityUtils.getSubject().getPrincipal();
        User user = new User();
        user.setName(params.getUserName());
        user.setpUserId(params.getpUserId());
        List<UserFunModule> functions = params.getFunctions();
        // 验证三级权限是否大于二级权限
        if (params.getpUserId() != 1) {
            UserVo userVo = clientService.getUserByUserName(params.getUserName()).getData();
            MultiResponse<UserRoleData> allUsersResponse = clientService.getUsers();
            Optional<UserRoleData> matchUser = allUsersResponse.getData().stream().filter(item -> item.getUserId() == userVo.getpUserId()).findFirst();
            if (matchUser.isPresent()) {
                userVo.setpUserName(matchUser.get().getName());
            }
            List<UserFunModule> permission = clientService.getUserFunModule(userVo.getpUserName()).getData();
            for (UserFunModule userFunModule : functions) {
                String funModuleId = userFunModule.getFunModuleId();
                Integer canLook = userFunModule.getCanLook();
                Integer canEdit = userFunModule.getCanEdit();
                List<UserFunModule> pUserFun = permission.stream().filter(item -> item.getFunModuleId().equals(funModuleId)).collect(Collectors.toList());
                if (pUserFun.size() == 0 || (canLook == 1 && pUserFun.get(0).getCanLook() == 0) || (canEdit == 1 && pUserFun.get(0).getCanEdit() == 0)) {
                    return ResponseModel.ofError(languageFind.findKey("UserFunctionLessThanSuperior"));
                }
            }

            List<Repeater> pUserRepeater = commonIClient.getAuthorityRepeaters(userVo.getpUserName());
            List<String> cUserRepeater = params.getRepeaters();
            for (String repeaterId : cUserRepeater) {
                if (repeaterId.indexOf("site_") >= 0) {
                    continue;
                }
                List<Repeater> pRepeater = pUserRepeater.stream().filter(item -> item.getRepeaterId().toString().equals(repeaterId)).collect(Collectors.toList());
                if (pRepeater.size() == 0) {
                    return ResponseModel.ofError(languageFind.findKey("UserRepeaterLessThanSuperior"));
                }
            }
        }

        SingleResponse<Integer> response = clientService.editUserModel(user);
        if (!response.isSuccess() || !response.getData().equals(0)) {
            return ResponseModel.ofError(languageFind.findKey("UpdateUserFailed"));
        }
        for (UserFunModule userFunModule : functions) {
            userFunModule.setUserId(params.getUserName());
        }

        clientService.delUserFunModule(params.getUserName());
        clientService.addUserFunModule(params.getUserName(), functions);
        if (params.getpUserId() == 1) {
            clientService.deleteChildUserFunModule(params.getUserId().toString(), params.getFunctions());
        }
        List<String> repeaterOldAuthority = clientService.getUserRepeaterByUserName(params.getUserName());
        clientService.delUserRepeater(params.getUserName());
        clientService.addUserRepeater(params.getUserName(), params.getRepeaters());
        if (params.getpUserId() == 1) {
            clientService.deleteChildUserRepeater(params.getpUserId().toString(), repeaterOldAuthority, params.getRepeaters());
        }
        List<Repeater> authorityRepeaters = commonIClient.getAuthorityRepeaters(account.getUserName());
        List<String> serialNoList = authorityRepeaters.stream()
                .map(Repeater::getSerialNo)
                .collect(Collectors.toList());
        RepeaterCache.getInstance().updateUserRepeater(account.getUserName(), serialNoList);
        clientService.deleteUserNotice(params.getUserName());
        for (EmailInfoModel emailInfoModel : params.getEmails()) {
            UserNotice userNotice = new UserNotice();
            userNotice.setUserName(params.getUserName());
            userNotice.setDescription(emailInfoModel.getDescription());
            userNotice.setEmail(emailInfoModel.getEmail());
            userNotice.setWarningNotice(emailInfoModel.getWarningNotice());
            userNotice.setNoticeLanguage(emailInfoModel.getNoticeLanguage());
            userNotice.setIsNeedEmail(emailInfoModel.getIsNeedEmail());
            clientService.addUserNotice(userNotice);
        }

        clientService.clientLog(account.getUserName(), ClientLogType.LogUserManager, ClientSubLogType.LogUserManager_ModifyUser, "ModifyUserSuccess" + "**||**" + params.getUserName(), account.getIp());
        topologyUserControl.initUpdateUserRepeater();
        return ResponseModel.ofSuccess();
    }

    public ResponseModel deleteRepeaterByUserNames(List<String> userNames) {
        for (String userName : userNames) {
            commonService.deleteUser(userName);
            RepeaterCache.getInstance().clearUserRepeater(userName);
        }
        Account account = (Account) SecurityUtils.getSubject().getPrincipal();
        clientService.clientLog(account.getUserName(), ClientLogType.LogUserManager, ClientSubLogType.LogUserManager_DeleteUser, "DeleteUserSuccess" + "**||**" + userNames, account.getIp());
        topologyUserControl.initUpdateUserRepeater();
        return ResponseModel.ofSuccess();
    }

    public ResponseModel<UserVo> queryUser(String userName) {
        UserVo userVo = clientService.getUserByUserName(userName).getData();
        if (userVo == null) {
            return ResponseModel.ofError(languageFind.findKey("UserIsNotExist"));
        }
        MultiResponse<UserRoleData> allUsersResponse = clientService.getUsers();
        Optional<UserRoleData> matchUser = allUsersResponse.getData().stream().filter(item -> item.getUserId() == userVo.getpUserId()).findFirst();
        if (matchUser.isPresent()) {
            userVo.setpUserName(matchUser.get().getName());
        }
        List<FunctionModule> functionNodeList = getFunctionModules(userName);
        userVo.setFunctions(functionNodeList);
        List<UserRepeater> userRepeaters = clientService.getUserRepeater(userName).getData();
        List<String> repeaterIds = userRepeaters.stream().map(UserRepeater::getRepeaterId).collect(Collectors.toList());
        userVo.setRepeaters(repeaterIds);
        List<EmailInfoModel> emails = clientService.getUserNoticeByUserName(userName).getData();
        userVo.setEmails(emails);
        return ResponseModel.ofSuccess(userVo);
    }

    private List<FunctionModule> getFunctionModules(String userName) {
        List<FunctionModule> functionNodeList = functionCodeClient.getFunctionModule(userName);
        FunctionModule functionModule = new FunctionModule();
        functionModule.setName("SystemParameter");
        functionModule.setCode("0502");
        functionModule.setCanLook(1);
        functionModule.setCanEdit(1);
        functionNodeList.add(functionModule);
        return functionNodeList;
    }

    private List<FunctionModule> getFunctionModulesForMenu(String userName) {
        List<FunctionModule> functionNodeList = functionCodeClient.getFunctionModuleForMenu(userName);
        FunctionModule functionModule = new FunctionModule();
        functionModule.setName("SystemParameter");
        functionModule.setCode("0502");
        functionModule.setCanLook(1);
        functionModule.setCanEdit(1);
        functionNodeList.add(functionModule);
        return functionNodeList;
    }


    public ResponseModel<List<TopoRepeaterData>> queryRepeaterAdministrativeAuthority(String userName) {
        List<TopoRepeaterData> repeatersList = topologyUserControl.repeaterDropAndDownList(userName);
        List<TopoRepeaterData> filterList = repeatersList.stream().filter(item -> !item.getName().equals(languageFind.findKey("UnRegisterSite"))).collect(Collectors.toList());
        return ResponseModel.ofSuccess(filterList);
    }

    public ResponseModel<List<FunctionModule>> queryUserMenu(String userName) {
        List<FunctionModule> functionModuleList = new ArrayList<>();
        try {
            functionModuleList = functionCodeClient.getFunctionModuleForMenu(userName);
            FunctionModule functionModule = new FunctionModule();
            functionModule.setName("SystemParameter");
            functionModule.setId("0502");
            functionModule.setCode("0502");
            functionModule.setCanLook(1);
            functionModule.setCanEdit(1);
            functionModule.setHasRead(1);
            functionModule.setHasWrite(1);
            functionModule.setSystemType(2);
            functionModule.setPay(0);
            functionModule.setPid("05");
            functionModuleList.add(functionModule);
        } catch (Exception e) {
            logger.error("queryUserMenu-Exception:{}", e);
        }
        return ResponseModel.ofSuccess(functionModuleList);

    }

    private boolean filterNodesRecursively(List<FunctionModule> functionNodeList, Set<String> idSet, List<FunctionModule> filteredNodes) {
        boolean hasMatchingChild = false;
        if (CollectionUtils.isEmpty(functionNodeList)) {
            return hasMatchingChild;
        }
        for (FunctionModule node : functionNodeList) {
            // 递归过滤子节点
            List<FunctionModule> filteredChildren = new ArrayList<>();
            boolean childMatches = filterNodesRecursively(node.getChildren(), idSet, filteredChildren);

            // 如果当前节点的 funmoduleId 在 ids 中,或者子节点有匹配的节点
            if (idSet.contains(node.getCode()) || childMatches) {
                hasMatchingChild = true; // 标记当前节点有匹配的子节点
                FunctionModule newNode = new FunctionModule();
                newNode.setName(node.getName());
                newNode.setCode(node.getCode());
                newNode.setCanLook(node.getCanLook());
                newNode.setCanEdit(node.getCanEdit());
                newNode.setChildren(filteredChildren); // 设置过滤后的子节点
                filteredNodes.add(newNode); // 添加当前节点
            }
        }

        return hasMatchingChild; // 返回是否有匹配的子节点
    }
}

UserFunModuleDaoImpl

java 复制代码
package com.xnms.data.service.dao.mysql.impl;

import com.xnms.data.contract.database.db.UserFunModule;
import com.xnms.data.service.dao.UserFunModuleDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Repository
public class UserFunModuleDaoImpl implements UserFunModuleDao {

    private static final Logger logger = LoggerFactory.getLogger(UserFunModuleDaoImpl.class);

    @PersistenceContext
    private EntityManager entityManager;

    @Transactional
    @Override
    public void addUserFunModule(String userId, List<UserFunModule> userFunModuleList) {
        String insertSql = "";
        Query query = null;
        for (UserFunModule userFunModule : userFunModuleList) {
            insertSql = "INSERT INTO USER_FUNMODULE (USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT) VALUES (:userId, :funModuleId, :canLook, :canEdit)";
            query = entityManager.createNativeQuery(insertSql);
            query.setParameter("userId", userId);
            query.setParameter("funModuleId", userFunModule.getFunModuleId());
            query.setParameter("canLook", userFunModule.getCanLook());
            query.setParameter("canEdit", userFunModule.getCanEdit());
            query.executeUpdate();
        }
    }

    @Transactional
    @Override
    public void delUserFunModule(String userId) {
        String sql = "DELETE FROM USER_FUNMODULE WHERE USERID = :userId";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("userId", userId);
        query.executeUpdate();
    }

    @Override
    public List<UserFunModule> getUserFunModule(String userId) {
        logger.info("UserFunModuleDaoImpl类,getUserFunModule方法:userId = [{}]",userId);
        List<UserFunModule> userFunModules = new ArrayList<>();
        String sql = "SELECT USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT FROM USER_FUNMODULE WHERE USERID = :userId";
        try {
            Query query = entityManager.createNativeQuery(sql, UserFunModule.class);
            query.setParameter("userId", userId);
            userFunModules = query.getResultList();
        } catch (Exception ex) {
            // 这里可以使用 logger 记录错误
            logger.error("<UserFunModuleDaoImpl getUserFunModule> Error:{} ", ex.getMessage(),ex);
        }
        return userFunModules;
    }

    @Transactional
    @Override
    public void deleteChildUserFunModule(String pUSERID, List<UserFunModule> pUserFunModuleList) {
        String sqlGetAllChild = "SELECT USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT FROM `USER_FUNMODULE` WHERE USERID IN(SELECT NAME FROM USER WHERE PUSERID = '"+ pUSERID + "')";
        Query sqlGetAllChildQuery = entityManager.createNativeQuery(sqlGetAllChild, UserFunModule.class);
        List<UserFunModule> userFunModulesList = sqlGetAllChildQuery.getResultList();

        for (UserFunModule userFunModule : pUserFunModuleList) {
            String funModuleId = userFunModule.getFunModuleId();
            Integer canLook = userFunModule.getCanLook();
            Integer canEdit = userFunModule.getCanEdit();
            if (canLook == 0) {
                List<UserFunModule> rows = userFunModulesList.stream().filter(item -> item.getCanLook() == 1).collect(Collectors.toList());
                if (rows.size() > 0) {
                    String userList = "";
                    for (int j = 0; j < rows.size(); j++) {
                        userList += "'" + rows.get(j).getUserId() + "'";
                        if (j != rows.size() - 1)
                        {
                            userList += ",";
                        }
                    }
                    String updateSql = "UPDATE USER_FUNMODULE SET CAN_LOOK = 0, CAN_EDIT = 0 WHERE USERID IN("+ userList + ") AND FUNMODULE_ID='"+ funModuleId + "'";
                    Query updateSqlQuery = entityManager.createNativeQuery(updateSql);
                    updateSqlQuery.executeUpdate();
                }
            }

            if (canEdit == 0) {
                List<UserFunModule> rows = userFunModulesList.stream().filter(item -> item.getCanEdit() == 1).collect(Collectors.toList());
                if (rows.size() > 0) {
                    String userList = "";
                    for (int j = 0; j < rows.size(); j++) {
                        userList += "'" + rows.get(j).getUserId() + "'";
                        if (j != rows.size() - 1)
                        {
                            userList += ",";
                        }
                    }
                    String updateSql = "UPDATE USER_FUNMODULE SET CAN_EDIT = 0 WHERE USERID IN(" + userList + ") AND FUNMODULE_ID = '"+ funModuleId + "'";
                    Query updateSqlQuery = entityManager.createNativeQuery(updateSql);
                    updateSqlQuery.executeUpdate();
                }
            }
        }
    }
}

UserFunModule

java 复制代码
package com.xnms.data.contract.database.db;

import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;

// 用户功能模块
@Entity
public class UserFunModule {

    // 用户登录名
    @Column(name = "USERID")
    private String userId;

    // 功能ID
    @Id
    @Column(name = "FUNMODULE_ID")
    private String funModuleId;

    // 可以读
    @Column(name = "CAN_LOOK")
    private Integer canLook;

    // 可以写
    @Column(name = "CAN_EDIT")
    private Integer canEdit;

    @Transient
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getFunModuleId() {
        return funModuleId;
    }

    public void setFunModuleId(String funModuleId) {
        this.funModuleId = funModuleId;
    }

    public Integer getCanLook() {
        return canLook;
    }

    public void setCanLook(Integer canLook) {
        this.canLook = canLook;
    }

    public Integer getCanEdit() {
        return canEdit;
    }

    public void setCanEdit(Integer canEdit) {
        this.canEdit = canEdit;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}

UserDaoImpl

java 复制代码
package com.xnms.data.service.dao.mysql.impl;

import com.xnms.data.contract.database.db.Repeater;
import com.xnms.data.contract.database.db.User;
import com.xnms.data.contract.database.db.UserData;
import com.xnms.data.contract.database.db.UserRoleData;
import com.xnms.data.service.dao.UserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.ArrayList;
import java.util.List;

@Repository
public class UserDaoImpl implements UserDao {

    private static final Logger logger = LoggerFactory.getLogger(UserDaoImpl.class);

    @PersistenceContext
    private EntityManager entityManager;

    @Override
    public List<UserRoleData> getAllUser() {
        String sql = "SELECT u.USER_ID, u.NAME, u.PASSWORD, u.PUSERID, r.ROLE_LEVEL, u.ENABLE, u.CLOSED_ID " +
                "FROM `USER` u " +
                "LEFT JOIN USER_ROLE ur ON u.USER_ID = ur.USER_ID " +
                "LEFT JOIN ROLE r ON r.ROLE_ID = ur.ROLE_ID";
        Query query = entityManager.createNativeQuery(sql, UserRoleData.class);
        List<UserRoleData> listUser = query.getResultList();
        for (UserRoleData userRoleData : listUser) {
            if (userRoleData.getRoleLevel() == null) {
                userRoleData.setRoleLevel(1);
            }
        }
        return listUser;
    }

    @Override
    public boolean checkPassword(String username, String password) {
        String sql = "select count(1) from user WHERE name = :name AND password = :password";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", username);
        query.setParameter("password", password);
        Object result = query.getSingleResult();
        if (((Number) result).intValue() == 0) {
            return false;
        }
        return true;
    }

    @Override
    @Transactional
    public int updatePassword(String userName, String password) {
        String sql = "UPDATE USER SET password = :password WHERE name = :name";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", userName);
        query.setParameter("password", password);
        return query.executeUpdate();
    }

    @Override
    public Boolean isExistedUser(String name) {
        String sql = "SELECT COUNT(1) FROM USER WHERE NAME = :name";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", name);
        Object result = query.getSingleResult();
        if (((Number) result).intValue() <= 0) {
            return false;
        }
        return true;
    }

    @Transactional
    @Override
    public int addUser(User user) {
        String insertSql = "INSERT INTO USER (NAME, PASSWORD, PUSERID) VALUES ( :name, :password, :pUserId)";
        Query query = entityManager.createNativeQuery(insertSql);
        query.setParameter("name", user.getName());
        query.setParameter("password", user.getPassword());
        query.setParameter("pUserId", user.getpUserId());
        query.executeUpdate();
        return 0;
    }

    @Transactional
    @Override
    public int addUserTopoinfo() {
        try {
            String insertSql = "INSERT INTO USER_TOPOINFO (USERID, TOPOINFO) VALUES ( :userid, :topoinfo)";
            Query query = entityManager.createNativeQuery(insertSql);
            query.setParameter("userid", "1");
            query.setParameter("topoinfo", "1");
            query.executeUpdate();
        } catch (Exception e) {
            logger.error("addUserTopoinfo 1 error:{}", e.getMessage());
        }
        return 0;
    }

    @Override
    public void deleteUser(String name) {
        String sql = "DELETE FROM USER WHERE NAME = :name";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", name);
        query.executeUpdate();
    }

    @Transactional
    @Override
    public void editUserModel(User user) {
        String sql = "UPDATE USER SET PUSERID = :pUserId WHERE NAME = :name";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", user.getName());
        query.setParameter("pUserId", user.getpUserId());
        query.executeUpdate();
    }

    @Override
    public UserRoleData getUserByUserName(String name) {
        String querySql = "SELECT u.USER_ID, u.NAME, u.PASSWORD, u.PUSERID, u.ENABLE, u.CLOSED_ID,r.ROLE_LEVEL " +
                "FROM `USER` u " +
                "LEFT JOIN USER_ROLE ur ON u.USER_ID = ur.USER_ID " +
                "LEFT JOIN ROLE r ON r.ROLE_ID = ur.ROLE_ID " +
                "WHERE u.NAME = :name";
        Query query = entityManager.createNativeQuery(querySql, UserRoleData.class);
        query.setParameter("name", name);
        List<UserRoleData> listUser = query.getResultList();
        return listUser.get(0);
    }

    @Override
    public void updateUser(User user) {

    }

    @Override
    public List<UserData> getUserByRepeaterSn(String sn, String systemType) {
        List<UserData> listUser = new ArrayList<>();
        if (systemType.equals("0")) {
            String conventionalSql = "SELECT U.USER_ID,  U.NAME, U.PASSWORD, U.PUSERID, R.ROLE_LEVEL, NOTICE.ISNEEDEMAIL,NOTICE.ID," +
                    "NOTICE.EMAIL,NOTICE.DESCRIPTION, NOTICE.REPEATERSTATENOTICE, NOTICE.WARNINGNOTICE, NOTICE.NOTICELANGUAGE " +
                    "FROM `USER` U " +
                    "INNER JOIN USER_ROLE ur ON u.USER_ID = ur.USER_ID " +
                    "INNER JOIN ROLE R ON R.ROLE_ID = ur.ROLE_ID " +
                    "LEFT JOIN USER_NOTICE NOTICE on u.`NAME` = NOTICE.USER_NAME " +
                    "WHERE U.NAME IN (SELECT user_repeater.USERID FROM `user_repeater`, repeater " +
                    "WHERE user_repeater.REPEATERID = repeater.REPEATER_ID AND SERIAL_NO = :sn )";
            Query conventionalQuery = entityManager.createNativeQuery(conventionalSql, UserData.class);
            conventionalQuery.setParameter("sn", sn);
            listUser = conventionalQuery.getResultList();
            if (listUser == null || listUser.size() == 0) {
                return new ArrayList<>();
            }
        } else if (systemType.equals("1") || systemType.equals("2")) {
            String sqlSiteID = String.format(
                    " SELECT SITE_ID,'Site' as SiteAlias, REPEATER_ID, r.ALIAS, IPADDRESS, SERIAL_NO, SITE_INDEX, TYPE, IP_CONNECT_PORT," +
                            " SNMP_PORT, deleted, STATUS, SERVER_IP, FUNC_GetRepeaterIPParent(IPADDRESS) AS RECURSION_MASTER_IP, MASTER_IP, MASTER_PORT," +
                            " SYSTEM_TYPE, LNG, LNG_DEGREE, LNG_MINUTE, LNG_SECOND, LAT, LAT_DEGREE, LAT_MINUTE, LAT_SECOND, Elevation, RADIO_ID," +
                            " FIRMWAVE_NO, RCDB_NO, CURRENT_RX_FREQUENCE, CURRENT_TX_FREQUENCE, CUR_MODE, CHANNEL_NAME, REPEATER_SITE_TYPE, REAL_ACCESS_CODE," +
                            " REPEATER_ACCESS_CODE, MODEL_NAME, MODEL_NO, NOTE1, NOTE2, NOTE3, IS_SNMPV3, REPEATER_SNMP_VERSION, SNMPV3_SECURITY_LEVEL," +
                            " SNMPV3_AUTH_ALGORITHM, SNMPV3_AUTH_PASSWORD, SNMPV3_PRIVACY_ALGORITHM, SNMPV3_PRIVACY_PASSWORD, SNMPV3_CONTEXT_NAME, SNMPV3_USM_USER " +
                            " FROM REPEATER r WHERE SERIAL_NO=? LIMIT 0,1");

            Query sqlSiteIDQuery = entityManager.createNativeQuery(sqlSiteID, Repeater.class);
            sqlSiteIDQuery.setParameter(1, sn);
            List<Repeater> resultList = sqlSiteIDQuery.getResultList();
            int siteId = -1;
            if (!resultList.isEmpty()) {
                siteId =  resultList.get(0).getSiteId();
            }

            String xptSql = "SELECT U.USER_ID,  U.NAME, U.PASSWORD, U.PUSERID, R.ROLE_LEVEL, NOTICE.ISNEEDEMAIL,NOTICE.ID," +
                    "NOTICE.EMAIL,NOTICE.DESCRIPTION, NOTICE.REPEATERSTATENOTICE, NOTICE.WARNINGNOTICE, NOTICE.NOTICELANGUAGE " +
                    "FROM `USER` U " +
                    "INNER JOIN USER_ROLE ur ON u.USER_ID = ur.USER_ID " +
                    "INNER JOIN ROLE R ON R.ROLE_ID = ur.ROLE_ID " +
                    "LEFT JOIN USER_NOTICE NOTICE on u.`NAME` = NOTICE.USER_NAME " +
                    "WHERE U.NAME IN (SELECT USER_REPEATER.USERID FROM `USER_REPEATER` WHERE UPPER(REPEATERID) = :sn ) AND NOTICE.ID != ''";
            Query xptQuery = entityManager.createNativeQuery(xptSql, UserData.class);
            xptQuery.setParameter("sn", "SITE_" + siteId);
            listUser = xptQuery.getResultList();
            if (listUser == null || listUser.size() == 0) {
                return new ArrayList<>();
            }
        }
        return listUser;
    }

    @Override
    public List<UserRoleData> getAllUser(int pUserId) {
        String sql = "SELECT u.USER_ID,  u.NAME, u.PASSWORD, u.PUSERID, r.ROLE_LEVEL, u.ENABLE, u.CLOSED_ID " +
                "FROM `USER` u " +
                "INNER JOIN USER_ROLE ur ON u.USER_ID = ur.USER_ID " +
                "INNER JOIN ROLE r ON r.ROLE_ID = ur.ROLE_ID " +
                "WHERE u.PUSERID = :pUserId";
        Query query = entityManager.createNativeQuery(sql, UserRoleData.class);
        query.setParameter("pUserId", pUserId);
        return query.getResultList();
    }

    @Override
    public int getClosedIDByUserName(String userName) {
        return 0;
    }

    @Transactional
    @Override
    public void restoreClosedByUserName(String userName) {
        String sql = "UPDATE USER SET CLOSED_ID = 0 WHERE NAME = :name";
        Query query = entityManager.createNativeQuery(sql);
        query.setParameter("name", userName);
        query.executeUpdate();
    }

    @Override
    public void writeToClosedID(List<String> userIDs, String closedID) {

    }
}

User

java 复制代码
package com.xnms.data.contract.database.db;

import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

// 用户类
@Entity
@Table(name = "user")
public class User {

    // 用户ID
    @Id
    @Column(name = "USER_ID")
    private Integer userId;

    // 用户名
    @Column(name = "NAME")
    private String name;

    // 用户密码
    @Column(name = "PASSWORD")
    private String password;

    @Column(name = "ENABLE")
    private Integer enable;

    @Column(name = "CLOSED_ID")
    private Integer closedId;

    // 父用户ID
    @Column(name = "PUSERID")
    private Integer pUserId;


    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getEnable() {
        return enable;
    }

    public void setEnable(Integer enable) {
        this.enable = enable;
    }

    public Integer getClosedId() {
        return closedId;
    }

    public void setClosedId(Integer closedId) {
        this.closedId = closedId;
    }


    public Integer getpUserId() {
        return pUserId;
    }

    public void setpUserId(Integer pUserId) {
        this.pUserId = pUserId;
    }

    // 检查密码
    public boolean checkPassword(String password) {
        return password.equals(this.password);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}

function_module表

java 复制代码
CREATE TABLE `function_module` (
  `ID` varchar(32) COLLATE utf8_bin NOT NULL,
  `NAME` varchar(100) COLLATE utf8_bin DEFAULT NULL,
  `CODE` varchar(32) COLLATE utf8_bin DEFAULT NULL,
  `PID` varchar(32) COLLATE utf8_bin DEFAULT NULL,
  `SYSTEM_TYPE` int(11) DEFAULT NULL,
  `HAS_READ` int(11) DEFAULT NULL,
  `HAS_WRITE` int(11) DEFAULT NULL,
  `PAY` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
java 复制代码
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('00', 'TopolgyDisplay', '00', '-1', 2, 1, 1, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0000', 'TopolgyMap', '0000', '00', 2, 1, 1, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0001', 'ElectronicMap', '0001', '00', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('01', 'MonitoringAlarm', '01', '-1', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0100', 'DynamicMonitor', '0100', '01', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0101', 'DiagnosticsAlarm', '0101', '01', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0102', 'DetailedInfo', '0102', '01', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('02', 'ParameterSetting', '02', '-1', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0200', 'BasicSetting', '0200', '02', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0201', 'Network', '0201', '02', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0202', 'ParamSettingPhoneService', '0202', '02', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0203', 'XptChannel', '0203', '02', 1, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0204', 'XptService', '0204', '02', 1, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0205', 'UpgradeService', '0205', '02', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0206', 'ParamService', '0206', '02', 0, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0207', 'DigitalCvtChannel', '0207', '02', 0, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0208', 'CvtSimuChannel', '0208', '02', 0, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0209', 'MixedChannel', '0209', '02', 0, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('03', 'DataQuery', '03', '-1', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0300', 'Query_BusinessDataQuery', '0300', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0301', 'Query_CallDataQuery', '0301', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0302', 'Query_TextDataQuery', '0302', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0303', 'Query_AlaramDataQuery', '0303', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0304', 'Query_UserCallNumsDataQuery', '0304', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0305', 'Query_GroupCallNumsDataQuery', '0305', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0306', 'Query_SystemRssiCover', '0306', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0307', 'Query_RunHistory', '0307', '03', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0308', 'Query_SystemLog', '0308', '03', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0310', 'Query_TimerExportFunction', '0310', '03', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('04', 'Statistics', '04', '-1', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0400', 'SiteStatistice', '0400', '04', 1, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0401', 'RepeaterStatistice', '0401', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0402', 'PrivateCallStatistice', '0402', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0403', 'GroupCallStatistice', '0403', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0404', 'TabItem_UserCallNumsStatistice', '0404', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0405', 'TabItem_GroupCallNumsStatistice', '0405', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0406', 'TabItem_RSSIStatistice', '0406', '04', 2, 1, 0, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0407', 'TabItem_CoustomReport', '0407', '04', 2, 1, 0, 1);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('05', 'SystemMangment', '05', '-1', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0500', 'DeviceManagement', '0500', '05', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0501', 'UserManagement', '0501', '05', 2, 1, 1, 0);
INSERT INTO xpt_db.function_module
(ID, NAME, CODE, PID, SYSTEM_TYPE, HAS_READ, HAS_WRITE, PAY)
VALUES('0503', 'DatabaseMangment', '0503', '05', 2, 1, 1, 0);

user表

java 复制代码
CREATE TABLE `user` (
  `USER_ID` int(11) NOT NULL AUTO_INCREMENT,
  `NAME` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `PASSWORD` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ENABLE` bit(1) DEFAULT b'1',
  `PUSERID` int(11) DEFAULT NULL,
  `CLOSED_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`USER_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
java 复制代码
INSERT INTO xpt_db.`user`
(USER_ID, NAME, PASSWORD, ENABLE, PUSERID, CLOSED_ID)
VALUES(1, 'Admin', 'E3AFED0047B08059D0FADA10F400C1E5', 1, -1, 0);

user_funmodule表

java 复制代码
CREATE TABLE `user_funmodule` (
  `USERID` varchar(32) COLLATE utf8_bin NOT NULL,
  `FUNMODULE_ID` varchar(32) COLLATE utf8_bin NOT NULL,
  `CAN_LOOK` tinyint(1) NOT NULL,
  `CAN_EDIT` tinyint(1) NOT NULL,
  PRIMARY KEY (`USERID`,`FUNMODULE_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
java 复制代码
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '00', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0000', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0001', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '01', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0100', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0101', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0102', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '02', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0200', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0201', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0202', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0203', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0204', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0205', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0206', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0207', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0208', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0209', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '03', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0300', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0301', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0302', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0303', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0304', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0305', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0306', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0307', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0308', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0309', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0310', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '04', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0400', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0401', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0402', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0403', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0404', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0405', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0406', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0407', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '05', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0500', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0501', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0502', 1, 1);
INSERT INTO xpt_db.user_funmodule
(USERID, FUNMODULE_ID, CAN_LOOK, CAN_EDIT)
VALUES('Admin', '0503', 1, 1);

user_notice表

java 复制代码
CREATE TABLE `user_notice` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `USER_NAME` varchar(128) COLLATE utf8_bin DEFAULT NULL,
  `EMAIL` varchar(128) COLLATE utf8_bin DEFAULT NULL,
  `REPEATERSTATENOTICE` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `WARNINGNOTICE` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `NOTICELANGUAGE` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `ISNEEDEMAIL` bit(1) DEFAULT b'0',
  `DESCRIPTION` varchar(256) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

user_repeater表

java 复制代码
CREATE TABLE `user_repeater` (
  `USERID` varchar(32) COLLATE utf8_bin NOT NULL,
  `REPEATERID` varchar(32) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`USERID`,`REPEATERID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

user_role表

java 复制代码
CREATE TABLE `user_role` (
  `USER_ROLE_ID` int(11) NOT NULL AUTO_INCREMENT,
  `USER_ID` int(11) NOT NULL,
  `ROLE_ID` int(11) NOT NULL,
  PRIMARY KEY (`USER_ROLE_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
java 复制代码
INSERT INTO xpt_db.user_role
(USER_ROLE_ID, USER_ID, ROLE_ID)
VALUES(1, 1, 1);

role表

java 复制代码
INSERT INTO xpt_db.`role`
(ROLE_ID, NAME, ROLE_LEVEL)
VALUES(1, 'Admins', 0);
INSERT INTO xpt_db.`role`
(ROLE_ID, NAME, ROLE_LEVEL)
VALUES(2, 'Users', 1);

四、说明

说明点1:Admin是唯一的管理员账户,其他最大创建的只有三级账户。

说明点2:添加账户的用户名必须唯一。

说明点3:添加账户的功能操作权限列表,用于控制用户的菜单权限,其中"查看"权限代表只能查看,该功能针对不同页面效果会有略微的不同,比如设备管理页面就是只有刷新按钮,其他页面比如地图页面就没有查询按钮;另外"编辑"按钮就是 添加、修改、删除、导入等等菜单项按钮。

说明点4:上级管理员下拉列表修改后,中转台管理权限中的列表也会同步刷新。

说明点5:勾选中转台管理权限中的列表项是有区别的,CVT模式是勾选单个中转台,而XPT模式中只能勾选站点,但是数据库保存的只是当前时刻站点下的所有中转台,哪怕后续你在站点1下新增了中转台,该用户也没有权限。

五、本人其他相关文章链接

相关推荐
冉冰学姐3 天前
SSM学生竞赛模拟系统4x1nt(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·ssm 框架·学生竞赛模拟系统
PyHaVolask4 天前
Linux零基础入门:用户管理与权限控制完全指南
用户管理·sudo·权限控制·linux用户管理·linux安全运维
煎蛋学姐4 天前
SSM星河书城9p6tr(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·ssm 框架·星河书城·线上书城
煎蛋学姐7 天前
SSM协同过滤的视频推荐系统s04mp(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·协同过滤·ssm 框架·视频推荐系统
煎蛋学姐15 天前
SSM校园兼职平台52t96(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·ssm 框架·校园兼职平台
马克学长1 个月前
SSM桐梓娄山书店管理系统6k3s6(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·ssm框架·书店管理系统
煎蛋学姐1 个月前
SSM速到校园网上订餐网站5n2pv(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·校园订餐系统·ssm 框架
煎蛋学姐2 个月前
SSM社区生鲜电商平台dq96z(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·用户管理·ssm 框架·社区生鲜电商·商品信息管理
马克学长2 个月前
SSM基于Java的医疗器械销售系统oy281(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
java·开发语言·用户管理·ssm 框架·医疗器械销售系统