食品采购接口优化
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
fp.food_product_id, fp.food_id, fp.price, fp.supplier_id, fp.edu_id, fp.remark, fp.check_remark, fp.check_status, fp.create_time, fp.update_time, fp.check_time,
|
||||
fp.num, fp.name, fp.type_id,fp.unit_id,fp.spec_id
|
||||
fp.num, fp.name, fp.type_id,fp.unit_id,fp.spec_id,fp.image_url
|
||||
</sql>
|
||||
<select id="queryFoodProductVO" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductVO">
|
||||
SELECT
|
||||
@@ -13,7 +13,7 @@
|
||||
ed.edu_name,sp.supplier_name,sp.del_flag,fp.food_product_id,
|
||||
fp.food_id,fp.price,fp.supplier_id,fp.edu_id,fp.remark,
|
||||
fp.check_remark,fp.check_status,fp.create_time,fp.update_time,
|
||||
fp.check_time,fp.num,fp.name,fp.type_id,fp.unit_id,fp.spec_id,
|
||||
fp.check_time,fp.num,fp.name,fp.type_id,fp.unit_id,fp.spec_id,fp.dept_id,fp.image_url,
|
||||
IFNULL(r.totalProductNum, 0) AS totalProductNum
|
||||
FROM food_product fp
|
||||
LEFT JOIN edu ed ON ed.edu_id = fp.edu_id
|
||||
@@ -23,8 +23,6 @@
|
||||
-- 供货商过滤条件移到ON,保留无供货商商品
|
||||
LEFT JOIN supplier sp
|
||||
ON sp.supplier_id = fp.supplier_id
|
||||
AND sp.status = 1
|
||||
AND sp.del_flag = 0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
food_product_id,
|
||||
@@ -39,7 +37,7 @@
|
||||
) r ON r.food_product_id = fp.food_product_id
|
||||
<where>
|
||||
<if test="foodProductId != null">
|
||||
fp.food_product_id = #{foodProductId}
|
||||
and fp.food_product_id = #{foodProductId}
|
||||
</if>
|
||||
<if test="foodId != null">
|
||||
and fp.food_id = #{foodId}
|
||||
@@ -63,21 +61,32 @@
|
||||
<if test="delFlag != null">
|
||||
and fp.del_flag = #{delFlag}
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and fp.dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by fp.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="pageCKList" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO">
|
||||
select a.food_product_id,a.num,a.name,c.repo_name repoName,d.spec_label specName,
|
||||
b.food_product_num foodProductNum,e.unit_label unitName,a.supplier_id supplierId,
|
||||
a.type_id typeId,b.repo_id repoId,c.merchant_id deptId,a.price
|
||||
select a.food_product_id,a.num,a.name,a.dept_id,c.repo_name repoName,d.spec_label specName,
|
||||
b.food_product_num foodProductNum,e.unit_label unitName,a.supplier_id supplierId,a.image_url imageUrl,
|
||||
a.type_id typeId,b.repo_id repoId,c.merchant_id deptId,a.price,sup.supplier_name supplierName
|
||||
from food_product a
|
||||
left join food_repo b on a.food_product_id=b.food_product_id
|
||||
left join repository c on b.repo_id=c.id
|
||||
left join food_spec d on a.spec_id=d.spec_id
|
||||
left join food_unit e on a.unit_id=e.unit_id
|
||||
where b.repo_id=#{repoId}
|
||||
left join supplier sup on a.supplier_id=sup.supplier_id
|
||||
where b.repo_id=#{repoId} and a.del_flag=0
|
||||
</select>
|
||||
|
||||
<update id="updateDelFlag">
|
||||
update food_product set del_flag = 1 where food_product_id = #{foodProductId}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -15,17 +15,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result column="total_cost" property="totalCost"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="msg" property="msg"/>
|
||||
<result column="school_id" property="schoolId"/>
|
||||
<result column="dept_id" property="deptId"/>
|
||||
<result column="oper_id" property="operId"/>
|
||||
</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
|
||||
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost,re.oper_id operId,su.user_name operName 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 sys_user su on re.oper_id=su.user_id
|
||||
left join food_product p on re.product_id=p.food_product_id WHERE re.id = #{repoRecordId}
|
||||
</select>
|
||||
|
||||
@@ -41,7 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="operId != null">oper_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="applyDate != null">#{applyDate},</if>
|
||||
@@ -53,18 +56,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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>
|
||||
<if test="deptId != null">#{deptId,jdbcType=BIGINT},</if>
|
||||
<if test="operId != null">#{operId,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
|
||||
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost,re.oper_id operId,su.user_name operName 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
|
||||
left join sys_user su on re.oper_id=su.user_id
|
||||
<where>
|
||||
<if test="repoId != null">
|
||||
AND re.repo_id = #{repoId,jdbcType=INTEGER}
|
||||
@@ -72,15 +77,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<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 test="status != null">
|
||||
AND re.status = #{status,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND re.apply_date >= #{startTime,jdbcType=DATETIME}
|
||||
AND re.apply_date >= #{startTime,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND re.apply_date <= #{endTime,jdbcType=DATETIME}
|
||||
AND re.apply_date <= #{endTime,jdbcType=TIMESTAMP}
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and re.dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRepoRecordListByProductId" 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,re.oper_id operId,su.user_name operName 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
|
||||
left join sys_user su on re.oper_id=su.user_id
|
||||
where re.product_id = #{productId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -23,9 +23,13 @@
|
||||
r.manager, r.order_num, d.dept_name as merchant_name
|
||||
from repository r left join sys_dept d on r.merchant_id = d.dept_id
|
||||
</sql>
|
||||
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.entity.Repository"
|
||||
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.vo.RepositoryVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
|
||||
<include refid="joinColumn"/>
|
||||
select r.id,r.merchant_id,r.repo_num,r.repo_name,r.area_code,r.detail_address,r.default_repo,r.create_time,r.update_time,r.oper_id,r.manager,r.order_num,d.dept_name merchant_name,count(fr.food_product_num) spCount,ifnull(sum(fr.food_product_num),0) wpCount,su.user_name managerName
|
||||
from repository r
|
||||
left join sys_dept d on r.merchant_id=d.dept_id
|
||||
left join food_repo fr on r.id=fr.repo_id
|
||||
left join sys_user su on r.manager=su.user_id
|
||||
<where>
|
||||
<if test="id != null ">and r.id = #{id}</if>
|
||||
<if test="merchantId != null ">and r.merchant_id = #{merchantId}</if>
|
||||
@@ -46,6 +50,7 @@
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by r.id,r.merchant_id,r.repo_num,r.repo_name,r.area_code,r.detail_address,r.default_repo,r.create_time,r.update_time,r.oper_id,r.manager,r.order_num,d.dept_name;
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -8,15 +8,13 @@
|
||||
</sql>
|
||||
<select id="querySchoolCartItemVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolCartItemVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolCartItemVO">
|
||||
select
|
||||
<include refid="Base_Column_List"/>,
|
||||
f.food_name, ft.type_id , ft.type_label , fp.price , fu.unit_id , fu.unit_label , su.supplier_name,
|
||||
fp.check_status,fp.del_flag,fp.remark,f.del_flag as foodDelFlag
|
||||
select ci.cart_item_id, ci.school_id, ci.food_product_id, ci.product_num, ci.supplier_id, ci.item_remark, ci.create_time, ci.update_time,
|
||||
fp.name foodName, ft.type_id , ft.type_label , fp.price , fu.unit_id , fu.unit_label , su.supplier_name,
|
||||
fp.check_status,fp.del_flag,fp.remark
|
||||
from school_cart_item ci
|
||||
left join food_product fp on ci.food_product_id = fp.food_product_id
|
||||
left join food f on fp.food_id = f.food_id
|
||||
left join food_type ft on f.type_id = ft.type_id
|
||||
left join food_unit fu on f.unit_id = fu.unit_id
|
||||
left join food_type ft on fp.type_id = ft.type_id
|
||||
left join food_unit fu on fp.unit_id = fu.unit_id
|
||||
left join supplier su on ci.supplier_id = su.supplier_id
|
||||
left join school s on ci.school_id = s.school_id
|
||||
|
||||
@@ -31,7 +29,7 @@
|
||||
and ci.food_product_id = #{foodProductId}
|
||||
</if>
|
||||
<if test="foodName != null and foodName !='' ">
|
||||
and f.food_name like concat('%',#{foodName},'%')
|
||||
and fp.name like concat('%',#{foodName},'%')
|
||||
</if>
|
||||
<if test="supplierId != null">
|
||||
and ci.supplier_id = #{supplierId}
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
</sql>
|
||||
<select id="querySchoolOrderItemVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO">
|
||||
select<include refid="Base_Column_List"/>,
|
||||
ft.type_label,fu.unit_label,fp.remark as food_product_remark
|
||||
select soi.order_item_no, soi.order_no,soi.food_id, soi.school_id, soi.edu_id, soi.supplier_id, soi.food_product_id, soi.food_name, soi.price, soi.product_num, soi.type_id, soi.unit_id, soi.order_item_status, soi.create_time, soi.update_time, soi.order_item_remark,soi.refund_num,
|
||||
ft.type_label,fu.unit_label,fp.remark as food_product_remark,sup.supplier_name supplierName,fu.unit_label modelName
|
||||
from school_order_item soi
|
||||
left join supplier sup on soi.supplier_id=sup.supplier_id
|
||||
left join school_order so on soi.order_no = so.order_no
|
||||
left join food_product fp on soi.food_product_id = fp.food_product_id
|
||||
left join food f on f.food_id = fp.food_id
|
||||
left join food_type ft on ft.type_id = f.type_id
|
||||
left join food_unit fu on fu.unit_id = f.unit_id
|
||||
left join food_type ft on ft.type_id = fp.type_id
|
||||
left join food_unit fu on fu.unit_id = fp.unit_id
|
||||
<where>
|
||||
<if test="orderItemNo != null and orderItemNo != ''">
|
||||
and soi.order_item_no = #{orderItemNo}
|
||||
|
||||
29
fp-system/src/main/resources/mapper/XhMapper.xml
Normal file
29
fp-system/src/main/resources/mapper/XhMapper.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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.XhMapper">
|
||||
|
||||
|
||||
|
||||
<select id="queryXhCreate" resultType="com.zf.foodpurchase.fdsafe.entity.XhCreate">
|
||||
select id, dept_num as deptNum, dept_id as deptId, time_str as timeStr, xh
|
||||
from xh_create
|
||||
where dept_id=#{deptId} and time_str=#{timeStr}
|
||||
</select>
|
||||
<select id="selectMaxDeptNum" resultType="INTEGER">
|
||||
select MAX(dept_num)
|
||||
from xh_create
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertXhCreate">
|
||||
insert into xh_create(dept_num, dept_id, time_str, xh)
|
||||
values(#{deptNum}, #{deptId}, #{timeStr}, #{xh})
|
||||
</insert>
|
||||
|
||||
<update id="updateXhCreate">
|
||||
update xh_create
|
||||
set xh=#{xh}
|
||||
where dept_id=#{deptId} and time_str=#{timeStr}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -94,6 +94,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectRepoUsers" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.account_type ,u.account_dept_id,d.dept_name, d.leader from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
where u.del_flag = '0'
|
||||
<if test="userId != null and userId != 0">
|
||||
AND u.user_id = #{userId}
|
||||
</if>
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND u.status = #{status}
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test="deptIdList != null and deptIdList.size() > 0">
|
||||
and u.dept_id in
|
||||
<foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time, u.account_type,u.account_dept_id
|
||||
from sys_user u
|
||||
|
||||
Reference in New Issue
Block a user