MaterialBatchMapper.xml 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.jsh.erp.datasource.mappers.MaterialBatchMapper">
  4. <select id="getMaterialBatchByMaterialId" resultType="com.jsh.erp.datasource.entities.MaterialBatch">
  5. SELECT id,material_id,depot_id,inventory FROM material_batch
  6. WHERE material_id = #{mid} AND inventory > 0
  7. ORDER BY production_date ASC
  8. </select>
  9. <select id="getInventorySumByDepotAndMid" resultType="java.math.BigDecimal">
  10. select ifnull(sum(inventory),0) inventory from material_batch
  11. where material_id = #{mid}
  12. <if test="depotList.size()>0">
  13. and depot_id in
  14. <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
  15. #{item}
  16. </foreach>
  17. </if>
  18. AND ifnull(delete_Flag,'0') !='1'
  19. </select>
  20. <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
  21. select m.*,u.name unit_name,mc.name categoryName,me.bar_code,me.id meId,me.commodity_unit,me.sku,
  22. me.production_date,me.expiry_num,me.supplier_id,me.batch_number,me.depot_id,me.position,d.`name` depotName,s.supplier supplierName,me.inventory
  23. from jsh_material m
  24. left join material_batch me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
  25. left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
  26. left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
  27. left JOIN jsh_depot d on me.depot_id = d.id and ifnull(d.delete_Flag,'0') !='1'
  28. left JOIN jsh_supplier s on me.supplier_id = s.id and ifnull(s.delete_Flag,'0') !='1'
  29. where m.enabled=1 and me.id is not null
  30. <if test="q != null and q !=''">
  31. <bind name="bindKey" value="'%'+q+'%'"/>
  32. and (me.bar_code like #{bindKey} or me.batch_number like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey} or m.standard like #{bindKey}
  33. or m.model like #{bindKey} or m.color like #{bindKey} or m.brand like #{bindKey} )
  34. </if>
  35. <if test="standardOrModel != null and standardOrModel !=''">
  36. <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
  37. and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
  38. </if>
  39. <if test="color != null and color !=''">
  40. <bind name="bindColor" value="'%'+color+'%'"/>
  41. and m.color like #{bindColor}
  42. </if>
  43. <if test="brand != null and brand !=''">
  44. <bind name="bindBrand" value="'%'+brand+'%'"/>
  45. and m.brand like #{bindBrand}
  46. </if>
  47. <if test="enableSerialNumber != null and enableSerialNumber !=''">
  48. and m.enable_serial_number = #{enableSerialNumber}
  49. </if>
  50. <if test="enableBatchNumber != null and enableBatchNumber !=''">
  51. and m.enable_batch_number = #{enableBatchNumber}
  52. </if>
  53. <if test="depotId != null and depotId !=''">
  54. and me.depot_id = #{depotId}
  55. </if>
  56. and ifnull(m.delete_flag,'0') !='1'
  57. ORDER BY m.id desc, me.default_flag desc, me.id asc
  58. <if test="offset != null and rows != null">
  59. limit #{offset},#{rows}
  60. </if>
  61. </select>
  62. </mapper>