| <?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.SysStoreInfoDao"> | 
|   | 
|     <resultMap type="SysStoreInfo" id="SysStoreInfoMap"> | 
|         <id property="id" column="ID" /> | 
|         <result property="storeId" column="STORE_ID" /> | 
|         <result property="skuId" column="SKU_ID" /> | 
|         <result property="storeTotal" column="STORE_TOTAL" /> | 
|         <result property="goodsPrice" column="GOODS_PRICE" /> | 
|         <result property="batch" column="batch" /> | 
|         <result property="time" column="time" /> | 
|         <result property="shopId" column="shop_id"/> | 
|         <result property="companyId" column="company_id"/> | 
|   | 
|   | 
|   | 
|         <!-- 扩展属性 --> | 
|         <result property="storeName" column="STORE_NAME" /> | 
|         <result property="batchCount" column="batchCount" /> | 
|         <association property="goods"   resultMap="com.matrix.system.hive.dao.ShoppingGoodsDao.ShoppingGoodsMap" columnPrefix="gs_" /> | 
|   | 
|     </resultMap> | 
|     <resultMap type="SysStoreInfo" id="SysStoreInfoMapSimple"> | 
|         <id property="id" column="ID" /> | 
|         <result property="storeId" column="STORE_ID" /> | 
|         <result property="skuId" column="SKU_ID" /> | 
|         <result property="storeTotal" column="STORE_TOTAL" /> | 
|         <result property="goodsPrice" column="GOODS_PRICE" /> | 
|     </resultMap> | 
|   | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="SysStoreInfo" | 
|             useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO sys_store_info ( | 
|             STORE_ID, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             GOODS_PRICE, | 
|             batch, | 
|             time, | 
|             shop_id, | 
|             company_id | 
|         ) | 
|     VALUES ( | 
|             #{storeId}, | 
|             #{skuId}, | 
|             #{storeTotal}, | 
|             #{goodsPrice}, | 
|             #{batch}, | 
|             #{time}, | 
|             #{shopId}, | 
|             #{companyId} | 
|     ) | 
|     </insert> | 
|   | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO sys_store_info ( | 
|         STORE_ID, | 
|         SKU_ID, | 
|         STORE_TOTAL, | 
|         GOODS_PRICE, | 
|         batch, | 
|         time, | 
|         shop_id, | 
|         company_id | 
|         ) | 
|         VALUES | 
|         <foreach collection="list" item="item" index="index" separator=",">( | 
|             #{item.storeId}, | 
|             #{item.skuId}, | 
|             #{item.storeTotal}, | 
|             #{item.goodsPrice}, | 
|             #{item.batch}, | 
|             #{item.time}, | 
|             #{item.shopId}, | 
|             #{item.companyId} | 
|             )</foreach> | 
|     </insert> | 
|   | 
|   | 
|   | 
|   | 
|     <update id="updateGoodsCk" > | 
|         UPDATE sys_store_info | 
|         <set> | 
|             STORE_TOTAL =STORE_TOTAL - #{count} | 
|         </set> | 
|         where ID=#{id} and SKU_ID=#{skuId} | 
|     </update> | 
|   | 
|   | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE sys_store_info | 
|         <set> | 
|             <if test="storeId != null and storeId !='' "> | 
|                 STORE_ID = #{storeId}, | 
|             </if> | 
|             <if test="skuId != null and skuId !='' "> | 
|                 SKU_ID = #{skuId}, | 
|             </if> | 
|             <if test="storeTotal != null "> | 
|                 STORE_TOTAL = #{storeTotal}, | 
|             </if> | 
|             <if test="goodsPrice != null and goodsPrice !='' "> | 
|                 GOODS_PRICE = #{goodsPrice}, | 
|             </if> | 
|             <if test="time != null"> | 
|                 time = #{time}, | 
|             </if> | 
|             <if test="batch != null and batch !='' "> | 
|                 batch = #{batch}, | 
|             </if> | 
|         </set> | 
|         WHERE ID=#{id} | 
|     </update> | 
|   | 
|     <!-- 根据skuid 和仓库id 查询--> | 
|     <select id="selectStoInfo" resultMap="SysStoreInfoMap"> | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             batch, | 
|             time, | 
|             GOODS_PRICE, | 
|             shop_id, | 
|             company_id | 
|         from | 
|             sys_store_info | 
|         where | 
|             batch=#{batch} and  STORE_ID=#{storeId} | 
|   | 
|     </select> | 
|   | 
|     <select id="selectStoInfoBySku" resultMap="SysStoreInfoMap"> | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             batch, | 
|             time, | 
|             GOODS_PRICE, | 
|             shop_id, | 
|             company_id | 
|         from | 
|             sys_store_info | 
|         where | 
|             sku_id=#{skuId} and  STORE_ID=#{storeId} and STORE_TOTAL>0 | 
|             order by time desc | 
|   | 
|     </select> | 
|     <select id="selectByStoreId" resultMap="SysStoreInfoMap"> | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             batch, | 
|             time, | 
|             GOODS_PRICE, | 
|             shop_id, | 
|             company_id | 
|         from | 
|             sys_store_info | 
|         where     STORE_ID=#{storeId}   and STORE_TOTAL>0 | 
|             order by time desc | 
|     </select> | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     <!-- 根据skuid 和仓库id 查询--> | 
|     <select id="selectStoInfoSimple" resultMap="SysStoreInfoMapSimple"> | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             batch, | 
|             time, | 
|             GOODS_PRICE, | 
|             shop_id, | 
|             company_id | 
|         from | 
|             sys_store_info | 
|         where | 
|             SKU_ID=#{skuId} and  STORE_ID=#{storeId} | 
|         order by time desc; | 
|   | 
|     </select> | 
|   | 
|   | 
|     <select id="countDetail"   resultType="java.lang.Integer" > | 
|         select count(*) from sys_store_info where  SKU_ID = #{skuId} | 
|     </select> | 
|   | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="SysStoreInfoMap"> | 
|         select | 
|         a.ID, | 
|         a.STORE_ID, | 
|         (select name from warehouse t where t.id = STORE_ID) STORE_NAME, | 
|         a.SKU_ID, | 
|         a.STORE_TOTAL, | 
|         a.GOODS_PRICE, | 
|         a.batch, | 
|         a.time, | 
|         c.id as gs_id, | 
|         c.code as gs_code, | 
|         c.NAME as gs_NAME, | 
|         c.UNIT as gs_UNIT, | 
|         c.good_type as gs_good_type, | 
|         c.GOODS_SORT_ID as gs_GOODS_SORT_ID, | 
|         c.SUPPLIER_ID as gs_SUPPLIER_ID, | 
|         (select TYPE_NAME from sys_goods_type t where t.id=c.GOODS_SORT_ID) gs_goodsSortName, | 
|   | 
|         c.alarm_num as gs_alarm_num, | 
|         c.volume as gs_volume, | 
|         c.price as gs_price, | 
|         c.wholesale as gs_wholesale, | 
|         a.shop_id, | 
|         a.company_id | 
|         from | 
|         sys_store_info a | 
|         left join  shopping_goods c | 
|         on a.SKU_ID=c.ID | 
|         left join warehouse d | 
|         on a.STORE_ID=d.ID | 
|         where | 
|         a.STORE_TOTAL>0 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.batch != null and record.batch !='' "> | 
|                 and batch = #{record.batch} | 
|             </if> | 
|             <if test="record.storeId != null and record.storeId !='' "> | 
|                 and STORE_ID = #{record.storeId} | 
|             </if> | 
|   | 
|             <if test="record.storeTotal != null and record.storeTotal !='' "> | 
|                 and STORE_TOTAL = #{record.storeTotal} | 
|             </if> | 
|             <if test="record.goods != null and record.goods.name!=null  and record.goods.name!=''"> | 
|                 and  c.NAME like concat('%',#{record.goods.name},'%') | 
|             </if> | 
|             <if test="record.goods != null and record.goods.goodsSortId!=null and record.goods.goodsSortId !='' "> | 
|                 and c.GOODS_SORT_ID=#{record.goods.goodsSortId} | 
|             </if> | 
| <!--            <if test="record.goods != null and record.goods.goodsAttr!=null and record.goods.goodsAttr !='' ">--> | 
| <!--                and c.GOODS_ATTR like concat('%', #{record.goods.goodsAttr} ,'%')--> | 
| <!--            </if>--> | 
|   | 
|             <if test="record.goods != null and record.goods.goodsNo!=null and record.goods.goodsNo !='' "> | 
|                 and c.GOODS_NO like concat('%',#{record.goods.goodsNo},'%') | 
|             </if> | 
|   | 
|             <if test="record.storeName != null and record.storeName !='' "> | 
|                 and d.name like concat('%',#{record.storeName},'%') | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and a.shop_id=#{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and a.company_id=#{record.companyId} | 
|             </if> | 
|   | 
|             <!-- 库存预警 --> | 
|             <if test="record.isAlarm!= null and record.isAlarm !='' "> | 
|                 <if test="record.isAlarm==1"> | 
|                     and a.STORE_TOTAL <= c.ALARM_NUM | 
|                 </if> | 
|                 <if test="record.isAlarm==2"> | 
|                     and a.STORE_TOTAL > c.ALARM_NUM | 
|                 </if> | 
|             </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" parameterType="SysStoreInfo"   resultType="java.lang.Integer"> | 
|         select | 
|         count(*) | 
|         from | 
|         sys_store_info a | 
|         left join  shopping_goods c | 
|         on a.SKU_ID=c.ID | 
|         left join warehouse d | 
|         on a.STORE_ID=d.ID | 
|         where | 
|         a.STORE_TOTAL>0 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.batch != null and record.batch !='' "> | 
|                 and batch = #{record.batch} | 
|             </if> | 
|             <if test="record.storeId != null and record.storeId !='' "> | 
|                 and STORE_ID = #{record.storeId} | 
|             </if> | 
|   | 
|             <if test="record.storeTotal != null and record.storeTotal !='' "> | 
|                 and STORE_TOTAL = #{record.storeTotal} | 
|             </if> | 
|             <if test="record.goods != null and record.goods.name!=null  and record.goods.name!=''"> | 
|                 and  c.NAME like concat('%',#{record.goods.name},'%') | 
|             </if> | 
|             <if test="record.goods != null and record.goods.goodsSortId!=null and record.goods.goodsSortId !='' "> | 
|                 and c.GOODS_SORT_ID=#{record.goods.goodsSortId} | 
|             </if> | 
| <!--            <if test="record.goods != null and record.goods.goodsAttr!=null and record.goods.goodsAttr !='' ">--> | 
| <!--                and c.GOODS_ATTR like concat('%', #{record.goods.goodsAttr} ,'%')--> | 
| <!--            </if>--> | 
|   | 
|             <if test="record.goods  != null and record.goods.goodsNo!=null and record.goods.goodsNo !='' "> | 
|                 and c.GOODS_NO like concat('%',#{record.goods.goodsNo},'%') | 
|             </if> | 
|   | 
|             <if test="record.storeName != null and record.storeName !='' "> | 
|                 and d.name like concat('%',#{record.storeName},'%') | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and a.shop_id=#{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and a.company_id=#{record.companyId} | 
|             </if> | 
|   | 
|             <!-- 库存预警 --> | 
|             <if test="record.isAlarm!= null and record.isAlarm !='' "> | 
|                 <if test="record.isAlarm==1"> | 
|                     and a.STORE_TOTAL <= c.ALARM_NUM | 
|                 </if> | 
|                 <if test="record.isAlarm==2"> | 
|                     and a.STORE_TOTAL > c.ALARM_NUM | 
|                 </if> | 
|             </if> | 
|   | 
|         </if> | 
|     </select> | 
|   | 
|   | 
|   | 
|     <!-- 汇总查库存  --> | 
|     <!-- 分页查询 --> | 
|     <select id="selectCountInPage" resultMap="SysStoreInfoMap"> | 
|         select | 
|         a.ID, | 
|         a.STORE_ID, | 
|         (select name from warehouse t where t.id = STORE_ID) STORE_NAME, | 
|         a.SKU_ID, | 
|         ROUND(SUM(a.STORE_TOTAL) ,2)as STORE_TOTAL, | 
|         count(a.ID) as batchCount, | 
|         AVG(a.GOODS_PRICE) as GOODS_PRICE, | 
|         a.time, | 
|         c.id as gs_id, | 
|         c.code as gs_code, | 
|         c.NAME as gs_NAME, | 
|         c.UNIT as gs_UNIT, | 
|         c.good_type as gs_good_type, | 
|         c.GOODS_SORT_ID as gs_GOODS_SORT_ID, | 
|         c.SUPPLIER_ID as gs_SUPPLIER_ID, | 
|         (select TYPE_NAME from sys_goods_type t where t.id=c.GOODS_SORT_ID) gs_goodsSortName, | 
|   | 
|         c.alarm_num as gs_alarm_num, | 
|         c.volume as gs_volume, | 
|         c.price as gs_price, | 
|         c.wholesale as gs_wholesale, | 
|         c.img as gs_img, | 
|         a.shop_id, | 
|         a.company_id | 
|         from | 
|         sys_store_info a | 
|         left join  shopping_goods c | 
|         on a.SKU_ID=c.ID | 
|         left join warehouse d | 
|         on a.STORE_ID=d.ID | 
|         where | 
|         a.STORE_TOTAL>0 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.batch != null and record.batch !='' "> | 
|                 and batch = #{record.batch} | 
|             </if> | 
|   | 
|             <if test="record.queryKey != null and record.queryKey !='' "> | 
|                 and (instr(c.name,#{record.queryKey}) or instr(c.goods_no, #{record.queryKey}) or instr(c.zjm, #{record.queryKey})) | 
|             </if> | 
|             <if test="record.storeId != null and record.storeId !='' "> | 
|                 and STORE_ID = #{record.storeId} | 
|             </if> | 
|   | 
|             <if test="record.storeTotal != null and record.storeTotal !='' "> | 
|                 and STORE_TOTAL = #{record.storeTotal} | 
|             </if> | 
|             <if test="record.goods != null and record.goods.name!=null and record.goods.name!='' "> | 
|                 and  c.NAME like concat('%',#{record.goods.name},'%') | 
|             </if> | 
|             <if test="record.goods != null and record.goods.goodsSortId!=null and record.goods.goodsSortId !='' "> | 
|                 and c.GOODS_SORT_ID=#{record.goods.goodsSortId} | 
|             </if> | 
| <!--            <if test="record.goods != null and record.goods.goodsAttr!=null and record.goods.goodsAttr !='' ">--> | 
| <!--                and c.GOODS_ATTR like concat('%', #{record.goods.goodsAttr} ,'%')--> | 
| <!--            </if>--> | 
|   | 
|             <if test="record.goods != null and record.goods.goodsNo!=null and record.goods.goodsNo !='' "> | 
|                 and c.GOODS_NO like concat('%',#{record.goods.goodsNo},'%') | 
|             </if> | 
|   | 
|             <if test="record.storeName != null and record.storeName !='' "> | 
|                 and d.name like concat('%',#{record.storeName},'%') | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and a.shop_id=#{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and a.company_id=#{record.companyId} | 
|             </if> | 
|   | 
|             <!-- 库存预警 --> | 
|             <if test="record.isAlarm!= null and record.isAlarm !='' "> | 
|                 <if test="record.isAlarm==1"> | 
|                     and a.STORE_TOTAL <= c.ALARM_NUM | 
|                 </if> | 
|                 <if test="record.isAlarm==2"> | 
|                     and a.STORE_TOTAL > c.ALARM_NUM | 
|                 </if> | 
|             </if> | 
|   | 
|         </if> | 
|         group by a.SKU_ID,a.shop_id | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|   | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|   | 
|     </select> | 
|   | 
|     <!-- 查询总条 --> | 
|     <select id="selectCountTotalRecord" parameterType="SysStoreInfo"   resultType="java.lang.Integer"> | 
|     select count(1) from ( | 
|         select | 
|         a.STORE_ID | 
|         from | 
|         sys_store_info a | 
|         left join  shopping_goods c | 
|         on a.SKU_ID=c.ID | 
|         left join warehouse d | 
|         on a.STORE_ID=d.ID | 
|         where | 
|         a.STORE_TOTAL>0 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.batch != null and record.batch !='' "> | 
|                 and batch = #{record.batch} | 
|             </if> | 
|             <if test="record.queryKey != null and record.queryKey !='' "> | 
|                 and (instr(c.name,#{record.queryKey}) or instr(c.goods_no, #{record.queryKey}) or instr(c.zjm, #{record.queryKey})) | 
|             </if> | 
|             <if test="record.storeId != null and record.storeId !='' "> | 
|                 and STORE_ID = #{record.storeId} | 
|             </if> | 
|   | 
|             <if test="record.storeTotal != null and record.storeTotal !='' "> | 
|                 and STORE_TOTAL = #{record.storeTotal} | 
|             </if> | 
|             <if test="record.goods != null and record.goods.name!=null    and record.goods.name!=''"> | 
|                 and  c.NAME like concat('%',#{record.goods.name},'%') | 
|             </if> | 
|             <if test="record.goods != null and record.goods.goodsSortId!=null and record.goods.goodsSortId !='' "> | 
|                 and c.GOODS_SORT_ID=#{record.goods.goodsSortId} | 
|             </if> | 
| <!--            <if test="record.goods != null and record.goods.goodsAttr!=null and record.goods.goodsAttr !='' ">--> | 
| <!--                and c.GOODS_ATTR like concat('%', #{record.goods.goodsAttr} ,'%')--> | 
| <!--            </if>--> | 
|   | 
|             <if test="record.goods  != null and record.goods.goodsNo!=null and record.goods.goodsNo !='' "> | 
|                 and c.GOODS_NO like concat('%',#{record.goods.goodsNo},'%') | 
|             </if> | 
|   | 
|             <if test="record.storeName != null and record.storeName !='' "> | 
|                 and d.name like concat('%',#{record.storeName},'%') | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and a.shop_id=#{record.shopId} | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and a.company_id=#{record.companyId} | 
|             </if> | 
|   | 
|             <!-- 库存预警 --> | 
|             <if test="record.isAlarm!= null and record.isAlarm !='' "> | 
|                 <if test="record.isAlarm==1"> | 
|                     and a.STORE_TOTAL <= c.ALARM_NUM | 
|                 </if> | 
|                 <if test="record.isAlarm==2"> | 
|                     and a.STORE_TOTAL > c.ALARM_NUM | 
|                 </if> | 
|             </if> | 
|   | 
|         </if> | 
|         group by a.SKU_ID,a.shop_id) f | 
|     </select> | 
|     <!--汇总查询结束 --> | 
|   | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="SysStoreInfoMap"> | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             (select name from warehouse t where t.id = STORE_ID) STORE_NAME, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             GOODS_PRICE, | 
|             batch, | 
|             time, | 
|             shop_id, | 
|             company_id | 
|         from | 
|             sys_store_info | 
|         where | 
|             id=#{id} | 
|   | 
|     </select> | 
|   | 
|   | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="SysStoreInfoMap"> | 
|         select | 
|         ID, | 
|         STORE_ID, | 
|         (select name from warehouse t where t.id = STORE_ID) STORE_NAME, | 
|         SKU_ID, | 
|         STORE_TOTAL, | 
|         GOODS_PRICE, | 
|         batch, | 
|         time | 
|         batch, | 
|         time, | 
|         a.shop_id, | 
|         a.company_id, | 
|         c.id as gs_id, | 
|         c.code as gs_code, | 
|         c.NAME as gs_NAME, | 
|         c.UNIT as gs_UNIT, | 
|         c.good_type as gs_good_type, | 
|         c.GOODS_SORT_ID as gs_GOODS_SORT_ID, | 
|         c.SUPPLIER_ID as gs_SUPPLIER_ID, | 
|         (select TYPE_NAME from sys_goods_type t where t.id=c.GOODS_SORT_ID) gs_goodsSortName, | 
|   | 
|         c.alarm_num as gs_alarm_num, | 
|         c.volume as gs_volume, | 
|         c.price as gs_price, | 
|         c.wholesale as gs_wholesale | 
|         from | 
|         sys_store_info a | 
|         left join  shopping_goods c | 
|         on a.SKU_ID=c.ID | 
|         left join warehouse d | 
|         on a.STORE_ID=d.ID | 
|         where | 
|         1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and ID = #{record.id} | 
|             </if> | 
|             <if test="record.storeId != null and record.storeId !='' "> | 
|                 and STORE_ID = #{record.storeId} | 
|             </if> | 
|             <if test="record.batch != null and record.batch !='' "> | 
|                 and batch = #{record.batch} | 
|             </if> | 
|   | 
|             <if test="record.storeTotal != null and record.storeTotal !='' "> | 
|                 and STORE_TOTAL = #{record.storeTotal} | 
|             </if> | 
|             <if test="record.goods != null and record.goods.name!=null  and record.goods.name!=''"> | 
|                 and  c.NAME like concat('%',#{record.goods.name},'%') | 
|             </if> | 
|             <if test="record.goods != null and record.goods.goodsSortId!=null and record.goods.goodsSortId !='' "> | 
|                 and c.GOODS_SORT_ID=#{record.goods.goodsSortId} | 
|             </if> | 
| <!--            <if test="record.goods != null and record.goods.goodsAttr!=null and record.goods.goodsAttr !='' ">--> | 
| <!--                and c.GOODS_ATTR like concat('%', #{record.goods.goodsAttr} ,'%')--> | 
| <!--            </if>--> | 
|   | 
|             <if test="record.goods!= null  and record.goods.goodsNo!=null and record.goods.goodsNo !='' "> | 
|                 and c.GOODS_NO like concat('%',#{record.goods.goodsNo},'%') | 
|             </if> | 
|   | 
|             <if test="record.storeName != null and record.storeName !='' "> | 
|                 and d.name like concat('%',#{record.storeName},'%') | 
|             </if> | 
|   | 
|             <!-- 库存预警 --> | 
|             <if test="record.isAlarm!= null and record.isAlarm !='' "> | 
|                 <if test="record.isAlarm==1"> | 
|                     and a.STORE_TOTAL <= c.ALARM_NUM | 
|                 </if> | 
|                 <if test="record.isAlarm==2"> | 
|                     and a.STORE_TOTAL > c.ALARM_NUM | 
|                 </if> | 
|             </if> | 
|   | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 查询库存中是否有这个商品 --> | 
|     <select id="getStoreByGoodsId" resultMap="SysStoreInfoMap"> | 
|   | 
|         select | 
|             ID, | 
|             STORE_ID, | 
|             (select name from warehouse t where t.id = STORE_ID) STORE_NAME, | 
|             SKU_ID, | 
|             STORE_TOTAL, | 
|             GOODS_PRICE, | 
|             batch, | 
|             time, | 
|             shop_id, | 
|             company_id | 
|         from    | 
|             sys_store_info | 
|         where  | 
|             SKU_ID = #{skuId} | 
|         and | 
|             STORE_ID = #{storeId} | 
|     </select> | 
|   | 
|     <!-- 查询商品出入库明细 --> | 
|     <select id="findStoreInOutRecord" resultType="com.matrix.system.hive.pojo.StoreInOutRecordVO"> | 
|   | 
| SELECT | 
|     * | 
| FROM | 
|     ( | 
|     SELECT | 
|         b.id id, | 
|         b.create_time as createTime, | 
|         e.CODE, | 
|         e.NAME, | 
|         f.TYPE_NAME AS typeName, | 
|         (0-a.AMOUNT) as AMOUNT, | 
|         g.GOODS_PRICE as goodsPrice, | 
|         (0-a.AMOUNT * g.GOODS_PRICE ) AS totalPrice, | 
|         g.batch, | 
|         b.out_store_no AS orderNo, | 
|         b.remark, | 
|         b.TYPE AS orderType , | 
|         c.su_name as userName, | 
|         d.SHOP_NAME as shopName | 
|     FROM | 
|         sys_out_store_item a | 
|         LEFT JOIN sys_out_store b ON a.OUT_STORE_ID = b.id | 
|         LEFT JOIN sys_users c ON b.STAFF_ID = c.su_id | 
|         LEFT JOIN sys_shop_info d ON b.SHOP_ID = d.id | 
|         LEFT JOIN shopping_goods e ON a.SKU_ID = e.id | 
|         LEFT JOIN sys_goods_type f ON e.GOODS_SORT_ID = f.id | 
|         LEFT JOIN sys_store_info g ON a.store_id = g.id | 
|         <where> | 
|             <if test="record.shopId!=null and record.shopId!='' "> | 
|                 and d.id  = #{record.shopId} | 
|             </if> | 
|             <if test="record.goodsSortId!=null and record.goodsSortId!='' "> | 
|                 and f.id  = #{record.goodsSortId} | 
|             </if> | 
|             <if test="record.userName!=null and record.userName!='' "> | 
|                 and instr( c.su_name, #{record.userName}) | 
|             </if> | 
|             <if test="record.name!=null and record.name!='' "> | 
|                 and (instr( e.NAME, #{record.name}) or instr( e.code, #{record.name})) | 
|             </if> | 
|             <if test="record.orderType!=null and record.orderType!='' "> | 
|                 and b.TYPE =  #{record.orderType} | 
|             </if> | 
|             <if test=" record.beginTime!=null  "> | 
|                 <![CDATA[ and #{record.beginTime}  <=  b.create_time]]> | 
|             </if> | 
|             <if test=" record.endTime!=null   "> | 
|                 <![CDATA[     and #{record.endTime} >=b.create_time]]> | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and    b.company_id = #{record.companyId} | 
|             </if> | 
|   | 
|         </where> | 
|   | 
|     UNION ALL | 
|     SELECT | 
|         t2_b.id id, | 
|         t2_b.create_time, | 
|         t2_e.CODE, | 
|         t2_e.NAME, | 
|         t2_f.TYPE_NAME AS typeName, | 
|         t2_a.AMOUNT, | 
|         t2_g.GOODS_PRICE, | 
|         ( t2_a.AMOUNT * t2_g.GOODS_PRICE ) AS total_price, | 
|         t2_g.batch, | 
|         t2_b.instore_id, | 
|         t2_b.remark, | 
|         t2_b.instore_type, | 
|         t2_c.su_name, | 
|         t2_d.SHOP_NAME | 
|     FROM | 
|         sys_instore_detail t2_a | 
|         LEFT JOIN sys_instore_info t2_b ON t2_a.INSTORE_ID = t2_b.id | 
|         LEFT JOIN sys_users t2_c ON t2_b.MAKING_MAN_ID = t2_c.su_id | 
|         LEFT JOIN sys_shop_info t2_d ON t2_b.SHOP_ID = t2_d.id | 
|         LEFT JOIN shopping_goods t2_e ON t2_a.SKU_ID = t2_e.id | 
|         LEFT JOIN sys_goods_type t2_f ON t2_e.GOODS_SORT_ID = t2_f.id | 
|         LEFT JOIN sys_store_info t2_g ON t2_a.SKU_ID = t2_g.SKU_ID | 
|         AND t2_a.batch = t2_g.batch | 
|         <where> | 
|             <if test="record.shopId!=null and record.shopId!='' "> | 
|                 and t2_d.id  = #{record.shopId} | 
|             </if> | 
|             <if test="record.goodsSortId!=null and record.goodsSortId!='' "> | 
|                 and t2_f.id  = #{record.goodsSortId} | 
|             </if> | 
|             <if test="record.userName!=null and record.userName!='' "> | 
|                 and instr( t2_c.su_name, #{record.userName}) | 
|             </if> | 
|             <if test="record.name!=null and record.name!='' "> | 
|                 and (instr( t2_e.NAME, #{record.name}) or instr( t2_e.code, #{record.name})) | 
|             </if> | 
|             <if test="record.orderType!=null and record.orderType!='' "> | 
|                 and t2_b.instore_type =  #{record.orderType} | 
|             </if> | 
|             <if test=" record.beginTime!=null   "> | 
|                 <![CDATA[ and #{record.beginTime}  <=   t2_b.create_time ]]> | 
|             </if> | 
|             <if test=" record.endTime!=null  "> | 
|                 <![CDATA[     and #{record.endTime} >= t2_b.create_time  ]]> | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and    t2_b.company_id = #{record.companyId} | 
|             </if> | 
|         </where> | 
|   | 
|   | 
|   | 
|     ) t | 
|     order by    createTime desc | 
|     <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|   | 
|         <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|             limit | 
|             #{pageVo.offset},#{pageVo.limit} | 
|         </if> | 
|     </if> | 
|   | 
|   | 
|   | 
|     </select> | 
|   | 
|     <!-- 统计数量 --> | 
|     <select id="findStoreInOutTotal" resultType="java.lang.Integer"> | 
|   | 
|         SELECT | 
|         count(*) | 
|         FROM | 
|         ( | 
|         SELECT a.id | 
|         FROM | 
|         sys_out_store_item a | 
|         LEFT JOIN sys_out_store b ON a.OUT_STORE_ID = b.id | 
|         LEFT JOIN sys_users c ON b.STAFF_ID = c.su_id | 
|         LEFT JOIN sys_shop_info d ON b.SHOP_ID = d.id | 
|         LEFT JOIN shopping_goods e ON a.SKU_ID = e.id | 
|         LEFT JOIN sys_goods_type f ON e.GOODS_SORT_ID = f.id | 
|         LEFT JOIN sys_store_info g ON a.store_id = g.id | 
|         <where> | 
|             <if test="record.shopId!=null and record.shopId!='' "> | 
|                 and d.id  = #{record.shopId} | 
|             </if> | 
|             <if test="record.goodsSortId!=null and record.goodsSortId!='' "> | 
|                 and f.id  = #{record.goodsSortId} | 
|             </if> | 
|             <if test="record.userName!=null and record.userName!='' "> | 
|                 and instr( c.su_name, #{record.userName}) | 
|             </if> | 
|             <if test="record.name!=null and record.name!='' "> | 
|                 and (instr( e.NAME, #{record.name}) or instr( e.code, #{record.name})) | 
|             </if> | 
|             <if test="record.orderType!=null and record.orderType!='' "> | 
|                 and b.TYPE =  #{record.orderType} | 
|             </if> | 
|             <if test=" record.beginTime!=null  "> | 
|                 <![CDATA[ and #{record.beginTime}  <=  b.create_time]]> | 
|             </if> | 
|             <if test=" record.endTime!=null  "> | 
|                 <![CDATA[     and #{record.endTime} >=b.create_time]]> | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and    b.company_id = #{record.companyId} | 
|             </if> | 
|         </where> | 
|         UNION ALL | 
|         SELECT | 
|         t2_a.id | 
|         FROM | 
|         sys_instore_detail t2_a | 
|         LEFT JOIN sys_instore_info t2_b ON t2_a.INSTORE_ID = t2_b.id | 
|         LEFT JOIN sys_users t2_c ON t2_b.MAKING_MAN_ID = t2_c.su_id | 
|         LEFT JOIN sys_shop_info t2_d ON t2_b.SHOP_ID = t2_d.id | 
|         LEFT JOIN shopping_goods t2_e ON t2_a.SKU_ID = t2_e.id | 
|         LEFT JOIN sys_goods_type t2_f ON t2_e.GOODS_SORT_ID = t2_f.id | 
|         LEFT JOIN sys_store_info t2_g ON t2_a.SKU_ID = t2_g.SKU_ID | 
|         AND t2_a.batch = t2_g.batch | 
|         <where> | 
|             <if test="record.shopId!=null and record.shopId!='' "> | 
|                 and t2_d.id  = #{record.shopId} | 
|             </if> | 
|             <if test="record.goodsSortId!=null and record.goodsSortId!='' "> | 
|                 and t2_f.id  = #{record.goodsSortId} | 
|             </if> | 
|             <if test="record.userName!=null and record.userName!='' "> | 
|                 and instr( t2_c.su_name, #{record.userName}) | 
|             </if> | 
|             <if test="record.name!=null and record.name!='' "> | 
|                 and (instr( t2_e.NAME, #{record.name}) or instr( t2_e.code, #{record.name})) | 
|             </if> | 
|             <if test="record.orderType!=null and record.orderType!='' "> | 
|                 and t2_b.instore_type =  #{record.orderType} | 
|             </if> | 
|             <if test=" record.beginTime!=null  "> | 
|                 <![CDATA[ and #{record.beginTime}  <=   t2_b.create_time ]]> | 
|             </if> | 
|             <if test=" record.endTime!=null   "> | 
|                 <![CDATA[     and #{record.endTime} >= t2_b.create_time  ]]> | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId !='' "> | 
|                 and    t2_b.company_id = #{record.companyId} | 
|             </if> | 
|         </where> | 
|         ) t | 
|   | 
|   | 
|   | 
|   | 
|     </select> | 
|   | 
|   | 
|   | 
| </mapper> |