MaterialsMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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="cn.iocoder.yudao.module.iscs.dal.mysql.materials.MaterialsMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="getIsMaterialsPage"
  11. resultType="cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialsRespVO">
  12. SELECT
  13. m.*,
  14. t.materials_type_name,
  15. c.cabinet_name,
  16. t.materials_type_icon,
  17. t.materials_type_picture
  18. FROM
  19. isc_materials m
  20. LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
  21. LEFT JOIN isc_materials_cabinet c ON c.id = m.materials_cabinet_id
  22. <where>
  23. m.deleted = 0
  24. <if test="vo.materialsCode != null and vo.materialsCode.trim != ''">
  25. and m.materials_code like concat('%',#{vo.materialsCode},'%')
  26. </if>
  27. <if test="vo.materialsName != null and vo.materialsName.trim != ''">
  28. and m.materials_name like concat('%',#{vo.materialsName},'%')
  29. </if>
  30. <if test="vo.loanState != null and vo.loanState.trim != ''">
  31. and m.loan_state = #{vo.loanState}
  32. </if>
  33. <if test="vo.status != null and vo.status.trim != ''">
  34. and m.status = #{vo.status}
  35. </if>
  36. <if test="vo.materialsCabinetId != null and vo.materialsCabinetId > 0">
  37. and m.materials_cabinet_id = #{vo.materialsCabinetId}
  38. </if>
  39. <if test="vo.materialsCabinetId != null and vo.materialsCabinetId == 0">
  40. and (m.materials_cabinet_id is null or m.materials_cabinet_id = 0)
  41. </if>
  42. <if test="vo.materialsTypeId != null">
  43. and m.materials_type_id = #{vo.materialsTypeId}
  44. </if>
  45. <if test="vo.startTime != null and vo.startTime.trim != ''">
  46. and m.create_time &gt;= #{vo.startTime}
  47. </if>
  48. <if test="vo.endTime != null and vo.endTime.trim != ''">
  49. and m.create_time &lt;= #{vo.endTime}
  50. </if>
  51. <if test="vo.startExpirationDate != null and vo.startExpirationDate.trim != ''">
  52. and m.expiration_date &gt;= #{vo.startExpirationDate}
  53. </if>
  54. <if test="vo.endExpirationDate != null and vo.endExpirationDate.trim != ''">
  55. and m.expiration_date &lt;= #{vo.endExpirationDate}
  56. </if>
  57. <if test="vo.supplier != null and vo.supplier.trim != ''">
  58. and m.supplier like concat('%',#{vo.supplier},'%')
  59. </if>
  60. <if test="vo.materialsRfid != null and vo.materialsRfid.trim != ''">
  61. and m.materials_rfid like concat('%',#{vo.materialsRfid},'%')
  62. </if>
  63. <if test="vo.propertyId != null and vo.propertyId.trim != ''">
  64. and m.properties like concat('%',#{vo.propertyId},'%')
  65. </if>
  66. <if test="vo.recordId != null and vo.recordId.trim != ''">
  67. and m.properties like concat('%',#{vo.recordId},'%')
  68. </if>
  69. </where>
  70. ORDER BY m.id DESC
  71. </select>
  72. <select id="getExMaterials"
  73. resultType="cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialsRespVO">
  74. SELECT
  75. m.*,
  76. t.materials_type_name,
  77. c.cabinet_name,
  78. t.materials_type_icon,
  79. t.materials_type_picture
  80. FROM
  81. isc_materials m
  82. LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
  83. LEFT JOIN isc_materials_cabinet c ON c.id = m.materials_cabinet_id
  84. <where>
  85. m.deleted = 0 and
  86. m.materials_id in
  87. <foreach collection="materialsIds" index="index" item="item" open="(" separator="," close=")">
  88. #{item}
  89. </foreach>
  90. </where>
  91. </select>
  92. <select id="getCheckMaterialsByCabinetId"
  93. resultType="cn.iocoder.yudao.module.iscs.controller.admin.hardwareapi.hardwareMaterialApi.CheckMaterialsDateVO">
  94. SELECT
  95. m.id as materials_id,
  96. m.materials_name,
  97. m.status,
  98. m.materials_cabinet_id,
  99. m.materials_type_id,
  100. m.materials_rfid,
  101. t.materials_type_name,
  102. t.materials_type_icon,
  103. t.materials_type_picture,
  104. t.check_standard
  105. FROM
  106. isc_materials m
  107. LEFT JOIN isc_materials_type t ON t.id = m.materials_type_id
  108. where m.materials_cabinet_id = #{cabinetId} and m.loan_state = "1"
  109. </select>
  110. </mapper>