WXF пре 2 година
родитељ
комит
7bdd366e89

+ 4 - 22
simulation-resource-server/src/main/resources/mapper/system/ClusterMapper.xml

@@ -102,34 +102,16 @@
 
     <!--查询已分配未到期节点数量-->
     <select id="getClusterNum" parameterType="api.common.pojo.param.system.ClusterParam" resultType="java.util.HashMap">
+
         select
-        (
-        select
-        sum(p.num_simulation_license)
-        from system_user u
-        left join system_cluster p on u.id = p.user_id
-        <where>
-            u.is_deleted = '0' and u.visible = '1' and p.is_deleted = '0'
-            and DATE(p.date_simulation_license) >= DATE(NOW())
-            and u.role_code = #{roleCode,jdbcType=VARCHAR}
-        </where>
-        <if test="createUserId != null and createUserId != ''">
-            and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
-        </if>
-        ) as totalSimulation, (
-        select
-        sum(p.num_dynamic_license)
+          IFNULL(SUM(IF(DATE(p.date_simulation_license) >= DATE(NOW()),p.num_simulation_license,0)),0) as totalSimulation,
+          IFNULL(SUM(IF(DATE(p.date_dynamic_license) >= DATE(NOW()),p.num_dynamic_license,0)),0) as totalDynamic
         from system_user u
         left join system_cluster p on u.id = p.user_id
-        <where>
-            u.is_deleted = '0' and u.visible = '1'  and p.is_deleted = '0'
-            and DATE(p.date_dynamic_license) >= DATE(NOW())
-            and u.role_code = #{roleCode,jdbcType=VARCHAR}
-        </where>
+        where u.is_deleted = '0' and p.is_deleted = '0' and u.role_code = #{roleCode,jdbcType=VARCHAR}
         <if test="createUserId != null and createUserId != ''">
             and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
         </if>
-        ) as totalDynamic
     </select>
 
     <!--查询根据userId未到期的仿真软件license数量-->