From 94f45ae874f2ff67bd0abd36b6a34b19fcaea5bd Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Mon, 9 Mar 2026 20:01:18 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=AF=BC=E5=87=BAexcel=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/controller/DeviceDataAccumulateController.java | 2 +- .../dashboard/back/controller/DeviceDataBaStatusController.java | 2 +- .../dashboard/back/controller/DeviceDataMeasureController.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataAccumulateController.java b/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataAccumulateController.java index f99a26a..a23335f 100644 --- a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataAccumulateController.java +++ b/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"); // ===== 固定导出分页大小===== diff --git a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataBaStatusController.java b/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataBaStatusController.java index 9722f6b..9b55b85 100644 --- a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataBaStatusController.java +++ b/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"); // ===== 固定导出分页大小 ===== diff --git a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataMeasureController.java b/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataMeasureController.java index e4eff25..429ed4b 100644 --- a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceDataMeasureController.java +++ b/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"); // ===== 固定导出分页大小 ===== From 73ea589207cda2b28c94be578df83acfa99f5b7e Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Fri, 13 Mar 2026 10:11:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=94=B6=E8=97=8F=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E8=A1=A5=E5=85=85=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/back/service/impl/FavoritedDeviceServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java index 55ffb20..5b25350 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java +++ b/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; @@ -67,6 +68,7 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService { pageSearchParam.setCategoryIdList(Constants.CATEGORY_MAP.get(pageSearchParam.getClassId())); } + PageHelper.startPage(pageSearchParam.getPageNum() == null ? 1 : pageSearchParam.getPageNum(), pageSearchParam.getPageSize() == null ? 20 : pageSearchParam.getPageSize()); List favoritedDeviceVOList = favoritedDeviceMapperExt.getListPage(pageSearchParam); List resultList = new ArrayList<>(); From 382914431749168b04d856abee66d00fd4dcf43a Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Wed, 18 Mar 2026 08:42:32 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=94=B9=E5=AE=8C?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/config/language/msg/msg_cn.yml | 1 + .../resources/config/language/msg/msg_en.yml | 1 + .../resources/config/language/msg/msg_jp.yml | 75 ++++----- .../config/language/msg/msg_jp_bak.yml | 154 ++++++++++++++++++ .../back/controller/DeviceController.java | 4 +- 5 files changed, 196 insertions(+), 39 deletions(-) create mode 100644 dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp_bak.yml diff --git a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml b/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml index 3d94b6d..22c728b 100644 --- a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml +++ b/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_cn.yml @@ -145,5 +145,6 @@ msgcn: addNotification: 新增通知 editNotification: 编辑通知 delNotification: 删除通知 + editDeviceField: 编辑设备属性 diff --git a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml b/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml index 48f8cec..77aab0c 100644 --- a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_en.yml +++ b/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 diff --git a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml b/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml index ce16418..081a5ba 100644 --- a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp.yml +++ b/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: デバイス属性を編集 diff --git a/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp_bak.yml b/dongjian-dashboard-back-common/src/main/resources/config/language/msg/msg_jp_bak.yml new file mode 100644 index 0000000..8691e77 --- /dev/null +++ b/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} 様

このたびは、データ管理プラットフォームへのご登録、誠にありがとうございます。

下記の通り、アカウントが発行されましたのでご案内いたします。

-------------------------------------------------
ユーザー名(ID):{1}
初期パスワード:{2}
-------------------------------------------------

ご不明な点がございましたら、お気軽にサポートまでお問い合わせください。

ログインはこちらから:
【AD スマビル 可視化UI URL】:https://smbil.ifmservice.jp/login

