ClusterMapper.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.css.simulation.resource.system.mapper.ClusterMapper" >
  4. <!--查询集群列表-->
  5. <select id="getClusterList" parameterType="api.common.pojo.param.system.ClusterParam" resultType="api.common.pojo.vo.system.ClusterVO">
  6. select
  7. p.id,
  8. u.id as user_id,
  9. u.username,
  10. u.use_type,
  11. IFNULL(p.num_simulation_license,0) as num_simulation_license,
  12. IFNULL(p.num_dynamic_license,0) as num_dynamic_license,
  13. p.date_simulation_license,
  14. p.date_dynamic_license,
  15. p.modify_time
  16. from system_user u
  17. left join system_cluster p on u.id = p.user_id
  18. where
  19. u.is_deleted = '0' and u.visible = '1' and IFNULL(p.is_deleted,'0') = '0'
  20. and u.role_code = #{roleCode,jdbcType=VARCHAR}
  21. <if test="createUserId != null and createUserId != ''">
  22. and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
  23. </if>
  24. <if test="userName != null and userName != ''">
  25. and u.username like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
  26. </if>
  27. <if test="modifyTimeStart != null and modifyTimeStart != ''">
  28. and p.modify_time &gt;= #{modifyTimeStart}
  29. </if>
  30. <if test="modifyTimeEnd != null and modifyTimeEnd != ''">
  31. and p.modify_time &lt;= #{modifyTimeEnd}
  32. </if>
  33. <if test="dueTimeStart != null and dueTimeStart != ''">
  34. and (p.date_simulation_license &gt;= #{dueTimeStart} or p.date_dynamic_license &gt;= #{dueTimeStart})
  35. </if>
  36. <if test="dueTimeEnd != null and dueTimeEnd != ''">
  37. and (p.date_simulation_license &lt;= #{dueTimeEnd} or p.date_dynamic_license &lt;= #{dueTimeEnd})
  38. </if>
  39. order by p.modify_time desc
  40. </select>
  41. <!-- 新增集群配置信息-->
  42. <insert id="insert" parameterType="api.common.pojo.po.system.ClusterPO">
  43. INSERT INTO system_cluster(
  44. id,
  45. user_id,
  46. num_simulation_license,
  47. date_simulation_license,
  48. num_dynamic_license,
  49. date_dynamic_license,
  50. create_time,
  51. modify_time,
  52. create_user_id,
  53. modify_user_id,
  54. is_deleted
  55. )
  56. VALUES(
  57. #{id,jdbcType=VARCHAR},
  58. #{userId,jdbcType=VARCHAR},
  59. #{numSimulationLicense,jdbcType=INTEGER},
  60. #{dateSimulationLicense,jdbcType=TIMESTAMP},
  61. #{numDynamicLicense,jdbcType=INTEGER},
  62. #{dateDynamicLicense,jdbcType=TIMESTAMP},
  63. #{createTime,jdbcType=TIMESTAMP},
  64. #{modifyTime,jdbcType=TIMESTAMP},
  65. #{createUserId,jdbcType=VARCHAR},
  66. #{modifyUserId,jdbcType=VARCHAR},
  67. #{isDeleted,jdbcType=VARCHAR}
  68. )
  69. </insert>
  70. <!-- 修改参数配置信息-->
  71. <update id="deleteById" parameterType="api.common.pojo.po.system.ClusterPO">
  72. update system_cluster set
  73. is_deleted = #{isDeleted,jdbcType=VARCHAR},
  74. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  75. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  76. where id = #{id,jdbcType=VARCHAR}
  77. </update>
  78. <!--查询集群修改历史记录-->
  79. <select id="getClusterHistory" parameterType="api.common.pojo.param.system.ClusterParam" resultType="api.common.pojo.vo.system.ClusterVO">
  80. select
  81. id,
  82. IFNULL(num_simulation_license,0) as num_simulation_license,
  83. IFNULL(num_dynamic_license,0) as num_dynamic_license,
  84. date_simulation_license,
  85. date_dynamic_license,
  86. modify_time
  87. from system_cluster
  88. <where>
  89. is_deleted = '1'
  90. </where>
  91. <if test="userId != null and userId != ''">
  92. and user_id = #{userId,jdbcType=VARCHAR}
  93. </if>
  94. order by modify_time desc
  95. </select>
  96. <!--查询已分配未到期节点数量-->
  97. <select id="getClusterNum" parameterType="api.common.pojo.param.system.ClusterParam" resultType="java.util.HashMap">
  98. select
  99. IFNULL(SUM(IF(DATE(p.date_simulation_license) >= DATE(NOW()),p.num_simulation_license,0)),0) as totalSimulation,
  100. IFNULL(SUM(IF(DATE(p.date_dynamic_license) >= DATE(NOW()),p.num_dynamic_license,0)),0) as totalDynamic
  101. from system_user u
  102. left join system_cluster p on u.id = p.user_id
  103. where u.is_deleted = '0' and p.is_deleted = '0' and u.role_code = #{roleCode,jdbcType=VARCHAR}
  104. <if test="createUserId != null and createUserId != ''">
  105. and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
  106. </if>
  107. </select>
  108. <!--查询根据 userId 未到期的仿真软件license数量-->
  109. <select id="getSimulationLicenseNum" parameterType="java.lang.String" resultType="java.lang.Integer">
  110. select num_simulation_license from system_cluster
  111. where is_deleted = '0' and DATE(date_simulation_license) >= DATE(NOW()) and user_id = #{userId,jdbcType=VARCHAR}
  112. </select>
  113. <!--查询根据userId未到期的动力学软件license数量-->
  114. <select id="getDynamicLicenseNum" resultType="java.lang.Integer">
  115. select num_dynamic_license from system_cluster
  116. where is_deleted = '0' and DATE(date_dynamic_license) >= DATE(NOW()) and user_id = #{userId,jdbcType=VARCHAR}
  117. </select>
  118. <select id="getClusterByUserId" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.ClusterVO">
  119. select num_simulation_license, date_simulation_license, num_dynamic_license, date_dynamic_license from system_cluster
  120. where is_deleted = '0' and user_id = #{userId,jdbcType=VARCHAR}
  121. </select>
  122. <select id="getAssignedSimLicenseNum" parameterType="api.common.pojo.param.system.ClusterParam" resultType="java.lang.Integer">
  123. select IFNULL(SUM(num_simulation_license),0) as AssignedSimLicenseNum from system_cluster
  124. where is_deleted = '0' and DATE(date_simulation_license) >= DATE(NOW()) and create_user_id = #{createUserId,jdbcType=VARCHAR}
  125. <if test="userId != null and userId != ''">
  126. and user_id != #{userId,jdbcType=VARCHAR}
  127. </if>
  128. </select>
  129. <select id="getAssignedDynLicenseNum" parameterType="api.common.pojo.param.system.ClusterParam" resultType="java.lang.Integer">
  130. select IFNULL(SUM(num_dynamic_license),0) as AssignedDynLicenseNum from system_cluster
  131. where is_deleted = '0' and DATE(date_dynamic_license) >= DATE(NOW()) and create_user_id = #{createUserId,jdbcType=VARCHAR}
  132. <if test="userId != null and userId != ''">
  133. and user_id != #{userId,jdbcType=VARCHAR}
  134. </if>
  135. </select>
  136. </mapper>