ExpenseItemMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.management.platform.mapper.ExpenseItemMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.ExpenseItem">
  6. <id column="id" property="id" />
  7. <result column="expense_id" property="expenseId" />
  8. <result column="project_id" property="projectId" />
  9. <result column="happen_date" property="happenDate" />
  10. <result column="invoice_type" property="invoiceType" />
  11. <result column="invoice_no" property="invoiceNo" />
  12. <result column="tax_percent" property="taxPercent" />
  13. <result column="tax_value" property="taxValue" />
  14. <result column="amount" property="amount" />
  15. <result column="remark" property="remark" />
  16. <result column="expense_type" property="expenseType" />
  17. <result column="pic" property="pic" />
  18. <result column="status" property="status" />
  19. </resultMap>
  20. <resultMap id="UserBaseResultMap" type="com.management.platform.entity.vo.ExpenseItemVO">
  21. <id column="id" property="id" />
  22. <result column="expense_id" property="expenseId" />
  23. <result column="project_id" property="projectId" />
  24. <result column="happen_date" property="happenDate" />
  25. <result column="invoice_type" property="invoiceType" />
  26. <result column="invoice_no" property="invoiceNo" />
  27. <result column="tax_percent" property="taxPercent" />
  28. <result column="tax_value" property="taxValue" />
  29. <result column="amount" property="amount" />
  30. <result column="remark" property="remark" />
  31. <result column="expense_type" property="expenseType" />
  32. <result column="pic" property="pic" />
  33. <result column="status" property="status" />
  34. <result column="username" property="username" />
  35. <result column="department_name" property="departmentName" />
  36. </resultMap>
  37. <!-- 通用查询结果列 -->
  38. <sql id="Base_Column_List">
  39. id, expense_id, project_id, happen_date, invoice_type, invoice_no, tax_percent, tax_value, amount, remark, expense_type, pic, status
  40. </sql>
  41. <select id="getUserExpenseDetail" resultMap="UserBaseResultMap">
  42. select a.id, a.expense_id, a.project_id, a.happen_date, a.invoice_type, a.tax_percent, a.tax_value, a.amount, a.remark, a.expense_type, a.pic,a.status,
  43. user.name as username, department.department_name
  44. from expense_item a left join expense_sheet b on a.expense_id = b.id
  45. left join user on user.id = b.owner_id
  46. left join department on department.department_id = user.department_id
  47. where a.project_id = #{projectId} order by a.happen_date desc
  48. </select>
  49. <select id="selectExpenseByProject" resultType="java.lang.Double">
  50. select IFNULL(sum(expense_item.amount),0)
  51. from expense_item
  52. left join expense_sheet on expense_sheet.id = expense_item.expense_id
  53. where expense_item.project_id = #{projectId}
  54. <if test="startDate!=null and endDate!=null">
  55. and happen_date between #{startDate} and #{endDate}
  56. </if>
  57. and expense_item.amount is not null
  58. and expense_sheet.status = 0
  59. </select>
  60. <select id="selectSumAmountByProjectAndType" resultType="java.lang.Double">
  61. select IFNULL(sum(expense_item.amount),0)
  62. from expense_item
  63. left join expense_sheet on expense_sheet.id = expense_item.expense_id
  64. where expense_item.project_id = #{projectId}
  65. and expense_item.amount is not null
  66. and expense_sheet.status &lt;= 1
  67. and expense_sheet.type = #{type}
  68. </select>
  69. </mapper>