Przeglądaj źródła

首页场景数量

wangzhiqiang 2 lat temu
rodzic
commit
b6b0bd5cf2

+ 2 - 1
simulation-resource-server/src/main/java/com/css/simulation/resource/home/ctrl/HomePageCtrl.java

@@ -49,7 +49,8 @@ public class HomePageCtrl {
     public ResponseBodyVO<Map<String,Integer>> queryAllNum() {
 
         Map<String,Integer> map = algorithmService.selectDetailsBySy();     //算法文件数量
-        map.put("SceneNum", sceneNaturalService.querySceneNumBySy());       //场景数量
+        map.put("SySceneNum", sceneNaturalService.querySceneNumBySy());//私有场景数量
+        map.put("GySceneNum", sceneNaturalService.querySceneNumByGy());//共有场景数量
         map.put("ConfigTotal", configService.getConfigTotal());             //车辆配置数量
         map.put("maxConcurrency", clusterService.getLicenseNum());          //最大并发数量
         map.put("currentConcurrency", homePageService.getRunningTask());    //当前并发数量

+ 19 - 0
simulation-resource-server/src/main/java/com/css/simulation/resource/scene/service/SceneNaturalService.java

@@ -452,6 +452,24 @@ public class SceneNaturalService {
         if (DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
             //管理员账户
             return sceneNaturalMapper.querySceneNumBySy(params);
+        } else if (DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)) {
+            //根据普通子账户查询父账户
+            userId = AuthUtil.getCreateUserId();
+            return sceneNaturalMapper.querySceneNumBySy(params);
+        } else if (DictConstants.ROLE_CODE_UESR.equals(roleCode)) {
+            //查询普通账户
+            return sceneNaturalMapper.querySceneNumBySy(params);
+        }
+        return 0;
+    }
+
+    public Integer querySceneNumByGy() {
+        SceneNaturalParam params = new SceneNaturalParam();
+        String roleCode = AuthUtil.getCurrentUserRoleCode();
+        String userId = AuthUtil.getCurrentUserId();
+        if (DictConstants.ROLE_CODE_ADMIN.equals(roleCode) || DictConstants.ROLE_CODE_SYSADMIN.equals(roleCode)) {
+            //管理员账户
+            return systemScenePackageMapper.querySceneNum("");
         } else if (DictConstants.ROLE_CODE_SUBUESR.equals(roleCode)) {
             //根据普通子账户查询父账户
             userId = AuthUtil.getCreateUserId();
@@ -464,6 +482,7 @@ public class SceneNaturalService {
     }
 
 
+
     /**
      * 获取自然场景数据:
      */

+ 24 - 4
simulation-resource-server/src/main/resources/mapper/scene/SceneNaturalMapper.xml

@@ -419,13 +419,33 @@
 
     <select id="querySceneNumBySy" parameterType="api.common.pojo.param.scene.SceneNaturalParam" resultType="java.lang.Integer">
       select SUM(num) from(
-        select COUNT(1) AS num from simulation.scene_natural WHERE is_deleted = '0'
+        select COUNT(1) AS num from simulation.scene_natural
+        <where> is_deleted = '0'  and share='0'
+        <if test="createUserId != null and createUserId!=''">
+            and create_user_id =#{createUserId}
+        </if>
+    </where>
         union all
-        select COUNT(1) AS num from simulation.scene_accident WHERE is_deleted = '0'
+        select COUNT(1) AS num from simulation.scene_accident
+        <where> is_deleted = '0'  and share='0'
+            <if test="createUserId != null and createUserId!=''">
+                and create_user_id =#{createUserId}
+            </if>
+        </where>
         union all
-        select COUNT(1) AS num from simulation.scene_standards_regulations WHERE is_deleted = '0'
+        select COUNT(1) AS num from simulation.scene_standards_regulations
+        <where> is_deleted = '0'  and share='0'
+            <if test="createUserId != null and createUserId!=''">
+                and create_user_id =#{createUserId}
+            </if>
+        </where>
         union all
-        select COUNT(1) AS num from simulation.scene_general_template WHERE is_deleted = '0') a
+        select COUNT(1) AS num from simulation.scene_general_template
+        <where> is_deleted = '0'  and share='0'
+            <if test="createUserId != null and createUserId!=''">
+                and create_user_id =#{createUserId}
+            </if>
+        </where>) a
     </select>
 
 

+ 24 - 4
simulation-resource-server/src/main/resources/mapper/scene/SystemScenePackageMapper.xml

@@ -148,28 +148,48 @@
                        JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
                        JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
                        JOIN scene_natural d ON d.natural_name = c.scene_name AND d.is_deleted = '0'
-              WHERE a.user_id = #{userId}
+        <where> d.share='2'
+            <if test="userId != null and userId!=''">
+                and a.user_id = #{userId}
+            </if>
+        </where>
+        UNION ALL SELECT COUNT(*) AS num from scene_natural where is_deleted = '0'  and share='1'
               UNION ALL
               SELECT COUNT(DISTINCT c.scene_name) AS num
               FROM system_user_scene a
                        JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
                        JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
                        JOIN scene_accident d ON d.scene_name = c.scene_name AND d.is_deleted = '0'
-              WHERE a.user_id = #{userId}
+        <where> d.share='2'
+            <if test="userId != null and userId!=''">
+                and a.user_id = #{userId}
+            </if>
+        </where>
+        UNION ALL SELECT COUNT(*) AS num from scene_accident where is_deleted = '0'  and share='1'
               UNION ALL
               SELECT COUNT(DISTINCT c.scene_name) AS num
               FROM system_user_scene a
                        JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
                        JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
                        JOIN scene_standards_regulations d ON d.scene_name = c.scene_name AND d.is_deleted = '0'
-              WHERE a.user_id = #{userId}
+        <where> d.share='2'
+            <if test="userId != null and userId!=''">
+                and a.user_id = #{userId}
+            </if>
+        </where>
+        UNION ALL SELECT COUNT(*) AS num from scene_standards_regulations where is_deleted = '0'  and share='1'
               UNION ALL
               SELECT COUNT(DISTINCT c.scene_name) AS num
               FROM system_user_scene a
                        JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
                        JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
                        JOIN scene_general_template d ON d.scene_id = c.scene_name AND d.is_deleted = '0'
-              WHERE a.user_id = #{userId}) AS t
+        <where> d.share='2'
+            <if test="userId != null and userId!=''">
+                and a.user_id = #{userId}
+            </if>
+        </where>
+        UNION ALL SELECT COUNT(*) AS num from scene_general_template where is_deleted = '0'  and share='1') AS t
     </select>