| <?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.matrix.system.hive.dao.SysAllotDetailDao"> | 
|        | 
|     <resultMap type="SysAllotDetail" id="SysAllotDetailMap"> | 
|             <id property="id" column="ID" /> | 
|             <result property="allotId" column="ALLOT_ID" /> | 
|             <result property="skuId" column="SKU_ID" /> | 
|             <result property="appTotal" column="APP_TOTAL" /> | 
|             <result property="realTotal" column="REAL_TOTAL" /> | 
|             <result property="remark" column="REMARK" /> | 
|             <result property="receiveTotal" column="receive_total" /> | 
|   | 
|         <result property="wholesale" column="wholesale" /> | 
|         <result property="storeId" column="store_id" /> | 
|   | 
|   | 
|         <!-- 扩展属性 --> | 
|         <association property="goods"    resultMap="com.matrix.system.hive.dao.SysGoodsDao.SysGoodsMap" /> | 
|         <!-- 调出的仓库库存记录--> | 
|         <association property="storeInfo"  resultMap="com.matrix.system.hive.dao.SysStoreInfoDao.SysStoreInfoMap" /> | 
|   | 
|     </resultMap> | 
|   | 
|     <!-- 获得调拨单明细 --> | 
|     <select id="selectAllottedDetailByOrderId" resultMap="SysAllotDetailMap"> | 
|   | 
|         select | 
|             a.ID, | 
|             a.ALLOT_ID, | 
|             a.SKU_ID, | 
|             a.APP_TOTAL, | 
|             a.REAL_TOTAL, | 
|             a.REMARK, | 
|             a.receive_total, | 
|             a.wholesale, | 
|             a.store_id, | 
|   | 
|             c.GOODS_NO, | 
|         c.NAME, | 
|         c.UNIT, | 
|         c.GOODS_ATTR, | 
|         c.GOODS_SORT_ID, | 
|         c.SUPPLIER_ID, | 
|         (select TYPE_NAME from sys_goods_type t where t.id=c.GOODS_SORT_ID) GOODS_SORT_NAME, | 
|         c.alarm_num, | 
|         c.volume, | 
|         c.price, | 
|         c.wholesale, | 
|   | 
|         b.STORE_TOTAL, | 
|         b.GOODS_PRICE, | 
|         b.batch | 
|         from | 
|             sys_allot_detail a | 
|             left join  sys_store_info b on a.store_id=b.id | 
|             left join  sys_goods c on a.SKU_ID=c.ID | 
|   | 
|         where | 
|             ALLOT_ID=#{alltoId} | 
|     </select> | 
|   | 
|   | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="SysAllotDetail" | 
|             useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO sys_allot_detail ( | 
|         <if test="id!= null and id !='' "> | 
|             ID, | 
|         </if> | 
|         ALLOT_ID, | 
|         SKU_ID, | 
|         APP_TOTAL, | 
|         REAL_TOTAL, | 
|         REMARK, | 
|         receive_total, | 
|         wholesale, | 
|         store_id | 
|         ) | 
|         VALUES ( | 
|         <if test="id!= null and id !='' "> | 
|             #{id}, | 
|         </if> | 
|         #{allotId}, | 
|         #{skuId}, | 
|         #{appTotal}, | 
|         #{realTotal}, | 
|         #{remark}, | 
|         #{receiveTotal}, | 
|         #{wholesale}, | 
|         #{storeId} | 
|         ) | 
|     </insert> | 
|   | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO sys_allot_detail ( | 
|         ID, | 
|         ALLOT_ID, | 
|         SKU_ID, | 
|         APP_TOTAL, | 
|         REAL_TOTAL, | 
|         REMARK, | 
|         receive_total, | 
|         wholesale, | 
|         store_id | 
|         ) | 
|         VALUES | 
|         <foreach collection="list" item="item" index="index" separator=",">( | 
|             #{item.id}, | 
|             #{item.allotId}, | 
|             #{item.skuId}, | 
|             #{item.appTotal}, | 
|             #{item.realTotal}, | 
|             #{item.remark}, | 
|             #{item.receiveTotal}, | 
|             #{item.wholesale}, | 
|             #{item.storeId} | 
|   | 
|             )</foreach> | 
|     </insert> | 
|   | 
|   | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE sys_allot_detail | 
|         <set> | 
|             <if test="allotId != null and allotId !='' "> | 
|                 ALLOT_ID = #{allotId}, | 
|             </if> | 
|             <if test="skuId != null and skuId !='' "> | 
|                 SKU_ID = #{skuId}, | 
|             </if> | 
|             <if test="appTotal != null "> | 
|                 APP_TOTAL = #{appTotal}, | 
|             </if> | 
|             <if test="realTotal != null "> | 
|                 REAL_TOTAL = #{realTotal}, | 
|             </if> | 
|             <if test="remark != null and remark !='' "> | 
|                 REMARK = #{remark}, | 
|             </if> | 
|             <if test="receiveTotal != null "> | 
|                 receive_total = #{receiveTotal}, | 
|             </if> | 
|             <if test="wholesale != null "> | 
|                 wholesale = #{wholesale}, | 
|             </if> | 
|             <if test="storeId != null "> | 
|                 store_id = #{storeId}, | 
|             </if> | 
|         </set> | 
|         WHERE ID=#{id} | 
|     </update> | 
|   | 
|   | 
|   | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from sys_allot_detail where  ID in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|                  separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM sys_allot_detail | 
|         where  ID=#{id} | 
|     </delete> | 
|   | 
|     <!-- 根据调拨单id删除--> | 
|     <delete id="deletebyAllottedInfoId" > | 
|         DELETE FROM sys_allot_detail | 
|         where allot_id=#{id} | 
|     </delete> | 
|   | 
|     <!-- 批量删除  注意 这里的参数是要删除的对象的集合--> | 
|     <delete id="deleteByBeans" parameterType="java.util.List"> | 
|         delete from sys_allot_detail where  ID in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|                  separator="," close=")"> | 
|             #{item.id} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="SysAllotDetailMap"> | 
|         select | 
|         ID, | 
|         ALLOT_ID, | 
|         SKU_ID, | 
|         APP_TOTAL, | 
|         REAL_TOTAL, | 
|         REMARK, | 
|         receive_total, | 
|         wholesale, | 
|         store_id | 
|         from sys_allot_detail | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.allotId != null and record.allotId !='' "> | 
|                 and ALLOT_ID = #{record.allotId} | 
|             </if> | 
|             <if test="record.goodsId != null and record.goodsId !='' "> | 
|                 and SKU_ID = #{record.goodsId} | 
|             </if> | 
|             <if test="record.appTotal != null and record.appTotal !='' "> | 
|                 and APP_TOTAL = #{record.appTotal} | 
|             </if> | 
|             <if test="record.realTotal != null and record.realTotal !='' "> | 
|                 and REAL_TOTAL = #{record.realTotal} | 
|             </if> | 
|             <if test="record.remark != null and record.remark !='' "> | 
|                 and REMARK = #{record.remark} | 
|             </if> | 
|             <if test="record.receiveTotal != null and record.receiveTotal !='' "> | 
|                 and receive_total = #{record.receiveTotal} | 
|             </if> | 
|         </if> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 查询总条 --> | 
|     <select id="selectTotalRecord"    resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from sys_allot_detail | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.allotId != null and record.allotId !='' "> | 
|                 and ALLOT_ID = #{record.allotId} | 
|             </if> | 
|             <if test="record.goodsId != null and record.goodsId !='' "> | 
|                 and SKU_ID = #{record.goodsId} | 
|             </if> | 
|             <if test="record.appTotal != null and record.appTotal !='' "> | 
|                 and APP_TOTAL = #{record.appTotal} | 
|             </if> | 
|             <if test="record.realTotal != null and record.realTotal !='' "> | 
|                 and REAL_TOTAL = #{record.realTotal} | 
|             </if> | 
|             <if test="record.remark != null and record.remark !='' "> | 
|                 and REMARK = #{record.remark} | 
|             </if> | 
|             <if test="record.receiveTotal != null and record.receiveTotal !='' "> | 
|                 and receive_total = #{record.receiveTotal} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="SysAllotDetailMap"> | 
|         select | 
|             ID, | 
|             ALLOT_ID, | 
|             SKU_ID, | 
|             APP_TOTAL, | 
|             REAL_TOTAL, | 
|             REMARK, | 
|             wholesale, | 
|             receive_total, | 
|             store_id | 
|         from sys_allot_detail | 
|         where  ID=#{id} | 
|     </select> | 
|   | 
|   | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="SysAllotDetailMap"> | 
|         select | 
|         ID, | 
|         ALLOT_ID, | 
|         SKU_ID, | 
|         APP_TOTAL, | 
|         REAL_TOTAL, | 
|         REMARK, | 
|         wholesale, | 
|         receive_total, | 
|         store_id | 
|         from sys_allot_detail | 
|         where 1=1 | 
|         <if test="id != null and id !='' "> | 
|             and ID = #{id} | 
|         </if> | 
|         <if test="allotId != null and allotId !='' "> | 
|             and ALLOT_ID = #{allotId} | 
|         </if> | 
|         <if test="skuId != null and skuId !='' "> | 
|             and SKU_ID = #{skuId} | 
|         </if> | 
|         <if test="appTotal != null and appTotal !='' "> | 
|             and APP_TOTAL = #{appTotal} | 
|         </if> | 
|         <if test="realTotal != null and realTotal !='' "> | 
|             and REAL_TOTAL = #{realTotal} | 
|         </if> | 
|         <if test="remark != null and remark !='' "> | 
|             and REMARK = #{remark} | 
|         </if> | 
|         <if test="receiveTotal != null and receiveTotal !='' "> | 
|             and receive_total = #{receiveTotal} | 
|         </if> | 
|     </select> | 
| </mapper> |