OperatingReportMapper.xml 6.7 KB

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