12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.jsh.erp.datasource.mappers.MaterialBatchMapper">
- <select id="getMaterialBatchByMaterialId" resultType="com.jsh.erp.datasource.entities.MaterialBatch">
- SELECT id,material_id,depot_id,inventory FROM material_batch
- WHERE material_id = #{mid} AND inventory > 0
- ORDER BY production_date ASC
- </select>
- <select id="getInventorySumByDepotAndMid" resultType="java.math.BigDecimal">
- select ifnull(sum(inventory),0) inventory from material_batch
- where material_id = #{mid}
- <if test="depotList.size()>0">
- and depot_id in
- <foreach collection="depotList" item="item" index="index" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- AND ifnull(delete_Flag,'0') !='1'
- </select>
- <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
- select m.*,u.name unit_name,mc.name categoryName,me.bar_code,me.id meId,me.commodity_unit,me.sku,
- 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
- from jsh_material m
- left join material_batch me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
- left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
- left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
- left JOIN jsh_depot d on me.depot_id = d.id and ifnull(d.delete_Flag,'0') !='1'
- left JOIN jsh_supplier s on me.supplier_id = s.id and ifnull(s.delete_Flag,'0') !='1'
- where m.enabled=1 and me.id is not null
- <if test="q != null and q !=''">
- <bind name="bindKey" value="'%'+q+'%'"/>
- 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}
- or m.model like #{bindKey} or m.color like #{bindKey} or m.brand like #{bindKey} )
- </if>
- <if test="standardOrModel != null and standardOrModel !=''">
- <bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
- and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
- </if>
- <if test="color != null and color !=''">
- <bind name="bindColor" value="'%'+color+'%'"/>
- and m.color like #{bindColor}
- </if>
- <if test="brand != null and brand !=''">
- <bind name="bindBrand" value="'%'+brand+'%'"/>
- and m.brand like #{bindBrand}
- </if>
- <if test="enableSerialNumber != null and enableSerialNumber !=''">
- and m.enable_serial_number = #{enableSerialNumber}
- </if>
- <if test="enableBatchNumber != null and enableBatchNumber !=''">
- and m.enable_batch_number = #{enableBatchNumber}
- </if>
- <if test="depotId != null and depotId !=''">
- and me.depot_id = #{depotId}
- </if>
- and ifnull(m.delete_flag,'0') !='1'
- ORDER BY m.id desc, me.default_flag desc, me.id asc
- <if test="offset != null and rows != null">
- limit #{offset},#{rows}
- </if>
- </select>
- </mapper>
|