Browse Source

Merge branch 'ppt-20260120' into jwy

zhc
review512jwy@163.com 2 weeks ago
parent
commit
761a41a806
  1. 7
      document/db/20260327.sql
  2. 1
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml
  3. 1
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml
  4. 75
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml
  5. 154
      dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp_bak.yml
  6. 4
      dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceController.java
  7. 2
      dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataAccumulateController.java
  8. 2
      dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataBaStatusController.java
  9. 2
      dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataMeasureController.java
  10. 46
      dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/RoleController.java
  11. 6
      dongjian-dashboard-back-controller/src/test/java/com/dongjian/dashboard/back/controller/AdminRoleControllerTest.java
  12. 16
      dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/ex/BasicRoleMenuRelationMapperExt.java
  13. 60
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/BasicRoleMenuRelationMapperExt.xml
  14. 1
      dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml
  15. 6
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/OptRoleParam.java
  16. 10
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/RoleMenuPermissionDTO.java
  17. 32
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/DashboardTreeMenusDTO.java
  18. 13
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuEntity.java
  19. 14
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuTreeVO.java
  20. 13
      dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/RoleMenuPermissionEntity.java
  21. 11
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/RoleService.java
  22. 70
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/DashboardMenuTree.java
  23. 24
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java
  24. 186
      dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/RoleServiceImpl.java

7
document/db/20260327.sql

@ -0,0 +1,7 @@
CREATE TABLE basic_role_menu_relation_dashboard (
role_id BIGINT,
menu_id BIGINT,
permission_type INT COMMENT '0-拒绝 1-只读 2-全部',
creator_id BIGINT,
create_time BIGINT
);

1
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml

@ -145,5 +145,6 @@ msgcn:
addNotification: 新增通知
editNotification: 编辑通知
delNotification: 删除通知
editDeviceField: 编辑设备属性

1
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml

@ -145,6 +145,7 @@ msgen:
addNotification: Add notification
editNotification: Edit notification
delNotification: Delete notification
editDeviceField: Edit device attributes

75
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml

@ -80,18 +80,18 @@ msgjp:
elapsedTime: '{0}日{1}時間{2}分間'
categoryHasExisted: カテゴリは既に存在します。
operationLogMap:
addRole: ロールを追加
editRole: ロールを編集
deleteRole: ロールを削除
queryRole: ロール一覧を取得
addUser: ユーザーを追加
editUser: ユーザーを編集
deleteUser: ユーザーを削除
resetPassword: パスワードをリセット
addRole: ロール管理
editRole: ロール管理
deleteRole: ロール管理
queryRole: ロール管理
addUser: ユーザー管理
editUser: ユーザー管理
deleteUser: ユーザー管理
resetPassword: ユーザー管理
changePassword: パスワードを変更
unbindMFADevice: MFAデバイスの連携を解除
queryUser: ユーザー一覧を取得
queryOperationLog: 操作ログを照会する
queryUser: ユーザー管理
queryOperationLog: 操作ログ
getS3Credentials: S3ファイル操作トークンを取得する
addSlack: Slackを追加
editSlack: Slackを編集
@ -101,14 +101,14 @@ msgjp:
editTeams: Teamsを編集
deleteTeams: Teamsを削除
queryTeams: Teamsリストを取得
getCumulativeDataList: 積算データ一覧を取得
getCumulativeDataList: 計量
queryDeviceList: デバイス一覧を取得
addDeviceGroup: デバイスグループを追加
editDeviceGroup: デバイスグループを編集
deleteDeviceGroup: デバイスグループを削除
queryDeviceGroup: デバイスグループ一覧を取得
bindGroupForDevice: デバイスにデバイスグループを割り当てる
bindDeviceForGroup: デバイスグループに紐付けるデバイスを設定する
addDeviceGroup: パネル選択
editDeviceGroup: パネル選択
deleteDeviceGroup: パネル選択
queryDeviceGroup: パネル選択
bindGroupForDevice: パネル選択
bindDeviceForGroup: パネル選択
addMonitoringPointCategory: 監視ポイントカテゴリを追加
editMonitoringPointCategory: 監視ポイントカテゴリを編集
deleteMonitoringPointCategory: 監視ポイントカテゴリを削除
@ -119,32 +119,33 @@ msgjp:
queryMonitoringPointCategoryGroup: 監視ポイントカテゴリグループ一覧を取得
bindGroupForCategory: 監視ポイントカテゴリにグループをバインド
bindCategoryForGroup: グループに監視ポイントカテゴリをバインド
confirmAlarm: アラームを確認
handleAlarm: アラームを対応
exportCumulativeData: 積算データをエクスポート
getAlarmDataList: アラームデータ一覧を取得
exportAlarmData: アラームデータをエクスポート
getMeasureDataList: 計測データ一覧を取得
exportMeasureData: 計測データをエクスポート
getBaStatusDataList: 稼働設備一覧を取得
exportBaStatusData: 稼働設備データをエクスポート
getFavoriteList: お気に入りデバイス一覧を取得
removeFavoriteDevice: お気に入りデバイスを削除
addFavoriteDevice: お気に入りデバイスを追加
addDeviceForGroup: デバイスグループにバインドされたデバイスを設定する
delDeviceForGroup: デバイスグループにバインドされた指定されたデバイスを削除する
confirmAlarm: 警報管理
handleAlarm: 警報管理
exportCumulativeData: 計量
getAlarmDataList: 警報管理
exportAlarmData: 警報管理
getMeasureDataList: 計測
exportMeasureData: 計測
getBaStatusDataList: 運転
exportBaStatusData: 運転
getFavoriteList: お気に入り
removeFavoriteDevice: お気に入り
addFavoriteDevice: お気に入り
addDeviceForGroup: パネル選択
delDeviceForGroup: パネル選択
editBuildingField: 建物の属性を編集
setLngLat: 天気の経度と緯度を設定
addLevel: レベルを追加
editLevel: レベルを編集
deleteLevel: レベルを削除
queryLevel: レベル一覧を取得
addNotificationCategory: 通知カテゴリを追加
editNotificationCategory: 通知カテゴリを編集
delNotificationCategory: 通知カテゴリを削除
addNotification: 通知を追加
editNotification: 通知を編集
delNotification: 通知を削除
addNotificationCategory: お知らせカテゴリ管理
editNotificationCategory: お知らせカテゴリ管理
delNotificationCategory: お知らせカテゴリ管理
addNotification: お知らせ管理
editNotification: お知らせ管理
delNotification: お知らせ管理
editDeviceField: デバイス属性を編集

