<?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.mandi.fendan.mapper.Fd_XSTDMXMapper">
|
<sql id="whereSql">
|
<if test="tdls !=null and tdls !='' ">
|
and a.tdmx_tdls = #{tdls}
|
</if>
|
<if test="fdywdh !=null and fdywdh !='' ">
|
and a.tdmx_fdywdh = #{fdywdh}
|
</if>
|
<if test="pch !=null and pch !='' ">
|
and a.tdmx_pch = #{pch}
|
</if>
|
<if test="zcbz !=null ">
|
and a.tdmx_sfzc = #{zcbz}
|
</if>
|
<!-- 为空,都可见;不为空,只有可见 -->
|
<if test=" companyNo !=null and companyNo !='' ">
|
and case when NOT EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdls = a.tdmx_tdls) then 1 <!-- 全部没分 -->
|
when EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdfl = a.tdmx_tdfl AND wlgs_no = #{companyNo} ) then 1 <!-- 分给一个人 -->
|
when not EXISTS ( SELECT * FROM fd_mx_wlgs WHERE tdmx_tdfl = a.tdmx_tdfl) and tdmx_fdwlgsbh is null then 1 <!-- 某一个没有分且没人领,全部可见 -->
|
when tdmx_fdwlgsbh =#{companyNo} then 1 <!-- 自己领的 -->
|
end >0
|
</if>
|
</sql>
|
|
<select id="getList" parameterType="java.util.Map" resultType="java.util.Map">
|
<choose>
|
<when test="pagesize > 0 ">
|
select top ${pagesize} *
|
</when>
|
<otherwise>
|
select *
|
</otherwise>
|
</choose>
|
from ( select row_number()
|
<choose>
|
<when test="sort !=null and sort!='' ">
|
over (order by ${sort} )
|
</when>
|
<otherwise>
|
over (order by a.tdmx_tdfl desc )
|
</otherwise>
|
</choose>
|
as rownumber,ISNULL(fdc.name, fdcmx.name) mxwlgsName, isnull(fdc.companyNo,tdmx_fdwlgsbh)
|
mxwlgsNo,CONVERT(varchar(100), fdb.ctime, 120) ctime,DATEDIFF (mi,fdb.ctime,getdate()) timeMinus ,
|
(select count(1) from bussinesssheet where exists (
|
select top 1 * from ACT_HI_TASKINST where NAME_ = 'issue_card' and PROC_INST_ID_ = instanceId and (DELETE_REASON_ ='completed' or end_time_ is not null)
|
) and bussinessNo = a.tdmx_fdywbh) fkStatus,
|
a.*
|
from xstdmx_view a
|
left join fd_mx_wlgs mxwl on mxwl.tdmx_tdfl = a.tdmx_tdfl
|
left join fd_company fdc on mxwl.wlgs_no=fdc.companyNo
|
left join fd_bsheet fdb on fdb.bsNo = a.tdmx_fdywbh
|
left join fd_company fdcmx on a.tdmx_fdwlgsbh=fdcmx.companyNo
|
<where>
|
<include refid="whereSql"></include>
|
</where>
|
) as a where rownumber > #{pagesize}*#{page}
|
|
</select>
|
|
<select id="countPage" parameterType="Map" resultType="int">
|
select count(1) from xstdmx_view a
|
<where>
|
<include refid="whereSql"></include>
|
</where>
|
</select>
|
</mapper>
|