|
|
|
<?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.PurApplyDao">
|
|
|
|
<select id="queryPageList" parameterType="com.glxp.api.req.purchase.PurApplyRequest"
|
|
|
|
resultType="com.glxp.api.res.purchase.PurApplyResponse">
|
|
|
|
SELECT IFNULL(saf.status,1) as flowStatus,saf.updateTime as flowAuditTime,
|
|
|
|
pur_apply.*,
|
|
|
|
cb.employeeName createByName,
|
|
|
|
ab.employeeName auditByName,
|
|
|
|
auth_warehouse.`name` targetInvName,
|
|
|
|
auth_dept.`name` targetDeptName,
|
|
|
|
aw1.`name` invName,
|
|
|
|
ad1.`name` deptName
|
|
|
|
FROM pur_apply
|
|
|
|
LEFT JOIN auth_user cb ON pur_apply.createUser = cb.id
|
|
|
|
LEFT JOIN auth_user ab ON pur_apply.auditUser = ab.id
|
|
|
|
LEFT JOIN auth_warehouse ON pur_apply.targetInvCode = auth_warehouse.`code`
|
|
|
|
LEFT JOIN auth_dept ON auth_dept.`code` = pur_apply.targetDeptCode
|
|
|
|
LEFT JOIN auth_warehouse aw1 ON pur_apply.invCode = aw1.`code`
|
|
|
|
LEFT JOIN auth_dept ad1 ON ad1.`code` = pur_apply.deptCode
|
|
|
|
Left Join sys_approval_flow as saf ON pur_apply.approvalFlowId = saf.id
|
|
|
|
<where>
|
|
|
|
<if test="billNo != '' and billNo != null">
|
|
|
|
AND billNo = #{billNo}
|
|
|
|
</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="startAuditDate != null and startAuditDate != ''">
|
|
|
|
<![CDATA[
|
|
|
|
and DATE_FORMAT(pur_apply.auditTime, '%Y-%m-%d') >= #{startAuditDate}
|
|
|
|
]]>
|
|
|
|
</if>
|
|
|
|
<if test="endAuditDate != null and endAuditDate != ''">
|
|
|
|
<![CDATA[
|
|
|
|
and DATE_FORMAT(pur_apply.auditTime, '%Y-%m-%d') <= #{endAuditDate}
|
|
|
|
]]>
|
|
|
|
</if>
|
|
|
|
<if test="status != null and status != 10 and status != 11 and status != 12">
|
|
|
|
and pur_apply.status = #{status}
|
|
|
|
</if>
|
|
|
|
<if test="status == 10">
|
|
|
|
and (saf.status=2 or saf.status=1 or saf.status=3)
|
|
|
|
</if>
|
|
|
|
<if test="status == 11">
|
|
|
|
and (saf.status is null or saf.status=0 or saf.status=1 or saf.status=3)
|
|
|
|
</if>
|
|
|
|
<if test="status == 12">
|
|
|
|
and (saf.status=2 or saf.status=3)
|
|
|
|
</if>
|
|
|
|
<if test="deptCode != '' and deptCode != null">
|
|
|
|
AND deptCode = #{deptCode}
|
|
|
|
</if>
|
|
|
|
<if test="invCode != '' and invCode != null">
|
|
|
|
AND pur_apply.invCode = #{invCode}
|
|
|
|
</if>
|
|
|
|
<if test="targetInvCode != '' and targetInvCode != null">
|
|
|
|
AND targetInvCode = #{targetInvCode}
|
|
|
|
</if>
|
|
|
|
<if test="targetDeptCode != '' and targetDeptCode != null">
|
|
|
|
AND targetDeptCode = #{targetDeptCode}
|
|
|
|
</if>
|
|
|
|
<if test="auditUser != '' and auditUser != null">
|
|
|
|
AND auditUser = #{auditUser}
|
|
|
|
</if>
|
|
|
|
<if test="createUser != '' and createUser != null">
|
|
|
|
AND pur_apply.createUser = #{createUser}
|
|
|
|
</if>
|
|
|
|
<if test="applyType != null">
|
|
|
|
AND generatePlan = 1
|
|
|
|
</if>
|
|
|
|
<if test="emergency != null">
|
|
|
|
AND emergency = #{emergency}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
<choose>
|
|
|
|
<when test="(orderBy != null) and (sort == 'desc' or sort == 'asc')">
|
|
|
|
order by ${orderBy} ${sort}
|
|
|
|
</when>
|
|
|
|
<otherwise>
|
|
|
|
ORDER BY updateTime DESC
|
|
|
|
</otherwise>
|
|
|
|
</choose>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByIds" parameterType="java.util.List">
|
|
|
|
DELETE
|
|
|
|
FROM pur_apply WHERE id in
|
|
|
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
|
|
|
#{item}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteById" parameterType="long">
|
|
|
|
DELETE
|
|
|
|
FROM pur_apply
|
|
|
|
WHERE id = #{id}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<update id="update" parameterType="com.glxp.api.entity.purchase.PurApplyEntity">
|
|
|
|
UPDATE pur_apply
|
|
|
|
<trim prefix="set" suffixOverrides=",">
|
|
|
|
<if test="billNo != null">
|
|
|
|
billNo=#{billNo},
|
|
|
|
</if>
|
|
|
|
<if test="billDate != null">
|
|
|
|
billDate=#{billDate},
|
|
|
|
</if>
|
|
|
|
<if test="status != null">
|
|
|
|
status=#{status},
|
|
|
|
</if>
|
|
|
|
<if test="billType != null">
|
|
|
|
billType=#{billType},
|
|
|
|
</if>
|
|
|
|
<if test="remark != null">
|
|
|
|
remark=#{remark},
|
|
|
|
</if>
|
|
|
|
<if test="invCode != null">
|
|
|
|
invCode=#{invCode},
|
|
|
|
</if>
|
|
|
|
<if test="deptCode != null">
|
|
|
|
deptCode=#{deptCode},
|
|
|
|
</if>
|
|
|
|
<if test="auditUser != null">
|
|
|
|
auditUser=#{auditUser},
|
|
|
|
</if>
|
|
|
|
<if test="auditTime != null">
|
|
|
|
auditTime=#{auditTime},
|
|
|
|
</if>
|
|
|
|
<if test="createUser != null">
|
|
|
|
createUser=#{createUser},
|
|
|
|
</if>
|
|
|
|
<if test="createTime != null">
|
|
|
|
createTime=#{createTime},
|
|
|
|
</if>
|
|
|
|
<if test="updateTime != null">
|
|
|
|
updateTime=#{updateTime},
|
|
|
|
</if>
|
|
|
|
<if test="updateUser != null">
|
|
|
|
updateUser=#{updateUser},
|
|
|
|
</if>
|
|
|
|
<if test="auditRemark != null">
|
|
|
|
auditRemark=#{auditRemark},
|
|
|
|
</if>
|
|
|
|
<if test="targetInvCode != null">
|
|
|
|
targetInvCode=#{targetInvCode},
|
|
|
|
</if>
|
|
|
|
<if test="targetDeptCode != null">
|
|
|
|
targetDeptCode=#{targetDeptCode},
|
|
|
|
</if>
|
|
|
|
<if test="planBillNo != null">
|
|
|
|
planBillNo=#{planBillNo},
|
|
|
|
</if>
|
|
|
|
<if test="generatePlan != null">
|
|
|
|
generatePlan=#{generatePlan},
|
|
|
|
</if>
|
|
|
|
<if test="emergency != null">
|
|
|
|
emergency=#{emergency},
|
|
|
|
</if>
|
|
|
|
<if test="arrivalTime != null">
|
|
|
|
arrivalTime=#{arrivalTime},
|
|
|
|
</if>
|
|
|
|
<if test="approvalFlowId != null">
|
|
|
|
approvalFlowId=#{approvalFlowId},
|
|
|
|
</if>
|
|
|
|
</trim>
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
</mapper>
|