ExpenseItemMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. <result column="corpwxUserId" property="corpwxUserId" />
  37. <result column="corpwxDeptId" property="corpwxDeptId" />
  38. </resultMap>
  39. <!-- 通用查询结果列 -->
  40. <sql id="Base_Column_List">
  41. id, expense_id, project_id, happen_date, invoice_type, invoice_no, tax_percent, tax_value, amount, remark, expense_type, pic, status
  42. </sql>
  43. <select id="getUserExpenseDetail" resultMap="UserBaseResultMap">
  44. 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,
  45. user.name as username,user.corpwx_userid as corpwxUserId, department.department_name,department.corpwx_deptid as corpwxDeptId
  46. from expense_item a
  47. left join expense_sheet b on a.expense_id = b.id
  48. left join user on user.id = b.owner_id
  49. left join department on department.department_id = user.department_id
  50. where a.project_id = #{projectId} order by a.happen_date desc
  51. </select>
  52. <select id="selectExpenseByProject" resultType="java.lang.Double">
  53. select IFNULL(sum(expense_item.amount),0)
  54. from expense_item
  55. left join expense_sheet on expense_sheet.id = expense_item.expense_id
  56. where expense_item.project_id = #{projectId}
  57. <if test="startDate!=null and endDate!=null">
  58. and happen_date between #{startDate} and #{endDate}
  59. </if>
  60. and expense_item.amount is not null
  61. and expense_sheet.status = 0
  62. <if test="type!=null">
  63. and expense_sheet.type = #{type}
  64. </if>
  65. </select>
  66. <select id="selectSumAmountByProjectAndType" resultType="java.lang.Double">
  67. select IFNULL(sum(expense_item.amount),0)
  68. from expense_item
  69. left join expense_sheet on expense_sheet.id = expense_item.expense_id
  70. where expense_item.project_id = #{projectId}
  71. and expense_item.amount is not null
  72. and expense_sheet.status &lt;= 1
  73. and expense_sheet.type = #{type}
  74. </select>
  75. </mapper>