ExpenseItemMapper.xml 4.1 KB

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