| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 | 
							- <?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.ym.mec.biz.dal.dao.GoodsProcurementDao">
 
- 	
 
- 	<resultMap type="com.ym.mec.biz.dal.entity.GoodsProcurement" id="GoodsProcurement">
 
- 		<result column="id_" property="id" />
 
- 		<result column="goods_id_" property="goodsId" />
 
- 		<result column="goods_category_id_" property="goodsCategoryId" />
 
- 		<result column="supply_channel_" property="supplyChannel" />
 
- 		<result column="discount_price_" property="discountPrice" />
 
- 		<result column="agree_cost_price_" property="agreeCostPrice" />
 
- 		<result column="stock_count_" property="stockCount" />
 
- 		<result column="tax_stock_count_" property="taxStockCount" />
 
- 		<result column="operator_id_" property="operatorId" />
 
- 		<result column="batch_no_" property="batchNo" />
 
- 		<result column="stock_sold_num_" property="stockSoldNum"/>
 
- 		<result column="tax_stock_sold_num_" property="taxStockSoldNum"/>
 
- 		<result column="create_time_" property="createTime" />
 
- 		<result column="update_time_" property="updateTime" />
 
-         <result column="tenant_id_" property="tenantId"/>
 
- 	</resultMap>
 
- 	
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<select id="get" resultMap="GoodsProcurement" >
 
- 		SELECT * FROM goods_procurement WHERE id_ = #{id} 
 
- 	</select>
 
- 	
 
- 	<!-- 全查询 -->
 
- 	<select id="findAll" resultMap="GoodsProcurement">
 
- 		SELECT * FROM goods_procurement where tenant_id_ = #{tenantId} ORDER BY id_
 
- 	</select>
 
- 	
 
- 	<!-- 向数据库增加一条记录 -->
 
- 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.GoodsProcurement" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		INSERT INTO goods_procurement (goods_id_,goods_category_id_,supply_channel_,discount_price_,agree_cost_price_,stock_count_,tax_stock_count_,operator_id_,batch_no_,create_time_,update_time_,tenant_id_)
 
