|
|
|
<?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.glxp.api.dao.purchase.PurApplyDetailDao">
|
|
|
|
<select id="queryPageList" parameterType="com.glxp.api.req.purchase.PurApplyDetailRequest"
|
|
|
|
resultType="com.glxp.api.entity.purchase.PurApplyDetailEntity">
|
|
|
|
select *
|
|
|
|
FROM pur_apply_detail
|
|
|
|
<where>
|
|
|
|
<if test="orderIdFk != '' and orderIdFk != null">
|
|
|
|
AND orderIdFk = #{orderIdFk}
|
|
|
|
</if>
|
|
|
|
<if test="productId != null">
|
|
|
|
AND productId = #{productId}
|
|
|
|
</if>
|
|
|
|
<if test="supId != '' and supId != null">
|
|
|
|
AND supId = #{supId}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="joinQueryList" parameterType="com.glxp.api.req.purchase.PurApplyDetailRequest"
|
|
|
|
resultType="com.glxp.api.res.purchase.PurOrderDetailResponse">
|
|
|
|
SELECT
|
|
|
|
pur_apply_detail.*,
|
|
|
|
basic_products.nameCode nameCode,
|
|
|
|
basic_products.ggxh spec,
|
|
|
|
basic_products.packUnit,
|
|
|
|
basic_products.manufactory,
|
|
|
|
basic_products.ylqxzcrbarmc,
|
|
|
|
basic_products.spmc,
|
|
|
|
basic_corp.`name` supName
|
|
|
|
FROM pur_apply_detail
|
|
|
|
INNER JOIN basic_udirel ON pur_apply_detail.productId = basic_udirel.id
|
|
|
|
INNER JOIN basic_products ON basic_udirel.uuid = basic_products.uuid
|
|
|
|
left JOIN basic_corp ON pur_apply_detail.supId = basic_corp.erpId
|
|
|
|
<where>
|
|
|
|
<if test="orderIdFk != '' and orderIdFk != null">
|
|
|
|
AND orderIdFk = #{orderIdFk}
|
|
|
|
</if>
|
|
|
|
<if test="productId != null">
|
|
|
|
AND productId = #{productId}
|
|
|
|
</if>
|
|
|
|
<if test="supId != '' and supId != null">
|
|
|
|
AND supId = #{supId}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
GROUP BY basic_products.uuid
|
|
|
|
order by pur_apply_detail.id desc
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="joinQueryListDrug" parameterType="com.glxp.api.req.purchase.PurApplyDetailRequest"
|
|
|
|
resultType="com.glxp.api.res.purchase.PurOrderDetailResponse">
|
|
|
|
SELECT
|
|
|
|
pur_apply_detail.*,
|
|
|
|
basic_products.nameCode nameCode,
|
|
|
|
basic_products.ggxh spec,
|
|
|
|
basic_products.manufactory,
|
|
|
|
basic_products.ylqxzcrbarmc,
|
|
|
|
basic_products.spmc,
|
|
|
|
basic_products.bzgg,
|
|
|
|
basic_products.packUnit,
|
|
|
|
basic_products.prepnSpec,
|
|
|
|
basic_products.prepnUnit,
|
|
|
|
basic_corp.`name` supName
|
|
|
|
FROM pur_apply_detail
|
|
|
|
INNER JOIN basic_udirel ON pur_apply_detail.productId = basic_udirel.id
|
|
|
|
INNER JOIN basic_products ON basic_udirel.uuid = basic_products.uuid
|
|
|
|
left JOIN basic_corp ON pur_apply_detail.supId = basic_corp.erpId
|
|
|
|
<where>
|
|
|
|
<if test="orderIdFk != '' and orderIdFk != null">
|
|
|
|
AND orderIdFk = #{orderIdFk}
|
|
|
|
</if>
|
|
|
|
<if test="productId != null">
|
|
|
|
AND productId = #{productId}
|
|
|
|
</if>
|
|
|
|
<if test="supId != '' and supId != null">
|
|
|
|
AND supId = #{supId}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
GROUP BY basic_products.uuid
|
|
|
|
order by pur_apply_detail.id desc
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="false"
|
|
|
|
parameterType="com.glxp.api.entity.purchase.PurApplyDetailEntity">
|
|
|
|
replace INTO pur_apply_detail
|
|
|
|
(orderIdFk, productId, productName, `count`, supId, zczbhhzbapzbh,destinyId)
|
|
|
|
values (#{orderIdFk},
|
|
|
|
#{productId},
|
|
|
|
#{productName},
|
|
|
|
#{count},
|
|
|
|
#{supId}, #{zczbhhzbapzbh}, #{destinyId})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByIds" parameterType="java.util.List">
|
|
|
|
DELETE
|
|
|
|
FROM pur_apply_detail WHERE id in
|
|
|
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByOrderId" parameterType="map">
|
|
|
|
DELETE
|
|
|
|
FROM pur_apply_detail
|
|
|
|
WHERE orderIdFk = #{orderIdFk}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="update" parameterType="com.glxp.api.entity.purchase.PurApplyDetailEntity">
|
|
|
|
UPDATE pur_apply_detail
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
<if test="orderIdFk != null">
|
|
|
|
orderIdFk=#{orderIdFk},
|
|
|
|
</if>
|
|
|
|
<if test="productId != null">
|
|
|
|
productId=#{productId},
|
|
|
|
</if>
|
|
|
|
<if test="productName != null">
|
|
|
|
productName=#{productName},
|
|
|
|
</if>
|
|
|
|
<if test="count != null">
|
|
|
|
`count`=#{count},
|
|
|
|
</if>
|
|
|
|
<if test="supId != null">
|
|
|
|
supId=#{supId},
|
|
|
|
</if>
|
|
|
|
<if test="zczbhhzbapzbh != null">
|
|
|
|
zczbhhzbapzbh=#{zczbhhzbapzbh},
|
|
|
|
</if>
|
|
|
|
</trim>
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="insertPurApplyDetailEntity" keyProperty="id"
|
|
|
|
parameterType="com.glxp.api.entity.purchase.PurApplyDetailEntity">
|
|
|
|
REPLACE INTO pur_apply_detail
|
|
|
|
(orderIdFk, productId, productName, count, supId, zczbhhzbapzbh) values
|
|
|
|
|
|
|
|
<foreach collection="datas" item="item" index="index" separator=",">
|
|
|
|
(#{item.orderIdFk},
|
|
|
|
#{item.productId},
|
|
|
|
#{item.productName},
|
|
|
|
#{item.count},
|
|
|
|
#{item.supId},
|
|
|
|
#{item.zczbhhzbapzbh})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="selectPurApplyDetailList" resultType="com.glxp.api.res.purchase.PurOrderDetailResponse">
|
|
|
|
SELECT pur_apply_detail.*,
|
|
|
|
pur_apply.billNo,
|
|
|
|
COALESCE(basic_products.ggxh,basic_products.bzgg) AS spec,
|
|
|
|
basic_products.nameCode,
|
|
|
|
basic_products.manufactory,
|
|
|
|
basic_products.ylqxzcrbarmc,
|
|
|
|
basic_corp.`name` supName
|
|
|
|
FROM pur_apply_detail
|
|
|
|
INNER JOIN basic_udirel ON pur_apply_detail.productId = basic_udirel.id
|
|
|
|
INNER JOIN basic_products ON basic_udirel.uuid = basic_products.uuid
|
|
|
|
left JOIN basic_corp ON pur_apply_detail.supId = basic_corp.erpId
|
|
|
|
left join pur_apply on pur_apply.id = pur_apply_detail.orderIdFk
|
|
|
|
Left Join sys_approval_flow as saf ON pur_apply.approvalFlowId = saf.id
|
|
|
|
<where>
|
|
|
|
<if test="nameCode != null and nameCode != ''">
|
|
|
|
AND basic_products.nameCode like concat('%', #{nameCode}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="billNo != null and billNo != ''">
|
|
|
|
AND pur_apply.billNo like concat('%', #{billNo}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="pageType != null ">
|
|
|
|
AND pur_apply.pageType = #{pageType}
|
|
|
|
</if>
|
|
|
|
<if test="productType != null ">
|
|
|
|
AND pur_apply.productType = #{productType}
|
|
|
|
</if>
|
|
|
|
<if test="productId != null">
|
|
|
|
AND productId like concat('%', #{productId}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="productName != null and productName != ''">
|
|
|
|
AND productName like concat('%', #{productName}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="spec != null and spec != ''">
|
|
|
|
AND (
|
|
|
|
basic_products.ggxh like concat('%', #{spec}, '%')
|
|
|
|
or basic_products.bzgg like concat('%', #{spec}, '%')
|
|
|
|
)
|
|
|
|
</if>
|
|
|
|
<if test="zczbhhzbapzbh != null and zczbhhzbapzbh != ''">
|
|
|
|
AND pur_apply_detail.zczbhhzbapzbh like concat('%', #{zczbhhzbapzbh}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="manufactory != null and manufactory != ''">
|
|
|
|
AND basic_products.manufactory like concat('%', #{manufactory}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="startDate != null and startDate != ''">
|
|
|
|
<![CDATA[
|
|
|
|
and DATE_FORMAT(pur_apply.createTime, '%Y-%m-%d') >= #{startDate}
|
|
|
|
]]>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null and endDate != ''">
|
|
|
|
<![CDATA[
|
|
|
|
and DATE_FORMAT(pur_apply.createTime, '%Y-%m-%d') <= #{endDate}
|
|
|
|
]]>
|
|
|
|
</if>
|
|
|
|
<if test="keyWords != '' and keyWords != null">
|
|
|
|
AND (
|
|
|
|
basic_products.nameCode like concat('%', #{keyWords}, '%')
|
|
|
|
or productName like concat('%', #{keyWords}, '%')
|
|
|
|
or basic_products.ggxh like concat('%', #{keyWords}, '%')
|
|
|
|
or basic_products.bzgg LIKE concat('%', #{keyWords}, '%')
|
|
|
|
or basic_products.manufactory like concat('%', #{keyWords}, '%')
|
|
|
|
or pur_apply_detail.zczbhhzbapzbh like concat('%', #{keyWords}, '%'))
|
|
|
|
</if>
|
|
|
|
and (pur_apply.status = 3 or saf.status = 3)
|
|
|
|
</where>
|
|
|
|
GROUP BY basic_products.uuid
|
|
|
|
</select>
|
|
|
|
</mapper>
|