OperatingReportMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.ym.mec.biz.dal.dao.OperatingReportDao">
  4. <resultMap id="OperatingReport" type="com.ym.mec.biz.dal.entity.OperatingReport">
  5. <!--@mbg.generated-->
  6. <!--@Table operating_report-->
  7. <id column="id_" property="id"/>
  8. <result column="organ_id_" property="organId"/>
  9. <result column="organ_name_" property="organName"/>
  10. <result column="cooperation_organ_id_" property="cooperationOrganId"/>
  11. <result column="school_name_" property="schoolName"/>
  12. <result column="sell_amount_" property="sellAmount"/>
  13. <result column="service_amount_" property="serviceAmount"/>
  14. <result column="other_income_" property="otherIncome"/>
  15. <result column="refund_amount_" property="refundAmount"/>
  16. <result column="income_total_" property="incomeTotal"/>
  17. <result column="sell_cost_" property="sellCost"/>
  18. <result column="expenses_amount_" property="expensesAmount"/>
  19. <result column="variable_cost_" property="variableCost"/>
  20. <result column="distribution_amount_" property="distributionAmount"/>
  21. <result column="cost_amount_" property="costAmount"/>
  22. <result column="profit_" property="profit"/>
  23. <result column="month_" property="month"/>
  24. <result column="create_time_" property="createTime"/>
  25. <result column="tenant_id_" property="tenantId"/>
  26. </resultMap>
  27. <sql id="Base_Column_List">
  28. <!--@mbg.generated-->
  29. id_, organ_id_, cooperation_organ_id_, sell_amount_, service_amount_,other_income_, refund_amount_,
  30. income_total_,
  31. sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, cost_amount_,
  32. profit_, month_, create_time_,tenant_id_
  33. </sql>
  34. <select id="get" parameterType="java.lang.Integer" resultMap="OperatingReport">
  35. <!--@mbg.generated-->
  36. select
  37. <include refid="Base_Column_List"/>
  38. from operating_report
  39. where id_ = #{id}
  40. </select>
  41. <delete id="delete" parameterType="java.lang.Integer">
  42. <!--@mbg.generated-->
  43. delete from operating_report
  44. where id_ = #{id}
  45. </delete>
  46. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.OperatingReport"
  47. useGeneratedKeys="true">
  48. <!--@mbg.generated-->
  49. insert into operating_report (organ_id_, cooperation_organ_id_, sell_amount_, service_amount_,other_income_,
  50. refund_amount_,
  51. income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_,
  52. cost_amount_, profit_, month_, create_time_,tenant_id_)
  53. values (#{organId}, #{cooperationOrganId}, #{sellAmount}, #{serviceAmount},#{otherIncome}, #{refundAmount},
  54. #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount},
  55. #{costAmount}, #{profit}, #{month}, #{createTime},#{tenantId})
  56. </insert>
  57. <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReport">
  58. <!--@mbg.generated-->
  59. update operating_report
  60. <set>
  61. <if test="organId != null">
  62. organ_id_ = #{organId},
  63. </if>
  64. <if test="cooperationOrganId != null">
  65. cooperation_organ_id_ = #{cooperationOrganId},
  66. </if>
  67. <if test="sellAmount != null">
  68. sell_amount_ = #{sellAmount},
  69. </if>
  70. <if test="serviceAmount != null">
  71. service_amount_ = #{serviceAmount},
  72. </if>
  73. <if test="otherIncome != null">
  74. other_income_ = #{otherIncome},
  75. </if>
  76. <if test="refundAmount != null">
  77. refund_amount_ = #{refundAmount},
  78. </if>
  79. <if test="incomeTotal != null">
  80. income_total_ = #{incomeTotal},
  81. </if>
  82. <if test="sellCost != null">
  83. sell_cost_ = #{sellCost},
  84. </if>
  85. <if test="expensesAmount != null">
  86. expenses_amount_ = #{expensesAmount},
  87. </if>
  88. <if test="variableCost != null">
  89. variable_cost_ = #{variableCost},
  90. </if>
  91. <if test="distributionAmount != null">
  92. distribution_amount_ = #{distributionAmount},
  93. </if>
  94. <if test="costAmount != null">
  95. cost_amount_ = #{costAmount},
  96. </if>
  97. <if test="profit != null">
  98. profit_ = #{profit},
  99. </if>
  100. <if test="month != null">
  101. month_ = #{month},
  102. </if>
  103. <if test="createTime != null">
  104. create_time_ = #{createTime},
  105. </if>
  106. </set>
  107. where id_ = #{id} and tenant_id_ = #{tenantId}
  108. </update>
  109. <!-- 分页查询 -->
  110. <select id="queryPage" resultMap="OperatingReport" parameterType="map">
  111. SELECT opr.*,o.name_ organ_name_,co.name_ school_name_ FROM operating_report opr
  112. LEFT JOIN organization o ON o.id_ = opr.organ_id_
  113. LEFT JOIN cooperation_organ co ON co.id_= opr.cooperation_organ_id_
  114. <include refid="queryPageSql"/>
  115. ORDER BY opr.month_ DESC,opr.organ_id_ ASC
  116. <include refid="global.limit"/>
  117. </select>
  118. <!-- 查询当前表的总记录数 -->
  119. <select id="queryCount" resultType="int">
  120. SELECT COUNT(*) FROM operating_report opr
  121. <include refid="queryPageSql"/>
  122. </select>
  123. <sql id="queryPageSql">
  124. <where>
  125. opr.tenant_id_ = #{tenantId}
  126. <if test="organIdList != null and organIdList != ''">
  127. AND FIND_IN_SET(opr.organ_id_,#{organIdList})
  128. </if>
  129. <if test="type != null and type=='organ'.toString()">
  130. AND opr.cooperation_organ_id_ IS NULL
  131. </if>
  132. <if test="type != null and type=='school'.toString()">
  133. AND opr.cooperation_organ_id_ IS NOT NULL
  134. </if>
  135. <if test="cooperationOrganId != null">
  136. AND opr.cooperation_organ_id_ = #{cooperationOrganId}
  137. </if>
  138. <if test="startTime != null">
  139. AND opr.month_ >= #{startTime}
  140. </if>
  141. <if test="endTime != null">
  142. AND opr.month_ &lt;= #{endTime}
  143. </if>
  144. </where>
  145. </sql>
  146. <select id="getReport" resultMap="OperatingReport" parameterType="map">
  147. SELECT * FROM operating_report
  148. <where>
  149. organ_id_ = #{organId}
  150. <if test="cooperationOrganId != null">
  151. AND cooperation_organ_id_ = #{cooperationOrganId}
  152. </if>
  153. <if test="cooperationOrganId == null">
  154. AND cooperation_organ_id_ IS NULL
  155. </if>
  156. <if test="startTime != null">
  157. AND month_ >= #{startTime}
  158. </if>
  159. <if test="endTime != null">
  160. AND month_ &lt;= #{endTime}
  161. </if>
  162. </where>
  163. LIMIT 1
  164. </select>
  165. </mapper>