- 		VALUES(#{goodsId},#{goodsCategoryId},#{supplyChannel},#{discountPrice},#{agreeCostPrice},#{stockCount},#{taxStockCount},#{operatorId},#{batchNo},NOW(),NOW(),#{tenantId})
 
- 	</insert>
 
- 	<insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.GoodsProcurement" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 
- 		INSERT INTO goods_procurement (goods_id_,goods_category_id_,supply_channel_,discount_price_,agree_cost_price_,stock_count_,tax_stock_count_,operator_id_,batch_no_,create_time_,update_time_,tenant_id_)
 
- 		VALUE
 
- 		<foreach collection="goodsProcurements" item="gp" separator=",">
 
- 			(#{gp.goodsId},#{gp.goodsCategoryId},#{gp.supplyChannel},#{gp.discountPrice},#{gp.agreeCostPrice},#{gp.stockCount},#{gp.taxStockCount},#{gp.operatorId},#{gp.batchNo},NOW(),NOW(),#{gp.tenantId})
 
- 		</foreach>
 
- 	</insert>
 
- 	
 
- 	<!-- 根据主键查询一条记录 -->
 
- 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.GoodsProcurement">
 
- 		UPDATE goods_procurement
 
- 		<set>
 
- 			<if test="operatorId != null">
 
- 				operator_id_ = #{operatorId},
 
- 			</if>
 
- 			<if test="agreeCostPrice != null">
 
- 				agree_cost_price_ = #{agreeCostPrice},
 
- 			</if>
 
- 			<if test="id != null">
 
- 				id_ = #{id},
 
- 			</if>
 
- 			<if test="goodsCategoryId != null">
 
- 				goods_category_id_ = #{goodsCategoryId},
 
- 			</if>
 
- 			<if test="taxStockCount != null">
 
- 				tax_stock_count_ = #{taxStockCount},
 
- 			</if>
 
- 			<if test="supplyChannel != null">
 
- 				supply_channel_ = #{supplyChannel},
 
- 			</if>
 
- 			<if test="discountPrice != null">
 
- 				discount_price_ = #{discountPrice},
 
- 			</if>
 
- 			<if test="stockCount != null">
 
- 				stock_count_ = #{stockCount},
 
- 			</if>
 
- 			<if test="goodsId != null">
 
- 				goods_id_ = #{goodsId},
 
- 			</if>
 
- 			<if test="batchNo != null">
 
- 				batch_no_ = #{batchNo},
 
- 			</if>
 
- 			<if test="stockSoldNum != null">
 
- 				stock_sold_num_ = #{stockSoldNum},
 
- 			</if>
 
- 			<if test="taxStockSoldNum != null">
 
- 				tax_stock_sold_num_ = #{taxStockSoldNum},
 
- 			</if>
 
- 				update_time_ = NOW(),
 
- 		</set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
 
- 	</update>
 
- 	
 
-     <update id="batchUpdate" parameterType="java.util.List">
 
-         <foreach collection="goodsProcurements" item="item" index="index" open="" close="" separator=";">
 
- 			UPDATE goods_procurement
 
- 			<set>
 
- 				<if test="item.operatorId != null">
 
- 					operator_id_ = #{item.operatorId},
 
- 				</if>
 
- 				<if test="item.agreeCostPrice != null">
 
- 					agree_cost_price_ = #{item.agreeCostPrice},
 
- 				</if>
 
- 				<if test="item.id != null">
 
- 					id_ = #{item.id},
 
- 				</if>
 
- 				<if test="item.goodsCategoryId != null">
 
- 					goods_category_id_ = #{item.goodsCategoryId},
 
- 				</if>
 
- 				<if test="item.taxStockCount != null">
 
- 					tax_stock_count_ = #{item.taxStockCount},
 
- 				</if>
 
- 				<if test="item.supplyChannel != null">
 
- 					supply_channel_ = #{item.supplyChannel},
 
- 				</if>
 
- 				<if test="item.discountPrice != null">
 
- 					discount_price_ = #{item.discountPrice},
 
- 				</if>
 
- 				<if test="item.stockCount != null">
 
- 					stock_count_ = #{item.stockCount},
 
- 				</if>
 
- 				<if test="item.goodsId != null">
 
- 					goods_id_ = #{item.goodsId},
 
- 				</if>
 
- 				<if test="item.batchNo != null">
 
- 					batch_no_ = #{item.batchNo},
 
- 				</if>
 
- 				<if test="item.stockSoldNum != null">
 
- 					stock_sold_num_ = #{item.stockSoldNum},
 
- 				</if>
 
- 				<if test="item.taxStockSoldNum != null">
 
- 					tax_stock_sold_num_ = #{item.taxStockSoldNum},
 
- 				</if>
 
- 					update_time_ = NOW(),
 
- 			</set> WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
 
- 		</foreach>
 
- 	</update>
 
- 	
 
- 	<!-- 根据主键删除一条记录 -->
 
- 	<delete id="delete" >
 
- 		DELETE FROM goods_procurement WHERE id_ = #{id} 
 
- 	</delete>
 
- 	<sql id="queryCondition">
 
- 		<where>
 
- 			tenant_id_ = #{tenantId}
 
- 			<if test="goodsId!=null">
 
- 				AND goods_id_ = #{goodsId}
 
- 			</if>
 
- 			<if test="enterStorageStartTime!=null and enterStorageEndTime!=null">
 
- 				AND DATE_FORMAT(create_time_, '%Y-%m-%d') BETWEEN #{enterStorageStartTime} AND #{enterStorageEndTime}
 
- 			</if>
 
- 			<if test="search!=null and search!=''">
 
- 				AND supply_channel_ LIKE CONCAT('%', #{search}, '%')
 
- 			</if>
 
- 		</where>
 
- 	</sql>
 
- 	<select id="queryGoodsProcurements" resultMap="GoodsProcurement" parameterType="map">
 
- 		SELECT * FROM goods_procurement
 
- 		<include refid="queryCondition"></include>
 
- 		ORDER BY id_ DESC <include refid="global.limit"/>
 
- 	</select>
 
- 	<select id="countGoodsProcurements" resultType="int">
 
- 		SELECT COUNT(*) FROM goods_procurement
 
- 		<include refid="queryCondition"></include>
 
- 	</select>
 
- 	
 
- 	<!-- 分页查询 -->
 
- 	<select id="queryPage" resultMap="GoodsProcurement" parameterType="map">
 
- 		SELECT * FROM goods_procurement where tenant_id_ = #{tenantId}
 
- 		ORDER BY id_ DESC <include refid="global.limit"/>
 
- 	</select>
 
- 	
 
- 	<!-- 查询当前表的总记录数 -->
 
- 	<select id="queryCount" resultType="int">
 
- 		SELECT COUNT(*) FROM goods_procurement where tenant_id_ = #{tenantId}
 
- 	</select>
 
- 	<select id="getWithStockSurplusProcurement" resultMap="GoodsProcurement" useCache="false" flushCache="true">
 
- 		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND stock_count_>stock_sold_num_ ORDER BY create_time_ LIMIT 1
 
- 	</select>
 
- 	<select id="getWithTaxStockSurplusProcurement" resultMap="GoodsProcurement" useCache="false" flushCache="true">
 
- 		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND tax_stock_count_>tax_stock_sold_num_ ORDER BY create_time_ LIMIT 1
 
- 	</select>
 
- 	<select id="getWithGoodsAndBatchNo" resultMap="GoodsProcurement">
 
- 		SELECT * FROM goods_procurement WHERE goods_id_ = #{goodsId} AND batch_no_=#{batchNo}
 
- 	</select>
 
- </mapper>
 
 
  |