-------------------------------
イオンディライト株式会社
サポート窓口: smbil-support@ifmservice.jp
-------------------------------' + 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: 通知を削除 + + + + + + + diff --git a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceController.java b/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceController.java index e49dbe0..f554575 100644 --- a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/DeviceController.java +++ b/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> 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( From 38aa47d1e6a031d38884846f11ce7e59f19de740 Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Thu, 19 Mar 2026 18:43:09 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=95=B0=E9=87=8F=E5=AF=B9=E4=B8=8D=E4=B8=8A?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/service/impl/FavoritedDeviceServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java index 5b25350..523b469 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java +++ b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java @@ -117,9 +117,10 @@ 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); From cd3bec963ba570dc20326680664c521576e14457 Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Thu, 19 Mar 2026 18:46:11 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=95=B0=E9=87=8F=E5=AF=B9=E4=B8=8D=E4=B8=8A?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/service/impl/FavoritedDeviceServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java index 523b469..14dd629 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java +++ b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java @@ -66,7 +66,9 @@ 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 favoritedDeviceVOList = favoritedDeviceMapperExt.getListPage(pageSearchParam); From 8d578e825d8e4119c67093df9689ca85b10d1877 Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Thu, 19 Mar 2026 19:42:58 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mappers/ex/FavoritedDeviceMapperExt.xml | 1 + .../service/impl/FavoritedDeviceServiceImpl.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml b/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml index c0b6462..dfa346b 100644 --- a/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/FavoritedDeviceMapperExt.xml +++ b/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 AND basic_building.building_id = #{buildingId} diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java index 14dd629..433ef4e 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java +++ b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/FavoritedDeviceServiceImpl.java @@ -125,7 +125,18 @@ public class FavoritedDeviceServiceImpl implements FavoritedDeviceService { resultList.add(data); } - return new PageInfo<>(resultList); + // -------------------- 保留 PageHelper 分页信息 -------------------- + PageInfo pageInfo = new PageInfo<>(favoritedDeviceVOList); + PageInfo 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 buildAlarmDataMap(Long companyId, Integer languageType, List deviceIds) { From 5a8f290586204b4c5d64556ba211caa9e34d5ee7 Mon Sep 17 00:00:00 2001 From: "review512jwy@163.com" <“review512jwy@163.com”> Date: Mon, 30 Mar 2026 20:36:54 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E3=80=90=E5=85=A8=E9=83=A8=20?= =?UTF-8?q?=E6=8B=92=E7=BB=9D=20=E5=8F=AA=E8=AF=BB=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- document/db/20260327.sql | 7 + .../back/controller/RoleController.java | 46 ++++- .../controller/AdminRoleControllerTest.java | 6 +- .../ex/BasicRoleMenuRelationMapperExt.java | 16 ++ .../ex/BasicRoleMenuRelationMapperExt.xml | 60 ++++++ .../dashboard/back/dto/role/OptRoleParam.java | 6 +- .../back/dto/role/RoleMenuPermissionDTO.java | 10 + .../back/vo/role/DashboardTreeMenusDTO.java | 32 +++ .../dashboard/back/vo/role/MenuEntity.java | 13 ++ .../dashboard/back/vo/role/MenuTreeVO.java | 14 ++ .../vo/role/RoleMenuPermissionEntity.java | 13 ++ .../dashboard/back/service/RoleService.java | 11 +- .../service/common/DashboardMenuTree.java | 70 +++++++ .../back/service/impl/RoleServiceImpl.java | 186 ++++++++++++++++-- 14 files changed, 462 insertions(+), 28 deletions(-) create mode 100644 document/db/20260327.sql create mode 100644 dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/RoleMenuPermissionDTO.java create mode 100644 dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/DashboardTreeMenusDTO.java create mode 100644 dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuEntity.java create mode 100644 dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuTreeVO.java create mode 100644 dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/RoleMenuPermissionEntity.java create mode 100644 dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/DashboardMenuTree.java diff --git a/document/db/20260327.sql b/document/db/20260327.sql new file mode 100644 index 0000000..6e81549 --- /dev/null +++ b/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 +); \ No newline at end of file diff --git a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/RoleController.java b/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/RoleController.java index f71b0d6..b0a348e 100644 --- a/dongjian-dashboard-back-controller/src/main/java/com/dongjian/dashboard/back/controller/RoleController.java +++ b/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> 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 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> 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> 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 list) { + roleService.saveRolePermission(roleId, list); + } } diff --git a/dongjian-dashboard-back-controller/src/test/java/com/dongjian/dashboard/back/controller/AdminRoleControllerTest.java b/dongjian-dashboard-back-controller/src/test/java/com/dongjian/dashboard/back/controller/AdminRoleControllerTest.java index 30fb884..45c837f 100644 --- a/dongjian-dashboard-back-controller/src/test/java/com/dongjian/dashboard/back/controller/AdminRoleControllerTest.java +++ b/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); diff --git a/dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/ex/BasicRoleMenuRelationMapperExt.java b/dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/ex/BasicRoleMenuRelationMapperExt.java index 25e9deb..ab55bff 100644 --- a/dongjian-dashboard-back-dao/src/main/java/com/dongjian/dashboard/back/dao/ex/BasicRoleMenuRelationMapperExt.java +++ b/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 deleteMap); + + List selectAllMenu(Map allMenusParamMap); + + List selectByRoleId(@Param("roleId") Long roleId); + + int deleteByRoleId(@Param("roleId") Long roleId); + + int dashboardBatchInsert(@Param("list") List list); + + Long getRoleIdByUserId(@Param("userId") Long userId); + + List getMenuIdListByRoleId(Long roleId); } diff --git a/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/BasicRoleMenuRelationMapperExt.xml b/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/BasicRoleMenuRelationMapperExt.xml index 43b47c3..086d184 100644 --- a/dongjian-dashboard-back-dao/src/main/resources/mappers/ex/BasicRoleMenuRelationMapperExt.xml +++ b/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 FROM basic_role_menu_relation_dashboard + WHERE role_id = #{roleId} + + + + INSERT INTO basic_role_menu_relation_dashboard (role_id, menu_id, permission_type, create_time) + VALUES + + (#{item.roleId}, + #{item.menuId}, + #{item.permissionType}, + #{item.createTime}) + + + + + + \ No newline at end of file diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/OptRoleParam.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/OptRoleParam.java index c875296..33f144a 100644 --- a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/OptRoleParam.java +++ b/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 menuIds; @Schema(description = "所属企业ID",example = "2", hidden = true) private Long companyId; diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/RoleMenuPermissionDTO.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/dto/role/RoleMenuPermissionDTO.java new file mode 100644 index 0000000..2e7d76b --- /dev/null +++ b/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; +} diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/DashboardTreeMenusDTO.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/DashboardTreeMenusDTO.java new file mode 100644 index 0000000..f2e7909 --- /dev/null +++ b/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 children; + + private Integer permissionType; // 0-拒绝 1-只读 2-全部 null=半选 + + private Integer dashboardLowestNode; // 0-否 1-是 + +} diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuEntity.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuEntity.java new file mode 100644 index 0000000..35794c2 --- /dev/null +++ b/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; +} diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuTreeVO.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/MenuTreeVO.java new file mode 100644 index 0000000..b73717c --- /dev/null +++ b/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 children; +} diff --git a/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/RoleMenuPermissionEntity.java b/dongjian-dashboard-back-model/src/main/java/com/dongjian/dashboard/back/vo/role/RoleMenuPermissionEntity.java new file mode 100644 index 0000000..96da09d --- /dev/null +++ b/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; +} diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/RoleService.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/RoleService.java index 8b8b468..7e455fd 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/RoleService.java +++ b/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 getListPage(com.dongjian.dashboard.back.dto.role.PageSearchParam pageSearchParam, Long companyId, Long userId, Integer languageType); - + + SimpleDataResponse> getOwnMenuTree(Long companyId, Long userId, Integer languageType); + + void saveRolePermission(Long roleId, List list); + + SimpleDataResponse> getMenuIdListByRoleId(Long roleId, Long companyId, Long userId, Integer languageType); } diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/DashboardMenuTree.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/common/DashboardMenuTree.java new file mode 100644 index 0000000..872f093 --- /dev/null +++ b/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 menuList = new ArrayList<>(); + + public DashboardMenuTree(List menuList) { + this.menuList = menuList; + } + + /** + * 构建树 + */ + public List buildTree(String rootNodeKey) { + List 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 children = new ArrayList<>(); + + for (DashboardTreeMenusDTO node : menuList) { + if (node.getParentMenuId().equals(parent.getMenuId())) { + children.add(buildChildTree(node)); + } + } + + parent.setChildren(children); + return parent; + } + + /** + * 获取根节点 + */ + private List getRootNode(String rootNodeKey) { + + List roots = new ArrayList<>(); + + for (DashboardTreeMenusDTO node : menuList) { + if (Objects.equals(String.valueOf(node.getParentMenuId()), rootNodeKey)) { + roots.add(node); + } + } + + return roots; + } +} \ No newline at end of file diff --git a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/RoleServiceImpl.java b/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/RoleServiceImpl.java index 5604ee4..1099aa9 100644 --- a/dongjian-dashboard-back-service/src/main/java/com/dongjian/dashboard/back/service/impl/RoleServiceImpl.java +++ b/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 deleteMap = new HashMap<>(); - deleteMap.put("roleId", roleId); - basicRoleMenuRelationMapperExt.deleteDashboardRelation(deleteMap); - //重新插入关联关系 - List idList = Arrays.asList(menuIds.split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()); - Map paramMap = new HashMap(); - 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 menuIds) { + basicRoleMenuRelationMapperExt.deleteByRoleId(roleId); + + if (menuIds == null || menuIds.isEmpty()) { + return; } + + List 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> getOwnMenuTree(Long companyId, Long userId, Integer languageType) { + + // 1查询用户信息 + BasicUser basicUser = basicUserMapperExt.selectByPrimaryKey(userId); + int superRole = basicUser.getSuperRole() == null ? 0 : basicUser.getSuperRole(); + + // 获取角色权限(非超级管理员) + Map permissionMap = new HashMap<>(); + if (superRole != 1) { + Long roleId = basicRoleMenuRelationMapperExt.getRoleIdByUserId(userId); + List permissions = basicRoleMenuRelationMapperExt.selectByRoleId(roleId); + permissionMap = permissions.stream() + .collect(Collectors.toMap( + RoleMenuPermissionEntity::getMenuId, + RoleMenuPermissionEntity::getPermissionType + )); + } + + // 查询全量菜单 + List allMenus = basicRoleMenuRelationMapperExt.selectAllMenu(Collections.emptyMap()); + Map fullMenuMap = allMenus.stream() + .collect(Collectors.toMap(DashboardTreeMenusDTO::getMenuId, m -> m)); + + // 获取用户可见菜单(叶子或有权限的节点) + List visibleMenus; + if (superRole == 1) { + // 超级管理员可见所有 + visibleMenus = new ArrayList<>(allMenus); + } else { + Long roleId = basicRoleMenuRelationMapperExt.getRoleIdByUserId(userId); + Map 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 result = tree.buildTree("-1"); + + // 叶子权限赋值 + fillLeafPermission(result, permissionMap, superRole); + + // 父节点统一赋值=2 + fillParentPermission(result); + + return SimpleDataResponse.success(result); + } + + /** + * 补全父节点(一次传入全量菜单 map) + */ + private List fillMissingParents(List menuList, + Map fullMenuMap) { + + Set allIds = menuList.stream().map(DashboardTreeMenusDTO::getMenuId).collect(Collectors.toSet()); + Set 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 nodes, + Map 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 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 list) { + + basicRoleMenuRelationMapperExt.deleteByRoleId(roleId); + + if (list == null || list.isEmpty()) { + return; + } + + List 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> 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()); + } + } + }