src/main/java/com/nanometer/smartlab/dao/OpeWarehouseReserveDao.xml
@@ -7,10 +7,12 @@
    <result property="reserve" column="reserve"></result>
    <result property="updateTime" column="update_time"></result>
      <result property="warehouseId" column="warehouseId"></result>
      <result property="containerId" column="container_id"></result>
      <result property="warehouseName" column="warehouseName"></result>
    <result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result>
    <result property="reagentId" column="reagent_id"></result>
    <result property="userId" column="user_id"></result>
    <association property="reagent" javaType="com.nanometer.smartlab.entity.SysReagent">
         <id property="id" column="reagentId"/>
       <result property="name" column="name"></result>
@@ -56,6 +58,9 @@
    <if test="productSn != null and productSn != ''">
        and sr.product_sn like concat('%',#{productSn},'%')
    </if>
      <if test="warehouseName != null and warehouseName != ''">
          and sw.name like concat('%',#{warehouseName},'%')
      </if>
  </sql>
  <sql id="queryColumns">
@@ -102,12 +107,12 @@
  </select>
    <insert id="insertOpeWarehouseReserve" parameterType="com.nanometer.smartlab.entity.OpeWarehouseReserve">
        insert into ope_warehouse_reserve(id, reagent_id, article_number, reserve, valid_flag, update_time,warehouseId)
        values (#{id}, #{reagentId}, #{articleNumber}, #{reserve}, 1, now(),#{warehouseId})
        insert into ope_warehouse_reserve(id, reagent_id, article_number, reserve, valid_flag, update_time,warehouseId,container_id,user_id)
        values (#{id}, #{reagentId}, #{articleNumber}, #{reserve}, 1, now(),#{warehouseId},#{containerId},#{userId})
    </insert>
    <insert id="insertOpeWarehouseReserve2" parameterType="com.nanometer.smartlab.entity.OpeWarehouseReserve">
        insert into ope_warehouse_reserve(id, reagent_id, article_number, reserve, valid_flag, update_time,warehouseId,apply_code,order_code)
        values (#{id}, #{reagentId}, #{articleNumber}, #{reserve}, 1, now(),#{warehouseId},#{applyCode},#{orderCode})
        insert into ope_warehouse_reserve(id, reagent_id, article_number, reserve, valid_flag, update_time,warehouseId,apply_code,order_code,container_id,user_id)
        values (#{id}, #{reagentId}, #{articleNumber}, #{reserve}, 1, now(),#{warehouseId},#{applyCode},#{orderCode},#{containerId},#{userId})
    </insert>
    <update id="updateOpeWarehouseReserve" parameterType="com.nanometer.smartlab.entity.OpeWarehouseReserve">
@@ -122,12 +127,101 @@
            <if test="warehouseId != null and warehouseId !=''">
                warehouseId=#{warehouseId},
            </if>
            <if test="containerId != null and containerId !=''">
                container_id=#{containerId},
            </if>
            <if test="userId != null and userId !=''">
                user_id=#{userId},
            </if>
        </set>
        where id=#{id}
    </update>
    <update id="updateOpeWarehouseReserve2" parameterType="com.nanometer.smartlab.entity.OpeWarehouseReserve">
        update ope_warehouse_reserve
         set reserve=#{reserve}
        where id=#{id}
    </update>
    <select id="selectByReId" resultMap="OpeWarehouseReserve">
        select * from ope_warehouse_reserve where reagent_id=#{id}
    </select>
    <select id="selectWarehouseByReagentIdAndArticleNumber" resultMap="OpeWarehouseReserve" parameterType="java.util.Map">
        SELECT
            owr.id,
            owr.reagent_id,
            owr.warehouseId,
            sw.NAME warehouseName,
            sum( owr.reserve ) reserve
        FROM
            ope_warehouse_reserve owr
            LEFT JOIN sys_warehouse sw ON sw.id = owr.warehouseId
        WHERE
            sw.valid_flag = 1
            AND owr.valid_flag = 1
            and owr.reserve > 0
            and  owr.reagent_id = #{reagentId}
        <if test="articleNumber != null and articleNumber != ''">
            and owr.article_number = #{articleNumber}
        </if>
        GROUP BY
            reagent_id,
            warehouseId
        HAVING
            reserve > 0
    </select>
    <select id="selectWarehouseByRidAndArtiNumberAndWid" resultMap="OpeWarehouseReserve" parameterType="java.util.Map">
        SELECT
        owr.id,
        owr.reagent_id,
        owr.warehouseId,
        sw.NAME warehouseName,
        owr.reserve,
        owr.article_number,
        owr.container_id,
        owr.user_id,
        owr.update_time
        FROM
        ope_warehouse_reserve owr
        LEFT JOIN sys_warehouse sw ON sw.id = owr.warehouseId
        WHERE
        sw.valid_flag = 1
        AND owr.valid_flag = 1
        and owr.reserve > 0
        and  owr.reagent_id = #{reagentId}
        <if test="articleNumber != null and articleNumber != ''">
            and owr.article_number = #{articleNumber}
        </if>
        <if test="warehouseId != null and warehouseId != ''">
            and owr.warehouseId = #{warehouseId}
        </if>
    </select>
    <select id="getOpeWarehouseReserveList2" resultMap="OpeWarehouseReserve" parameterType="java.util.Map">
        <include refid="queryColumns"/>
        from ope_warehouse_reserve as oa
        <include refid="queryJoins"/>
        where oa.valid_flag = 1 and oa.reserve > 0
        <include refid="queryWhereSql"/>
        order by oa.update_time,oa.reserve
    </select>
    <select id="countByReagentId" resultType="java.lang.Integer">
        select ifnull(sum(owr.reserve),0)
        from ope_warehouse_reserve as owr
        where owr.reserve > 0
        and owr.reagent_id = #{id}
        and owr.valid_flag = 1
        group by owr.reagent_id
    </select>
    <select id="getRowData" resultMap="OpeWarehouseReserve">
        <include refid="queryColumns"/>
        from ope_warehouse_reserve as oa
        <include refid="queryJoins"/>
        where oa.id = #{id}
    </select>
    <update id="updateByReId" parameterType="java.util.Map">
@@ -137,6 +231,12 @@
    <update id="updateCount" parameterType="java.util.Map">
        update ope_warehouse_reserve set reserve=reserve+1 where reagent_id=#{reagentId} and article_number=#{articleNumber}
        and valid_flag = 1
    </update>
    <update id="updateBtReserve">
        UPDATE ope_warehouse_reserve
        set reserve = reserve - #{1}
        where id = #{0}
    </update>