87 lines
4.5 KiB
XML
87 lines
4.5 KiB
XML
|
|
<?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.zf.foodpurchase.fdsafe.mapper.RepoRecordMapper">
|
||
|
|
|
||
|
|
<resultMap id="RepoRecordResultMap" type="com.zf.foodpurchase.fdsafe.entity.RepoRecord">
|
||
|
|
<id column="id" property="id"/>
|
||
|
|
<result column="apply_date" property="applyDate"/>
|
||
|
|
<result column="supplier_id" property="supplierId"/>
|
||
|
|
<result column="category_id" property="categoryId"/>
|
||
|
|
<result column="repo_id" property="repoId"/>
|
||
|
|
<result column="product_id" property="productId"/>
|
||
|
|
<result column="product_num" property="productNum"/>
|
||
|
|
<result column="total_cost" property="totalCost"/>
|
||
|
|
<result column="status" property="status"/>
|
||
|
|
<result column="msg" property="msg"/>
|
||
|
|
<result column="school_id" property="schoolId"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectRepoRecordByRepoRecordId" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
|
||
|
|
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
|
||
|
|
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
|
||
|
|
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
|
||
|
|
left join food_type fd on re.category_id=fd.type_id
|
||
|
|
left join sys_dept sd on re.supplier_id=sd.dept_id
|
||
|
|
left join repository rep on re.repo_id = rep.id
|
||
|
|
left join food_product p on re.product_id=p.food_product_id WHERE re.id = #{repoRecordId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertRepoRecord" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||
|
|
INSERT INTO repo_record
|
||
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="applyDate != null">apply_date,</if>
|
||
|
|
<if test="supplierId != null">supplier_id,</if>
|
||
|
|
<if test="categoryId != null">category_id,</if>
|
||
|
|
<if test="repoId != null">repo_id,</if>
|
||
|
|
<if test="productId != null">product_id,</if>
|
||
|
|
<if test="productNum != null">product_num,</if>
|
||
|
|
<if test="totalCost != null">total_cost,</if>
|
||
|
|
<if test="status != null">status,</if>
|
||
|
|
<if test="msg != null and msg != ''">msg,</if>
|
||
|
|
<if test="schoolId != null">school_id,</if>
|
||
|
|
</trim>
|
||
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
|
<if test="applyDate != null">#{applyDate},</if>
|
||
|
|
<if test="supplierId != null">#{supplierId,jdbcType=INTEGER},</if>
|
||
|
|
<if test="categoryId != null">#{categoryId,jdbcType=INTEGER},</if>
|
||
|
|
<if test="repoId != null">#{repoId,jdbcType=INTEGER},</if>
|
||
|
|
<if test="productId != null">#{productId,jdbcType=INTEGER},</if>
|
||
|
|
<if test="productNum != null">#{productNum,jdbcType=INTEGER},</if>
|
||
|
|
<if test="totalCost != null">#{totalCost},</if>
|
||
|
|
<if test="status != null">#{status,jdbcType=INTEGER},</if>
|
||
|
|
<if test="msg != null and msg != ''">#{msg,jdbcType=VARCHAR},</if>
|
||
|
|
<if test="schoolId != null">#{schoolId,jdbcType=BIGINT},</if>
|
||
|
|
</trim>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="selectRepoRecordList" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
|
||
|
|
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
|
||
|
|
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
|
||
|
|
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
|
||
|
|
left join food_type fd on re.category_id=fd.type_id
|
||
|
|
left join sys_dept sd on re.supplier_id=sd.dept_id
|
||
|
|
left join repository rep on re.repo_id = rep.id
|
||
|
|
left join food_product p on re.product_id=p.food_product_id
|
||
|
|
<where>
|
||
|
|
<if test="repoId != null">
|
||
|
|
AND re.repo_id = #{repoId,jdbcType=INTEGER}
|
||
|
|
</if>
|
||
|
|
<if test="productName != null and productName != ''">
|
||
|
|
AND p.name LIKE CONCAT('%', #{productName,jdbcType=VARCHAR}, '%')
|
||
|
|
</if>
|
||
|
|
<if test="categoryId != null">
|
||
|
|
AND fd.type_id = #{categoryId,jdbcType=INTEGER}
|
||
|
|
</if>
|
||
|
|
<if test="startTime != null">
|
||
|
|
AND re.apply_date >= #{startTime,jdbcType=DATETIME}
|
||
|
|
</if>
|
||
|
|
<if test="endTime != null">
|
||
|
|
AND re.apply_date <= #{endTime,jdbcType=DATETIME}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
</mapper>
|