154
dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp_bak.yml

@ -0,0 +1,154 @@
msgjpbak:
parameterMap:
serviceError: 内部サービスのエラー
tokenError: インターフェイスの認証に失敗
excelEmpty: フォームが空になっている
lineNum: 行{0}:
paramsFormatError: パラメータのフォーマットエラー
verifCodeExpired: 確認コード期限切れ
verifCodeError: 確認コードエラー
accountExpired: アカウントの有効期限が切れている
pwdError: パスワードエラー
userNotExist: ユーザーが存在しない
noOperationAuth: 操作権限なし
projectNameHasExisted: プロジェクト名がすでにある
projectNameDoesNotExist: プロジェクト名がない
buildingNameHasExisted: 該当ビル名がすでにある
buildingNameDoesNotExist: 該当ビル名がない
floorNameHasExisted: 該当フロア名がすでにある
floorNameDoesNotExist: 該当フロア名がない
buildingNotFound: 該当ビルがない
fbNotSameCompany: ビルと同じ会社に所属してください
spaceNameHasExisted: 該当部屋名がすでにある
floorNotFound: 該当フロア名がない
rfNotSameCompany: フロアと同じ会社に所属してください
assetNameHasExisted: 該当資産名がすでにある
assetSymbolHasExisted: 記号はすでに存在します
assetNameDoesNotExist: 該当資産名がない
assetSymbolDoesNotExist: 資産記号が存在しません
spaceNotFound: 該当部屋がない
faNotSameCompany: 部屋と同じ会社に所属してください
bindedDevice: デバイスと関連付け
deviceTypeNotExist: デバイスタイプがない
excelBuildingLineDuplicate: テーブルに同じデータがある
dbBuildingDuplicate: プラットフォームにすでに該当ビルがない
dbFloorDuplicate: プラットフォームには既にこのフロアが存在しています。
dbSpaceDuplicate: プラットフォームには既にこのスペースが存在しています。
dbAssetDuplicate: プラットフォームには既にこのアセットが存在しています。
excelCompanyNameIsNull: 会社名を入力してください
excelBuildingNameIsNull: ビルを入力してください
excelFloorNameIsNull: フロア名を入力してください。
excelSpaceNameIsNull: スペース名を入力してください。
excelSpaceOrFloorNameIsNull: フロア名とスペース名を入力してください。
excelCompanyNameNotExist: プラットフォーム上に該当会社名はない
userOrEmailNotExist: ユーザーが存在しません
companyNameHasExisted: 会社はすでにプラットフォーム上に存在する
taowaComapny: 下位の会社を親会社として利用することは不可
hasSubsidiary: 削除対象の会社には下位の会社があるので、先に下位の会社を対応してください
roleNameExist: 役割名が既に登録済み
roleHasBinded: 役割はユーザーにバインドされている ので、削除する前にバインドを解除してください
loginNameOrEmailHasExisted: ユーザー名またはメールボックスはすでに使用されています
mailAddUserPwdSubject: 新規アカウント・パスワードの作成
mailAddUserPwdContent: '{0} 様<br/><br/>このたびは、データ管理プラットフォームへのご登録、誠にありがとうございます。<br/><br/>下記の通り、アカウントが発行されましたのでご案内いたします。<br/><br/>-------------------------------------------------<br/>ユーザー名(ID):<u>{1}</u><br/>初期パスワード:<span style="text-transform: none;"><u>{2}</u></span><br/>-------------------------------------------------<br/><br/>ご不明な点がございましたら、お気軽にサポートまでお問い合わせください。<br/><br/>ログインはこちらから:<br/>【AD スマビル 可視化UI URL】:https://smbil.ifmservice.jp/login<br/><br/>-------------------------------<br/>イオンディライト株式会社<br/>サポート窓口: smbil-support@ifmservice.jp<br/>-------------------------------'
mailResetUserPwdSubject: アカウント・パスワードのリセット
pwdFormatError: パスワードの構成には、数字、アルファベット、特殊文字(~!@#$%^&*) で、12桁以上
oldPwdError: 旧パスワードエラー
newPwdSameOld: 注:旧パスワードと同じものを使用しないでください
companyLimit: 最大15のエンタープライズを作成可能
consecutiveLoginFail: ログインの失敗が多すぎます。{0}分{1}秒待ってから再度ログインしてください。
loginFailCount: ログインに{0}回失敗しました。残りの試行回数:{1}回。
deviceGroupNameHasExisted: デバイスグループ名は既に存在しています。
invalidDeviceCategory: サポートされていないデバイスタイプ。
monitoringPointCategoryNameHasExisted: この監視ポイントカテゴリ名は既に存在します
monitoringPointCategoryGroupNameHasExisted: この監視ポイントグループ名は既に存在します
alertLevel_1: 通常
alertLevel_2: 緊急故障
alertLevel_3: 深刻な故障
alertLevel_4: 中程度の故障
alertLevel_5: 軽微な故障
confirmStatus_0: 未確認
confirmStatus_1: 確認済み
handleStatus_1: 未対応
handleStatus_2: 対応中
handleStatus_3: 完了
handleStatus_4: 自動復旧
canNotProcessed: これ以上の処理はできません
processOwnRole: 自分のロールを操作することはできません
levelNameExist: 階層名は既に存在しています
invalidParentLevel: 無効な上位階層です
levelReferencedByChildren: 下位階層に紐づいています。削除する前に紐付けを解除してください。
elapsedTime: '{0}日{1}時間{2}分間'
categoryHasExisted: カテゴリは既に存在します。
operationLogMap:
addRole: ロールを追加
editRole: ロールを編集
deleteRole: ロールを削除
queryRole: ロール一覧を取得
addUser: ユーザーを追加
editUser: ユーザーを編集
deleteUser: ユーザーを削除
resetPassword: パスワードをリセット
changePassword: パスワードを変更
unbindMFADevice: MFAデバイスの連携を解除
queryUser: ユーザー一覧を取得
queryOperationLog: 操作ログを照会する
getS3Credentials: S3ファイル操作トークンを取得する
addSlack: Slackを追加
editSlack: Slackを編集
deleteSlack: Slackを削除
querySlack: Slackリストを取得
addTeams: Teamsを追加
editTeams: Teamsを編集
deleteTeams: Teamsを削除
queryTeams: Teamsリストを取得
getCumulativeDataList: 積算データ一覧を取得
queryDeviceList: デバイス一覧を取得
addDeviceGroup: デバイスグループを追加
editDeviceGroup: デバイスグループを編集
deleteDeviceGroup: デバイスグループを削除
queryDeviceGroup: デバイスグループ一覧を取得
bindGroupForDevice: デバイスにデバイスグループを割り当てる
bindDeviceForGroup: デバイスグループに紐付けるデバイスを設定する
addMonitoringPointCategory: 監視ポイントカテゴリを追加
editMonitoringPointCategory: 監視ポイントカテゴリを編集
deleteMonitoringPointCategory: 監視ポイントカテゴリを削除
queryMonitoringPointCategory: 監視ポイントカテゴリ一覧を取得
addMonitoringPointCategoryGroup: 監視ポイントカテゴリグループを追加
editMonitoringPointCategoryGroup: 監視ポイントカテゴリグループを編集
deleteMonitoringPointCategoryGroup: 監視ポイントカテゴリグループを削除
queryMonitoringPointCategoryGroup: 監視ポイントカテゴリグループ一覧を取得
bindGroupForCategory: 監視ポイントカテゴリにグループをバインド
bindCategoryForGroup: グループに監視ポイントカテゴリをバインド
confirmAlarm: アラームを確認
handleAlarm: アラームを対応
exportCumulativeData: 積算データをエクスポート
getAlarmDataList: アラームデータ一覧を取得
exportAlarmData: アラームデータをエクスポート
getMeasureDataList: 計測データ一覧を取得
exportMeasureData: 計測データをエクスポート
getBaStatusDataList: 稼働設備一覧を取得
exportBaStatusData: 稼働設備データをエクスポート
getFavoriteList: お気に入りデバイス一覧を取得
removeFavoriteDevice: お気に入りデバイスを削除
addFavoriteDevice: お気に入りデバイスを追加
addDeviceForGroup: デバイスグループにバインドされたデバイスを設定する
delDeviceForGroup: デバイスグループにバインドされた指定されたデバイスを削除する
editBuildingField: 建物の属性を編集
setLngLat: 天気の経度と緯度を設定
addLevel: レベルを追加
editLevel: レベルを編集
deleteLevel: レベルを削除
queryLevel: レベル一覧を取得
addNotificationCategory: 通知カテゴリを追加
editNotificationCategory: 通知カテゴリを編集
delNotificationCategory: 通知カテゴリを削除
addNotification: 通知を追加
editNotification: 通知を編集
delNotification: 通知を削除

4
dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceController.java

@ -38,7 +38,7 @@ public class DeviceController {
@Autowired
private DeviceService deviceService;
@OperationLog(operation = "queryDeviceList", remark = "")
// @OperationLog(operation = "queryDeviceList", remark = "")
@Operation(summary = "获取设备列表")
@RequestMapping(value = "/getListPage",method = RequestMethod.GET)
public PageResponse<PageInfo<DeviceVO>> getListPage(
@ -65,7 +65,7 @@ public class DeviceController {
return pageResponse;
}
@OperationLog(operation = "editRole", remark = "")
// @OperationLog(operation = "editDeviceField", remark = "")
@Operation(summary = "编辑设备属性")
@RequestMapping(value = "/editField",method = RequestMethod.POST)
public SimpleDataResponse editField(

2
dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataAccumulateController.java

@ -104,7 +104,7 @@ public class DeviceDataAccumulateController {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("積算データ"+CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
String fileName = URLEncoder.encode("計量"+CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
// ===== 固定导出分页大小=====

2
dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataBaStatusController.java

@ -103,7 +103,7 @@ public class DeviceDataBaStatusController {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("稼働設備"+ CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
String fileName = URLEncoder.encode("運転"+ CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
// ===== 固定导出分页大小 =====

2
dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataMeasureController.java

@ -103,7 +103,7 @@ public class DeviceDataMeasureController {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("計測データ"+ CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
String fileName = URLEncoder.encode("計測"+ CommonUtil.generateExcelSuffix(), StandardCharsets.UTF_8).replace("+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
// ===== 固定导出分页大小 =====

46
dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/RoleController.java

@ -11,10 +11,15 @@ import com.dongjian.dashboard.back.configurator.interceptor.AccessRequired;
import com.dongjian.dashboard.back.dto.role.DeleteRoleParam;
import com.dongjian.dashboard.back.dto.role.OptRoleParam;
import com.dongjian.dashboard.back.dto.role.PageSearchParam;
import com.dongjian.dashboard.back.dto.role.RoleMenuPermissionDTO;
import com.dongjian.dashboard.back.vo.TreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.DashboardTreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.MenuTreeVO;
import com.dongjian.dashboard.back.vo.role.RoleMenuPermissionEntity;
import com.dongjian.dashboard.back.vo.role.RolePageDTO;
import com.dongjian.dashboard.back.service.RoleService;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
@ -110,7 +115,8 @@ public class RoleController {
}
return pageResponse;
}
@Hidden
@Operation(summary = "获取当前登录用户拥有的权限菜单树")
@RequestMapping(value = "/getOwnMenuIds",method = RequestMethod.GET)
public SimpleDataResponse<List<TreeMenusDTO>> getOwnMenuIds(
@ -121,7 +127,8 @@ public class RoleController {
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getOwnMenuIds(CompanyId, UserId, LanguageType);
}
@Hidden
@Operation(summary = "获取对应角色拥有的权限菜单ID")
@RequestMapping(value = "/getMenuIdsByRoleId",method = RequestMethod.GET)
public SimpleDataResponse<String> getMenuIdsByRoleId(
@ -133,5 +140,40 @@ public class RoleController {
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getMenuIdsByRoleId(roleId, CompanyId, UserId, LanguageType);
}
/**
* 获取菜单树 + 权限
*/
@GetMapping("/getOwnMenuTree")
public SimpleDataResponse<List<DashboardTreeMenusDTO>> getTree(
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getOwnMenuTree(CompanyId, UserId, LanguageType);
}
@Operation(summary = "获取对应角色拥有的权限菜单ID")
@RequestMapping(value = "/getMenuIdListByRoleId",method = RequestMethod.GET)
public SimpleDataResponse<List<RoleMenuPermissionEntity>> getMenuIdListByRoleId(
@Parameter(name="roleId",description="角色ID",required=true, schema = @Schema(defaultValue = "28")) @RequestParam Long roleId,
@Parameter(name = "LoginName", description = "Login name", required = true, schema = @Schema(defaultValue = "admin")) @RequestHeader(required=true) String LoginName,
@Parameter(name = "AccessToken", description = "Authentication token", required = true) @RequestHeader(required=true) String AccessToken,
@Parameter(name = "UserId", description = "User ID", required = true, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long UserId,
@Parameter(name = "CompanyId", description = "ID of the company to which the user belongs", required = false, schema = @Schema(defaultValue = "1")) @RequestHeader(required=true) Long CompanyId,
@Parameter(name = "LanguageType", description = "Language type (0: Chinese, 1: English, 2: Japanese)", required = true, schema = @Schema(defaultValue = "2")) @RequestHeader(required=true) Integer LanguageType){
return roleService.getMenuIdListByRoleId(roleId, CompanyId, UserId, LanguageType);
}
/**
* 保存权限
*/
@Hidden
@PostMapping("/save")
public void save(@RequestParam Long roleId,
@RequestBody List<RoleMenuPermissionDTO> list) {
roleService.saveRolePermission(roleId, list);
}
}

6
dongjian-dashboard-back-controller/src/test/java/com/dongjian/dashboard/back/controller/AdminRoleControllerTest.java

@ -30,6 +30,8 @@ import org.springframework.web.context.WebApplicationContext;
import jakarta.annotation.Resource;
import java.util.ArrayList;
@RunWith(SpringRunner.class)
@SpringBootTest
@ -134,7 +136,7 @@ public class AdminRoleControllerTest {
OptRoleParam param = new OptRoleParam();
param.setRoleName(ROLE_NAME);
param.setDescription("Description");
param.setMenuIds("1,2");
param.setMenuIds(new ArrayList<>());
return param;
}
@ -204,7 +206,7 @@ public class AdminRoleControllerTest {
param.setRoleId(getMockDataId());
param.setRoleName(ROLE_NAME);
param.setDescription("Description-edit");
param.setMenuIds("1,2,3");
param.setMenuIds(new ArrayList<>());
String content = (new ObjectMapper()).writeValueAsString(param);
System.out.println("testEdit params:"+content);

16
dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/ex/BasicRoleMenuRelationMapperExt.java

@ -1,10 +1,14 @@
package com.dongjian.dashboard.back.dao.ex;
import java.util.List;
import java.util.Map;
import com.dongjian.dashboard.back.vo.role.DashboardTreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.RoleMenuPermissionEntity;
import org.apache.ibatis.annotations.Mapper;
import com.dongjian.dashboard.back.dao.auto.BasicRoleMenuRelationMapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface BasicRoleMenuRelationMapperExt extends BasicRoleMenuRelationMapper {
@ -14,4 +18,16 @@ public interface BasicRoleMenuRelationMapperExt extends BasicRoleMenuRelationMap
String getMenuIdsByRoleId(Long roleId);
void deleteDashboardRelation(Map<String, Object> deleteMap);
List<DashboardTreeMenusDTO> selectAllMenu(Map<String, Object> allMenusParamMap);
List<RoleMenuPermissionEntity> selectByRoleId(@Param("roleId") Long roleId);
int deleteByRoleId(@Param("roleId") Long roleId);
int dashboardBatchInsert(@Param("list") List<RoleMenuPermissionEntity> list);
Long getRoleIdByUserId(@Param("userId") Long userId);
List<RoleMenuPermissionEntity> getMenuIdListByRoleId(Long roleId);
}

60
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/BasicRoleMenuRelationMapperExt.xml

@ -30,5 +30,65 @@
r.role_id = #{roleId} AND m.used_by_dashboard = 1
</delete>
<select id="selectAllMenu" resultType="com.dongjian.dashboard.back.vo.role.DashboardTreeMenusDTO">
SELECT
bmenu.`id` AS `menuId`,
bmenu.parent_menu_id AS parentMenuId,
bmenu.menu_name AS title,
bmenu.dashboard_lowest_node AS dashboardLowestNode
FROM
basic_menu bmenu
<if test="superRole != null and superRole == 0">
inner join basic_role_menu_relation_dashboard brmrd on bmenu.id = brmrd.menu_id and brmrd.role_id = #{roleId}
</if>
WHERE
bmenu.flag = 0 AND bmenu.used_by_dashboard = 1
</select>
<select id="selectByRoleId" resultType="com.dongjian.dashboard.back.vo.role.RoleMenuPermissionEntity">
SELECT
role_id,
menu_id,
permission_type,
create_time
FROM basic_role_menu_relation_dashboard
WHERE role_id = #{roleId}
</select>
<delete id="deleteByRoleId">
DELETE FROM basic_role_menu_relation_dashboard
WHERE role_id = #{roleId}
</delete>
<insert id="dashboardBatchInsert">
INSERT INTO basic_role_menu_relation_dashboard (role_id, menu_id, permission_type, create_time)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.roleId},
#{item.menuId},
#{item.permissionType},
#{item.createTime})
</foreach>
</insert>
<select id="getRoleIdByUserId" resultType="long">
SELECT role_id
FROM basic_role_user_relation
WHERE user_id = #{userId}
LIMIT 1
</select>
<select id="getMenuIdListByRoleId" resultType="com.dongjian.dashboard.back.vo.role.RoleMenuPermissionEntity">
SELECT
brmrd.role_id,
brmrd.menu_id,
brmrd.permission_type,
brmrd.create_time
FROM
basic_role_menu_relation_dashboard brmrd
INNER JOIN basic_menu bmenu ON bmenu.id = brmrd.menu_id
WHERE
bmenu.flag != 1 AND brmrd.role_id = #{roleId} AND bmenu.used_by_dashboard = 1
</select>
</mapper>

1
dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml

@ -19,6 +19,7 @@
left join type ty on ty.id = dinfo.type_id
WHERE
dinfo.flag != 1 AND basic_monitoring_asset.flag != 1
AND (dinfo.device_id LIKE '%\_85' or dinfo.device_id LIKE '%\_85_9003' or dinfo.device_id LIKE '%\_131_5')
AND basic_space.flag != 1 AND basic_floor.flag != 1 AND basic_building.flag != 1
<if test="buildingId != null">
AND basic_building.building_id = #{buildingId}

6
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/OptRoleParam.java

@ -4,6 +4,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author zhc
* @time 2022年6月14日10:56:38
@ -22,8 +24,8 @@ public class OptRoleParam {
@Schema(description = "描述",example = "这是管理员描述", required = true)
private String description;
@Schema(description = "菜单权限ID,使用逗号连接",example = "1,4,5,6", required = true)
private String menuIds;
@Schema(description = "菜单权限ID,使用逗号连接",example = "[]", required = true)
private List<RoleMenuPermissionDTO> menuIds;
@Schema(description = "所属企业ID",example = "2", hidden = true)
private Long companyId;

10
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/RoleMenuPermissionDTO.java

@ -0,0 +1,10 @@
package com.dongjian.dashboard.back.dto.role;
import lombok.Data;
@Data
public class RoleMenuPermissionDTO {
private Long menuId;
private Integer permissionType;
}

32
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/DashboardTreeMenusDTO.java

@ -0,0 +1,32 @@
package com.dongjian.dashboard.back.vo.role;
import com.dongjian.dashboard.back.vo.TreeMenusDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* @author Mr.Jiang
* @time 2022年7月29日 下午4:37:50
*/
@Data
public class DashboardTreeMenusDTO {
@Schema(description = "节点ID",example = "11", required = true)
private Long menuId;
@Schema(description = "父节点ID",example = "2", hidden = true)
private Long parentMenuId;
@Schema(description = "节点名称",example = "添加", required = true)
private String title;
@Schema(description = "子节点",example = "[]", required = false)
private List<DashboardTreeMenusDTO> children;
private Integer permissionType; // 0-拒绝 1-只读 2-全部 null=半选
private Integer dashboardLowestNode; // 0-否 1-是
}

13
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuEntity.java

@ -0,0 +1,13 @@
package com.dongjian.dashboard.back.vo.role;
import lombok.Data;
@Data
public class MenuEntity {
private Long id;
private Long parentMenuId;
private String menuName;
private Integer menuLevel;
private Integer flag;
}

14
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuTreeVO.java

@ -0,0 +1,14 @@
package com.dongjian.dashboard.back.vo.role;
import lombok.Data;
import java.util.List;
@Data
public class MenuTreeVO {
private Long id;
private String name;
private Integer permissionType;
private List<MenuTreeVO> children;
}

13
dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/RoleMenuPermissionEntity.java

@ -0,0 +1,13 @@
package com.dongjian.dashboard.back.vo.role;
import lombok.Data;
@Data
public class RoleMenuPermissionEntity {
private Long roleId;
private Long menuId;
private Integer permissionType;
private Long createTime;
}

11
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/RoleService.java

@ -6,7 +6,11 @@ import com.dongjian.dashboard.back.common.response.PageInfo;
import com.dongjian.dashboard.back.common.response.SimpleDataResponse;
import com.dongjian.dashboard.back.dto.role.DeleteRoleParam;
import com.dongjian.dashboard.back.dto.role.OptRoleParam;
import com.dongjian.dashboard.back.dto.role.RoleMenuPermissionDTO;
import com.dongjian.dashboard.back.vo.TreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.DashboardTreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.MenuTreeVO;
import com.dongjian.dashboard.back.vo.role.RoleMenuPermissionEntity;
import com.dongjian.dashboard.back.vo.role.RolePageDTO;
/**
@ -26,6 +30,11 @@ public interface RoleService {
PageInfo<RolePageDTO> getListPage(com.dongjian.dashboard.back.dto.role.PageSearchParam pageSearchParam,
Long companyId, Long userId, Integer languageType);
SimpleDataResponse<List<DashboardTreeMenusDTO>> getOwnMenuTree(Long companyId, Long userId, Integer languageType);
void saveRolePermission(Long roleId, List<RoleMenuPermissionDTO> list);
SimpleDataResponse<List<RoleMenuPermissionEntity>> getMenuIdListByRoleId(Long roleId, Long companyId, Long userId, Integer languageType);
}

70
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/DashboardMenuTree.java

@ -0,0 +1,70 @@
package com.dongjian.dashboard.back.service.common;
import com.dongjian.dashboard.back.vo.role.DashboardTreeMenusDTO;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class DashboardMenuTree {
private List<DashboardTreeMenusDTO> menuList = new ArrayList<>();
public DashboardMenuTree(List<DashboardTreeMenusDTO> menuList) {
this.menuList = menuList;
}
/**
* 构建树
*/
public List<DashboardTreeMenusDTO> buildTree(String rootNodeKey) {
List<DashboardTreeMenusDTO> treeMenus = new ArrayList<>();
for (DashboardTreeMenusDTO node : getRootNode(rootNodeKey)) {
treeMenus.add(buildChildTree(node));
}
return treeMenus;
}
/**
* 构建子树核心修改点
*/
private DashboardTreeMenusDTO buildChildTree(DashboardTreeMenusDTO parent) {
// 如果是最小节点 → 直接终止
if (parent.getDashboardLowestNode() != null
&& parent.getDashboardLowestNode() == 1) {
parent.setChildren(new ArrayList<>());
return parent;
}
List<DashboardTreeMenusDTO> children = new ArrayList<>();
for (DashboardTreeMenusDTO node : menuList) {
if (node.getParentMenuId().equals(parent.getMenuId())) {
children.add(buildChildTree(node));
}
}
parent.setChildren(children);
return parent;
}
/**
* 获取根节点
*/
private List<DashboardTreeMenusDTO> getRootNode(String rootNodeKey) {
List<DashboardTreeMenusDTO> roots = new ArrayList<>();
for (DashboardTreeMenusDTO node : menuList) {
if (Objects.equals(String.valueOf(node.getParentMenuId()), rootNodeKey)) {
roots.add(node);
}
}
return roots;
}
}

24
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java

@ -19,6 +19,7 @@ import com.dongjian.dashboard.back.vo.data.DeviceAlarmData;
import com.dongjian.dashboard.back.vo.data.DeviceBaStatusData;
import com.dongjian.dashboard.back.vo.data.DeviceMeasureData;
import com.dongjian.dashboard.back.vo.device.FavoritedDeviceVO;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -65,8 +66,11 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService {
}
if (null != pageSearchParam.getClassId()){
pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(pageSearchParam.getClassId()));
}
} else {
pageSearchParam.setCategoryIdList(Constants.ALL_CATEGORY_IDS);
}
PageHelper.startPage(pageSearchParam.getPageNum() == null ? 1 : pageSearchParam.getPageNum(), pageSearchParam.getPageSize() == null ? 20 : pageSearchParam.getPageSize());
List<FavoritedDeviceVO> favoritedDeviceVOList = favoritedDeviceMapperExt.getListPage(pageSearchParam);
List<Object> resultList = new ArrayList<>();
@ -115,12 +119,24 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService {
data = alarmDataMap.get(deviceId);
}
if (data != null) {
resultList.add(data);
if (data == null) {
data = vo; // 保留原 VO,避免返回条数不足
}
resultList.add(data);
}
return new PageInfo<>(resultList);
// -------------------- 保留 PageHelper 分页信息 --------------------
PageInfo<FavoritedDeviceVO> pageInfo = new PageInfo<>(favoritedDeviceVOList);
PageInfo<Object> resultPageInfo = new PageInfo<>();
resultPageInfo.setList(resultList);
resultPageInfo.setPageNum(pageInfo.getPageNum());
resultPageInfo.setPageSize(pageInfo.getPageSize());
resultPageInfo.setTotal(pageInfo.getTotal());
resultPageInfo.setPages(pageInfo.getPages());
resultPageInfo.setHasNextPage(pageInfo.isHasNextPage());
resultPageInfo.setHasPreviousPage(pageInfo.isHasPreviousPage());
return resultPageInfo;
}
private Map<String, DeviceAlarmData> buildAlarmDataMap(Long companyId, Integer languageType, List<String> deviceIds) {

186
dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/RoleServiceImpl.java

@ -1,5 +1,8 @@
package com.dongjian.dashboard.back.service.impl;
import com.dongjian.dashboard.back.dto.role.RoleMenuPermissionDTO;
import com.dongjian.dashboard.back.service.common.DashboardMenuTree;
import com.dongjian.dashboard.back.vo.role.*;
import com.github.pagehelper.PageHelper;
import com.dongjian.dashboard.back.common.exception.MsgCodeException;
import com.dongjian.dashboard.back.common.language.msg.MsgLanguageChange;
@ -19,7 +22,6 @@ import com.dongjian.dashboard.back.service.common.CommonOpt;
import com.dongjian.dashboard.back.service.common.MenuTree;
import com.dongjian.dashboard.back.util.CommonUtil;
import com.dongjian.dashboard.back.vo.TreeMenusDTO;
import com.dongjian.dashboard.back.vo.role.RolePageDTO;
import java.util.*;
import java.util.stream.Collectors;
@ -94,26 +96,23 @@ public class RoleServiceImpl implements RoleService {
private void insertRoleMenuRelation(Long companyId, Long userId, long currentUnix, Long roleId, String menuIds) {
if (StringUtils.isNoneBlank(menuIds)) {
//把无效的id去掉
menuIds = filterMenuIds(companyId, userId, menuIds);
if (StringUtils.isBlank(menuIds)) {
return;
}
//先删除原有的角色ID
Map<String, Object> deleteMap = new HashMap<>();
deleteMap.put("roleId", roleId);
basicRoleMenuRelationMapperExt.deleteDashboardRelation(deleteMap);
//重新插入关联关系
List<Long> idList = Arrays.asList(menuIds.split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("roleId", roleId);
paramMap.put("menuIds", idList);
paramMap.put("creatorId", userId);
paramMap.put("createTime", currentUnix);
basicRoleMenuRelationMapperExt.batchInsert(paramMap);
private void insertRoleMenuRelation(Long companyId, Long userId, long currentUnix, Long roleId, List<RoleMenuPermissionDTO> menuIds) {
basicRoleMenuRelationMapperExt.deleteByRoleId(roleId);
if (menuIds == null || menuIds.isEmpty()) {
return;
}
List<RoleMenuPermissionEntity> entities = menuIds.stream().map(item -> {
RoleMenuPermissionEntity entity = new RoleMenuPermissionEntity();
entity.setRoleId(roleId);
entity.setMenuId(item.getMenuId());
entity.setPermissionType(item.getPermissionType());
entity.setCreateTime(currentUnix);
return entity;
}).collect(Collectors.toList());
basicRoleMenuRelationMapperExt.dashboardBatchInsert(entities);
}
@ -143,7 +142,7 @@ public class RoleServiceImpl implements RoleService {
if(StringUtils.isBlank(param.getRoleName()) || param.getRoleName().length() > 100){
return new SimpleDataResponse(ResponseCode.MSG_ERROR, "Parameter [roleName] error");
}
if(StringUtils.isBlank(param.getMenuIds())){
if(CollectionUtils.isEmpty(param.getMenuIds())){
return new SimpleDataResponse(ResponseCode.MSG_ERROR, "menuIds can not be null");
}
return SimpleDataResponse.success();
@ -315,4 +314,149 @@ public class RoleServiceImpl implements RoleService {
return new PageInfo<>(resultList);
}
@Override
public SimpleDataResponse<List<DashboardTreeMenusDTO>> getOwnMenuTree(Long companyId, Long userId, Integer languageType) {
// 1查询用户信息
BasicUser basicUser = basicUserMapperExt.selectByPrimaryKey(userId);
int superRole = basicUser.getSuperRole() == null ? 0 : basicUser.getSuperRole();
// 获取角色权限(非超级管理员)
Map<Long, Integer> permissionMap = new HashMap<>();
if (superRole != 1) {
Long roleId = basicRoleMenuRelationMapperExt.getRoleIdByUserId(userId);
List<RoleMenuPermissionEntity> permissions = basicRoleMenuRelationMapperExt.selectByRoleId(roleId);
permissionMap = permissions.stream()
.collect(Collectors.toMap(
RoleMenuPermissionEntity::getMenuId,
RoleMenuPermissionEntity::getPermissionType
));
}
// 查询全量菜单
List<DashboardTreeMenusDTO> allMenus = basicRoleMenuRelationMapperExt.selectAllMenu(Collections.emptyMap());
Map<Long, DashboardTreeMenusDTO> fullMenuMap = allMenus.stream()
.collect(Collectors.toMap(DashboardTreeMenusDTO::getMenuId, m -> m));
// 获取用户可见菜单(叶子或有权限的节点)
List<DashboardTreeMenusDTO> visibleMenus;
if (superRole == 1) {
// 超级管理员可见所有
visibleMenus = new ArrayList<>(allMenus);
} else {
Long roleId = basicRoleMenuRelationMapperExt.getRoleIdByUserId(userId);
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("superRole", superRole);
paramMap.put("roleId", roleId);
visibleMenus = basicRoleMenuRelationMapperExt.selectAllMenu(paramMap);
}
// 补全父节点
visibleMenus = fillMissingParents(visibleMenus, fullMenuMap);
// 构建树
DashboardMenuTree tree = new DashboardMenuTree(visibleMenus);
List<DashboardTreeMenusDTO> result = tree.buildTree("-1");
// 叶子权限赋值
fillLeafPermission(result, permissionMap, superRole);
// 父节点统一赋值=2
fillParentPermission(result);
return SimpleDataResponse.success(result);
}
/**
* 补全父节点一次传入全量菜单 map
*/
private List<DashboardTreeMenusDTO> fillMissingParents(List<DashboardTreeMenusDTO> menuList,
Map<Long, DashboardTreeMenusDTO> fullMenuMap) {
Set<Long> allIds = menuList.stream().map(DashboardTreeMenusDTO::getMenuId).collect(Collectors.toSet());
Set<Long> missingParentIds = new HashSet<>();
for (DashboardTreeMenusDTO menu : menuList) {
Long pid = menu.getParentMenuId();
while (pid != null && !Objects.equals(pid, -1L) && !allIds.contains(pid)) {
missingParentIds.add(pid);
DashboardTreeMenusDTO parentMenu = fullMenuMap.get(pid);
if (parentMenu == null) break; // 防止死循环
pid = parentMenu.getParentMenuId();
}
}
for (Long pid : missingParentIds) {
DashboardTreeMenusDTO parentMenu = fullMenuMap.get(pid);
if (parentMenu != null) {
menuList.add(parentMenu);
}
}
return menuList;
}
/**
* 叶子赋权
*/
private void fillLeafPermission(List<DashboardTreeMenusDTO> nodes,
Map<Long, Integer> permissionMap, Integer superRole) {
for (DashboardTreeMenusDTO node : nodes) {
if (node.getDashboardLowestNode() != null && node.getDashboardLowestNode() == 1) {
if (superRole == 1) {
node.setPermissionType(2);
} else {
node.setPermissionType(permissionMap.getOrDefault(node.getMenuId(), 0));
}
}
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
fillLeafPermission(node.getChildren(), permissionMap, superRole);
}
}
}
/**
* 父节点权限统一赋值 2
*/
private void fillParentPermission(List<DashboardTreeMenusDTO> nodes) {
for (DashboardTreeMenusDTO node : nodes) {
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
fillParentPermission(node.getChildren());
node.setPermissionType(2);
}
}
}
@Override
@Transactional
public void saveRolePermission(Long roleId, List<RoleMenuPermissionDTO> list) {
basicRoleMenuRelationMapperExt.deleteByRoleId(roleId);
if (list == null || list.isEmpty()) {
return;
}
List<RoleMenuPermissionEntity> entities = list.stream().map(item -> {
RoleMenuPermissionEntity entity = new RoleMenuPermissionEntity();
entity.setRoleId(roleId);
entity.setMenuId(item.getMenuId());
entity.setPermissionType(item.getPermissionType());
entity.setCreateTime(System.currentTimeMillis());
return entity;
}).collect(Collectors.toList());
basicRoleMenuRelationMapperExt.dashboardBatchInsert(entities);
}
@Override
public SimpleDataResponse<List<RoleMenuPermissionEntity>> getMenuIdListByRoleId(Long roleId, Long companyId, Long userId, Integer languageType) {
try {
return SimpleDataResponse.success(basicRoleMenuRelationMapperExt.getMenuIdListByRoleId(roleId));
} catch (Exception e) {
logger.error("获取角色菜单出错", e);
return new SimpleDataResponse(ResponseCode.SERVER_ERROR, e.getMessage());
}
}
}

Loading…
Cancel
Save