InventoryMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.sd.business.mapper.inventory.InventoryMapper">
  4. <select id="getPage" resultType="com.sd.business.entity.inventory.vo.InventoryVo">
  5. select i.id,
  6. i.warehouse_id,
  7. i.bom_spec_id,
  8. i.balance_unit_price,
  9. i.quantity,
  10. i.department_id,
  11. w.name warehouseName,
  12. bs.name bomSpecName,
  13. bs.code bomSpecCode,
  14. d.name departmentName
  15. from ${tableName} i
  16. left join bom_spec bs on i.bom_spec_id = bs.id
  17. left join bom b on bs.bom_id = b.id
  18. left join warehouse w on i.warehouse_id = w.id
  19. left join department d on i.department_id = d.id
  20. ${ew.customSqlSegment}
  21. </select>
  22. <select id="getQuantityByWarehouse" resultType="com.sd.business.entity.inventory.vo.QuantityByWarehouseVo">
  23. select sum(ifnull(i.quantity, 0)) inventoryQuantity,
  24. w.id warehouseId,
  25. w.name warehouseName
  26. from inventory i
  27. left join warehouse w on i.warehouse_id = w.id
  28. group by w.id
  29. order by w.id
  30. </select>
  31. <select id="getQuantityByDepartment" resultType="com.sd.business.entity.inventory.vo.QuantityByDepartmentVo">
  32. select sum(ifnull(i.quantity, 0)) inventoryQuantity,
  33. d.id departmentId,
  34. d.name departmentName
  35. from inventory i
  36. left join department d on i.department_id = d.id
  37. group by d.id
  38. order by d.id
  39. </select>
  40. <select id="getNum" resultType="decimal">
  41. select sum(ifnull(i.quantity, 0))
  42. from in_out_storage_details i
  43. <where>
  44. <if test="bomSpecId != null">
  45. and bom_spec_id = #{bomSpecId}
  46. </if>
  47. <if test="warehouseId != null">
  48. and warehouse_id = #{warehouseId}
  49. </if>
  50. and type = 1
  51. </where>
  52. </select>
  53. <select id="getprice" resultType="decimal">
  54. select sum(ifnull(i.in_sum_price, 0))
  55. from in_out_storage_details i
  56. <where>
  57. <if test="bomSpecId != null">
  58. and bom_spec_id = #{bomSpecId}
  59. </if>
  60. <if test="warehouseId != null">
  61. and warehouse_id = #{warehouseId}
  62. </if>
  63. and type = 1
  64. </where>
  65. </select>
  66. <select id="getInOutDetails" resultType="com.sd.business.entity.in.po.InOutStorageDetails">
  67. select i.quantity,
  68. i.in_unit_price,
  69. i.in_sum_price
  70. from in_out_storage_details i
  71. <where>
  72. <if test="bomSpecId != null">
  73. and bom_spec_id = #{bomSpecId}
  74. </if>
  75. <if test="warehouseId != null">
  76. and warehouse_id = #{warehouseId}
  77. </if>
  78. <if test="departmentId != null">
  79. and department_id = #{departmentId}
  80. </if>
  81. and type = 1
  82. and quantity > 0
  83. </where>
  84. order by i.create
  85. </select>
  86. </mapper>