<?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.gkhy.hazmat.system.mapper.HzProductMapper">
|
<resultMap type="com.gkhy.hazmat.system.domain.HzProduct" id="HzProductResult">
|
<result property="id" column="id" />
|
<result property="basicId" column="basic_id" />
|
<result property="warehouseId" column="warehouse_id" />
|
<result property="remaining" column="remaining" />
|
<result property="state" column="state" />
|
<result property="code" column="code" />
|
<result property="delFlag" column="del_flag" />
|
<result property="companyId" column="company_id" />
|
<result property="version" column="version" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark" />
|
<result property="warehouseName" column="warehouse_name" />
|
<association property="productBasic" javaType="com.gkhy.hazmat.system.domain.HzProductBasic" resultMap="productBasicResult" />
|
</resultMap>
|
|
<resultMap type="com.gkhy.hazmat.system.domain.HzProductBasic" id="productBasicResult">
|
<result property="id" column="basic_id" />
|
<result property="name" column="basic_name" />
|
<result property="cas" column="basic_cas" />
|
<result property="minPackage" column="basic_min_package" />
|
<result property="productType" column="basic_product_type" />
|
<result property="productCharacter" column="basic_product_character" />
|
<result property="supplier" column="basic_supplier" />
|
<result property="manufacturer" column="basic_manufacturer" />
|
<result property="metering" column="basic_metering" />
|
<result property="unit" column="basic_unit" />
|
<result property="productSn" column="product_sn" />
|
</resultMap>
|
|
<sql id="selectProductVo">
|
select a.id, a.basic_id,a.code, a.warehouse_id, a.remaining, a.state,a.company_id,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
|
b.id as basic_id,b.name as basic_name,b.cas as basic_cas,b.product_type as basic_product_type,b.product_character as basic_product_character,
|
b.supplier as basic_supplier,b.manufacturer as basic_manufacturer,b.metering as basic_metering,b.unit as basic_unit,b.product_sn,b.min_package as basic_min_package,c.name as warehouse_name
|
from hz_product a
|
left join hz_product_basic b on b.id=a.basic_id
|
left join hz_warehouse c on c.id=a.warehouse_id
|
</sql>
|
|
<update id="deleteProductById" parameterType="java.lang.Long">
|
update hz_product set del_flag=1 where id=#{productId}
|
</update>
|
|
<select id="selectProductCountOfWarehouse" resultType="integer">
|
select count(a.id) from hz_product a
|
inner join hz_product_basic b on b.id=basic_id
|
where a.warehouse_id=#{warehouseId} and b.id=#{basicId} and a.company_id=#{companyId} and b.company_id=#{companyId} and a.del_flag=0 and a.state=0
|
</select>
|
|
<select id="selectProductList" resultMap="HzProductResult"
|
parameterType="com.gkhy.hazmat.system.domain.HzProduct">
|
<include refid="selectProductVo"/>
|
<where>
|
and a.del_flag=0
|
<if test="warehouseId != null">
|
and a.warehouse_id=#{warehouseId}
|
</if>
|
<if test="basicId != null">
|
and a.basic_id=#{basicId}
|
</if>
|
<if test="entryId != null">
|
and a.entry_id=#{entryId}
|
</if>
|
<if test="companyId != null">
|
AND a.company_id =#{companyId}
|
</if>
|
<if test="state != null">
|
and a.state=#{state}
|
</if>
|
</where>
|
order by a.id desc
|
</select>
|
|
<select id="selectProductByCode" resultMap="HzProductResult">
|
<include refid="selectProductVo"/>
|
where a.del_flag=0 and a.code=#{code} and a.company_id=#{companyId} limit 1
|
</select>
|
|
<select id="selectProductGroupWareHouse" resultType="com.gkhy.hazmat.system.domain.vo.HzProductWarehouseVO"
|
parameterType="com.gkhy.hazmat.system.domain.HzProduct">
|
select a.basic_id,a.warehouse_id,
|
(select count(1) from hz_product where state=0 and basic_id=a.basic_id and warehouse_id=a.warehouse_id) as stock
|
from hz_product a
|
left join hz_product_basic b on b.id=a.basic_id
|
<where>
|
<if test="companyId != null">
|
AND a.company_id= #{companyId}
|
</if>
|
<if test="basicId != null">
|
AND a.basic_id= #{basicId}
|
</if>
|
<if test="warehouseId != null">
|
AND a.warehouse_id= #{warehouseId}
|
</if>
|
<if test="params.name != null and params.name != ''">
|
AND b.name like concat(#{params.name},"%")
|
</if>
|
<if test="params.productSn != null and params.productSn != ''">
|
AND b.product_sn =#{params.productSn}
|
</if>
|
and a.del_flag=0
|
</where>
|
group by a.basic_id,a.warehouse_id
|
</select>
|
|
</mapper>
|