ProductStockMapper.xml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.hys.app.mapper.erp.ProductStockMapper">
  4. <select id="getOne" resultType="com.hys.app.model.erp.dos.ProductStockDO">
  5. select * from erp_product_stock where id=#{id}
  6. </select>
  7. <!-- 查询产品预警库存信息分页列表 -->
  8. <select id="queryList" resultType="com.hys.app.model.erp.vo.ProductStockV1" useCache="false">
  9. select
  10. ps.id,
  11. ps.actual_stock,
  12. ps.usable_stock,
  13. ps.transit_Stock,
  14. ps.warning_stock,
  15. w.id as warehouse_id,
  16. w.name as warehouse_name,
  17. g.id as goods_id,
  18. g.name as goodsName,
  19. g.bar_code as goods_bar_code,
  20. g.sn ,
  21. p.id as product_id,
  22. p.name as product_name,
  23. p.unit goodsUnit
  24. from erp_product_stock ps
  25. left join erp_warehouse w on ps.warehouse_id = w.id
  26. left join erp_product p on ps.product_id = p.id
  27. left join erp_goods g on ps.goods_id = g.id
  28. <where>
  29. <if test="request.warehouseId != null and request.warehouseId != 0">
  30. and ps.id = #{request.warehouseId}
  31. </if>
  32. <if test="request.keyword != null and request.keyword != ''">
  33. and (
  34. g.name like concat("%",#{request.keyword },"%")
  35. or g.bar_code like concat("%",#{request.keyword },"%")
  36. or g.name like concat("%",#{request.keyword },"%")
  37. )
  38. </if>
  39. </where>
  40. order by ps.id desc
  41. limit ${(request.pageNo- 1) * request.pageSize} , #{request.pageSize}
  42. </select>
  43. <!-- 查询产品预警库存信息分页列表 -->
  44. <select id="selectCount" resultType="Long" useCache="false">
  45. select
  46. count(ps.id)
  47. from erp_product_stock ps
  48. left join erp_warehouse w on ps.warehouse_id = w.id
  49. left join erp_product p on ps.product_id = p.id
  50. left join erp_goods g on ps.goods_id = g.id
  51. left join erp_warehouse_area a on ps.area_id = a.id
  52. <where>
  53. <if test="request.warehouseId != null and request.warehouseId != 0">
  54. and ps.id = #{request.warehouseId}
  55. </if>
  56. <if test="request.keyword != null and request.keyword != ''">
  57. and (
  58. g.name like concat("%",#{request.keyword },"%")
  59. or g.bar_code like concat("%",#{request.keyword },"%")
  60. or g.name like concat("%",#{request.keyword },"%")
  61. )
  62. </if>
  63. </where>
  64. </select>
  65. <!-- 查询产品预警库存信息分页列表 -->
  66. <select id="listWarningStockPage" resultType="com.hys.app.model.erp.vo.ProductStockWarningVO" useCache="false">
  67. select p.*,ps.warehouse_id,w.`name` as warehouse_name,w.dept_id,sd.`name` as dept_name,ps.num as stock_num from erp_product_stock ps
  68. left join erp_warehouse w on ps.warehouse_id = w.id
  69. left join erp_product p on ps.product_id = p.id
  70. left join system_dept sd on w.dept_id = sd.id
  71. <where>
  72. ps.num &lt;= p.warning_value
  73. <if test="deptId != null and deptId != 0">
  74. and w.dept_id = #{deptId}
  75. </if>
  76. <if test="warehouseId != null and warehouseId != 0">
  77. and ps.warehouse_id = #{warehouseId}
  78. </if>
  79. <if test="name != null and name != ''">
  80. and p.name like concat('%',#{name},'%')
  81. </if>
  82. </where>
  83. </select>
  84. </mapper>