You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-wms-java/src/main/resources/mybatis/mapper/purchase/PurPlanDao.xml

115 lines
4.6 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.glxp.api.dao.purchase.PurPlanDao">
<select id="queryPageList" parameterType="com.glxp.api.req.purchase.PurPlanRequest"
resultType="com.glxp.api.res.purchase.PurPlanResponse">
SELECT IFNULL(saf.status,1) as flowStatus,saf.updateTime as flowAuditTime,saf.updateUserName as flowAuditByName,
pur_plan.*,
cb.employeeName createUserName,
ab.employeeName auditUserName,
db.employeeName applyCreateBy,
auth_warehouse.NAME invName,
aw1.name applyInvName,
auth_dept.`name` deptName
FROM pur_plan
LEFT JOIN auth_user cb ON pur_plan.createUser = cb.id
LEFT JOIN auth_user ab ON pur_plan.auditUser = ab.id
LEFT JOIN auth_user db ON pur_plan.applyCreateUser = db.id
LEFT JOIN auth_warehouse ON pur_plan.invCode = auth_warehouse.`code`
LEFT JOIN auth_dept ON auth_dept.CODE = pur_plan.deptCode
left join auth_warehouse aw1 on pur_plan.applyInv = aw1.`code`
Left Join sys_approval_flow as saf ON pur_plan.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_plan.createTime, '%Y-%m-%d') >= #{startDate}
]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[
and DATE_FORMAT(pur_plan.createTime, '%Y-%m-%d') <= #{endDate}
]]>
</if>
<if test="startAuditDate != null and startAuditDate != ''">
<![CDATA[
and DATE_FORMAT(pur_plan.auditTime, '%Y-%m-%d') >= #{startAuditDate}
]]>
</if>
<if test="endAuditDate != null and endAuditDate != ''">
<![CDATA[
and DATE_FORMAT(pur_plan.auditTime, '%Y-%m-%d') <= #{endAuditDate}
]]>
</if>
<if test="!sysApprovalFlow">
<if test="status != null and status != 10 and status != 11 and status != 12 ">
and pur_plan.status = #{status}
</if>
<if test="status == 10">
and (pur_plan.status = 2 )
</if>
<if test="status == 11">
and (pur_plan.status = 1 or pur_plan.status = 2 or pur_plan.status = 4)
</if>
<if test="status == 12">
and (pur_plan.status = 3)
</if>
</if>
<if test="sysApprovalFlow">
<if test="status != null and status != 10 and status != 11 and status != 12 ">
and saf.status = #{status}
</if>
<if test="status == 10">
and (saf.status = 2)
</if>
<if test="status == 11">
and (saf.status = 1 or saf.status = 2 or saf.status = 4 or saf.status is null)
</if>
<if test="status == 12">
and (saf.status = 3)
</if>
</if>
<if test="deptCode != '' and deptCode != null">
AND deptCode = #{deptCode}
</if>
<if test="invCode != '' and invCode != null">
AND invCode = #{invCode}
</if>
<if test="auditUser != '' and auditUser != null">
AND auditUser = #{auditUser}
</if>
<if test="createUser != '' and createUser != null">
AND createUser = #{createUser}
</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 pur_plan.updateTime DESC
</otherwise>
</choose>
</select>
<delete id="deleteByIds" parameterType="java.util.List">
DELETE
FROM pur_plan WHERE id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</mapper>